@jeffreycao/copilot-api 2.3.4 → 2.3.8
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 +12 -4
- package/README.zh-CN.md +12 -4
- package/dist/auth-7o-lDs1E.js +2 -0
- package/dist/{auth-OxiT7vCr.js → auth-BGsyAMIi.js} +4 -4
- package/dist/auth-BGsyAMIi.js.map +1 -0
- package/dist/{config-CEGVuc_4.js → config-ByEK-9s6.js} +2 -2
- package/dist/{config-CEGVuc_4.js.map → config-ByEK-9s6.js.map} +1 -1
- package/dist/{debug-Db0SCVSP.js → debug-BHOitPm3.js} +2 -2
- package/dist/{debug-Db0SCVSP.js.map → debug-BHOitPm3.js.map} +1 -1
- package/dist/main.js +3 -3
- package/dist/{models-Bd9M8jdy.js → models-DQiEEAuD.js} +2 -2
- package/dist/{models-Bd9M8jdy.js.map → models-DQiEEAuD.js.map} +1 -1
- package/dist/{server-CKVtJPpg.js → server-RgLmJGxa.js} +47 -24
- package/dist/server-RgLmJGxa.js.map +1 -0
- package/dist/{start-DqfeTNPH.js → start-Drle7xM6.js} +6 -6
- package/dist/{start-DqfeTNPH.js.map → start-Drle7xM6.js.map} +1 -1
- package/dist/{token-C3cN0vNj.js → token-Dc0QXsOC.js} +2 -2
- package/dist/{token-C3cN0vNj.js.map → token-Dc0QXsOC.js.map} +1 -1
- package/package.json +1 -1
- package/dist/auth-B-ry4rJx.js +0 -2
- package/dist/auth-OxiT7vCr.js.map +0 -1
- package/dist/server-CKVtJPpg.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models-
|
|
1
|
+
{"version":3,"file":"models-DQiEEAuD.js","names":[],"sources":["../src/lib/models.ts"],"sourcesContent":["import type { Model } from \"~/lib/types/models\"\n\nimport { state } from \"~/lib/state\"\n\n/**\n * Converts a Copilot upstream model ID to a client-friendly ID that Claude Code\n * and Claude Desktop recognize (dots in version replaced with hyphens).\n * e.g. \"claude-sonnet-4.6\" -> \"claude-sonnet-4-6\"\n * Non-Claude models are returned unchanged.\n */\nexport const toClientModelId = (modelId: string): string => {\n const normalized = normalizeSdkModelId(modelId)\n if (!normalized) return modelId\n const versionHyphenated = normalized.version.replaceAll(\".\", \"-\")\n return `claude-${normalized.family}-${versionHyphenated}`\n}\n\nexport interface NormalizedSdkModelId {\n family: string\n version: string\n}\n\nexport const findEndpointModel = (sdkModelId: string): Model | undefined => {\n const models = state.models?.data ?? []\n const exactMatch = models.find((m) => m.id === sdkModelId)\n if (exactMatch) {\n return exactMatch\n }\n\n const normalized = normalizeSdkModelId(sdkModelId)\n if (!normalized) {\n return undefined\n }\n\n const modelName = `claude-${normalized.family}-${normalized.version}`\n const model = models.find((m) => m.id === modelName)\n if (model) {\n return model\n }\n\n return undefined\n}\n\n/**\n * Finds the latest available model for a given Claude family (e.g. \"opus\",\n * \"sonnet\", \"haiku\") among the models currently cached in `state.models`.\n * \"Latest\" is determined by the highest semantic version parsed from the model\n * ID. Returns `undefined` when no model of that family is available.\n */\nexport const getLatestModelForFamily = (family: string): Model | undefined => {\n const models = state.models?.data ?? []\n\n let best: { model: Model; major: number; minor: number } | undefined\n\n for (const model of models) {\n const normalized = normalizeSdkModelId(model.id)\n if (!normalized || normalized.family !== family) {\n continue\n }\n\n const [majorPart, minorPart = \"0\"] = normalized.version.split(\".\")\n const major = Number.parseInt(majorPart, 10)\n const minor = Number.parseInt(minorPart, 10)\n if (Number.isNaN(major) || Number.isNaN(minor)) {\n continue\n }\n\n if (\n !best\n || major > best.major\n || (major === best.major && minor > best.minor)\n ) {\n best = { model, major, minor }\n }\n }\n\n return best?.model\n}\n\n/**\n * Normalizes an SDK model ID to extract the model family and version.\n * this method from github copilot extension\n * Examples:\n * - \"claude-opus-4-5-20251101\" -> { family: \"opus\", version: \"4.5\" }\n * - \"claude-3-5-sonnet-20241022\" -> { family: \"sonnet\", version: \"3.5\" }\n * - \"claude-sonnet-4-20250514\" -> { family: \"sonnet\", version: \"4\" }\n * - \"claude-haiku-3-5-20250514\" -> { family: \"haiku\", version: \"3.5\" }\n * - \"claude-haiku-4.5\" -> { family: \"haiku\", version: \"4.5\" }\n */\nexport const normalizeSdkModelId = (\n sdkModelId: string,\n): NormalizedSdkModelId | undefined => {\n const lower = sdkModelId.toLowerCase()\n\n // Strip date suffix (8 digits at the end)\n const withoutDate = lower.replace(/-\\d{8}$/, \"\")\n\n // Pattern 1: claude-{family}-{major}.{minor} (e.g., claude-haiku-4.5)\n const pattern1 = withoutDate.match(/^claude-(\\w+)-(\\d+)\\.(\\d+)$/)\n if (pattern1) {\n return { family: pattern1[1], version: `${pattern1[2]}.${pattern1[3]}` }\n }\n\n // Pattern 2: claude-{family}-{major}-{minor} (e.g., claude-opus-4-5, claude-haiku-3-5)\n const pattern2 = withoutDate.match(/^claude-(\\w+)-(\\d+)-(\\d+)$/)\n if (pattern2) {\n return { family: pattern2[1], version: `${pattern2[2]}.${pattern2[3]}` }\n }\n\n // Pattern 3: claude-{major}-{minor}-{family} (e.g., claude-3-5-sonnet)\n const pattern3 = withoutDate.match(/^claude-(\\d+)-(\\d+)-(\\w+)$/)\n if (pattern3) {\n return { family: pattern3[3], version: `${pattern3[1]}.${pattern3[2]}` }\n }\n\n // Pattern 4: claude-{family}-{major} (e.g., claude-sonnet-4)\n const pattern4 = withoutDate.match(/^claude-(\\w+)-(\\d+)$/)\n if (pattern4) {\n return { family: pattern4[1], version: pattern4[2] }\n }\n\n // Pattern 5: claude-{major}-{family} (e.g., claude-3-opus)\n const pattern5 = withoutDate.match(/^claude-(\\d+)-(\\w+)$/)\n if (pattern5) {\n return { family: pattern5[2], version: pattern5[1] }\n }\n\n return undefined\n}\n"],"mappings":";;;;;;;;AAUA,MAAa,mBAAmB,YAA4B;CAC1D,MAAM,aAAa,oBAAoB,QAAQ;CAC/C,IAAI,CAAC,YAAY,OAAO;CACxB,MAAM,oBAAoB,WAAW,QAAQ,WAAW,KAAK,IAAI;CACjE,OAAO,UAAU,WAAW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GAAG,GAAG,SAAS;EAAM;CAI1E,MAAM,WAAW,YAAY,MAAM,6BAA6B;CAChE,IAAI,UACF,OAAO;EAAE,QAAQ,SAAS;EAAI,SAAS,GAAG,SAAS,GAAG,GAAG,SAAS;EAAM;CAI1E,MAAM,WAAW,YAAY,MAAM,uBAAuB;CAC1D,IAAI,UACF,OAAO;EAAE,QAAQ,SAAS;EAAI,SAAS,SAAS;EAAI;CAItD,MAAM,WAAW,YAAY,MAAM,uBAAuB;CAC1D,IAAI,UACF,OAAO;EAAE,QAAQ,SAAS;EAAI,SAAS,SAAS;EAAI"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { A as isResponsesApiWebSocketEnabled, C as getClaudeTokenMultiplier, D as isAlphaSearchCodexPriorityEnabled, E as getResponsesTransportConfig, N as PATHS, O as isMessagesApiEnabled, S as getClaudeAutoModel, T as getMessageApiWebSearchModel, _ as resolveMappedModel, b as getAlphaSearchModel, d as getModelResponsesApiCompactThreshold$1, f as getReasoningEffortForModel, g as isGpt56OrAbove, h as isContextManagementEnabledForResponses, i as listEnabledProviders, k as isResponsesApiWebSearchEnabled, l as getExtraPromptForModel, m as isContextManagementEnabledForMessages, n as getRawProviderConfig, o as resolveEffectiveProviderType, p as getSmallModel, s as resolveProviderAuthType, t as getProviderConfig, u as getModelMappings, v as setModelMappings, x as getAnthropicApiKey } from "./config-
|
|
2
|
-
import { B as fetchResponsesWithLifecycle, C as compactAutoContinuePromptStarts, D as compactTextOnlyGuard, E as compactSystemPromptStarts, F as forwardCodexResponses, G as createWebSocketUrl, H as encodePoolKeyPart, I as generateTraceId, J as forwardError, K as state, L as requestContext, N as CODEX_API_BASE_URL, O as createAuthMiddleware, P as buildCodexRequestHeaders, R as resolveTraceId$1, U as isTerminalResponsesStreamChunk, V as createResponsesSafeStream, W as createPooledWebSocketStream, b as prepareInteractionHeaders, c as getUUID, d as isResponsesStream, f as parseUserIdMetadata, g as copilotHeaders, h as copilotBaseUrl, k as getConfiguredAdminApiKeys, l as isAsyncIterable, o as generateRequestIdFromPayload, p as getCopilotUsage, q as HTTPError, r as setupCodexToken, s as getRootSessionId, u as isNullish, v as copilotWebSocketHeaders, w as compactMessageSections, x as prepareMessageProxyHeaders, y as prepareForCompact, z as createResponsesHttpEventStream } from "./token-
|
|
1
|
+
import { A as isResponsesApiWebSocketEnabled, C as getClaudeTokenMultiplier, D as isAlphaSearchCodexPriorityEnabled, E as getResponsesTransportConfig, N as PATHS, O as isMessagesApiEnabled, S as getClaudeAutoModel, T as getMessageApiWebSearchModel, _ as resolveMappedModel, b as getAlphaSearchModel, d as getModelResponsesApiCompactThreshold$1, f as getReasoningEffortForModel, g as isGpt56OrAbove, h as isContextManagementEnabledForResponses, i as listEnabledProviders, k as isResponsesApiWebSearchEnabled, l as getExtraPromptForModel, m as isContextManagementEnabledForMessages, n as getRawProviderConfig, o as resolveEffectiveProviderType, p as getSmallModel, s as resolveProviderAuthType, t as getProviderConfig, u as getModelMappings, v as setModelMappings, x as getAnthropicApiKey } from "./config-ByEK-9s6.js";
|
|
2
|
+
import { B as fetchResponsesWithLifecycle, C as compactAutoContinuePromptStarts, D as compactTextOnlyGuard, E as compactSystemPromptStarts, F as forwardCodexResponses, G as createWebSocketUrl, H as encodePoolKeyPart, I as generateTraceId, J as forwardError, K as state, L as requestContext, N as CODEX_API_BASE_URL, O as createAuthMiddleware, P as buildCodexRequestHeaders, R as resolveTraceId$1, U as isTerminalResponsesStreamChunk, V as createResponsesSafeStream, W as createPooledWebSocketStream, b as prepareInteractionHeaders, c as getUUID, d as isResponsesStream, f as parseUserIdMetadata, g as copilotHeaders, h as copilotBaseUrl, k as getConfiguredAdminApiKeys, l as isAsyncIterable, o as generateRequestIdFromPayload, p as getCopilotUsage, q as HTTPError, r as setupCodexToken, s as getRootSessionId, u as isNullish, v as copilotWebSocketHeaders, w as compactMessageSections, x as prepareMessageProxyHeaders, y as prepareForCompact, z as createResponsesHttpEventStream } from "./token-Dc0QXsOC.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-Ds1vbmGG.js";
|
|
4
|
-
import { i as toClientModelId, r as normalizeSdkModelId, t as findEndpointModel } from "./models-
|
|
4
|
+
import { i as toClientModelId, r as normalizeSdkModelId, t as findEndpointModel } from "./models-DQiEEAuD.js";
|
|
5
5
|
import consola from "consola";
|
|
6
6
|
import { createHash } from "node:crypto";
|
|
7
7
|
import fs, { readFileSync } from "node:fs";
|
|
@@ -660,6 +660,38 @@ const builtinProviderModelRegistry = new class BuiltinProviderModelRegistry {
|
|
|
660
660
|
output: 4.4
|
|
661
661
|
}
|
|
662
662
|
},
|
|
663
|
+
"glm-5.3-flash": {
|
|
664
|
+
contextWindow: 1e6,
|
|
665
|
+
inputModalities: ["text", "image"],
|
|
666
|
+
maxOutputTokens: 131072,
|
|
667
|
+
pricing: {
|
|
668
|
+
cachedInput: .015,
|
|
669
|
+
input: .075,
|
|
670
|
+
output: .25
|
|
671
|
+
},
|
|
672
|
+
reasoningEfforts: [
|
|
673
|
+
"low",
|
|
674
|
+
"high",
|
|
675
|
+
"max"
|
|
676
|
+
]
|
|
677
|
+
},
|
|
678
|
+
"muse-spark-1.2-contributor": {
|
|
679
|
+
contextWindow: 1048576,
|
|
680
|
+
inputModalities: ["text", "image"],
|
|
681
|
+
maxOutputTokens: 131072,
|
|
682
|
+
pricing: {
|
|
683
|
+
cachedInput: .002,
|
|
684
|
+
input: .1,
|
|
685
|
+
output: .2
|
|
686
|
+
},
|
|
687
|
+
reasoningEfforts: [
|
|
688
|
+
"minimal",
|
|
689
|
+
"low",
|
|
690
|
+
"medium",
|
|
691
|
+
"high",
|
|
692
|
+
"xhigh"
|
|
693
|
+
]
|
|
694
|
+
},
|
|
663
695
|
"grok-4.5": {
|
|
664
696
|
contextWindow: 5e5,
|
|
665
697
|
defaultReasoningEffort: "high",
|
|
@@ -821,21 +853,6 @@ const builtinProviderModelRegistry = new class BuiltinProviderModelRegistry {
|
|
|
821
853
|
maxInputTokens: 512e3,
|
|
822
854
|
output: 2.4
|
|
823
855
|
}] }
|
|
824
|
-
},
|
|
825
|
-
"ox-alpha-free": {
|
|
826
|
-
contextWindow: 1e6,
|
|
827
|
-
inputModalities: ["text", "image"],
|
|
828
|
-
maxOutputTokens: 131072,
|
|
829
|
-
pricing: {
|
|
830
|
-
cachedInput: 0,
|
|
831
|
-
input: 0,
|
|
832
|
-
output: 0
|
|
833
|
-
},
|
|
834
|
-
reasoningEfforts: [
|
|
835
|
-
"low",
|
|
836
|
-
"high",
|
|
837
|
-
"max"
|
|
838
|
-
]
|
|
839
856
|
}
|
|
840
857
|
},
|
|
841
858
|
kimi: {
|
|
@@ -3570,7 +3587,6 @@ function mapOpenAIStopReasonToAnthropic(finishReason) {
|
|
|
3570
3587
|
content_filter: "end_turn"
|
|
3571
3588
|
}[finishReason];
|
|
3572
3589
|
}
|
|
3573
|
-
const COPILOT_TOOL_CONTENT_SUPPORT_TYPE = ["array", "image"];
|
|
3574
3590
|
function translateToOpenAI(payload, options = {}) {
|
|
3575
3591
|
const modelId = payload.model;
|
|
3576
3592
|
const model = state.models?.data.find((m) => m.id === modelId);
|
|
@@ -3583,7 +3599,7 @@ function translateToOpenAI(payload, options = {}) {
|
|
|
3583
3599
|
model: modelId,
|
|
3584
3600
|
messages: translateAnthropicMessagesToOpenAI(payload, modelId, {
|
|
3585
3601
|
supportPdf: options.supportPdf ?? false,
|
|
3586
|
-
toolContentSupportType: options.toolContentSupportType ??
|
|
3602
|
+
toolContentSupportType: options.toolContentSupportType ?? []
|
|
3587
3603
|
}),
|
|
3588
3604
|
max_completion_tokens: payload.max_tokens,
|
|
3589
3605
|
stop: payload.stop_sequences,
|
|
@@ -8011,6 +8027,12 @@ After deleting anything material, briefly tell the user what was removed and whe
|
|
|
8011
8027
|
function isCodexUserAgent(userAgent) {
|
|
8012
8028
|
return CODEX_USER_AGENT_PATTERN.test(userAgent?.trim() ?? "");
|
|
8013
8029
|
}
|
|
8030
|
+
function isDeepSeekModelId(modelId) {
|
|
8031
|
+
return modelId.toLowerCase().includes("deepseek");
|
|
8032
|
+
}
|
|
8033
|
+
function shouldInjectMessagesToolCallTips(userAgent, targetModel) {
|
|
8034
|
+
return isCodexUserAgent(userAgent) && !isDeepSeekModelId(targetModel);
|
|
8035
|
+
}
|
|
8014
8036
|
async function logCodexModelsResponse(response) {
|
|
8015
8037
|
try {
|
|
8016
8038
|
const models = await response.clone().json();
|
|
@@ -8099,6 +8121,7 @@ function createSyntheticCodexModel(candidate, template, priority) {
|
|
|
8099
8121
|
const defaultReasoningEffort = reasoningEfforts.includes(candidate.defaultReasoningEffort) ? candidate.defaultReasoningEffort : reasoningEfforts[0];
|
|
8100
8122
|
const supportsReasoning = reasoningEfforts.some((effort) => effort !== "none");
|
|
8101
8123
|
const inputModalities = [...new Set(candidate.inputModalities)];
|
|
8124
|
+
const isDeepSeekModel = isDeepSeekModelId(candidate.slug);
|
|
8102
8125
|
return {
|
|
8103
8126
|
...template,
|
|
8104
8127
|
slug: candidate.slug,
|
|
@@ -8114,8 +8137,8 @@ function createSyntheticCodexModel(candidate, template, priority) {
|
|
|
8114
8137
|
apply_patch_tool_type: "freeform",
|
|
8115
8138
|
web_search_tool_type: "text_and_image",
|
|
8116
8139
|
supports_search_tool: false,
|
|
8117
|
-
use_responses_lite: true,
|
|
8118
|
-
tool_mode: "code_mode_only",
|
|
8140
|
+
use_responses_lite: isDeepSeekModel ? false : true,
|
|
8141
|
+
tool_mode: isDeepSeekModel ? null : "code_mode_only",
|
|
8119
8142
|
multi_agent_version: "v2",
|
|
8120
8143
|
shell_type: "shell_command",
|
|
8121
8144
|
experimental_supported_tools: [],
|
|
@@ -10144,7 +10167,7 @@ async function handleResponsesViaMessages(c, options) {
|
|
|
10144
10167
|
}, {
|
|
10145
10168
|
model: options.targetModel,
|
|
10146
10169
|
publicModel: options.publicModel,
|
|
10147
|
-
toolCallTips:
|
|
10170
|
+
toolCallTips: shouldInjectMessagesToolCallTips(c.req.header("user-agent"), options.targetModel)
|
|
10148
10171
|
});
|
|
10149
10172
|
const context = translation;
|
|
10150
10173
|
debugJson(logger$3, "Translated Messages request:", {
|
|
@@ -10709,4 +10732,4 @@ server.route("/:provider/images", providerImageRoutes);
|
|
|
10709
10732
|
//#endregion
|
|
10710
10733
|
export { server };
|
|
10711
10734
|
|
|
10712
|
-
//# sourceMappingURL=server-
|
|
10735
|
+
//# sourceMappingURL=server-RgLmJGxa.js.map
|