@1agents/acp-service 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/README.md +57 -33
  2. package/dist/bin/acp-service.js +2 -2
  3. package/dist/src/bridge.d.ts +2 -2
  4. package/dist/src/bridge.js +1 -1
  5. package/dist/src/catalog.js +20 -3
  6. package/dist/src/manifest.js +1 -1
  7. package/package.json +27 -8
  8. package/vendor/runtime/LICENSE +21 -0
  9. package/vendor/runtime/README.md +115 -0
  10. package/vendor/runtime/dist/agent-registry-CMg8LHKY.js +806 -0
  11. package/vendor/runtime/dist/agent-registry-CMg8LHKY.js.map +1 -0
  12. package/vendor/runtime/dist/agent-registry.d.ts +70 -0
  13. package/vendor/runtime/dist/agent-registry.d.ts.map +1 -0
  14. package/vendor/runtime/dist/agent-registry.js +2 -0
  15. package/vendor/runtime/dist/cli-DUHyAADv.js +182 -0
  16. package/vendor/runtime/dist/cli-DUHyAADv.js.map +1 -0
  17. package/vendor/runtime/dist/cli.d.ts +12 -0
  18. package/vendor/runtime/dist/cli.d.ts.map +1 -0
  19. package/vendor/runtime/dist/cli.js +2632 -0
  20. package/vendor/runtime/dist/cli.js.map +1 -0
  21. package/vendor/runtime/dist/client-DjkWknf7.d.ts +262 -0
  22. package/vendor/runtime/dist/client-DjkWknf7.d.ts.map +1 -0
  23. package/vendor/runtime/dist/docs-site/.nojekyll +0 -0
  24. package/vendor/runtime/dist/docs-site/CLI.html +832 -0
  25. package/vendor/runtime/dist/docs-site/CNAME +1 -0
  26. package/vendor/runtime/dist/docs-site/VISION.html +415 -0
  27. package/vendor/runtime/dist/docs-site/agents.html +391 -0
  28. package/vendor/runtime/dist/docs-site/compare.html +359 -0
  29. package/vendor/runtime/dist/docs-site/config.html +450 -0
  30. package/vendor/runtime/dist/docs-site/custom-agents.html +408 -0
  31. package/vendor/runtime/dist/docs-site/exit-codes.html +347 -0
  32. package/vendor/runtime/dist/docs-site/favicon.svg +21 -0
  33. package/vendor/runtime/dist/docs-site/flows.html +497 -0
  34. package/vendor/runtime/dist/docs-site/index.html +367 -0
  35. package/vendor/runtime/dist/docs-site/install.html +386 -0
  36. package/vendor/runtime/dist/docs-site/llms.txt +35 -0
  37. package/vendor/runtime/dist/docs-site/output-formats.html +403 -0
  38. package/vendor/runtime/dist/docs-site/permissions.html +413 -0
  39. package/vendor/runtime/dist/docs-site/prompting.html +460 -0
  40. package/vendor/runtime/dist/docs-site/proof-2026-07-18-grok-ext-methods/index.html +336 -0
  41. package/vendor/runtime/dist/docs-site/quickstart.html +382 -0
  42. package/vendor/runtime/dist/docs-site/runtime-environment.html +329 -0
  43. package/vendor/runtime/dist/docs-site/runtime-process-lifecycle.html +335 -0
  44. package/vendor/runtime/dist/docs-site/session-control.html +406 -0
  45. package/vendor/runtime/dist/docs-site/session-watch.html +354 -0
  46. package/vendor/runtime/dist/docs-site/sessions.html +486 -0
  47. package/vendor/runtime/dist/docs-site/shared-sessions.html +377 -0
  48. package/vendor/runtime/dist/flows-CiJSCy4D.js +2474 -0
  49. package/vendor/runtime/dist/flows-CiJSCy4D.js.map +1 -0
  50. package/vendor/runtime/dist/flows.d.ts +334 -0
  51. package/vendor/runtime/dist/flows.d.ts.map +1 -0
  52. package/vendor/runtime/dist/flows.js +2 -0
  53. package/vendor/runtime/dist/invocation-options-BlIySxIw.js +345 -0
  54. package/vendor/runtime/dist/invocation-options-BlIySxIw.js.map +1 -0
  55. package/vendor/runtime/dist/ipc-BlljKR2b.js +5336 -0
  56. package/vendor/runtime/dist/ipc-BlljKR2b.js.map +1 -0
  57. package/vendor/runtime/dist/output-BzXQKArM.js +1012 -0
  58. package/vendor/runtime/dist/output-BzXQKArM.js.map +1 -0
  59. package/vendor/runtime/dist/queue-owner-runtime-DSFdsS_y.js +8867 -0
  60. package/vendor/runtime/dist/queue-owner-runtime-DSFdsS_y.js.map +1 -0
  61. package/vendor/runtime/dist/runtime.d.ts +1156 -0
  62. package/vendor/runtime/dist/runtime.d.ts.map +1 -0
  63. package/vendor/runtime/dist/runtime.js +3675 -0
  64. package/vendor/runtime/dist/runtime.js.map +1 -0
  65. package/vendor/runtime/dist/session-options-ORCchZGk.d.ts +426 -0
  66. package/vendor/runtime/dist/session-options-ORCchZGk.d.ts.map +1 -0
  67. package/vendor/runtime/dist/session-watch-BiBTBMz4.js +76 -0
  68. package/vendor/runtime/dist/session-watch-BiBTBMz4.js.map +1 -0
  69. package/vendor/runtime/dist/watch-iYiP-lOo.js +85 -0
  70. package/vendor/runtime/dist/watch-iYiP-lOo.js.map +1 -0
  71. package/vendor/runtime/package.json +46 -0
  72. package/vendor/runtime/skills/acpx/SKILL.md +688 -0
@@ -0,0 +1,688 @@
1
+ ---
2
+ name: acpx
3
+ description: Use acpx as a headless ACP CLI for agent-to-agent communication, including installed-agent inspection, prompt/exec/sessions workflows, session scoping, queueing, permissions, output formats, system-prompt overrides, and multi-agent flows authored with defineFlow/decision/decisionEdge.
4
+ ---
5
+
6
+ # acpx
7
+
8
+ ## When to use this skill
9
+
10
+ Use this skill when you need to run coding agents through `acpx`, manage persistent ACP sessions, queue prompts, override the Claude system prompt, prune stale sessions, consume structured agent output from scripts, or compose multi-agent workflows declaratively with `acpx/flows`.
11
+
12
+ ## What acpx is
13
+
14
+ `acpx` is a headless, scriptable CLI client for the Agent Client Protocol (ACP). It is built for agent-to-agent communication over the command line and avoids PTY scraping.
15
+
16
+ Core capabilities:
17
+
18
+ - Persistent multi-turn sessions per repo/cwd
19
+ - One-shot execution mode (`exec`)
20
+ - Named parallel sessions (`-s/--session`)
21
+ - Idempotent session creation (`sessions ensure`)
22
+ - Session retention controls (`sessions prune` with age filters and history cleanup)
23
+ - Portable session export/import for moving records and history across machines
24
+ - Queue-aware prompt submission with optional fire-and-forget (`--no-wait`)
25
+ - Cooperative cancel command (`cancel`) for in-flight turns
26
+ - Graceful cancellation via ACP `session/cancel` on interrupt
27
+ - Session control methods (`set-mode`, `set <key> <value>`)
28
+ - Agent reconnect/resume after dead subprocess detection
29
+ - Prompt input via stdin or `--file`
30
+ - Config files with global+project merge and `config show|init`
31
+ - Session metadata/history inspection (`sessions show`, `sessions history`)
32
+ - Passive replay and live observation (`sessions watch -s <name> --cursor <cursor>`; omit the cursor for retained history)
33
+ - Local agent process checks via `status`
34
+ - Stable ACP client methods for filesystem and terminal requests; filesystem paths preserve symlink/parent traversal order within the working directory
35
+ - Stable ACP `authenticate` handshake via env/config credentials
36
+ - Structured streaming output (`text`, `json`, `quiet`) with optional `--suppress-reads`
37
+ - Prompt-response `_meta` preservation across direct, queued, compare, and embedded-runtime results
38
+ - Built-in agent registry plus raw `--agent` escape hatch
39
+ - Claude system prompt override via `--system-prompt` / `--append-system-prompt`
40
+ - Optional ACP filesystem and terminal capability opt-outs via `--no-fs` and `--no-terminal`
41
+ - Tool whitelist (`--allowed-tools`), turn cap (`--max-turns`), retry on transient failures (`--prompt-retries`)
42
+ - Multi-agent flows via `acpx flow run` and the `acpx/flows` authoring API (`defineFlow`, `decision`, `decisionEdge`, `acp`, `action`, `compute`, `checkpoint`)
43
+
44
+ ## Install
45
+
46
+ ```bash
47
+ npm i -g @scottzx/1acp
48
+ ```
49
+
50
+ The package installs both `1acp` and the upstream-compatible `acpx` command. For normal session reuse, prefer a global install over `npx`.
51
+
52
+ ## Command model
53
+
54
+ `prompt` is the default verb.
55
+
56
+ ```bash
57
+ acpx [global_options] [prompt_text...]
58
+ acpx [global_options] prompt [prompt_options] [prompt_text...]
59
+ acpx [global_options] exec [prompt_options] [prompt_text...]
60
+ acpx [global_options] compare <agent>... '<prompt_text>'
61
+ acpx [global_options] compare <agent>... --file <path>
62
+ acpx [global_options] cancel [-s <name>]
63
+ acpx [global_options] set-mode <mode> [-s <name>]
64
+ acpx [global_options] set <key> <value> [-s <name>]
65
+ acpx [global_options] status [-s <name>]
66
+ acpx [global_options] sessions [list | new [--name <name>] | ensure [--name <name>] | close [name] | show [name] | history [name] [--limit <count>] | watch [-s <name>] [--cursor <cursor>] | export [name] --output <path> | import <archive> [--name <name>] [--cwd <dir>] | prune [--dry-run] [--before <date> | --older-than <days>] [--include-history]]
67
+ acpx [global_options] config [show | init]
68
+ acpx [global_options] flow run <file> [--input-json '<json>' | --input-file <path>] [--default-agent <name>]
69
+
70
+ acpx [global_options] <agent> [prompt_options] [prompt_text...]
71
+ acpx [global_options] <agent> prompt [prompt_options] [prompt_text...]
72
+ acpx [global_options] <agent> exec [prompt_options] [prompt_text...]
73
+ acpx [global_options] <agent> cancel [-s <name>]
74
+ acpx [global_options] <agent> set-mode <mode> [-s <name>]
75
+ acpx [global_options] <agent> set <key> <value> [-s <name>]
76
+ acpx [global_options] <agent> status [-s <name>]
77
+ acpx [global_options] <agent> sessions [list | new [--name <name>] | ensure [--name <name>] | close [name] | show [name] | history [name] [--limit <count>] | watch [-s <name>] [--cursor <cursor>] | export [name] --output <path> | import <archive> [--name <name>] [--cwd <dir>] | prune [--dry-run] [--before <date> | --older-than <days>] [--include-history]]
78
+ ```
79
+
80
+ If prompt text is omitted and stdin is piped, `acpx` reads prompt text from stdin.
81
+
82
+ ## Built-in agent registry
83
+
84
+ The `@1agents/acp-service` host prefers adapter packages in its search roots, then installed adapter executables, before using npx. JavaScript adapter executables run with the service's Node interpreter. Embedded Mux inspection recognizes the installed `mux acp` entrypoint. A startup diagnostic containing npm `ENOTEMPTY` inside `_npx` identifies a cache directory replacement failure: upgrade npm and move that affected directory aside only after ensuring no installation is using it, then retry.
85
+
86
+ Friendly agent names resolve to commands:
87
+
88
+ - `pi` -> `npx pi-acp` (ACPX-owned package range; see `agents/Pi.md`)
89
+ - `openclaw` -> `openclaw acp` (see the [OpenClaw guide](https://github.com/openclaw/acpx/blob/main/agents/OpenClaw.md))
90
+ - `codex` -> `npx -y @agentclientprotocol/codex-acp` (ACPX-owned package range)
91
+ - `claude` -> `npx -y @agentclientprotocol/claude-agent-acp` (ACPX-owned package range; see `agents/Claude.md`)
92
+ - `gemini` -> `gemini --acp`
93
+ - `cursor` -> `cursor-agent acp`
94
+ - `copilot` -> `copilot --acp --stdio`
95
+ - `antigravity` -> `agy_acp_server.par` (`--uid=` on Linux; `agy_acp_server.exe` on Windows). Install the official runtime/helper pair and configure its own sign-in first; see [Antigravity](https://github.com/openclaw/acpx/blob/main/agents/Antigravity.md). Fixed-choice interaction questions are cancelled, including with `--approve-all`, host permission callbacks, and existing custom launchers; acpx cannot supply user answers through permission approval.
96
+ - `devin` -> `devin acp`
97
+ - `droid` -> `droid exec --output-format acp` (`factory-droid` and `factorydroid` also resolve to `droid`)
98
+ - `fast-agent` -> `uvx fast-agent-mcp acp`
99
+ - `fx` -> `fx acp` (install and authenticate a provider first; see the [fx guide](https://github.com/openclaw/acpx/blob/main/agents/Fx.md))
100
+ - `grok-build` -> `grok agent stdio`
101
+ - `iflow` -> `iflow --experimental-acp`
102
+ - `junie` -> `junie --acp=true` (install and authenticate Junie first; see the [Junie guide](https://github.com/openclaw/acpx/blob/main/agents/Junie.md))
103
+ - `kilocode` -> `npx -y @kilocode/cli acp`
104
+ - `kimi` -> `kimi acp`
105
+ - `kiro` -> `kiro-cli-chat acp`
106
+ - `mcode` -> `mcode acp` (install/authenticate MCode first; prefer `exec` for one-shot work, and require advertised ACP reload support for cross-invocation continuity)
107
+ - `mux` -> `mux acp` via an ACPX-owned npm range
108
+ - `opencode` -> `npx -y opencode-ai acp`
109
+ - `pool` -> `pool acp`
110
+ - `qoder` -> `qodercli --acp`
111
+ Forwards Qoder-native `--allowed-tools` and `--max-turns` startup flags from `acpx` session options.
112
+ - `qwen` -> `qwen --acp`
113
+ - `trae` -> `traecli acp serve`
114
+ - `zeroclaw` -> `zeroclaw acp`
115
+
116
+ Rules:
117
+
118
+ - Default agent is `codex` for top-level `prompt`, `exec`, and `sessions`.
119
+ - Unknown positional agent tokens are treated as raw agent commands.
120
+ - `--agent <command>` explicitly sets a raw ACP adapter command.
121
+ - Do not combine a positional agent and `--agent` in the same command.
122
+ - Gemini version checks, Copilot ACP support checks, and their startup diagnostics use the selected agent's working directory and child environment, including session environment and embedded runtime overrides.
123
+ - Embedded host lifecycle admission also covers compatibility and diagnostic invocations. Correlate their events by `launchId`; one session can produce several adapter processes. Checks retire their owned processes and output pipes before settling.
124
+
125
+ ## Embedded hosts
126
+
127
+ When embedding ACPX, import `createAgentRegistry` from `acpx/agent-registry` and use `inspect(agentId)` to obtain installed launch facts without starting an agent. Treat `undefined` as uninspectable. Check the returned missing command/package requirements before acquiring a session; recheck when launching because installed files can change. Authentication and native model discovery belong to session acquisition.
128
+
129
+ Custom registry names such as `constructor` and `__proto__` work with resolution, listing, and inspection. Without an explicit registry entry, unknown names remain raw commands.
130
+
131
+ Use `getStatus({ handle }).models.availableModels` when present for native display names, and pass the selected opaque model ID, including any slashes, unchanged to `setModel`. Model changes validate against the connected session's advertised models, including after reconnect. `setConfigOption` applies the same validation when `key` names the advertised model option and returns that operation's native ACP response with the accepted `configOptions`. Use the response to update model and reasoning controls together. Embedded callers can identify unknown or ambiguous model failures with `isRequestedModelUnsupportedError(error)` and `error.reason === "unadvertised-model"`. When a Cursor alias matches multiple advertised variants, the error also has `ambiguous: true`; a selector with no advertised match omits that flag. Claude ACP retains its forwarding exception for selectors absent from its advertised list.
132
+
133
+ Use `prepareFreshSession({ handle })` to persist a fresh-session request across restart, then ensure without `resumeSessionId`. Ordinary `close` retains session continuity; explicit remote discard requires the adapter’s optional close capability.
134
+
135
+ Embedded controls save accepted settings with the current conversation. Turn finalization and one-shot cleanup wait for admitted controls, preserving final output, usage, and selections in the saved session. Ordinary `close` can return before active prompt cancellation finishes; the later save preserves its close/reset markers.
136
+
137
+ For persistent sessions, compatible `ensureSession` calls may reuse an active record, including from permission callbacks during control reconnects. Changing its working directory, adapter invocation, or resume identity while turns or controls remain unfinished rejects with `ACP_SESSION_INIT_FAILED`; await that work or use a different key. After an active close, await its turn result before reopening. Idle replacement retires the old owner before initializing the successor; other records and distinct one-shot sessions remain independent.
138
+
139
+ For installed entrypoints and prerequisites, read the matching [agent guide](https://github.com/openclaw/acpx/tree/main/agents). For resolver callbacks, custom command overrides, and lifecycle details, read [embedded agent discovery](https://github.com/openclaw/acpx/blob/main/docs/session-control.md#embedded-agent-discovery).
140
+
141
+ ## Commands
142
+
143
+ ### Prompt (default, persistent session)
144
+
145
+ Implicit:
146
+
147
+ ```bash
148
+ acpx codex 'fix flaky tests'
149
+ ```
150
+
151
+ Explicit:
152
+
153
+ ```bash
154
+ acpx codex prompt 'fix flaky tests'
155
+ acpx prompt 'fix flaky tests' # defaults to codex
156
+ ```
157
+
158
+ Behavior:
159
+
160
+ - Uses a saved session for the session scope key
161
+ - Auto-resumes prior session when one exists for that scope
162
+ - If no session exists for the scope, exits with `NO_SESSION` and prompts for `sessions new`
163
+ - Is queue-aware when another prompt is already running for the same session
164
+ - On interrupt during an active turn, sends ACP `session/cancel` before force-kill fallback
165
+
166
+ Prompt options:
167
+
168
+ - `-s, --session <name>`: use a named session within the same cwd
169
+ - `--no-wait`: enqueue and return immediately when session is already busy
170
+ - `-f, --file <path>`: read prompt text from file (`-` means stdin)
171
+
172
+ ### Exec (one-shot)
173
+
174
+ ```bash
175
+ acpx exec 'summarize this repo'
176
+ acpx codex exec 'summarize this repo'
177
+ acpx --model gpt-5.6-sol codex exec --config-option reasoning_effort=xhigh 'review this repo'
178
+ ```
179
+
180
+ Behavior:
181
+
182
+ - Runs a single prompt in a temporary ACP session
183
+ - Applies `--model`, then repeatable `--config-option <key=value>` selections, before prompting
184
+ - Fails before the prompt if the adapter rejects a requested config option
185
+ - Does not reuse or save persistent session state
186
+
187
+ ### Compare (multi-agent one-shot)
188
+
189
+ ```bash
190
+ acpx compare pi openclaw codex 'summarize this checkout'
191
+ acpx --format json compare codex claude --file prompt.md
192
+ ```
193
+
194
+ Behavior:
195
+
196
+ - Runs the same temporary-session prompt against each listed agent
197
+ - Runs agents serially in the requested workspace
198
+ - Reuses the global `exec` controls: cwd, timeout, permissions, `--policy`, auth, terminal, retries, model/system options, and output format
199
+ - `--format text` prints one summary table row per agent
200
+ - `--format json` or `--json` prints `CompareRow[]`
201
+ - `--format quiet` prints `<agent>\t<status>` per row
202
+ - Does not create saved sessions or separate compare transcript directories
203
+
204
+ ### Cancel / Mode / Config / Model
205
+
206
+ ```bash
207
+ acpx codex cancel
208
+ acpx codex set-mode auto
209
+ acpx codex set model gpt-5.6-sol
210
+ acpx codex set reasoning_effort max
211
+ ```
212
+
213
+ Behavior:
214
+
215
+ - `cancel`: sends cooperative `session/cancel` through queue-owner IPC.
216
+ - `set-mode`: calls ACP `session/set_mode`.
217
+ - `set-mode` mode ids are adapter-defined; unsupported values are rejected by the adapter (often `Invalid params`).
218
+ - On allowed fresh fallback, `set-mode` replaces the old saved mode without replaying it. Other saved settings restore first; the new mode preference is saved only after acceptance.
219
+ - Prompt reconnect uses model metadata received while restoring a saved mode before replaying the selected model, and retains changed or removed model support in the final session metadata.
220
+ - `set`: calls ACP `session/set_config_option`.
221
+ - A config key named `mode` keeps config-option transport; explicit `set-mode` uses the separate `session/set_mode` control.
222
+ - Current codex-acp releases expose `model` and `reasoning_effort` as separate config options.
223
+ - `--model <id>`: Claude-compatible adapters may consume session creation metadata; other agents must advertise a model config option or legacy `models` metadata.
224
+ - `set model <id>`: validates against the connected session's advertised models, uses `session/set_config_option` for model config options, and preserves `session/set_model` for explicitly advertised legacy models. Claude Code still accepts or rejects selectors absent from its advertised list.
225
+ - Model switches can change or remove reasoning-effort controls. ACPX reconciles saved config selections with the accepted response; select a supported effort again if needed.
226
+ - After reconnect, ACPX restores the saved model when advertised and replays saved config selections before prompting. A replay failure is reported instead of silently using defaults.
227
+ - `set-mode`/`set` route through queue-owner IPC when active, otherwise reconnect directly.
228
+
229
+ ### Sessions
230
+
231
+ Use `acpx --format json pi sessions watch -s reviewer` to observe another client's work. Resume with `--cursor` using the last event's opaque cursor. Watchers do not cancel turns when stopped; use `turn_result` for the settled outcome, and treat owner-loss errors as unknown outcomes rather than retry instructions. See [Watching sessions](https://github.com/openclaw/acpx/blob/main/docs/session-watch.md).
232
+
233
+ ```bash
234
+ acpx sessions
235
+ acpx sessions list
236
+ acpx sessions list --filter-cwd .
237
+ acpx sessions list --cursor <cursor>
238
+ acpx sessions list --local
239
+ acpx sessions new
240
+ acpx sessions new --name backend
241
+ acpx sessions ensure
242
+ acpx sessions ensure --name backend
243
+ acpx sessions close
244
+ acpx sessions close backend
245
+ acpx sessions show
246
+ acpx sessions history --limit 20
247
+ acpx sessions export backend --output backend-session.json
248
+ acpx sessions import backend-session.json --name backend-restored
249
+ acpx sessions prune --dry-run --older-than 7
250
+ acpx sessions prune --older-than 30 --include-history
251
+ acpx status
252
+
253
+ acpx codex sessions
254
+ acpx codex sessions new --name backend
255
+ acpx codex sessions ensure --name backend
256
+ acpx codex sessions close backend
257
+ acpx codex sessions show backend
258
+ acpx codex sessions history backend --limit 20
259
+ acpx codex sessions export backend --output backend-session.json
260
+ acpx codex sessions import backend-session.json --name backend-restored
261
+ acpx codex sessions prune --before 2026-04-01 --include-history
262
+ acpx codex status
263
+ ```
264
+
265
+ Behavior:
266
+
267
+ - `sessions` and `sessions list` are equivalent
268
+ - `sessions list` uses ACP `session/list` when the agent advertises it; JSON
269
+ includes agent `SessionInfo`, `_meta`, and `nextCursor`
270
+ - `sessions list --filter-cwd <dir>` applies the ACP cwd filter, and
271
+ `--cursor <cursor>` requests a specific page
272
+ - `sessions list --local` reads saved acpx records instead
273
+ - `new` creates a fresh session for the current `(agentCommand, cwd, optional name)` scope
274
+ - `new --name <name>` targets a named session scope
275
+ - when `new` replaces an existing open session in that scope, the old one is soft-closed
276
+ - `ensure` returns the nearest matching active session for the scope, or creates one when none is open. Idempotent — safe to call before every prompt in scripts.
277
+ - `close` targets current cwd default session
278
+ - `close <name>` targets current cwd named session
279
+ - `show [name]` prints stored metadata for that scoped session
280
+ - `history [name]` prints stored turn history previews (default 20, use `--limit`)
281
+ - `export [name] --output <path>` writes a portable JSON archive containing session state and event history
282
+ - `import <archive>` creates a fresh local record, reopens the copied session as idle, keeps the provider session id, and clears source-machine process metadata
283
+ - imported sessions must resume that provider session; if the destination agent cannot load it, prompts fail clearly instead of starting an empty conversation
284
+ - `import --name <name>` and `--cwd <dir>` override the destination scope; import fails if that scope already has an active session or another local record already uses the same provider session id
285
+ - `prune` deletes closed session records to reclaim disk space
286
+ - `--dry-run` previews what would be deleted without touching disk
287
+ - `--older-than <days>` and `--before <date>` filter by close time, falling back to last-used time when a record was never explicitly closed
288
+ - `--include-history` also removes per-session event stream files (otherwise only the JSON record is removed)
289
+
290
+ ## Global options
291
+
292
+ - `--agent <command>`: raw ACP agent command (escape hatch)
293
+ - `--cwd <dir>`: working directory for session scope (default: current directory)
294
+ - `--approve-all`: approve tool permission requests not resolved by a per-tool policy
295
+ - `--approve-reads`: approve remaining read/search requests and prompt for other tools (default mode)
296
+ - `--deny-all`: deny tool permission requests not resolved by a per-tool policy
297
+ - `--non-interactive-permissions <policy>`: choose `deny` or `fail` when the permission mode requires a prompt but stdin or stderr is not a TTY
298
+ - `--permission-policy <json-or-file>` / `--policy`: per-tool ACP permission rules that take precedence over the permission mode
299
+ - `--format <fmt>`: output format (`text`, `json`, `quiet`)
300
+ - `--json-strict`: strict JSON mode; requires `--format json` and suppresses non-JSON stderr output
301
+ - `--suppress-reads`: suppress raw read-file contents while preserving the selected format
302
+ - `--timeout <seconds>`: response deadline (positive number); partial text is not completion. A final response during the bounded drain keeps its actual outcome. Queued prompts wait for cancellation and retirement of unfinished connections before reconnecting to the saved session; cleanup can extend elapsed time beyond the deadline.
303
+ - `--ttl <seconds>`: queue owner idle TTL before shutdown (default `300`, `0` disables TTL)
304
+ - `--model <id>`: request an agent model during session creation; non-Claude agents must advertise a model config option or legacy `models` metadata
305
+ - `--system-prompt <text>`: replace the agent system prompt. Forwarded to claude-agent-acp via ACP `_meta.systemPrompt`; persisted in `session_options.system_prompt` so reuse keeps the override. Other agents ignore the field.
306
+ - `--append-system-prompt <text>`: append text to the agent system prompt. Forwarded to claude-agent-acp via ACP `_meta.systemPrompt.append`; same persistence rules as `--system-prompt`. Both system-prompt flags also apply to persistent and isolated ACP nodes in `flow run`.
307
+ - `--allowed-tools <list>`: comma-separated tool whitelist (use `""` for no tools)
308
+ - `--max-turns <count>`: cap session turn count
309
+ - `--prompt-retries <count>`: retry failed prompt turns on transient errors (default `0`); cancelling a queued turn stops remaining attempts, while already-received final responses keep their outcome
310
+ - `--no-fs`: disable ACP filesystem callbacks so compatible agents use their native file operations. This is a protocol callback policy, not an OS sandbox for the agent's own filesystem access.
311
+ - `--no-terminal`: disable the ACP terminal callback. This is a protocol callback policy, not an OS sandbox for the agent's own process access.
312
+ - `--verbose`: verbose ACP/debug logs to stderr
313
+
314
+ Cursor may advertise bracketed model IDs such as `composer-2.5[fast=false]`. An exact
315
+ advertised ID always wins. Only Cursor accepts a bare model name through a unique
316
+ advertised bracketed variant; unknown or ambiguous names are rejected before the
317
+ model change. This rule uses the current connected catalog for `set model`, embedded
318
+ `setModel`, and model selections through `setConfigOption`, including after reconnect.
319
+
320
+ An acknowledged model alias is saved as the resolved current model ID; its original spelling remains the preference replayed on reconnect. Non-list config catalogs are treated as acknowledgements, while an explicit empty list withdraws the catalog.
321
+
322
+ Permission flags are mutually exclusive.
323
+
324
+ ## System prompt override (Claude)
325
+
326
+ `--system-prompt` and `--append-system-prompt` let you specialize a Claude session without leaving lingering one-off state, while still benefiting from persistent session reuse.
327
+
328
+ ```bash
329
+ # Create a named session with a replacement system prompt.
330
+ acpx --system-prompt "You are a code reviewer who challenges every implicit assumption." \
331
+ claude sessions new --name review
332
+ acpx claude -s review 'review the current diff'
333
+
334
+ # Create a named session with an appended guideline.
335
+ acpx --append-system-prompt "Always explain trade-offs before recommending a fix." \
336
+ claude sessions new --name impl
337
+ acpx claude -s impl 'implement the requested change'
338
+ ```
339
+
340
+ Run the creation command once, then select the session with `-s` for later prompts. Running `sessions new` again in the same scope closes the prior local record and creates a fresh session.
341
+
342
+ The override is forwarded via ACP `_meta.systemPrompt` (or `_meta.systemPrompt.append`) on `session/new`, `session/load`, and `session/resume` and stored in `session_options.system_prompt`. Subsequent `prompt`/`ensure` calls in the same scope keep the override unless you explicitly create a new session. Non-Claude adapters ignore the field, so the same flag is safe inside cross-agent scripts.
343
+
344
+ Embedded `SessionAgentOptions.systemPrompt` preserves raw nonempty replacement or append text through saving and reconnecting, including whitespace-only text. CLI prompt flags trim surrounding whitespace and reject whitespace-only values.
345
+
346
+ ## Claude settings isolation
347
+
348
+ Built-in `acpx claude` sessions load Claude project and local settings, but not
349
+ user settings. The same isolation and saved session options apply on creation,
350
+ load, and resume. This prevents globally enabled channel and daemon plugins from
351
+ claiming singleton external resources in an ACP-spawned session.
352
+
353
+ Set `ACPX_CLAUDE_INCLUDE_USER_SETTINGS=1` only when the spawned session needs
354
+ the user's global Claude settings and no such plugin conflict exists. Ambient
355
+ credentials and other environment variables are still inherited normally.
356
+
357
+ On Windows, native Claude executable discovery resolves relative `PATH` entries
358
+ from the selected session cwd. An explicit `CLAUDE_CODE_EXECUTABLE` still takes
359
+ precedence.
360
+
361
+ ## Sessions cleanup
362
+
363
+ Closed session records accumulate on disk by default. Use `sessions prune` to enforce retention:
364
+
365
+ ```bash
366
+ # Preview what would be deleted (no writes)
367
+ acpx codex sessions prune --dry-run --older-than 7
368
+
369
+ # Remove records closed more than 30 days ago, including their event-stream files
370
+ acpx codex sessions prune --older-than 30 --include-history
371
+
372
+ # Remove everything closed before a date
373
+ acpx codex sessions prune --before 2026-04-01
374
+ ```
375
+
376
+ Without `--include-history`, only the lightweight JSON record is removed; event-stream files are preserved for audit. With it, the per-session event log is also deleted to reclaim disk space.
377
+
378
+ ## Config files
379
+
380
+ Config files are merged in this order (later wins):
381
+
382
+ - global: `~/.acpx/config.json`
383
+ - project: `<cwd>/.acpxrc.json`
384
+
385
+ Supported keys:
386
+
387
+ - `defaultAgent`
388
+ - `defaultPermissions` (`approve-all`, `approve-reads`, `deny-all`)
389
+ - `nonInteractivePermissions` (`deny`, `fail`)
390
+ - `ttl` (seconds)
391
+ - `timeout` (seconds or `null`)
392
+ - `format` (`text`, `json`, `quiet`)
393
+ - `agents` map (`name -> { argv: [executable, ...args] }`); structured argv is required on Windows, and legacy `{ command, args }` entries migrate automatically
394
+ - `auth` map (`authMethodId -> credential`)
395
+
396
+ Use `acpx config show` to inspect the resolved config and `acpx config init` to create the global template.
397
+
398
+ For ACP `authenticate` handshakes, use either config `auth` entries or explicit
399
+ `ACPX_AUTH_<METHOD_ID>` environment variables such as `ACPX_AUTH_OPENAI_API_KEY`.
400
+ Ambient provider env vars such as `OPENAI_API_KEY` are still passed through to
401
+ child agents, but they do not trigger ACP auth-method selection on their own.
402
+
403
+ ## Devin ACP compatibility
404
+
405
+ The `devin` shortcut runs the installed Devin CLI. Authenticate with Devin before starting sessions:
406
+
407
+ ```bash
408
+ acpx devin exec 'summarize this repo'
409
+ ```
410
+
411
+ `acpx --model <id> devin` uses the advertised ACP model config option. Raw `--agent` overrides remain available for launch flags. Devin launches retain their scoped Windsurf-compatible identity; see [`agents/Devin.md`](https://github.com/openclaw/acpx/blob/main/agents/Devin.md) for detection, version overrides, capabilities, and extension handling.
412
+
413
+ ## Session behavior
414
+
415
+ Persistent prompt sessions are scoped by:
416
+
417
+ - `agentCommand`
418
+ - absolute `cwd`
419
+ - optional session `name`
420
+
421
+ Persistence:
422
+
423
+ - Session records are stored in `~/.acpx/sessions/*.json`.
424
+ - `-s/--session` selects a named conversation; create it with `sessions new --name <name>` or `sessions ensure --name <name>` before prompting.
425
+ - Changing `--cwd` changes scope and therefore session lookup.
426
+ - Records saved under an earlier default command of a built-in agent, such as a previous ACPX-owned adapter range, are read as that agent's current command, so they stay in scope after an ACPX upgrade. Records with a custom launcher keep it. When both an upgraded and a current record match a scope, the most recently used one wins.
427
+ - closed sessions are retained on disk with `closed: true` and `closedAt` until pruned.
428
+ - auto-resume by scope skips closed sessions.
429
+
430
+ Resume behavior:
431
+
432
+ - Prompt mode attempts to reconnect to saved session.
433
+ - If adapter-side session is invalid/not found, `acpx` creates a fresh session and updates the saved record.
434
+ - explicitly selected session records can still be resumed via `loadSession` even if previously closed.
435
+ - dead saved PIDs are detected and reconnected on the next prompt.
436
+ - each completed prompt stores lightweight turn history previews in the session record.
437
+
438
+ ## Prompt queueing and `--no-wait`
439
+
440
+ Queueing is per persistent session.
441
+
442
+ - The active `acpx` process for a running prompt becomes the queue owner.
443
+ - Other invocations submit prompts over local IPC.
444
+ - On Unix-like systems, queue IPC uses `/tmp/acpx-<home-hash>/<session-hash>.sock`.
445
+ - Ownership is coordinated with a lease file at `~/.acpx/queues/<session-hash>.lock`.
446
+ - Persistent turns retain a separate filesystem guard through checkpoint and cleanup. Waiting can be cancelled; admitted ownership ends only after cleanup. Live guards never expire by age, and ambiguous guard state is preserved. See [session ownership](../../docs/sessions.md#queue-ownership).
447
+ - On Windows, named pipes are used instead of Unix sockets.
448
+ - after the queue drains, owner shutdown is governed by TTL (default 300s, configurable with `--ttl`).
449
+ - Session controls use the retained adapter while active or idle, and the owner saves accepted settings before success. Idle controls keep the owner alive; prompt completion and close drain admitted controls. Treat timed-out settings as uncertain and do not repeat them automatically. Older callers or retained owners keep their previous persistence behavior.
450
+
451
+ Submission behavior:
452
+
453
+ - Default: enqueue and wait for queued prompt completion, streaming updates back.
454
+ - `--no-wait`: enqueue and return after queue acknowledgement.
455
+ - `Ctrl+C` during an active turn sends ACP `session/cancel`, waits briefly, then force-kills only if cancellation does not finish in time.
456
+ - `cancel` sends the same cooperative cancellation without requiring terminal signals.
457
+
458
+ ## Output formats
459
+
460
+ Use `--format <fmt>`:
461
+
462
+ - `text` (default): human-readable stream with updates/tool status and done line
463
+ - `json`: NDJSON event stream (good for automation)
464
+ - `quiet`: final assistant text on stdout; failed prompts emit one structured `[acpx] error:` line on stderr
465
+ - `--suppress-reads`: replace raw read-file contents with `[read output suppressed]` in `text` and `json` output
466
+ - `--json-strict`: pair with `--format json` to suppress non-JSON stderr noise (logs, banners) for downstream consumers
467
+
468
+ Example automation:
469
+
470
+ ```bash
471
+ acpx --format json codex exec 'review changed files' \
472
+ | jq -r 'select(.method=="session/update") | .params.update
473
+ | select(.sessionUpdate=="tool_call" or .sessionUpdate=="tool_call_update")
474
+ | [(.status // "-"), (.title // "-")] | @tsv'
475
+ ```
476
+
477
+ ## Permission modes
478
+
479
+ For ACP tool permission requests, per-tool policy takes precedence over the permission mode. Rules are evaluated in this order: `autoDeny`, `autoApprove`, `escalate`, then `defaultAction`. The selected mode applies only when the policy does not resolve the request.
480
+
481
+ - `--approve-all`: approve remaining tool permission requests without prompting
482
+ - `--approve-reads` (default): approve remaining read/search requests and prompt for other tools
483
+ - `--deny-all`: deny remaining tool permission requests
484
+ - `--non-interactive-permissions <deny|fail>`: choose what happens when the mode requires a prompt but stdin or stderr is not a TTY
485
+ - `--policy <json-or-file>`: match ACP tool permission requests by kind, title, title head, or raw input tool name
486
+
487
+ An `autoApprove` rule can approve a tool request under `--deny-all`. An `escalate` rule can prompt under `--approve-all` when stdin and stderr are TTYs. Without both TTYs, escalation denies or cancels the current request and adds `_meta.acpx.permissionEscalation` to the ACP response, even when `--non-interactive-permissions fail` is selected.
488
+
489
+ Per-tool policies govern `session/request_permission`. ACP filesystem and terminal operations use the client's permission mode separately; a tool approval does not bypass those operation checks.
490
+
491
+ If every permission request is denied/cancelled and none approved, `acpx` exits with permission-denied status.
492
+
493
+ Interactive tool, file-write, and terminal questions are serialized within each acpx process. Each question needs a separate answer; EOF denies active and waiting questions.
494
+
495
+ Pending permissions, file operations, and terminal creation retain their admitting prompt's lifetime. Cancelled, completed, timed-out, superseded, or closed prompts cannot gain new mutation/spawn authority from late answers. Individual ACP request cancellation stays local to that request. Already-dispatched OS work is not rolled back.
496
+
497
+ When a tool kind is absent, read/search approval is inferred only from complete leading action words. Filenames or substrings in other action titles do not grant approval; ambiguous titles still require the normal permission decision.
498
+
499
+ Codex refusals prefer an offered non-cancelling one-time rejection. If safe refusal uses cancellation, acpx explains the possible turn termination in text output, quiet stderr, JSON response `_meta.acpx.permissionNotice`, and embedded status events. Permission denial never grants the requested operation. See [Codex](https://github.com/openclaw/acpx/blob/main/agents/Codex.md#permission-refusals).
500
+
501
+ ## Flows (multi-agent workflows)
502
+
503
+ Flows let you declare a multi-agent workflow as a graph of typed nodes connected by edges, executed by the `acpx` runtime. The runtime owns persistence, retries, timeouts, and routing — the flow file declares the shape, not the engine.
504
+
505
+ ### Run a flow
506
+
507
+ ```bash
508
+ acpx flow run ./my-flow.flow.ts --input-file ./flow-input.json
509
+ acpx flow run ./my-flow.flow.ts --input-json '{"task":"FIX: add a regression test"}'
510
+ acpx --approve-all flow run examples/flows/pr-triage/pr-triage.flow.ts \
511
+ --input-json '{"repo":"openclaw/acpx","prNumber":150}'
512
+ acpx flow run ./my-flow.flow.ts --default-agent claude
513
+ ```
514
+
515
+ Run artifacts persist under `~/.acpx/flows/runs/<runId>/`. Default per-step timeout is 15 minutes when `--timeout` is unset; flows that declare permission requirements fail fast before starting.
516
+
517
+ Each attempt has one deadline across preparation, execution, and parsing. Callbacks receive `context.signal`; function actions also receive `context.runShell` to run commands whose processes and output streams the runner owns. A command's own timeout returns partial output with `timedOut: true`; enclosing node cancellation rejects after cleanup and prevents later managed commands. Admitted runtime writes finish before routing or final publication. Check the signal around custom asynchronous side effects: arbitrary JavaScript cannot be forcibly stopped, and completed effects are not rolled back. Persistent reconnects must load the same backend session or fail. See `docs/flows.md` for the command result and cancellation contracts.
518
+
519
+ ### Authoring a flow
520
+
521
+ The authoring surface lives in `acpx/flows`. The minimal example:
522
+
523
+ ```ts
524
+ import { acp, decision, decisionEdge, defineFlow, checkpoint, extractJsonObject } from "acpx/flows";
525
+
526
+ const choices = ["bug", "feat", "doc"] as const;
527
+
528
+ export default defineFlow({
529
+ name: "pr-triage",
530
+ startAt: "classify",
531
+ nodes: {
532
+ classify: decision({
533
+ choices,
534
+ question: ({ input }) =>
535
+ `Classify the PR description below. Reply with one of: ${choices.join(", ")}.\n\n${input.description}`,
536
+ }),
537
+ bug_lane: acp({
538
+ prompt: ({ outputs }) =>
539
+ `The PR is a bug. Write a regression test that reproduces it.\n\nDecision context: ${JSON.stringify(outputs.classify)}`,
540
+ parse: (text) => extractJsonObject(text),
541
+ }),
542
+ feat_lane: acp({
543
+ prompt: () => "List acceptance criteria for the feature, one bullet per criterion.",
544
+ }),
545
+ doc_lane: checkpoint({
546
+ summary: "doc change — needs human review",
547
+ run: ({ outputs }) => ({ route: "doc", note: outputs.classify }),
548
+ }),
549
+ },
550
+ edges: [
551
+ decisionEdge({
552
+ from: "classify",
553
+ choices,
554
+ cases: {
555
+ bug: "bug_lane",
556
+ feat: "feat_lane",
557
+ doc: "doc_lane",
558
+ },
559
+ }),
560
+ ],
561
+ });
562
+ ```
563
+
564
+ ### Node types
565
+
566
+ | Type | Purpose |
567
+ | --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
568
+ | `acp({ prompt, parse?, agent?, cwd? })` | Model-driven step. The `prompt` builder receives `{ input, outputs }`. Optional `parse` coerces the raw text (e.g., `extractJsonObject`). |
569
+ | `decision({ choices, question })` | Constrained-choice LLM step. `choices` is a `readonly` tuple; the runtime validates the model's reply against it and TypeScript infers the union from `choices`. |
570
+ | `action(...)` | Runtime-supervised deterministic operation: shell, GitHub API, test execution, comment posting. |
571
+ | `compute(...)` | Pure local data transform: normalization, routing key derivation, signal reduction. |
572
+ | `checkpoint({ summary, run })` | Pause point for human or external trigger. `run` returns the outcome to record while paused. |
573
+
574
+ ### Edge shapes
575
+
576
+ ```ts
577
+ // Linear edge
578
+ { from: "node", to: "next" }
579
+
580
+ // JSONPath switch — non-decision routing
581
+ {
582
+ from: "node",
583
+ switch: {
584
+ on: "$.route",
585
+ cases: { "value-a": "branch_a", "value-b": "branch_b" },
586
+ },
587
+ }
588
+
589
+ // Decision edge — exhaustive at compile time
590
+ decisionEdge({
591
+ from: "classify",
592
+ choices, // same readonly tuple as decision()
593
+ cases: { // every choice must map to a node id
594
+ bug: "bug_lane",
595
+ feat: "feat_lane",
596
+ doc: "doc_lane",
597
+ },
598
+ })
599
+ ```
600
+
601
+ If a `decisionEdge` omits a case from `choices`, the TypeScript compiler refuses to compile — so a flow can't ship with a forgotten branch when new choices are added.
602
+
603
+ ### Why use flows
604
+
605
+ - **Cross-vendor by construction**: classify with `codex`, write code with `claude`, summarize with `gemini` — same flow file, no glue.
606
+ - **Persistence and replay**: every run streams events to disk, replayable via the flow viewer under `~/.acpx/flows/runs/`.
607
+ - **Permission preflight**: flows declaring permission requirements fail before any agent starts, instead of mid-run.
608
+ - **Typed routing**: the LLM is constrained to a literal union, the compiler verifies exhaustivity, the runtime validates the reply.
609
+
610
+ See `examples/flows/` in the repo for working samples (`branch.flow.ts`, `pr-triage/`, `two-turn.flow.ts`, `shell.flow.ts`, `workdir.flow.ts`).
611
+
612
+ ## Practical workflows
613
+
614
+ For explicit `prompt` and `exec`, an agent-level `--file` is inherited unless the subcommand supplies its own file. Agent-level `--no-wait` also applies to `prompt`. Session-list options work on `sessions` or `list`, with explicit child values taking precedence. Watch inherits the agent's session selector unless `watch --name`/`-s` overrides it; its `--cursor` stays local to watch and never inherits the list pagination cursor.
615
+
616
+ Persistent repo assistant:
617
+
618
+ ```bash
619
+ acpx codex 'inspect failing tests and propose a fix plan'
620
+ acpx codex 'apply the smallest safe fix and run tests'
621
+ ```
622
+
623
+ Parallel named streams:
624
+
625
+ ```bash
626
+ acpx codex -s backend 'fix API pagination bug'
627
+ acpx codex -s docs 'draft changelog entry for release'
628
+ ```
629
+
630
+ Specialized Claude reviewer that survives session reuse:
631
+
632
+ ```bash
633
+ acpx --system-prompt "You are a reviewer who refuses to approve untested changes." \
634
+ claude sessions new --name reviewer
635
+ acpx claude -s reviewer 'review the diff in src/auth/'
636
+ ```
637
+
638
+ Idempotent session bootstrap (safe to call before every prompt in scripts):
639
+
640
+ ```bash
641
+ acpx codex sessions ensure -s ci
642
+ acpx codex -s ci 'run the smoke suite and report failures'
643
+ ```
644
+
645
+ Queue follow-up without waiting:
646
+
647
+ ```bash
648
+ acpx codex 'run full test suite and investigate failures'
649
+ acpx codex --no-wait 'after tests, summarize root causes and next steps'
650
+ ```
651
+
652
+ One-shot script step:
653
+
654
+ ```bash
655
+ acpx --format quiet exec 'summarize repo purpose in 3 lines'
656
+ ```
657
+
658
+ Machine-readable output for orchestration:
659
+
660
+ ```bash
661
+ acpx --format json --json-strict codex 'review current branch changes' > events.ndjson
662
+ ```
663
+
664
+ Raw custom adapter command:
665
+
666
+ ```bash
667
+ acpx --agent './bin/custom-acp-server --profile ci' 'run validation checks'
668
+ ```
669
+
670
+ Periodic cleanup:
671
+
672
+ ```bash
673
+ acpx codex sessions prune --dry-run --older-than 14
674
+ acpx codex sessions prune --older-than 30 --include-history
675
+ ```
676
+
677
+ Multi-agent triage flow:
678
+
679
+ ```bash
680
+ acpx --approve-all flow run ./pr-triage.flow.ts --input-json '{"prNumber": 842}'
681
+ ```
682
+
683
+ Repo-scoped review with permissive mode:
684
+
685
+ ```bash
686
+ acpx --cwd ~/repos/shop --approve-all codex -s pr-842 \
687
+ 'review PR #842 for regressions and propose minimal patch'
688
+ ```