{"kind":"Skill","metadata":{"namespace":"community","name":"acp-router","version":"0.1.0"},"spec":{"description":"Route plain-language requests for Pi, Claude Code, Cursor, Copilot, OpenClaw ACP, OpenCode, Gemini CLI, Qwen, Kiro, Kimi, iFlow, Factory Droid, Kilocode, or explicit ACP harness work into either OpenClaw ACP runtime sessions or direct acpx-driven sessions (\"telephone game\" flow). For coding-agent thread requests, read this skill first, then use only `sessions_spawn` for thread creation. Codex chat binding defaults to the native Codex app-server plugin unless ACP is explicit or background spawn needs ACP.","files":{"SKILL.md":"---\nname: acp-router\ndescription: Route plain-language requests for Pi, Claude Code, Cursor, Copilot, OpenClaw ACP, OpenCode, Gemini CLI, Qwen, Kiro, Kimi, iFlow, Factory Droid, Kilocode, or explicit ACP harness work into either OpenClaw ACP runtime sessions or direct acpx-driven sessions (\"telephone game\" flow). For coding-agent thread requests, read this skill first, then use only `sessions_spawn` for thread creation. Codex chat binding defaults to the native Codex app-server plugin unless ACP is explicit or background spawn needs ACP.\nuser-invocable: false\n---\n\n# ACP Harness Router\n\nWhen user intent is \"run this in Pi/Claude Code/Cursor/Copilot/OpenClaw/OpenCode/Gemini/Qwen/Kiro/Kimi/iFlow/Droid/Kilocode (ACP harness)\", do not use subagent runtime or PTY scraping. Route through ACP-aware flows.\n\nCodex is special: plain chat/conversation binding and control should use the native Codex app-server plugin (`/codex bind`, `/codex threads`, `/codex resume`) instead of the default ACP path. Use ACP for Codex only when the user explicitly names ACP/`/acp`/acpx, or when spawning background child sessions through `sessions_spawn` where a native Codex runtime spawn is not available yet.\n\n## Intent detection\n\nTrigger this skill when the user asks OpenClaw to:\n\n- run something in Pi / Claude Code / Cursor / Copilot / OpenClaw / OpenCode / Gemini / Qwen / Kiro / Kimi / iFlow / Droid / Kilocode\n- run Codex explicitly through ACP, `/acp`, or acpx\n- continue existing harness work\n- relay instructions to an external coding harness\n- keep an external harness conversation in a thread-like conversation\n\nMandatory preflight for coding-agent thread requests:\n\n- Before creating any thread for ACP harness work, read this skill first in the same turn.\n- After reading, follow `OpenClaw ACP runtime path` below; do not use `message(action=\"thread-create\")` for ACP harness thread spawn.\n\n## Mode selection\n\nChoose one of these paths:\n\n1. OpenClaw ACP runtime path (default): use `sessions_spawn` / ACP runtime tools.\n2. Direct `acpx` path (telephone game): use `acpx` CLI through `exec` to drive the harness session directly.\n\nUse direct `acpx` when one of these is true:\n\n- user explicitly asks for direct `acpx` driving\n- ACP runtime/plugin path is unavailable or unhealthy\n- the task is \"just relay prompts to harness\" and no OpenClaw ACP lifecycle features are needed\n\nDo not use:\n\n- `subagents` runtime for harness control\n- `/acp` command delegation as a requirement for the user\n- PTY scraping of supported ACP harness CLIs when `acpx` is available\n\n## AgentId mapping\n\nUse these defaults when user names a harness directly:\n\n- \"pi\" -\u003e `agentId: \"pi\"`\n- \"openclaw\" -\u003e `agentId: \"openclaw\"`\n- \"claude\" or \"claude code\" -\u003e `agentId: \"claude\"`\n- \"codex\" -\u003e `agentId: \"codex\"` only for explicit ACP/acpx requests or background ACP runtime spawn\n- \"copilot\" or \"github copilot\" -\u003e `agentId: \"copilot\"`\n- \"cursor\" or \"cursor cli\" -\u003e `agentId: \"cursor\"`\n- \"droid\" or \"factory droid\" -\u003e `agentId: \"droid\"`\n- \"opencode\" -\u003e `agentId: \"opencode\"`\n- \"gemini\" or \"gemini cli\" -\u003e `agentId: \"gemini\"`\n- \"iflow\" -\u003e `agentId: \"iflow\"`\n- \"kilocode\" -\u003e `agentId: \"kilocode\"`\n- \"kimi\" or \"kimi cli\" -\u003e `agentId: \"kimi\"`\n- \"kiro\" or \"kiro cli\" -\u003e `agentId: \"kiro\"`\n- \"qwen\" or \"qwen code\" -\u003e `agentId: \"qwen\"`\n\nThese defaults match current acpx built-in aliases.\n\nIf policy rejects the chosen id, report the policy error clearly and ask for the allowed ACP agent id.\n\n## OpenClaw ACP runtime path\n\nRequired behavior:\n\n1. For ACP harness thread spawn requests, read this skill first in the same turn before calling tools.\n2. Use `sessions_spawn` with:\n   - `runtime: \"acp\"`\n   - `thread: true`\n   - `mode: \"session\"` (unless user explicitly wants one-shot)\n3. For ACP harness thread creation, do not use `message` with `action=thread-create`; `sessions_spawn` is the only thread-create path.\n4. Put requested work in `task` so the ACP session gets it immediately.\n5. Set `agentId` explicitly unless ACP default agent is known.\n6. Do not ask user to run slash commands or CLI when this path works directly.\n\nExample:\n\nUser: \"spawn a test codex ACP session in thread and tell it to say hi\"\n\nCall:\n\n```json\n{\n  \"task\": \"Say hi.\",\n  \"runtime\": \"acp\",\n  \"agentId\": \"codex\",\n  \"thread\": true,\n  \"mode\": \"session\"\n}\n```\n\n## Thread spawn recovery policy\n\nWhen the user asks to start a coding harness in a thread, treat that as an ACP runtime request and try to satisfy it end-to-end.\n\nRequired behavior when ACP backend is unavailable:\n\n1. Do not immediately ask the user to pick an alternate path.\n2. First attempt automatic local repair:\n   - ensure plugin-local pinned acpx is installed in the ACPX plugin package\n   - verify `${ACPX_CMD} --version`\n3. After reinstall/repair, restart the gateway and explicitly offer to run that restart for the user.\n4. Retry ACP thread spawn once after repair.\n5. Only if repair+retry fails, report the concrete error and then offer fallback options.\n\nWhen offering fallback, keep ACP first:\n\n- Option 1: retry ACP spawn after showing exact failing step\n- Option 2: direct acpx telephone-game flow\n\nDo not default to subagent runtime for these requests.\n\n## ACPX install and version policy (direct acpx path)\n\nFor this repo, direct `acpx` calls must follow the same pinned policy as the `@openclaw/acpx` extension package.\n\n1. Prefer plugin-local binary, not global PATH:\n   - `${ACPX_PLUGIN_ROOT}/node_modules/.bin/acpx`\n2. Resolve pinned version from extension dependency:\n   - `node -e \"console.log(require(process.env.ACPX_PLUGIN_ROOT + '/package.json').dependencies.acpx)\"`\n3. If binary is missing or version mismatched, install plugin-local pinned version:\n   - `cd \"$ACPX_PLUGIN_ROOT\" \u0026\u0026 npm install --omit=dev --no-save acpx@\u003cpinnedVersion\u003e`\n4. Verify before use:\n   - `${ACPX_PLUGIN_ROOT}/node_modules/.bin/acpx --version`\n5. If install/repair changed ACPX artifacts, restart the gateway and offer to run the restart.\n6. Do not run `npm install -g acpx` unless the user explicitly asks for global install.\n\nSet and reuse:\n\n```bash\nACPX_PLUGIN_ROOT=\"\u003cbundled-acpx-plugin-root\u003e\"\nACPX_CMD=\"$ACPX_PLUGIN_ROOT/node_modules/.bin/acpx\"\n```\n\n## Direct acpx path (\"telephone game\")\n\nUse this path to drive harness sessions without `/acp` or subagent runtime.\n\n### Rules\n\n1. Use `exec` commands that call `${ACPX_CMD}`.\n2. Reuse a stable session name per conversation so follow-up prompts stay in the same harness context.\n3. Prefer `--format quiet` for clean assistant text to relay back to user.\n4. Use `exec` (one-shot) only when the user wants one-shot behavior.\n5. Keep working directory explicit (`--cwd`) when task scope depends on repo context.\n\n### Session naming\n\nUse a deterministic name, for example:\n\n- `oc-\u003charness\u003e-\u003cconversationId\u003e`\n\nWhere `conversationId` is thread id when available, otherwise channel/conversation id.\n\n### Command templates\n\nPersistent session (create if missing, then prompt):\n\n```bash\n${ACPX_CMD} codex sessions show oc-codex-\u003cconversationId\u003e \\\n  || ${ACPX_CMD} codex sessions new --name oc-codex-\u003cconversationId\u003e\n\n${ACPX_CMD} codex -s oc-codex-\u003cconversationId\u003e --cwd \u003cworkspacePath\u003e --format quiet \"\u003cprompt\u003e\"\n```\n\nOne-shot:\n\n```bash\n${ACPX_CMD} codex exec --cwd \u003cworkspacePath\u003e --format quiet \"\u003cprompt\u003e\"\n```\n\nCancel in-flight turn:\n\n```bash\n${ACPX_CMD} codex cancel -s oc-codex-\u003cconversationId\u003e\n```\n\nClose session:\n\n```bash\n${ACPX_CMD} codex sessions close oc-codex-\u003cconversationId\u003e\n```\n\n### Harness aliases in acpx\n\n- `claude`\n- `codex`\n- `copilot`\n- `cursor`\n- `droid`\n- `gemini`\n- `iflow`\n- `kilocode`\n- `kimi`\n- `kiro`\n- `openclaw`\n- `opencode`\n- `pi`\n- `qwen`\n\n### Built-in adapter commands in acpx\n\nDefaults are:\n\n- `openclaw -\u003e openclaw acp`\n- `claude -\u003e bundled @agentclientprotocol/claude-agent-acp@0.32.0`\n- `codex -\u003e bundled @zed-industries/codex-acp@0.13.0 through OpenClaw's isolated CODEX_HOME wrapper`\n- `copilot -\u003e copilot --acp --stdio`\n- `cursor -\u003e cursor-agent acp`\n- `droid -\u003e droid exec --output-format acp`\n- `gemini -\u003e gemini --acp`\n- `iflow -\u003e iflow --experimental-acp`\n- `kilocode -\u003e npx -y @kilocode/cli acp`\n- `kimi -\u003e kimi acp`\n- `kiro -\u003e kiro-cli acp`\n- `opencode -\u003e npx -y opencode-ai acp`\n- `pi -\u003e npx pi-acp@^0.0.22`\n- `qwen -\u003e qwen --acp`\n\nIf `~/.acpx/config.json` overrides `agents`, those overrides replace defaults.\nIf your local Cursor install still exposes ACP as `agent acp`, set that as the `cursor` agent override explicitly.\n\n### Failure handling\n\n- `acpx: command not found`:\n  - for thread-spawn ACP requests, install plugin-local pinned acpx in the ACPX plugin package immediately\n  - restart gateway after install and offer to run the restart automatically\n  - then retry once\n  - do not ask for install permission first unless policy explicitly requires it\n  - do not install global `acpx` unless explicitly requested\n- adapter command missing (for example `claude-agent-acp` not found):\n  - for thread-spawn ACP requests, first restore built-in defaults by removing broken `~/.acpx/config.json` agent overrides\n  - then retry once before offering fallback\n  - if user wants binary-based overrides, install exactly the configured adapter binary\n- `NO_SESSION`: run `${ACPX_CMD} \u003cagent\u003e sessions new --name \u003csessionName\u003e` then retry prompt.\n- queue busy: either wait for completion (default) or use `--no-wait` when async behavior is explicitly desired.\n\n### Output relay\n\nWhen relaying to user, return the final assistant text output from `acpx` command result. Avoid relaying raw local tool noise unless user asked for verbose logs.\n"},"import":{"commit_sha":"424c6d0a5f4665b803ad6768d08b0be7659deaf4","imported_at":"2026-05-18T20:13:36Z","license_text":"MIT License\n\nCopyright (c) 2025 Peter Steinberger\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","owner":"openclaw","repo":"openclaw/openclaw","source_url":"https://github.com/openclaw/openclaw/tree/424c6d0a5f4665b803ad6768d08b0be7659deaf4/extensions/acpx/skills/acp-router"}},"content_hash":[17,210,201,168,231,174,144,76,55,75,126,174,77,33,96,19,118,20,65,108,139,24,72,191,34,107,154,77,195,106,15,68],"trust_level":"unsigned","yanked":false}
