@jeffreycao/copilot-api 1.11.6 → 1.12.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/README.md +2 -1
- package/README.zh-CN.md +2 -1
- package/dist/{auth-BOghei1C.js → auth-DIHsuzzC.js} +2 -2
- package/dist/{auth-BOghei1C.js.map → auth-DIHsuzzC.js.map} +1 -1
- package/dist/{check-usage-BuLKteH9.js → check-usage-De_AMKLc.js} +2 -2
- package/dist/{check-usage-BuLKteH9.js.map → check-usage-De_AMKLc.js.map} +1 -1
- package/dist/main.js +3 -3
- package/dist/{server-BoJeL2Ok.js → server-f_gmacXT.js} +26 -4
- package/dist/server-f_gmacXT.js.map +1 -0
- package/dist/{start-Cc04L2jJ.js → start-BAHLvLkh.js} +3 -3
- package/dist/{start-Cc04L2jJ.js.map → start-BAHLvLkh.js.map} +1 -1
- package/dist/{token-hMKJBqzT.js → token-Nj-1C8tP.js} +4 -4
- package/dist/{token-hMKJBqzT.js.map → token-Nj-1C8tP.js.map} +1 -1
- package/package.json +4 -2
- package/dist/server-BoJeL2Ok.js.map +0 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ English | [简体中文](./README.zh-CN.md)
|
|
|
7
7
|
> [!IMPORTANT]
|
|
8
8
|
> **Before using, please be aware of the following:**
|
|
9
9
|
>
|
|
10
|
-
> 1. **Claude Code configuration:** When using with Claude Code, please configure the model ID as `claude-opus-4-6` or `claude-opus-4.6
|
|
10
|
+
> 1. **Claude Code configuration:** When using with Claude Code, please configure the model ID as `claude-opus-4-6` or `claude-opus-4.6`. Example claude `settings.json` see [Manual Configuration with `settings.json`](#manual-configuration-with-settingsjson).
|
|
11
11
|
>
|
|
12
12
|
> 2. **Recommend for Opencode:** For opencode, prefer the opencode OAuth app. It matches opencode's built-in GitHub Copilot provider and avoids Terms of Service risk:
|
|
13
13
|
> ```sh
|
|
@@ -424,6 +424,7 @@ Here is an example `.claude/settings.json` file:
|
|
|
424
424
|
- Turning off CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION and CLAUDE_CODE_ENABLE_AWAY_SUMMARY can prevent quota from being consumed unnecessarily.
|
|
425
425
|
- Claude Code WebSearch is supported for pure search requests. For Copilot, keep the global `messageApiWebSearchModel` set to a Responses-capable GPT model or a `provider/model` alias. For provider routes, use a native Anthropic provider or an `openai-responses` provider. Add `WebSearch` to `permissions.deny` only if you want to forbid this traffic.
|
|
426
426
|
- If using a non-Claude model, do not enable ENABLE_TOOL_SEARCH. If using the Claude model, can enable ENABLE_TOOL_SEARCH. The current Claude Code uses the client tool search mode. In this mode, loading defer tools requires an additional request each time.
|
|
427
|
+
- `CLAUDE_CODE_AUTO_COMPACT_WINDOW`: Set the context capacity in tokens used for auto-compaction calculations. Defaults to the model's context window: 200K for standard models or 1M for extended context models. Use a lower value like `500000` on a 1M model (e.g., `claude-opus-4-6[1m]`) to treat the window as 500K for compaction purposes. The value is capped at the model's actual context window. `CLAUDE_AUTOCOMPACT_PCT_OVERRIDE` is applied as a percentage of this value. Setting this variable decouples the compaction threshold from the status line's `used_percentage`, which always uses the model's full context window.
|
|
427
428
|
|
|
428
429
|
You can find more options here: [Claude Code settings](https://docs.anthropic.com/en/docs/claude-code/settings#environment-variables)
|
|
429
430
|
|
package/README.zh-CN.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
> [!IMPORTANT]
|
|
8
8
|
> **使用前请先注意以下几点:**
|
|
9
9
|
>
|
|
10
|
-
> 1. **Claude Code 配置:** 与 Claude Code 搭配使用时,请将模型 ID 配置为 `claude-opus-4-6` 或 `claude-opus-4.6
|
|
10
|
+
> 1. **Claude Code 配置:** 与 Claude Code 搭配使用时,请将模型 ID 配置为 `claude-opus-4-6` 或 `claude-opus-4.6`。示例 claude `settings.json` 见 [通过 `settings.json` 手动配置](#manual-configuration-with-settingsjson)。
|
|
11
11
|
>
|
|
12
12
|
> 2. **推荐给 opencode 用户:** 对 opencode 而言,优先使用 opencode OAuth app。它与 opencode 内置的 GitHub Copilot provider 行为一致,且没有 Terms of Service 风险:
|
|
13
13
|
> ```sh
|
|
@@ -428,6 +428,7 @@ npx @jeffreycao/copilot-api@latest start --claude-code
|
|
|
428
428
|
- 关闭 `CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION` 和 `CLAUDE_CODE_ENABLE_AWAY_SUMMARY` 可以避免不必要地消耗额度。
|
|
429
429
|
- Claude Code WebSearch 已支持纯搜索请求。Copilot 路径请保持全局 `messageApiWebSearchModel` 指向 Responses-capable GPT 模型或 `provider/model` 别名;provider 路由请使用原生 Anthropic provider 或 `openai-responses` provider。只有在你明确想禁止这类流量时,才需要把 `WebSearch` 加到 `permissions.deny`。
|
|
430
430
|
- 如果使用的不是 Claude 模型,请不要启用 `ENABLE_TOOL_SEARCH`。如果使用的是 Claude 模型,则可以启用 `ENABLE_TOOL_SEARCH`。当前 Claude Code 使用的是客户端 tool search 模式,在该模式下每次加载 defer tools 都需要额外请求一次。
|
|
431
|
+
- `CLAUDE_CODE_AUTO_COMPACT_WINDOW`:设置用于自动压缩计算的上下文容量(以 token 为单位)。默认使用模型自身的上下文窗口:标准模型为 200K,扩展上下文模型为 1M。使用 1M 上下文模型(如 `claude-opus-4-6[1m]`)时,可设置一个较低的值(如 `500000`)将窗口视为 500K 用于压缩计算。该值受限于模型的实际上下文窗口上限。`CLAUDE_AUTOCOMPACT_PCT_OVERRIDE` 会基于此值的百分比生效。设置此变量可将压缩阈值与状态栏的 `used_percentage` 解耦(后者始终使用模型的完整上下文窗口)。
|
|
431
432
|
|
|
432
433
|
更多选项见:[Claude Code settings](https://docs.anthropic.com/en/docs/claude-code/settings#environment-variables)
|
|
433
434
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { S as ensurePaths, x as PATHS } from "./config-DA-Jdm0G.js";
|
|
2
|
-
import { A as loginCodex, R as state, a as setupGitHubToken, n as persistCodexCredentials } from "./token-
|
|
2
|
+
import { A as loginCodex, R as state, a as setupGitHubToken, n as persistCodexCredentials } from "./token-Nj-1C8tP.js";
|
|
3
3
|
import { defineCommand } from "citty";
|
|
4
4
|
import consola from "consola";
|
|
5
5
|
//#region src/auth.ts
|
|
@@ -113,4 +113,4 @@ const auth = defineCommand({
|
|
|
113
113
|
//#endregion
|
|
114
114
|
export { auth };
|
|
115
115
|
|
|
116
|
-
//# sourceMappingURL=auth-
|
|
116
|
+
//# sourceMappingURL=auth-DIHsuzzC.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-
|
|
1
|
+
{"version":3,"file":"auth-DIHsuzzC.js","names":[],"sources":["../src/auth.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { defineCommand } from \"citty\"\nimport consola from \"consola\"\n\nimport { loginCodex } from \"./lib/oauth/codex\"\nimport { PATHS, ensurePaths } from \"./lib/paths\"\nimport { state } from \"./lib/state\"\nimport { persistCodexCredentials, setupGitHubToken } from \"./lib/token\"\n\ninterface RunAuthOptions {\n provider?: string\n verbose: boolean\n showToken: boolean\n}\n\nconst authArgs = {\n provider: {\n type: \"string\",\n description: \"Provider to log in with (copilot or codex)\",\n },\n verbose: {\n alias: \"v\",\n type: \"boolean\",\n default: false,\n description: \"Enable verbose logging\",\n },\n \"show-token\": {\n type: \"boolean\",\n default: false,\n description: \"Show provider access token on auth\",\n },\n} as const\n\nconst BUILTIN_PROVIDER_NAMES = [\"copilot\", \"codex\"] as const\n\ntype BuiltinProviderName = (typeof BUILTIN_PROVIDER_NAMES)[number]\n\nconst BUILTIN_PROVIDER_LABELS: Record<BuiltinProviderName, string> = {\n copilot: \"GitHub Copilot\",\n codex: \"OpenAI Codex\",\n}\n\nfunction isBuiltinProviderName(\n providerName: string,\n): providerName is BuiltinProviderName {\n return BUILTIN_PROVIDER_NAMES.includes(providerName as BuiltinProviderName)\n}\n\nasync function resolveProviderSelection(\n providerArg: string | undefined,\n): Promise<BuiltinProviderName> {\n const availableProviders = [...BUILTIN_PROVIDER_NAMES]\n\n if (providerArg !== undefined) {\n const providerName = providerArg.trim()\n if (!isBuiltinProviderName(providerName)) {\n throw new Error(\n `Unknown provider '${providerArg}'. Expected one of: ${availableProviders.join(\", \")}`,\n )\n }\n return providerName\n }\n\n if (availableProviders.length === 1) {\n return availableProviders[0]\n }\n\n const provider = await consola.prompt(\"Select a provider to log in with\", {\n type: \"select\",\n options: availableProviders.map((providerName) => ({\n label: `${BUILTIN_PROVIDER_LABELS[providerName]} (${providerName})`,\n value: providerName,\n })),\n })\n\n if (!provider || !isBuiltinProviderName(provider)) {\n throw new Error(\"No provider selected\")\n }\n\n return provider\n}\n\nasync function loginWithCodex(): Promise<void> {\n const credentials = await loginCodex({\n onAuth(info) {\n consola.info(\"Open the following URL to authenticate with Codex:\")\n consola.log(info.url)\n if (info.instructions) {\n consola.info(info.instructions)\n }\n },\n onPrompt(message) {\n return consola.prompt(message, {\n type: \"text\",\n })\n },\n onProgress(message) {\n consola.debug(message)\n },\n })\n\n await persistCodexCredentials(credentials, { enableProvider: true })\n consola.success(\n `Codex provider config written to ${PATHS.CONFIG_PATH} and credentials written to ${PATHS.CODEX_CREDENTIAL_PATH}`,\n )\n}\n\nasync function loginWithProvider(provider: BuiltinProviderName): Promise<void> {\n if (provider === \"copilot\") {\n await setupGitHubToken({ force: true })\n consola.success(\"GitHub token written to\", PATHS.GITHUB_TOKEN_PATH)\n return\n }\n\n await loginWithCodex()\n}\n\nexport async function runAuthLogin(options: RunAuthOptions): Promise<void> {\n if (options.verbose) {\n consola.level = 5\n consola.info(\"Verbose logging enabled\")\n }\n\n state.showToken = options.showToken\n\n await ensurePaths()\n const provider = await resolveProviderSelection(options.provider)\n\n consola.info(`Logging in with ${BUILTIN_PROVIDER_LABELS[provider]}`)\n await loginWithProvider(provider)\n}\n\nconst authLogin = defineCommand({\n meta: {\n name: \"login\",\n description: \"Authenticate a builtin provider without running the server\",\n },\n args: authArgs,\n run({ args }) {\n return runAuthLogin({\n provider: args.provider,\n verbose: args.verbose,\n showToken: args[\"show-token\"],\n })\n },\n})\n\nexport const auth = defineCommand({\n meta: {\n name: \"auth\",\n description: \"Run authentication flows without running the server\",\n },\n args: authArgs,\n subCommands: {\n login: authLogin,\n },\n run({ args }) {\n if ((args._[0] ?? \"\").trim()) {\n return\n }\n\n return runAuthLogin({\n provider: args.provider,\n verbose: args.verbose,\n showToken: args[\"show-token\"],\n })\n },\n})\n"],"mappings":";;;;;AAgBA,MAAM,WAAW;CACf,UAAU;EACR,MAAM;EACN,aAAa;EACd;CACD,SAAS;EACP,OAAO;EACP,MAAM;EACN,SAAS;EACT,aAAa;EACd;CACD,cAAc;EACZ,MAAM;EACN,SAAS;EACT,aAAa;EACd;CACF;AAED,MAAM,yBAAyB,CAAC,WAAW,QAAQ;AAInD,MAAM,0BAA+D;CACnE,SAAS;CACT,OAAO;CACR;AAED,SAAS,sBACP,cACqC;CACrC,OAAO,uBAAuB,SAAS,aAAoC;;AAG7E,eAAe,yBACb,aAC8B;CAC9B,MAAM,qBAAqB,CAAC,GAAG,uBAAuB;CAEtD,IAAI,gBAAgB,KAAA,GAAW;EAC7B,MAAM,eAAe,YAAY,MAAM;EACvC,IAAI,CAAC,sBAAsB,aAAa,EACtC,MAAM,IAAI,MACR,qBAAqB,YAAY,sBAAsB,mBAAmB,KAAK,KAAK,GACrF;EAEH,OAAO;;CAGT,IAAI,mBAAmB,WAAW,GAChC,OAAO,mBAAmB;CAG5B,MAAM,WAAW,MAAM,QAAQ,OAAO,oCAAoC;EACxE,MAAM;EACN,SAAS,mBAAmB,KAAK,kBAAkB;GACjD,OAAO,GAAG,wBAAwB,cAAc,IAAI,aAAa;GACjE,OAAO;GACR,EAAE;EACJ,CAAC;CAEF,IAAI,CAAC,YAAY,CAAC,sBAAsB,SAAS,EAC/C,MAAM,IAAI,MAAM,uBAAuB;CAGzC,OAAO;;AAGT,eAAe,iBAAgC;CAmB7C,MAAM,wBAAwB,MAlBJ,WAAW;EACnC,OAAO,MAAM;GACX,QAAQ,KAAK,qDAAqD;GAClE,QAAQ,IAAI,KAAK,IAAI;GACrB,IAAI,KAAK,cACP,QAAQ,KAAK,KAAK,aAAa;;EAGnC,SAAS,SAAS;GAChB,OAAO,QAAQ,OAAO,SAAS,EAC7B,MAAM,QACP,CAAC;;EAEJ,WAAW,SAAS;GAClB,QAAQ,MAAM,QAAQ;;EAEzB,CAAC,EAEyC,EAAE,gBAAgB,MAAM,CAAC;CACpE,QAAQ,QACN,oCAAoC,MAAM,YAAY,8BAA8B,MAAM,wBAC3F;;AAGH,eAAe,kBAAkB,UAA8C;CAC7E,IAAI,aAAa,WAAW;EAC1B,MAAM,iBAAiB,EAAE,OAAO,MAAM,CAAC;EACvC,QAAQ,QAAQ,2BAA2B,MAAM,kBAAkB;EACnE;;CAGF,MAAM,gBAAgB;;AAGxB,eAAsB,aAAa,SAAwC;CACzE,IAAI,QAAQ,SAAS;EACnB,QAAQ,QAAQ;EAChB,QAAQ,KAAK,0BAA0B;;CAGzC,MAAM,YAAY,QAAQ;CAE1B,MAAM,aAAa;CACnB,MAAM,WAAW,MAAM,yBAAyB,QAAQ,SAAS;CAEjE,QAAQ,KAAK,mBAAmB,wBAAwB,YAAY;CACpE,MAAM,kBAAkB,SAAS;;AAkBnC,MAAa,OAAO,cAAc;CAChC,MAAM;EACJ,MAAM;EACN,aAAa;EACd;CACD,MAAM;CACN,aAAa,EACX,OAtBc,cAAc;EAC9B,MAAM;GACJ,MAAM;GACN,aAAa;GACd;EACD,MAAM;EACN,IAAI,EAAE,QAAQ;GACZ,OAAO,aAAa;IAClB,UAAU,KAAK;IACf,SAAS,KAAK;IACd,WAAW,KAAK;IACjB,CAAC;;EAEL,CASU,EACR;CACD,IAAI,EAAE,QAAQ;EACZ,KAAK,KAAK,EAAE,MAAM,IAAI,MAAM,EAC1B;EAGF,OAAO,aAAa;GAClB,UAAU,KAAK;GACf,SAAS,KAAK;GACd,WAAW,KAAK;GACjB,CAAC;;CAEL,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { S as ensurePaths } from "./config-DA-Jdm0G.js";
|
|
2
|
-
import { _ as getCopilotUsage, a as setupGitHubToken } from "./token-
|
|
2
|
+
import { _ as getCopilotUsage, a as setupGitHubToken } from "./token-Nj-1C8tP.js";
|
|
3
3
|
import { defineCommand } from "citty";
|
|
4
4
|
import consola from "consola";
|
|
5
5
|
//#region src/check-usage.ts
|
|
@@ -39,4 +39,4 @@ const checkUsage = defineCommand({
|
|
|
39
39
|
//#endregion
|
|
40
40
|
export { checkUsage };
|
|
41
41
|
|
|
42
|
-
//# sourceMappingURL=check-usage-
|
|
42
|
+
//# sourceMappingURL=check-usage-De_AMKLc.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-usage-
|
|
1
|
+
{"version":3,"file":"check-usage-De_AMKLc.js","names":[],"sources":["../src/check-usage.ts"],"sourcesContent":["import { defineCommand } from \"citty\"\nimport consola from \"consola\"\n\nimport { ensurePaths } from \"./lib/paths\"\nimport { setupGitHubToken } from \"./lib/token\"\nimport {\n getCopilotUsage,\n type QuotaDetail,\n} from \"./services/github/get-copilot-usage\"\n\nexport const checkUsage = defineCommand({\n meta: {\n name: \"check-usage\",\n description: \"Show current GitHub Copilot usage/quota information\",\n },\n async run() {\n await ensurePaths()\n await setupGitHubToken()\n try {\n const usage = await getCopilotUsage()\n const premium = usage.quota_snapshots.premium_interactions\n const premiumTotal = premium.entitlement\n const premiumUsed = premiumTotal - premium.remaining\n const premiumPercentUsed =\n premiumTotal > 0 ? (premiumUsed / premiumTotal) * 100 : 0\n const premiumPercentRemaining = premium.percent_remaining\n\n // Helper to summarize a quota snapshot\n function summarizeQuota(name: string, snap: QuotaDetail | undefined) {\n if (!snap) return `${name}: N/A`\n const total = snap.entitlement\n const used = total - snap.remaining\n const percentUsed = total > 0 ? (used / total) * 100 : 0\n const percentRemaining = snap.percent_remaining\n return `${name}: ${used}/${total} used (${percentUsed.toFixed(1)}% used, ${percentRemaining.toFixed(1)}% remaining)`\n }\n\n const premiumLine = `Premium: ${premiumUsed}/${premiumTotal} used (${premiumPercentUsed.toFixed(1)}% used, ${premiumPercentRemaining.toFixed(1)}% remaining)`\n const chatLine = summarizeQuota(\"Chat\", usage.quota_snapshots.chat)\n const completionsLine = summarizeQuota(\n \"Completions\",\n usage.quota_snapshots.completions,\n )\n\n consola.box(\n `Copilot Usage (plan: ${usage.copilot_plan})\\n`\n + `Quota resets: ${usage.quota_reset_date}\\n`\n + `\\nQuotas:\\n`\n + ` ${premiumLine}\\n`\n + ` ${chatLine}\\n`\n + ` ${completionsLine}`,\n )\n } catch (err) {\n consola.error(\"Failed to fetch Copilot usage:\", err)\n process.exit(1)\n }\n },\n})\n"],"mappings":";;;;;AAUA,MAAa,aAAa,cAAc;CACtC,MAAM;EACJ,MAAM;EACN,aAAa;EACd;CACD,MAAM,MAAM;EACV,MAAM,aAAa;EACnB,MAAM,kBAAkB;EACxB,IAAI;GACF,MAAM,QAAQ,MAAM,iBAAiB;GACrC,MAAM,UAAU,MAAM,gBAAgB;GACtC,MAAM,eAAe,QAAQ;GAC7B,MAAM,cAAc,eAAe,QAAQ;GAC3C,MAAM,qBACJ,eAAe,IAAK,cAAc,eAAgB,MAAM;GAC1D,MAAM,0BAA0B,QAAQ;GAGxC,SAAS,eAAe,MAAc,MAA+B;IACnE,IAAI,CAAC,MAAM,OAAO,GAAG,KAAK;IAC1B,MAAM,QAAQ,KAAK;IACnB,MAAM,OAAO,QAAQ,KAAK;IAC1B,MAAM,cAAc,QAAQ,IAAK,OAAO,QAAS,MAAM;IACvD,MAAM,mBAAmB,KAAK;IAC9B,OAAO,GAAG,KAAK,IAAI,KAAK,GAAG,MAAM,SAAS,YAAY,QAAQ,EAAE,CAAC,UAAU,iBAAiB,QAAQ,EAAE,CAAC;;GAGzG,MAAM,cAAc,YAAY,YAAY,GAAG,aAAa,SAAS,mBAAmB,QAAQ,EAAE,CAAC,UAAU,wBAAwB,QAAQ,EAAE,CAAC;GAChJ,MAAM,WAAW,eAAe,QAAQ,MAAM,gBAAgB,KAAK;GACnE,MAAM,kBAAkB,eACtB,eACA,MAAM,gBAAgB,YACvB;GAED,QAAQ,IACN,wBAAwB,MAAM,aAAa,mBACtB,MAAM,iBAAiB,iBAEnC,YAAY,MACZ,SAAS,MACT,kBACV;WACM,KAAK;GACZ,QAAQ,MAAM,kCAAkC,IAAI;GACpD,QAAQ,KAAK,EAAE;;;CAGpB,CAAC"}
|
package/dist/main.js
CHANGED
|
@@ -39,11 +39,11 @@ if (typeof args["api-home"] === "string") process.env.COPILOT_API_HOME = args["a
|
|
|
39
39
|
if (typeof args["oauth-app"] === "string") process.env.COPILOT_API_OAUTH_APP = args["oauth-app"];
|
|
40
40
|
if (typeof args["enterprise-url"] === "string") process.env.COPILOT_API_ENTERPRISE_URL = args["enterprise-url"];
|
|
41
41
|
bindElectronFetch();
|
|
42
|
-
const { auth } = await import("./auth-
|
|
43
|
-
const { checkUsage } = await import("./check-usage-
|
|
42
|
+
const { auth } = await import("./auth-DIHsuzzC.js");
|
|
43
|
+
const { checkUsage } = await import("./check-usage-De_AMKLc.js");
|
|
44
44
|
const { debug } = await import("./debug-BiX0ewij.js");
|
|
45
45
|
const { mcp } = await import("./mcp-DZgcvqQY.js");
|
|
46
|
-
const { start } = await import("./start-
|
|
46
|
+
const { start } = await import("./start-BAHLvLkh.js");
|
|
47
47
|
await runMain(defineCommand({
|
|
48
48
|
meta: {
|
|
49
49
|
name: "copilot-api",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as getMessageApiWebSearchModel, c as getProviderConfig, d as getSmallModel, f as isMessagesApiEnabled, h as isResponsesApiWebSocketEnabled, i as getExtraPromptForModel, l as getRawProviderConfig, m as isResponsesApiWebSearchEnabled, n as getClaudeTokenMultiplier, o as getModelMappings, p as isResponsesApiContextManagementEnabled, r as getConfig, s as getModelResponsesApiCompactThreshold$1, t as getAnthropicApiKey, u as getReasoningEffortForModel, v as resolveMappedModel, x as PATHS, y as setModelMappings } from "./config-DA-Jdm0G.js";
|
|
2
|
-
import { B as forwardError, C as prepareMessageProxyHeaders, E as compactMessageSections, F as createPooledWebSocketStream, I as createWebSocketUrl, M as generateTraceId, N as requestContext, O as compactSystemPromptStarts, P as resolveTraceId$1, R as state, S as prepareInteractionHeaders, T as compactAutoContinuePromptStarts, _ as getCopilotUsage, b as copilotWebSocketHeaders, d as generateRequestIdFromPayload, f as getRootSessionId, g as sleep, h as parseUserIdMetadata, j as forwardCodexResponses, m as isNullish, p as getUUID, r as setupCodexToken, s as cacheModels, v as copilotBaseUrl, x as prepareForCompact, y as copilotHeaders, z as HTTPError } from "./token-
|
|
2
|
+
import { B as forwardError, C as prepareMessageProxyHeaders, E as compactMessageSections, F as createPooledWebSocketStream, I as createWebSocketUrl, M as generateTraceId, N as requestContext, O as compactSystemPromptStarts, P as resolveTraceId$1, R as state, S as prepareInteractionHeaders, T as compactAutoContinuePromptStarts, _ as getCopilotUsage, b as copilotWebSocketHeaders, d as generateRequestIdFromPayload, f as getRootSessionId, g as sleep, h as parseUserIdMetadata, j as forwardCodexResponses, m as isNullish, p as getUUID, r as setupCodexToken, s as cacheModels, v as copilotBaseUrl, x as prepareForCompact, y as copilotHeaders, z as HTTPError } from "./token-Nj-1C8tP.js";
|
|
3
3
|
import { a as isDeferredToolName, c as parseMcpToolSearchSentinel, d as shouldEnableResponsesToolSearch, i as isBridgeToolSearchName, l as resolveBridgeToolSearchName, o as listDeferredToolNames, r as formatToolSearchBridgeArguments, s as normalizeToolSearchBridgeArguments, t as BRIDGE_TOOL_SEARCH_NAME, u as selectDeferredToolsByNames } from "./tool-search-wA-fLduL.js";
|
|
4
4
|
import consola from "consola";
|
|
5
5
|
import { createHash } from "node:crypto";
|
|
@@ -1927,7 +1927,7 @@ function getAnthropicToolUseBlocks(toolCalls) {
|
|
|
1927
1927
|
const toClientModelId = (modelId) => {
|
|
1928
1928
|
const normalized = normalizeSdkModelId(modelId);
|
|
1929
1929
|
if (!normalized) return modelId;
|
|
1930
|
-
const versionHyphenated = normalized.version.
|
|
1930
|
+
const versionHyphenated = normalized.version.replaceAll(".", "-");
|
|
1931
1931
|
return `claude-${normalized.family}-${versionHyphenated}`;
|
|
1932
1932
|
};
|
|
1933
1933
|
const findEndpointModel = (sdkModelId) => {
|
|
@@ -1985,6 +1985,8 @@ const IDE_EXECUTE_CODE_TOOL = "mcp__ide__executeCode";
|
|
|
1985
1985
|
const IDE_GET_DIAGNOSTICS_TOOL = "mcp__ide__getDiagnostics";
|
|
1986
1986
|
const IDE_GET_DIAGNOSTICS_DESCRIPTION = "Get language diagnostics from VS Code. Returns errors, warnings, information, and hints for files in the workspace.";
|
|
1987
1987
|
const PDF_FILE_READ_PREFIX = "PDF file read:";
|
|
1988
|
+
const CLAUDE_CODE_BILLING_HEADER_PREFIX = "x-anthropic-billing-header:";
|
|
1989
|
+
const CLAUDE_CODE_CCH_SEGMENT_PATTERN = /(^|;\s*)cch=[^;]+;/u;
|
|
1988
1990
|
const createTextBlock = (text) => ({
|
|
1989
1991
|
type: "text",
|
|
1990
1992
|
text
|
|
@@ -2039,7 +2041,25 @@ const prependSystemContentToUserMessage = (message, addition) => {
|
|
|
2039
2041
|
}
|
|
2040
2042
|
message.content = [...toSystemTextBlocks(addition), ...typeof message.content === "string" ? [createTextBlock(message.content)] : message.content];
|
|
2041
2043
|
};
|
|
2044
|
+
const normalizeClaudeCodeBillingHeader = (text) => {
|
|
2045
|
+
if (!text.startsWith(CLAUDE_CODE_BILLING_HEADER_PREFIX)) return text;
|
|
2046
|
+
return text.replace(CLAUDE_CODE_CCH_SEGMENT_PATTERN, "$1cch=<stable>;");
|
|
2047
|
+
};
|
|
2048
|
+
const normalizeClaudeCodeBillingHeaderInSystem = (payload) => {
|
|
2049
|
+
const system = payload.system;
|
|
2050
|
+
if (!system) return;
|
|
2051
|
+
if (typeof system === "string") {
|
|
2052
|
+
payload.system = normalizeClaudeCodeBillingHeader(system);
|
|
2053
|
+
return;
|
|
2054
|
+
}
|
|
2055
|
+
if (system.length === 0) return;
|
|
2056
|
+
payload.system = system.map((block, index) => index === 0 ? {
|
|
2057
|
+
...block,
|
|
2058
|
+
text: normalizeClaudeCodeBillingHeader(block.text)
|
|
2059
|
+
} : block);
|
|
2060
|
+
};
|
|
2042
2061
|
const normalizeSystemMessages = (payload) => {
|
|
2062
|
+
normalizeClaudeCodeBillingHeaderInSystem(payload);
|
|
2043
2063
|
if (!payload.messages.some((msg) => msg.role === "system")) return;
|
|
2044
2064
|
const normalizedMessages = [];
|
|
2045
2065
|
let system = payload.system;
|
|
@@ -4538,6 +4558,7 @@ const createUsageRecorder = (payload, sessionId, webSearchModel) => webSearchFlo
|
|
|
4538
4558
|
*/
|
|
4539
4559
|
const tryHandleWebSearch = async (c, payload, options) => {
|
|
4540
4560
|
if (!hasWebSearchServerTool(payload)) return null;
|
|
4561
|
+
normalizeSystemMessages(payload);
|
|
4541
4562
|
const route = resolveWebSearchRoute(payload, {
|
|
4542
4563
|
webSearchModel: getMessageApiWebSearchModel(),
|
|
4543
4564
|
responsesWebSearchEnabled: isResponsesApiWebSearchEnabled()
|
|
@@ -5681,8 +5702,9 @@ modelRoutes.get("/", async (c) => {
|
|
|
5681
5702
|
const contextWindow = model.capabilities?.limits?.max_context_window_tokens ?? 0;
|
|
5682
5703
|
const clientId = toClientModelId(model.id);
|
|
5683
5704
|
return {
|
|
5705
|
+
claude_model_id: contextWindow >= 1e6 ? `${clientId}[1m]` : clientId,
|
|
5684
5706
|
...model,
|
|
5685
|
-
id:
|
|
5707
|
+
id: clientId,
|
|
5686
5708
|
object: "model",
|
|
5687
5709
|
type: "model",
|
|
5688
5710
|
created: 0,
|
|
@@ -6169,4 +6191,4 @@ server.route("/:provider/v1/models", providerModelRoutes);
|
|
|
6169
6191
|
//#endregion
|
|
6170
6192
|
export { server };
|
|
6171
6193
|
|
|
6172
|
-
//# sourceMappingURL=server-
|
|
6194
|
+
//# sourceMappingURL=server-f_gmacXT.js.map
|