@qlairoslabs/acp-client 0.3.1 → 0.3.2
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.
- package/README.md +13 -2
- package/package.json +1 -1
- package/src/activity.ts +9 -0
- package/src/adapters.ts +10 -1
- package/src/agent-session.ts +9 -0
- package/src/client.ts +14 -5
- package/src/index.ts +1 -0
- package/src/types.ts +17 -1
package/README.md
CHANGED
|
@@ -97,12 +97,23 @@ await agent.prompt("Find and fix the failing test.", {
|
|
|
97
97
|
onChunk: (text) => process.stdout.write(text), // response text as it streams
|
|
98
98
|
onActivity: (event) => render(event), // thinking / tool calls / plan / …
|
|
99
99
|
onUpdate: (raw) => log(raw), // every raw session/update, unmapped
|
|
100
|
-
onPermissionRequest: (req) =>
|
|
100
|
+
onPermissionRequest: (req) => { // blocking — the agent waits
|
|
101
|
+
const allow = req.options.find((o) => o.kind === "allow_once");
|
|
102
|
+
return allow ? { outcome: "selected", optionId: allow.optionId } : { outcome: "cancelled" };
|
|
103
|
+
},
|
|
101
104
|
});
|
|
102
105
|
```
|
|
103
106
|
|
|
107
|
+
Always pick a permission option by **`kind`**, never by position or name. Option ids are
|
|
108
|
+
the agent's own strings, the order is the agent's choice — Claude lists its reject option
|
|
109
|
+
first — and `name` is prose meant for a human. The four kinds are `allow_once`,
|
|
110
|
+
`allow_always`, `reject_once`, `reject_always`; treat the `_always` pair as policy, since
|
|
111
|
+
they persist into the agent's settings and outlive the session.
|
|
112
|
+
|
|
104
113
|
If you omit `onPermissionRequest`, the client falls back to the controller's
|
|
105
|
-
`defaultPermission` (`"approve"` / `"cancel"`).
|
|
114
|
+
`defaultPermission` (`"approve"` / `"cancel"`). `"approve"` selects `allow_once`, or
|
|
115
|
+
`allow_always` if that is the only grant offered, and cancels if it finds neither — it
|
|
116
|
+
never guesses.
|
|
106
117
|
|
|
107
118
|
Every session update except the response text reaches `onActivity`, discriminated by
|
|
108
119
|
`kind`: `thinking`, `user_message`, `tool`, `tool_update`, `plan`, `plan_update`,
|
package/package.json
CHANGED
package/src/activity.ts
CHANGED
|
@@ -347,6 +347,15 @@ export class ActivityAggregator {
|
|
|
347
347
|
event: Extract<ActivityEvent, { kind: "tool" }>,
|
|
348
348
|
emitted: AggregatedRecord[],
|
|
349
349
|
): ApplyResult {
|
|
350
|
+
// A RE-announcement is an update in disguise. Claude announces every call twice — once
|
|
351
|
+
// with `rawInput: {}`, then again with the real arguments, both as `tool_call` rather
|
|
352
|
+
// than `tool_call_update`. Taking the second as a fresh announce would replace the
|
|
353
|
+
// stored call (losing whatever the re-announce omits) and spend a second `announced`
|
|
354
|
+
// line where every other agent spends `input`.
|
|
355
|
+
if (this.calls.has(event.toolCallId)) {
|
|
356
|
+
return this.foldToolUpdate({ ...event, kind: "tool_update" }, emitted);
|
|
357
|
+
}
|
|
358
|
+
|
|
350
359
|
const call: ToolActivity = { ...event };
|
|
351
360
|
this.calls.set(call.toolCallId, call);
|
|
352
361
|
if (hasInput(call.rawInput)) this.inputSeen.add(call.toolCallId);
|
package/src/adapters.ts
CHANGED
|
@@ -19,11 +19,20 @@ export interface Adapter {
|
|
|
19
19
|
* Convenient presets. NOT exhaustive and NOT authoritative — a caller can always pass
|
|
20
20
|
* a raw `{ command: [...] }`. These only encode how to start the binary; they say
|
|
21
21
|
* nothing about what the agent supports.
|
|
22
|
+
*
|
|
23
|
+
* A wrong command here surfaces as a connect timeout, which reads like a library fault, so
|
|
24
|
+
* the marked entries are the ones actually spawned and verified. `claude` was
|
|
25
|
+
* `claude-agent-acp` until it wasn't: the ACP bridge for Claude Code ships as
|
|
26
|
+
* `@zed-industries/claude-code-acp`, and the `claude` CLI itself speaks no ACP. Check
|
|
27
|
+
* `which <command>` before assuming the library is at fault.
|
|
22
28
|
*/
|
|
23
29
|
export const ADAPTERS = {
|
|
24
|
-
kimi: { command: ["kimi", "acp"], ptyCommand: ["kimi"], displayName: "Kimi" },
|
|
30
|
+
kimi: { command: ["kimi", "acp"], ptyCommand: ["kimi"], displayName: "Kimi" }, // verified
|
|
31
|
+
// verified — @zed-industries/claude-code-acp. NOT `claude-agent-acp`, and not the `claude` CLI.
|
|
25
32
|
claude: { command: ["claude-code-acp"], ptyCommand: ["claude"], displayName: "Claude" },
|
|
33
|
+
// verified — @agentclientprotocol/codex-acp. The `codex` CLI has no `acp` subcommand.
|
|
26
34
|
codex: { command: ["codex-acp"], ptyCommand: ["codex"], displayName: "Codex" },
|
|
35
|
+
// Below: from each project's docs, not spawned here. Correct at time of writing, unverified.
|
|
27
36
|
gemini: { command: ["gemini", "--acp", "--stdio"], ptyCommand: ["gemini"], displayName: "Gemini" },
|
|
28
37
|
copilot: { command: ["copilot", "--acp", "--stdio"], ptyCommand: ["copilot"], displayName: "Copilot" },
|
|
29
38
|
opencode: { command: ["opencode", "acp"], ptyCommand: ["opencode"], displayName: "OpenCode" },
|
package/src/agent-session.ts
CHANGED
|
@@ -453,6 +453,15 @@ export class AgentSession implements AgentClient, Bridgeable {
|
|
|
453
453
|
get configOptions(): ConfigOptions {
|
|
454
454
|
return this.controller.configOptions;
|
|
455
455
|
}
|
|
456
|
+
/**
|
|
457
|
+
* Set one of the agent's own session options — the `configOptions` it advertised on
|
|
458
|
+
* connect. This is where per-agent knobs live that are NOT launch flags and NOT
|
|
459
|
+
* environment: Codex exposes `reasoning_effort` (low…ultra), `model`, and `mode` this
|
|
460
|
+
* way, so it is the only route to them once the process is running.
|
|
461
|
+
*/
|
|
462
|
+
setConfig(configId: string, value: unknown): Promise<void> {
|
|
463
|
+
return this.controller.setConfig(configId, value);
|
|
464
|
+
}
|
|
456
465
|
get agentCommands(): AgentCommand[] {
|
|
457
466
|
return this.controller.agentCommands;
|
|
458
467
|
}
|
package/src/client.ts
CHANGED
|
@@ -673,11 +673,20 @@ export class AcpClient implements AgentClient {
|
|
|
673
673
|
}
|
|
674
674
|
|
|
675
675
|
private defaultOutcome(request: PermissionRequest): PermissionOutcome {
|
|
676
|
-
if ((this.config.defaultPermission ?? "cancel")
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
676
|
+
if ((this.config.defaultPermission ?? "cancel") !== "approve") return { outcome: "cancelled" };
|
|
677
|
+
|
|
678
|
+
// By KIND, never by position. Agents order their options differently and Claude leads
|
|
679
|
+
// with reject, so taking `options[0]` auto-REFUSED every call it meant to approve.
|
|
680
|
+
//
|
|
681
|
+
// `allow_once` first is deliberate: `allow_always` writes a rule into the agent's own
|
|
682
|
+
// settings that outlives this session, and an auto-approver must not quietly make
|
|
683
|
+
// policy on the user's behalf. It is the fallback, never the preference.
|
|
684
|
+
const allow =
|
|
685
|
+
request.options.find((o) => o.kind === "allow_once") ??
|
|
686
|
+
request.options.find((o) => o.kind === "allow_always");
|
|
687
|
+
|
|
688
|
+
// Nothing recognizable to approve: refuse rather than guess. Guessing is the bug above.
|
|
689
|
+
return allow ? { outcome: "selected", optionId: allow.optionId } : { outcome: "cancelled" };
|
|
681
690
|
}
|
|
682
691
|
}
|
|
683
692
|
|
package/src/index.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -168,11 +168,27 @@ export type PermissionOutcome =
|
|
|
168
168
|
| { outcome: "selected"; optionId: string }
|
|
169
169
|
| { outcome: "cancelled" };
|
|
170
170
|
|
|
171
|
+
/**
|
|
172
|
+
* What an option DOES, independent of what it is called or where it sits in the list.
|
|
173
|
+
* The only safe thing to branch on: `name` is prose and the order is the agent's whim
|
|
174
|
+
* (Claude puts its reject option first). `allow_always` and `reject_always` persist into
|
|
175
|
+
* the agent's own settings and outlive the session — treat them as policy, not answers.
|
|
176
|
+
*
|
|
177
|
+
* The open arm keeps a kind we don't know yet from failing to typecheck; branch with a
|
|
178
|
+
* fallback rather than assuming the four.
|
|
179
|
+
*/
|
|
180
|
+
export type PermissionOptionKind =
|
|
181
|
+
| "allow_once"
|
|
182
|
+
| "allow_always"
|
|
183
|
+
| "reject_once"
|
|
184
|
+
| "reject_always"
|
|
185
|
+
| (string & {});
|
|
186
|
+
|
|
171
187
|
/** A permission request surfaced to the caller. The agent BLOCKS until this resolves. */
|
|
172
188
|
export interface PermissionRequest {
|
|
173
189
|
toolCallId: string;
|
|
174
190
|
title?: string;
|
|
175
|
-
options: Array<{ optionId: string; name: string; kind:
|
|
191
|
+
options: Array<{ optionId: string; name: string; kind: PermissionOptionKind }>;
|
|
176
192
|
/** The raw SDK request, for callers that need fields we haven't surfaced. */
|
|
177
193
|
raw: unknown;
|
|
178
194
|
}
|