@agentclientprotocol/claude-agent-acp 0.25.3 → 0.27.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.
- package/dist/acp-agent.d.ts +19 -1
- package/dist/acp-agent.d.ts.map +1 -1
- package/dist/acp-agent.js +102 -47
- package/dist/index.js +14 -2
- package/dist/lib.d.ts +1 -1
- package/dist/lib.d.ts.map +1 -1
- package/dist/tools.d.ts +1 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +25 -25
- package/package.json +10 -10
package/dist/acp-agent.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ type Session = {
|
|
|
38
38
|
}>;
|
|
39
39
|
nextPendingOrder: number;
|
|
40
40
|
abortController: AbortController;
|
|
41
|
+
emitRawSDKMessages: boolean | SDKMessageFilter[];
|
|
41
42
|
};
|
|
42
43
|
type BackgroundTerminal = {
|
|
43
44
|
handle: TerminalHandle;
|
|
@@ -47,6 +48,10 @@ type BackgroundTerminal = {
|
|
|
47
48
|
status: "aborted" | "exited" | "killed" | "timedOut";
|
|
48
49
|
pendingOutput: TerminalOutputResponse;
|
|
49
50
|
};
|
|
51
|
+
export type SDKMessageFilter = {
|
|
52
|
+
type: string;
|
|
53
|
+
subtype?: string;
|
|
54
|
+
};
|
|
50
55
|
/**
|
|
51
56
|
* Extra metadata that can be given when creating a new session.
|
|
52
57
|
*/
|
|
@@ -68,6 +73,14 @@ export type NewSessionMeta = {
|
|
|
68
73
|
* - tools (passed through; defaults to claude_code preset if not provided)
|
|
69
74
|
*/
|
|
70
75
|
options?: Options;
|
|
76
|
+
/**
|
|
77
|
+
* When set, raw SDK messages are emitted as extNotification("_claude/sdkMessage", message)
|
|
78
|
+
* in addition to normal processing.
|
|
79
|
+
* - true: emit all messages
|
|
80
|
+
* - false/undefined: emit nothing (default)
|
|
81
|
+
* - SDKMessageFilter[]: emit only messages matching at least one filter
|
|
82
|
+
*/
|
|
83
|
+
emitRawSDKMessages?: boolean | SDKMessageFilter[];
|
|
71
84
|
};
|
|
72
85
|
additionalRoots?: string[];
|
|
73
86
|
};
|
|
@@ -142,6 +155,8 @@ export declare class ClaudeAcpAgent implements Agent {
|
|
|
142
155
|
/** Cleanly tear down a session: cancel in-flight work, dispose resources,
|
|
143
156
|
* and remove it from the session map. */
|
|
144
157
|
private teardownSession;
|
|
158
|
+
/** Tear down all active sessions. Called when the ACP connection closes. */
|
|
159
|
+
dispose(): Promise<void>;
|
|
145
160
|
unstable_closeSession(params: CloseSessionRequest): Promise<CloseSessionResponse>;
|
|
146
161
|
unstable_setSessionModel(params: SetSessionModelRequest): Promise<SetSessionModelResponse | void>;
|
|
147
162
|
setSessionMode(params: SetSessionModeRequest): Promise<SetSessionModeResponse>;
|
|
@@ -172,6 +187,9 @@ export declare function streamEventToAcpNotifications(message: SDKPartialAssista
|
|
|
172
187
|
clientCapabilities?: ClientCapabilities;
|
|
173
188
|
cwd?: string;
|
|
174
189
|
}): SessionNotification[];
|
|
175
|
-
export declare function runAcp():
|
|
190
|
+
export declare function runAcp(): {
|
|
191
|
+
connection: AgentSideConnection;
|
|
192
|
+
agent: ClaudeAcpAgent;
|
|
193
|
+
};
|
|
176
194
|
export {};
|
|
177
195
|
//# sourceMappingURL=acp-agent.d.ts.map
|
package/dist/acp-agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acp-agent.d.ts","sourceRoot":"","sources":["../src/acp-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,mBAAmB,EACnB,mBAAmB,EAGnB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EAEnB,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EAEpB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,6BAA6B,EAC7B,8BAA8B,EAC9B,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EAEtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,UAAU,EAMV,OAAO,EACP,cAAc,EACd,KAAK,EAEL,0BAA0B,EAE1B,cAAc,EAEf,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"acp-agent.d.ts","sourceRoot":"","sources":["../src/acp-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,mBAAmB,EACnB,mBAAmB,EAGnB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EAEnB,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EAEpB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,6BAA6B,EAC7B,8BAA8B,EAC9B,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EAEtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,UAAU,EAMV,OAAO,EACP,cAAc,EACd,KAAK,EAEL,0BAA0B,EAE1B,cAAc,EAEf,MAAM,g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EAAE,EACvF,IAAI,EAAE,WAAW,GAAG,MAAM,EAC1B,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE;IACR,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,GACA,mBAAmB,EAAE,CAoPvB;AAED,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,0BAA0B,EACnC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE;IACR,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,GACA,mBAAmB,EAAE,CA0CvB;AAED,wBAAgB,MAAM;;;EAWrB"}
|
package/dist/acp-agent.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { AgentSideConnection, ndJsonStream, RequestError, } from "@agentclientprotocol/sdk";
|
|
2
2
|
import { getSessionMessages, listSessions, query, } from "@anthropic-ai/claude-agent-sdk";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
|
-
import * as fs from "node:fs";
|
|
5
4
|
import * as os from "node:os";
|
|
6
5
|
import * as path from "node:path";
|
|
7
6
|
import packageJson from "../package.json" with { type: "json" };
|
|
@@ -101,37 +100,75 @@ export class ClaudeAcpAgent {
|
|
|
101
100
|
};
|
|
102
101
|
const supportsTerminalAuth = request.clientCapabilities?.auth?.terminal === true;
|
|
103
102
|
const supportsMetaTerminalAuth = request.clientCapabilities?._meta?.["terminal-auth"] === true;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
claudeLoginMethod._meta = {
|
|
122
|
-
"terminal-auth": {
|
|
123
|
-
command: process.execPath,
|
|
124
|
-
args: [...baseArgs, "--cli", "auth", "login", "--claudeai"],
|
|
125
|
-
label: "Claude Login",
|
|
126
|
-
},
|
|
103
|
+
// Detect remote environments where the OAuth browser redirect to localhost
|
|
104
|
+
// won't work. This matches the SDK's internal isRemote check. In these cases,
|
|
105
|
+
// the `auth login` subcommand would fall back to a device-code-like manual
|
|
106
|
+
// flow, which doesn't work well over ACP, so we offer the TUI login instead.
|
|
107
|
+
const isRemote = !!(process.env.NO_BROWSER ||
|
|
108
|
+
process.env.SSH_CONNECTION ||
|
|
109
|
+
process.env.SSH_CLIENT ||
|
|
110
|
+
process.env.SSH_TTY ||
|
|
111
|
+
process.env.CLAUDE_CODE_REMOTE);
|
|
112
|
+
const terminalAuthMethods = [];
|
|
113
|
+
if (isRemote) {
|
|
114
|
+
const remoteLoginMethod = {
|
|
115
|
+
description: "Run `claude /login` in the terminal",
|
|
116
|
+
name: "Log in with Claude",
|
|
117
|
+
id: "claude-login",
|
|
118
|
+
type: "terminal",
|
|
119
|
+
args: ["--cli"],
|
|
127
120
|
};
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
121
|
+
if (supportsMetaTerminalAuth) {
|
|
122
|
+
remoteLoginMethod._meta = {
|
|
123
|
+
"terminal-auth": {
|
|
124
|
+
command: process.execPath,
|
|
125
|
+
args: [...process.argv.slice(1), "--cli"],
|
|
126
|
+
label: "Claude Login",
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
if (!shouldHideClaudeAuth() && (supportsTerminalAuth || supportsMetaTerminalAuth)) {
|
|
131
|
+
terminalAuthMethods.push(remoteLoginMethod);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
const claudeLoginMethod = {
|
|
136
|
+
description: "Use Claude subscription ",
|
|
137
|
+
name: "Claude Subscription",
|
|
138
|
+
id: "claude-ai-login",
|
|
139
|
+
type: "terminal",
|
|
140
|
+
args: ["--cli", "auth", "login", "--claudeai"],
|
|
134
141
|
};
|
|
142
|
+
const consoleLoginMethod = {
|
|
143
|
+
description: "Use Anthropic Console (API usage billing)",
|
|
144
|
+
name: "Anthropic Console",
|
|
145
|
+
id: "console-login",
|
|
146
|
+
type: "terminal",
|
|
147
|
+
args: ["--cli", "auth", "login", "--console"],
|
|
148
|
+
};
|
|
149
|
+
if (supportsMetaTerminalAuth) {
|
|
150
|
+
const baseArgs = process.argv.slice(1);
|
|
151
|
+
claudeLoginMethod._meta = {
|
|
152
|
+
"terminal-auth": {
|
|
153
|
+
command: process.execPath,
|
|
154
|
+
args: [...baseArgs, "--cli", "auth", "login", "--claudeai"],
|
|
155
|
+
label: "Claude Login",
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
consoleLoginMethod._meta = {
|
|
159
|
+
"terminal-auth": {
|
|
160
|
+
command: process.execPath,
|
|
161
|
+
args: [...baseArgs, "--cli", "auth", "login", "--console"],
|
|
162
|
+
label: "Anthropic Console Login",
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
if (!shouldHideClaudeAuth() && (supportsTerminalAuth || supportsMetaTerminalAuth)) {
|
|
167
|
+
terminalAuthMethods.push(claudeLoginMethod);
|
|
168
|
+
}
|
|
169
|
+
if (supportsTerminalAuth || supportsMetaTerminalAuth) {
|
|
170
|
+
terminalAuthMethods.push(consoleLoginMethod);
|
|
171
|
+
}
|
|
135
172
|
}
|
|
136
173
|
return {
|
|
137
174
|
protocolVersion: 1,
|
|
@@ -162,21 +199,10 @@ export class ClaudeAcpAgent {
|
|
|
162
199
|
title: "Claude Agent",
|
|
163
200
|
version: packageJson.version,
|
|
164
201
|
},
|
|
165
|
-
authMethods: [
|
|
166
|
-
...(!shouldHideClaudeAuth() && (supportsTerminalAuth || supportsMetaTerminalAuth)
|
|
167
|
-
? [claudeLoginMethod]
|
|
168
|
-
: []),
|
|
169
|
-
...(supportsTerminalAuth || supportsMetaTerminalAuth ? [consoleLoginMethod] : []),
|
|
170
|
-
...(supportsGatewayAuth ? [gatewayAuthMethod] : []),
|
|
171
|
-
],
|
|
202
|
+
authMethods: [...terminalAuthMethods, ...(supportsGatewayAuth ? [gatewayAuthMethod] : [])],
|
|
172
203
|
};
|
|
173
204
|
}
|
|
174
205
|
async newSession(params) {
|
|
175
|
-
if (!this.gatewayAuthMeta &&
|
|
176
|
-
fs.existsSync(path.resolve(os.homedir(), ".claude.json.backup")) &&
|
|
177
|
-
!fs.existsSync(path.resolve(os.homedir(), ".claude.json"))) {
|
|
178
|
-
throw RequestError.authRequired();
|
|
179
|
-
}
|
|
180
206
|
const response = await this.createSession(params, {
|
|
181
207
|
// Revisit these meta values once we support resume
|
|
182
208
|
resume: params._meta?.claudeCode?.options?.resume,
|
|
@@ -291,6 +317,13 @@ export class ClaudeAcpAgent {
|
|
|
291
317
|
}
|
|
292
318
|
break;
|
|
293
319
|
}
|
|
320
|
+
if (session.emitRawSDKMessages &&
|
|
321
|
+
shouldEmitRawMessage(session.emitRawSDKMessages, message)) {
|
|
322
|
+
await this.client.extNotification("_claude/sdkMessage", {
|
|
323
|
+
sessionId: params.sessionId,
|
|
324
|
+
message: message,
|
|
325
|
+
});
|
|
326
|
+
}
|
|
294
327
|
switch (message.type) {
|
|
295
328
|
case "system":
|
|
296
329
|
switch (message.subtype) {
|
|
@@ -361,6 +394,7 @@ export class ClaudeAcpAgent {
|
|
|
361
394
|
case "task_started":
|
|
362
395
|
case "task_notification":
|
|
363
396
|
case "task_progress":
|
|
397
|
+
case "task_updated":
|
|
364
398
|
case "elicitation_complete":
|
|
365
399
|
case "api_retry":
|
|
366
400
|
// Todo: process via status api: https://docs.claude.com/en/docs/claude-code/hooks#hook-output
|
|
@@ -592,7 +626,7 @@ export class ClaudeAcpAgent {
|
|
|
592
626
|
async cancel(params) {
|
|
593
627
|
const session = this.sessions[params.sessionId];
|
|
594
628
|
if (!session) {
|
|
595
|
-
|
|
629
|
+
return;
|
|
596
630
|
}
|
|
597
631
|
session.cancelled = true;
|
|
598
632
|
for (const [, pending] of session.pendingMessages) {
|
|
@@ -611,8 +645,13 @@ export class ClaudeAcpAgent {
|
|
|
611
645
|
await this.cancel({ sessionId });
|
|
612
646
|
session.settingsManager.dispose();
|
|
613
647
|
session.abortController.abort();
|
|
648
|
+
session.query.close();
|
|
614
649
|
delete this.sessions[sessionId];
|
|
615
650
|
}
|
|
651
|
+
/** Tear down all active sessions. Called when the ACP connection closes. */
|
|
652
|
+
async dispose() {
|
|
653
|
+
await Promise.all(Object.keys(this.sessions).map((id) => this.teardownSession(id)));
|
|
654
|
+
}
|
|
616
655
|
async unstable_closeSession(params) {
|
|
617
656
|
if (!this.sessions[params.sessionId]) {
|
|
618
657
|
throw new Error("Session not found");
|
|
@@ -755,6 +794,7 @@ export class ClaudeAcpAgent {
|
|
|
755
794
|
}
|
|
756
795
|
if (toolName === "ExitPlanMode") {
|
|
757
796
|
const options = [
|
|
797
|
+
{ kind: "allow_always", name: 'Yes, and use "auto" mode', optionId: "auto" },
|
|
758
798
|
{
|
|
759
799
|
kind: "allow_always",
|
|
760
800
|
name: "Yes, and auto-accept edits",
|
|
@@ -785,6 +825,7 @@ export class ClaudeAcpAgent {
|
|
|
785
825
|
if (response.outcome?.outcome === "selected" &&
|
|
786
826
|
(response.outcome.optionId === "default" ||
|
|
787
827
|
response.outcome.optionId === "acceptEdits" ||
|
|
828
|
+
response.outcome.optionId === "auto" ||
|
|
788
829
|
response.outcome.optionId === "bypassPermissions")) {
|
|
789
830
|
await this.client.sessionUpdate({
|
|
790
831
|
sessionId,
|
|
@@ -1105,7 +1146,7 @@ export class ClaudeAcpAgent {
|
|
|
1105
1146
|
{
|
|
1106
1147
|
id: "auto",
|
|
1107
1148
|
name: "Auto",
|
|
1108
|
-
|
|
1149
|
+
description: "Use a model classifier to approve/deny permission prompts.",
|
|
1109
1150
|
},
|
|
1110
1151
|
{
|
|
1111
1152
|
id: "default",
|
|
@@ -1161,6 +1202,7 @@ export class ClaudeAcpAgent {
|
|
|
1161
1202
|
pendingMessages: new Map(),
|
|
1162
1203
|
nextPendingOrder: 0,
|
|
1163
1204
|
abortController,
|
|
1205
|
+
emitRawSDKMessages: sessionMeta?.claudeCode?.emitRawSDKMessages ?? false,
|
|
1164
1206
|
};
|
|
1165
1207
|
return {
|
|
1166
1208
|
sessionId,
|
|
@@ -1170,6 +1212,13 @@ export class ClaudeAcpAgent {
|
|
|
1170
1212
|
};
|
|
1171
1213
|
}
|
|
1172
1214
|
}
|
|
1215
|
+
function shouldEmitRawMessage(config, message) {
|
|
1216
|
+
if (config === true)
|
|
1217
|
+
return true;
|
|
1218
|
+
if (config === false)
|
|
1219
|
+
return false;
|
|
1220
|
+
return config.some((f) => f.type === message.type && (f.subtype === undefined || f.subtype === message.subtype));
|
|
1221
|
+
}
|
|
1173
1222
|
function sessionUsage(session) {
|
|
1174
1223
|
return {
|
|
1175
1224
|
inputTokens: session.accumulatedUsage.inputTokens,
|
|
@@ -1510,8 +1559,8 @@ export function toAcpNotifications(content, role, sessionId, toolUseCache, clien
|
|
|
1510
1559
|
const alreadyCached = chunk.id in toolUseCache;
|
|
1511
1560
|
toolUseCache[chunk.id] = chunk;
|
|
1512
1561
|
if (chunk.name === "TodoWrite") {
|
|
1513
|
-
// @ts-expect-error - sometimes input is empty object
|
|
1514
|
-
if (Array.isArray(chunk.input
|
|
1562
|
+
// @ts-expect-error - sometimes input is empty object or undefined
|
|
1563
|
+
if (Array.isArray(chunk.input?.todos)) {
|
|
1515
1564
|
update = {
|
|
1516
1565
|
sessionUpdate: "plan",
|
|
1517
1566
|
entries: planEntries(chunk.input),
|
|
@@ -1653,6 +1702,7 @@ export function toAcpNotifications(content, role, sessionId, toolUseCache, clien
|
|
|
1653
1702
|
case "container_upload":
|
|
1654
1703
|
case "compaction":
|
|
1655
1704
|
case "compaction_delta":
|
|
1705
|
+
case "advisor_tool_result":
|
|
1656
1706
|
break;
|
|
1657
1707
|
default:
|
|
1658
1708
|
unreachable(chunk, logger);
|
|
@@ -1703,7 +1753,12 @@ export function runAcp() {
|
|
|
1703
1753
|
const input = nodeToWebWritable(process.stdout);
|
|
1704
1754
|
const output = nodeToWebReadable(process.stdin);
|
|
1705
1755
|
const stream = ndJsonStream(input, output);
|
|
1706
|
-
|
|
1756
|
+
let agent;
|
|
1757
|
+
const connection = new AgentSideConnection((client) => {
|
|
1758
|
+
agent = new ClaudeAcpAgent(client);
|
|
1759
|
+
return agent;
|
|
1760
|
+
}, stream);
|
|
1761
|
+
return { connection, agent };
|
|
1707
1762
|
}
|
|
1708
1763
|
function commonPrefixLength(a, b) {
|
|
1709
1764
|
let i = 0;
|
package/dist/index.js
CHANGED
|
@@ -20,7 +20,19 @@ else {
|
|
|
20
20
|
process.on("unhandledRejection", (reason, promise) => {
|
|
21
21
|
console.error("Unhandled Rejection at:", promise, "reason:", reason);
|
|
22
22
|
});
|
|
23
|
-
runAcp();
|
|
24
|
-
|
|
23
|
+
const { connection, agent } = runAcp();
|
|
24
|
+
async function shutdown() {
|
|
25
|
+
await agent.dispose().catch((err) => {
|
|
26
|
+
console.error("Error during cleanup:", err);
|
|
27
|
+
});
|
|
28
|
+
process.exit(0);
|
|
29
|
+
}
|
|
30
|
+
// Exit cleanly when the ACP connection closes (e.g. stdin EOF, transport
|
|
31
|
+
// error). Without this, `process.stdin.resume()` keeps the event loop
|
|
32
|
+
// alive indefinitely, causing orphan process accumulation in oneshot mode.
|
|
33
|
+
connection.closed.then(shutdown);
|
|
34
|
+
process.on("SIGTERM", shutdown);
|
|
35
|
+
process.on("SIGINT", shutdown);
|
|
36
|
+
// Keep process alive while connection is open
|
|
25
37
|
process.stdin.resume();
|
|
26
38
|
}
|
package/dist/lib.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ClaudeAcpAgent, runAcp, toAcpNotifications, streamEventToAcpNotifications, type ToolUpdateMeta, type NewSessionMeta, } from "./acp-agent.js";
|
|
1
|
+
export { ClaudeAcpAgent, runAcp, toAcpNotifications, streamEventToAcpNotifications, type ToolUpdateMeta, type NewSessionMeta, type SDKMessageFilter, } from "./acp-agent.js";
|
|
2
2
|
export { loadManagedSettings, applyEnvironmentSettings, nodeToWebReadable, nodeToWebWritable, Pushable, unreachable, } from "./utils.js";
|
|
3
3
|
export { toolInfoFromToolUse, toDisplayPath, planEntries, toolUpdateFromToolResult, } from "./tools.js";
|
|
4
4
|
export { SettingsManager, type ClaudeCodeSettings, type SettingsManagerOptions, } from "./settings.js";
|
package/dist/lib.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,MAAM,EACN,kBAAkB,EAClB,6BAA6B,EAC7B,KAAK,cAAc,EACnB,KAAK,cAAc,
|
|
1
|
+
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,MAAM,EACN,kBAAkB,EAClB,6BAA6B,EAC7B,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,gBAAgB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,iBAAiB,EACjB,iBAAiB,EACjB,QAAQ,EACR,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,WAAW,EACX,wBAAwB,GACzB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,eAAe,EACf,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,GAC5B,MAAM,eAAe,CAAC;AAGvB,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/tools.d.ts
CHANGED
|
@@ -42,7 +42,7 @@ export type ClaudePlanEntry = {
|
|
|
42
42
|
};
|
|
43
43
|
export declare function planEntries(input: {
|
|
44
44
|
todos: ClaudePlanEntry[];
|
|
45
|
-
}): PlanEntry[];
|
|
45
|
+
} | undefined): PlanEntry[];
|
|
46
46
|
export declare function markdownEscape(text: string): string;
|
|
47
47
|
/**
|
|
48
48
|
* Builds diff ToolUpdate content from the structured Edit toolResponse provided
|
package/dist/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACT,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAa9D,OAAO,EAGL,oBAAoB,EAEpB,6BAA6B,EAE9B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,yCAAyC,EAGzC,qCAAqC,EAGrC,kCAAkC,EAGlC,+CAA+C,EAI/C,wBAAwB,EACxB,kCAAkC,EAIlC,gCAAgC,EAEhC,iCAAiC,EAClC,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AA0BxC,UAAU,QAAQ;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,SAAS,CAAC,EAAE,gBAAgB,EAAE,CAAC;CAChC;AAED,UAAU,UAAU;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;IAC5B,SAAS,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC/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wB,CACtC,UAAU,EACN,oBAAoB,GACpB,wBAAwB,GACxB,iCAAiC,GACjC,gCAAgC,GAChC,6BAA6B,GAC7B,qCAAqC,GACrC,yCAAyC,GACzC,+CAA+C,GAC/C,kCAAkC,GAClC,kCAAkC,EACtC,OAAO,EAAE,GAAG,GAAG,SAAS,EACxB,sBAAsB,GAAE,OAAe,GACtC,UAAU,CA6HZ;AA0GD,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,SAAS,GAAG,aAAa,GAAG,WAAW,CAAC;IAChD,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,WAAW,CAAC,KAAK,EAAE;IAAE,KAAK,EAAE,eAAe,EAAE,CAAA;CAAE,GAAG,SAAS,GAAG,SAAS,EAAE,CAMxF;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQnD;AAeD;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAAC,YAAY,EAAE,OAAO,GAAG;IACrE,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;IAC5B,SAAS,CAAC,EAAE,gBAAgB,EAAE,CAAC;CAChC,CAoCA;AAcD,eAAO,MAAM,oBAAoB,GAC/B,WAAW,MAAM,EACjB,wBAEG;IACD,iBAAiB,CAAC,EAAE,CAClB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,OAAO,EAClB,YAAY,EAAE,OAAO,KAClB,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB,SAKF,CAAC;AAGF,eAAO,MAAM,qBAAqB,GAE9B,SAAQ,MAAgB,EACxB,UAAU;IACR,eAAe,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACvC,KACA,YAoBF,CAAC"}
|
package/dist/tools.js
CHANGED
|
@@ -52,17 +52,17 @@ export function toolInfoFromToolUse(toolUse, supportsTerminalOutput = false, cwd
|
|
|
52
52
|
case "Read": {
|
|
53
53
|
const input = toolUse.input;
|
|
54
54
|
let limit = "";
|
|
55
|
-
if (input
|
|
55
|
+
if (input?.limit && input.limit > 0) {
|
|
56
56
|
limit = " (" + (input.offset ?? 1) + " - " + ((input.offset ?? 1) + input.limit - 1) + ")";
|
|
57
57
|
}
|
|
58
|
-
else if (input
|
|
58
|
+
else if (input?.offset) {
|
|
59
59
|
limit = " (from line " + input.offset + ")";
|
|
60
60
|
}
|
|
61
|
-
const displayPath = input
|
|
61
|
+
const displayPath = input?.file_path ? toDisplayPath(input.file_path, cwd) : "File";
|
|
62
62
|
return {
|
|
63
63
|
title: "Read " + displayPath + limit,
|
|
64
64
|
kind: "read",
|
|
65
|
-
locations: input
|
|
65
|
+
locations: input?.file_path
|
|
66
66
|
? [
|
|
67
67
|
{
|
|
68
68
|
path: input.file_path,
|
|
@@ -126,38 +126,38 @@ export function toolInfoFromToolUse(toolUse, supportsTerminalOutput = false, cwd
|
|
|
126
126
|
case "Glob": {
|
|
127
127
|
const input = toolUse.input;
|
|
128
128
|
let label = "Find";
|
|
129
|
-
if (input
|
|
129
|
+
if (input?.path) {
|
|
130
130
|
label += ` \`${input.path}\``;
|
|
131
131
|
}
|
|
132
|
-
if (input
|
|
132
|
+
if (input?.pattern) {
|
|
133
133
|
label += ` \`${input.pattern}\``;
|
|
134
134
|
}
|
|
135
135
|
return {
|
|
136
136
|
title: label,
|
|
137
137
|
kind: "search",
|
|
138
138
|
content: [],
|
|
139
|
-
locations: input
|
|
139
|
+
locations: input?.path ? [{ path: input.path }] : [],
|
|
140
140
|
};
|
|
141
141
|
}
|
|
142
142
|
case "Grep": {
|
|
143
143
|
const input = toolUse.input;
|
|
144
144
|
let label = "grep";
|
|
145
|
-
if (input["-i"]) {
|
|
145
|
+
if (input?.["-i"]) {
|
|
146
146
|
label += " -i";
|
|
147
147
|
}
|
|
148
|
-
if (input["-n"]) {
|
|
148
|
+
if (input?.["-n"]) {
|
|
149
149
|
label += " -n";
|
|
150
150
|
}
|
|
151
|
-
if (input["-A"] !== undefined) {
|
|
151
|
+
if (input?.["-A"] !== undefined) {
|
|
152
152
|
label += ` -A ${input["-A"]}`;
|
|
153
153
|
}
|
|
154
|
-
if (input["-B"] !== undefined) {
|
|
154
|
+
if (input?.["-B"] !== undefined) {
|
|
155
155
|
label += ` -B ${input["-B"]}`;
|
|
156
156
|
}
|
|
157
|
-
if (input["-C"] !== undefined) {
|
|
157
|
+
if (input?.["-C"] !== undefined) {
|
|
158
158
|
label += ` -C ${input["-C"]}`;
|
|
159
159
|
}
|
|
160
|
-
if (input
|
|
160
|
+
if (input?.output_mode) {
|
|
161
161
|
switch (input.output_mode) {
|
|
162
162
|
case "files_with_matches":
|
|
163
163
|
label += " -l";
|
|
@@ -170,22 +170,22 @@ export function toolInfoFromToolUse(toolUse, supportsTerminalOutput = false, cwd
|
|
|
170
170
|
break;
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
|
-
if (input
|
|
173
|
+
if (input?.head_limit !== undefined) {
|
|
174
174
|
label += ` | head -${input.head_limit}`;
|
|
175
175
|
}
|
|
176
|
-
if (input
|
|
176
|
+
if (input?.glob) {
|
|
177
177
|
label += ` --include="${input.glob}"`;
|
|
178
178
|
}
|
|
179
|
-
if (input
|
|
179
|
+
if (input?.type) {
|
|
180
180
|
label += ` --type=${input.type}`;
|
|
181
181
|
}
|
|
182
|
-
if (input
|
|
182
|
+
if (input?.multiline) {
|
|
183
183
|
label += " -P";
|
|
184
184
|
}
|
|
185
|
-
if (input
|
|
185
|
+
if (input?.pattern) {
|
|
186
186
|
label += ` "${input.pattern}"`;
|
|
187
187
|
}
|
|
188
|
-
if (input
|
|
188
|
+
if (input?.path) {
|
|
189
189
|
label += ` ${input.path}`;
|
|
190
190
|
}
|
|
191
191
|
return {
|
|
@@ -211,11 +211,11 @@ export function toolInfoFromToolUse(toolUse, supportsTerminalOutput = false, cwd
|
|
|
211
211
|
}
|
|
212
212
|
case "WebSearch": {
|
|
213
213
|
const input = toolUse.input;
|
|
214
|
-
let label = `"${input.query}"
|
|
215
|
-
if (input
|
|
214
|
+
let label = input?.query ? `"${input.query}"` : "Web search";
|
|
215
|
+
if (input?.allowed_domains && input.allowed_domains.length > 0) {
|
|
216
216
|
label += ` (allowed: ${input.allowed_domains.join(", ")})`;
|
|
217
217
|
}
|
|
218
|
-
if (input
|
|
218
|
+
if (input?.blocked_domains && input.blocked_domains.length > 0) {
|
|
219
219
|
label += ` (blocked: ${input.blocked_domains.join(", ")})`;
|
|
220
220
|
}
|
|
221
221
|
return {
|
|
@@ -477,9 +477,9 @@ function toAcpContentBlock(content, isError) {
|
|
|
477
477
|
}
|
|
478
478
|
}
|
|
479
479
|
export function planEntries(input) {
|
|
480
|
-
return input
|
|
481
|
-
content:
|
|
482
|
-
status:
|
|
480
|
+
return (input?.todos ?? []).map((todo) => ({
|
|
481
|
+
content: todo.content,
|
|
482
|
+
status: todo.status,
|
|
483
483
|
priority: "medium",
|
|
484
484
|
}));
|
|
485
485
|
}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.27.0",
|
|
7
7
|
"description": "An ACP-compatible coding agent powered by the Claude Agent SDK (TypeScript)",
|
|
8
8
|
"main": "dist/lib.js",
|
|
9
9
|
"types": "dist/lib.d.ts",
|
|
@@ -60,22 +60,22 @@
|
|
|
60
60
|
"author": "Zed Industries",
|
|
61
61
|
"license": "Apache-2.0",
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@agentclientprotocol/sdk": "0.18.
|
|
64
|
-
"@anthropic-ai/claude-agent-sdk": "0.2.
|
|
63
|
+
"@agentclientprotocol/sdk": "0.18.2",
|
|
64
|
+
"@anthropic-ai/claude-agent-sdk": "0.2.104",
|
|
65
65
|
"zod": "^3.25.0 || ^4.0.0"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@anthropic-ai/sdk": "0.
|
|
68
|
+
"@anthropic-ai/sdk": "0.88.0",
|
|
69
69
|
"@eslint/js": "10.0.1",
|
|
70
|
-
"@types/node": "25.
|
|
71
|
-
"@typescript-eslint/eslint-plugin": "8.58.
|
|
72
|
-
"@typescript-eslint/parser": "8.58.
|
|
70
|
+
"@types/node": "25.6.0",
|
|
71
|
+
"@typescript-eslint/eslint-plugin": "8.58.1",
|
|
72
|
+
"@typescript-eslint/parser": "8.58.1",
|
|
73
73
|
"eslint": "10.2.0",
|
|
74
74
|
"eslint-config-prettier": "10.1.8",
|
|
75
|
-
"globals": "17.
|
|
76
|
-
"prettier": "3.8.
|
|
75
|
+
"globals": "17.5.0",
|
|
76
|
+
"prettier": "3.8.2",
|
|
77
77
|
"ts-node": "10.9.2",
|
|
78
78
|
"typescript": "6.0.2",
|
|
79
|
-
"vitest": "4.1.
|
|
79
|
+
"vitest": "4.1.4"
|
|
80
80
|
}
|
|
81
81
|
}
|