@agentclientprotocol/claude-agent-acp 0.52.0 → 0.53.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 +20 -1
- package/dist/acp-agent.d.ts.map +1 -1
- package/dist/acp-agent.js +134 -43
- package/dist/elicitation.d.ts.map +1 -1
- package/dist/index.js +8 -5
- package/package.json +4 -4
package/dist/acp-agent.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuthenticateRequest, CancelNotification, ClientCapabilities, CompleteElicitationNotification, CreateElicitationRequest, CreateElicitationResponse, ForkSessionRequest, ForkSessionResponse, InitializeRequest, InitializeResponse, ListSessionsRequest, ListSessionsResponse, LoadSessionRequest, LoadSessionResponse, NewSessionRequest, NewSessionResponse, PromptRequest, PromptResponse, ReadTextFileRequest, ReadTextFileResponse, RequestPermissionRequest, RequestPermissionResponse, ResumeSessionRequest, ResumeSessionResponse, SessionConfigOption, SessionModeState, SessionNotification, SetSessionConfigOptionRequest, SetSessionConfigOptionResponse, SetSessionModeRequest, SetSessionModeResponse, CloseSessionRequest, CloseSessionResponse, DeleteSessionRequest, DeleteSessionResponse, WriteTextFileRequest, WriteTextFileResponse } from "@agentclientprotocol/sdk";
|
|
1
|
+
import { AuthenticateRequest, CancelNotification, ClientCapabilities, CompleteElicitationNotification, CreateElicitationRequest, CreateElicitationResponse, ForkSessionRequest, ForkSessionResponse, InitializeRequest, InitializeResponse, ListSessionsRequest, ListSessionsResponse, LoadSessionRequest, LoadSessionResponse, LogoutRequest, NewSessionRequest, NewSessionResponse, PromptRequest, PromptResponse, ReadTextFileRequest, ReadTextFileResponse, RequestPermissionRequest, RequestPermissionResponse, ResumeSessionRequest, ResumeSessionResponse, SessionConfigOption, SessionModeState, SessionNotification, SetSessionConfigOptionRequest, SetSessionConfigOptionResponse, SetSessionModeRequest, SetSessionModeResponse, CloseSessionRequest, CloseSessionResponse, DeleteSessionRequest, DeleteSessionResponse, WriteTextFileRequest, WriteTextFileResponse } from "@agentclientprotocol/sdk";
|
|
2
2
|
import { AgentInfo, CanUseTool, ModelInfo, Options, PermissionMode, PermissionUpdate, Query, SDKMessageOrigin, SDKPartialAssistantMessage, SDKUserMessage } from "@anthropic-ai/claude-agent-sdk";
|
|
3
3
|
import { ContentBlockParam } from "@anthropic-ai/sdk/resources";
|
|
4
4
|
import { BetaContentBlock, BetaRawContentBlockDelta } from "@anthropic-ai/sdk/resources/beta.mjs";
|
|
@@ -131,6 +131,14 @@ type Session = {
|
|
|
131
131
|
* `tool_result` time so a long-running session doesn't accumulate every
|
|
132
132
|
* tool call for its whole lifetime. */
|
|
133
133
|
toolUseCache: ToolUseCache;
|
|
134
|
+
/** Tracks which tool_use ids we've already emitted a `tool_call` for, so the
|
|
135
|
+
* second source to encounter a tool call sends a `tool_call_update` instead
|
|
136
|
+
* of a duplicate `tool_call`. The SDK can invoke `canUseTool` (→ a permission
|
|
137
|
+
* request, which emits the tool_call eagerly so the client has it before
|
|
138
|
+
* being asked to approve it) either before or after the assistant message's
|
|
139
|
+
* tool_use block streams; this set makes the two paths converge regardless of
|
|
140
|
+
* order. Pruned at `tool_result` time alongside `toolUseCache`. */
|
|
141
|
+
emittedToolCalls: Set<string>;
|
|
134
142
|
/** Maps the ACP `messageId` we expose to clients (see `messageIdForGrouping`)
|
|
135
143
|
* to the SDK message uuid that the Agent SDK's rewind/resume APIs key on
|
|
136
144
|
* (`Query.rewindFiles` takes a user-message uuid; `resumeSessionAt` takes an
|
|
@@ -298,6 +306,7 @@ export declare class ClaudeAcpAgent {
|
|
|
298
306
|
* the title is best-effort and another turn will retry. */
|
|
299
307
|
private maybeUpdateSessionTitle;
|
|
300
308
|
authenticate(_params: AuthenticateRequest): Promise<void>;
|
|
309
|
+
logout(_params: LogoutRequest): Promise<void>;
|
|
301
310
|
prompt(params: PromptRequest): Promise<PromptResponse>;
|
|
302
311
|
/** Lazily start the per-session consumer that drains the SDK query stream for
|
|
303
312
|
* the session's whole life. Idempotent: only the first `prompt()` starts it. */
|
|
@@ -350,6 +359,14 @@ export declare class ClaudeAcpAgent {
|
|
|
350
359
|
* "Tool use aborted" the callers already expect, so a cancelled dialog no
|
|
351
360
|
* longer leaves the `await` hanging. */
|
|
352
361
|
private requestPermissionFromClient;
|
|
362
|
+
/** Emit the `tool_call` a permission request references if it hasn't been sent
|
|
363
|
+
* yet, so the client has the tool call before being asked to approve it. The
|
|
364
|
+
* matching streamed tool_use chunk later refines it with a `tool_call_update`
|
|
365
|
+
* instead of emitting a duplicate (see `emittedToolCalls`). Built via the same
|
|
366
|
+
* `toolCallNotification` helper as the streamed path so the two are identical.
|
|
367
|
+
* Tools the stream renders as a plan (TodoWrite) or suppresses (Task*) are
|
|
368
|
+
* skipped so a permission prompt for them never surfaces a stray tool_call. */
|
|
369
|
+
private ensureToolCallEmitted;
|
|
353
370
|
canUseTool(sessionId: string): CanUseTool;
|
|
354
371
|
/**
|
|
355
372
|
* Handle elicitation requests that originate from MCP servers by forwarding
|
|
@@ -411,12 +428,14 @@ export declare function toAcpNotifications(content: string | ContentBlockParam[]
|
|
|
411
428
|
parentToolUseId?: string | null;
|
|
412
429
|
cwd?: string;
|
|
413
430
|
taskState?: TaskState;
|
|
431
|
+
emittedToolCalls?: Set<string>;
|
|
414
432
|
messageId?: string;
|
|
415
433
|
}): SessionNotification[];
|
|
416
434
|
export declare function streamEventToAcpNotifications(message: SDKPartialAssistantMessage, sessionId: string, toolUseCache: ToolUseCache, client: AcpClient, logger: Logger, options?: {
|
|
417
435
|
clientCapabilities?: ClientCapabilities;
|
|
418
436
|
cwd?: string;
|
|
419
437
|
taskState?: TaskState;
|
|
438
|
+
emittedToolCalls?: Set<string>;
|
|
420
439
|
messageId?: string;
|
|
421
440
|
}): SessionNotification[];
|
|
422
441
|
/** Run a `session/prompt` while honoring `$/cancel_request` for it. ACP clients
|
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,EAGL,mBAAmB,EAGnB,kBAAkB,EAClB,kBAAkB,EAClB,+BAA+B,EAC/B,wBAAwB,EACxB,yBAAyB,EACzB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"acp-agent.d.ts","sourceRoot":"","sources":["../src/acp-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,mBAAmB,EAGnB,kBAAkB,EAClB,kBAAkB,EAClB,+BAA+B,EAC/B,wBAAwB,EACxB,yBAAyB,EACzB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EAGb,iBAAiB,EACjB,kBAAkB,EAElB,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EAEpB,wBAAwB,EACxB,yBAAyB,EACzB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,6BAA6B,EAC7B,8BAA8B,EAC9B,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EAEtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,SAAS,EACT,UAAU,EAMV,SAAS,EAGT,OAAO,EACP,cAAc,EAEd,gBAAgB,EAChB,KAAK,EAKL,gBAAgB,EAChB,0BAA0B,EAC1B,cAAc,EAGf,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,sCAAsC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MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE;IACR,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,gBAAgB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GACA,mBAAmB,EAAE,CAoDvB;AAED;;;;;;;;;;;oEAWoE;AACpE,wBAAsB,yBAAyB,CAC7C,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC,EAC3D,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,cAAc,CAAC,CAczB;AAED,wBAAgB,MAAM;;;EAqCrB"}
|
package/dist/acp-agent.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { agent as acpAgent, methods, ndJsonStream, RequestError, } from "@agentclientprotocol/sdk";
|
|
2
2
|
import { deleteSession, getSessionInfo, getSessionMessages, listSessions, query, } from "@anthropic-ai/claude-agent-sdk";
|
|
3
|
+
import { execFile } from "node:child_process";
|
|
3
4
|
import { randomUUID } from "node:crypto";
|
|
4
5
|
import * as fs from "node:fs/promises";
|
|
5
6
|
import * as os from "node:os";
|
|
6
7
|
import * as path from "node:path";
|
|
8
|
+
import { promisify } from "node:util";
|
|
7
9
|
import packageJson from "../package.json" with { type: "json" };
|
|
8
10
|
import { applyAskElicitationResponse, askUserQuestionsToCreateRequest, createElicitationResponseToElicitResult, extractAskUserQuestions, mcpElicitationToCreateRequest, } from "./elicitation.js";
|
|
9
11
|
import { SettingsManager } from "./settings.js";
|
|
10
12
|
import { applyTaskCreate, applyTaskUpdate, createPostToolUseHook, createTaskHook, parseTaskCreateOutput, planEntries, registerHookCallback, taskStateToPlanEntries, toolInfoFromToolUse, toolUpdateFromDiffToolResponse, toolUpdateFromToolResult, } from "./tools.js";
|
|
11
13
|
import { nodeToWebReadable, nodeToWebWritable, Pushable, unreachable } from "./utils.js";
|
|
12
14
|
export const CLAUDE_CONFIG_DIR = process.env.CLAUDE_CONFIG_DIR ?? path.join(os.homedir(), ".claude");
|
|
15
|
+
const execFileAsync = promisify(execFile);
|
|
13
16
|
const MAX_TITLE_LENGTH = 256;
|
|
14
17
|
function sanitizeTitle(text) {
|
|
15
18
|
// Replace newlines and collapse whitespace
|
|
@@ -411,6 +414,9 @@ export class ClaudeAcpAgent {
|
|
|
411
414
|
http: true,
|
|
412
415
|
sse: true,
|
|
413
416
|
},
|
|
417
|
+
auth: {
|
|
418
|
+
logout: {},
|
|
419
|
+
},
|
|
414
420
|
loadSession: true,
|
|
415
421
|
sessionCapabilities: {
|
|
416
422
|
additionalDirectories: {},
|
|
@@ -534,6 +540,25 @@ export class ClaudeAcpAgent {
|
|
|
534
540
|
}
|
|
535
541
|
throw new Error("Method not implemented.");
|
|
536
542
|
}
|
|
543
|
+
async logout(_params) {
|
|
544
|
+
// Clear in-memory gateway credentials supplied via `authenticate`. The
|
|
545
|
+
// gateway method never touches the on-disk credential store, so dropping
|
|
546
|
+
// this reference is the whole logout for that path.
|
|
547
|
+
this.gatewayAuthRequest = undefined;
|
|
548
|
+
// For the Claude/Console login methods the credentials live in the native
|
|
549
|
+
// CLI's store (keychain or config dir), which only the binary can clear.
|
|
550
|
+
// `claude auth logout` is non-interactive and idempotent.
|
|
551
|
+
const cliPath = await claudeCliPath();
|
|
552
|
+
try {
|
|
553
|
+
await execFileAsync(cliPath, ["auth", "logout"]);
|
|
554
|
+
}
|
|
555
|
+
catch (error) {
|
|
556
|
+
const stderr = typeof error === "object" && error && "stderr" in error
|
|
557
|
+
? String(error.stderr).trim()
|
|
558
|
+
: undefined;
|
|
559
|
+
throw RequestError.internalError({ stderr: stderr || undefined }, `claude auth logout failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
537
562
|
async prompt(params) {
|
|
538
563
|
const session = this.sessions[params.sessionId];
|
|
539
564
|
if (!session) {
|
|
@@ -1081,6 +1106,7 @@ export class ClaudeAcpAgent {
|
|
|
1081
1106
|
case "api_retry":
|
|
1082
1107
|
case "thinking_tokens":
|
|
1083
1108
|
case "model_refusal_fallback":
|
|
1109
|
+
case "model_refusal_no_fallback":
|
|
1084
1110
|
// Todo: process via status api: https://docs.claude.com/en/docs/claude-code/hooks#hook-output
|
|
1085
1111
|
break;
|
|
1086
1112
|
default:
|
|
@@ -1342,6 +1368,7 @@ export class ClaudeAcpAgent {
|
|
|
1342
1368
|
clientCapabilities: this.clientCapabilities,
|
|
1343
1369
|
cwd: session.cwd,
|
|
1344
1370
|
taskState: session.taskState,
|
|
1371
|
+
emittedToolCalls: session.emittedToolCalls,
|
|
1345
1372
|
messageId: currentStreamMessageId,
|
|
1346
1373
|
})) {
|
|
1347
1374
|
await this.client.sessionUpdate(notification);
|
|
@@ -1537,6 +1564,7 @@ export class ClaudeAcpAgent {
|
|
|
1537
1564
|
parentToolUseId: message.parent_tool_use_id,
|
|
1538
1565
|
cwd: session.cwd,
|
|
1539
1566
|
taskState: session.taskState,
|
|
1567
|
+
emittedToolCalls: session.emittedToolCalls,
|
|
1540
1568
|
messageId: messageIdForGrouping(message),
|
|
1541
1569
|
})) {
|
|
1542
1570
|
await this.client.sessionUpdate(notification);
|
|
@@ -1912,7 +1940,14 @@ export class ClaudeAcpAgent {
|
|
|
1912
1940
|
* outcome or a `requestCancelled` rejection). Either way we surface the same
|
|
1913
1941
|
* "Tool use aborted" the callers already expect, so a cancelled dialog no
|
|
1914
1942
|
* longer leaves the `await` hanging. */
|
|
1915
|
-
async requestPermissionFromClient(params, signal) {
|
|
1943
|
+
async requestPermissionFromClient(params, toolName, signal) {
|
|
1944
|
+
// The SDK may invoke `canUseTool` (and therefore this permission request)
|
|
1945
|
+
// before the assistant message's tool_use block streams to us. Some ACP clients
|
|
1946
|
+
// expect the `tool_call` a permission request references to already exist,
|
|
1947
|
+
// so emit it now if it hasn't been sent yet. The streamed tool_use chunk
|
|
1948
|
+
// later refines it with a `tool_call_update` rather than emitting a
|
|
1949
|
+
// duplicate (see `emittedToolCalls` in `toAcpNotifications`).
|
|
1950
|
+
await this.ensureToolCallEmitted(params.sessionId, toolName, params.toolCall.toolCallId, params.toolCall.rawInput);
|
|
1916
1951
|
try {
|
|
1917
1952
|
return await this.client.requestPermission(params, signal);
|
|
1918
1953
|
}
|
|
@@ -1923,6 +1958,28 @@ export class ClaudeAcpAgent {
|
|
|
1923
1958
|
throw error;
|
|
1924
1959
|
}
|
|
1925
1960
|
}
|
|
1961
|
+
/** Emit the `tool_call` a permission request references if it hasn't been sent
|
|
1962
|
+
* yet, so the client has the tool call before being asked to approve it. The
|
|
1963
|
+
* matching streamed tool_use chunk later refines it with a `tool_call_update`
|
|
1964
|
+
* instead of emitting a duplicate (see `emittedToolCalls`). Built via the same
|
|
1965
|
+
* `toolCallNotification` helper as the streamed path so the two are identical.
|
|
1966
|
+
* Tools the stream renders as a plan (TodoWrite) or suppresses (Task*) are
|
|
1967
|
+
* skipped so a permission prompt for them never surfaces a stray tool_call. */
|
|
1968
|
+
async ensureToolCallEmitted(sessionId, toolName, toolCallId, toolInput) {
|
|
1969
|
+
const session = this.sessions[sessionId];
|
|
1970
|
+
if (!session || !shouldEmitToolCall(toolName)) {
|
|
1971
|
+
return;
|
|
1972
|
+
}
|
|
1973
|
+
if (session.emittedToolCalls.has(toolCallId)) {
|
|
1974
|
+
return;
|
|
1975
|
+
}
|
|
1976
|
+
session.emittedToolCalls.add(toolCallId);
|
|
1977
|
+
const supportsTerminalOutput = this.clientCapabilities?._meta?.["terminal_output"] === true;
|
|
1978
|
+
await this.client.sessionUpdate({
|
|
1979
|
+
sessionId,
|
|
1980
|
+
update: toolCallNotification({ id: toolCallId, name: toolName, input: toolInput }, toolInput, supportsTerminalOutput, session.cwd),
|
|
1981
|
+
});
|
|
1982
|
+
}
|
|
1926
1983
|
canUseTool(sessionId) {
|
|
1927
1984
|
return async (toolName, toolInput, { signal, suggestions, toolUseID }) => {
|
|
1928
1985
|
const alwaysAllowLabel = describeAlwaysAllow(suggestions, toolName);
|
|
@@ -1939,6 +1996,9 @@ export class ClaudeAcpAgent {
|
|
|
1939
1996
|
// than the interactive dialog). Present it as an ACP form elicitation and
|
|
1940
1997
|
// feed the answers back as updatedInput for the tool's own call() to read.
|
|
1941
1998
|
if (toolName === "AskUserQuestion" && this.clientCapabilities?.elicitation?.form) {
|
|
1999
|
+
// Like permission requests, the elicitation references this toolUseID, so
|
|
2000
|
+
// make sure the tool_call has surfaced to the client before we send it.
|
|
2001
|
+
await this.ensureToolCallEmitted(sessionId, toolName, toolUseID, toolInput);
|
|
1942
2002
|
return this.handleAskUserQuestion(sessionId, toolInput, toolUseID, signal);
|
|
1943
2003
|
}
|
|
1944
2004
|
if (toolName === "ExitPlanMode") {
|
|
@@ -1973,7 +2033,7 @@ export class ClaudeAcpAgent {
|
|
|
1973
2033
|
rawInput: toolInput,
|
|
1974
2034
|
...toolInfoFromToolUse({ name: toolName, input: toolInput, id: toolUseID }, supportsTerminalOutput, session?.cwd),
|
|
1975
2035
|
},
|
|
1976
|
-
}, signal);
|
|
2036
|
+
}, toolName, signal);
|
|
1977
2037
|
if (signal.aborted || response.outcome?.outcome === "cancelled") {
|
|
1978
2038
|
throw new Error("Tool use aborted");
|
|
1979
2039
|
}
|
|
@@ -2032,7 +2092,7 @@ export class ClaudeAcpAgent {
|
|
|
2032
2092
|
rawInput: toolInput,
|
|
2033
2093
|
...toolInfoFromToolUse({ name: toolName, input: toolInput, id: toolUseID }, supportsTerminalOutput, session?.cwd),
|
|
2034
2094
|
},
|
|
2035
|
-
}, signal);
|
|
2095
|
+
}, toolName, signal);
|
|
2036
2096
|
if (signal.aborted || response.outcome?.outcome === "cancelled") {
|
|
2037
2097
|
throw new Error("Tool use aborted");
|
|
2038
2098
|
}
|
|
@@ -2640,6 +2700,7 @@ export class ClaudeAcpAgent {
|
|
|
2640
2700
|
contextWindowSize: inferContextWindowFromModel(models.currentModelId, currentModelInfo?.displayName, currentModelInfo?.description) ?? DEFAULT_CONTEXT_WINDOW,
|
|
2641
2701
|
taskState,
|
|
2642
2702
|
toolUseCache: {},
|
|
2703
|
+
emittedToolCalls: new Set(),
|
|
2643
2704
|
messageIdToUuid: new Map(),
|
|
2644
2705
|
};
|
|
2645
2706
|
return {
|
|
@@ -3262,6 +3323,53 @@ function applyMessageId(update, messageId) {
|
|
|
3262
3323
|
update.messageId = messageId;
|
|
3263
3324
|
}
|
|
3264
3325
|
}
|
|
3326
|
+
/** Built-in tools that drive the task list (headless/SDK sessions use these
|
|
3327
|
+
* instead of TodoWrite). Their tool_use/tool_result are surfaced as `plan`
|
|
3328
|
+
* snapshots rather than as tool_calls. */
|
|
3329
|
+
function isTaskTool(toolName) {
|
|
3330
|
+
return (toolName === "TaskCreate" ||
|
|
3331
|
+
toolName === "TaskUpdate" ||
|
|
3332
|
+
toolName === "TaskList" ||
|
|
3333
|
+
toolName === "TaskGet");
|
|
3334
|
+
}
|
|
3335
|
+
/** Whether a tool's tool_use surfaces to the client as a standalone
|
|
3336
|
+
* `tool_call`. TodoWrite is rendered as a `plan` and Task* tools are
|
|
3337
|
+
* suppressed (their plan snapshot is emitted at tool_result time), so neither
|
|
3338
|
+
* produces a tool_call. */
|
|
3339
|
+
function shouldEmitToolCall(toolName) {
|
|
3340
|
+
return toolName !== "TodoWrite" && !isTaskTool(toolName);
|
|
3341
|
+
}
|
|
3342
|
+
/** Build the `tool_call` (or, with `refine`, the `tool_call_update`)
|
|
3343
|
+
* notification for a tool_use. Shared by every site that surfaces a tool call:
|
|
3344
|
+
* the streamed tool_use path (first encounter → tool_call, later encounter →
|
|
3345
|
+
* refine) and the permission flow (`ensureToolCallEmitted`), so they can't
|
|
3346
|
+
* drift. The initial `tool_call` carries `status: "pending"` and, for Bash, the
|
|
3347
|
+
* `terminal_info` _meta that the later `terminal_output`/`terminal_exit`
|
|
3348
|
+
* updates key off of; a refining `tool_call_update` carries neither. */
|
|
3349
|
+
function toolCallNotification(toolUse, rawInput, supportsTerminalOutput, cwd, refine = false) {
|
|
3350
|
+
if (refine) {
|
|
3351
|
+
return {
|
|
3352
|
+
_meta: { claudeCode: { toolName: toolUse.name } },
|
|
3353
|
+
toolCallId: toolUse.id,
|
|
3354
|
+
sessionUpdate: "tool_call_update",
|
|
3355
|
+
rawInput,
|
|
3356
|
+
...toolInfoFromToolUse(toolUse, supportsTerminalOutput, cwd),
|
|
3357
|
+
};
|
|
3358
|
+
}
|
|
3359
|
+
return {
|
|
3360
|
+
_meta: {
|
|
3361
|
+
claudeCode: { toolName: toolUse.name },
|
|
3362
|
+
...(toolUse.name === "Bash" && supportsTerminalOutput
|
|
3363
|
+
? { terminal_info: { terminal_id: toolUse.id } }
|
|
3364
|
+
: {}),
|
|
3365
|
+
},
|
|
3366
|
+
toolCallId: toolUse.id,
|
|
3367
|
+
sessionUpdate: "tool_call",
|
|
3368
|
+
rawInput,
|
|
3369
|
+
status: "pending",
|
|
3370
|
+
...toolInfoFromToolUse(toolUse, supportsTerminalOutput, cwd),
|
|
3371
|
+
};
|
|
3372
|
+
}
|
|
3265
3373
|
/**
|
|
3266
3374
|
* Convert an SDKAssistantMessage (Claude) to a SessionNotification (ACP).
|
|
3267
3375
|
* Only handles text, image, and thinking chunks for now.
|
|
@@ -3344,10 +3452,7 @@ export function toAcpNotifications(content, role, sessionId, toolUseCache, clien
|
|
|
3344
3452
|
};
|
|
3345
3453
|
}
|
|
3346
3454
|
}
|
|
3347
|
-
else if (chunk.name
|
|
3348
|
-
chunk.name === "TaskUpdate" ||
|
|
3349
|
-
chunk.name === "TaskList" ||
|
|
3350
|
-
chunk.name === "TaskGet") {
|
|
3455
|
+
else if (isTaskTool(chunk.name)) {
|
|
3351
3456
|
// Task* tool_use is suppressed; the plan update is emitted at
|
|
3352
3457
|
// tool_result time once we have the task ID (for TaskCreate) and
|
|
3353
3458
|
// confirmation that the change took effect.
|
|
@@ -3399,40 +3504,25 @@ export function toAcpNotifications(content, role, sessionId, toolUseCache, clien
|
|
|
3399
3504
|
catch {
|
|
3400
3505
|
// ignore if we can't turn it to JSON
|
|
3401
3506
|
}
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
};
|
|
3507
|
+
// Emit a `tool_call` only the first time this id surfaces to the
|
|
3508
|
+
// client; afterwards refine it with a `tool_call_update`. The first
|
|
3509
|
+
// surface may be this stream chunk OR an earlier permission request
|
|
3510
|
+
// (see `ensureToolCallEmitted`), so emission is tracked separately
|
|
3511
|
+
// from `toolUseCache`. Without an `emittedToolCalls` set we fall back
|
|
3512
|
+
// to cache presence — the historical streaming-only behavior.
|
|
3513
|
+
const emittedToolCalls = options?.emittedToolCalls;
|
|
3514
|
+
const alreadyEmitted = emittedToolCalls ? emittedToolCalls.has(chunk.id) : alreadyCached;
|
|
3515
|
+
emittedToolCalls?.add(chunk.id);
|
|
3516
|
+
if (alreadyEmitted) {
|
|
3517
|
+
// Already surfaced (full assistant message after streaming, or a
|
|
3518
|
+
// permission request emitted it first) — refine with a
|
|
3519
|
+
// tool_call_update rather than emitting a duplicate tool_call.
|
|
3520
|
+
update = toolCallNotification(chunk, rawInput, supportsTerminalOutput, options?.cwd, true);
|
|
3417
3521
|
}
|
|
3418
3522
|
else {
|
|
3419
|
-
// First
|
|
3420
|
-
//
|
|
3421
|
-
update =
|
|
3422
|
-
_meta: {
|
|
3423
|
-
claudeCode: {
|
|
3424
|
-
toolName: chunk.name,
|
|
3425
|
-
},
|
|
3426
|
-
...(chunk.name === "Bash" && supportsTerminalOutput
|
|
3427
|
-
? { terminal_info: { terminal_id: chunk.id } }
|
|
3428
|
-
: {}),
|
|
3429
|
-
},
|
|
3430
|
-
toolCallId: chunk.id,
|
|
3431
|
-
sessionUpdate: "tool_call",
|
|
3432
|
-
rawInput,
|
|
3433
|
-
status: "pending",
|
|
3434
|
-
...toolInfoFromToolUse(chunk, supportsTerminalOutput, options?.cwd),
|
|
3435
|
-
};
|
|
3523
|
+
// First surface (streaming content_block_start or replay) — send as
|
|
3524
|
+
// tool_call (with terminal_info for Bash).
|
|
3525
|
+
update = toolCallNotification(chunk, rawInput, supportsTerminalOutput, options?.cwd);
|
|
3436
3526
|
}
|
|
3437
3527
|
}
|
|
3438
3528
|
break;
|
|
@@ -3445,15 +3535,13 @@ export function toAcpNotifications(content, role, sessionId, toolUseCache, clien
|
|
|
3445
3535
|
case "bash_code_execution_tool_result":
|
|
3446
3536
|
case "text_editor_code_execution_tool_result":
|
|
3447
3537
|
case "mcp_tool_result": {
|
|
3538
|
+
options?.emittedToolCalls?.delete(chunk.tool_use_id);
|
|
3448
3539
|
const toolUse = toolUseCache[chunk.tool_use_id];
|
|
3449
3540
|
if (!toolUse) {
|
|
3450
3541
|
logger.error(`[claude-agent-acp] Got a tool result for tool use that wasn't tracked: ${chunk.tool_use_id}`);
|
|
3451
3542
|
break;
|
|
3452
3543
|
}
|
|
3453
|
-
if (toolUse.name
|
|
3454
|
-
toolUse.name === "TaskUpdate" ||
|
|
3455
|
-
toolUse.name === "TaskList" ||
|
|
3456
|
-
toolUse.name === "TaskGet") {
|
|
3544
|
+
if (isTaskTool(toolUse.name)) {
|
|
3457
3545
|
// Headless/SDK sessions emit Task* tools instead of TodoWrite.
|
|
3458
3546
|
// TaskCreate / TaskUpdate mutate the accumulated task list; TaskList
|
|
3459
3547
|
// and TaskGet are read-only so we just suppress their tool_call /
|
|
@@ -3560,6 +3648,7 @@ export function streamEventToAcpNotifications(message, sessionId, toolUseCache,
|
|
|
3560
3648
|
parentToolUseId: message.parent_tool_use_id,
|
|
3561
3649
|
cwd: options?.cwd,
|
|
3562
3650
|
taskState: options?.taskState,
|
|
3651
|
+
emittedToolCalls: options?.emittedToolCalls,
|
|
3563
3652
|
messageId: options?.messageId,
|
|
3564
3653
|
});
|
|
3565
3654
|
case "content_block_delta":
|
|
@@ -3568,6 +3657,7 @@ export function streamEventToAcpNotifications(message, sessionId, toolUseCache,
|
|
|
3568
3657
|
parentToolUseId: message.parent_tool_use_id,
|
|
3569
3658
|
cwd: options?.cwd,
|
|
3570
3659
|
taskState: options?.taskState,
|
|
3660
|
+
emittedToolCalls: options?.emittedToolCalls,
|
|
3571
3661
|
messageId: options?.messageId,
|
|
3572
3662
|
});
|
|
3573
3663
|
// No content. `ping` is a Messages-API keep-alive event that the SDK's
|
|
@@ -3637,6 +3727,7 @@ export function runAcp() {
|
|
|
3637
3727
|
.onRequest(methods.agent.session.setMode, (ctx) => agent.setSessionMode(ctx.params))
|
|
3638
3728
|
.onRequest(methods.agent.session.setConfigOption, (ctx) => agent.setSessionConfigOption(ctx.params))
|
|
3639
3729
|
.onRequest(methods.agent.authenticate, (ctx) => agent.authenticate(ctx.params))
|
|
3730
|
+
.onRequest(methods.agent.logout, (ctx) => agent.logout(ctx.params))
|
|
3640
3731
|
.onRequest(methods.agent.session.prompt, (ctx) => runPromptWithCancellation(agent, ctx.params, ctx.signal))
|
|
3641
3732
|
.onNotification(methods.agent.session.cancel, (ctx) => agent.cancel(ctx.params))
|
|
3642
3733
|
.connect(stream);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elicitation.d.ts","sourceRoot":"","sources":["../src/elicitation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,wBAAwB,EACxB,yBAAyB,EAI1B,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAC5F,OAAO,KAAK,EACV,oBAAoB,EAErB,MAAM,6CAA6C,CAAC;AAErD;;;;;;;;;;;;;GAaG;AAEH,yDAAyD;AACzD,MAAM,MAAM,kBAAkB,GAAG;IAC/B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wBAAwB,GAAG,IAAI,CAyBjC;AAED;;;GAGG;AACH,wBAAgB,uCAAuC,CACrD,QAAQ,EAAE,yBAAyB,GAClC,iBAAiB,CAUnB;AAED;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,oBAAoB,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAExE;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,eAAe,EAAE,GAAG,IAAI,CAUhG;AA4CD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,+BAA+B,CAC7C,SAAS,EAAE,eAAe,EAAE,EAC5B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GAAG,SAAS,GAC7B,wBAAwB,CAwD1B;AAED,+EAA+E;AAC/E,MAAM,MAAM,sBAAsB,GAChC;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,QAAQ,CAAA;CAAE,CAAC;AAEvF;;;;;;;;;;GAUG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,yBAAyB,EACnC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,SAAS,EAAE,eAAe,EAAE,GAC3B,sBAAsB,CAkCxB"}
|
package/dist/index.js
CHANGED
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
import { resolveSettings } from "@anthropic-ai/claude-agent-sdk";
|
|
3
3
|
import { claudeCliPath, runAcp } from "./acp-agent.js";
|
|
4
4
|
import packageJson from "../package.json" with { type: "json" };
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
else if (process.argv.includes("--cli")) {
|
|
5
|
+
// `--cli` is checked first so that `--version`/`-v` (and any other flags) are
|
|
6
|
+
// forwarded to the wrapped native CLI rather than swallowed by our own version
|
|
7
|
+
// handler below. Our version flag only applies when not delegating.
|
|
8
|
+
if (process.argv.includes("--cli")) {
|
|
10
9
|
const { spawn } = await import("node:child_process");
|
|
11
10
|
const args = process.argv.slice(2).filter((arg) => arg !== "--cli");
|
|
12
11
|
const child = spawn(await claudeCliPath(), args, { stdio: "inherit" });
|
|
@@ -36,6 +35,10 @@ else if (process.argv.includes("--cli")) {
|
|
|
36
35
|
process.exit(1);
|
|
37
36
|
});
|
|
38
37
|
}
|
|
38
|
+
else if (process.argv.includes("--version") || process.argv.includes("-v")) {
|
|
39
|
+
console.log(packageJson.version);
|
|
40
|
+
process.exit(0);
|
|
41
|
+
}
|
|
39
42
|
else {
|
|
40
43
|
// Apply env vars from the managed-policy tier before any SDK call so the
|
|
41
44
|
// SDK subprocess inherits them. Going through resolveSettings (vs. a raw
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.53.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",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
66
|
"@agentclientprotocol/sdk": "1.0.0",
|
|
67
|
-
"@anthropic-ai/claude-agent-sdk": "0.3.
|
|
67
|
+
"@anthropic-ai/claude-agent-sdk": "0.3.195",
|
|
68
68
|
"zod": "^3.25.0 || ^4.0.0"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
@@ -74,10 +74,10 @@
|
|
|
74
74
|
"@types/node": "26.0.1",
|
|
75
75
|
"@typescript-eslint/eslint-plugin": "8.62.0",
|
|
76
76
|
"@typescript-eslint/parser": "8.62.0",
|
|
77
|
-
"eslint": "10.
|
|
77
|
+
"eslint": "10.6.0",
|
|
78
78
|
"eslint-config-prettier": "10.1.8",
|
|
79
79
|
"globals": "17.7.0",
|
|
80
|
-
"prettier": "3.
|
|
80
|
+
"prettier": "3.9.1",
|
|
81
81
|
"ts-node": "10.9.2",
|
|
82
82
|
"typescript": "6.0.3",
|
|
83
83
|
"vitest": "4.1.9"
|