@jeffreycao/copilot-api 2.5.3 → 2.5.5
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 +38 -26
- package/README.zh-CN.md +37 -29
- package/dist/auth-BKEWjsYR.js +2 -0
- package/dist/{auth-BjbkSiVc.js → auth-LJ5y6v6e.js} +2 -2
- package/dist/{auth-BjbkSiVc.js.map → auth-LJ5y6v6e.js.map} +1 -1
- package/dist/main.js +2 -2
- package/dist/{models-DRiRPEy3.js → models-uKftaEt_.js} +2 -2
- package/dist/{models-DRiRPEy3.js.map → models-uKftaEt_.js.map} +1 -1
- package/dist/{server-DriTUys0.js → server-DJl6uDKl.js} +39 -39
- package/dist/server-DJl6uDKl.js.map +1 -0
- package/dist/{start-DJrCCMlX.js → start-r3xnAtBs.js} +5 -5
- package/dist/{start-DJrCCMlX.js.map → start-r3xnAtBs.js.map} +1 -1
- package/dist/{token-Bm_dyi5a.js → token-DZDtQb7h.js} +2 -2
- package/dist/{token-Bm_dyi5a.js.map → token-DZDtQb7h.js.map} +1 -1
- package/package.json +1 -1
- package/dist/auth-BZLuISLH.js +0 -2
- package/dist/server-DriTUys0.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { A as isResponsesApiWebSocketEnabled, C as getClaudeTokenMultiplier, D as isAlphaSearchCodexPriorityEnabled, E as getUpstreamTransportConfig, 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-DYtohLpX.js";
|
|
2
|
-
import { A as
|
|
2
|
+
import { A as createAuthMiddleware, B as resolveTraceId$1, C as prepareMessageProxyHeaders, E as compactMessageSections, F as CODEX_API_BASE_URL, G as isTerminalResponsesStreamChunk, H as createResponsesHttpEventStream, I as buildCodexRequestHeaders, J as state, K as createPooledWebSocketStream, L as forwardCodexResponses, O as compactSystemPromptStarts, R as generateTraceId, S as prepareInteractionHeaders, T as compactAutoContinuePromptStarts, U as createResponsesSafeStream, V as fetchUpstreamWithLifecycle, W as encodePoolKeyPart, X as forwardError, Y as HTTPError, _ as copilotBaseUrl, b as copilotWebSocketHeaders, c as getUUID, d as isResponsesStream, f as parseUserIdMetadata, j as getConfiguredAdminApiKeys, k as compactTextOnlyGuard, l as isAsyncIterable, o as generateRequestIdFromPayload, p as getCopilotUsage, q as createWebSocketUrl, r as setupCodexToken, s as getRootSessionId, u as isNullish, v as copilotHeaders, x as prepareForCompact, z as requestContext } from "./token-DZDtQb7h.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-uKftaEt_.js";
|
|
5
5
|
import consola from "consola";
|
|
6
6
|
import { createHash } from "node:crypto";
|
|
7
7
|
import fs, { createWriteStream, readFileSync, rmSync } from "node:fs";
|
|
@@ -636,25 +636,20 @@ const builtinProviderModelRegistry = new class BuiltinProviderModelRegistry {
|
|
|
636
636
|
}
|
|
637
637
|
},
|
|
638
638
|
deepseek: {
|
|
639
|
-
"deepseek-
|
|
640
|
-
contextWindow: 1e6,
|
|
641
|
-
inputModalities: ["text"],
|
|
642
|
-
maxOutputTokens: 64e3,
|
|
643
|
-
pricing: {
|
|
644
|
-
cachedInput: .1,
|
|
645
|
-
input: 3,
|
|
646
|
-
output: 9
|
|
647
|
-
}
|
|
648
|
-
},
|
|
649
|
-
"deepseek-v4-flash-vision-exp": {
|
|
639
|
+
"deepseek-flash": {
|
|
650
640
|
contextWindow: 1e6,
|
|
651
641
|
inputModalities: ["text", "image"],
|
|
652
|
-
maxOutputTokens:
|
|
642
|
+
maxOutputTokens: 384e3,
|
|
653
643
|
pricing: {
|
|
654
|
-
cachedInput: .
|
|
655
|
-
input:
|
|
656
|
-
output:
|
|
657
|
-
}
|
|
644
|
+
cachedInput: .04,
|
|
645
|
+
input: 2,
|
|
646
|
+
output: 8
|
|
647
|
+
},
|
|
648
|
+
reasoningEfforts: [
|
|
649
|
+
"low",
|
|
650
|
+
"high",
|
|
651
|
+
"max"
|
|
652
|
+
]
|
|
658
653
|
},
|
|
659
654
|
"deepseek-v4-pro": {
|
|
660
655
|
contextWindow: 1e6,
|
|
@@ -664,7 +659,12 @@ const builtinProviderModelRegistry = new class BuiltinProviderModelRegistry {
|
|
|
664
659
|
cachedInput: .3,
|
|
665
660
|
input: 9,
|
|
666
661
|
output: 27
|
|
667
|
-
}
|
|
662
|
+
},
|
|
663
|
+
reasoningEfforts: [
|
|
664
|
+
"low",
|
|
665
|
+
"high",
|
|
666
|
+
"max"
|
|
667
|
+
]
|
|
668
668
|
}
|
|
669
669
|
},
|
|
670
670
|
"opencode-go": {
|
|
@@ -815,6 +815,21 @@ const builtinProviderModelRegistry = new class BuiltinProviderModelRegistry {
|
|
|
815
815
|
"xhigh"
|
|
816
816
|
]
|
|
817
817
|
},
|
|
818
|
+
"deepseek-v4.1-flash": {
|
|
819
|
+
contextWindow: 1e6,
|
|
820
|
+
inputModalities: ["text", "image"],
|
|
821
|
+
maxOutputTokens: 384e3,
|
|
822
|
+
pricing: {
|
|
823
|
+
cachedInput: .006,
|
|
824
|
+
input: .3,
|
|
825
|
+
output: 1.2
|
|
826
|
+
},
|
|
827
|
+
reasoningEfforts: [
|
|
828
|
+
"low",
|
|
829
|
+
"high",
|
|
830
|
+
"max"
|
|
831
|
+
]
|
|
832
|
+
},
|
|
818
833
|
"deepseek-v4-flash": {
|
|
819
834
|
contextWindow: 1e6,
|
|
820
835
|
inputModalities: ["text"],
|
|
@@ -2211,8 +2226,6 @@ const isCopilotQuotaSnapshot = (value) => {
|
|
|
2211
2226
|
};
|
|
2212
2227
|
//#endregion
|
|
2213
2228
|
//#region src/services/copilot/create-responses.ts
|
|
2214
|
-
const ROOT_AGENT_MESSAGE_DELAY_MS = 1e3;
|
|
2215
|
-
const createResponsesDependencies = { sleep };
|
|
2216
2229
|
const createResponses = async (payload, { vision, initiator, subagentMarker, requestId, sessionId, compactType, transport = "http", clientSignal }) => {
|
|
2217
2230
|
if (!state.copilotToken) throw new Error("Copilot token not found");
|
|
2218
2231
|
const headers = {
|
|
@@ -2226,7 +2239,6 @@ const createResponses = async (payload, { vision, initiator, subagentMarker, req
|
|
|
2226
2239
|
const effectiveTransport = compactType === 1 ? "http" : transport;
|
|
2227
2240
|
if (payload.stream === true && effectiveTransport === "websocket") {
|
|
2228
2241
|
clientSignal?.throwIfAborted();
|
|
2229
|
-
if (shouldDelaySubagentRequestAfterRootMessage(payload.input)) await createResponsesDependencies.sleep(ROOT_AGENT_MESSAGE_DELAY_MS);
|
|
2230
2242
|
return createPooledResponsesWebSocketStream(prepareResponsesWebSocketRequest(payload, headers, {
|
|
2231
2243
|
requestId,
|
|
2232
2244
|
subagentMarker
|
|
@@ -2234,11 +2246,6 @@ const createResponses = async (payload, { vision, initiator, subagentMarker, req
|
|
|
2234
2246
|
}
|
|
2235
2247
|
return await createHttpResponses(payload, headers, clientSignal);
|
|
2236
2248
|
};
|
|
2237
|
-
const shouldDelaySubagentRequestAfterRootMessage = (input) => {
|
|
2238
|
-
if (!Array.isArray(input)) return false;
|
|
2239
|
-
const lastItem = input.at(-1);
|
|
2240
|
-
return typeof lastItem === "object" && lastItem !== null && "type" in lastItem && lastItem.type === "agent_message" && "author" in lastItem && lastItem.author === "/root";
|
|
2241
|
-
};
|
|
2242
2249
|
const createHttpResponses = async (payload, headers, clientSignal) => {
|
|
2243
2250
|
const transportConfig = getUpstreamTransportConfig();
|
|
2244
2251
|
const response = await fetchUpstreamWithLifecycle(`${copilotBaseUrl(state)}/responses`, {
|
|
@@ -10506,12 +10513,6 @@ const FALLBACK_BASE_INSTRUCTIONS = FALLBACK_CODEX_MODELS.find((model) => model.b
|
|
|
10506
10513
|
function isCodexUserAgent(userAgent) {
|
|
10507
10514
|
return CODEX_USER_AGENT_PATTERN.test(userAgent?.trim() ?? "");
|
|
10508
10515
|
}
|
|
10509
|
-
function isDeepSeekModelId(modelId) {
|
|
10510
|
-
return modelId.toLowerCase().includes("deepseek");
|
|
10511
|
-
}
|
|
10512
|
-
function shouldInjectMessagesToolCallTips(userAgent, targetModel) {
|
|
10513
|
-
return isCodexUserAgent(userAgent) && !isDeepSeekModelId(targetModel);
|
|
10514
|
-
}
|
|
10515
10516
|
/**
|
|
10516
10517
|
* Proxies a models request to the fixed Codex upstream models endpoint.
|
|
10517
10518
|
* Returns a 404 JSON response when the codex provider is unavailable.
|
|
@@ -10581,7 +10582,6 @@ function createSyntheticCodexModel(candidate, template, priority) {
|
|
|
10581
10582
|
const defaultReasoningEffort = reasoningEfforts.includes(candidate.defaultReasoningEffort) ? candidate.defaultReasoningEffort : reasoningEfforts[0];
|
|
10582
10583
|
const supportsReasoning = reasoningEfforts.some((effort) => effort !== "none");
|
|
10583
10584
|
const inputModalities = [...new Set(candidate.inputModalities)];
|
|
10584
|
-
const isDeepSeekModel = isDeepSeekModelId(candidate.slug);
|
|
10585
10585
|
return {
|
|
10586
10586
|
...template,
|
|
10587
10587
|
slug: candidate.slug,
|
|
@@ -10597,11 +10597,11 @@ function createSyntheticCodexModel(candidate, template, priority) {
|
|
|
10597
10597
|
apply_patch_tool_type: "freeform",
|
|
10598
10598
|
web_search_tool_type: "text_and_image",
|
|
10599
10599
|
supports_search_tool: false,
|
|
10600
|
-
use_responses_lite:
|
|
10601
|
-
tool_mode:
|
|
10600
|
+
use_responses_lite: true,
|
|
10601
|
+
tool_mode: "code_mode_only",
|
|
10602
10602
|
multi_agent_version: "v2",
|
|
10603
10603
|
multi_agent_reasoning_effort: null,
|
|
10604
|
-
shell_type:
|
|
10604
|
+
shell_type: template.shell_type,
|
|
10605
10605
|
experimental_supported_tools: [],
|
|
10606
10606
|
input_modalities: inputModalities,
|
|
10607
10607
|
supports_image_detail_original: false,
|
|
@@ -11955,7 +11955,7 @@ async function handleResponsesViaMessages(c, options) {
|
|
|
11955
11955
|
}, {
|
|
11956
11956
|
model: options.targetModel,
|
|
11957
11957
|
publicModel: options.publicModel,
|
|
11958
|
-
toolCallTips:
|
|
11958
|
+
toolCallTips: isCodexUserAgent(c.req.header("user-agent"))
|
|
11959
11959
|
});
|
|
11960
11960
|
const context = translation;
|
|
11961
11961
|
debugJson(logger$3, "Translated Messages request:", {
|
|
@@ -12553,4 +12553,4 @@ createServer();
|
|
|
12553
12553
|
//#endregion
|
|
12554
12554
|
export { createServer };
|
|
12555
12555
|
|
|
12556
|
-
//# sourceMappingURL=server-
|
|
12556
|
+
//# sourceMappingURL=server-DJl6uDKl.js.map
|