-- Register workflows tool in ai_tool_registry
INSERT INTO ai_tool_registry (name, description, definition, is_active, tool_mode)
VALUES (
'workflows',
'Manage automation workflows: create multi-step DAGs with branching, webhooks, conditions, and data flow between steps. Actions: list, get, create, update, delete (workflow CRUD); add_step, update_step, delete_step (step management); start, pause, resume, cancel (run control); runs, step_runs (execution history); analytics (performance metrics); create_webhook, list_webhooks, delete_webhook (webhook endpoints).',
'{
"description": "Manage automation workflows: create multi-step DAGs with branching, webhooks, conditions, and data flow between steps.",
"input_schema": {
"type": "object",
"properties": {
"action": {
"type": "string",
"description": "Action to perform. Workflow CRUD: list, get, create, update, delete. Step management: add_step, update_step, delete_step. Run control: start, pause, resume, cancel. History: runs, step_runs. Metrics: analytics. Webhooks: create_webhook, list_webhooks, delete_webhook.",
"enum": ["list", "get", "create", "update", "delete", "add_step", "update_step", "delete_step", "start", "pause", "resume", "cancel", "runs", "step_runs", "analytics", "create_webhook", "list_webhooks", "delete_webhook"]
},
"workflow_id": {
"type": "string",
"description": "Workflow UUID (for get, update, delete, start, add_step, create_webhook)"
},
"name": {
"type": "string",
"description": "Workflow or webhook name (for create)"
},
"description": {
"type": "string",
"description": "Description text"
},
"status": {
"type": "string",
"description": "Workflow status: draft, active, paused, archived. Filter for list or set for update.",
"enum": ["draft", "active", "paused", "archived"]
},
"trigger_type": {
"type": "string",
"description": "Trigger type: event, schedule, condition, webhook, manual, api",
"enum": ["event", "schedule", "condition", "webhook", "manual", "api"]
},
"trigger_config": {
"type": "object",
"description": "Trigger-specific config (e.g. cron expression, event name)"
},
"steps": {
"type": "array",
"description": "Array of step definitions for create. Each: {step_key, step_type, is_entry_point, on_success, on_failure, step_config, max_retries, timeout_seconds}. step_type: tool|condition|transform|delay|webhook_out|parallel|noop. step_config for tool: {tool_name, args_template}. For condition: {expression, on_true, on_false}. For delay: {seconds}. Data flows via {{steps.step_key.output.field}} templates."
},
"step_key": {
"type": "string",
"description": "Unique step key within workflow (for add_step)"
},
"step_type": {
"type": "string",
"description": "Step type: tool, condition, transform, delay, webhook_out, parallel, noop"
},
"step_config": {
"type": "object",
"description": "Step-specific config. Tool: {tool_name, args_template}. Condition: {expression, on_true, on_false}. Transform: {mapping}. Delay: {seconds}. Webhook: {url, method, headers, body_template}"
},
"is_entry_point": {
"type": "boolean",
"description": "Whether this is the first step (for add_step)"
},
"on_success": {
"type": "string",
"description": "Step key to go to on success (null = end workflow)"
},
"on_failure": {
"type": "string",
"description": "Step key to go to on failure (null = fail workflow)"
},
"step_id": {
"type": "string",
"description": "Step UUID (for update_step, delete_step)"
},
"run_id": {
"type": "string",
"description": "Run UUID (for pause, resume, cancel, step_runs)"
},
"trigger_payload": {
"type": "object",
"description": "Payload to pass to workflow run (for start)"
},
"idempotency_key": {
"type": "string",
"description": "Prevent duplicate runs (for start)"
},
"max_concurrent_runs": {
"type": "integer",
"description": "Max parallel runs (default 1)"
},
"max_retries": {
"type": "integer",
"description": "Max retry attempts per step (default 3)"
},
"timeout_seconds": {
"type": "integer",
"description": "Step timeout in seconds (default 60)"
},
"slug": {
"type": "string",
"description": "Webhook URL slug (for create_webhook). URL: https://whale-agent.fly.dev/webhooks/<slug>"
},
"webhook_id": {
"type": "string",
"description": "Webhook UUID (for delete_webhook)"
},
"days": {
"type": "integer",
"description": "Analytics period in days (default 30)"
},
"limit": {
"type": "integer",
"description": "Max results (default 25-50)"
}
},
"required": ["action"]
}
}'::jsonb,
true,
'ops'
)
ON CONFLICT (name) DO UPDATE SET
description = EXCLUDED.description,
definition = EXCLUDED.definition,
is_active = true,
tool_mode = 'ops';