@agentclientprotocol/claude-agent-acp 0.47.0 → 0.48.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 +40 -8
- package/dist/acp-agent.d.ts.map +1 -1
- package/dist/acp-agent.js +153 -17
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +16 -6
- package/package.json +5 -5
package/dist/acp-agent.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CanUseTool, ModelInfo, Options, PermissionMode, PermissionUpdate, Query, SDKMessageOrigin, SDKPartialAssistantMessage, SDKUserMessage } from "@anthropic-ai/claude-agent-sdk";
|
|
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";
|
|
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";
|
|
5
5
|
import { SettingsManager } from "./settings.js";
|
|
@@ -89,6 +89,14 @@ type Session = {
|
|
|
89
89
|
models: SessionModelState;
|
|
90
90
|
modelInfos: ModelInfo[];
|
|
91
91
|
configOptions: SessionConfigOption[];
|
|
92
|
+
/** Custom main-thread agent personas the user (or a plugin/project) has
|
|
93
|
+
* configured, discovered via `supportedAgents()` with Claude Code's built-in
|
|
94
|
+
* subagents filtered out. Empty when none are configured, in which case the
|
|
95
|
+
* "agent" config option is omitted entirely. */
|
|
96
|
+
agents: AgentInfo[];
|
|
97
|
+
/** The currently selected main-thread agent name, or "default" for the
|
|
98
|
+
* standard Claude Code agent (no `agent` flag applied). */
|
|
99
|
+
currentAgent: string;
|
|
92
100
|
abortController: AbortController;
|
|
93
101
|
/** Signal the consumer races `query.next()` against. Aborted by cancel()
|
|
94
102
|
* (after a grace period) to force the active turn to settle "cancelled" when
|
|
@@ -237,11 +245,27 @@ export declare function resolvePermissionMode(defaultMode?: unknown, logger?: Lo
|
|
|
237
245
|
* tool so "Always Allow" is never a blank check without disclosure.
|
|
238
246
|
*/
|
|
239
247
|
export declare function describeAlwaysAllow(suggestions: PermissionUpdate[] | undefined, toolName: string): string;
|
|
240
|
-
|
|
248
|
+
/**
|
|
249
|
+
* Client-facing surface the agent calls back into. This is the subset of ACP
|
|
250
|
+
* client methods the agent actually uses, expressed as a narrow interface so
|
|
251
|
+
* tests can supply lightweight mocks. In production it is backed by
|
|
252
|
+
* {@link ClientConnection} over the SDK's typed `AgentContext`.
|
|
253
|
+
*/
|
|
254
|
+
export interface AcpClient {
|
|
255
|
+
sessionUpdate(params: SessionNotification): Promise<void>;
|
|
256
|
+
requestPermission(params: RequestPermissionRequest): Promise<RequestPermissionResponse>;
|
|
257
|
+
readTextFile(params: ReadTextFileRequest): Promise<ReadTextFileResponse>;
|
|
258
|
+
writeTextFile(params: WriteTextFileRequest): Promise<WriteTextFileResponse>;
|
|
259
|
+
unstable_createElicitation(params: CreateElicitationRequest): Promise<CreateElicitationResponse>;
|
|
260
|
+
unstable_completeElicitation(params: CompleteElicitationNotification): Promise<void>;
|
|
261
|
+
/** Send a custom (extension) notification, e.g. `_claude/sdkMessage`. */
|
|
262
|
+
extNotification(method: string, params: Record<string, unknown>): Promise<void>;
|
|
263
|
+
}
|
|
264
|
+
export declare class ClaudeAcpAgent {
|
|
241
265
|
sessions: {
|
|
242
266
|
[key: string]: Session;
|
|
243
267
|
};
|
|
244
|
-
client:
|
|
268
|
+
client: AcpClient;
|
|
245
269
|
clientCapabilities?: ClientCapabilities;
|
|
246
270
|
logger: Logger;
|
|
247
271
|
gatewayAuthRequest?: GatewayAuthRequest;
|
|
@@ -249,7 +273,7 @@ export declare class ClaudeAcpAgent implements Agent {
|
|
|
249
273
|
* return "cancelled". See {@link DEFAULT_FORCE_CANCEL_GRACE_MS}. Mutable so
|
|
250
274
|
* tests can shrink it. */
|
|
251
275
|
forceCancelGraceMs: number;
|
|
252
|
-
constructor(client:
|
|
276
|
+
constructor(client: AcpClient, logger?: Logger);
|
|
253
277
|
initialize(request: InitializeRequest): Promise<InitializeResponse>;
|
|
254
278
|
newSession(params: NewSessionRequest): Promise<NewSessionResponse>;
|
|
255
279
|
unstable_forkSession(params: ForkSessionRequest): Promise<ForkSessionResponse>;
|
|
@@ -327,6 +351,14 @@ export declare class ClaudeAcpAgent implements Agent {
|
|
|
327
351
|
private validateCwd;
|
|
328
352
|
private createSession;
|
|
329
353
|
}
|
|
354
|
+
export declare const BUILTIN_AGENT_NAMES: Set<string>;
|
|
355
|
+
export declare const DEFAULT_AGENT_ID = "default";
|
|
356
|
+
/** Discover user/plugin/project-configured main-thread agents, excluding the
|
|
357
|
+
* built-in subagents and the reserved "default" sentinel. Returns an empty
|
|
358
|
+
* list if discovery fails so a flaky control request never blocks session
|
|
359
|
+
* creation. */
|
|
360
|
+
export declare function discoverCustomAgents(q: Query): Promise<AgentInfo[]>;
|
|
361
|
+
export declare function buildConfigOptions(modes: SessionModeState, models: SessionModelState, modelInfos: ModelInfo[], currentEffortLevel?: string, agents?: AgentInfo[], currentAgent?: string): SessionConfigOption[];
|
|
330
362
|
export declare function promptToClaude(prompt: PromptRequest): SDKUserMessage;
|
|
331
363
|
/**
|
|
332
364
|
* Resolves the ACP `messageId` for a Claude SDK message (live) or a persisted
|
|
@@ -348,7 +380,7 @@ export declare function messageIdForGrouping(message: {
|
|
|
348
380
|
* Convert an SDKAssistantMessage (Claude) to a SessionNotification (ACP).
|
|
349
381
|
* Only handles text, image, and thinking chunks for now.
|
|
350
382
|
*/
|
|
351
|
-
export declare function toAcpNotifications(content: string | ContentBlockParam[] | BetaContentBlock[] | BetaRawContentBlockDelta[], role: "assistant" | "user", sessionId: string, toolUseCache: ToolUseCache, client:
|
|
383
|
+
export declare function toAcpNotifications(content: string | ContentBlockParam[] | BetaContentBlock[] | BetaRawContentBlockDelta[], role: "assistant" | "user", sessionId: string, toolUseCache: ToolUseCache, client: AcpClient, logger: Logger, options?: {
|
|
352
384
|
registerHooks?: boolean;
|
|
353
385
|
clientCapabilities?: ClientCapabilities;
|
|
354
386
|
parentToolUseId?: string | null;
|
|
@@ -356,14 +388,14 @@ export declare function toAcpNotifications(content: string | ContentBlockParam[]
|
|
|
356
388
|
taskState?: TaskState;
|
|
357
389
|
messageId?: string;
|
|
358
390
|
}): SessionNotification[];
|
|
359
|
-
export declare function streamEventToAcpNotifications(message: SDKPartialAssistantMessage, sessionId: string, toolUseCache: ToolUseCache, client:
|
|
391
|
+
export declare function streamEventToAcpNotifications(message: SDKPartialAssistantMessage, sessionId: string, toolUseCache: ToolUseCache, client: AcpClient, logger: Logger, options?: {
|
|
360
392
|
clientCapabilities?: ClientCapabilities;
|
|
361
393
|
cwd?: string;
|
|
362
394
|
taskState?: TaskState;
|
|
363
395
|
messageId?: string;
|
|
364
396
|
}): SessionNotification[];
|
|
365
397
|
export declare function runAcp(): {
|
|
366
|
-
connection:
|
|
398
|
+
connection: import("@agentclientprotocol/sdk").AgentConnection;
|
|
367
399
|
agent: ClaudeAcpAgent;
|
|
368
400
|
};
|
|
369
401
|
export {};
|
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,
|
|
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,EAGnB,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,EAKV,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,CAAC;AAelG,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EASL,SAAS,EAKV,MAAM,YAAY,CAAC;AACpB,OAAO,EAAwC,QAAQ,EAAe,MAAM,YAA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O,EAAE,MAAM,GAAG,iBAAiB,EAAE,GAAG,gBAAgB,EAAE,GAAG,wBAAwB,EAAE,EACvF,IAAI,EAAE,WAAW,GAAG,MAAM,EAC1B,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,SAAS,EACjB,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;IACb,SAAS,CAAC,EAAE,SAAS,CAAC;IAMtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GACA,mBAAmB,EAAE,CAiTvB;AAED,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,0BAA0B,EACnC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,SAAS,EACjB,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,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GACA,mBAAmB,EAAE,CAkDvB;AAED,wBAAgB,MAAM;;;EAkCrB"}
|
package/dist/acp-agent.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { agent as acpAgent, methods, ndJsonStream, RequestError, } from "@agentclientprotocol/sdk";
|
|
2
2
|
import { deleteSession, getSessionMessages, listSessions, query, } from "@anthropic-ai/claude-agent-sdk";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
import * as fs from "node:fs/promises";
|
|
@@ -246,7 +246,38 @@ export function describeAlwaysAllow(suggestions, toolName) {
|
|
|
246
246
|
}
|
|
247
247
|
return `Always Allow ${parts.join(" and ")}`;
|
|
248
248
|
}
|
|
249
|
-
|
|
249
|
+
/**
|
|
250
|
+
* Bridges {@link AcpClient} to the connection-scoped {@link AgentContext}
|
|
251
|
+
* exposed by `AgentApp.connect(...)` as `connection.client`. The peer handle is
|
|
252
|
+
* valid for the entire connection lifetime, so it is captured once at
|
|
253
|
+
* construction.
|
|
254
|
+
*/
|
|
255
|
+
class ClientConnection {
|
|
256
|
+
constructor(ctx) {
|
|
257
|
+
this.ctx = ctx;
|
|
258
|
+
}
|
|
259
|
+
sessionUpdate(params) {
|
|
260
|
+
return this.ctx.notify(methods.client.session.update, params);
|
|
261
|
+
}
|
|
262
|
+
requestPermission(params) {
|
|
263
|
+
return this.ctx.request(methods.client.session.requestPermission, params);
|
|
264
|
+
}
|
|
265
|
+
readTextFile(params) {
|
|
266
|
+
return this.ctx.request(methods.client.fs.readTextFile, params);
|
|
267
|
+
}
|
|
268
|
+
writeTextFile(params) {
|
|
269
|
+
return this.ctx.request(methods.client.fs.writeTextFile, params);
|
|
270
|
+
}
|
|
271
|
+
unstable_createElicitation(params) {
|
|
272
|
+
return this.ctx.request(methods.client.elicitation.create, params);
|
|
273
|
+
}
|
|
274
|
+
unstable_completeElicitation(params) {
|
|
275
|
+
return this.ctx.notify(methods.client.elicitation.complete, params);
|
|
276
|
+
}
|
|
277
|
+
extNotification(method, params) {
|
|
278
|
+
return this.ctx.notify(method, params);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
250
281
|
export class ClaudeAcpAgent {
|
|
251
282
|
constructor(client, logger) {
|
|
252
283
|
/** Grace period before a `session/cancel` forces a wedged prompt loop to
|
|
@@ -562,7 +593,12 @@ export class ClaudeAcpAgent {
|
|
|
562
593
|
lastAssistantError = undefined;
|
|
563
594
|
lastRefusalExplanation = null;
|
|
564
595
|
compactionInProgress = false;
|
|
565
|
-
currentStreamMessageId
|
|
596
|
+
// Do NOT reset currentStreamMessageId here. `message_start` sets it per
|
|
597
|
+
// message; clearing it on turn activation drops the id for any block that
|
|
598
|
+
// streams after a mid-message activation (the replayed user echo with
|
|
599
|
+
// --replay-user-messages), so those ids never enter streamedTextIds and the
|
|
600
|
+
// consolidated assistant message re-emits already-streamed text as a
|
|
601
|
+
// duplicate. #785 stopped resetting streamedTextIds here but left this line.
|
|
566
602
|
stopReason = "end_turn";
|
|
567
603
|
session.accumulatedUsage = {
|
|
568
604
|
inputTokens: 0,
|
|
@@ -2029,7 +2065,7 @@ export class ClaudeAcpAgent {
|
|
|
2029
2065
|
// Rebuild config options since effort levels depend on the selected model
|
|
2030
2066
|
const effortOpt = session.configOptions.find((o) => o.id === "effort");
|
|
2031
2067
|
const currentEffort = typeof effortOpt?.currentValue === "string" ? effortOpt.currentValue : undefined;
|
|
2032
|
-
session.configOptions = buildConfigOptions(session.modes, session.models, session.modelInfos, currentEffort);
|
|
2068
|
+
session.configOptions = buildConfigOptions(session.modes, session.models, session.modelInfos, currentEffort, session.agents, session.currentAgent);
|
|
2033
2069
|
// Sync effort with the SDK if it changed after the model switch
|
|
2034
2070
|
const newEffortOpt = session.configOptions.find((o) => o.id === "effort");
|
|
2035
2071
|
const newEffort = typeof newEffortOpt?.currentValue === "string" ? newEffortOpt.currentValue : undefined;
|
|
@@ -2054,6 +2090,18 @@ export class ClaudeAcpAgent {
|
|
|
2054
2090
|
});
|
|
2055
2091
|
}
|
|
2056
2092
|
}
|
|
2093
|
+
else if (configId === "agent") {
|
|
2094
|
+
// Live agent switch — no subprocess restart needed. Apply the SDK flag
|
|
2095
|
+
// first so a rejected control request leaves both `currentAgent` and the
|
|
2096
|
+
// config option untouched (no UI/SDK desync). Passing `null` clears the
|
|
2097
|
+
// flag layer back to the standard Claude Code agent; the change takes
|
|
2098
|
+
// effect on the next turn (SDK >= 0.3.161).
|
|
2099
|
+
await session.query.applyFlagSettings({
|
|
2100
|
+
agent: value === DEFAULT_AGENT_ID ? null : value,
|
|
2101
|
+
});
|
|
2102
|
+
session.currentAgent = value;
|
|
2103
|
+
session.configOptions = session.configOptions.map((o) => o.id === configId && typeof o.currentValue === "string" ? { ...o, currentValue: value } : o);
|
|
2104
|
+
}
|
|
2057
2105
|
else {
|
|
2058
2106
|
session.configOptions = session.configOptions.map((o) => o.id === configId && typeof o.currentValue === "string" ? { ...o, currentValue: value } : o);
|
|
2059
2107
|
if (configId === "effort") {
|
|
@@ -2405,7 +2453,17 @@ export class ClaudeAcpAgent {
|
|
|
2405
2453
|
currentModeId: effectiveMode,
|
|
2406
2454
|
availableModes,
|
|
2407
2455
|
};
|
|
2408
|
-
const
|
|
2456
|
+
const agents = await discoverCustomAgents(q);
|
|
2457
|
+
// Only adopt the requested agent as the selected value if it's one we
|
|
2458
|
+
// actually surface in the picker. A built-in (filtered out above) or
|
|
2459
|
+
// otherwise-unknown name would leave the config option's `currentValue`
|
|
2460
|
+
// pointing at an entry not in its own `options` list, which clients render
|
|
2461
|
+
// as a blank/invalid selection.
|
|
2462
|
+
const requestedAgent = userProvidedOptions?.agent;
|
|
2463
|
+
const currentAgent = requestedAgent && agents.some((a) => a.name === requestedAgent)
|
|
2464
|
+
? requestedAgent
|
|
2465
|
+
: DEFAULT_AGENT_ID;
|
|
2466
|
+
const configOptions = buildConfigOptions(modes, models, allowedModels, settingsManager.getSettings().effortLevel, agents, currentAgent);
|
|
2409
2467
|
// Apply the initial effort level to the SDK so it matches the UI default
|
|
2410
2468
|
const initialEffort = configOptions.find((o) => o.id === "effort");
|
|
2411
2469
|
if (initialEffort &&
|
|
@@ -2432,6 +2490,8 @@ export class ClaudeAcpAgent {
|
|
|
2432
2490
|
models,
|
|
2433
2491
|
modelInfos: allowedModels,
|
|
2434
2492
|
configOptions,
|
|
2493
|
+
agents,
|
|
2494
|
+
currentAgent,
|
|
2435
2495
|
abortController,
|
|
2436
2496
|
emitRawSDKMessages: sessionMeta?.claudeCode?.emitRawSDKMessages ?? false,
|
|
2437
2497
|
contextWindowSize: inferContextWindowFromModel(models.currentModelId) ?? DEFAULT_CONTEXT_WINDOW,
|
|
@@ -2578,7 +2638,39 @@ function buildAvailableModes(modelInfo) {
|
|
|
2578
2638
|
function toSdkEffortLevel(value) {
|
|
2579
2639
|
return value === undefined || value === "default" ? null : value;
|
|
2580
2640
|
}
|
|
2581
|
-
|
|
2641
|
+
// `supportedAgents()` always returns Claude Code's built-in subagents — the
|
|
2642
|
+
// ones used for Task-tool delegation (Explore, Plan, etc.) — even when the user
|
|
2643
|
+
// has configured none of their own. Those aren't meaningful *main-thread*
|
|
2644
|
+
// personas, so we filter them out and only surface the Agent picker when the
|
|
2645
|
+
// user (or a plugin/project) has configured custom agents. Update this set if
|
|
2646
|
+
// the SDK's built-in roster changes.
|
|
2647
|
+
export const BUILTIN_AGENT_NAMES = new Set([
|
|
2648
|
+
"claude",
|
|
2649
|
+
"general-purpose",
|
|
2650
|
+
"Explore",
|
|
2651
|
+
"Plan",
|
|
2652
|
+
"statusline-setup",
|
|
2653
|
+
]);
|
|
2654
|
+
// Value of the synthetic "Default" entry in the agent picker, which maps to the
|
|
2655
|
+
// standard Claude Code agent (`applyFlagSettings({ agent: null })`). It is a
|
|
2656
|
+
// reserved sentinel: a custom agent named exactly this would collide with it
|
|
2657
|
+
// (two options sharing the value, selection silently routing to `null`), so we
|
|
2658
|
+
// exclude that name from discovery.
|
|
2659
|
+
export const DEFAULT_AGENT_ID = "default";
|
|
2660
|
+
/** Discover user/plugin/project-configured main-thread agents, excluding the
|
|
2661
|
+
* built-in subagents and the reserved "default" sentinel. Returns an empty
|
|
2662
|
+
* list if discovery fails so a flaky control request never blocks session
|
|
2663
|
+
* creation. */
|
|
2664
|
+
export async function discoverCustomAgents(q) {
|
|
2665
|
+
try {
|
|
2666
|
+
const agents = await q.supportedAgents();
|
|
2667
|
+
return agents.filter((a) => !BUILTIN_AGENT_NAMES.has(a.name) && a.name !== DEFAULT_AGENT_ID);
|
|
2668
|
+
}
|
|
2669
|
+
catch {
|
|
2670
|
+
return [];
|
|
2671
|
+
}
|
|
2672
|
+
}
|
|
2673
|
+
export function buildConfigOptions(modes, models, modelInfos, currentEffortLevel, agents = [], currentAgent = DEFAULT_AGENT_ID) {
|
|
2582
2674
|
const options = [
|
|
2583
2675
|
{
|
|
2584
2676
|
id: "mode",
|
|
@@ -2635,6 +2727,27 @@ function buildConfigOptions(modes, models, modelInfos, currentEffortLevel) {
|
|
|
2635
2727
|
options: effortOptions,
|
|
2636
2728
|
});
|
|
2637
2729
|
}
|
|
2730
|
+
// Only surface the Agent picker when there's a real choice — i.e. the user
|
|
2731
|
+
// has configured at least one custom agent (built-ins are filtered out in
|
|
2732
|
+
// discoverCustomAgents). With none configured, "Default" would be the only
|
|
2733
|
+
// entry, so we omit the option entirely.
|
|
2734
|
+
if (agents.length > 0) {
|
|
2735
|
+
options.push({
|
|
2736
|
+
id: "agent",
|
|
2737
|
+
name: "Agent",
|
|
2738
|
+
description: "Main-thread agent persona",
|
|
2739
|
+
type: "select",
|
|
2740
|
+
currentValue: currentAgent,
|
|
2741
|
+
options: [
|
|
2742
|
+
{ value: DEFAULT_AGENT_ID, name: "Default", description: "Standard Claude Code agent" },
|
|
2743
|
+
...agents.map((a) => ({
|
|
2744
|
+
value: a.name,
|
|
2745
|
+
name: a.name,
|
|
2746
|
+
description: a.description || undefined,
|
|
2747
|
+
})),
|
|
2748
|
+
],
|
|
2749
|
+
});
|
|
2750
|
+
}
|
|
2638
2751
|
return options;
|
|
2639
2752
|
}
|
|
2640
2753
|
// Claude Code CLI persists display strings like "opus[1m]" in settings,
|
|
@@ -3062,13 +3175,17 @@ export function toAcpNotifications(content, role, sessionId, toolUseCache, clien
|
|
|
3062
3175
|
break;
|
|
3063
3176
|
case "thinking":
|
|
3064
3177
|
case "thinking_delta":
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3178
|
+
// Recent models default `thinking.display` to "omitted", which streams
|
|
3179
|
+
// signature-only thinking blocks whose text is empty.
|
|
3180
|
+
if (chunk.thinking.length > 0) {
|
|
3181
|
+
update = {
|
|
3182
|
+
sessionUpdate: "agent_thought_chunk",
|
|
3183
|
+
content: {
|
|
3184
|
+
type: "text",
|
|
3185
|
+
text: chunk.thinking,
|
|
3186
|
+
},
|
|
3187
|
+
};
|
|
3188
|
+
}
|
|
3072
3189
|
break;
|
|
3073
3190
|
case "tool_use":
|
|
3074
3191
|
case "server_tool_use":
|
|
@@ -3329,11 +3446,30 @@ export function runAcp() {
|
|
|
3329
3446
|
const input = nodeToWebWritable(process.stdout);
|
|
3330
3447
|
const output = nodeToWebReadable(process.stdin);
|
|
3331
3448
|
const stream = ndJsonStream(input, output);
|
|
3449
|
+
// `connect(...)` returns a connection-scoped peer handle (`connection.client`)
|
|
3450
|
+
// that stays valid for the whole connection, so the agent captures it once.
|
|
3451
|
+
// Handlers close over `agent`, which is assigned synchronously right after
|
|
3452
|
+
// `connect()` returns — before the connection processes any inbound message.
|
|
3453
|
+
// It cannot be `const`: its value depends on `connection.client`, which does
|
|
3454
|
+
// not exist until `connect()` has been called.
|
|
3455
|
+
// eslint-disable-next-line prefer-const
|
|
3332
3456
|
let agent;
|
|
3333
|
-
const connection =
|
|
3334
|
-
agent
|
|
3335
|
-
|
|
3336
|
-
|
|
3457
|
+
const connection = acpAgent({ name: "claude-code-acp" })
|
|
3458
|
+
.onRequest(methods.agent.initialize, (ctx) => agent.initialize(ctx.params))
|
|
3459
|
+
.onRequest(methods.agent.session.new, (ctx) => agent.newSession(ctx.params))
|
|
3460
|
+
.onRequest(methods.agent.session.load, (ctx) => agent.loadSession(ctx.params))
|
|
3461
|
+
.onRequest(methods.agent.session.fork, (ctx) => agent.unstable_forkSession(ctx.params))
|
|
3462
|
+
.onRequest(methods.agent.session.list, (ctx) => agent.listSessions(ctx.params))
|
|
3463
|
+
.onRequest(methods.agent.session.delete, (ctx) => agent.deleteSession(ctx.params))
|
|
3464
|
+
.onRequest(methods.agent.session.resume, (ctx) => agent.resumeSession(ctx.params))
|
|
3465
|
+
.onRequest(methods.agent.session.close, (ctx) => agent.closeSession(ctx.params))
|
|
3466
|
+
.onRequest(methods.agent.session.setMode, (ctx) => agent.setSessionMode(ctx.params))
|
|
3467
|
+
.onRequest(methods.agent.session.setConfigOption, (ctx) => agent.setSessionConfigOption(ctx.params))
|
|
3468
|
+
.onRequest(methods.agent.authenticate, (ctx) => agent.authenticate(ctx.params))
|
|
3469
|
+
.onRequest(methods.agent.session.prompt, (ctx) => agent.prompt(ctx.params))
|
|
3470
|
+
.onNotification(methods.agent.session.cancel, (ctx) => agent.cancel(ctx.params))
|
|
3471
|
+
.connect(stream);
|
|
3472
|
+
agent = new ClaudeAcpAgent(new ClientConnection(connection.client));
|
|
3337
3473
|
return { connection, agent };
|
|
3338
3474
|
}
|
|
3339
3475
|
function commonPrefixLength(a, b) {
|
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;AAC9D,OAAO,EASL,eAAe,EACf,gBAAgB,EAChB,eAAe,EAIhB,MAAM,6CAA6C,CAAC;AACrD,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,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gB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQnD;AAeD;;;;;;GAMG;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;AAEJ;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,GACxB,SAAS;IAAE,SAAS,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,KAAG,YAsBpE,CAAC"}
|
package/dist/tools.js
CHANGED
|
@@ -366,7 +366,9 @@ export function toolUpdateFromToolResult(toolResult, toolUse, supportsTerminalOu
|
|
|
366
366
|
// Extract output and exit code from either format:
|
|
367
367
|
// 1. BetaBashCodeExecutionResultBlock: { type: "bash_code_execution_result", stdout, stderr, return_code }
|
|
368
368
|
// 2. Plain string content from a regular tool_result
|
|
369
|
-
// 3. Array content (e.g. [{ type: "text", text: "..." }]
|
|
369
|
+
// 3. Array content (e.g. [{ type: "text", text: "..." }] for stdout,
|
|
370
|
+
// or [{ type: "image", source: {...} }] when the local Bash tool
|
|
371
|
+
// produces an image, e.g. piping a base64 data URI)
|
|
370
372
|
let output = "";
|
|
371
373
|
let exitCode = isError ? 1 : 0;
|
|
372
374
|
if (result &&
|
|
@@ -380,11 +382,19 @@ export function toolUpdateFromToolResult(toolResult, toolUse, supportsTerminalOu
|
|
|
380
382
|
else if (typeof result === "string") {
|
|
381
383
|
output = result;
|
|
382
384
|
}
|
|
383
|
-
else if (Array.isArray(result) &&
|
|
384
|
-
result.
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
385
|
+
else if (Array.isArray(result) && result.length > 0) {
|
|
386
|
+
const textOnly = result.every((c) => c && typeof c === "object" && typeof c.text === "string");
|
|
387
|
+
if (textOnly) {
|
|
388
|
+
output = result.map((c) => c.text).join("\n");
|
|
389
|
+
}
|
|
390
|
+
else {
|
|
391
|
+
// Image (or mixed non-text) content. Binary payloads can't be
|
|
392
|
+
// streamed through the terminal-output _meta channel, so bypass
|
|
393
|
+
// it and surface the blocks as ACP content. This handles the
|
|
394
|
+
// local Bash tool's image output, which previously failed the
|
|
395
|
+
// text-only guard and was silently dropped.
|
|
396
|
+
return toAcpContentUpdate(result, isError);
|
|
397
|
+
}
|
|
388
398
|
}
|
|
389
399
|
if (supportsTerminalOutput) {
|
|
390
400
|
return {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.48.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,14 +60,14 @@
|
|
|
60
60
|
"author": "Zed Industries",
|
|
61
61
|
"license": "Apache-2.0",
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@agentclientprotocol/sdk": "0.
|
|
64
|
-
"@anthropic-ai/claude-agent-sdk": "0.3.
|
|
63
|
+
"@agentclientprotocol/sdk": "0.28.1",
|
|
64
|
+
"@anthropic-ai/claude-agent-sdk": "0.3.183",
|
|
65
65
|
"zod": "^3.25.0 || ^4.0.0"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@anthropic-ai/sdk": "0.
|
|
68
|
+
"@anthropic-ai/sdk": "0.105.0",
|
|
69
69
|
"@eslint/js": "10.0.1",
|
|
70
|
-
"@types/node": "
|
|
70
|
+
"@types/node": "26.0.0",
|
|
71
71
|
"@typescript-eslint/eslint-plugin": "8.61.1",
|
|
72
72
|
"@typescript-eslint/parser": "8.61.1",
|
|
73
73
|
"eslint": "10.5.0",
|