Skip to content

Commit e131748

Browse files
authored
fix(docs): correct raw ACP JSON automation examples (#525)
1 parent 0a6220c commit e131748

6 files changed

Lines changed: 58 additions & 9 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Repo: https://github.com/openclaw/acpx
1414

1515
### Fixes
1616

17+
- Docs/JSON: fix raw ACP tool-call pipelines and message examples so automation reads nested session updates and handles partial tool updates. Fixes #520. Thanks @prateek.
18+
1719
## 2026.8.18 (v0.13.1)
1820

1921
### Changes

‎docs/CLI.md‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -542,8 +542,8 @@ When `--suppress-reads` is enabled:
542542
ACP message examples:
543543
544544
```json
545-
{"jsonrpc":"2.0","id":"req-1","method":"session/prompt","params":{"sessionId":"019c...","prompt":"hi"}}
546-
{"jsonrpc":"2.0","method":"session/update","params":{"sessionUpdate":"agent_message_chunk","content":{"type":"text","text":"Hello"}}}
545+
{"jsonrpc":"2.0","id":"req-1","method":"session/prompt","params":{"sessionId":"019c...","prompt":[{"type":"text","text":"hi"}]}}
546+
{"jsonrpc":"2.0","method":"session/update","params":{"sessionId":"019c...","update":{"sessionUpdate":"agent_message_chunk","content":{"type":"text","text":"Hello"}}}}
547547
{"jsonrpc":"2.0","id":"req-1","result":{"stopReason":"end_turn"}}
548548
```
549549
@@ -668,5 +668,7 @@ acpx config init
668668
669669
# JSON automation pipeline
670670
acpx --format json codex exec 'review latest diff for security issues' \
671-
| jq -r 'select(.type=="tool_call") | [.status, .title] | @tsv'
671+
| jq -r 'select(.method=="session/update") | .params.update
672+
| select(.sessionUpdate=="tool_call" or .sessionUpdate=="tool_call_update")
673+
| [(.status // "-"), (.title // "-")] | @tsv'
672674
```

‎docs/index.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ acpx codex 'find the flaky test and fix it'
1515

1616
# Switch agents, same surface.
1717
acpx claude 'refactor the auth middleware'
18-
acpx gemini 'review this branch'
1918

2019
# One-shot, no saved context.
2120
acpx codex exec 'summarize this repo in 5 bullets'
2221

2322
# Pipe structured ACP events into your own automation.
2423
acpx --format json codex exec 'review changed files' \
25-
| jq -r 'select(.type=="tool_call") | [.status,.title] | @tsv'
24+
| jq -r 'select(.method=="session/update") | .params.update
25+
| select(.sessionUpdate=="tool_call" or .sessionUpdate=="tool_call_update")
26+
| [(.status // "-"), (.title // "-")] | @tsv'
2627

2728
# Run a TypeScript multi-step flow against a real agent.
2829
acpx flow run examples/flows/branch.flow.ts \
@@ -33,7 +34,7 @@ acpx flow run examples/flows/branch.flow.ts \
3334

3435
## What acpx does
3536

36-
- **One CLI, every coding agent.** Built-in adapters for Codex, Claude, Pi, OpenClaw, Gemini, Cursor, Copilot, Droid, Qwen, Qoder, Trae, and more — plus `--agent` for any custom ACP server.
37+
- **One CLI, every coding agent.** Built-in adapters for Pi, OpenClaw, Codex, Claude, and more — plus `--agent` for any custom ACP server.
3738
- **Persistent sessions.** Multi-turn conversations survive across invocations, scoped per repo. `-s <name>` runs parallel workstreams (`backend`, `docs`, `pr-842`).
3839
- **Queue-aware prompts.** Submit while a turn is running; new prompts queue and drain in order. `--no-wait` enqueues and returns. `cancel` aborts cooperatively without tearing the session down.
3940
- **Crash-resistant.** Dead agent processes are detected and reloaded automatically. `Ctrl+C` sends ACP `session/cancel` before any force-kill.

‎docs/output-formats.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ acpx --format json codex exec 'review changed files' \
4040
```
4141

4242
```json
43-
{"jsonrpc":"2.0","id":"req-1","method":"session/prompt","params":{"sessionId":"019c…","prompt":"hi"}}
44-
{"jsonrpc":"2.0","method":"session/update","params":{"sessionUpdate":"agent_message_chunk","content":{"type":"text","text":"Hello"}}}
43+
{"jsonrpc":"2.0","id":"req-1","method":"session/prompt","params":{"sessionId":"019c…","prompt":[{"type":"text","text":"hi"}]}}
44+
{"jsonrpc":"2.0","method":"session/update","params":{"sessionId":"019c…","update":{"sessionUpdate":"agent_message_chunk","content":{"type":"text","text":"Hello"}}}}
4545
{"jsonrpc":"2.0","id":"req-1","result":{"stopReason":"end_turn"}}
4646
```
4747

‎skills/acpx/SKILL.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,9 @@ Example automation:
422422
423423
```bash
424424
acpx --format json codex exec 'review changed files' \
425-
| jq -r 'select(.type=="tool_call") | [.status, .title] | @tsv'
425+
| jq -r 'select(.method=="session/update") | .params.update
426+
| select(.sessionUpdate=="tool_call" or .sessionUpdate=="tool_call_update")
427+
| [(.status // "-"), (.title // "-")] | @tsv'
426428
```
427429
428430
## Permission modes

‎test/docs-output.test.ts‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import assert from "node:assert/strict";
2+
import { spawnSync } from "node:child_process";
3+
import { readFileSync } from "node:fs";
4+
import test from "node:test";
5+
6+
const docs = ["skills/acpx/SKILL.md", "docs/CLI.md", "docs/index.md"];
7+
8+
test("documented jq pipelines select raw ACP tool calls and sparse updates", (t) => {
9+
const jq = spawnSync("jq", ["--version"], { encoding: "utf8" });
10+
if (jq.error && "code" in jq.error && jq.error.code === "ENOENT") {
11+
t.skip("jq is required to execute the documented automation examples");
12+
return;
13+
}
14+
assert.equal(jq.status, 0, jq.stderr);
15+
16+
const updates = [
17+
{ sessionUpdate: "agent_message_chunk", content: { type: "text", text: "Hello" } },
18+
{ sessionUpdate: "tool_call", toolCallId: "read-1", status: "in_progress", title: "Read" },
19+
{ sessionUpdate: "tool_call_update", toolCallId: "read-1", status: "completed" },
20+
{ sessionUpdate: "tool_call_update", toolCallId: "read-1", title: "Read README" },
21+
{ sessionUpdate: "tool_call_update", toolCallId: "read-1", content: [] },
22+
];
23+
const frames = [
24+
{ jsonrpc: "2.0", id: 1, method: "initialize", params: { protocolVersion: 1 } },
25+
...updates.map((update) => ({
26+
jsonrpc: "2.0",
27+
method: "session/update",
28+
params: { sessionId: "session-1", update },
29+
})),
30+
{ jsonrpc: "2.0", id: 2, result: { stopReason: "end_turn" } },
31+
];
32+
const input = frames.map((frame) => JSON.stringify(frame)).join("\n");
33+
34+
for (const doc of docs) {
35+
const source = readFileSync(doc, "utf8");
36+
const filters = [...source.matchAll(/\| jq -r '([^']+)'/g)];
37+
assert.equal(filters.length, 1, `${doc}: expected one automation pipeline`);
38+
const result = spawnSync("jq", ["-r", filters[0][1]], { input, encoding: "utf8" });
39+
assert.equal(result.status, 0, `${doc}: ${result.stderr}`);
40+
assert.equal(result.stdout, "in_progress\tRead\ncompleted\t-\n-\tRead README\n-\t-\n", doc);
41+
}
42+
});

0 commit comments

Comments
 (0)