@zed-industries/claude-code-acp
Advanced tools
@@ -1,2 +0,2 @@ | ||
| import { Agent, AgentSideConnection, AuthenticateRequest, CancelNotification, ClientCapabilities, ForkSessionRequest, ForkSessionResponse, InitializeRequest, InitializeResponse, ListSessionsRequest, ListSessionsResponse, NewSessionRequest, NewSessionResponse, PromptRequest, PromptResponse, ReadTextFileRequest, ReadTextFileResponse, ResumeSessionRequest, ResumeSessionResponse, SessionNotification, SetSessionModelRequest, SetSessionModelResponse, SetSessionModeRequest, SetSessionModeResponse, TerminalHandle, TerminalOutputResponse, WriteTextFileRequest, WriteTextFileResponse } from "@agentclientprotocol/sdk"; | ||
| import { Agent, AgentSideConnection, AuthenticateRequest, CancelNotification, ClientCapabilities, ForkSessionRequest, ForkSessionResponse, InitializeRequest, InitializeResponse, LoadSessionRequest, LoadSessionResponse, ListSessionsRequest, ListSessionsResponse, NewSessionRequest, NewSessionResponse, PromptRequest, PromptResponse, ReadTextFileRequest, ReadTextFileResponse, ResumeSessionRequest, ResumeSessionResponse, SessionNotification, SetSessionModelRequest, SetSessionModelResponse, SetSessionModeRequest, SetSessionModeResponse, TerminalHandle, TerminalOutputResponse, WriteTextFileRequest, WriteTextFileResponse } from "@agentclientprotocol/sdk"; | ||
| import { SettingsManager } from "./settings.js"; | ||
@@ -84,2 +84,3 @@ import { CanUseTool, Options, PermissionMode, Query, SDKPartialAssistantMessage, SDKUserMessage } from "@anthropic-ai/claude-agent-sdk"; | ||
| unstable_resumeSession(params: ResumeSessionRequest): Promise<ResumeSessionResponse>; | ||
| loadSession(params: LoadSessionRequest): Promise<LoadSessionResponse>; | ||
| /** | ||
@@ -96,2 +97,3 @@ * List Claude Code sessions by parsing JSONL files | ||
| setSessionMode(params: SetSessionModeRequest): Promise<SetSessionModeResponse>; | ||
| private replaySessionHistory; | ||
| readTextFile(params: ReadTextFileRequest): Promise<ReadTextFileResponse>; | ||
@@ -107,3 +109,5 @@ writeTextFile(params: WriteTextFileRequest): Promise<WriteTextFileResponse>; | ||
| */ | ||
| export declare function toAcpNotifications(content: string | ContentBlockParam[] | BetaContentBlock[] | BetaRawContentBlockDelta[], role: "assistant" | "user", sessionId: string, toolUseCache: ToolUseCache, client: AgentSideConnection, logger: Logger): SessionNotification[]; | ||
| export declare function toAcpNotifications(content: string | ContentBlockParam[] | BetaContentBlock[] | BetaRawContentBlockDelta[], role: "assistant" | "user", sessionId: string, toolUseCache: ToolUseCache, client: AgentSideConnection, logger: Logger, options?: { | ||
| registerHooks?: boolean; | ||
| }): SessionNotification[]; | ||
| export declare function streamEventToAcpNotifications(message: SDKPartialAssistantMessage, sessionId: string, toolUseCache: ToolUseCache, client: AgentSideConnection, logger: Logger): SessionNotification[]; | ||
@@ -110,0 +114,0 @@ export declare function runAcp(): void; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"acp-agent.d.ts","sourceRoot":"","sources":["../src/acp-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,mBAAmB,EACnB,mBAAmB,EAEnB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EAEpB,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EAEpB,oBAAoB,EACpB,qBAAqB,EAGrB,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,EACtB,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EACL,UAAU,EAEV,OAAO,EACP,cAAc,EACd,KAAK,EAEL,0BAA0B,EAC1B,cAAc,EACf,MAAM,gCAAgC,CAAC;AAIxC,OAAO,EAAwC,QAAQ,EAAe,MAAM,YAAY,CAAC;AAYzF,OAAO,EAAE,iBAAiB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AM,SAMrB"} |
+112
-39
@@ -6,4 +6,5 @@ import { AgentSideConnection, ndJsonStream, RequestError, } from "@agentclientprotocol/sdk"; | ||
| import * as path from "node:path"; | ||
| import * as readline from "node:readline"; | ||
| import * as os from "node:os"; | ||
| import { nodeToWebReadable, nodeToWebWritable, Pushable, unreachable } from "./utils.js"; | ||
| import { encodeProjectPath, nodeToWebReadable, nodeToWebWritable, Pushable, unreachable, } from "./utils.js"; | ||
| import { createMcpServer } from "./mcp-server.js"; | ||
@@ -34,2 +35,5 @@ import { EDIT_TOOL_NAMES, acpToolNames } from "./tools.js"; | ||
| } | ||
| function sessionFilePath(cwd, sessionId) { | ||
| return path.join(CLAUDE_CONFIG_DIR, "projects", encodeProjectPath(cwd), `${sessionId}.jsonl`); | ||
| } | ||
| const MAX_TITLE_LENGTH = 128; | ||
@@ -89,2 +93,3 @@ function sanitizeTitle(text) { | ||
| }, | ||
| loadSession: true, | ||
| sessionCapabilities: { | ||
@@ -134,2 +139,22 @@ fork: {}, | ||
| } | ||
| async loadSession(params) { | ||
| try { | ||
| await fs.promises.access(sessionFilePath(params.cwd, params.sessionId)); | ||
| } | ||
| catch { | ||
| throw new Error("Session not found"); | ||
| } | ||
| const response = await this.createSession({ | ||
| cwd: params.cwd, | ||
| mcpServers: params.mcpServers ?? [], | ||
| _meta: params._meta, | ||
| }, { | ||
| resume: params.sessionId, | ||
| }); | ||
| await this.replaySessionHistory(params.sessionId, params.cwd); | ||
| return { | ||
| modes: response.modes, | ||
| models: response.models, | ||
| }; | ||
| } | ||
| /** | ||
@@ -433,2 +458,50 @@ * List Claude Code sessions by parsing JSONL files | ||
| } | ||
| async replaySessionHistory(sessionId, cwd) { | ||
| const filePath = sessionFilePath(cwd, sessionId); | ||
| const toolUseCache = {}; | ||
| const stream = fs.createReadStream(filePath, { encoding: "utf-8" }); | ||
| const reader = readline.createInterface({ input: stream, crlfDelay: Infinity }); | ||
| try { | ||
| for await (const line of reader) { | ||
| const trimmed = line.trim(); | ||
| if (!trimmed) { | ||
| continue; | ||
| } | ||
| let entry; | ||
| try { | ||
| entry = JSON.parse(trimmed); | ||
| } | ||
| catch { | ||
| continue; | ||
| } | ||
| if (entry.type !== "user" && entry.type !== "assistant") { | ||
| continue; | ||
| } | ||
| if (entry.isSidechain) { | ||
| continue; | ||
| } | ||
| if (entry.sessionId && entry.sessionId !== sessionId) { | ||
| continue; | ||
| } | ||
| const message = entry.message; | ||
| if (!message) { | ||
| continue; | ||
| } | ||
| const role = message.role === "assistant" ? "assistant" : message.role === "user" ? "user" : null; | ||
| if (!role) { | ||
| continue; | ||
| } | ||
| const content = message.content; | ||
| if (typeof content !== "string" && !Array.isArray(content)) { | ||
| continue; | ||
| } | ||
| for (const notification of toAcpNotifications(content, role, sessionId, toolUseCache, this.client, this.logger, { registerHooks: false })) { | ||
| await this.client.sessionUpdate(notification); | ||
| } | ||
| } | ||
| } | ||
| finally { | ||
| reader.close(); | ||
| } | ||
| } | ||
| async readTextFile(params) { | ||
@@ -626,7 +699,2 @@ const response = await this.client.readTextFile(params); | ||
| const userProvidedOptions = params._meta?.claudeCode?.options; | ||
| const extraArgs = { ...userProvidedOptions?.extraArgs }; | ||
| if (creationOpts?.resume === undefined || creationOpts?.forkSession) { | ||
| // Set our own session id if not resuming an existing session. | ||
| extraArgs["session-id"] = sessionId; | ||
| } | ||
| // Configure thinking tokens from environment variable | ||
@@ -646,3 +714,2 @@ const maxThinkingTokens = process.env.MAX_THINKING_TOKENS | ||
| mcpServers: { ...(userProvidedOptions?.mcpServers || {}), ...mcpServers }, | ||
| extraArgs, | ||
| // If we want bypassPermissions to be an option, we have to allow it here. | ||
@@ -693,2 +760,6 @@ // But it doesn't work in root mode, so we only activate it if it will work. | ||
| }; | ||
| if (creationOpts?.resume === undefined || creationOpts?.forkSession) { | ||
| // Set our own session id if not resuming an existing session. | ||
| options.sessionId = sessionId; | ||
| } | ||
| const allowedTools = []; | ||
@@ -738,4 +809,4 @@ // Disable this for now, not a great way to expose this over ACP at the moment (in progress work so we can revisit) | ||
| }; | ||
| const availableCommands = await getAvailableSlashCommands(q); | ||
| const models = await getAvailableModels(q, settingsManager); | ||
| const initializationResult = await q.initializationResult(); | ||
| const models = await getAvailableModels(q, initializationResult.models, settingsManager); | ||
| // Needs to happen after we return the session | ||
@@ -747,3 +818,3 @@ setTimeout(() => { | ||
| sessionUpdate: "available_commands_update", | ||
| availableCommands, | ||
| availableCommands: getAvailableSlashCommands(initializationResult.commands), | ||
| }, | ||
@@ -792,4 +863,3 @@ }); | ||
| } | ||
| async function getAvailableModels(query, settingsManager) { | ||
| const models = await query.supportedModels(); | ||
| async function getAvailableModels(query, models, settingsManager) { | ||
| const settings = settingsManager.getSettings(); | ||
@@ -817,3 +887,3 @@ let currentModel = models[0]; | ||
| } | ||
| async function getAvailableSlashCommands(query) { | ||
| function getAvailableSlashCommands(commands) { | ||
| const UNSUPPORTED_COMMANDS = [ | ||
@@ -828,3 +898,2 @@ "cost", | ||
| ]; | ||
| const commands = await query.supportedCommands(); | ||
| return commands | ||
@@ -949,3 +1018,4 @@ .map((command) => { | ||
| */ | ||
| export function toAcpNotifications(content, role, sessionId, toolUseCache, client, logger) { | ||
| export function toAcpNotifications(content, role, sessionId, toolUseCache, client, logger, options) { | ||
| const registerHooks = options?.registerHooks !== false; | ||
| if (typeof content === "string") { | ||
@@ -1015,27 +1085,28 @@ return [ | ||
| else { | ||
| // Register hook callback to receive the structured output from the hook | ||
| registerHookCallback(chunk.id, { | ||
| onPostToolUseHook: async (toolUseId, toolInput, toolResponse) => { | ||
| const toolUse = toolUseCache[toolUseId]; | ||
| if (toolUse) { | ||
| const update = { | ||
| _meta: { | ||
| claudeCode: { | ||
| toolResponse, | ||
| toolName: toolUse.name, | ||
| if (registerHooks) { | ||
| registerHookCallback(chunk.id, { | ||
| onPostToolUseHook: async (toolUseId, toolInput, toolResponse) => { | ||
| const toolUse = toolUseCache[toolUseId]; | ||
| if (toolUse) { | ||
| const update = { | ||
| _meta: { | ||
| claudeCode: { | ||
| toolResponse, | ||
| toolName: toolUse.name, | ||
| }, | ||
| }, | ||
| }, | ||
| toolCallId: toolUseId, | ||
| sessionUpdate: "tool_call_update", | ||
| }; | ||
| await client.sessionUpdate({ | ||
| sessionId, | ||
| update, | ||
| }); | ||
| } | ||
| else { | ||
| logger.error(`[claude-code-acp] Got a tool response for tool use that wasn't tracked: ${toolUseId}`); | ||
| } | ||
| }, | ||
| }); | ||
| toolCallId: toolUseId, | ||
| sessionUpdate: "tool_call_update", | ||
| }; | ||
| await client.sessionUpdate({ | ||
| sessionId, | ||
| update, | ||
| }); | ||
| } | ||
| else { | ||
| logger.error(`[claude-code-acp] Got a tool response for tool use that wasn't tracked: ${toolUseId}`); | ||
| } | ||
| }, | ||
| }); | ||
| } | ||
| let rawInput; | ||
@@ -1099,2 +1170,4 @@ try { | ||
| case "container_upload": | ||
| case "compaction": | ||
| case "compaction_delta": | ||
| break; | ||
@@ -1101,0 +1174,0 @@ default: |
+1
-0
@@ -32,2 +32,3 @@ import { Readable, Writable } from "node:stream"; | ||
| export declare function extractLinesWithByteLimit(fullContent: string, maxContentLength: number): ExtractLinesResult; | ||
| export declare function encodeProjectPath(cwd: string): string; | ||
| //# sourceMappingURL=utils.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjE,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAA0B,MAAM,eAAe,CAAC;AAG3E,qBAAa,QAAQ,CAAC,CAAC,CAAE,YAAW,aAAa,CAAC,CAAC,CAAC;IAClD,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,SAAS,CAA8C;IAC/D,OAAO,C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CAAC,SAAS,CAA8C;IAC/D,OAAO,CAAC,IAAI,CAAS;IAErB,IAAI,CAAC,IAAI,EAAE,CAAC;IASZ,GAAG;IAQH,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC;CAgB3C;AAGD,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,QAAQ,GAAG,cAAc,CAAC,UAAU,CAAC,CAclF;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,QAAQ,GAAG,cAAc,CAAC,UAAU,CAAC,CAUlF;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,GAAE,MAAgB,QAQjE;AAED,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEjD;AAED,wBAAgB,mBAAmB,IAAI,kBAAkB,GAAG,IAAI,CAM/D;AAED,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI,CAM3E;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,MAAM,EACnB,gBAAgB,EAAE,MAAM,GACvB,kBAAkB,CA8CpB;AAKD,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAUrD"} |
+13
-0
@@ -151,1 +151,14 @@ // A pushable async iterable: allows you to push items and consume them with for-await. | ||
| } | ||
| // Helper to encode a path like Claude does: | ||
| // - Unix: "/Users/test" -> "-Users-test" | ||
| // - Windows: "C:\Users\test" -> "C-Users-test" | ||
| export function encodeProjectPath(cwd) { | ||
| const windowsPathMatch = cwd.match(/^([A-Za-z]):[\\/]/); | ||
| if (windowsPathMatch) { | ||
| const driveLetter = windowsPathMatch[1]; | ||
| const rest = cwd.slice(2); | ||
| return `${driveLetter}${rest.replace(/[\\/]/g, "-")}`; | ||
| } | ||
| // Unix paths | ||
| return cwd.replace(/\//g, "-"); | ||
| } |
+6
-6
@@ -6,3 +6,3 @@ { | ||
| }, | ||
| "version": "0.15.0", | ||
| "version": "0.16.0", | ||
| "description": "An ACP-compatible coding agent powered by the Claude Code SDK (TypeScript)", | ||
@@ -64,11 +64,11 @@ "main": "dist/lib.js", | ||
| "dependencies": { | ||
| "@agentclientprotocol/sdk": "0.13.1", | ||
| "@anthropic-ai/claude-agent-sdk": "0.2.32", | ||
| "@agentclientprotocol/sdk": "0.14.1", | ||
| "@anthropic-ai/claude-agent-sdk": "0.2.34", | ||
| "@modelcontextprotocol/sdk": "1.26.0", | ||
| "diff": "8.0.3", | ||
| "minimatch": "10.1.1" | ||
| "minimatch": "10.1.2" | ||
| }, | ||
| "devDependencies": { | ||
| "@anthropic-ai/sdk": "0.72.1", | ||
| "@types/node": "25.2.0", | ||
| "@anthropic-ai/sdk": "0.73.0", | ||
| "@types/node": "25.2.1", | ||
| "@typescript-eslint/eslint-plugin": "8.54.0", | ||
@@ -75,0 +75,0 @@ "@typescript-eslint/parser": "8.54.0", |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 5 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 5 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
170439
2.24%3592
2.6%+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
Updated