diff --git a/skills/index.js b/skills/index.js index c4f6167e..e3d738e1 100644 --- a/skills/index.js +++ b/skills/index.js @@ -341,7 +341,7 @@ export const SKILLS_CATALOG = [ "issue automation", "/automation:create" ], - "content": "# OpenHands Automations\n\nCreate and manage automations that run inside an OpenHands agent server — triggered by cron schedules or webhook events (GitHub, custom services).\n\n## Automation Creation Process\nThe agent must follow these steps when creating an automation:\n* Quickly check that you can access the correct automations backend using the auth mechanism below\n* Quickly check that you can access any necessary integrations (e.g. GitHub, Slack); if access fails, inform the user and stop\n* Ask the user for any necessary information, e.g. if you need the name of a Slack channel or GitHub repo to proceed\n* Write the code or prompt that will be sent to the automations backend _inside the current workspace_\n* Show the code to the user with the `canvas_ui` tool if available, otherwise present it in a fenced code block in your reply\n* Message the user with a concise summary of how the automation will behave, and ask if they are ready to deploy it\n\n## Architecture\n\nTwo components work together to run automations:\n\n**Automation Service** (API at `OPENHANDS_HOST/api/automation/v1`)\nManages the *when*: holds automation definitions, schedules cron-triggered runs, dispatches webhook-triggered runs, and receives completion callbacks to mark runs as done. This is the API you call to create, update, and manage automations.\n\n**Agent Server** (accessible as `AGENT_SERVER_URL` inside script runs)\nManages the *what*: the runtime environment where automation scripts execute and where conversations (AI agent interactions with tools, bash, file editing, etc.) run. When a run is triggered, the automation service uploads the automation's tarball to the agent server, which unpacks and runs the entrypoint script. The script connects back to the agent server using `AGENT_SERVER_URL` and a session API key to start, monitor, and stop conversations.\n\nThe agent server typically runs inside a **sandbox** (a Docker or Kubernetes container). Some deployments use sandboxless mode, where the agent server runs directly on a host.\n\n**Key environment variables:**\n\n| Variable | Availability | Description |\n|---|---|---|\n| `RUNTIME_URL` | Ambient in cloud environments | Public-facing URL of the **agent server** sandbox. Use this to determine whether external webhook delivery is possible — if unset or local, webhooks cannot be received. The automation service may run at a separate URL (see Determining the API Host). |\n| `AGENT_SERVER_URL` | Injected into scripts at run time only | Internal URL of the agent server. Available inside script execution context; **not** an ambient environment variable outside of a running script. |\n| `OPENHANDS_HOST` | Shell convention only — set manually | Base URL for the automation service API. **Not a real environment variable.** Set it from the `` system-prompt value, or default to `https://app.all-hands.dev`. Used in all `curl` examples throughout this skill. |\n\n> **⚠️ CRITICAL — Agent behavior rules:**\n>\n> 0. **Does this task need an LLM at all? Check first.** Before picking a preset, ask whether the task actually requires reasoning, judgment, summarization, or open-ended tool use. If it is fully deterministic — fixed data transforms, scheduled HTTP calls, healthcheck pings, file rotation, picking from a known list, posting a templated message — an LLM-driven preset is overkill. Every run will consume LLM tokens, which adds up fast at high frequencies (every 5 min ≈ 288 runs/day). Surface the trade-off to the user and offer the custom-script path (see `references/custom-automation.md`) as the cheaper, more reliable option. Be especially careful for cron schedules tighter than hourly.\n>\n> **Instant-recognition patterns — these are always deterministic, never use an LLM preset:**\n> - \"post a quote / message / fact every N minutes\" (rotating from a list)\n> - \"send a scheduled reminder / standup / digest\"\n> - \"ping a health-check URL on a schedule\"\n> - \"post to Slack / webhook every N minutes\"\n> - Any task where the full output could be written as a static template right now\n>\n> 1. **For LLM-appropriate work, default to preset endpoints.** They handle all SDK boilerplate, tarball packaging, and upload automatically:\n> - **Prompt preset** (`POST /v1/preset/prompt`) — for tasks expressed as a natural language prompt that benefit from agent reasoning\n> - **Plugin preset** (`POST /v1/preset/plugin`) — when plugins with skills, MCP configs, or commands are needed\n> 2. **Do not silently create custom scripts.** Do not generate Python code, `setup.sh` files, or tarball uploads without user consent. But *do* proactively recommend the custom path (per rule 0) when the task is deterministic or high-frequency — surface the option and let the user choose.\n> 3. **If neither preset is the right fit**, do NOT silently fall back to custom automation. Instead, explain the available options to the user:\n> - **Prompt preset** — natural language prompt execution (LLM-driven)\n> - **Plugin preset** — load plugins with extended capabilities (skills, MCP, hooks, commands)\n> - **Custom script** — full control over code, with or without LLM; point them to `references/custom-automation.md`\n> - Let the user choose which approach to use.\n> 4. **Only create custom scripts after the user agrees to that path.** Refer to `references/custom-automation.md` for the full reference.\n> 5. **Before suggesting event-triggered (webhook) automations, check whether the deployment is publicly reachable.** Check `RUNTIME_URL`. Webhooks require an internet-accessible URL so that external services (GitHub, Slack, Linear, etc.) can deliver events to the automation service. If `RUNTIME_URL` is unset, empty, or resolves to a local or private address (`localhost`, `127.0.0.1`, `0.0.0.0`, or any RFC 1918 range: `10.x.x.x`, `192.168.x.x`, `172.16–31.x.x`), the service cannot receive inbound webhook traffic from the public internet. In that case:\n> - **Recommend a cron-based polling automation instead.** Have the automation run on a schedule and call the external service's API (e.g., the GitHub REST API) to check for new events since the last run.\n> - Explain the limitation clearly to the user: \"Because this is a local deployment, external services can't reach the webhook endpoint. I'll set up a polling automation using a cron schedule instead.\"\n\n### No-LLM Script Helpers\n\nWhen building a deterministic custom script, these two stdlib-only functions are required. Copy them verbatim — they use `AGENT_SERVER_URL` and `SESSION_API_KEY` injected by the automation service.\n\n```python\nimport json, os, urllib.request\n\ndef get_secret(name):\n \"\"\"Fetch a named secret stored in the agent server.\"\"\"\n url = os.environ.get(\"AGENT_SERVER_URL\", \"\").rstrip(\"/\")\n key = os.environ.get(\"SESSION_API_KEY\") or os.environ.get(\"OH_SESSION_API_KEYS_0\", \"\")\n with urllib.request.urlopen(urllib.request.Request(\n f\"{url}/api/settings/secrets/{name}\", headers={\"X-Session-API-Key\": key}\n )) as r:\n return r.read().decode().strip()\n\ndef fire_callback(status=\"COMPLETED\", error=None):\n \"\"\"Signal run completion. MUST be called on every exit path — success AND error.\"\"\"\n url = os.environ.get(\"AUTOMATION_CALLBACK_URL\", \"\")\n if not url: return\n body = {\"status\": status, \"run_id\": os.environ.get(\"AUTOMATION_RUN_ID\", \"\")}\n if error: body[\"error\"] = error\n try:\n urllib.request.urlopen(urllib.request.Request(url, data=json.dumps(body).encode(), headers={\n \"Content-Type\": \"application/json\",\n \"Authorization\": f\"Bearer {os.environ.get('AUTOMATION_CALLBACK_API_KEY', '')}\",\n }))\n except Exception as e: print(f\"Callback error: {e}\")\n```\n\nEntrypoint must be `python3 main.py` (no `setup.sh` needed). Wrap your main logic in `try/except` and call `fire_callback(\"FAILED\", str(e))` in the except block.\n\n**State persistence between runs** — polling automations that track a \"last processed\" timestamp or active conversation IDs must use the built-in KV store rather than local files. Local files are lost when a run ends on a cloud pod. The KV store is available when `AUTOMATION_KV_TOKEN` is injected into the run environment. See `references/custom-automation.md#state-persistence-kv-store` for ready-to-copy `kv_get` / `kv_set` / `load_state` / `save_state` helpers.\n\n---\n\n## Authentication\n\nAll requests require Bearer authentication:\n\n```bash\n-H \"Authorization: Bearer ${OPENHANDS_API_KEY}\"\n```\n\n## API Endpoints\n\n### Determining the API Host\n\n**Before making API calls, determine the correct host:**\n\nThe automation service may run at a different URL from the agent server. In the examples throughout this skill, `${OPENHANDS_HOST}` is a shell-variable convention for the automation service base URL — it is **not** a real environment variable. Set it from context before running any curl command:\n\n- Look for a `` value in the system prompt. If present, use that URL.\n- Otherwise default to `https://app.all-hands.dev`.\n\n```bash\nOPENHANDS_HOST=\"https://app.all-hands.dev\" # replace with if provided\n```\n\n\n### Automation Endpoints\n\n| Endpoint | Method | Description |\n|----------|--------|-------------|\n| `/api/automation/v1/preset/prompt` | POST | **Create automation from a prompt (recommended)** |\n| `/api/automation/v1/preset/plugin` | POST | **Create automation with plugins** |\n| `/api/automation/v1` | GET | List automations |\n| `/api/automation/v1/{id}` | GET | Get automation details |\n| `/api/automation/v1/{id}` | PATCH | Update automation |\n| `/api/automation/v1/{id}` | DELETE | Delete automation |\n| `/api/automation/v1/{id}/dispatch` | POST | Trigger a run manually |\n| `/api/automation/v1/{id}/runs` | GET | List automation runs |\n\n### Custom Webhook Endpoints\n\n| Endpoint | Method | Description |\n|----------|--------|-------------|\n| `/api/automation/v1/webhooks` | POST | Register a custom webhook source |\n| `/api/automation/v1/webhooks` | GET | List all custom webhooks |\n| `/api/automation/v1/webhooks/{id}` | GET | Get webhook details |\n| `/api/automation/v1/webhooks/{id}` | PATCH | Update webhook settings |\n| `/api/automation/v1/webhooks/{id}` | DELETE | Delete a webhook |\n| `/api/automation/v1/webhooks/{id}/rotate-secret` | POST | Rotate signing secret |\n\n---\n\n## Trigger Types\n\nAutomations support two trigger types:\n\n| Trigger Type | Use Case |\n|--------------|----------|\n| **Cron** | Run on a schedule (daily, weekly, hourly, etc.) |\n| **Event** | Run when a webhook event occurs (GitHub PR opened, issue commented, etc.) — **requires a publicly reachable deployment** |\n\n---\n\n## Creating Automations\n\nTwo preset endpoints simplify automation creation by handling SDK boilerplate, tarball packaging, and upload automatically:\n\n1. **Prompt Preset** — Execute a natural language prompt (simple tasks)\n2. **Plugin Preset** — Load plugins with skills, MCP configs, and commands (extended capabilities)\n\n---\n\n### Prompt Preset\n\nUse the **preset/prompt endpoint** for simple automations. Provide a natural language prompt describing the task.\n\n#### How It Works\n\n1. Send a prompt describing the task (e.g., \"Generate a weekly status report\")\n2. The automation service generates a Python script that: fetches LLM config and secrets from the agent server, starts an AI agent conversation with your prompt, and sends a completion callback when done\n3. The script is packaged as a tarball and the automation is registered; on each trigger, the automation service uploads the tarball to the agent server, which unpacks and runs the script inside its environment\n\n#### Request\n\n```bash\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/preset/prompt\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"My Automation Name\",\n \"prompt\": \"What the automation should do\",\n \"trigger\": {\n \"type\": \"cron\",\n \"schedule\": \"0 9 * * *\",\n \"timezone\": \"UTC\"\n }\n }'\n```\n\n#### Request Fields\n\n| Field | Required | Description |\n|-------|----------|-------------|\n| `name` | Yes | Name of the automation (1-500 characters) |\n| `prompt` | Yes | Natural language instructions (1-50,000 characters) |\n| `trigger` | Yes | Trigger configuration — either `cron` or `event` (see below) |\n| `timeout` | No | Max execution time in seconds (default: system maximum) |\n| `repos` | No | Repositories to clone (see [Repository Cloning](#repository-cloning)) |\n\n**Cron Trigger Fields:**\n\n| Field | Required | Description |\n|-------|----------|-------------|\n| `trigger.type` | Yes | `\"cron\"` |\n| `trigger.schedule` | Yes | Cron expression (5 fields: min hour day month weekday) |\n| `trigger.timezone` | No | IANA timezone (default: `\"UTC\"`) |\n\n**Event Trigger Fields:**\n\n| Field | Required | Description |\n|-------|----------|-------------|\n| `trigger.type` | Yes | `\"event\"` |\n| `trigger.source` | Yes | Event source: `\"github\"` or custom webhook source name |\n| `trigger.on` | Yes | Event key pattern(s) to match (see Event Keys below) |\n| `trigger.filter` | No | JMESPath expression for payload filtering (see Filter Expressions below) |\n\n#### Prompt Tips\n\nWrite the prompt as an instruction to an AI agent. The prompt executes inside a sandbox with full tool access (bash, file editing, etc.), the user's configured LLM, stored secrets, and MCP server integrations. Examples:\n\n- `\"Generate a weekly status report summarizing the team's GitHub activity and post it to Slack\"`\n- `\"Check the production API health endpoint every hour and alert if it returns non-200\"`\n- `\"Pull the latest data from our analytics API and update the dashboard spreadsheet\"`\n\n#### Cron Schedule\n\n| Field | Values | Description |\n|-------|--------|-------------|\n| Minute | 0-59 | Minute of the hour |\n| Hour | 0-23 | Hour of the day (24-hour) |\n| Day | 1-31 | Day of the month |\n| Month | 1-12 | Month of the year |\n| Weekday | 0-6 | Day of week (0=Sun, 6=Sat) |\n\nCommon schedules: `0 9 * * *` (daily 9 AM), `0 9 * * 1-5` (weekdays 9 AM), `0 9 * * 1` (Mondays 9 AM), `0 0 1 * *` (first of month), `*/15 * * * *` (every 15 min), `0 */6 * * *` (every 6 hours).\n\n#### Response (HTTP 201)\n\n```json\n{\n \"id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"name\": \"My Automation Name\",\n \"trigger\": {\"type\": \"cron\", \"schedule\": \"0 9 * * *\", \"timezone\": \"UTC\"},\n \"enabled\": true,\n \"created_at\": \"2025-03-25T10:00:00Z\"\n}\n```\n\n#### Prompt Preset Examples\n\n**Daily report:**\n```bash\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/preset/prompt\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"Daily Report\",\n \"prompt\": \"Generate a daily status report and save it to a file in the workspace\",\n \"trigger\": {\"type\": \"cron\", \"schedule\": \"0 9 * * 1-5\", \"timezone\": \"America/New_York\"}\n }'\n```\n\n**Weekly cleanup:**\n```bash\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/preset/prompt\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"Weekly Cleanup\",\n \"prompt\": \"Clean up temporary files older than 7 days and send a summary of what was removed\",\n \"trigger\": {\"type\": \"cron\", \"schedule\": \"0 2 * * 0\", \"timezone\": \"UTC\"},\n \"timeout\": 300\n }'\n```\n\n---\n\n## Polling as a Webhook Alternative\n\nWhen the deployment cannot receive inbound webhook traffic (see rule 5), use a cron-triggered automation that calls the external service’s API on a schedule to check for new events.\n\n### Polling vs. Webhooks at a Glance\n\n| | Webhooks (Event trigger) | Polling (Cron trigger) |\n|---|---|---|\n| **Requires public URL** | Yes | No — works locally |\n| **Latency** | Near-instant | Up to one poll interval |\n| **API calls** | Only on real events | Every poll interval |\n| **Best for** | Cloud / public deployments | Local or private deployments |\n\n---\n\n## Event-Triggered Automations (Webhooks)\n\nEvent-triggered automations run when a webhook event occurs — like a GitHub PR being opened, an issue receiving a comment, or a custom service sending a notification.\n\n### Built-in Integrations\n\n**GitHub** is a built-in integration — no webhook registration needed. Just create automations with `\"source\": \"github\"`.\n\n### GitHub Event Keys\n\nEvents use the format `{event_type}.{action}` or just `{event_type}` (for events without actions like `push`).\n\n| Event Type | Event Keys | Description |\n|------------|------------|-------------|\n| `pull_request` | `pull_request.opened`, `pull_request.closed`, `pull_request.synchronize`, `pull_request.labeled`, `pull_request.unlabeled`, `pull_request.reopened`, `pull_request.edited`, `pull_request.ready_for_review` | PR activity |\n| `issues` | `issues.opened`, `issues.closed`, `issues.reopened`, `issues.labeled`, `issues.unlabeled`, `issues.edited`, `issues.assigned` | Issue activity |\n| `issue_comment` | `issue_comment.created`, `issue_comment.edited`, `issue_comment.deleted` | Comments on issues/PRs |\n| `push` | `push` | Code pushed to a branch |\n| `release` | `release.published`, `release.created`, `release.released`, `release.prereleased` | Release activity |\n| `pull_request_review` | `pull_request_review.submitted`, `pull_request_review.edited`, `pull_request_review.dismissed` | PR review activity |\n\n**Wildcards:** Use `*` to match any action — e.g., `pull_request.*` matches all PR events.\n\n**Multiple patterns:** The `on` field can be a string or array — e.g., `[\"push\", \"pull_request.opened\"]`.\n\n### Filter Expressions (JMESPath)\n\nFilters let you match events based on payload content using JMESPath expressions.\n\n#### Available Functions\n\n| Function | Description | Example |\n|----------|-------------|---------|\n| `glob(str, pattern)` | Wildcard pattern matching | `glob(repository.full_name, 'myorg/*')` |\n| `icontains(str, substr)` | Case-insensitive substring | `icontains(comment.body, '@openhands')` |\n| `contains(array, value)` | Array contains value | `contains(pull_request.labels[].name, 'bug')` |\n| `regex(str, pattern)` | Regular expression match | `regex(ref, '^refs/tags/v\\\\d+')` |\n| `starts_with(str, prefix)` | String starts with | `starts_with(ref, 'refs/heads/')` |\n| `ends_with(str, suffix)` | String ends with | `ends_with(ref, '/main')` |\n| `lower(str)` / `upper(str)` | Case conversion | `lower(sender.login) == 'admin'` |\n\n#### Boolean Operators\n\n- `&&` — AND\n- `||` — OR \n- `!` — NOT\n\n#### Filter Examples\n\n```javascript\n// Exact match on label name\n\"contains(pull_request.labels[].name, 'openhands')\"\n\n// Case-insensitive mention in comment\n\"icontains(comment.body, '@openhands')\"\n\n// Match specific repository\n\"repository.full_name == 'myorg/myrepo'\"\n\n// Match any repo in an org\n\"glob(repository.full_name, 'myorg/*')\"\n\n// PR with 'bug' label in any org repo\n\"glob(repository.full_name, 'myorg/*') && contains(pull_request.labels[].name, 'bug')\"\n\n// Push to main or release branches\n\"glob(ref, 'refs/heads/main') || glob(ref, 'refs/heads/release/*')\"\n\n// Issue opened by a specific user\n\"sender.login == 'dependabot[bot]'\"\n\n// Not a draft PR\n\"!pull_request.draft\"\n```\n\n---\n\n### Event-Triggered Examples\n\n#### GitHub: Respond to @openhands mentions in comments\n\n```bash\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/preset/prompt\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"OpenHands Mention Responder\",\n \"prompt\": \"Analyze the issue or PR context and provide a helpful response to the user'\\''s question. The comment body and context are available in the event payload.\",\n \"trigger\": {\n \"type\": \"event\",\n \"source\": \"github\",\n \"on\": \"issue_comment.created\",\n \"filter\": \"icontains(comment.body, '\\''@openhands'\\'')\"\n },\n \"timeout\": 300\n }'\n```\n\n#### GitHub: Auto-review PRs with the \"openhands\" label\n\n```bash\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/preset/prompt\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"Auto Review PRs\",\n \"prompt\": \"Review this pull request for code quality, potential bugs, and best practices. Provide constructive feedback.\",\n \"trigger\": {\n \"type\": \"event\",\n \"source\": \"github\",\n \"on\": \"pull_request.labeled\",\n \"filter\": \"contains(pull_request.labels[].name, '\\''openhands'\\'')\"\n }\n }'\n```\n\n#### GitHub: Run tests on push to main\n\n```bash\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/preset/prompt\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"Run Tests on Main\",\n \"prompt\": \"Clone the repository and run the test suite. Report any failures.\",\n \"trigger\": {\n \"type\": \"event\",\n \"source\": \"github\",\n \"on\": \"push\",\n \"filter\": \"ref == '\\''refs/heads/main'\\''\"\n }\n }'\n```\n\n#### GitHub: Triage new issues in specific repos\n\n```bash\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/preset/prompt\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"Issue Triage Bot\",\n \"prompt\": \"Analyze this new issue and suggest appropriate labels. If it looks like a bug, try to identify the root cause.\",\n \"trigger\": {\n \"type\": \"event\",\n \"source\": \"github\",\n \"on\": \"issues.opened\",\n \"filter\": \"glob(repository.full_name, '\\''myorg/*'\\'')\"\n }\n }'\n```\n\n#### GitHub: Respond to multiple event types\n\n```bash\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/preset/prompt\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"PR Activity Bot\",\n \"prompt\": \"Process the PR event and take appropriate action based on the event type.\",\n \"trigger\": {\n \"type\": \"event\",\n \"source\": \"github\",\n \"on\": [\"pull_request.opened\", \"pull_request.synchronize\", \"pull_request.ready_for_review\"]\n }\n }'\n```\n\n---\n\n## Custom Webhooks\n\nFor services other than GitHub (Linear, Stripe, Slack, etc.), register a custom webhook first.\n\n> **Agent behavior:**\n> - **Always provide the curl request** to the user — do not attempt to register webhooks yourself.\n> - **Ask the user:** \"Do you have a webhook signing secret from [service], or should the system generate one?\"\n> - If they have one → include `webhook_secret` in the request\n> - If not → omit it; the response will contain a generated secret they must configure in their service\n\n### Register a Custom Webhook\n\n```bash\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/webhooks\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"Linear Issues\",\n \"source\": \"linear\",\n \"event_key_expr\": \"type\",\n \"signature_header\": \"Linear-Signature\",\n \"webhook_secret\": \"your-linear-webhook-secret\"\n }'\n```\n\n#### Webhook Fields\n\n| Field | Required | Description |\n|-------|----------|-------------|\n| `name` | Yes | Human-readable name for the webhook |\n| `source` | Yes | Unique source identifier (lowercase, alphanumeric with hyphens, 1-50 chars) |\n| `event_key_expr` | No | JMESPath expression to extract event type from payload (default: `\"type\"`) |\n| `signature_header` | No | HTTP header containing HMAC signature (default: `\"X-Signature-256\"`) |\n| `webhook_secret` | No | Signing secret — provide your own (from the external service) or let the system generate one |\n\n#### Response\n\n```json\n{\n \"id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"webhook_url\": \"https://app.all-hands.dev/v1/events/{org_id}/linear\",\n \"source\": \"linear\",\n \"enabled\": true\n}\n```\n\n**Note:** When you provide your own `webhook_secret`, it won't be echoed back in the response. If you don't provide one, the system generates a secret and returns it once — store it securely.\n\n### Manage Custom Webhooks\n\n```bash\n# List all webhooks\ncurl \"${OPENHANDS_HOST}/api/automation/v1/webhooks\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\"\n\n# Update a webhook\ncurl -X PATCH \"${OPENHANDS_HOST}/api/automation/v1/webhooks/{webhook_id}\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"enabled\": false}'\n\n# Rotate the signing secret\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/webhooks/{webhook_id}/rotate-secret\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\"\n\n# Delete a webhook\ncurl -X DELETE \"${OPENHANDS_HOST}/api/automation/v1/webhooks/{webhook_id}\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\"\n```\n\n### Custom Webhook Example: Linear\n\nLinear sends webhooks with:\n- Signature header: `Linear-Signature`\n- Event type in payload: `type` field (e.g., `Issue`, `Comment`, `Project`)\n- Action in payload: `action` field (e.g., `create`, `update`, `remove`)\n\n```bash\n# 1. Register the Linear webhook\n# - Get your webhook signing secret from Linear's webhook settings\n# - Use \"Linear-Signature\" as the signature header\n# - Use \"type\" to extract the event type from the payload\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/webhooks\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"Linear Issues\",\n \"source\": \"linear\",\n \"event_key_expr\": \"type\",\n \"signature_header\": \"Linear-Signature\",\n \"webhook_secret\": \"lin_wh_xxxxxxxxxxxxx\"\n }'\n\n# Response includes webhook_url — configure this in Linear:\n# Settings → API → Webhooks → New webhook → paste the webhook_url\n\n# 2. Create an automation for new Linear issues\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/preset/prompt\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"Triage New Linear Issues\",\n \"prompt\": \"A new issue was created in Linear. Analyze the issue title and description, suggest appropriate labels, and add a comment with initial triage notes.\",\n \"trigger\": {\n \"type\": \"event\",\n \"source\": \"linear\",\n \"on\": \"Issue\",\n \"filter\": \"action == '\\''create'\\''\"\n }\n }'\n\n# 3. Create an automation for high-priority issue updates\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/preset/prompt\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"High Priority Issue Alert\",\n \"prompt\": \"A high-priority issue was updated. Review the changes and notify the team if action is needed.\",\n \"trigger\": {\n \"type\": \"event\",\n \"source\": \"linear\",\n \"on\": \"Issue\",\n \"filter\": \"action == '\\''update'\\'' && data.priority == `1`\"\n }\n }'\n```\n\n### Common Signature Headers by Service\n\n| Service | Signature Header | Event Key Expression |\n|---------|-----------------|---------------------|\n| Linear | `Linear-Signature` | `type` |\n| Stripe | `Stripe-Signature` | `type` |\n| Slack | `X-Slack-Signature` | `type` |\n| Twilio | `X-Twilio-Signature` | `type` |\n| Generic | `X-Signature-256` | `type` |\n\n---\n\n### Plugin Preset\n\nUse the **preset/plugin endpoint** when you need to load one or more plugins that provide extended capabilities like skills, MCP configurations, hooks, and commands.\n\n> **💡 Finding plugins:** Browse the [OpenHands/extensions](https://github.com/OpenHands/extensions) repository for available skills and plugins. When given a broad use case, check this directory first to see if something already exists that fits your needs.\n\n#### How It Works\n\n1. Specify one or more plugins (from GitHub repos, git URLs, or monorepo subdirectories)\n2. Provide a prompt that can invoke plugin commands (e.g., `/plugin-name:command`)\n3. The service generates SDK boilerplate that loads all plugins at runtime, creates a conversation with plugin capabilities, and executes the prompt\n4. The service packages everything into a tarball, uploads it, and creates the automation\n\n#### Request\n\n```bash\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/preset/plugin\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"My Plugin Automation\",\n \"plugins\": [\n {\"source\": \"github:owner/repo\", \"ref\": \"v1.0.0\"},\n {\"source\": \"github:owner/another-plugin\"}\n ],\n \"prompt\": \"Use the plugin commands to perform the task\",\n \"trigger\": {\n \"type\": \"cron\",\n \"schedule\": \"0 9 * * 1\",\n \"timezone\": \"UTC\"\n }\n }'\n```\n\n#### Request Fields\n\n| Field | Required | Description |\n|-------|----------|-------------|\n| `name` | Yes | Name of the automation (1-500 characters) |\n| `plugins` | Yes | List of plugin sources (at least one required) |\n| `plugins[].source` | Yes | Plugin source: `github:owner/repo`, git URL, or local path |\n| `plugins[].ref` | No | Git ref: branch, tag, or commit SHA |\n| `plugins[].repo_path` | No | Subdirectory path for monorepos |\n| `prompt` | Yes | Instructions for the automation (1-50,000 characters) |\n| `trigger` | Yes | Trigger configuration — either `cron` or `event` (same as Prompt Preset) |\n| `timeout` | No | Max execution time in seconds (default: system maximum) |\n| `repos` | No | Repositories to clone (see [Repository Cloning](#repository-cloning)) |\n\n#### Plugin Source Formats\n\n| Format | Example | Description |\n|--------|---------|-------------|\n| GitHub shorthand | `github:owner/repo` | Fetches from GitHub |\n| Git URL | `https://github.com/owner/repo.git` | Any git repository |\n| With ref | `{\"source\": \"github:owner/repo\", \"ref\": \"v1.0.0\"}` | Specific branch/tag/commit |\n| Monorepo | `{\"source\": \"github:org/monorepo\", \"repo_path\": \"plugins/my-plugin\"}` | Subdirectory in repo |\n\n#### Response (HTTP 201)\n\n```json\n{\n \"id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"name\": \"My Plugin Automation\",\n \"trigger\": {\"type\": \"cron\", \"schedule\": \"0 9 * * 1\", \"timezone\": \"UTC\"},\n \"enabled\": true,\n \"created_at\": \"2025-03-25T10:00:00Z\"\n}\n```\n\n#### Plugin Preset Examples\n\n**Single plugin with version:**\n```bash\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/preset/plugin\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"Code Review Automation\",\n \"plugins\": [\n {\"source\": \"github:owner/code-review-plugin\", \"ref\": \"v2.0.0\"}\n ],\n \"prompt\": \"Review all Python files in the repository for code quality issues\",\n \"trigger\": {\"type\": \"cron\", \"schedule\": \"0 9 * * 1-5\", \"timezone\": \"UTC\"}\n }'\n```\n\n**Multiple plugins:**\n```bash\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/preset/plugin\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"Security Scan Automation\",\n \"plugins\": [\n {\"source\": \"github:owner/security-scanner\"},\n {\"source\": \"github:owner/report-generator\", \"ref\": \"main\"}\n ],\n \"prompt\": \"Run a security scan on the codebase and generate a report\",\n \"trigger\": {\"type\": \"cron\", \"schedule\": \"0 2 * * 0\", \"timezone\": \"UTC\"},\n \"timeout\": 600\n }'\n```\n\n**Monorepo plugin:**\n```bash\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/preset/plugin\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"Style Guide Enforcement\",\n \"plugins\": [\n {\"source\": \"github:company/monorepo\", \"repo_path\": \"plugins/style-guide\", \"ref\": \"main\"}\n ],\n \"prompt\": \"Check all files against the company style guide\",\n \"trigger\": {\"type\": \"cron\", \"schedule\": \"0 8 * * 1\", \"timezone\": \"America/Los_Angeles\"}\n }'\n```\n\n---\n\n## Repository Cloning\n\nBoth presets support an optional `repos` field to clone repositories into the sandbox before execution. Cloned repos have their skills (AGENTS.md, `.agents/skills/`) automatically loaded.\n\n### Repo Source Formats\n\n| Format | Example | Description |\n|--------|---------|-------------|\n| Full URL | `\"https://github.com/owner/repo\"` | Provider auto-detected |\n| Full URL + ref | `{\"url\": \"https://github.com/owner/repo\", \"ref\": \"main\"}` | With branch/tag/SHA |\n| Short URL | `{\"url\": \"owner/repo\", \"provider\": \"github\"}` | Requires `provider` field |\n\n**Supported providers:** `github`, `gitlab`, `bitbucket`\n\n> **Note:** Short URLs (`owner/repo`) require an explicit `provider` field. Full URLs auto-detect the provider.\n\n### Examples\n\n**Single repo (full URL):**\n```json\n{\n \"repos\": [\"https://github.com/OpenHands/openhands-cli\"]\n}\n```\n\n**Multiple repos with refs:**\n```json\n{\n \"repos\": [\n {\"url\": \"https://github.com/owner/repo1\", \"ref\": \"main\"},\n {\"url\": \"https://gitlab.com/owner/repo2\", \"ref\": \"v1.0.0\"}\n ]\n}\n```\n\n**Short URL with provider:**\n```json\n{\n \"repos\": [\n {\"url\": \"owner/repo\", \"provider\": \"github\", \"ref\": \"main\"}\n ]\n}\n```\n\n### Complete Automation Example\n\n```bash\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/preset/prompt\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"Analyze Codebase\",\n \"prompt\": \"Analyze the openhands-cli codebase and generate a summary report\",\n \"trigger\": {\"type\": \"cron\", \"schedule\": \"0 9 * * 1\"},\n \"repos\": [\n {\"url\": \"https://github.com/OpenHands/openhands-cli\", \"ref\": \"main\"}\n ]\n }'\n```\n\n---\n\n## Managing Automations\n\n### List Automations\n\n```bash\ncurl \"${OPENHANDS_HOST}/api/automation/v1?limit=20\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\"\n```\n\n### Get / Update / Delete\n\n```bash\n# Get details\ncurl \"${OPENHANDS_HOST}/api/automation/v1/{automation_id}\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\"\n\n# Update (fields: name, trigger, enabled, timeout)\ncurl -X PATCH \"${OPENHANDS_HOST}/api/automation/v1/{automation_id}\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"enabled\": false}'\n\n# Delete\ncurl -X DELETE \"${OPENHANDS_HOST}/api/automation/v1/{automation_id}\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\"\n```\n\n### Trigger and Monitor Runs\n\n```bash\n# Manually trigger a run\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/{automation_id}/dispatch\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\"\n\n# List runs\ncurl \"${OPENHANDS_HOST}/api/automation/v1/{automation_id}/runs?limit=20\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\"\n```\n\nRun status values: `PENDING` (waiting for dispatch), `RUNNING` (in progress), `COMPLETED` (success), `FAILED` (check `error_detail`).\n\n---\n\n## Run Lifecycle\n\nWhen a run completes, the automation service receives a callback and marks the run done. Any conversations started during the run remain accessible in the OpenHands UI — users can view the history and continue interacting. The agent server persists until it times out or is manually deleted.\n\nThe automation script itself controls when the callback fires (signalling completion). For simple synchronous scripts this happens naturally on exit. For scripts that start asynchronous conversations, the callback should be deferred until the conversation reaches an idle state (see `references/custom-automation.md` for patterns).\n\n---\n\n## Choosing the Right Preset\n\nPick based on **what the task needs**, not just **what is technically possible**. An LLM-driven preset can do almost anything, so \"the preset can satisfy this\" is not by itself a good reason to pick it — every run costs tokens and sandbox time.\n\n| Use Case | Recommended |\n|----------|-------------|\n| Reasoning, summarization, triage, code review, or open-ended tool use | **Prompt Preset** |\n| Needs plugin commands / skills / MCP configs / hooks | **Plugin Preset** |\n| Compare plugin versions or configurations across runs | **Plugin Preset with A/B testing** — see `references/ab-testing.md` |\n| **Deterministic task** (fixed data + scheduled action, e.g. healthcheck, Slack notification, rotating from a known list) — especially if it runs frequently | **Custom script, no LLM** — see `references/custom-automation.md#deterministic-script-no-llm` |\n| Custom Python dependencies, multi-file project, or direct SDK lifecycle control | **Custom script with SDK** — see `references/custom-automation.md#sdk-based-scripts` |\n\nThe **prompt preset** is the right default for genuinely agent-shaped work — anything that benefits from reasoning over context, calling tools dynamically, or producing a non-templated output. Use the **plugin preset** when you need extended capabilities from plugins (skills, MCP configurations, hooks, commands).\n\n**Watch for deterministic, high-frequency patterns.** Requests like \"send a daily standup reminder\", \"ping a healthcheck URL every minute\", \"post a random quote every 5 minutes\", or \"rotate a fact-of-the-day message\" do not need an LLM. Surface this to the user explicitly with a rough cost framing (e.g. \"this schedule will invoke your LLM ~288 times/day\") before defaulting to a preset. As a rule of thumb, any cron tighter than hourly deserves a deliberate \"should this really be agent-driven?\" check.\n\n**When neither preset is the right fit** (deterministic task, custom Python dependencies, non-Python entrypoint, multi-file project structure, direct SDK lifecycle control), explain the options to the user and let them decide. Do not attempt custom automation without explicit user agreement. If they choose the custom route, refer to `references/custom-automation.md`.\n\n## Reference Files\n\n- **`references/custom-automation.md`** — Detailed guide for custom automations: tarball uploads, code structure (SDK and no-LLM), state persistence via the KV store, environment variables, validation rules, and complete examples. Consult this whenever you need to evaluate or recommend the custom path (including for deterministic / cost-sensitive tasks per rule 0). Only *implement* a custom automation after the user agrees to that path.\n- **`references/ab-testing.md`** — A/B testing for plugin automations: defining variants with weights, experiment configuration, variant selection logic, observability via conversation tags, and complete examples. Consult this when a user wants to compare plugin versions or configurations." + "content": "# OpenHands Automations\n\nCreate and manage automations that run inside an OpenHands agent server — triggered by cron schedules or webhook events (GitHub, custom services).\n\n## Automation Creation Process\nThe agent must follow these steps when creating an automation:\n* Quickly check that you can access the correct automations backend using the auth mechanism below\n* Quickly check that you can access any necessary integrations (e.g. GitHub, Slack); if access fails, inform the user and stop\n* Ask the user for any necessary information, e.g. if you need the name of a Slack channel or GitHub repo to proceed\n* Write the code or prompt that will be sent to the automations backend _inside the current workspace_\n* Show the code to the user with the `canvas_ui` tool if available, otherwise present it in a fenced code block in your reply\n* Message the user with a concise summary of how the automation will behave, and ask if they are ready to deploy it\n\n## Architecture\n\nTwo components work together to run automations:\n\n**Automation Service** (API at `OPENHANDS_HOST/api/automation/v1`)\nManages the *when*: holds automation definitions, schedules cron-triggered runs, dispatches webhook-triggered runs, and receives completion callbacks to mark runs as done. This is the API you call to create, update, and manage automations.\n\n**Agent Server** (accessible as `AGENT_SERVER_URL` inside script runs)\nManages the *what*: the runtime environment where automation scripts execute and where conversations (AI agent interactions with tools, bash, file editing, etc.) run. When a run is triggered, the automation service uploads the automation's tarball to the agent server, which unpacks and runs the entrypoint script. The script connects back to the agent server using `AGENT_SERVER_URL` and a session API key to start, monitor, and stop conversations.\n\nThe agent server typically runs inside a **sandbox** (a Docker or Kubernetes container). Some deployments use sandboxless mode, where the agent server runs directly on a host.\n\n**Key environment variables:**\n\n| Variable | Availability | Description |\n|---|---|---|\n| `RUNTIME_URL` | Ambient in cloud environments | Public-facing URL of the **agent server** sandbox. Use this to determine whether external webhook delivery is possible — if unset or local, webhooks cannot be received. The automation service may run at a separate URL (see Determining the API Host). |\n| `AGENT_SERVER_URL` | Injected into scripts at run time only | Internal URL of the agent server. Available inside script execution context; **not** an ambient environment variable outside of a running script. |\n| `OPENHANDS_HOST` | Shell convention only — set manually | Base URL for the automation service API. **Not a real environment variable.** Set it from the `` system-prompt value, or default to `https://app.all-hands.dev`. Used in all `curl` examples throughout this skill. |\n\n> **⚠️ CRITICAL — Agent behavior rules:**\n>\n> 0. **Does this task need an LLM at all? Check first.** Before picking a preset, ask whether the task actually requires reasoning, judgment, summarization, or open-ended tool use. If it is fully deterministic — fixed data transforms, scheduled HTTP calls, healthcheck pings, file rotation, picking from a known list, posting a templated message — an LLM-driven preset is overkill. Every run will consume LLM tokens, which adds up fast at high frequencies (every 5 min ≈ 288 runs/day). Surface the trade-off to the user and offer the custom-script path (see `references/custom-automation.md`) as the cheaper, more reliable option. Be especially careful for cron schedules tighter than hourly.\n>\n> **Instant-recognition patterns — these are always deterministic, never use an LLM preset:**\n> - \"post a quote / message / fact every N minutes\" (rotating from a list)\n> - \"send a scheduled reminder / standup / digest\"\n> - \"ping a health-check URL on a schedule\"\n> - \"post to Slack / webhook every N minutes\"\n> - Any task where the full output could be written as a static template right now\n>\n> 1. **For LLM-appropriate work, default to preset endpoints.** They handle all SDK boilerplate, tarball packaging, and upload automatically:\n> - **Prompt preset** (`POST /v1/preset/prompt`) — for tasks expressed as a natural language prompt that benefit from agent reasoning\n> - **Plugin preset** (`POST /v1/preset/plugin`) — when plugins with skills, MCP configs, or commands are needed\n> 2. **Do not silently create custom scripts.** Do not generate Python code, `setup.sh` files, or tarball uploads without user consent. But *do* proactively recommend the custom path (per rule 0) when the task is deterministic or high-frequency — surface the option and let the user choose.\n> 3. **If neither preset is the right fit**, do NOT silently fall back to custom automation. Instead, explain the available options to the user:\n> - **Prompt preset** — natural language prompt execution (LLM-driven)\n> - **Plugin preset** — load plugins with extended capabilities (skills, MCP, hooks, commands)\n> - **Custom script** — full control over code, with or without LLM; point them to `references/custom-automation.md`\n> - Let the user choose which approach to use.\n> 4. **Only create custom scripts after the user agrees to that path.** Refer to `references/custom-automation.md` for the full reference.\n> 5. **Before suggesting event-triggered (webhook) automations, check whether the deployment is publicly reachable.** Check `RUNTIME_URL`. Webhooks require an internet-accessible URL so that external services (GitHub, Slack, Linear, etc.) can deliver events to the automation service. If `RUNTIME_URL` is unset, empty, or resolves to a local or private address (`localhost`, `127.0.0.1`, `0.0.0.0`, or any RFC 1918 range: `10.x.x.x`, `192.168.x.x`, `172.16–31.x.x`), the service cannot receive inbound webhook traffic from the public internet. In that case:\n> - **Recommend a cron-based polling automation instead.** Have the automation run on a schedule and call the external service's API (e.g., the GitHub REST API) to check for new events since the last run.\n> - Explain the limitation clearly to the user: \"Because this is a local deployment, external services can't reach the webhook endpoint. I'll set up a polling automation using a cron schedule instead.\"\n\n### No-LLM Script Helpers\n\nWhen building a deterministic custom script, these two stdlib-only functions are required. Copy them verbatim — they use `AGENT_SERVER_URL` and `SESSION_API_KEY` injected by the automation service.\n\n```python\nimport json, os, urllib.request\n\ndef get_secret(name):\n \"\"\"Fetch a named secret stored in the agent server.\"\"\"\n url = os.environ.get(\"AGENT_SERVER_URL\", \"\").rstrip(\"/\")\n key = os.environ.get(\"SESSION_API_KEY\") or os.environ.get(\"OH_SESSION_API_KEYS_0\", \"\")\n with urllib.request.urlopen(urllib.request.Request(\n f\"{url}/api/settings/secrets/{name}\", headers={\"X-Session-API-Key\": key}\n )) as r:\n return r.read().decode().strip()\n\ndef fire_callback(status=\"COMPLETED\", error=None):\n \"\"\"Signal run completion. MUST be called on every exit path — success AND error.\"\"\"\n url = os.environ.get(\"AUTOMATION_CALLBACK_URL\", \"\")\n if not url: return\n body = {\"status\": status, \"run_id\": os.environ.get(\"AUTOMATION_RUN_ID\", \"\")}\n if error: body[\"error\"] = error\n try:\n urllib.request.urlopen(urllib.request.Request(url, data=json.dumps(body).encode(), headers={\n \"Content-Type\": \"application/json\",\n \"Authorization\": f\"Bearer {os.environ.get('AUTOMATION_CALLBACK_API_KEY', '')}\",\n }))\n except Exception as e: print(f\"Callback error: {e}\")\n```\n\nEntrypoint must be `python3 main.py` (no `setup.sh` needed). Wrap your main logic in `try/except` and call `fire_callback(\"FAILED\", str(e))` in the except block.\n\n**State persistence between runs** — polling automations that track a \"last processed\" timestamp or active conversation IDs must use the built-in KV store rather than local files. Local files are lost when a run ends on a cloud pod. The KV store is available when `AUTOMATION_KV_TOKEN` is injected into the run environment. See `references/custom-automation.md#state-persistence-kv-store` for ready-to-copy `kv_get` / `kv_set` / `load_state` / `save_state` helpers.\n\n---\n\n## Authentication\n\nAll requests require Bearer authentication:\n\n```bash\n-H \"Authorization: Bearer ${OPENHANDS_API_KEY}\"\n```\n\n## API Endpoints\n\n### Determining the API Host\n\n**Before making API calls, determine the correct host:**\n\nThe automation service may run at a different URL from the agent server. In the examples throughout this skill, `${OPENHANDS_HOST}` is a shell-variable convention for the automation service base URL — it is **not** a real environment variable. Set it from context before running any curl command:\n\n- Look for a `` value in the system prompt. If present, use that URL.\n- Otherwise default to `https://app.all-hands.dev`.\n\n```bash\nOPENHANDS_HOST=\"https://app.all-hands.dev\" # replace with if provided\n```\n\n\n### Automation Endpoints\n\n| Endpoint | Method | Description |\n|----------|--------|-------------|\n| `/api/automation/v1/preset/prompt` | POST | **Create automation from a prompt (recommended)** |\n| `/api/automation/v1/preset/plugin` | POST | **Create automation with plugins** |\n| `/api/automation/v1` | POST | Create a custom automation from an uploaded or external tarball |\n| `/api/automation/v1` | GET | List automations |\n| `/api/automation/v1/{id}` | GET | Get automation details |\n| `/api/automation/v1/{id}` | PATCH | Update automation |\n| `/api/automation/v1/{id}` | DELETE | Delete automation |\n| `/api/automation/v1/{id}/dispatch` | POST | Trigger a run manually |\n| `/api/automation/v1/{id}/runs` | GET | List automation runs |\n\n### Custom Webhook Endpoints\n\n| Endpoint | Method | Description |\n|----------|--------|-------------|\n| `/api/automation/v1/webhooks` | POST | Register a custom webhook source |\n| `/api/automation/v1/webhooks` | GET | List all custom webhooks |\n| `/api/automation/v1/webhooks/{id}` | GET | Get webhook details |\n| `/api/automation/v1/webhooks/{id}` | PATCH | Update webhook settings |\n| `/api/automation/v1/webhooks/{id}` | DELETE | Delete a webhook |\n| `/api/automation/v1/webhooks/{id}/rotate-secret` | POST | Rotate signing secret |\n\n---\n\n## Trigger Types\n\nAutomations support two trigger types:\n\n| Trigger Type | Use Case |\n|--------------|----------|\n| **Cron** | Run on a schedule (daily, weekly, hourly, etc.) |\n| **Event** | Run when a webhook event occurs (GitHub PR opened, issue commented, etc.) — **requires a publicly reachable deployment** |\n\n---\n\n## Creating Automations\n\nTwo preset endpoints simplify automation creation by handling SDK boilerplate, tarball packaging, and upload automatically:\n\n1. **Prompt Preset** — Execute a natural language prompt (simple tasks)\n2. **Plugin Preset** — Load plugins with skills, MCP configs, and commands (extended capabilities)\n\n### Run Configuration Options\n\nThese optional fields are supported by `POST /api/automation/v1/preset/prompt`, `POST /api/automation/v1/preset/plugin`, and custom `POST /api/automation/v1` unless noted:\n\n| Field | Applies to | Description |\n|-------|------------|-------------|\n| `model` | All create endpoints, PATCH | Model profile name for automation runs. If omitted, the service stores the user's active profile at creation time. |\n| `timeout` | All create endpoints, PATCH | Max execution time in seconds. Omit to use the service default (currently 600 seconds). Values must be positive and no greater than the configured max (currently 1800 seconds / 30 minutes); invalid values return HTTP 422. |\n| `keep_alive` | All create endpoints, PATCH | Sandbox cleanup policy. `true` leaves the sandbox for runtime TTL cleanup after the run finishes; `false` or `null` lets the automation service explicitly clean it up after completion or failure. |\n| `repos` | Preset endpoints only | Repositories to clone before execution (see [Repository Cloning](#repository-cloning)). |\n\nUse `timeout` for long-running jobs that legitimately need more than the default. Use `keep_alive: true` only when you intentionally want the sandbox to remain available until the runtime TTL reaper removes it, for example while debugging or inspecting run artifacts.\n\n---\n\n### Prompt Preset\n\nUse the **preset/prompt endpoint** for simple automations. Provide a natural language prompt describing the task.\n\n#### How It Works\n\n1. Send a prompt describing the task (e.g., \"Generate a weekly status report\")\n2. The automation service generates a Python script that: fetches LLM config and secrets from the agent server, starts an AI agent conversation with your prompt, and sends a completion callback when done\n3. The script is packaged as a tarball and the automation is registered; on each trigger, the automation service uploads the tarball to the agent server, which unpacks and runs the script inside its environment\n\n#### Request\n\n```bash\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/preset/prompt\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"My Automation Name\",\n \"prompt\": \"What the automation should do\",\n \"trigger\": {\n \"type\": \"cron\",\n \"schedule\": \"0 9 * * *\",\n \"timezone\": \"UTC\"\n }\n }'\n```\n\n#### Request Fields\n\n| Field | Required | Description |\n|-------|----------|-------------|\n| `name` | Yes | Name of the automation (1-500 characters) |\n| `prompt` | Yes | Natural language instructions (1-50,000 characters) |\n| `model` | No | Model profile name for automation runs; defaults to the active profile at creation time |\n| `trigger` | Yes | Trigger configuration — either `cron` or `event` (see below) |\n| `timeout` | No | Max execution time in seconds (default 600, max 1800 unless the service is configured differently) |\n| `keep_alive` | No | `true` leaves sandbox cleanup to runtime TTL; `false` or `null` explicitly cleans up after terminal runs |\n| `repos` | No | Repositories to clone (see [Repository Cloning](#repository-cloning)) |\n\n**Cron Trigger Fields:**\n\n| Field | Required | Description |\n|-------|----------|-------------|\n| `trigger.type` | Yes | `\"cron\"` |\n| `trigger.schedule` | Yes | Cron expression (5 fields: min hour day month weekday) |\n| `trigger.timezone` | No | IANA timezone (default: `\"UTC\"`) |\n\n**Event Trigger Fields:**\n\n| Field | Required | Description |\n|-------|----------|-------------|\n| `trigger.type` | Yes | `\"event\"` |\n| `trigger.source` | Yes | Event source: `\"github\"` or custom webhook source name |\n| `trigger.on` | Yes | Event key pattern(s) to match (see Event Keys below) |\n| `trigger.filter` | No | JMESPath expression for payload filtering (see Filter Expressions below) |\n\n#### Prompt Tips\n\nWrite the prompt as an instruction to an AI agent. The prompt executes inside a sandbox with full tool access (bash, file editing, etc.), the user's configured LLM, stored secrets, and MCP server integrations. Examples:\n\n- `\"Generate a weekly status report summarizing the team's GitHub activity and post it to Slack\"`\n- `\"Check the production API health endpoint every hour and alert if it returns non-200\"`\n- `\"Pull the latest data from our analytics API and update the dashboard spreadsheet\"`\n\n#### Cron Schedule\n\n| Field | Values | Description |\n|-------|--------|-------------|\n| Minute | 0-59 | Minute of the hour |\n| Hour | 0-23 | Hour of the day (24-hour) |\n| Day | 1-31 | Day of the month |\n| Month | 1-12 | Month of the year |\n| Weekday | 0-6 | Day of week (0=Sun, 6=Sat) |\n\nCommon schedules: `0 9 * * *` (daily 9 AM), `0 9 * * 1-5` (weekdays 9 AM), `0 9 * * 1` (Mondays 9 AM), `0 0 1 * *` (first of month), `*/15 * * * *` (every 15 min), `0 */6 * * *` (every 6 hours).\n\n#### Response (HTTP 201)\n\n```json\n{\n \"id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"name\": \"My Automation Name\",\n \"model\": \"active-profile\",\n \"trigger\": {\"type\": \"cron\", \"schedule\": \"0 9 * * *\", \"timezone\": \"UTC\"},\n \"timeout\": 600,\n \"keep_alive\": null,\n \"enabled\": true,\n \"created_at\": \"2025-03-25T10:00:00Z\"\n}\n```\n\n#### Prompt Preset Examples\n\n**Daily report:**\n```bash\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/preset/prompt\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"Daily Report\",\n \"prompt\": \"Generate a daily status report and save it to a file in the workspace\",\n \"trigger\": {\"type\": \"cron\", \"schedule\": \"0 9 * * 1-5\", \"timezone\": \"America/New_York\"}\n }'\n```\n\n**Weekly cleanup:**\n```bash\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/preset/prompt\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"Weekly Cleanup\",\n \"prompt\": \"Clean up temporary files older than 7 days and send a summary of what was removed\",\n \"trigger\": {\"type\": \"cron\", \"schedule\": \"0 2 * * 0\", \"timezone\": \"UTC\"},\n \"timeout\": 300,\n \"keep_alive\": false\n }'\n```\n\n---\n\n## Polling as a Webhook Alternative\n\nWhen the deployment cannot receive inbound webhook traffic (see rule 5), use a cron-triggered automation that calls the external service’s API on a schedule to check for new events.\n\n### Polling vs. Webhooks at a Glance\n\n| | Webhooks (Event trigger) | Polling (Cron trigger) |\n|---|---|---|\n| **Requires public URL** | Yes | No — works locally |\n| **Latency** | Near-instant | Up to one poll interval |\n| **API calls** | Only on real events | Every poll interval |\n| **Best for** | Cloud / public deployments | Local or private deployments |\n\n---\n\n## Event-Triggered Automations (Webhooks)\n\nEvent-triggered automations run when a webhook event occurs — like a GitHub PR being opened, an issue receiving a comment, or a custom service sending a notification.\n\n### Built-in Integrations\n\n**GitHub** is a built-in integration — no webhook registration needed. Just create automations with `\"source\": \"github\"`.\n\n### GitHub Event Keys\n\nEvents use the format `{event_type}.{action}` or just `{event_type}` (for events without actions like `push`).\n\n| Event Type | Event Keys | Description |\n|------------|------------|-------------|\n| `pull_request` | `pull_request.opened`, `pull_request.closed`, `pull_request.synchronize`, `pull_request.labeled`, `pull_request.unlabeled`, `pull_request.reopened`, `pull_request.edited`, `pull_request.ready_for_review` | PR activity |\n| `issues` | `issues.opened`, `issues.closed`, `issues.reopened`, `issues.labeled`, `issues.unlabeled`, `issues.edited`, `issues.assigned` | Issue activity |\n| `issue_comment` | `issue_comment.created`, `issue_comment.edited`, `issue_comment.deleted` | Comments on issues/PRs |\n| `push` | `push` | Code pushed to a branch |\n| `release` | `release.published`, `release.created`, `release.released`, `release.prereleased` | Release activity |\n| `pull_request_review` | `pull_request_review.submitted`, `pull_request_review.edited`, `pull_request_review.dismissed` | PR review activity |\n\n**Wildcards:** Use `*` to match any action — e.g., `pull_request.*` matches all PR events.\n\n**Multiple patterns:** The `on` field can be a string or array — e.g., `[\"push\", \"pull_request.opened\"]`.\n\n### Filter Expressions (JMESPath)\n\nFilters let you match events based on payload content using JMESPath expressions.\n\n#### Available Functions\n\n| Function | Description | Example |\n|----------|-------------|---------|\n| `glob(str, pattern)` | Wildcard pattern matching | `glob(repository.full_name, 'myorg/*')` |\n| `icontains(str, substr)` | Case-insensitive substring | `icontains(comment.body, '@openhands')` |\n| `contains(array, value)` | Array contains value | `contains(pull_request.labels[].name, 'bug')` |\n| `regex(str, pattern)` | Regular expression match | `regex(ref, '^refs/tags/v\\\\d+')` |\n| `starts_with(str, prefix)` | String starts with | `starts_with(ref, 'refs/heads/')` |\n| `ends_with(str, suffix)` | String ends with | `ends_with(ref, '/main')` |\n| `lower(str)` / `upper(str)` | Case conversion | `lower(sender.login) == 'admin'` |\n\n#### Boolean Operators\n\n- `&&` — AND\n- `||` — OR \n- `!` — NOT\n\n#### Filter Examples\n\n```javascript\n// Exact match on label name\n\"contains(pull_request.labels[].name, 'openhands')\"\n\n// Case-insensitive mention in comment\n\"icontains(comment.body, '@openhands')\"\n\n// Match specific repository\n\"repository.full_name == 'myorg/myrepo'\"\n\n// Match any repo in an org\n\"glob(repository.full_name, 'myorg/*')\"\n\n// PR with 'bug' label in any org repo\n\"glob(repository.full_name, 'myorg/*') && contains(pull_request.labels[].name, 'bug')\"\n\n// Push to main or release branches\n\"glob(ref, 'refs/heads/main') || glob(ref, 'refs/heads/release/*')\"\n\n// Issue opened by a specific user\n\"sender.login == 'dependabot[bot]'\"\n\n// Not a draft PR\n\"!pull_request.draft\"\n```\n\n---\n\n### Event-Triggered Examples\n\n#### GitHub: Respond to @openhands mentions in comments\n\n```bash\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/preset/prompt\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"OpenHands Mention Responder\",\n \"prompt\": \"Analyze the issue or PR context and provide a helpful response to the user'\\''s question. The comment body and context are available in the event payload.\",\n \"trigger\": {\n \"type\": \"event\",\n \"source\": \"github\",\n \"on\": \"issue_comment.created\",\n \"filter\": \"icontains(comment.body, '\\''@openhands'\\'')\"\n },\n \"timeout\": 300\n }'\n```\n\n#### GitHub: Auto-review PRs with the \"openhands\" label\n\n```bash\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/preset/prompt\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"Auto Review PRs\",\n \"prompt\": \"Review this pull request for code quality, potential bugs, and best practices. Provide constructive feedback.\",\n \"trigger\": {\n \"type\": \"event\",\n \"source\": \"github\",\n \"on\": \"pull_request.labeled\",\n \"filter\": \"contains(pull_request.labels[].name, '\\''openhands'\\'')\"\n }\n }'\n```\n\n#### GitHub: Run tests on push to main\n\n```bash\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/preset/prompt\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"Run Tests on Main\",\n \"prompt\": \"Clone the repository and run the test suite. Report any failures.\",\n \"trigger\": {\n \"type\": \"event\",\n \"source\": \"github\",\n \"on\": \"push\",\n \"filter\": \"ref == '\\''refs/heads/main'\\''\"\n }\n }'\n```\n\n#### GitHub: Triage new issues in specific repos\n\n```bash\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/preset/prompt\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"Issue Triage Bot\",\n \"prompt\": \"Analyze this new issue and suggest appropriate labels. If it looks like a bug, try to identify the root cause.\",\n \"trigger\": {\n \"type\": \"event\",\n \"source\": \"github\",\n \"on\": \"issues.opened\",\n \"filter\": \"glob(repository.full_name, '\\''myorg/*'\\'')\"\n }\n }'\n```\n\n#### GitHub: Respond to multiple event types\n\n```bash\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/preset/prompt\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"PR Activity Bot\",\n \"prompt\": \"Process the PR event and take appropriate action based on the event type.\",\n \"trigger\": {\n \"type\": \"event\",\n \"source\": \"github\",\n \"on\": [\"pull_request.opened\", \"pull_request.synchronize\", \"pull_request.ready_for_review\"]\n }\n }'\n```\n\n---\n\n## Custom Webhooks\n\nFor services other than GitHub (Linear, Stripe, Slack, etc.), register a custom webhook first.\n\n> **Agent behavior:**\n> - **Always provide the curl request** to the user — do not attempt to register webhooks yourself.\n> - **Ask the user:** \"Do you have a webhook signing secret from [service], or should the system generate one?\"\n> - If they have one → include `webhook_secret` in the request\n> - If not → omit it; the response will contain a generated secret they must configure in their service\n\n### Register a Custom Webhook\n\n```bash\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/webhooks\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"Linear Issues\",\n \"source\": \"linear\",\n \"event_key_expr\": \"type\",\n \"signature_header\": \"Linear-Signature\",\n \"webhook_secret\": \"your-linear-webhook-secret\"\n }'\n```\n\n#### Webhook Fields\n\n| Field | Required | Description |\n|-------|----------|-------------|\n| `name` | Yes | Human-readable name for the webhook |\n| `source` | Yes | Unique source identifier (lowercase, alphanumeric with hyphens, 1-50 chars) |\n| `event_key_expr` | No | JMESPath expression to extract event type from payload (default: `\"type\"`) |\n| `signature_header` | No | HTTP header containing HMAC signature (default: `\"X-Signature-256\"`) |\n| `webhook_secret` | No | Signing secret — provide your own (from the external service) or let the system generate one |\n\n#### Response\n\n```json\n{\n \"id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"webhook_url\": \"https://app.all-hands.dev/v1/events/{org_id}/linear\",\n \"source\": \"linear\",\n \"enabled\": true\n}\n```\n\n**Note:** When you provide your own `webhook_secret`, it won't be echoed back in the response. If you don't provide one, the system generates a secret and returns it once — store it securely.\n\n### Manage Custom Webhooks\n\n```bash\n# List all webhooks\ncurl \"${OPENHANDS_HOST}/api/automation/v1/webhooks\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\"\n\n# Update a webhook\ncurl -X PATCH \"${OPENHANDS_HOST}/api/automation/v1/webhooks/{webhook_id}\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"enabled\": false}'\n\n# Rotate the signing secret\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/webhooks/{webhook_id}/rotate-secret\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\"\n\n# Delete a webhook\ncurl -X DELETE \"${OPENHANDS_HOST}/api/automation/v1/webhooks/{webhook_id}\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\"\n```\n\n### Custom Webhook Example: Linear\n\nLinear sends webhooks with:\n- Signature header: `Linear-Signature`\n- Event type in payload: `type` field (e.g., `Issue`, `Comment`, `Project`)\n- Action in payload: `action` field (e.g., `create`, `update`, `remove`)\n\n```bash\n# 1. Register the Linear webhook\n# - Get your webhook signing secret from Linear's webhook settings\n# - Use \"Linear-Signature\" as the signature header\n# - Use \"type\" to extract the event type from the payload\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/webhooks\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"Linear Issues\",\n \"source\": \"linear\",\n \"event_key_expr\": \"type\",\n \"signature_header\": \"Linear-Signature\",\n \"webhook_secret\": \"lin_wh_xxxxxxxxxxxxx\"\n }'\n\n# Response includes webhook_url — configure this in Linear:\n# Settings → API → Webhooks → New webhook → paste the webhook_url\n\n# 2. Create an automation for new Linear issues\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/preset/prompt\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"Triage New Linear Issues\",\n \"prompt\": \"A new issue was created in Linear. Analyze the issue title and description, suggest appropriate labels, and add a comment with initial triage notes.\",\n \"trigger\": {\n \"type\": \"event\",\n \"source\": \"linear\",\n \"on\": \"Issue\",\n \"filter\": \"action == '\\''create'\\''\"\n }\n }'\n\n# 3. Create an automation for high-priority issue updates\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/preset/prompt\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"High Priority Issue Alert\",\n \"prompt\": \"A high-priority issue was updated. Review the changes and notify the team if action is needed.\",\n \"trigger\": {\n \"type\": \"event\",\n \"source\": \"linear\",\n \"on\": \"Issue\",\n \"filter\": \"action == '\\''update'\\'' && data.priority == `1`\"\n }\n }'\n```\n\n### Common Signature Headers by Service\n\n| Service | Signature Header | Event Key Expression |\n|---------|-----------------|---------------------|\n| Linear | `Linear-Signature` | `type` |\n| Stripe | `Stripe-Signature` | `type` |\n| Slack | `X-Slack-Signature` | `type` |\n| Twilio | `X-Twilio-Signature` | `type` |\n| Generic | `X-Signature-256` | `type` |\n\n---\n\n### Plugin Preset\n\nUse the **preset/plugin endpoint** when you need to load one or more plugins that provide extended capabilities like skills, MCP configurations, hooks, and commands.\n\n> **💡 Finding plugins:** Browse the [OpenHands/extensions](https://github.com/OpenHands/extensions) repository for available skills and plugins. When given a broad use case, check this directory first to see if something already exists that fits your needs.\n\n#### How It Works\n\n1. Specify one or more plugins (from GitHub repos, git URLs, or monorepo subdirectories)\n2. Provide a prompt that can invoke plugin commands (e.g., `/plugin-name:command`)\n3. The service generates SDK boilerplate that loads all plugins at runtime, creates a conversation with plugin capabilities, and executes the prompt\n4. The service packages everything into a tarball, uploads it, and creates the automation\n\n#### Request\n\n```bash\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/preset/plugin\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"My Plugin Automation\",\n \"plugins\": [\n {\"source\": \"github:owner/repo\", \"ref\": \"v1.0.0\"},\n {\"source\": \"github:owner/another-plugin\"}\n ],\n \"prompt\": \"Use the plugin commands to perform the task\",\n \"trigger\": {\n \"type\": \"cron\",\n \"schedule\": \"0 9 * * 1\",\n \"timezone\": \"UTC\"\n }\n }'\n```\n\n#### Request Fields\n\n| Field | Required | Description |\n|-------|----------|-------------|\n| `name` | Yes | Name of the automation (1-500 characters) |\n| `plugins` | Yes* | List of plugin sources (at least one required for standard plugin automations) |\n| `plugins[].source` | Yes | Plugin source: `github:owner/repo`, git URL, or local path |\n| `plugins[].ref` | No | Git ref: branch, tag, or commit SHA |\n| `plugins[].repo_path` | No | Subdirectory path for monorepos |\n| `variants` | Yes* | A/B test variants used instead of `plugins`; see `references/ab-testing.md` |\n| `experiment_id` | Yes* | Required when using `variants` |\n| `prompt` | Yes | Instructions for the automation (1-50,000 characters) |\n| `model` | No | Model profile name for automation runs; defaults to the active profile at creation time |\n| `trigger` | Yes | Trigger configuration — either `cron` or `event` (same as Prompt Preset) |\n| `timeout` | No | Max execution time in seconds (default 600, max 1800 unless the service is configured differently) |\n| `keep_alive` | No | `true` leaves sandbox cleanup to runtime TTL; `false` or `null` explicitly cleans up after terminal runs |\n| `repos` | No | Repositories to clone (see [Repository Cloning](#repository-cloning)) |\n\nNote: Provide either `plugins` for a standard plugin automation or `variants` plus `experiment_id` for an A/B test, not both.\n\n#### Plugin Source Formats\n\n| Format | Example | Description |\n|--------|---------|-------------|\n| GitHub shorthand | `github:owner/repo` | Fetches from GitHub |\n| Git URL | `https://github.com/owner/repo.git` | Any git repository |\n| With ref | `{\"source\": \"github:owner/repo\", \"ref\": \"v1.0.0\"}` | Specific branch/tag/commit |\n| Monorepo | `{\"source\": \"github:org/monorepo\", \"repo_path\": \"plugins/my-plugin\"}` | Subdirectory in repo |\n\n#### Response (HTTP 201)\n\n```json\n{\n \"id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"name\": \"My Plugin Automation\",\n \"model\": \"active-profile\",\n \"trigger\": {\"type\": \"cron\", \"schedule\": \"0 9 * * 1\", \"timezone\": \"UTC\"},\n \"timeout\": 600,\n \"keep_alive\": null,\n \"enabled\": true,\n \"created_at\": \"2025-03-25T10:00:00Z\"\n}\n```\n\n#### Plugin Preset Examples\n\n**Single plugin with version:**\n```bash\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/preset/plugin\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"Code Review Automation\",\n \"plugins\": [\n {\"source\": \"github:owner/code-review-plugin\", \"ref\": \"v2.0.0\"}\n ],\n \"prompt\": \"Review all Python files in the repository for code quality issues\",\n \"trigger\": {\"type\": \"cron\", \"schedule\": \"0 9 * * 1-5\", \"timezone\": \"UTC\"}\n }'\n```\n\n**Multiple plugins:**\n```bash\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/preset/plugin\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"Security Scan Automation\",\n \"plugins\": [\n {\"source\": \"github:owner/security-scanner\"},\n {\"source\": \"github:owner/report-generator\", \"ref\": \"main\"}\n ],\n \"prompt\": \"Run a security scan on the codebase and generate a report\",\n \"trigger\": {\"type\": \"cron\", \"schedule\": \"0 2 * * 0\", \"timezone\": \"UTC\"},\n \"timeout\": 600\n }'\n```\n\n**Monorepo plugin:**\n```bash\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/preset/plugin\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"Style Guide Enforcement\",\n \"plugins\": [\n {\"source\": \"github:company/monorepo\", \"repo_path\": \"plugins/style-guide\", \"ref\": \"main\"}\n ],\n \"prompt\": \"Check all files against the company style guide\",\n \"trigger\": {\"type\": \"cron\", \"schedule\": \"0 8 * * 1\", \"timezone\": \"America/Los_Angeles\"}\n }'\n```\n\n---\n\n## Repository Cloning\n\nBoth presets support an optional `repos` field to clone repositories into the sandbox before execution. Cloned repos have their skills (AGENTS.md, `.agents/skills/`) automatically loaded.\n\n### Repo Source Formats\n\n| Format | Example | Description |\n|--------|---------|-------------|\n| Full URL | `\"https://github.com/owner/repo\"` | Provider auto-detected |\n| Full URL + ref | `{\"url\": \"https://github.com/owner/repo\", \"ref\": \"main\"}` | With branch/tag/SHA |\n| Short URL | `{\"url\": \"owner/repo\", \"provider\": \"github\"}` | Requires `provider` field |\n\n**Supported providers:** `github`, `gitlab`, `bitbucket`\n\n> **Note:** Short URLs (`owner/repo`) require an explicit `provider` field. Full URLs auto-detect the provider.\n\n### Examples\n\n**Single repo (full URL):**\n```json\n{\n \"repos\": [\"https://github.com/OpenHands/openhands-cli\"]\n}\n```\n\n**Multiple repos with refs:**\n```json\n{\n \"repos\": [\n {\"url\": \"https://github.com/owner/repo1\", \"ref\": \"main\"},\n {\"url\": \"https://gitlab.com/owner/repo2\", \"ref\": \"v1.0.0\"}\n ]\n}\n```\n\n**Short URL with provider:**\n```json\n{\n \"repos\": [\n {\"url\": \"owner/repo\", \"provider\": \"github\", \"ref\": \"main\"}\n ]\n}\n```\n\n### Complete Automation Example\n\n```bash\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/preset/prompt\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"Analyze Codebase\",\n \"prompt\": \"Analyze the openhands-cli codebase and generate a summary report\",\n \"trigger\": {\"type\": \"cron\", \"schedule\": \"0 9 * * 1\"},\n \"repos\": [\n {\"url\": \"https://github.com/OpenHands/openhands-cli\", \"ref\": \"main\"}\n ]\n }'\n```\n\n---\n\n## Managing Automations\n\n### List Automations\n\n```bash\ncurl \"${OPENHANDS_HOST}/api/automation/v1?limit=20\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\"\n```\n\n### Get / Update / Delete\n\n```bash\n# Get details\ncurl \"${OPENHANDS_HOST}/api/automation/v1/{automation_id}\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\"\n\n# Update fields: name, prompt, model, trigger, tarball_path, setup_script_path, entrypoint, enabled, timeout, keep_alive\ncurl -X PATCH \"${OPENHANDS_HOST}/api/automation/v1/{automation_id}\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"enabled\": false}'\n\n# Extend a run timeout and keep the sandbox around for TTL-based cleanup\ncurl -X PATCH \"${OPENHANDS_HOST}/api/automation/v1/{automation_id}\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"timeout\": 1200, \"keep_alive\": true}'\n\n# Delete\ncurl -X DELETE \"${OPENHANDS_HOST}/api/automation/v1/{automation_id}\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\"\n```\n\n### Trigger and Monitor Runs\n\n```bash\n# Manually trigger a run\ncurl -X POST \"${OPENHANDS_HOST}/api/automation/v1/{automation_id}/dispatch\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\"\n\n# List runs\ncurl \"${OPENHANDS_HOST}/api/automation/v1/{automation_id}/runs?limit=20\" \\\n -H \"Authorization: Bearer ${OPENHANDS_API_KEY}\"\n```\n\nRun status values: `PENDING` (waiting for dispatch), `RUNNING` (in progress), `COMPLETED` (success), `FAILED` (check `error_detail`).\n\n---\n\n## Run Lifecycle\n\nWhen a run completes, the automation service receives a callback and marks the run done. Any conversations started during the run remain accessible in the OpenHands UI - users can view the history and continue interacting.\n\nSandbox cleanup depends on `keep_alive`: `false` or `null` means the automation service explicitly cleans up after terminal runs; `true` leaves cleanup to the runtime TTL reaper. Use `keep_alive: true` only when you need post-run inspection or debugging time.\n\nThe automation script itself controls when the callback fires (signalling completion). For simple synchronous scripts this happens naturally on exit. For scripts that start asynchronous conversations, the callback should be deferred until the conversation reaches an idle state (see `references/custom-automation.md` for patterns).\n\n---\n\n## Choosing the Right Preset\n\nPick based on **what the task needs**, not just **what is technically possible**. An LLM-driven preset can do almost anything, so \"the preset can satisfy this\" is not by itself a good reason to pick it — every run costs tokens and sandbox time.\n\n| Use Case | Recommended |\n|----------|-------------|\n| Reasoning, summarization, triage, code review, or open-ended tool use | **Prompt Preset** |\n| Needs plugin commands / skills / MCP configs / hooks | **Plugin Preset** |\n| Compare plugin versions or configurations across runs | **Plugin Preset with A/B testing** — see `references/ab-testing.md` |\n| **Deterministic task** (fixed data + scheduled action, e.g. healthcheck, Slack notification, rotating from a known list) — especially if it runs frequently | **Custom script, no LLM** — see `references/custom-automation.md#deterministic-script-no-llm` |\n| Custom Python dependencies, multi-file project, or direct SDK lifecycle control | **Custom script with SDK** — see `references/custom-automation.md#sdk-based-scripts` |\n\nThe **prompt preset** is the right default for genuinely agent-shaped work — anything that benefits from reasoning over context, calling tools dynamically, or producing a non-templated output. Use the **plugin preset** when you need extended capabilities from plugins (skills, MCP configurations, hooks, commands).\n\n**Watch for deterministic, high-frequency patterns.** Requests like \"send a daily standup reminder\", \"ping a healthcheck URL every minute\", \"post a random quote every 5 minutes\", or \"rotate a fact-of-the-day message\" do not need an LLM. Surface this to the user explicitly with a rough cost framing (e.g. \"this schedule will invoke your LLM ~288 times/day\") before defaulting to a preset. As a rule of thumb, any cron tighter than hourly deserves a deliberate \"should this really be agent-driven?\" check.\n\n**When neither preset is the right fit** (deterministic task, custom Python dependencies, non-Python entrypoint, multi-file project structure, direct SDK lifecycle control), explain the options to the user and let them decide. Do not attempt custom automation without explicit user agreement. If they choose the custom route, refer to `references/custom-automation.md`.\n\n## Reference Files\n\n- **`references/custom-automation.md`** — Detailed guide for custom automations: tarball uploads, code structure (SDK and no-LLM), state persistence via the KV store, environment variables, validation rules, and complete examples. Consult this whenever you need to evaluate or recommend the custom path (including for deterministic / cost-sensitive tasks per rule 0). Only *implement* a custom automation after the user agrees to that path.\n- **`references/ab-testing.md`** — A/B testing for plugin automations: defining variants with weights, experiment configuration, variant selection logic, observability via conversation tags, and complete examples. Consult this when a user wants to compare plugin versions or configurations." }, { "name": "openhands-sdk", diff --git a/skills/openhands-automation/README.md b/skills/openhands-automation/README.md index 44729b84..2e8a8583 100644 --- a/skills/openhands-automation/README.md +++ b/skills/openhands-automation/README.md @@ -21,6 +21,7 @@ This skill is activated by keywords: - **Custom webhooks**: Register webhooks for any service (Stripe, Slack, Linear, etc.) - **JMESPath filters**: Match events based on payload content (labels, mentions, repos) - **Automation management**: List, update, enable/disable, and delete automations +- **Run configuration**: Set model profiles, execution timeouts, and sandbox cleanup behavior - **Manual dispatch**: Trigger automation runs on-demand - **Custom automations**: For advanced users who need full control (see [references/custom-automation.md](references/custom-automation.md)) diff --git a/skills/openhands-automation/SKILL.md b/skills/openhands-automation/SKILL.md index ee10db54..213b95ff 100644 --- a/skills/openhands-automation/SKILL.md +++ b/skills/openhands-automation/SKILL.md @@ -140,6 +140,7 @@ OPENHANDS_HOST="https://app.all-hands.dev" # replace with if provided |----------|--------|-------------| | `/api/automation/v1/preset/prompt` | POST | **Create automation from a prompt (recommended)** | | `/api/automation/v1/preset/plugin` | POST | **Create automation with plugins** | +| `/api/automation/v1` | POST | Create a custom automation from an uploaded or external tarball | | `/api/automation/v1` | GET | List automations | | `/api/automation/v1/{id}` | GET | Get automation details | | `/api/automation/v1/{id}` | PATCH | Update automation | @@ -178,6 +179,19 @@ Two preset endpoints simplify automation creation by handling SDK boilerplate, t 1. **Prompt Preset** — Execute a natural language prompt (simple tasks) 2. **Plugin Preset** — Load plugins with skills, MCP configs, and commands (extended capabilities) +### Run Configuration Options + +These optional fields are supported by `POST /api/automation/v1/preset/prompt`, `POST /api/automation/v1/preset/plugin`, and custom `POST /api/automation/v1` unless noted: + +| Field | Applies to | Description | +|-------|------------|-------------| +| `model` | All create endpoints, PATCH | Model profile name for automation runs. If omitted, the service stores the user's active profile at creation time. | +| `timeout` | All create endpoints, PATCH | Max execution time in seconds. Omit to use the service default (currently 600 seconds). Values must be positive and no greater than the configured max (currently 1800 seconds / 30 minutes); invalid values return HTTP 422. | +| `keep_alive` | All create endpoints, PATCH | Sandbox cleanup policy. `true` leaves the sandbox for runtime TTL cleanup after the run finishes; `false` or `null` lets the automation service explicitly clean it up after completion or failure. | +| `repos` | Preset endpoints only | Repositories to clone before execution (see [Repository Cloning](#repository-cloning)). | + +Use `timeout` for long-running jobs that legitimately need more than the default. Use `keep_alive: true` only when you intentionally want the sandbox to remain available until the runtime TTL reaper removes it, for example while debugging or inspecting run artifacts. + --- ### Prompt Preset @@ -213,8 +227,10 @@ curl -X POST "${OPENHANDS_HOST}/api/automation/v1/preset/prompt" \ |-------|----------|-------------| | `name` | Yes | Name of the automation (1-500 characters) | | `prompt` | Yes | Natural language instructions (1-50,000 characters) | +| `model` | No | Model profile name for automation runs; defaults to the active profile at creation time | | `trigger` | Yes | Trigger configuration — either `cron` or `event` (see below) | -| `timeout` | No | Max execution time in seconds (default: system maximum) | +| `timeout` | No | Max execution time in seconds (default 600, max 1800 unless the service is configured differently) | +| `keep_alive` | No | `true` leaves sandbox cleanup to runtime TTL; `false` or `null` explicitly cleans up after terminal runs | | `repos` | No | Repositories to clone (see [Repository Cloning](#repository-cloning)) | **Cron Trigger Fields:** @@ -260,7 +276,10 @@ Common schedules: `0 9 * * *` (daily 9 AM), `0 9 * * 1-5` (weekdays 9 AM), `0 9 { "id": "123e4567-e89b-12d3-a456-426614174000", "name": "My Automation Name", + "model": "active-profile", "trigger": {"type": "cron", "schedule": "0 9 * * *", "timezone": "UTC"}, + "timeout": 600, + "keep_alive": null, "enabled": true, "created_at": "2025-03-25T10:00:00Z" } @@ -289,7 +308,8 @@ curl -X POST "${OPENHANDS_HOST}/api/automation/v1/preset/prompt" \ "name": "Weekly Cleanup", "prompt": "Clean up temporary files older than 7 days and send a summary of what was removed", "trigger": {"type": "cron", "schedule": "0 2 * * 0", "timezone": "UTC"}, - "timeout": 300 + "timeout": 300, + "keep_alive": false }' ``` @@ -659,15 +679,21 @@ curl -X POST "${OPENHANDS_HOST}/api/automation/v1/preset/plugin" \ | Field | Required | Description | |-------|----------|-------------| | `name` | Yes | Name of the automation (1-500 characters) | -| `plugins` | Yes | List of plugin sources (at least one required) | +| `plugins` | Yes* | List of plugin sources (at least one required for standard plugin automations) | | `plugins[].source` | Yes | Plugin source: `github:owner/repo`, git URL, or local path | | `plugins[].ref` | No | Git ref: branch, tag, or commit SHA | | `plugins[].repo_path` | No | Subdirectory path for monorepos | +| `variants` | Yes* | A/B test variants used instead of `plugins`; see `references/ab-testing.md` | +| `experiment_id` | Yes* | Required when using `variants` | | `prompt` | Yes | Instructions for the automation (1-50,000 characters) | +| `model` | No | Model profile name for automation runs; defaults to the active profile at creation time | | `trigger` | Yes | Trigger configuration — either `cron` or `event` (same as Prompt Preset) | -| `timeout` | No | Max execution time in seconds (default: system maximum) | +| `timeout` | No | Max execution time in seconds (default 600, max 1800 unless the service is configured differently) | +| `keep_alive` | No | `true` leaves sandbox cleanup to runtime TTL; `false` or `null` explicitly cleans up after terminal runs | | `repos` | No | Repositories to clone (see [Repository Cloning](#repository-cloning)) | +Note: Provide either `plugins` for a standard plugin automation or `variants` plus `experiment_id` for an A/B test, not both. + #### Plugin Source Formats | Format | Example | Description | @@ -683,7 +709,10 @@ curl -X POST "${OPENHANDS_HOST}/api/automation/v1/preset/plugin" \ { "id": "123e4567-e89b-12d3-a456-426614174000", "name": "My Plugin Automation", + "model": "active-profile", "trigger": {"type": "cron", "schedule": "0 9 * * 1", "timezone": "UTC"}, + "timeout": 600, + "keep_alive": null, "enabled": true, "created_at": "2025-03-25T10:00:00Z" } @@ -818,12 +847,18 @@ curl "${OPENHANDS_HOST}/api/automation/v1?limit=20" \ curl "${OPENHANDS_HOST}/api/automation/v1/{automation_id}" \ -H "Authorization: Bearer ${OPENHANDS_API_KEY}" -# Update (fields: name, trigger, enabled, timeout) +# Update fields: name, prompt, model, trigger, tarball_path, setup_script_path, entrypoint, enabled, timeout, keep_alive curl -X PATCH "${OPENHANDS_HOST}/api/automation/v1/{automation_id}" \ -H "Authorization: Bearer ${OPENHANDS_API_KEY}" \ -H "Content-Type: application/json" \ -d '{"enabled": false}' +# Extend a run timeout and keep the sandbox around for TTL-based cleanup +curl -X PATCH "${OPENHANDS_HOST}/api/automation/v1/{automation_id}" \ + -H "Authorization: Bearer ${OPENHANDS_API_KEY}" \ + -H "Content-Type: application/json" \ + -d '{"timeout": 1200, "keep_alive": true}' + # Delete curl -X DELETE "${OPENHANDS_HOST}/api/automation/v1/{automation_id}" \ -H "Authorization: Bearer ${OPENHANDS_API_KEY}" @@ -847,7 +882,9 @@ Run status values: `PENDING` (waiting for dispatch), `RUNNING` (in progress), `C ## Run Lifecycle -When a run completes, the automation service receives a callback and marks the run done. Any conversations started during the run remain accessible in the OpenHands UI — users can view the history and continue interacting. The agent server persists until it times out or is manually deleted. +When a run completes, the automation service receives a callback and marks the run done. Any conversations started during the run remain accessible in the OpenHands UI - users can view the history and continue interacting. + +Sandbox cleanup depends on `keep_alive`: `false` or `null` means the automation service explicitly cleans up after terminal runs; `true` leaves cleanup to the runtime TTL reaper. Use `keep_alive: true` only when you need post-run inspection or debugging time. The automation script itself controls when the callback fires (signalling completion). For simple synchronous scripts this happens naturally on exit. For scripts that start asynchronous conversations, the callback should be deferred until the conversation reaches an idle state (see `references/custom-automation.md` for patterns). diff --git a/skills/openhands-automation/references/ab-testing.md b/skills/openhands-automation/references/ab-testing.md index 210148ce..75c2d701 100644 --- a/skills/openhands-automation/references/ab-testing.md +++ b/skills/openhands-automation/references/ab-testing.md @@ -59,7 +59,7 @@ curl -X POST "${OPENHANDS_HOST}/api/automation/v1/preset/plugin" \ *Required only for A/B tests. Standard plugin automations use `plugins` instead. -All other fields (`name`, `prompt`, `trigger`, `timeout`, `repos`, `model`) are identical to the standard plugin preset request. +All other fields (`name`, `prompt`, `trigger`, `model`, `timeout`, `keep_alive`, `repos`) are identical to the standard plugin preset request. ### Variant Object @@ -68,6 +68,7 @@ All other fields (`name`, `prompt`, `trigger`, `timeout`, `repos`, `model`) are | `name` | Yes | string | Unique variant name (1–100 chars) | | `weight` | Yes | integer | Relative selection weight (> 0) | | `plugins` | Yes | array | Plugin source(s) for this variant (at least one) | +| `model` | No | string | Model profile name for this variant; defaults to the automation-level model when omitted | ### Validation Rules diff --git a/skills/openhands-automation/references/custom-automation.md b/skills/openhands-automation/references/custom-automation.md index 619add48..16db427e 100644 --- a/skills/openhands-automation/references/custom-automation.md +++ b/skills/openhands-automation/references/custom-automation.md @@ -107,7 +107,8 @@ curl -X POST "${OPENHANDS_HOST}/api/automation/v1" \ }, "tarball_path": "oh-internal://uploads/550e8400-e29b-41d4-a716-446655440000", "entrypoint": "python main.py", - "timeout": 300 + "timeout": 1200, + "keep_alive": false }' ``` @@ -116,13 +117,20 @@ curl -X POST "${OPENHANDS_HOST}/api/automation/v1" \ | Field | Required | Description | |-------|----------|-------------| | `name` | Yes | Name of the automation (1-500 characters) | -| `trigger.type` | Yes | Must be `"cron"` | -| `trigger.schedule` | Yes | Cron expression (5 fields: min hour day month weekday) | +| `model` | No | Model profile name for automation runs; defaults to the active profile at creation time | +| `trigger.type` | Yes | Must be `"cron"` or `"event"` | +| `trigger.schedule` | Yes* | Cron expression (5 fields: min hour day month weekday), required for cron triggers | | `trigger.timezone` | No | IANA timezone (default: `"UTC"`) | +| `trigger.source` | Yes* | Event source such as `"github"` or a custom webhook source, required for event triggers | +| `trigger.on` | Yes* | Event key pattern(s), required for event triggers | +| `trigger.filter` | No | JMESPath filter expression for event triggers | | `tarball_path` | Yes | Path to code tarball (see Tarball Path Formats below) | | `entrypoint` | Yes | Command to execute (e.g., `"python main.py"`, `"uv run script.py"`) | | `setup_script_path` | No | Relative path to setup script inside tarball | -| `timeout` | No | Max execution time in seconds (1-600, default: 600) | +| `timeout` | No | Max execution time in seconds (default 600, max 1800 unless the service is configured differently) | +| `keep_alive` | No | `true` leaves sandbox cleanup to runtime TTL; `false` or `null` explicitly cleans up after terminal runs | + +Note: Trigger sub-fields marked with `Yes*` are required only for that trigger type. ### Tarball Path Formats @@ -144,8 +152,11 @@ curl -X POST "${OPENHANDS_HOST}/api/automation/v1" \ "schedule": "0 9 * * 1", "timezone": "UTC" }, + "model": "active-profile", "tarball_path": "oh-internal://uploads/550e8400-e29b-41d4-a716-446655440000", "entrypoint": "python main.py", + "timeout": 1200, + "keep_alive": false, "enabled": true, "created_at": "2025-03-25T10:00:00Z" } @@ -171,11 +182,18 @@ curl "${OPENHANDS_HOST}/api/automation/v1/{automation_id}" \ ### Update Automation +Patchable fields include `name`, `model`, `prompt`, `trigger`, `tarball_path`, `setup_script_path`, `entrypoint`, `enabled`, `timeout`, and `keep_alive`. + ```bash curl -X PATCH "${OPENHANDS_HOST}/api/automation/v1/{automation_id}" \ -H "Authorization: Bearer ${OPENHANDS_API_KEY}" \ -H "Content-Type: application/json" \ -d '{"enabled": false}' + +curl -X PATCH "${OPENHANDS_HOST}/api/automation/v1/{automation_id}" \ + -H "Authorization: Bearer ${OPENHANDS_API_KEY}" \ + -H "Content-Type: application/json" \ + -d '{"timeout": 1200, "keep_alive": true}' ``` ### Delete Automation @@ -628,7 +646,7 @@ The automation service injects these environment variables into every run: - **Cron schedule**: Valid 5-field cron expression - **Entrypoint**: Relative path, no shell metacharacters (`;`, `&`, `|`, etc.) - **Setup script path**: Relative path, no path traversal (`..`) -- **Timeout**: 1-600 seconds (10 minutes max) +- **Timeout**: Positive seconds, default 600 and max 1800 unless the service is configured differently - **Tarball size**: 1MB max for uploads ---