@agentproto/adapter-claude-sdk 0.3.1 → 0.4.1

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/README.md CHANGED
@@ -62,12 +62,21 @@ tier the harness might internally request — `ANTHROPIC_MODEL`,
62
62
  Native Anthropic (no `base_url`) leaves tier routing untouched.
63
63
 
64
64
  Verified live: Moonshot `https://api.moonshot.ai/anthropic` +
65
- `model=kimi-k2.7-code`, and OpenRouter `https://openrouter.ai/api/v1`, both
66
- return valid Anthropic Messages format under `Authorization: Bearer`.
65
+ `model=kimi-k2.7-code`, OpenRouter `https://openrouter.ai/api`, and Requesty
66
+ `https://router.requesty.ai` all return valid Anthropic Messages format under
67
+ `Authorization: Bearer`.
68
+
69
+ Note the base URLs carry no `/v1`: the SDK appends `/v1/messages` itself, so a
70
+ `/v1` in the preset yields `…/v1/v1/messages` → 404. Verify a gateway by
71
+ POSTing to `<base_url>/v1/messages` — NOT by curling the endpoint you think it
72
+ serves. An earlier "verified live" note recorded OpenRouter as `…/api/v1` on
73
+ the strength of a direct curl to `/api/v1/messages`, which left every
74
+ openrouter-mode spawn 404ing behind the misleading gateway error "model may not
75
+ exist or you may not have access to it".
67
76
 
68
77
  ### Gateway presets (modes)
69
78
 
70
- So you don't hand-type the base URL each spawn, three modes pre-wire the gateway
79
+ So you don't hand-type the base URL each spawn, four modes pre-wire the gateway
71
80
  endpoint (`base_url`/`auth_token`/`thinking` still work manually for anything
72
81
  else):
73
82
 
@@ -76,6 +85,7 @@ else):
76
85
  | `default` | nothing — native Anthropic | `ANTHROPIC_API_KEY` |
77
86
  | `moonshot` | `ANTHROPIC_BASE_URL` + `model=kimi-k2.7-code` + `--thinking` | `auth_token` (Moonshot key) |
78
87
  | `openrouter`| `ANTHROPIC_BASE_URL` | `model` (slug) + `auth_token` (key) |
88
+ | `requesty` | `ANTHROPIC_BASE_URL` | `model` (slug) + `auth_token` (key) |
79
89
  | `deepseek` | `ANTHROPIC_BASE_URL` + `model=deepseek-v4-pro` | `auth_token` (DeepSeek key) |
80
90
 
81
91
  `mode: moonshot` is a one-pick Kimi run; override `model` for another Moonshot
package/dist/index.mjs CHANGED
@@ -140,6 +140,15 @@ var claudeSdk = defineAgentCli({
140
140
  CLAUDE_SDK_GATEWAY_KEY_ENV: ANTHROPIC_GATEWAY_PRESETS.openrouter.keyEnv
141
141
  }
142
142
  },
143
+ {
144
+ id: ANTHROPIC_GATEWAY_PRESETS.requesty.id,
145
+ description: "Requesty gateway. Pre-wires ANTHROPIC_BASE_URL to Requesty's Anthropic-compatible endpoint. Pick a model via the `model` option (e.g. 'sference/thinkingcap-qwen3.6-27b', 'sference/glm-5.2') and supply the Requesty key via `auth_token` (or ANTHROPIC_AUTH_TOKEN). buildQueryOptions pins every model tier \u2014 including ANTHROPIC_SMALL_FAST_MODEL \u2014 to that one model, since Requesty serves no Claude-named tiers.",
146
+ env: {
147
+ ANTHROPIC_BASE_URL: ANTHROPIC_GATEWAY_PRESETS.requesty.baseUrl,
148
+ // Conventional credential source for this gateway (see moonshot above).
149
+ CLAUDE_SDK_GATEWAY_KEY_ENV: ANTHROPIC_GATEWAY_PRESETS.requesty.keyEnv
150
+ }
151
+ },
143
152
  {
144
153
  id: ANTHROPIC_GATEWAY_PRESETS.deepseek.id,
145
154
  description: "DeepSeek gateway. Pre-wires ANTHROPIC_BASE_URL to DeepSeek's Anthropic-compatible endpoint and defaults the model to deepseek-v4-pro. Supply the DeepSeek key via the `auth_token` option (or ANTHROPIC_AUTH_TOKEN); override `model` for deepseek-v4-flash. Thinking is opt-in (DeepSeek accepts requests without it, unlike Kimi).",
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;AAiCA,IAAM,WAAW,aAAA,CAAc,IAAI,IAAI,WAAA,EAAa,MAAA,CAAA,IAAA,CAAY,GAAG,CAAC,CAAA;AAE7D,IAAM,YAA4B,cAAA,CAAe;AAAA,EACtD,IAAA,EAA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;AAAA,MACN,WAAA,EACE,wUAAA;AAAA,MAKF,GAAA,EAAK,EAAE,oBAAA,EAAsB,SAAA;AAAU,KACzC;AAAA,IACA;AAAA,MACE,EAAA,EAAI,UAAA;AAAA;AAAA;AAAA;AAAA,MAIJ,IAAA,EAAM,SAAA;AAAA,MACN,WAAA,EACE,wQAAA;AAAA,MAIF,yBAAA,EAA2B,CAAC,YAAY;AAAA;AAC1C,GACF;AAAA,EACA,MAAM,CAAC,WAAA,EAAa,UAAU,kBAAA,EAAoB,YAAA,EAAc,OAAO,aAAa;AACtF,CAAC;AAEM,SAAS,gBAAA,GAAoC;AAClD,EAAA,OAAO,sBAAsB,SAAS,CAAA;AACxC","file":"index.mjs","sourcesContent":["/**\n * @agentproto/adapter-claude-sdk — first-party adapter that runs Claude Code's\n * agent harness as a LIBRARY.\n *\n * Unlike `@agentproto/adapter-claude-code` (which wraps the third-party\n * `@agentclientprotocol/claude-agent-acp` bridge), this adapter drives the\n * Claude Agent SDK's headless `query()` directly behind an AIP-44 ACP server\n * (see ./acp-host.ts), shipped as a CLI bin (`agentproto-claude-sdk acp`). The\n * daemon spawns it like any other arm; a user can launch it standalone.\n *\n * Driving the SDK directly buys us clean model pinning (`options.model`, no\n * spawn-arg rejection — issue #186), native usage telemetry (a `usage_update`\n * per turn — #186 P3), and a custom `base_url` (`ANTHROPIC_BASE_URL`) that\n * points the same Anthropic-native harness at real Anthropic, Bedrock/Vertex/\n * Azure, or an Anthropic-compatible gateway.\n *\n * import { claudeSdk, claudeSdkRuntime } from \"@agentproto/adapter-claude-sdk\"\n */\n\nimport { fileURLToPath } from \"node:url\"\nimport {\n createAgentCliRuntime,\n defineAgentCli,\n type AgentCliHandle,\n type AgentCliRuntime,\n} from \"@agentproto/driver-agent-cli\"\nimport { ANTHROPIC_GATEWAY_PRESETS } from \"@agentproto/provider-presets\"\nimport { DEFAULT_MODEL } from \"./options.js\"\n\n// Self-locating: the built handle spawns `node <this-dist>/cli.mjs acp`.\n// import.meta.url resolves into dist/ at runtime, where cli.mjs sits next to\n// index.mjs — so the same build works whether the daemon spawns it (resolved\n// from node_modules) or a user runs the published bin.\nconst cliEntry = fileURLToPath(new URL(\"./cli.mjs\", import.meta.url))\n\nexport const claudeSdk: AgentCliHandle = defineAgentCli({\n name: \"claude-sdk\",\n id: \"claude-sdk\",\n description:\n \"First-party agentproto adapter — Claude Code's agent harness run as a \" +\n \"library via the Claude Agent SDK's headless query(), behind an AIP-44 ACP \" +\n \"server. 100% Anthropic-native I/O: clean model pinning (options.model), \" +\n \"native per-turn usage (tokens + cost), and a custom base_url \" +\n \"(ANTHROPIC_BASE_URL) to front real Anthropic, Bedrock/Vertex/Azure, or an \" +\n \"Anthropic-compatible gateway. Spawned as `node cli.mjs acp` over stdio \" +\n \"JSON-RPC, or launched standalone via `agentproto-claude-sdk acp`.\",\n version: \"0.1.0\",\n bin: \"node\",\n bin_args: [cliEntry, \"acp\"],\n install: [\n {\n method: \"npm\",\n package: \"@agentproto/adapter-claude-sdk\",\n global: true,\n },\n ],\n // No external runtime to probe — the SDK's harness runs in the spawned node\n // process. A node version gate is enough to mark the arm ready.\n version_check: {\n cmd: \"node --version\",\n parse: \"(\\\\d+\\\\.\\\\d+\\\\.\\\\d+)\",\n range: \">=20.9.0\",\n timeout_ms: 5000,\n },\n auth: {\n ref: \"./claude-sdk.ACP.md\",\n // Auth is read from the spawn env by the SDK. Either an Anthropic key/token\n // (direct or via an Anthropic-compatible gateway), or the cloud-provider\n // toggles below.\n state: {\n env: [\n \"ANTHROPIC_API_KEY\",\n \"ANTHROPIC_AUTH_TOKEN\",\n \"CLAUDE_CODE_USE_BEDROCK\",\n \"CLAUDE_CODE_USE_VERTEX\",\n \"CLAUDE_CODE_USE_FOUNDRY\",\n ],\n },\n },\n // Billing-auth (opt-in — authEnforce defaults to \"when-configured\", so an\n // unconfigured spawn stays ambient/unchanged). provider \"anthropic\" ⇒\n // api-key mode SETS ANTHROPIC_API_KEY. Unlike the claude-code CLI wrapper,\n // the SDK's subscription/bearer var is ANTHROPIC_AUTH_TOKEN (see\n // options.ts / cli.ts) — so that's this adapter's authSubscription.setEnv,\n // with the CLI's CLAUDE_CODE_OAUTH_TOKEN scrubbed as the sibling credential.\n provider: \"anthropic\",\n authSubscription: {\n setEnv: \"ANTHROPIC_AUTH_TOKEN\",\n conflictEnv: [\"CLAUDE_CODE_OAUTH_TOKEN\"],\n },\n sandbox:\n \"In-process: the SDK harness runs inside the spawned node process, scoped \" +\n \"to the daemon's cwd. Tool-permission handling defaults to \" +\n \"bypassPermissions (override via CLAUDE_SDK_PERMISSION_MODE); the daemon \" +\n \"owns the surrounding sandbox.\",\n protocol: \"acp\",\n acp: \"./claude-sdk.ACP.md\",\n session: {\n mode: \"persistent\",\n idle_timeout_ms: 1_800_000,\n context_carryover: true,\n },\n models: {\n // A cheap Claude by default — this is the budget first-party arm.\n default: DEFAULT_MODEL,\n // Each entry states who serves it (`provider`) and, for a gateway model,\n // which mode below routes there (`mode`) — the mode pre-wires\n // ANTHROPIC_BASE_URL, so picking the model without it would send a\n // gateway id straight to real Anthropic. Native models need no mode:\n // `mode: default` is already this adapter's baseline. The `model`\n // option stays free-form, so any gateway id works even if it isn't\n // listed here.\n allowed: [\n // Native Anthropic — no mode switch needed\n { id: \"claude-haiku-4-5-20251001\", provider: \"anthropic\" },\n { id: \"claude-sonnet-5\", provider: \"anthropic\" },\n { id: \"claude-opus-4-8\", provider: \"anthropic\" },\n { id: \"claude-fable-5\", provider: \"anthropic\" },\n // Moonshot (Kimi) — mode: moonshot\n { id: \"kimi-k2.7-code\", provider: \"moonshot\", mode: \"moonshot\" },\n // OpenRouter — mode: openrouter\n { id: \"z-ai/glm-5.2\", provider: \"openrouter\", mode: \"openrouter\" },\n { id: \"deepseek/deepseek-v4-pro\", provider: \"openrouter\", mode: \"openrouter\" },\n { id: \"moonshotai/kimi-k2\", provider: \"openrouter\", mode: \"openrouter\" },\n ],\n env: {\n anthropic: \"ANTHROPIC_API_KEY\",\n },\n },\n capabilities: {\n streaming: true,\n // Claude Code's built-in tools (Read/Edit/Bash/…) and any injected MCP\n // tools run inside the harness and are relayed to the host as ACP\n // tool_call / tool_call_update updates (see acp-host.ts + message-map.ts).\n tool_calls: true,\n sub_agents: true,\n file_io: true,\n multimodal: false,\n // Turns resume via the SDK session store (options.resume), keyed by the\n // pinned session id.\n resumable: true,\n bidirectional: true,\n },\n // Gateway presets. The base_url/auth_token/thinking options already let a\n // caller front any Anthropic-compatible gateway by hand; these modes just\n // pre-wire the endpoint (and, for Moonshot, the model + --thinking) so the\n // caller only has to supply the key. The `model` option still overrides.\n modes: [\n {\n id: \"default\",\n description:\n \"Native Anthropic — the real Anthropic API (or whatever \" +\n \"ANTHROPIC_BASE_URL / cloud toggles the environment already sets). \" +\n \"Uses the native Claude models in `allowed`.\",\n },\n {\n id: ANTHROPIC_GATEWAY_PRESETS.moonshot.id,\n description:\n \"Moonshot (Kimi) gateway. Pre-wires ANTHROPIC_BASE_URL to Moonshot's \" +\n \"Anthropic-compatible endpoint, defaults the model to kimi-k2.7-code, \" +\n \"and enables --thinking (Kimi rejects a request without it). Supply the \" +\n \"Moonshot key via the `auth_token` option (or ANTHROPIC_AUTH_TOKEN); \" +\n \"override `model` for another Moonshot model.\",\n env: {\n ANTHROPIC_BASE_URL: ANTHROPIC_GATEWAY_PRESETS.moonshot.baseUrl,\n // cli.ts reads CLAUDE_SDK_MODEL as the model fallback (a `--model`\n // option still wins), so the mode ships a working default model.\n CLAUDE_SDK_MODEL: ANTHROPIC_GATEWAY_PRESETS.moonshot.defaultModel,\n // Declares this gateway's conventional credential source.\n // buildQueryOptions resolves the bearer from this env when no explicit\n // auth_token / ANTHROPIC_AUTH_TOKEN is set, and always scrubs the\n // ambient ANTHROPIC_API_KEY so it never reaches a non-Anthropic host.\n CLAUDE_SDK_GATEWAY_KEY_ENV: ANTHROPIC_GATEWAY_PRESETS.moonshot.keyEnv,\n },\n bin_args_append: [\"--thinking\"],\n },\n {\n id: ANTHROPIC_GATEWAY_PRESETS.openrouter.id,\n description:\n \"OpenRouter gateway. Pre-wires ANTHROPIC_BASE_URL to OpenRouter's \" +\n \"Anthropic-compatible endpoint. Pick a model via the `model` option \" +\n \"(e.g. 'z-ai/glm-5.2', 'deepseek/deepseek-v4-pro', 'moonshotai/kimi-k2') \" +\n \"and supply the OpenRouter key via `auth_token` (or ANTHROPIC_AUTH_TOKEN).\",\n env: {\n ANTHROPIC_BASE_URL: ANTHROPIC_GATEWAY_PRESETS.openrouter.baseUrl,\n // Conventional credential source for this gateway (see moonshot above).\n CLAUDE_SDK_GATEWAY_KEY_ENV: ANTHROPIC_GATEWAY_PRESETS.openrouter.keyEnv,\n },\n },\n {\n id: ANTHROPIC_GATEWAY_PRESETS.deepseek.id,\n description:\n \"DeepSeek gateway. Pre-wires ANTHROPIC_BASE_URL to DeepSeek's \" +\n \"Anthropic-compatible endpoint and defaults the model to \" +\n \"deepseek-v4-pro. Supply the DeepSeek key via the `auth_token` option \" +\n \"(or ANTHROPIC_AUTH_TOKEN); override `model` for deepseek-v4-flash. \" +\n \"Thinking is opt-in (DeepSeek accepts requests without it, unlike Kimi).\",\n env: {\n ANTHROPIC_BASE_URL: ANTHROPIC_GATEWAY_PRESETS.deepseek.baseUrl,\n // cli.ts reads CLAUDE_SDK_MODEL as the model fallback (a `--model`\n // option still wins), so the mode ships a working default model.\n CLAUDE_SDK_MODEL: ANTHROPIC_GATEWAY_PRESETS.deepseek.defaultModel,\n // Conventional credential source for this gateway (see moonshot above).\n CLAUDE_SDK_GATEWAY_KEY_ENV: ANTHROPIC_GATEWAY_PRESETS.deepseek.keyEnv,\n },\n },\n ],\n options: [\n {\n id: \"model\",\n // string (not enum) so any model id works without a code change — native\n // Claude ids, or a gateway id when a gateway mode is selected. Applied as\n // a `--model <id>` spawn arg → SDK options.model.\n type: \"string\" as const,\n description:\n \"Model id → SDK options.model, applied as a `--model` arg at spawn. \" +\n \"Native Claude (e.g. 'claude-opus-4-8', 'claude-sonnet-5') in the \" +\n \"default mode, or a gateway id when mode is moonshot/openrouter \" +\n \"(e.g. 'kimi-k2.7-code', 'z-ai/glm-5.2'). Omit for the mode's default.\",\n bin_args_template: [\"--model\", \"{value}\"],\n },\n {\n id: \"base_url\",\n // Injected into the child env as ANTHROPIC_BASE_URL — keeps the harness\n // Anthropic-native while fronting real Anthropic, a cloud provider, or an\n // Anthropic-compatible gateway (LiteLLM / claude-code-router). When set,\n // buildQueryOptions also pins every model tier to `model` (gateway mode).\n type: \"string\" as const,\n description:\n \"Custom Anthropic base URL. Injected as ANTHROPIC_BASE_URL in the \" +\n \"child env — front real Anthropic, Bedrock/Vertex/Azure, or an \" +\n \"Anthropic-compatible gateway. When set, every internal model tier \" +\n \"(opus/sonnet/haiku/small-fast) is pinned to `model` so a single-model \" +\n \"gateway never gets an unservable tier. Omit to use the default endpoint.\",\n env: { ANTHROPIC_BASE_URL: \"{value}\" },\n },\n {\n id: \"auth_token\",\n // Injected into the child env as ANTHROPIC_AUTH_TOKEN — the SDK sends it\n // as `Authorization: Bearer <token>`, which Anthropic-compatible gateways\n // (Moonshot, OpenRouter) accept. Pair with base_url for a per-spawn key.\n type: \"string\" as const,\n description:\n \"Bearer token for the Anthropic API or a compatible gateway. Injected \" +\n \"as ANTHROPIC_AUTH_TOKEN in the child env (sent as `Authorization: \" +\n \"Bearer`). Pair with base_url to target a gateway (e.g. Moonshot, \" +\n \"OpenRouter) with a per-spawn key instead of the ambient \" +\n \"ANTHROPIC_API_KEY. Omit to use ANTHROPIC_API_KEY from the environment.\",\n env: { ANTHROPIC_AUTH_TOKEN: \"{value}\" },\n },\n {\n id: \"thinking\",\n // Bare flag → cli.ts parses `--thinking` → SDK options.thinking =\n // { type: \"enabled\" }. Needed by thinking-gated gateway models such as\n // kimi-k2.7-code, which reject a request that omits `thinking`.\n type: \"boolean\" as const,\n description:\n \"Enable extended thinking (SDK options.thinking = { type: 'enabled' }). \" +\n \"Required by thinking-gated gateway models such as Moonshot's \" +\n \"kimi-k2.7-code, which reject a request without it. Off by default — \" +\n \"native Claude models choose their own thinking behaviour.\",\n bin_args_append_when_true: [\"--thinking\"],\n },\n ],\n tags: [\"anthropic\", \"claude\", \"claude-agent-sdk\", \"agentproto\", \"acp\", \"first-party\"],\n})\n\nexport function claudeSdkRuntime(): AgentCliRuntime {\n return createAgentCliRuntime(claudeSdk)\n}\n\nexport {\n ClaudeSdkAcpAgent,\n promptText,\n type QueryFn,\n} from \"./acp-host.js\"\nexport {\n buildQueryOptions,\n mapAcpMcpServers,\n DEFAULT_MODEL,\n type ClaudeSdkConfig,\n} from \"./options.js\"\nexport {\n sdkMessageToUpdates,\n assistantMessageUpdates,\n userMessageUpdates,\n resultUsageUpdate,\n systemInitSessionId,\n toolKindForClaudeTool,\n toolCallTitle,\n type UsageSessionUpdate,\n} from \"./message-map.js\"\nexport { runAcpOverStdio } from \"./run.js\"\nexport type { AgentCliHandle, AgentCliRuntime }\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;AAiCA,IAAM,WAAW,aAAA,CAAc,IAAI,IAAI,WAAA,EAAa,MAAA,CAAA,IAAA,CAAY,GAAG,CAAC,CAAA;AAE7D,IAAM,YAA4B,cAAA,CAAe;AAAA,EACtD,IAAA,EAAM,YAAA;AAAA,EACN,EAAA,EAAI,YAAA;AAAA,EACJ,WAAA,EACE,8eAAA;AAAA,EAOF,OAAA,EAAS,OAAA;AAAA,EACT,GAAA,EAAK,MAAA;AAAA,EACL,QAAA,EAAU,CAAC,QAAA,EAAU,KAAK,CAAA;AAAA,EAC1B,OAAA,EAAS;AAAA,IACP;AAAA,MACE,MAAA,EAAQ,KAAA;AAAA,MACR,OAAA,EAAS,gCAAA;AAAA,MACT,MAAA,EAAQ;AAAA;AACV,GACF;AAAA;AAAA;AAAA,EAGA,aAAA,EAAe;AAAA,IACb,GAAA,EAAK,gBAAA;AAAA,IACL,KAAA,EAAO,sBAAA;AAAA,IACP,KAAA,EAAO,UAAA;AAAA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A;AAAA,MAIF,yBAAA,EAA2B,CAAC,YAAY;AAAA;AAC1C,GACF;AAAA,EACA,MAAM,CAAC,WAAA,EAAa,UAAU,kBAAA,EAAoB,YAAA,EAAc,OAAO,aAAa;AACtF,CAAC;AAEM,SAAS,gBAAA,GAAoC;AAClD,EAAA,OAAO,sBAAsB,SAAS,CAAA;AACxC","file":"index.mjs","sourcesContent":["/**\n * @agentproto/adapter-claude-sdk — first-party adapter that runs Claude Code's\n * agent harness as a LIBRARY.\n *\n * Unlike `@agentproto/adapter-claude-code` (which wraps the third-party\n * `@agentclientprotocol/claude-agent-acp` bridge), this adapter drives the\n * Claude Agent SDK's headless `query()` directly behind an AIP-44 ACP server\n * (see ./acp-host.ts), shipped as a CLI bin (`agentproto-claude-sdk acp`). The\n * daemon spawns it like any other arm; a user can launch it standalone.\n *\n * Driving the SDK directly buys us clean model pinning (`options.model`, no\n * spawn-arg rejection — issue #186), native usage telemetry (a `usage_update`\n * per turn — #186 P3), and a custom `base_url` (`ANTHROPIC_BASE_URL`) that\n * points the same Anthropic-native harness at real Anthropic, Bedrock/Vertex/\n * Azure, or an Anthropic-compatible gateway.\n *\n * import { claudeSdk, claudeSdkRuntime } from \"@agentproto/adapter-claude-sdk\"\n */\n\nimport { fileURLToPath } from \"node:url\"\nimport {\n createAgentCliRuntime,\n defineAgentCli,\n type AgentCliHandle,\n type AgentCliRuntime,\n} from \"@agentproto/driver-agent-cli\"\nimport { ANTHROPIC_GATEWAY_PRESETS } from \"@agentproto/provider-presets\"\nimport { DEFAULT_MODEL } from \"./options.js\"\n\n// Self-locating: the built handle spawns `node <this-dist>/cli.mjs acp`.\n// import.meta.url resolves into dist/ at runtime, where cli.mjs sits next to\n// index.mjs — so the same build works whether the daemon spawns it (resolved\n// from node_modules) or a user runs the published bin.\nconst cliEntry = fileURLToPath(new URL(\"./cli.mjs\", import.meta.url))\n\nexport const claudeSdk: AgentCliHandle = defineAgentCli({\n name: \"claude-sdk\",\n id: \"claude-sdk\",\n description:\n \"First-party agentproto adapter — Claude Code's agent harness run as a \" +\n \"library via the Claude Agent SDK's headless query(), behind an AIP-44 ACP \" +\n \"server. 100% Anthropic-native I/O: clean model pinning (options.model), \" +\n \"native per-turn usage (tokens + cost), and a custom base_url \" +\n \"(ANTHROPIC_BASE_URL) to front real Anthropic, Bedrock/Vertex/Azure, or an \" +\n \"Anthropic-compatible gateway. Spawned as `node cli.mjs acp` over stdio \" +\n \"JSON-RPC, or launched standalone via `agentproto-claude-sdk acp`.\",\n version: \"0.1.0\",\n bin: \"node\",\n bin_args: [cliEntry, \"acp\"],\n install: [\n {\n method: \"npm\",\n package: \"@agentproto/adapter-claude-sdk\",\n global: true,\n },\n ],\n // No external runtime to probe — the SDK's harness runs in the spawned node\n // process. A node version gate is enough to mark the arm ready.\n version_check: {\n cmd: \"node --version\",\n parse: \"(\\\\d+\\\\.\\\\d+\\\\.\\\\d+)\",\n range: \">=20.9.0\",\n timeout_ms: 5000,\n },\n auth: {\n ref: \"./claude-sdk.ACP.md\",\n // Auth is read from the spawn env by the SDK. Either an Anthropic key/token\n // (direct or via an Anthropic-compatible gateway), or the cloud-provider\n // toggles below.\n state: {\n env: [\n \"ANTHROPIC_API_KEY\",\n \"ANTHROPIC_AUTH_TOKEN\",\n \"CLAUDE_CODE_USE_BEDROCK\",\n \"CLAUDE_CODE_USE_VERTEX\",\n \"CLAUDE_CODE_USE_FOUNDRY\",\n ],\n },\n },\n // Billing-auth (opt-in — authEnforce defaults to \"when-configured\", so an\n // unconfigured spawn stays ambient/unchanged). provider \"anthropic\" ⇒\n // api-key mode SETS ANTHROPIC_API_KEY. Unlike the claude-code CLI wrapper,\n // the SDK's subscription/bearer var is ANTHROPIC_AUTH_TOKEN (see\n // options.ts / cli.ts) — so that's this adapter's authSubscription.setEnv,\n // with the CLI's CLAUDE_CODE_OAUTH_TOKEN scrubbed as the sibling credential.\n provider: \"anthropic\",\n authSubscription: {\n setEnv: \"ANTHROPIC_AUTH_TOKEN\",\n conflictEnv: [\"CLAUDE_CODE_OAUTH_TOKEN\"],\n },\n sandbox:\n \"In-process: the SDK harness runs inside the spawned node process, scoped \" +\n \"to the daemon's cwd. Tool-permission handling defaults to \" +\n \"bypassPermissions (override via CLAUDE_SDK_PERMISSION_MODE); the daemon \" +\n \"owns the surrounding sandbox.\",\n protocol: \"acp\",\n acp: \"./claude-sdk.ACP.md\",\n session: {\n mode: \"persistent\",\n idle_timeout_ms: 1_800_000,\n context_carryover: true,\n },\n models: {\n // A cheap Claude by default — this is the budget first-party arm.\n default: DEFAULT_MODEL,\n // Each entry states who serves it (`provider`) and, for a gateway model,\n // which mode below routes there (`mode`) — the mode pre-wires\n // ANTHROPIC_BASE_URL, so picking the model without it would send a\n // gateway id straight to real Anthropic. Native models need no mode:\n // `mode: default` is already this adapter's baseline. The `model`\n // option stays free-form, so any gateway id works even if it isn't\n // listed here.\n allowed: [\n // Native Anthropic — no mode switch needed\n { id: \"claude-haiku-4-5-20251001\", provider: \"anthropic\" },\n { id: \"claude-sonnet-5\", provider: \"anthropic\" },\n { id: \"claude-opus-4-8\", provider: \"anthropic\" },\n { id: \"claude-fable-5\", provider: \"anthropic\" },\n // Moonshot (Kimi) — mode: moonshot\n { id: \"kimi-k2.7-code\", provider: \"moonshot\", mode: \"moonshot\" },\n // OpenRouter — mode: openrouter\n { id: \"z-ai/glm-5.2\", provider: \"openrouter\", mode: \"openrouter\" },\n { id: \"deepseek/deepseek-v4-pro\", provider: \"openrouter\", mode: \"openrouter\" },\n { id: \"moonshotai/kimi-k2\", provider: \"openrouter\", mode: \"openrouter\" },\n ],\n env: {\n anthropic: \"ANTHROPIC_API_KEY\",\n },\n },\n capabilities: {\n streaming: true,\n // Claude Code's built-in tools (Read/Edit/Bash/…) and any injected MCP\n // tools run inside the harness and are relayed to the host as ACP\n // tool_call / tool_call_update updates (see acp-host.ts + message-map.ts).\n tool_calls: true,\n sub_agents: true,\n file_io: true,\n multimodal: false,\n // Turns resume via the SDK session store (options.resume), keyed by the\n // pinned session id.\n resumable: true,\n bidirectional: true,\n },\n // Gateway presets. The base_url/auth_token/thinking options already let a\n // caller front any Anthropic-compatible gateway by hand; these modes just\n // pre-wire the endpoint (and, for Moonshot, the model + --thinking) so the\n // caller only has to supply the key. The `model` option still overrides.\n modes: [\n {\n id: \"default\",\n description:\n \"Native Anthropic — the real Anthropic API (or whatever \" +\n \"ANTHROPIC_BASE_URL / cloud toggles the environment already sets). \" +\n \"Uses the native Claude models in `allowed`.\",\n },\n {\n id: ANTHROPIC_GATEWAY_PRESETS.moonshot.id,\n description:\n \"Moonshot (Kimi) gateway. Pre-wires ANTHROPIC_BASE_URL to Moonshot's \" +\n \"Anthropic-compatible endpoint, defaults the model to kimi-k2.7-code, \" +\n \"and enables --thinking (Kimi rejects a request without it). Supply the \" +\n \"Moonshot key via the `auth_token` option (or ANTHROPIC_AUTH_TOKEN); \" +\n \"override `model` for another Moonshot model.\",\n env: {\n ANTHROPIC_BASE_URL: ANTHROPIC_GATEWAY_PRESETS.moonshot.baseUrl,\n // cli.ts reads CLAUDE_SDK_MODEL as the model fallback (a `--model`\n // option still wins), so the mode ships a working default model.\n CLAUDE_SDK_MODEL: ANTHROPIC_GATEWAY_PRESETS.moonshot.defaultModel,\n // Declares this gateway's conventional credential source.\n // buildQueryOptions resolves the bearer from this env when no explicit\n // auth_token / ANTHROPIC_AUTH_TOKEN is set, and always scrubs the\n // ambient ANTHROPIC_API_KEY so it never reaches a non-Anthropic host.\n CLAUDE_SDK_GATEWAY_KEY_ENV: ANTHROPIC_GATEWAY_PRESETS.moonshot.keyEnv,\n },\n bin_args_append: [\"--thinking\"],\n },\n {\n id: ANTHROPIC_GATEWAY_PRESETS.openrouter.id,\n description:\n \"OpenRouter gateway. Pre-wires ANTHROPIC_BASE_URL to OpenRouter's \" +\n \"Anthropic-compatible endpoint. Pick a model via the `model` option \" +\n \"(e.g. 'z-ai/glm-5.2', 'deepseek/deepseek-v4-pro', 'moonshotai/kimi-k2') \" +\n \"and supply the OpenRouter key via `auth_token` (or ANTHROPIC_AUTH_TOKEN).\",\n env: {\n ANTHROPIC_BASE_URL: ANTHROPIC_GATEWAY_PRESETS.openrouter.baseUrl,\n // Conventional credential source for this gateway (see moonshot above).\n CLAUDE_SDK_GATEWAY_KEY_ENV: ANTHROPIC_GATEWAY_PRESETS.openrouter.keyEnv,\n },\n },\n {\n id: ANTHROPIC_GATEWAY_PRESETS.requesty.id,\n description:\n \"Requesty gateway. Pre-wires ANTHROPIC_BASE_URL to Requesty's \" +\n \"Anthropic-compatible endpoint. Pick a model via the `model` option \" +\n \"(e.g. 'sference/thinkingcap-qwen3.6-27b', 'sference/glm-5.2') and \" +\n \"supply the Requesty key via `auth_token` (or ANTHROPIC_AUTH_TOKEN). \" +\n \"buildQueryOptions pins every model tier — including \" +\n \"ANTHROPIC_SMALL_FAST_MODEL — to that one model, since Requesty serves \" +\n \"no Claude-named tiers.\",\n env: {\n ANTHROPIC_BASE_URL: ANTHROPIC_GATEWAY_PRESETS.requesty.baseUrl,\n // Conventional credential source for this gateway (see moonshot above).\n CLAUDE_SDK_GATEWAY_KEY_ENV: ANTHROPIC_GATEWAY_PRESETS.requesty.keyEnv,\n },\n },\n {\n id: ANTHROPIC_GATEWAY_PRESETS.deepseek.id,\n description:\n \"DeepSeek gateway. Pre-wires ANTHROPIC_BASE_URL to DeepSeek's \" +\n \"Anthropic-compatible endpoint and defaults the model to \" +\n \"deepseek-v4-pro. Supply the DeepSeek key via the `auth_token` option \" +\n \"(or ANTHROPIC_AUTH_TOKEN); override `model` for deepseek-v4-flash. \" +\n \"Thinking is opt-in (DeepSeek accepts requests without it, unlike Kimi).\",\n env: {\n ANTHROPIC_BASE_URL: ANTHROPIC_GATEWAY_PRESETS.deepseek.baseUrl,\n // cli.ts reads CLAUDE_SDK_MODEL as the model fallback (a `--model`\n // option still wins), so the mode ships a working default model.\n CLAUDE_SDK_MODEL: ANTHROPIC_GATEWAY_PRESETS.deepseek.defaultModel,\n // Conventional credential source for this gateway (see moonshot above).\n CLAUDE_SDK_GATEWAY_KEY_ENV: ANTHROPIC_GATEWAY_PRESETS.deepseek.keyEnv,\n },\n },\n ],\n options: [\n {\n id: \"model\",\n // string (not enum) so any model id works without a code change — native\n // Claude ids, or a gateway id when a gateway mode is selected. Applied as\n // a `--model <id>` spawn arg → SDK options.model.\n type: \"string\" as const,\n description:\n \"Model id → SDK options.model, applied as a `--model` arg at spawn. \" +\n \"Native Claude (e.g. 'claude-opus-4-8', 'claude-sonnet-5') in the \" +\n \"default mode, or a gateway id when mode is moonshot/openrouter \" +\n \"(e.g. 'kimi-k2.7-code', 'z-ai/glm-5.2'). Omit for the mode's default.\",\n bin_args_template: [\"--model\", \"{value}\"],\n },\n {\n id: \"base_url\",\n // Injected into the child env as ANTHROPIC_BASE_URL — keeps the harness\n // Anthropic-native while fronting real Anthropic, a cloud provider, or an\n // Anthropic-compatible gateway (LiteLLM / claude-code-router). When set,\n // buildQueryOptions also pins every model tier to `model` (gateway mode).\n type: \"string\" as const,\n description:\n \"Custom Anthropic base URL. Injected as ANTHROPIC_BASE_URL in the \" +\n \"child env — front real Anthropic, Bedrock/Vertex/Azure, or an \" +\n \"Anthropic-compatible gateway. When set, every internal model tier \" +\n \"(opus/sonnet/haiku/small-fast) is pinned to `model` so a single-model \" +\n \"gateway never gets an unservable tier. Omit to use the default endpoint.\",\n env: { ANTHROPIC_BASE_URL: \"{value}\" },\n },\n {\n id: \"auth_token\",\n // Injected into the child env as ANTHROPIC_AUTH_TOKEN — the SDK sends it\n // as `Authorization: Bearer <token>`, which Anthropic-compatible gateways\n // (Moonshot, OpenRouter) accept. Pair with base_url for a per-spawn key.\n type: \"string\" as const,\n description:\n \"Bearer token for the Anthropic API or a compatible gateway. Injected \" +\n \"as ANTHROPIC_AUTH_TOKEN in the child env (sent as `Authorization: \" +\n \"Bearer`). Pair with base_url to target a gateway (e.g. Moonshot, \" +\n \"OpenRouter) with a per-spawn key instead of the ambient \" +\n \"ANTHROPIC_API_KEY. Omit to use ANTHROPIC_API_KEY from the environment.\",\n env: { ANTHROPIC_AUTH_TOKEN: \"{value}\" },\n },\n {\n id: \"thinking\",\n // Bare flag → cli.ts parses `--thinking` → SDK options.thinking =\n // { type: \"enabled\" }. Needed by thinking-gated gateway models such as\n // kimi-k2.7-code, which reject a request that omits `thinking`.\n type: \"boolean\" as const,\n description:\n \"Enable extended thinking (SDK options.thinking = { type: 'enabled' }). \" +\n \"Required by thinking-gated gateway models such as Moonshot's \" +\n \"kimi-k2.7-code, which reject a request without it. Off by default — \" +\n \"native Claude models choose their own thinking behaviour.\",\n bin_args_append_when_true: [\"--thinking\"],\n },\n ],\n tags: [\"anthropic\", \"claude\", \"claude-agent-sdk\", \"agentproto\", \"acp\", \"first-party\"],\n})\n\nexport function claudeSdkRuntime(): AgentCliRuntime {\n return createAgentCliRuntime(claudeSdk)\n}\n\nexport {\n ClaudeSdkAcpAgent,\n promptText,\n type QueryFn,\n} from \"./acp-host.js\"\nexport {\n buildQueryOptions,\n mapAcpMcpServers,\n DEFAULT_MODEL,\n type ClaudeSdkConfig,\n} from \"./options.js\"\nexport {\n sdkMessageToUpdates,\n assistantMessageUpdates,\n userMessageUpdates,\n resultUsageUpdate,\n systemInitSessionId,\n toolKindForClaudeTool,\n toolCallTitle,\n type UsageSessionUpdate,\n} from \"./message-map.js\"\nexport { runAcpOverStdio } from \"./run.js\"\nexport type { AgentCliHandle, AgentCliRuntime }\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentproto/adapter-claude-sdk",
3
- "version": "0.3.1",
3
+ "version": "0.4.1",
4
4
  "description": "@agentproto/adapter-claude-sdk — first-party agentproto adapter that runs Claude Code's agent harness as a library via the Claude Agent SDK headless query(), behind an AIP-44 ACP server. 100% Anthropic-native I/O; clean model pinning + base_url; native usage telemetry.",
5
5
  "keywords": [
6
6
  "agentproto",
@@ -49,8 +49,8 @@
49
49
  "dependencies": {
50
50
  "@agentclientprotocol/sdk": "^0.21.0",
51
51
  "@anthropic-ai/claude-agent-sdk": "^0.3.200",
52
- "@agentproto/driver-agent-cli": "1.1.0",
53
- "@agentproto/provider-presets": "0.3.0"
52
+ "@agentproto/driver-agent-cli": "2.0.0",
53
+ "@agentproto/provider-presets": "0.4.1"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/node": "^25.6.2",