@qlairoslabs/acp-client 0.3.2 → 0.3.4
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 +8 -3
- package/package.json +1 -1
- package/src/adapters.ts +26 -6
- package/src/terminals.ts +34 -1
package/README.md
CHANGED
|
@@ -263,9 +263,14 @@ agents route their shell commands through `terminal/create` and read/write files
|
|
|
263
263
|
event, so `content` entries of type `terminal` come with `output`, `truncated` and
|
|
264
264
|
`exitStatus` filled in.
|
|
265
265
|
|
|
266
|
-
Commands run as child processes of your app, with your environment.
|
|
267
|
-
|
|
268
|
-
|
|
266
|
+
Commands run as child processes of your app, with your environment. When the agent sends
|
|
267
|
+
`args`, they are spawned exactly as given; when it sends none, `command` is treated as a
|
|
268
|
+
shell line and run through `bash` (or `/bin/sh`), because that is how agents use it —
|
|
269
|
+
`claude-code-acp` puts its whole Bash command line, redirections and all, in `command`.
|
|
270
|
+
Set `ACP_TERMINAL_SHELL` to choose a different shell.
|
|
271
|
+
|
|
272
|
+
To opt out — letting the agent fall back to its own implementation — turn the capability
|
|
273
|
+
off, which also stops us advertising it:
|
|
269
274
|
|
|
270
275
|
```ts
|
|
271
276
|
new AcpClient({
|
package/package.json
CHANGED
package/src/adapters.ts
CHANGED
|
@@ -21,15 +21,35 @@ export interface Adapter {
|
|
|
21
21
|
* nothing about what the agent supports.
|
|
22
22
|
*
|
|
23
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. `
|
|
25
|
-
*
|
|
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.
|
|
24
|
+
* the marked entries are the ones actually spawned and verified. Check `which <command>`
|
|
25
|
+
* before assuming the library is at fault.
|
|
28
26
|
*/
|
|
29
27
|
export const ADAPTERS = {
|
|
30
28
|
kimi: { command: ["kimi", "acp"], ptyCommand: ["kimi"], displayName: "Kimi" }, // verified
|
|
31
|
-
// verified — @
|
|
32
|
-
|
|
29
|
+
// verified — @agentclientprotocol/claude-agent-acp. Not the `claude` CLI, which speaks no
|
|
30
|
+
// ACP. If the binary isn't on PATH: `npm i -g @agentclientprotocol/claude-agent-acp`, or
|
|
31
|
+
// pass `{ command: ["bunx", "@agentclientprotocol/claude-agent-acp"] }` and skip installing.
|
|
32
|
+
claude: { command: ["claude-agent-acp"], ptyCommand: ["claude"], displayName: "Claude" },
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated The same bridge under its old name. npm marks it renamed to
|
|
35
|
+
* `@agentclientprotocol/claude-agent-acp`, and it has been left far behind (0.16.x against
|
|
36
|
+
* 0.64.x), so it is frozen rather than merely older. Use `claude` above.
|
|
37
|
+
*
|
|
38
|
+
* Kept, and NOT quietly redirected, because a preset names a program to spawn: silently
|
|
39
|
+
* launching a different binary than the key says would be the harder failure to diagnose
|
|
40
|
+
* of the two. It is here so an existing install keeps working while it is migrated.
|
|
41
|
+
*
|
|
42
|
+
* The versions behave differently in ways that reach the caller. Most sharply, the ORDER
|
|
43
|
+
* of the permission options they offer is reversed — `allow_always` first here,
|
|
44
|
+
* `reject_once` first in the current package — so a client that picked an option by
|
|
45
|
+
* POSITION granted standing permission against one and refused everything against the
|
|
46
|
+
* other. Both are covered by smoke-tests/test4-permission.
|
|
47
|
+
*/
|
|
48
|
+
claudeCode: {
|
|
49
|
+
command: ["claude-code-acp"],
|
|
50
|
+
ptyCommand: ["claude"],
|
|
51
|
+
displayName: "Claude (deprecated bridge)",
|
|
52
|
+
},
|
|
33
53
|
// verified — @agentclientprotocol/codex-acp. The `codex` CLI has no `acp` subcommand.
|
|
34
54
|
codex: { command: ["codex-acp"], ptyCommand: ["codex"], displayName: "Codex" },
|
|
35
55
|
// Below: from each project's docs, not spawned here. Correct at time of writing, unverified.
|
package/src/terminals.ts
CHANGED
|
@@ -68,6 +68,39 @@ interface Entry {
|
|
|
68
68
|
*/
|
|
69
69
|
const DRAIN_GRACE_MS = 250;
|
|
70
70
|
|
|
71
|
+
/**
|
|
72
|
+
* The shell used when the agent hands us a command LINE.
|
|
73
|
+
*
|
|
74
|
+
* NOT `$SHELL`: that is the user's INTERACTIVE shell, which may be fish or nushell, and
|
|
75
|
+
* agents generate bash/POSIX syntax — `printf x >&2` is a syntax error in fish. Prefer
|
|
76
|
+
* bash, because agents write bashisms (`[[ ]]`, arrays) and `/bin/sh` is dash on Debian
|
|
77
|
+
* and Ubuntu, where those fail. Fall back to `/bin/sh`, which always exists.
|
|
78
|
+
*/
|
|
79
|
+
const SHELL = process.env.ACP_TERMINAL_SHELL || Bun.which("bash") || "/bin/sh";
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Turn a `terminal/create` request into an argv.
|
|
83
|
+
*
|
|
84
|
+
* The spec is ambiguous — "The command to execute" plus an optional "Array of command
|
|
85
|
+
* arguments" — and agents read it both ways. `claude-code-acp` puts its ENTIRE Bash command
|
|
86
|
+
* line in `command` and sends no `args` at all, so spawning `command` as an executable path
|
|
87
|
+
* failed every shell tool call it made: `Executable not found in $PATH: "printf 'ran' >
|
|
88
|
+
* shell.txt"`. Redirections, pipes and `&&` were unreachable, and so was a plain command
|
|
89
|
+
* that merely carried its own arguments.
|
|
90
|
+
*
|
|
91
|
+
* So: with `args`, the agent has already done the splitting and its arguments are final —
|
|
92
|
+
* spawn directly, because re-splitting would turn one argument containing a space into two.
|
|
93
|
+
* Without them, `command` is a line for a shell. The two readings never overlap, and for a
|
|
94
|
+
* bare program name they agree (`sh -c "ls"` and spawning `ls` do the same thing).
|
|
95
|
+
*
|
|
96
|
+
* The cost: a command line is subject to word splitting, so an agent sending an unquoted
|
|
97
|
+
* executable path containing spaces and no `args` would break. That shape is much rarer
|
|
98
|
+
* than the one this fixes, and quoting it here would corrupt every genuine command line.
|
|
99
|
+
*/
|
|
100
|
+
function toArgv(params: CreateTerminalParams): string[] {
|
|
101
|
+
return params.args?.length ? [params.command, ...params.args] : [SHELL, "-c", params.command];
|
|
102
|
+
}
|
|
103
|
+
|
|
71
104
|
export class TerminalRegistry {
|
|
72
105
|
private readonly terminals = new Map<string, Entry>();
|
|
73
106
|
private seq = 0;
|
|
@@ -86,7 +119,7 @@ export class TerminalRegistry {
|
|
|
86
119
|
};
|
|
87
120
|
for (const v of params.env ?? []) env[v.name] = v.value;
|
|
88
121
|
|
|
89
|
-
const proc = Bun.spawn(
|
|
122
|
+
const proc = Bun.spawn(toArgv(params), {
|
|
90
123
|
cwd: params.cwd ?? this.options.cwd,
|
|
91
124
|
env,
|
|
92
125
|
stdin: "ignore",
|