@agentproto/adapter-claude-sdk 0.2.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/LICENSE +21 -0
- package/README.md +98 -0
- package/claude-sdk.ACP.md +87 -0
- package/dist/chunk-DW2G2NIH.mjs +430 -0
- package/dist/chunk-DW2G2NIH.mjs.map +1 -0
- package/dist/cli.mjs +64 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/index.d.ts +263 -0
- package/dist/index.mjs +190 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/options.ts","../src/message-map.ts","../src/acp-host.ts","../src/run.ts"],"names":["query","sdkQuery"],"mappings":";;;;;;;;;;AAcO,IAAM,aAAA,GAAgB;AAc7B,IAAM,+BAAA,GAAkC;AAAA,EACtC,yBAAA;AAAA,EACA,wBAAA;AAAA,EACA,yBAAA;AAAA,EACA,+BAAA;AAAA,EACA,wBAAA;AAAA,EACA;AACF,CAAA;AAaO,IAAM,uBAAA,GAA0B,GAAA;AA6DhC,SAAS,iBACd,OAAA,EACiC;AACjC,EAAA,MAAM,MAAuC,EAAC;AAC9C,EAAA,KAAA,MAAW,MAAA,IAAU,OAAA,IAAW,EAAC,EAAG;AAClC,IAAA,IAAI,MAAA,IAAU,MAAA,IAAU,MAAA,CAAO,IAAA,KAAS,MAAA,EAAQ;AAC9C,MAAA,GAAA,CAAI,MAAA,CAAO,IAAI,CAAA,GAAI;AAAA,QACjB,IAAA,EAAM,MAAA;AAAA,QACN,KAAK,MAAA,CAAO,GAAA;AAAA,QACZ,OAAA,EAAS,YAAA,CAAa,MAAA,CAAO,OAAO;AAAA,OACtC;AAAA,IACF,CAAA,MAAA,IAAW,MAAA,IAAU,MAAA,IAAU,MAAA,CAAO,SAAS,KAAA,EAAO;AACpD,MAAA,GAAA,CAAI,MAAA,CAAO,IAAI,CAAA,GAAI;AAAA,QACjB,IAA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` for a turn, and map ACP-side inputs\n * (session id, injected MCP servers) onto it. Isolated from the ACP host so\n * the option-shaping is unit-testable without a live SDK.\n */\n\nimport type { McpServer } from \"@agentclientprotocol/sdk\"\nimport type {\n McpServerConfig,\n Options,\n PermissionMode,\n} from \"@anthropic-ai/claude-agent-sdk\"\n\n/** A cheap Claude by default — this is a budget first-party arm. */\nexport const DEFAULT_MODEL = \"claude-haiku-4-5-20251001\"\n\n/**\n * Boolean provider-select toggles the SDK's own `claude` binary groups\n * together with `CLAUDE_CODE_USE_BEDROCK`/`CLAUDE_CODE_USE_VERTEX` (same\n * array, `ac4f1e4` build of `@anthropic-ai/claude-agent-sdk`) to pick a\n * cloud-provider endpoint ahead of `ANTHROPIC_BASE_URL`. Leaking any of these\n * from a Claude-Code parent shell wedges a gateway turn against the wrong\n * provider. Deliberately excludes the non-boolean config members of that same\n * array (`ANTHROPIC_VERTEX_PROJECT_ID`, `ANTHROPIC_AWS_WORKSPACE_ID`,\n * `ANTHROPIC_FOUNDRY_RESOURCE`, `CLOUD_ML_REGION`) and the provider\n * credential/skip-auth vars — both are inert once the toggle that gates them\n * is gone.\n */\nconst CLOUD_PROVIDER_REDIRECT_TOGGLES = [\n \"CLAUDE_CODE_USE_BEDROCK\",\n \"CLAUDE_CODE_USE_VERTEX\",\n \"CLAUDE_CODE_USE_FOUNDRY\",\n \"CLAUDE_CODE_USE_ANTHROPIC_AWS\",\n \"CLAUDE_CODE_USE_MANTLE\",\n \"CLAUDE_CODE_USE_GATEWAY\",\n] as const\n\n/**\n * Default idle watchdog for a turn (ms). If `query()` yields no message for\n * this long, {@link ClaudeSdkConfig.idleTimeoutMs} aborts the turn instead of\n * hanging forever. Ninety seconds: the watchdog is IDLE-based (reset on every\n * SDK message), and a healthy streaming turn — native or gateway — emits\n * messages continuously with sub-second gaps, so a 90s silence means the SDK\n * child is genuinely wedged. The prior 5-minute ceiling was needlessly slow to\n * surface a wedged child; 90s stays well clear of any real inter-message gap\n * while turning a wedged turn around quickly. `0` disables. See\n * {@link ClaudeSdkConfig.idleTimeoutMs}.\n */\nexport const DEFAULT_IDLE_TIMEOUT_MS = 90_000\n\n/** Static config for the adapter, parsed from CLI args / env at boot. */\nexport interface ClaudeSdkConfig {\n /** SDK `options.model`. Defaults to {@link DEFAULT_MODEL}. */\n model?: string\n /** Sets `ANTHROPIC_BASE_URL` in the child env — points the harness at real\n * Anthropic, Bedrock/Vertex/Azure, or an Anthropic-compatible gateway. */\n baseUrl?: string\n /** Sets `ANTHROPIC_AUTH_TOKEN` in the child env — the SDK sends it as\n * `Authorization: Bearer`. Pair with {@link baseUrl} to target a gateway\n * (Moonshot / OpenRouter) with a per-spawn key instead of the ambient\n * `ANTHROPIC_API_KEY`. Never logged. */\n authToken?: string\n /**\n * Enable extended thinking (SDK `options.thinking = { type: \"enabled\" }`).\n * Required by some gateway models (e.g. Moonshot's `kimi-k2.7-code`, which\n * rejects a request without it). Off by default — native Claude models pick\n * their own thinking behaviour.\n */\n thinking?: boolean\n /** Working directory for the session (tools are confined here). */\n cwd?: string\n /**\n * Idle watchdog for a turn, in milliseconds. If the SDK's `query()` iterator\n * produces no message for this long, the turn is aborted with a surfaced\n * error instead of hanging forever. This is a defensive guard against a\n * wedged SDK child — one that stops yielding messages and never delivers the\n * SDK's terminal `result`, nor closes — which would otherwise leave the turn\n * stuck `busy` with zero output (the worst failure mode). The observed cause\n * is environmental, NOT the model or its response shape: a conflicting host\n * env leaking into the spawned SDK subprocess (e.g. a stray\n * `ANTHROPIC_BASE_URL`, or a `CLAUDE_CODE_USE_BEDROCK`/`_VERTEX` auth toggle\n * inherited from a Claude Code shell) can send the child down a path that\n * never completes. Moonshot's own Anthropic-compatible responses (empty\n * `thinking.signature`, a non-`msg_` `chatcmpl-…` id, a `message_delta`-\n * terminated stream) are consumed and finalised correctly by the SDK —\n * verified live end-to-end under a clean env — so the guard is a safety net\n * for a wedged child, not a gateway/response defect. Idle-based (reset on\n * every message), so a legitimately long generation or tool run is\n * unaffected. `0` disables the watchdog. Defaults to\n * {@link DEFAULT_IDLE_TIMEOUT_MS}. Overridable at the CLI via\n * `CLAUDE_SDK_IDLE_TIMEOUT_MS`.\n */\n idleTimeoutMs?: number\n /**\n * How the harness handles tool-permission prompts. Defaults to\n * `bypassPermissions` (with the required danger flag) so the arm can act\n * autonomously inside the daemon's sandbox, mirroring how the claude-code\n * arm is spawned. Override via `CLAUDE_SDK_PERMISSION_MODE`.\n */\n permissionMode?: PermissionMode\n}\n\n/**\n * Map ACP `session/new` MCP server declarations to the SDK's\n * `mcpServers` record (keyed by name). Lets the daemon inject a scoped toolset\n * into the harness exactly like any other arm. Env pairs / headers arrive as\n * `{ name, value }` lists on the wire; flatten them to the record shape the\n * SDK expects.\n */\nexport function mapAcpMcpServers(\n servers: McpServer[] | undefined,\n): Record<string, McpServerConfig> {\n const out: Record<string, McpServerConfig> = {}\n for (const server of servers ?? []) {\n if (\"type\" in server && server.type === \"http\") {\n out[server.name] = {\n type: \"http\",\n url: server.url,\n headers: flattenPairs(server.headers),\n }\n } else if (\"type\" in server && server.type === \"sse\") {\n out[server.name] = {\n type: \"sse\",\n url: server.url,\n headers: flattenPairs(server.headers),\n }\n } else {\n // Stdio is the default (untagged) ACP MCP variant.\n out[server.name] = {\n type: \"stdio\",\n command: server.command,\n args: server.args,\n env: flattenPairs(server.env),\n }\n }\n }\n return out\n}\n\n/** Flatten an ACP `{ name, value }[]` list to a `Record<string, string>`. */\nfunction flattenPairs(\n pairs: Array<{ name: string; value: string }> | undefined,\n): Record<string, string> {\n const out: Record<string, string> = {}\n for (const pair of pairs ?? []) out[pair.name] = pair.value\n return out\n}\n\n/**\n * Assemble the SDK `Options` for a single `query()` call.\n *\n * - `sessionId` pins a stable UUID on the FIRST turn so the ACP session id and\n * the SDK session id match (enabling resume).\n * - `resume` continues that same session on later turns.\n * - Native mode (no `base_url`): the ambient env — `ANTHROPIC_API_KEY` or the\n * Claude Code subscription/OAuth login — is passed through unchanged; an\n * explicit `auth_token` still wins as `ANTHROPIC_AUTH_TOKEN`.\n * - Gateway mode (`base_url` set → a non-Anthropic host): the ambient\n * `ANTHROPIC_API_KEY` is SCRUBBED (it must never be sent to a third-party\n * gateway — that both 401s and leaks the real key). The gateway bearer is\n * resolved from, in order, the explicit `auth_token`, an explicit\n * `ANTHROPIC_AUTH_TOKEN`, or the gateway's conventional key env named by the\n * mode via `CLAUDE_SDK_GATEWAY_KEY_ENV` (e.g. `MOONSHOT_API_KEY`). Every\n * internal model tier is also pinned to the resolved model so a single-model\n * gateway never gets a tier it can't serve (e.g. Moonshot rejecting\n * `claude-haiku-*`). The {@link CLOUD_PROVIDER_REDIRECT_TOGGLES} leaked from\n * a Claude-Code parent shell are also scrubbed so the gateway `base_url`\n * isn't overridden.\n */\nexport function buildQueryOptions(args: {\n config: ClaudeSdkConfig\n abortController: AbortController\n /** Set on the first turn to fix the session UUID. */\n sessionId?: string\n /** Set on resuming turns. */\n resume?: string\n mcpServers?: McpServer[]\n env?: Record<string, string | undefined>\n}): Options {\n const { config, abortController, sessionId, resume, mcpServers } = args\n const model = config.model ?? DEFAULT_MODEL\n const baseEnv = args.env ?? process.env\n const env: Record<string, string | undefined> = { ...baseEnv }\n if (config.baseUrl) {\n // Gateway mode (non-Anthropic host). Auth hygiene: an ambient\n // ANTHROPIC_API_KEY must NEVER reach a third-party gateway (it 401s AND\n // leaks the real Anthropic key). Resolve the gateway bearer from, in order,\n // the explicit auth_token, an explicit ANTHROPIC_AUTH_TOKEN, or the\n // gateway's conventional key env named by the mode via\n // CLAUDE_SDK_GATEWAY_KEY_ENV (e.g. MOONSHOT_API_KEY). Then scrub the\n // Anthropic key so exactly the gateway's own credential is presented; if\n // none resolves, present no credential (fail clean, never leak).\n env.ANTHROPIC_BASE_URL = config.baseUrl\n const gatewayKeyEnv = baseEnv.CLAUDE_SDK_GATEWAY_KEY_ENV\n const bearer =\n config.authToken ??\n baseEnv.ANTHROPIC_AUTH_TOKEN ??\n (gatewayKeyEnv ? baseEnv[gatewayKeyEnv] : undefined)\n delete env.ANTHROPIC_API_KEY\n if (bearer) env.ANTHROPIC_AUTH_TOKEN = bearer\n else delete env.ANTHROPIC_AUTH_TOKEN\n // A Claude-Code parent shell may leak CLAUDE_CODE_USE_BEDROCK / _VERTEX\n // (etc.) into this child's env; the SDK honours those ahead of\n // ANTHROPIC_BASE_URL, silently sending the turn to the wrong provider\n // instead of the gateway (the confirmed cause of turns wedging forever).\n // Scrub so exactly the gateway base_url + bearer are presented.\n for (const key of CLOUD_PROVIDER_REDIRECT_TOGGLES) delete env[key]\n // Pin every tier the harness might request (opus/sonnet/haiku defaults + the\n // small/fast background model) to the one model the gateway serves.\n env.ANTHROPIC_MODEL = model\n env.ANTHROPIC_DEFAULT_OPUS_MODEL = model\n env.ANTHROPIC_DEFAULT_SONNET_MODEL = model\n env.ANTHROPIC_DEFAULT_HAIKU_MODEL = model\n env.ANTHROPIC_SMALL_FAST_MODEL = model\n } else if (config.authToken) {\n // Native Anthropic: an explicit bearer (e.g. a subscription/OAuth token)\n // still wins; otherwise the SDK uses the ambient ANTHROPIC_API_KEY or the\n // Claude Code login (subscription), left untouched.\n env.ANTHROPIC_AUTH_TOKEN = config.authToken\n }\n\n const options: Options = {\n model,\n abortController,\n permissionMode: config.permissionMode ?? \"bypassPermissions\",\n // Required companion to bypassPermissions — this arm runs unattended.\n allowDangerouslySkipPermissions: true,\n // Hermetic embed: don't silently pull in filesystem settings / CLAUDE.md;\n // the daemon owns the configuration surface.\n settingSources: [],\n // Stream partial (`stream_event`) messages so a long thinking / generation\n // stretch is observable live instead of surfacing only at message\n // boundaries. Two things depend on it: (1) the daemon's output ring — the\n // mapped text/thinking deltas keep `lastOutputAt` advancing during a long\n // busy turn instead of freezing until the next tool boundary; and (2) the\n // turn watchdog (acp-host `#nextMessage`), which resets on every SDK\n // message — without partials, a >90s thinking block (kimi-k2.7-code with\n // `--thinking`) yields NO message and the idle watchdog wrongly aborts a\n // healthy turn. See message-map's `streamEventUpdates`.\n includePartialMessages: true,\n env,\n ...(config.cwd ? { cwd: config.cwd } : {}),\n ...(sessionId ? { sessionId } : {}),\n ...(resume ? { resume } : {}),\n }\n // Extended thinking, opt-in. Required by thinking-gated gateway models such\n // as kimi-k2.7-code (rejects a request with no `thinking`). The property's\n // type contextualises the literal, so no cast is needed.\n if (config.thinking) options.thinking = { type: \"enabled\" }\n const mapped = mapAcpMcpServers(mcpServers)\n if (Object.keys(mapped).length > 0) options.mcpServers = mapped\n return options\n}\n","/**\n * Pure mapping from the Claude Agent SDK's message stream (`SDKMessage`, the\n * values `query()` yields) to AIP-44 ACP `session/update` payloads. Kept\n * side-effect free and dependency-light (types only) so it is straightforward\n * to unit-test; the ACP host (acp-host.ts) owns the wire/IO and forwards\n * whatever this returns.\n *\n * I/O stays 100% Anthropic-native: we read the SDK's real message shapes and\n * translate them to ACP updates — no format translation of the model I/O.\n *\n * The SDK emits a typed union on `query()`. We surface:\n * - `stream_event` text delta → ACP `agent_message_chunk` (streamed prose)\n * - `stream_event` thinking delta → ACP `agent_thought_chunk` (streamed reasoning)\n * - `assistant` text blocks → ACP `agent_message_chunk` (assistant prose)\n * - `assistant` tool_use → ACP `tool_call` (a tool started)\n * - `user` tool_result → ACP `tool_call_update` (that tool finished/failed)\n * - `result` → ACP `usage_update` (tokens + cost)\n * The `system`/`init` message carries the SDK `session_id`, handled separately\n * by the host (see {@link systemInitSessionId}).\n *\n * With `includePartialMessages` on (see options.ts), assistant prose arrives\n * TWICE: first as streamed `stream_event` text deltas, then again in the\n * terminal complete `assistant` message. The host tracks whether it saw any\n * partial and asks {@link sdkMessageToUpdates} to suppress the complete\n * message's text so the ring isn't double-fed (see `suppressAssistantText`).\n * `thinking` is only ever surfaced via the streamed deltas — the complete\n * `assistant` message's thinking block is intentionally not mapped.\n */\n\nimport type {\n SDKAssistantMessage,\n SDKMessage,\n SDKPartialAssistantMessage,\n SDKResultMessage,\n SDKSystemMessage,\n SDKUserMessage,\n} from \"@anthropic-ai/claude-agent-sdk\"\nimport type { SessionUpdate, ToolKind, UsageUpdate } from \"@agentclientprotocol/sdk\"\n\n/**\n * A `usage_update` session update. ACP's `UsageUpdate` models `size`/`used`/\n * `cost`; we widen it with the optional `tokensIn`/`tokensOut` the agentproto\n * runtime also reads (see packages/acp translateSessionUpdate + runtime\n * sessions.ts), so a session whose adapter reports tokens can be priced even\n * without a `cost`. Assignable to `SessionUpdate` structurally (extra fields\n * are allowed), so no cast is needed.\n */\nexport type UsageSessionUpdate = UsageUpdate & {\n sessionUpdate: \"usage_update\"\n tokensIn?: number\n tokensOut?: number\n}\n\n/** Map a Claude Code built-in tool name to the ACP {@link ToolKind} that\n * drives client icon/UI treatment. Unknown/MCP tools fall back to \"other\". */\nexport function toolKindForClaudeTool(name: string): ToolKind {\n switch (name) {\n case \"Read\":\n case \"NotebookRead\":\n return \"read\"\n case \"Write\":\n case \"Edit\":\n case \"MultiEdit\":\n case \"NotebookEdit\":\n return \"edit\"\n case \"Bash\":\n case \"BashOutput\":\n case \"KillBash\":\n return \"execute\"\n case \"Grep\":\n case \"Glob\":\n return \"search\"\n case \"WebFetch\":\n case \"WebSearch\":\n return \"fetch\"\n case \"Task\":\n return \"think\"\n default:\n return \"other\"\n }\n}\n\n/** Read a string-valued property from an unknown value without an unsafe\n * cast — narrows via `in` and a `typeof` guard. */\nfunction stringField(input: unknown, key: string): string | undefined {\n if (input && typeof input === \"object\" && key in input) {\n const value: unknown = Reflect.get(input, key)\n if (typeof value === \"string\") return value\n }\n return undefined\n}\n\n/** A short, human-readable title for a tool call, e.g. `Bash: ls -la` or\n * `Read: src/index.ts`. Falls back to the bare tool name. */\nexport function toolCallTitle(name: string, input: unknown): string {\n const hint =\n stringField(input, \"command\") ??\n stringField(input, \"file_path\") ??\n stringField(input, \"path\") ??\n stringField(input, \"pattern\") ??\n stringField(input, \"url\")\n return hint ? `${name}: ${hint}` : name\n}\n\n/** Translate one complete `assistant` message into ACP updates: one per text\n * block (agent_message_chunk) and one per tool_use block (tool_call).\n *\n * `suppressText` drops the text blocks — set by the host once it has seen\n * `stream_event` deltas this turn, since the prose already streamed and\n * re-emitting the complete copy would double-feed the ring. tool_use blocks\n * are always emitted (they carry the full input the daemon needs and never\n * arrive as a usable partial). */\nexport function assistantMessageUpdates(\n msg: SDKAssistantMessage,\n suppressText = false,\n): SessionUpdate[] {\n const updates: SessionUpdate[] = []\n for (const block of msg.message.content) {\n if (block.type === \"text\") {\n if (suppressText || !block.text) continue\n updates.push({\n sessionUpdate: \"agent_message_chunk\",\n content: { type: \"text\", text: block.text },\n })\n } else if (block.type === \"tool_use\") {\n updates.push({\n sessionUpdate: \"tool_call\",\n toolCallId: block.id,\n title: toolCallTitle(block.name, block.input),\n kind: toolKindForClaudeTool(block.name),\n status: \"in_progress\",\n rawInput: block.input,\n })\n }\n }\n return updates\n}\n\n/**\n * Translate a `stream_event` (partial-assistant) message into ACP deltas.\n * Only `content_block_delta` text / thinking deltas carry user-visible content:\n * - `text_delta` → `agent_message_chunk` (streamed assistant prose)\n * - `thinking_delta` → `agent_thought_chunk` (streamed extended-thinking)\n * Every other frame (block start/stop, `input_json_delta`, `signature_delta`,\n * message-level `message_start`/`message_delta`/`message_stop`) produces\n * nothing here — but still counts as an SDK message to the host's turn\n * watchdog, which is exactly why partial streaming keeps a long thinking turn\n * from being mistaken for a stall.\n *\n * Read structurally (via typed field guards) rather than importing the beta\n * `RawContentBlockDelta` union — this file stays dependency-light per its\n * header, and the two delta shapes we care about are tiny and stable\n * (`{ type: \"text_delta\", text }` / `{ type: \"thinking_delta\", thinking }`).\n */\nexport function streamEventUpdates(\n msg: SDKPartialAssistantMessage,\n): SessionUpdate[] {\n const event: unknown = msg.event\n if (stringField(event, \"type\") !== \"content_block_delta\") return []\n const delta =\n event && typeof event === \"object\" ? Reflect.get(event, \"delta\") : undefined\n switch (stringField(delta, \"type\")) {\n case \"text_delta\": {\n const text = stringField(delta, \"text\")\n return text\n ? [\n {\n sessionUpdate: \"agent_message_chunk\",\n content: { type: \"text\", text },\n },\n ]\n : []\n }\n case \"thinking_delta\": {\n const thinking = stringField(delta, \"thinking\")\n return thinking\n ? [\n {\n sessionUpdate: \"agent_thought_chunk\",\n content: { type: \"text\", text: thinking },\n },\n ]\n : []\n }\n default:\n return []\n }\n}\n\n/** Translate a `user` message's tool_result blocks into ACP\n * `tool_call_update`s. Non-tool user echoes (a plain string, or the initial\n * prompt) produce nothing. */\nexport function userMessageUpdates(msg: SDKUserMessage): SessionUpdate[] {\n const content = msg.message.content\n if (typeof content === \"string\") return []\n const updates: SessionUpdate[] = []\n for (const block of content) {\n if (block.type !== \"tool_result\") continue\n updates.push({\n sessionUpdate: \"tool_call_update\",\n toolCallId: block.tool_use_id,\n status: block.is_error ? \"failed\" : \"completed\",\n rawOutput: block.content,\n })\n }\n return updates\n}\n\n/** The largest reported context-window size across the turn's models, or 0. */\nfunction contextWindowOf(msg: SDKResultMessage): number {\n let size = 0\n for (const usage of Object.values(msg.modelUsage)) {\n if (usage.contextWindow > size) size = usage.contextWindow\n }\n return size\n}\n\n/** Translate a `result` message into an ACP `usage_update`. Native Anthropic\n * usage → the shape the runtime already consumes: `size` (context window),\n * `used` (tokens in context), `cost` (from `total_cost_usd`), and the\n * `tokensIn`/`tokensOut` extension. */\nexport function resultUsageUpdate(msg: SDKResultMessage): UsageSessionUpdate {\n const u = msg.usage\n const cacheRead = u.cache_read_input_tokens ?? 0\n const cacheCreate = u.cache_creation_input_tokens ?? 0\n const tokensIn = u.input_tokens + cacheRead + cacheCreate\n const tokensOut = u.output_tokens\n return {\n sessionUpdate: \"usage_update\",\n size: contextWindowOf(msg),\n used: tokensIn + tokensOut,\n cost: { amount: msg.total_cost_usd, currency: \"USD\" },\n tokensIn,\n tokensOut,\n }\n}\n\n/**\n * Dispatch one SDK message to the ACP updates it produces (possibly none).\n * `system`/`init` is intentionally not mapped here — its `session_id` is read\n * by the host via {@link systemInitSessionId}, not surfaced as an update.\n *\n * `suppressAssistantText` is forwarded to {@link assistantMessageUpdates}: the\n * host sets it once a `stream_event` has streamed this turn's prose, so the\n * terminal complete `assistant` message doesn't re-emit the same text.\n */\nexport function sdkMessageToUpdates(\n msg: SDKMessage,\n opts: { suppressAssistantText?: boolean } = {},\n): SessionUpdate[] {\n switch (msg.type) {\n case \"stream_event\":\n return streamEventUpdates(msg)\n case \"assistant\":\n return assistantMessageUpdates(msg, opts.suppressAssistantText ?? false)\n case \"user\":\n return userMessageUpdates(msg)\n case \"result\":\n return [resultUsageUpdate(msg)]\n default:\n return []\n }\n}\n\n/** Extract the SDK `session_id` from the `system`/`init` message, else null. */\nexport function systemInitSessionId(msg: SDKMessage): string | null {\n if (msg.type === \"system\" && isInit(msg)) return msg.session_id\n return null\n}\n\n/** Narrow a `system` message to its `init` subtype (which carries the\n * authoritative `session_id` and model). */\nfunction isInit(msg: SDKMessage & { type: \"system\" }): msg is SDKSystemMessage {\n return msg.subtype === \"init\"\n}\n","/**\n * The agent side of AIP-44 ACP, backed by the Claude Agent SDK's headless\n * `query()`.\n *\n * Implements the `@agentclientprotocol/sdk` `Agent` interface: on\n * `session/prompt` it drives `query({ prompt, options })` and relays the SDK's\n * native message stream as ACP `session/update`s (assistant text, tool calls,\n * usage). I/O stays 100% Anthropic-native — no format translation of the model\n * I/O — so the daemon spawns this like any other ACP arm.\n *\n * Session identity: ACP requires a session id at `session/new`, before any\n * `query()` has run. We generate a UUID there and PIN it via the SDK's\n * `options.sessionId` on the first turn, so our ACP session id and the SDK's\n * `session_id` are the same value — which then feeds `options.resume` on later\n * turns (agentproto resume).\n */\n\nimport type {\n AgentSideConnection,\n Agent as AcpAgent,\n AuthenticateRequest,\n CancelNotification,\n InitializeRequest,\n InitializeResponse,\n McpServer,\n NewSessionRequest,\n NewSessionResponse,\n PromptRequest,\n PromptResponse,\n SetSessionConfigOptionRequest,\n SetSessionConfigOptionResponse,\n SetSessionModeRequest,\n} from \"@agentclientprotocol/sdk\"\nimport { PROTOCOL_VERSION } from \"@agentclientprotocol/sdk\"\nimport {\n query as sdkQuery,\n type Options,\n type SDKMessage,\n type SDKUserMessage,\n} from \"@anthropic-ai/claude-agent-sdk\"\nimport { sdkMessageToUpdates, systemInitSessionId } from \"./message-map.js\"\nimport {\n buildQueryOptions,\n DEFAULT_IDLE_TIMEOUT_MS,\n type ClaudeSdkConfig,\n} from \"./options.js\"\n\n/** The single SDK entry point we depend on — the headless async generator.\n * Typed structurally and injectable so tests can drive the host with a faked\n * message stream (no live Anthropic key required). */\nexport type QueryFn = (params: {\n prompt: string | AsyncIterable<SDKUserMessage>\n options?: Options\n}) => AsyncIterable<SDKMessage>\n\ninterface SessionState {\n /** The pinned ACP/SDK session id. */\n readonly id: string\n /** MCP servers injected by the daemon at `session/new`. */\n readonly mcpServers: McpServer[]\n /** null until the first turn has pinned the SDK session. */\n started: boolean\n /** The SDK's own session id, adopted from the `init` message. */\n sdkSessionId: string | null\n /** In-flight turn, for cancellation. */\n prompt: AbortController | null\n}\n\n/** A message from an unknown thrown value, without an unsafe cast. */\nfunction errorMessage(err: unknown): string {\n return err instanceof Error ? err.message : String(err)\n}\n\n/**\n * Thrown by the {@link ClaudeSdkAcpAgent}'s turn watchdog when `query()` stops\n * yielding messages: the SDK child wedged and never delivered the terminal\n * `result`, so the async iterator would otherwise never terminate. A defensive\n * safety net for an environmentally wedged child (e.g. a conflicting host env\n * leaked into the SDK subprocess), not a response-shape problem — a healthy\n * turn always reaches `result`. Distinct from a user cancel so the host\n * surfaces it as an error rather than silently reporting the turn as cancelled.\n */\nexport class TurnStalledError extends Error {\n constructor(public readonly idleMs: number) {\n super(\n `claude-sdk: query() produced no message for ${idleMs}ms — the model ` +\n `stream stalled and never delivered a terminal result. Aborting the ` +\n `turn to avoid a silent, zero-output hang. If this was a slow but ` +\n `healthy turn, raise CLAUDE_SDK_IDLE_TIMEOUT_MS.`,\n )\n this.name = \"TurnStalledError\"\n }\n}\n\n/** Pull the user's text out of an ACP prompt (its `text` content blocks). */\nexport function promptText(params: PromptRequest): string {\n return params.prompt\n .filter((b) => b.type === \"text\")\n .map((b) => b.text)\n .join(\"\")\n .trim()\n}\n\nexport class ClaudeSdkAcpAgent implements AcpAgent {\n readonly #conn: AgentSideConnection\n readonly #config: ClaudeSdkConfig\n readonly #query: QueryFn\n readonly #sessions = new Map<string, SessionState>()\n\n constructor(\n conn: AgentSideConnection,\n config: ClaudeSdkConfig = {},\n query: QueryFn = sdkQuery,\n ) {\n this.#conn = conn\n this.#config = config\n this.#query = query\n }\n\n async initialize(_params: InitializeRequest): Promise<InitializeResponse> {\n return {\n protocolVersion: PROTOCOL_VERSION,\n agentCapabilities: {\n // Turns resume via the SDK's session store (options.resume), keyed by\n // the pinned session id — but there is no ACP `session/load` replay\n // surface, so we advertise loadSession: false.\n loadSession: false,\n },\n }\n }\n\n async authenticate(\n _params: AuthenticateRequest,\n ): Promise<Record<string, never>> {\n // Auth (ANTHROPIC_API_KEY / ANTHROPIC_AUTH_TOKEN, or Bedrock/Vertex/Foundry\n // env) is read from the spawn env by the SDK — no ACP-level handshake.\n return {}\n }\n\n async newSession(params: NewSessionRequest): Promise<NewSessionResponse> {\n const id = crypto.randomUUID()\n this.#sessions.set(id, {\n id,\n mcpServers: params.mcpServers ?? [],\n started: false,\n sdkSessionId: null,\n prompt: null,\n })\n return { sessionId: id }\n }\n\n async prompt(params: PromptRequest): Promise<PromptResponse> {\n const session = this.#sessions.get(params.sessionId)\n if (!session) throw new Error(`unknown session ${params.sessionId}`)\n\n // Cancel any in-flight turn for this session before starting a new one.\n session.prompt?.abort()\n const ac = new AbortController()\n session.prompt = ac\n\n const text = promptText(params)\n try {\n const options = buildQueryOptions({\n config: this.#config,\n abortController: ac,\n // First turn pins the id; later turns resume the SDK session.\n ...(session.started\n ? { resume: session.sdkSessionId ?? session.id }\n : { sessionId: session.id }),\n mcpServers: session.mcpServers,\n })\n session.started = true\n\n await this.#drive(session, text, options, ac)\n } catch (err) {\n // A watchdog stall aborts `ac` to tear down the SDK subprocess, so check\n // the stall FIRST — otherwise it would masquerade as a user cancel and be\n // silently swallowed, which is exactly the zero-output failure we fix.\n if (ac.signal.aborted && !(err instanceof TurnStalledError)) {\n session.prompt = null\n return { stopReason: \"cancelled\" }\n }\n // Surface the failure as a message chunk, then end the turn — better UX\n // than a bare JSON-RPC error the host may swallow.\n await this.#conn.sessionUpdate({\n sessionId: session.id,\n update: {\n sessionUpdate: \"agent_message_chunk\",\n content: {\n type: \"text\",\n text: `\\n[claude-sdk error] ${errorMessage(err)}\\n`,\n },\n },\n })\n session.prompt = null\n return { stopReason: \"refusal\" }\n }\n\n const cancelled = ac.signal.aborted\n session.prompt = null\n return { stopReason: cancelled ? \"cancelled\" : \"end_turn\" }\n }\n\n async cancel(params: CancelNotification): Promise<void> {\n this.#sessions.get(params.sessionId)?.prompt?.abort()\n }\n\n /**\n * The daemon applies operator options (model, base_url) at spawn — via the\n * manifest's `bin_args_template` / `env` — then also calls this ACP config\n * hook (its default \"config apply\" path). Everything is already in effect,\n * so this reports our (empty) runtime-configurable set. Without it the spawn\n * fails with \"Method not found: session/set_config_option\".\n */\n async setSessionConfigOption(\n _params: SetSessionConfigOptionRequest,\n ): Promise<SetSessionConfigOptionResponse> {\n return { configOptions: [] }\n }\n\n /** No agent-specific modes; accept and ignore so a host that sets one\n * doesn't error. */\n async setSessionMode(\n _params: SetSessionModeRequest,\n ): Promise<Record<string, never>> {\n return {}\n }\n\n /** Drive one `query()` turn: adopt the SDK session id from `init`, then map\n * each SDK message to ACP updates and relay them.\n *\n * Iteration is driven manually (rather than `for await`) so an idle watchdog\n * can bound the wait for each next message. If the SDK child wedges mid-turn\n * — stops yielding messages without delivering the terminal `result` and\n * without closing (e.g. a conflicting host env leaked into the subprocess) —\n * the watchdog aborts the turn with a {@link TurnStalledError} instead of\n * awaiting forever with zero output. A defensive safety net; a well-behaved\n * turn (Moonshot included, under a clean env) reaches `result` and this\n * never fires. */\n async #drive(\n session: SessionState,\n text: string,\n options: Options,\n ac: AbortController,\n ): Promise<void> {\n const idleMs = this.#config.idleTimeoutMs ?? DEFAULT_IDLE_TIMEOUT_MS\n const iterator = this.#query({ prompt: text, options })[\n Symbol.asyncIterator\n ]()\n // Once a `stream_event` has streamed this turn's prose, the terminal\n // complete `assistant` message repeats it — suppress its text so the ring\n // isn't fed the same prose twice (see message-map's suppressAssistantText).\n let sawPartial = false\n try {\n while (!ac.signal.aborted) {\n const next = await this.#nextMessage(iterator, idleMs, ac)\n if (next.done) break\n const msg = next.value\n const sdkId = systemInitSessionId(msg)\n if (sdkId) session.sdkSessionId = sdkId\n if (msg.type === \"stream_event\") sawPartial = true\n for (const update of sdkMessageToUpdates(msg, {\n suppressAssistantText: sawPartial,\n })) {\n await this.#conn.sessionUpdate({ sessionId: session.id, update })\n }\n }\n } finally {\n // Best-effort generator close on any exit (stall, cancel, error). Do NOT\n // await it: on a stall the generator is suspended mid-`await` and its\n // `.return()` never settles, so awaiting here would re-introduce the very\n // hang we guard against. The turn's AbortController — already aborted on\n // a stall or a cancel — is what actually tears the SDK subprocess down.\n void Promise.resolve(iterator.return?.(undefined)).catch(() => undefined)\n }\n }\n\n /**\n * Await the next SDK message, but no longer than `idleMs`. On timeout the\n * turn is treated as stalled: abort the shared controller (tearing down the\n * SDK subprocess) and reject with {@link TurnStalledError}. `idleMs <= 0`\n * disables the watchdog and awaits indefinitely (legacy behaviour).\n */\n async #nextMessage(\n iterator: AsyncIterator<SDKMessage>,\n idleMs: number,\n ac: AbortController,\n ): Promise<IteratorResult<SDKMessage>> {\n const next = iterator.next()\n if (idleMs <= 0) return next\n // If the watchdog wins the race, `next` settles later with nobody awaiting\n // it; pre-attach a no-op handler so a late rejection isn't \"unhandled\".\n void next.catch(() => undefined)\n let timer: ReturnType<typeof setTimeout> | undefined\n const watchdog = new Promise<never>((_resolve, reject) => {\n timer = setTimeout(() => {\n ac.abort()\n reject(new TurnStalledError(idleMs))\n }, idleMs)\n // Don't let the watchdog alone keep the event loop alive.\n timer.unref()\n })\n try {\n return await Promise.race([next, watchdog])\n } finally {\n if (timer) clearTimeout(timer)\n }\n }\n}\n","/**\n * Boots the ACP server over stdio — the standard wiring for a spawned ACP\n * agent (mirrors the @agentclientprotocol/sdk agent example): the agent writes\n * JSON-RPC to stdout and reads from stdin.\n */\n\nimport { Readable, Writable } from \"node:stream\"\nimport { AgentSideConnection, ndJsonStream } from \"@agentclientprotocol/sdk\"\nimport { ClaudeSdkAcpAgent } from \"./acp-host.js\"\nimport type { ClaudeSdkConfig } from \"./options.js\"\n\nexport function runAcpOverStdio(\n config: ClaudeSdkConfig = {},\n): AgentSideConnection {\n // ndJsonStream(writable, readable): outgoing bytes -> stdout, incoming <- stdin.\n const toClient = Writable.toWeb(process.stdout) as WritableStream<Uint8Array>\n const fromClient = Readable.toWeb(\n process.stdin,\n ) as unknown as ReadableStream<Uint8Array>\n const stream = ndJsonStream(toClient, fromClient)\n return new AgentSideConnection(\n (conn) => new ClaudeSdkAcpAgent(conn, config),\n stream,\n )\n}\n"]}
|
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { runAcpOverStdio } from './chunk-DW2G2NIH.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @agentproto/adapter-claude-sdk v0.1.0-alpha
|
|
6
|
+
* First-party agentproto adapter: Claude Agent SDK headless query() -> ACP server.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// src/cli.ts
|
|
10
|
+
function parseArgs(argv) {
|
|
11
|
+
const rest = argv.slice(2);
|
|
12
|
+
const out = { cmd: rest[0] };
|
|
13
|
+
for (let i = 1; i < rest.length; i++) {
|
|
14
|
+
const arg = rest[i];
|
|
15
|
+
if (arg === "--model") out.model = rest[++i];
|
|
16
|
+
else if (arg === "--base-url") out.baseUrl = rest[++i];
|
|
17
|
+
else if (arg === "--auth-token") out.authToken = rest[++i];
|
|
18
|
+
else if (arg === "--thinking") out.thinking = true;
|
|
19
|
+
}
|
|
20
|
+
return out;
|
|
21
|
+
}
|
|
22
|
+
var USAGE = "usage: agentproto-claude-sdk acp [--model <claude-model>] [--base-url <url>] [--auth-token <token>] [--thinking]\n";
|
|
23
|
+
var PERMISSION_MODES = [
|
|
24
|
+
"default",
|
|
25
|
+
"acceptEdits",
|
|
26
|
+
"bypassPermissions",
|
|
27
|
+
"plan",
|
|
28
|
+
"dontAsk",
|
|
29
|
+
"auto"
|
|
30
|
+
];
|
|
31
|
+
function permissionModeFromEnv(raw) {
|
|
32
|
+
return PERMISSION_MODES.find((mode) => mode === raw);
|
|
33
|
+
}
|
|
34
|
+
function idleTimeoutMsFromEnv(raw) {
|
|
35
|
+
if (raw === void 0) return void 0;
|
|
36
|
+
const ms = Number.parseInt(raw, 10);
|
|
37
|
+
return Number.isInteger(ms) && ms >= 0 ? ms : void 0;
|
|
38
|
+
}
|
|
39
|
+
function main() {
|
|
40
|
+
const { cmd, model, baseUrl, authToken, thinking } = parseArgs(process.argv);
|
|
41
|
+
if (cmd !== "acp") {
|
|
42
|
+
process.stderr.write(USAGE);
|
|
43
|
+
process.exit(cmd ? 1 : 0);
|
|
44
|
+
}
|
|
45
|
+
const config = {
|
|
46
|
+
model: model ?? process.env.CLAUDE_SDK_MODEL,
|
|
47
|
+
baseUrl: baseUrl ?? process.env.ANTHROPIC_BASE_URL,
|
|
48
|
+
// The daemon injects the manifest `auth_token` option as ANTHROPIC_AUTH_TOKEN
|
|
49
|
+
// (env template); the flag is the standalone equivalent. Never logged.
|
|
50
|
+
authToken: authToken ?? process.env.ANTHROPIC_AUTH_TOKEN,
|
|
51
|
+
// `--thinking` (manifest bin_args_append_when_true) → options.thinking.
|
|
52
|
+
...thinking ? { thinking: true } : {},
|
|
53
|
+
// Tools are confined to the dir the daemon spawned us in.
|
|
54
|
+
cwd: process.cwd(),
|
|
55
|
+
...permissionModeFromEnv(process.env.CLAUDE_SDK_PERMISSION_MODE) ? { permissionMode: permissionModeFromEnv(process.env.CLAUDE_SDK_PERMISSION_MODE) } : {},
|
|
56
|
+
// Idle-stall watchdog override (ms); guards against a gateway whose stream
|
|
57
|
+
// never terminates (e.g. Moonshot). Unset → the adapter default applies.
|
|
58
|
+
...idleTimeoutMsFromEnv(process.env.CLAUDE_SDK_IDLE_TIMEOUT_MS) !== void 0 ? { idleTimeoutMs: idleTimeoutMsFromEnv(process.env.CLAUDE_SDK_IDLE_TIMEOUT_MS) } : {}
|
|
59
|
+
};
|
|
60
|
+
runAcpOverStdio(config);
|
|
61
|
+
}
|
|
62
|
+
main();
|
|
63
|
+
//# sourceMappingURL=cli.mjs.map
|
|
64
|
+
//# sourceMappingURL=cli.mjs.map
|
package/dist/cli.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;AAyBA,SAAS,UAAU,IAAA,EAA4B;AAC7C,EAAA,MAAM,IAAA,GAAO,IAAA,CAAK,KAAA,CAAM,CAAC,CAAA;AACzB,EAAA,MAAM,GAAA,GAAkB,EAAE,GAAA,EAAK,IAAA,CAAK,CAAC,CAAA,EAAE;AACvC,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,IAAA,CAAK,QAAQ,CAAA,EAAA,EAAK;AACpC,IAAA,MAAM,GAAA,GAAM,KAAK,CAAC,CAAA;AAClB,IAAA,IAAI,QAAQ,SAAA,EAAW,GAAA,CAAI,KAAA,GAAQ,IAAA,CAAK,EAAE,CAAC,CAAA;AAAA,SAAA,IAClC,QAAQ,YAAA,EAAc,GAAA,CAAI,OAAA,GAAU,IAAA,CAAK,EAAE,CAAC,CAAA;AAAA,SAAA,IAC5C,QAAQ,cAAA,EAAgB,GAAA,CAAI,SAAA,GAAY,IAAA,CAAK,EAAE,CAAC,CAAA;AAAA,SAAA,IAChD,GAAA,KAAQ,YAAA,EAAc,GAAA,CAAI,QAAA,GAAW,IAAA;AAAA,EAChD;AACA,EAAA,OAAO,GAAA;AACT;AAEA,IAAM,KAAA,GACJ,oH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BAAA,CAAsB,OAAA,CAAQ,GAAA,CAAI,0BAA0B,CAAA,GAC5D,EAAE,cAAA,EAAgB,qBAAA,CAAsB,OAAA,CAAQ,GAAA,CAAI,0BAA0B,CAAA,KAC9E,EAAC;AAAA;AAAA;AAAA,IAGL,GAAI,oBAAA,CAAqB,OAAA,CAAQ,GAAA,CAAI,0BAA0B,CAAA,KAAM,MAAA,GACjE,EAAE,aAAA,EAAe,qBAAqB,OAAA,CAAQ,GAAA,CAAI,0BAA0B,CAAA,KAC5E;AAAC,GACP;AAGA,EAAA,eAAA,CAAgB,MAAM,CAAA;AACxB;AAEA,IAAA,EAAK","file":"cli.mjs","sourcesContent":["#!/usr/bin/env node\n/**\n * Standalone CLI for the first-party Claude Agent SDK adapter.\n *\n * agentproto-claude-sdk acp [--model <id>] [--base-url <url>] \\\n * [--auth-token <token>] [--thinking]\n *\n * `acp` boots the ACP server over stdio — this is both what the agentproto\n * daemon spawns (as the `claude-sdk` arm) and what a user runs directly to\n * drive Claude Code's headless harness from any ACP-speaking host. I/O stays\n * 100% Anthropic-native.\n */\n\nimport { runAcpOverStdio } from \"./run.js\"\nimport type { ClaudeSdkConfig } from \"./options.js\"\nimport type { PermissionMode } from \"@anthropic-ai/claude-agent-sdk\"\n\ninterface ParsedArgs {\n cmd?: string\n model?: string\n baseUrl?: string\n authToken?: string\n thinking?: boolean\n}\n\nfunction parseArgs(argv: string[]): ParsedArgs {\n const rest = argv.slice(2)\n const out: ParsedArgs = { cmd: rest[0] }\n for (let i = 1; i < rest.length; i++) {\n const arg = rest[i]\n if (arg === \"--model\") out.model = rest[++i]\n else if (arg === \"--base-url\") out.baseUrl = rest[++i]\n else if (arg === \"--auth-token\") out.authToken = rest[++i]\n else if (arg === \"--thinking\") out.thinking = true\n }\n return out\n}\n\nconst USAGE =\n \"usage: agentproto-claude-sdk acp [--model <claude-model>] \" +\n \"[--base-url <url>] [--auth-token <token>] [--thinking]\\n\"\n\n/** Recognised permission-mode overrides (env `CLAUDE_SDK_PERMISSION_MODE`). */\nconst PERMISSION_MODES: readonly PermissionMode[] = [\n \"default\",\n \"acceptEdits\",\n \"bypassPermissions\",\n \"plan\",\n \"dontAsk\",\n \"auto\",\n]\n\nfunction permissionModeFromEnv(\n raw: string | undefined,\n): PermissionMode | undefined {\n return PERMISSION_MODES.find((mode) => mode === raw)\n}\n\n/** Parse the idle-stall watchdog override. A non-negative integer (ms); `0`\n * disables the watchdog. Anything else (unset, negative, non-numeric) → the\n * adapter default. */\nfunction idleTimeoutMsFromEnv(raw: string | undefined): number | undefined {\n if (raw === undefined) return undefined\n const ms = Number.parseInt(raw, 10)\n return Number.isInteger(ms) && ms >= 0 ? ms : undefined\n}\n\nfunction main(): void {\n const { cmd, model, baseUrl, authToken, thinking } = parseArgs(process.argv)\n if (cmd !== \"acp\") {\n process.stderr.write(USAGE)\n process.exit(cmd ? 1 : 0)\n }\n const config: ClaudeSdkConfig = {\n model: model ?? process.env.CLAUDE_SDK_MODEL,\n baseUrl: baseUrl ?? process.env.ANTHROPIC_BASE_URL,\n // The daemon injects the manifest `auth_token` option as ANTHROPIC_AUTH_TOKEN\n // (env template); the flag is the standalone equivalent. Never logged.\n authToken: authToken ?? process.env.ANTHROPIC_AUTH_TOKEN,\n // `--thinking` (manifest bin_args_append_when_true) → options.thinking.\n ...(thinking ? { thinking: true } : {}),\n // Tools are confined to the dir the daemon spawned us in.\n cwd: process.cwd(),\n ...(permissionModeFromEnv(process.env.CLAUDE_SDK_PERMISSION_MODE)\n ? { permissionMode: permissionModeFromEnv(process.env.CLAUDE_SDK_PERMISSION_MODE) }\n : {}),\n // Idle-stall watchdog override (ms); guards against a gateway whose stream\n // never terminates (e.g. Moonshot). Unset → the adapter default applies.\n ...(idleTimeoutMsFromEnv(process.env.CLAUDE_SDK_IDLE_TIMEOUT_MS) !== undefined\n ? { idleTimeoutMs: idleTimeoutMsFromEnv(process.env.CLAUDE_SDK_IDLE_TIMEOUT_MS) }\n : {}),\n }\n // The connection keeps the process alive (it holds stdin open); no explicit\n // wait loop needed.\n runAcpOverStdio(config)\n}\n\nmain()\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { AgentCliHandle, AgentCliRuntime } from '@agentproto/driver-agent-cli';
|
|
2
|
+
export { AgentCliHandle, AgentCliRuntime } from '@agentproto/driver-agent-cli';
|
|
3
|
+
import { McpServer, Agent, AgentSideConnection, InitializeRequest, InitializeResponse, AuthenticateRequest, NewSessionRequest, NewSessionResponse, PromptRequest, PromptResponse, CancelNotification, SetSessionConfigOptionRequest, SetSessionConfigOptionResponse, SetSessionModeRequest, UsageUpdate, SessionUpdate, ToolKind } from '@agentclientprotocol/sdk';
|
|
4
|
+
import { PermissionMode, Options, McpServerConfig, SDKUserMessage, SDKMessage, SDKAssistantMessage, SDKResultMessage } from '@anthropic-ai/claude-agent-sdk';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Build the Claude Agent SDK `Options` for a turn, and map ACP-side inputs
|
|
8
|
+
* (session id, injected MCP servers) onto it. Isolated from the ACP host so
|
|
9
|
+
* the option-shaping is unit-testable without a live SDK.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** A cheap Claude by default — this is a budget first-party arm. */
|
|
13
|
+
declare const DEFAULT_MODEL = "claude-haiku-4-5-20251001";
|
|
14
|
+
/** Static config for the adapter, parsed from CLI args / env at boot. */
|
|
15
|
+
interface ClaudeSdkConfig {
|
|
16
|
+
/** SDK `options.model`. Defaults to {@link DEFAULT_MODEL}. */
|
|
17
|
+
model?: string;
|
|
18
|
+
/** Sets `ANTHROPIC_BASE_URL` in the child env — points the harness at real
|
|
19
|
+
* Anthropic, Bedrock/Vertex/Azure, or an Anthropic-compatible gateway. */
|
|
20
|
+
baseUrl?: string;
|
|
21
|
+
/** Sets `ANTHROPIC_AUTH_TOKEN` in the child env — the SDK sends it as
|
|
22
|
+
* `Authorization: Bearer`. Pair with {@link baseUrl} to target a gateway
|
|
23
|
+
* (Moonshot / OpenRouter) with a per-spawn key instead of the ambient
|
|
24
|
+
* `ANTHROPIC_API_KEY`. Never logged. */
|
|
25
|
+
authToken?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Enable extended thinking (SDK `options.thinking = { type: "enabled" }`).
|
|
28
|
+
* Required by some gateway models (e.g. Moonshot's `kimi-k2.7-code`, which
|
|
29
|
+
* rejects a request without it). Off by default — native Claude models pick
|
|
30
|
+
* their own thinking behaviour.
|
|
31
|
+
*/
|
|
32
|
+
thinking?: boolean;
|
|
33
|
+
/** Working directory for the session (tools are confined here). */
|
|
34
|
+
cwd?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Idle watchdog for a turn, in milliseconds. If the SDK's `query()` iterator
|
|
37
|
+
* produces no message for this long, the turn is aborted with a surfaced
|
|
38
|
+
* error instead of hanging forever. This is a defensive guard against a
|
|
39
|
+
* wedged SDK child — one that stops yielding messages and never delivers the
|
|
40
|
+
* SDK's terminal `result`, nor closes — which would otherwise leave the turn
|
|
41
|
+
* stuck `busy` with zero output (the worst failure mode). The observed cause
|
|
42
|
+
* is environmental, NOT the model or its response shape: a conflicting host
|
|
43
|
+
* env leaking into the spawned SDK subprocess (e.g. a stray
|
|
44
|
+
* `ANTHROPIC_BASE_URL`, or a `CLAUDE_CODE_USE_BEDROCK`/`_VERTEX` auth toggle
|
|
45
|
+
* inherited from a Claude Code shell) can send the child down a path that
|
|
46
|
+
* never completes. Moonshot's own Anthropic-compatible responses (empty
|
|
47
|
+
* `thinking.signature`, a non-`msg_` `chatcmpl-…` id, a `message_delta`-
|
|
48
|
+
* terminated stream) are consumed and finalised correctly by the SDK —
|
|
49
|
+
* verified live end-to-end under a clean env — so the guard is a safety net
|
|
50
|
+
* for a wedged child, not a gateway/response defect. Idle-based (reset on
|
|
51
|
+
* every message), so a legitimately long generation or tool run is
|
|
52
|
+
* unaffected. `0` disables the watchdog. Defaults to
|
|
53
|
+
* {@link DEFAULT_IDLE_TIMEOUT_MS}. Overridable at the CLI via
|
|
54
|
+
* `CLAUDE_SDK_IDLE_TIMEOUT_MS`.
|
|
55
|
+
*/
|
|
56
|
+
idleTimeoutMs?: number;
|
|
57
|
+
/**
|
|
58
|
+
* How the harness handles tool-permission prompts. Defaults to
|
|
59
|
+
* `bypassPermissions` (with the required danger flag) so the arm can act
|
|
60
|
+
* autonomously inside the daemon's sandbox, mirroring how the claude-code
|
|
61
|
+
* arm is spawned. Override via `CLAUDE_SDK_PERMISSION_MODE`.
|
|
62
|
+
*/
|
|
63
|
+
permissionMode?: PermissionMode;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Map ACP `session/new` MCP server declarations to the SDK's
|
|
67
|
+
* `mcpServers` record (keyed by name). Lets the daemon inject a scoped toolset
|
|
68
|
+
* into the harness exactly like any other arm. Env pairs / headers arrive as
|
|
69
|
+
* `{ name, value }` lists on the wire; flatten them to the record shape the
|
|
70
|
+
* SDK expects.
|
|
71
|
+
*/
|
|
72
|
+
declare function mapAcpMcpServers(servers: McpServer[] | undefined): Record<string, McpServerConfig>;
|
|
73
|
+
/**
|
|
74
|
+
* Assemble the SDK `Options` for a single `query()` call.
|
|
75
|
+
*
|
|
76
|
+
* - `sessionId` pins a stable UUID on the FIRST turn so the ACP session id and
|
|
77
|
+
* the SDK session id match (enabling resume).
|
|
78
|
+
* - `resume` continues that same session on later turns.
|
|
79
|
+
* - Native mode (no `base_url`): the ambient env — `ANTHROPIC_API_KEY` or the
|
|
80
|
+
* Claude Code subscription/OAuth login — is passed through unchanged; an
|
|
81
|
+
* explicit `auth_token` still wins as `ANTHROPIC_AUTH_TOKEN`.
|
|
82
|
+
* - Gateway mode (`base_url` set → a non-Anthropic host): the ambient
|
|
83
|
+
* `ANTHROPIC_API_KEY` is SCRUBBED (it must never be sent to a third-party
|
|
84
|
+
* gateway — that both 401s and leaks the real key). The gateway bearer is
|
|
85
|
+
* resolved from, in order, the explicit `auth_token`, an explicit
|
|
86
|
+
* `ANTHROPIC_AUTH_TOKEN`, or the gateway's conventional key env named by the
|
|
87
|
+
* mode via `CLAUDE_SDK_GATEWAY_KEY_ENV` (e.g. `MOONSHOT_API_KEY`). Every
|
|
88
|
+
* internal model tier is also pinned to the resolved model so a single-model
|
|
89
|
+
* gateway never gets a tier it can't serve (e.g. Moonshot rejecting
|
|
90
|
+
* `claude-haiku-*`). The {@link CLOUD_PROVIDER_REDIRECT_TOGGLES} leaked from
|
|
91
|
+
* a Claude-Code parent shell are also scrubbed so the gateway `base_url`
|
|
92
|
+
* isn't overridden.
|
|
93
|
+
*/
|
|
94
|
+
declare function buildQueryOptions(args: {
|
|
95
|
+
config: ClaudeSdkConfig;
|
|
96
|
+
abortController: AbortController;
|
|
97
|
+
/** Set on the first turn to fix the session UUID. */
|
|
98
|
+
sessionId?: string;
|
|
99
|
+
/** Set on resuming turns. */
|
|
100
|
+
resume?: string;
|
|
101
|
+
mcpServers?: McpServer[];
|
|
102
|
+
env?: Record<string, string | undefined>;
|
|
103
|
+
}): Options;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* The agent side of AIP-44 ACP, backed by the Claude Agent SDK's headless
|
|
107
|
+
* `query()`.
|
|
108
|
+
*
|
|
109
|
+
* Implements the `@agentclientprotocol/sdk` `Agent` interface: on
|
|
110
|
+
* `session/prompt` it drives `query({ prompt, options })` and relays the SDK's
|
|
111
|
+
* native message stream as ACP `session/update`s (assistant text, tool calls,
|
|
112
|
+
* usage). I/O stays 100% Anthropic-native — no format translation of the model
|
|
113
|
+
* I/O — so the daemon spawns this like any other ACP arm.
|
|
114
|
+
*
|
|
115
|
+
* Session identity: ACP requires a session id at `session/new`, before any
|
|
116
|
+
* `query()` has run. We generate a UUID there and PIN it via the SDK's
|
|
117
|
+
* `options.sessionId` on the first turn, so our ACP session id and the SDK's
|
|
118
|
+
* `session_id` are the same value — which then feeds `options.resume` on later
|
|
119
|
+
* turns (agentproto resume).
|
|
120
|
+
*/
|
|
121
|
+
|
|
122
|
+
/** The single SDK entry point we depend on — the headless async generator.
|
|
123
|
+
* Typed structurally and injectable so tests can drive the host with a faked
|
|
124
|
+
* message stream (no live Anthropic key required). */
|
|
125
|
+
type QueryFn = (params: {
|
|
126
|
+
prompt: string | AsyncIterable<SDKUserMessage>;
|
|
127
|
+
options?: Options;
|
|
128
|
+
}) => AsyncIterable<SDKMessage>;
|
|
129
|
+
/** Pull the user's text out of an ACP prompt (its `text` content blocks). */
|
|
130
|
+
declare function promptText(params: PromptRequest): string;
|
|
131
|
+
declare class ClaudeSdkAcpAgent implements Agent {
|
|
132
|
+
#private;
|
|
133
|
+
constructor(conn: AgentSideConnection, config?: ClaudeSdkConfig, query?: QueryFn);
|
|
134
|
+
initialize(_params: InitializeRequest): Promise<InitializeResponse>;
|
|
135
|
+
authenticate(_params: AuthenticateRequest): Promise<Record<string, never>>;
|
|
136
|
+
newSession(params: NewSessionRequest): Promise<NewSessionResponse>;
|
|
137
|
+
prompt(params: PromptRequest): Promise<PromptResponse>;
|
|
138
|
+
cancel(params: CancelNotification): Promise<void>;
|
|
139
|
+
/**
|
|
140
|
+
* The daemon applies operator options (model, base_url) at spawn — via the
|
|
141
|
+
* manifest's `bin_args_template` / `env` — then also calls this ACP config
|
|
142
|
+
* hook (its default "config apply" path). Everything is already in effect,
|
|
143
|
+
* so this reports our (empty) runtime-configurable set. Without it the spawn
|
|
144
|
+
* fails with "Method not found: session/set_config_option".
|
|
145
|
+
*/
|
|
146
|
+
setSessionConfigOption(_params: SetSessionConfigOptionRequest): Promise<SetSessionConfigOptionResponse>;
|
|
147
|
+
/** No agent-specific modes; accept and ignore so a host that sets one
|
|
148
|
+
* doesn't error. */
|
|
149
|
+
setSessionMode(_params: SetSessionModeRequest): Promise<Record<string, never>>;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Pure mapping from the Claude Agent SDK's message stream (`SDKMessage`, the
|
|
154
|
+
* values `query()` yields) to AIP-44 ACP `session/update` payloads. Kept
|
|
155
|
+
* side-effect free and dependency-light (types only) so it is straightforward
|
|
156
|
+
* to unit-test; the ACP host (acp-host.ts) owns the wire/IO and forwards
|
|
157
|
+
* whatever this returns.
|
|
158
|
+
*
|
|
159
|
+
* I/O stays 100% Anthropic-native: we read the SDK's real message shapes and
|
|
160
|
+
* translate them to ACP updates — no format translation of the model I/O.
|
|
161
|
+
*
|
|
162
|
+
* The SDK emits a typed union on `query()`. We surface:
|
|
163
|
+
* - `stream_event` text delta → ACP `agent_message_chunk` (streamed prose)
|
|
164
|
+
* - `stream_event` thinking delta → ACP `agent_thought_chunk` (streamed reasoning)
|
|
165
|
+
* - `assistant` text blocks → ACP `agent_message_chunk` (assistant prose)
|
|
166
|
+
* - `assistant` tool_use → ACP `tool_call` (a tool started)
|
|
167
|
+
* - `user` tool_result → ACP `tool_call_update` (that tool finished/failed)
|
|
168
|
+
* - `result` → ACP `usage_update` (tokens + cost)
|
|
169
|
+
* The `system`/`init` message carries the SDK `session_id`, handled separately
|
|
170
|
+
* by the host (see {@link systemInitSessionId}).
|
|
171
|
+
*
|
|
172
|
+
* With `includePartialMessages` on (see options.ts), assistant prose arrives
|
|
173
|
+
* TWICE: first as streamed `stream_event` text deltas, then again in the
|
|
174
|
+
* terminal complete `assistant` message. The host tracks whether it saw any
|
|
175
|
+
* partial and asks {@link sdkMessageToUpdates} to suppress the complete
|
|
176
|
+
* message's text so the ring isn't double-fed (see `suppressAssistantText`).
|
|
177
|
+
* `thinking` is only ever surfaced via the streamed deltas — the complete
|
|
178
|
+
* `assistant` message's thinking block is intentionally not mapped.
|
|
179
|
+
*/
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* A `usage_update` session update. ACP's `UsageUpdate` models `size`/`used`/
|
|
183
|
+
* `cost`; we widen it with the optional `tokensIn`/`tokensOut` the agentproto
|
|
184
|
+
* runtime also reads (see packages/acp translateSessionUpdate + runtime
|
|
185
|
+
* sessions.ts), so a session whose adapter reports tokens can be priced even
|
|
186
|
+
* without a `cost`. Assignable to `SessionUpdate` structurally (extra fields
|
|
187
|
+
* are allowed), so no cast is needed.
|
|
188
|
+
*/
|
|
189
|
+
type UsageSessionUpdate = UsageUpdate & {
|
|
190
|
+
sessionUpdate: "usage_update";
|
|
191
|
+
tokensIn?: number;
|
|
192
|
+
tokensOut?: number;
|
|
193
|
+
};
|
|
194
|
+
/** Map a Claude Code built-in tool name to the ACP {@link ToolKind} that
|
|
195
|
+
* drives client icon/UI treatment. Unknown/MCP tools fall back to "other". */
|
|
196
|
+
declare function toolKindForClaudeTool(name: string): ToolKind;
|
|
197
|
+
/** A short, human-readable title for a tool call, e.g. `Bash: ls -la` or
|
|
198
|
+
* `Read: src/index.ts`. Falls back to the bare tool name. */
|
|
199
|
+
declare function toolCallTitle(name: string, input: unknown): string;
|
|
200
|
+
/** Translate one complete `assistant` message into ACP updates: one per text
|
|
201
|
+
* block (agent_message_chunk) and one per tool_use block (tool_call).
|
|
202
|
+
*
|
|
203
|
+
* `suppressText` drops the text blocks — set by the host once it has seen
|
|
204
|
+
* `stream_event` deltas this turn, since the prose already streamed and
|
|
205
|
+
* re-emitting the complete copy would double-feed the ring. tool_use blocks
|
|
206
|
+
* are always emitted (they carry the full input the daemon needs and never
|
|
207
|
+
* arrive as a usable partial). */
|
|
208
|
+
declare function assistantMessageUpdates(msg: SDKAssistantMessage, suppressText?: boolean): SessionUpdate[];
|
|
209
|
+
/** Translate a `user` message's tool_result blocks into ACP
|
|
210
|
+
* `tool_call_update`s. Non-tool user echoes (a plain string, or the initial
|
|
211
|
+
* prompt) produce nothing. */
|
|
212
|
+
declare function userMessageUpdates(msg: SDKUserMessage): SessionUpdate[];
|
|
213
|
+
/** Translate a `result` message into an ACP `usage_update`. Native Anthropic
|
|
214
|
+
* usage → the shape the runtime already consumes: `size` (context window),
|
|
215
|
+
* `used` (tokens in context), `cost` (from `total_cost_usd`), and the
|
|
216
|
+
* `tokensIn`/`tokensOut` extension. */
|
|
217
|
+
declare function resultUsageUpdate(msg: SDKResultMessage): UsageSessionUpdate;
|
|
218
|
+
/**
|
|
219
|
+
* Dispatch one SDK message to the ACP updates it produces (possibly none).
|
|
220
|
+
* `system`/`init` is intentionally not mapped here — its `session_id` is read
|
|
221
|
+
* by the host via {@link systemInitSessionId}, not surfaced as an update.
|
|
222
|
+
*
|
|
223
|
+
* `suppressAssistantText` is forwarded to {@link assistantMessageUpdates}: the
|
|
224
|
+
* host sets it once a `stream_event` has streamed this turn's prose, so the
|
|
225
|
+
* terminal complete `assistant` message doesn't re-emit the same text.
|
|
226
|
+
*/
|
|
227
|
+
declare function sdkMessageToUpdates(msg: SDKMessage, opts?: {
|
|
228
|
+
suppressAssistantText?: boolean;
|
|
229
|
+
}): SessionUpdate[];
|
|
230
|
+
/** Extract the SDK `session_id` from the `system`/`init` message, else null. */
|
|
231
|
+
declare function systemInitSessionId(msg: SDKMessage): string | null;
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Boots the ACP server over stdio — the standard wiring for a spawned ACP
|
|
235
|
+
* agent (mirrors the @agentclientprotocol/sdk agent example): the agent writes
|
|
236
|
+
* JSON-RPC to stdout and reads from stdin.
|
|
237
|
+
*/
|
|
238
|
+
|
|
239
|
+
declare function runAcpOverStdio(config?: ClaudeSdkConfig): AgentSideConnection;
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* @agentproto/adapter-claude-sdk — first-party adapter that runs Claude Code's
|
|
243
|
+
* agent harness as a LIBRARY.
|
|
244
|
+
*
|
|
245
|
+
* Unlike `@agentproto/adapter-claude-code` (which wraps the third-party
|
|
246
|
+
* `@agentclientprotocol/claude-agent-acp` bridge), this adapter drives the
|
|
247
|
+
* Claude Agent SDK's headless `query()` directly behind an AIP-44 ACP server
|
|
248
|
+
* (see ./acp-host.ts), shipped as a CLI bin (`agentproto-claude-sdk acp`). The
|
|
249
|
+
* daemon spawns it like any other arm; a user can launch it standalone.
|
|
250
|
+
*
|
|
251
|
+
* Driving the SDK directly buys us clean model pinning (`options.model`, no
|
|
252
|
+
* spawn-arg rejection — issue #186), native usage telemetry (a `usage_update`
|
|
253
|
+
* per turn — #186 P3), and a custom `base_url` (`ANTHROPIC_BASE_URL`) that
|
|
254
|
+
* points the same Anthropic-native harness at real Anthropic, Bedrock/Vertex/
|
|
255
|
+
* Azure, or an Anthropic-compatible gateway.
|
|
256
|
+
*
|
|
257
|
+
* import { claudeSdk, claudeSdkRuntime } from "@agentproto/adapter-claude-sdk"
|
|
258
|
+
*/
|
|
259
|
+
|
|
260
|
+
declare const claudeSdk: AgentCliHandle;
|
|
261
|
+
declare function claudeSdkRuntime(): AgentCliRuntime;
|
|
262
|
+
|
|
263
|
+
export { ClaudeSdkAcpAgent, type ClaudeSdkConfig, DEFAULT_MODEL, type QueryFn, type UsageSessionUpdate, assistantMessageUpdates, buildQueryOptions, claudeSdk, claudeSdkRuntime, mapAcpMcpServers, promptText, resultUsageUpdate, runAcpOverStdio, sdkMessageToUpdates, systemInitSessionId, toolCallTitle, toolKindForClaudeTool, userMessageUpdates };
|