@byokkit/cmd-provider-anthropic 0.1.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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/server/index.ts","../../src/server/anthropic-oauth-fetch.ts"],"sourcesContent":["// @byokkit/cmd-provider-anthropic/server — the SERVER half of the Anthropic provider: everything\n// the API worker needs to talk to api.anthropic.com on a user's behalf. Lives here (not in the\n// api package, not in shared) so the WHOLE provider — CLI OAuth, model catalog, and server wire\n// glue — ships as one package that can move to its own repo. The api worker imports these\n// factories and keeps zero Anthropic-specific logic of its own.\n//\n// Dependency note: '@ai-sdk/anthropic' is a real dependency of THIS package (declared in its\n// package.json). The CLI entry ('.') never imports this subpath, so CLI bundles don't pull the\n// AI SDK in.\n\nimport {createAnthropic} from '@ai-sdk/anthropic';\nimport {\n\tcreateAnthropicOAuthFetch,\n\tOAUTH_BETAS,\n} from './anthropic-oauth-fetch.js';\n\nexport {createAnthropicOAuthFetch} from './anthropic-oauth-fetch.js';\n\n// anthropic-beta header sets per auth mode. The OAuth set aliases the fetch's own OAUTH_BETAS —\n// createAnthropicOAuthFetch overwrites the header with that string on every request, so a\n// separate literal here would be dead on the wire and could silently drift.\nexport const ANTHROPIC_BETA_OAUTH = OAUTH_BETAS;\nexport const ANTHROPIC_BETA_API_KEY =\n\t'web-search-2025-03-05,web-fetch-2025-09-10';\n// (The Copilot-serves-Claude beta lives with the Copilot provider now:\n// COPILOT_ANTHROPIC_BETA in @byokkit/cmd-provider-copilot/server.)\n\nexport interface AnthropicLanguageModelParams {\n\treadonly modelId: string;\n\t/** ChatGPT-style OAuth token (Claude Pro/Max). Wins over apiKey when set. */\n\treadonly oAuthToken?: string | null;\n\t/** ANTHROPIC_API_KEY fallback for the key-auth path. */\n\treadonly apiKey?: string;\n}\n\n/**\n * Build the AI-SDK language model for an Anthropic request — OAuth (custom fetch: Bearer auth,\n * ?beta=true, Claude Code spoof, cc_ tool prefixing, cache_control preservation) or plain API\n * key. Returned as unknown; the api worker casts to its LanguageModelV3 like it always did.\n */\nexport function getAnthropicLanguageModel(\n\tparams: AnthropicLanguageModelParams,\n): unknown {\n\tif (params.oAuthToken) {\n\t\tconst anthropic = createAnthropic({\n\t\t\tapiKey: 'placeholder',\n\t\t\theaders: {\n\t\t\t\t'anthropic-beta': ANTHROPIC_BETA_OAUTH,\n\t\t\t},\n\t\t\tfetch: createAnthropicOAuthFetch(params.oAuthToken),\n\t\t});\n\t\treturn anthropic(params.modelId);\n\t}\n\tconst anthropic = createAnthropic({\n\t\tapiKey: params.apiKey,\n\t\theaders: {\n\t\t\t'anthropic-beta': ANTHROPIC_BETA_API_KEY,\n\t\t},\n\t});\n\treturn anthropic(params.modelId);\n}\n","/**\n * Custom fetch for Anthropic OAuth compatibility with @ai-sdk/anthropic.\n *\n */\n\n// Exported so server/index.ts can alias it as ANTHROPIC_BETA_OAUTH: this fetch unconditionally\n// overwrites the anthropic-beta header with this string, so any advertised OAuth beta set must\n// be THIS value — a separate literal elsewhere would be silently ignored on the wire.\nexport const OAUTH_BETAS =\n\t'oauth-2025-04-20,interleaved-thinking-2025-05-14,web-search-2025-03-05,web-fetch-2025-09-10';\nconst TOOL_PREFIX = 'cc_';\nconst CLAUDE_CODE_VERSION = '2.1.76';\nconst CLAUDE_CODE_USER_AGENT = `claude-code/${CLAUDE_CODE_VERSION}`;\nconst BILLING_SALT = '59cf53e54c78';\n\nasync function sha256Hex(input: string): Promise<string> {\n\tconst data = new TextEncoder().encode(input);\n\tconst hashBuffer = await crypto.subtle.digest('SHA-256', data);\n\treturn Array.from(new Uint8Array(hashBuffer))\n\t\t.map(b => b.toString(16).padStart(2, '0'))\n\t\t.join('');\n}\n\nfunction sampleJsCodeUnit(text: string, idx: number): string {\n\t// Encode as UTF-16 and get the nth code unit\n\tlet pos = 0;\n\tfor (let i = 0; i < text.length; i++) {\n\t\tconst code = text.charCodeAt(i);\n\t\tif (pos === idx) return String.fromCharCode(code);\n\t\tpos++;\n\t\t// Handle surrogate pairs\n\t\tif (code >= 0xd800 && code <= 0xdbff) {\n\t\t\tif (pos === idx) return String.fromCharCode(text.charCodeAt(i + 1));\n\t\t\tpos++;\n\t\t\ti++;\n\t\t}\n\t}\n\treturn '0';\n}\n\nfunction extractFirstUserMessage(\n\tmessages: Array<Record<string, unknown>>,\n): string {\n\tfor (const msg of messages) {\n\t\tif (msg.role !== 'user') continue;\n\t\tif (typeof msg.content === 'string') return msg.content;\n\t\tif (Array.isArray(msg.content)) {\n\t\t\tfor (const block of msg.content) {\n\t\t\t\tconst b = block as Record<string, unknown>;\n\t\t\t\tif (b.type === 'text' && typeof b.text === 'string')\n\t\t\t\t\treturn b.text as string;\n\t\t\t}\n\t\t}\n\t}\n\treturn '';\n}\n\nasync function buildBillingBlock(\n\tmessages: Array<Record<string, unknown>>,\n): Promise<string> {\n\tconst firstMsg = extractFirstUserMessage(messages);\n\tconst sampled = [4, 7, 20]\n\t\t.map(idx => sampleJsCodeUnit(firstMsg, idx))\n\t\t.join('');\n\tconst versionHash = await sha256Hex(\n\t\t`${BILLING_SALT}${sampled}${CLAUDE_CODE_VERSION}`,\n\t);\n\treturn `x-anthropic-billing-header: cc_version=${CLAUDE_CODE_VERSION}.${versionHash.slice(0, 3)}; cc_entrypoint=cli; cch=00000;`;\n}\n\n// Brand-spoof rename for the OAuth path (OAuth tokens are provisioned for\n// Claude Code traffic, so the system prompt must not name a different\n// product). The rename must NEVER touch a match embedded in a path or\n// identifier: the blind replace corrupted real filesystem paths — a working\n// directory like ~/Sandbox/commandcode-aa1 reached the model as\n// ~/Sandbox/claude-aa1, so it wrote files into a directory that doesn't\n// exist, and every `.commandcode/` config path (taste/agents/skills) plus\n// commandcode.ai support URL was rewritten to something wrong. The\n// lookarounds skip any occurrence adjacent to path separators, dots,\n// dashes, underscores, `~`, or other word characters — only prose mentions\n// of the product name are renamed.\nconst BRAND_SPOOF_RULES: ReadonlyArray<{\n\treadonly pattern: RegExp;\n\treadonly replacement: string;\n}> = [\n\t{\n\t\tpattern: /(?<![\\w./\\\\~-])Command Code(?![\\w-])/g,\n\t\treplacement: 'Claude Code',\n\t},\n\t{\n\t\tpattern: /(?<![\\w./\\\\~-])commandcode(?![\\w-])/gi,\n\t\treplacement: 'claude',\n\t},\n];\n\nfunction spoofBrandText(text: string): string {\n\tlet result = text;\n\tfor (const rule of BRAND_SPOOF_RULES) {\n\t\tresult = result.replace(rule.pattern, rule.replacement);\n\t}\n\treturn result;\n}\n\nfunction prefixOAuthToolName(\n\ttool: Record<string, unknown>,\n): Record<string, unknown> {\n\tconst name = tool.name as string | undefined;\n\tconst type = tool.type as string | undefined;\n\n\t// Don't prefix if no name or if it's a server-side web tool\n\tif (!name || type?.includes('web_')) {\n\t\treturn tool;\n\t}\n\n\treturn {\n\t\t...tool,\n\t\tname: `${TOOL_PREFIX}${name}`,\n\t};\n}\n\nfunction cleanOAuthMessageBlock(\n\tblock: Record<string, unknown>,\n): Record<string, unknown> {\n\tconst cleaned = {...block};\n\n\tif (cleaned.type === 'tool_use') {\n\t\treturn prefixOAuthToolName(cleaned);\n\t}\n\n\treturn cleaned;\n}\n\nfunction cleanOAuthMessage(\n\tmessage: Record<string, unknown>,\n): Record<string, unknown> {\n\tif (!message.content || !Array.isArray(message.content)) {\n\t\treturn message;\n\t}\n\n\treturn {\n\t\t...message,\n\t\tcontent: message.content.map((block: Record<string, unknown>) =>\n\t\t\tcleanOAuthMessageBlock(block),\n\t\t),\n\t};\n}\n\nexport function createAnthropicOAuthFetch(\n\toauthToken: string,\n): typeof globalThis.fetch {\n\treturn async (input, init) => {\n\t\tconst requestHeaders = new Headers(\n\t\t\tinit?.headers as ConstructorParameters<typeof Headers>[0],\n\t\t);\n\n\t\t// Set OAuth auth and strip API key\n\t\trequestHeaders.set('authorization', `Bearer ${oauthToken}`);\n\t\trequestHeaders.delete('x-api-key');\n\n\t\t// Replace SDK auto-added betas with OAuth betas\n\t\trequestHeaders.set('anthropic-beta', OAUTH_BETAS);\n\t\trequestHeaders.set('user-agent', CLAUDE_CODE_USER_AGENT);\n\n\t\t// Modify request body for OAuth compatibility\n\t\tlet body = init?.body;\n\t\tif (body && typeof body === 'string') {\n\t\t\ttry {\n\t\t\t\tconst parsed = JSON.parse(body);\n\t\t\t\t// Remove fields the OAuth API doesn't accept\n\t\t\t\tdelete parsed.tool_choice;\n\t\t\t\tdelete parsed.top_k;\n\t\t\t\tdelete parsed.top_p;\n\t\t\t\tdelete parsed.stop_sequences;\n\t\t\t\tfor (const key of Object.keys(parsed)) {\n\t\t\t\t\tif (parsed[key] === undefined || parsed[key] === null)\n\t\t\t\t\t\tdelete parsed[key];\n\t\t\t\t}\n\n\t\t\t\t// Build billing block and prepend to system\n\t\t\t\tconst billingText = await buildBillingBlock(\n\t\t\t\t\tparsed.messages || [],\n\t\t\t\t);\n\t\t\t\tconst billingBlock = {type: 'text', text: billingText};\n\t\t\t\tif (parsed.system && Array.isArray(parsed.system)) {\n\t\t\t\t\tparsed.system = [\n\t\t\t\t\t\tbillingBlock,\n\t\t\t\t\t\t...parsed.system.map(\n\t\t\t\t\t\t\t(item: Record<string, unknown>) => {\n\t\t\t\t\t\t\t\tconst cleaned = {...item};\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tcleaned.type === 'text' &&\n\t\t\t\t\t\t\t\t\ttypeof cleaned.text === 'string'\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tcleaned.text = spoofBrandText(\n\t\t\t\t\t\t\t\t\t\tcleaned.text as string,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn cleaned;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t),\n\t\t\t\t\t];\n\t\t\t\t} else if (typeof parsed.system === 'string') {\n\t\t\t\t\tparsed.system = [\n\t\t\t\t\t\tbillingBlock,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\ttext: spoofBrandText(parsed.system),\n\t\t\t\t\t\t},\n\t\t\t\t\t];\n\t\t\t\t} else {\n\t\t\t\t\tparsed.system = [billingBlock];\n\t\t\t\t}\n\n\t\t\t\t// Prefix tool names (skip server-side web tools — they must keep original names)\n\t\t\t\tif (parsed.tools && Array.isArray(parsed.tools)) {\n\t\t\t\t\tparsed.tools = parsed.tools.map(prefixOAuthToolName);\n\t\t\t\t}\n\t\t\t\t// Prefix tool_use blocks in messages while preserving cache_control.\n\t\t\t\tif (parsed.messages && Array.isArray(parsed.messages)) {\n\t\t\t\t\tparsed.messages = parsed.messages.map(cleanOAuthMessage);\n\t\t\t\t}\n\t\t\t\tbody = JSON.stringify(parsed);\n\t\t\t} catch {\n\t\t\t\t// ignore parse errors\n\t\t\t}\n\t\t}\n\n\t\t// Add ?beta=true query parameter\n\t\tlet requestInput = input;\n\t\ttry {\n\t\t\tconst url = new URL(\n\t\t\t\ttypeof input === 'string'\n\t\t\t\t\t? input\n\t\t\t\t\t: input instanceof URL\n\t\t\t\t\t\t? input.toString()\n\t\t\t\t\t\t: (input as Request).url,\n\t\t\t);\n\t\t\tif (\n\t\t\t\turl.pathname === '/v1/messages' &&\n\t\t\t\t!url.searchParams.has('beta')\n\t\t\t) {\n\t\t\t\turl.searchParams.set('beta', 'true');\n\t\t\t\trequestInput =\n\t\t\t\t\tinput instanceof Request\n\t\t\t\t\t\t? new Request(url.toString(), input)\n\t\t\t\t\t\t: url;\n\t\t\t}\n\t\t} catch {}\n\n\t\tconst response = await globalThis.fetch(requestInput, {\n\t\t\t...init,\n\t\t\tbody,\n\t\t\theaders: requestHeaders,\n\t\t});\n\n\t\t// Strip cc_ prefix from tool names in streaming response. Network chunks split at\n\t\t// arbitrary byte offsets, so the `\"name\": \"cc_…\"` fragment can span two reads — the\n\t\t// rewrite must only ever run on complete SSE lines. Decoded text accumulates in\n\t\t// `carry` and everything up to the last newline is rewritten and forwarded; the\n\t\t// remainder waits for the next chunk. SSE data lines are complete JSON documents,\n\t\t// so a line boundary guarantees the name field is whole.\n\t\tif (response.body) {\n\t\t\tconst reader = response.body.getReader();\n\t\t\tconst decoder = new TextDecoder();\n\t\t\tconst encoder = new TextEncoder();\n\t\t\tconst stripToolPrefix = (text: string): string =>\n\t\t\t\ttext.replace(/\"name\"\\s*:\\s*\"cc_([^\"]+)\"/g, '\"name\": \"$1\"');\n\t\t\tlet carry = '';\n\t\t\tconst stream = new ReadableStream({\n\t\t\t\tasync pull(controller) {\n\t\t\t\t\tconst {done, value} = await reader.read();\n\t\t\t\t\tif (done) {\n\t\t\t\t\t\tcarry += decoder.decode();\n\t\t\t\t\t\tif (carry) {\n\t\t\t\t\t\t\tcontroller.enqueue(\n\t\t\t\t\t\t\t\tencoder.encode(stripToolPrefix(carry)),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tcarry = '';\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontroller.close();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tcarry += decoder.decode(value, {stream: true});\n\t\t\t\t\tconst boundary = carry.lastIndexOf('\\n');\n\t\t\t\t\t// No complete line yet — keep buffering; pull() is invoked again as\n\t\t\t\t\t// long as the consumer wants data.\n\t\t\t\t\tif (boundary === -1) return;\n\t\t\t\t\tconst complete = carry.slice(0, boundary + 1);\n\t\t\t\t\tcarry = carry.slice(boundary + 1);\n\t\t\t\t\tcontroller.enqueue(\n\t\t\t\t\t\tencoder.encode(stripToolPrefix(complete)),\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t});\n\t\t\treturn new Response(stream, {\n\t\t\t\tstatus: response.status,\n\t\t\t\tstatusText: response.statusText,\n\t\t\t\theaders: response.headers,\n\t\t\t});\n\t\t}\n\t\treturn response;\n\t};\n}\n"],"mappings":";AAUA,SAAQ,uBAAsB;;;ACFvB,IAAM,cACZ;AACD,IAAM,cAAc;AACpB,IAAM,sBAAsB;AAC5B,IAAM,yBAAyB,eAAe,mBAAmB;A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BAAW;AAAA,YACV,QAAQ,OAAO,gBAAgB,QAAQ,CAAC;AAAA,UACzC;AAAA,QACD;AAAA,MACD,CAAC;AACD,aAAO,IAAI,SAAS,QAAQ;AAAA,QAC3B,QAAQ,SAAS;AAAA,QACjB,YAAY,SAAS;AAAA,QACrB,SAAS,SAAS;AAAA,MACnB,CAAC;AAAA,IACF;AACA,WAAO;AAAA,EACR;AACD;;;ADzRO,IAAM,uBAAuB;AAC7B,IAAM,yBACZ;AAiBM,SAAS,0BACf,QACU;AACV,MAAI,OAAO,YAAY;AACtB,UAAMA,aAAY,gBAAgB;AAAA,MACjC,QAAQ;AAAA,MACR,SAAS;AAAA,QACR,kBAAkB;AAAA,MACnB;AAAA,MACA,OAAO,0BAA0B,OAAO,UAAU;AAAA,IACnD,CAAC;AACD,WAAOA,WAAU,OAAO,OAAO;AAAA,EAChC;AACA,QAAM,YAAY,gBAAgB;AAAA,IACjC,QAAQ,OAAO;AAAA,IACf,SAAS;AAAA,MACR,kBAAkB;AAAA,IACnB;AAAA,EACD,CAAC;AACD,SAAO,UAAU,OAAO,OAAO;AAChC;","names":["anthropic"]}
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@byokkit/cmd-provider-anthropic",
3
+ "version": "0.1.0",
4
+ "description": "External BYOK provider for Anthropic in cmd.",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "import": "./dist/index.js",
9
+ "types": "./dist/index.d.ts"
10
+ },
11
+ "./models": {
12
+ "import": "./dist/models.js",
13
+ "types": "./dist/models.d.ts"
14
+ },
15
+ "./server": {
16
+ "import": "./dist/server/index.js",
17
+ "types": "./dist/server/index.d.ts"
18
+ }
19
+ },
20
+ "main": "./dist/index.js",
21
+ "types": "./dist/index.d.ts",
22
+ "files": [
23
+ "dist"
24
+ ],
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "scripts": {
29
+ "build": "tsup",
30
+ "dev": "tsup --watch",
31
+ "typecheck": "tsc --noEmit",
32
+ "test": "vitest run"
33
+ },
34
+ "dependencies": {
35
+ "@ai-sdk/anthropic": "^3.0.77"
36
+ },
37
+ "devDependencies": {
38
+ "@commandcode/harness": "workspace:*",
39
+ "@types/node": "^24.2.0",
40
+ "tsup": "^8.5.0",
41
+ "typescript": "^5.9.2",
42
+ "vitest": "^4.1.6"
43
+ }
44
+ }