@jeffreycao/copilot-api 1.16.3 → 1.16.6
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/dist/main.js +1 -1
- package/dist/{server-39Y0II3a.js → server-BdY9JFbK.js} +44 -11
- package/dist/server-BdY9JFbK.js.map +1 -0
- package/dist/{start-D8ijZ2gu.js → start-BwdJvu4z.js} +2 -2
- package/dist/{start-D8ijZ2gu.js.map → start-BwdJvu4z.js.map} +1 -1
- package/package.json +1 -1
- package/dist/server-39Y0II3a.js.map +0 -1
package/dist/main.js
CHANGED
|
@@ -25,7 +25,7 @@ bindElectronFetch();
|
|
|
25
25
|
const { auth } = await import("./auth-DH-ThnhJ.js");
|
|
26
26
|
const { debug } = await import("./debug-D2giR-Kj.js");
|
|
27
27
|
const { mcp } = await import("./mcp-BG6fpi6q.js");
|
|
28
|
-
const { start } = await import("./start-
|
|
28
|
+
const { start } = await import("./start-BwdJvu4z.js");
|
|
29
29
|
await runMain(defineCommand({
|
|
30
30
|
meta: {
|
|
31
31
|
name: "copilot-api",
|
|
@@ -3990,7 +3990,7 @@ const stripToolEagerInputStreaming = (payload) => {
|
|
|
3990
3990
|
const filterAssistantThinkingBlocks = (payload) => {
|
|
3991
3991
|
for (const msg of payload.messages) if (msg.role === "assistant" && Array.isArray(msg.content)) msg.content = msg.content.filter((block) => {
|
|
3992
3992
|
if (block.type !== "thinking") return true;
|
|
3993
|
-
return block.thinking
|
|
3993
|
+
return block.thinking !== "Thinking..." && block.signature && !block.signature.includes("@");
|
|
3994
3994
|
});
|
|
3995
3995
|
};
|
|
3996
3996
|
const prepareMessagesApiPayload = (payload, selectedModel) => {
|
|
@@ -7302,7 +7302,8 @@ const FALLBACK_AVAILABLE_IN_PLANS = [
|
|
|
7302
7302
|
const DEFAULT_REASONING_EFFORTS = [
|
|
7303
7303
|
"high",
|
|
7304
7304
|
"xhigh",
|
|
7305
|
-
"max"
|
|
7305
|
+
"max",
|
|
7306
|
+
"ultra"
|
|
7306
7307
|
];
|
|
7307
7308
|
function isCodexUserAgent(userAgent) {
|
|
7308
7309
|
return CODEX_USER_AGENT_PATTERN.test(userAgent?.trim() ?? "");
|
|
@@ -7333,21 +7334,44 @@ async function handleCodexModelsProxy(c, resolvedProviderConfig) {
|
|
|
7333
7334
|
await logCodexModelsResponse(upstreamResponse);
|
|
7334
7335
|
return createProviderProxyResponse(upstreamResponse);
|
|
7335
7336
|
}
|
|
7336
|
-
async function handleMergedCodexModels(c, candidatesRequest) {
|
|
7337
|
+
async function handleMergedCodexModels(c, candidatesRequest, options = {}) {
|
|
7337
7338
|
const [upstreamCatalog, candidates] = await Promise.all([tryGetCodexCatalog(c), Promise.resolve(candidatesRequest).catch((error) => {
|
|
7338
7339
|
logger$8.warn("models.codex.candidates_error", { error });
|
|
7339
7340
|
return [];
|
|
7340
7341
|
})]);
|
|
7341
7342
|
const upstreamModels = upstreamCatalog?.models ?? [];
|
|
7342
7343
|
const template = selectTemplate(upstreamModels);
|
|
7344
|
+
const catalogModelsBySlug = new Map(upstreamModels.map((model) => [model.slug, model]));
|
|
7343
7345
|
const seenSlugs = new Set(upstreamModels.map((model) => model.slug));
|
|
7344
|
-
const
|
|
7346
|
+
const codexProviderAliases = options.includeCodexProviderAliases ? upstreamModels.flatMap((model) => {
|
|
7347
|
+
const slug = `codex/${model.slug}`;
|
|
7348
|
+
if (seenSlugs.has(slug)) return [];
|
|
7349
|
+
seenSlugs.add(slug);
|
|
7350
|
+
return [{
|
|
7351
|
+
...model,
|
|
7352
|
+
slug
|
|
7353
|
+
}];
|
|
7354
|
+
}) : [];
|
|
7355
|
+
const syntheticModels = candidates.filter((candidate) => !seenSlugs.has(candidate.slug)).flatMap((candidate, index) => {
|
|
7356
|
+
const catalogModel = candidate.catalogSlug ? catalogModelsBySlug.get(candidate.catalogSlug) : void 0;
|
|
7357
|
+
if (catalogModel) return [{
|
|
7358
|
+
...catalogModel,
|
|
7359
|
+
slug: candidate.slug
|
|
7360
|
+
}];
|
|
7361
|
+
if (candidate.catalogMatchRequired) return [];
|
|
7362
|
+
return [createSyntheticCodexModel(candidate, template, upstreamModels.length + index)];
|
|
7363
|
+
});
|
|
7345
7364
|
const response = {
|
|
7346
7365
|
...upstreamCatalog ?? {},
|
|
7347
|
-
models: [
|
|
7366
|
+
models: [
|
|
7367
|
+
...upstreamModels,
|
|
7368
|
+
...codexProviderAliases,
|
|
7369
|
+
...syntheticModels
|
|
7370
|
+
]
|
|
7348
7371
|
};
|
|
7349
7372
|
debugJson(logger$8, "models.codex.merged_response", {
|
|
7350
7373
|
upstreamCount: upstreamModels.length,
|
|
7374
|
+
codexProviderAliasCount: codexProviderAliases.length,
|
|
7351
7375
|
syntheticCount: syntheticModels.length,
|
|
7352
7376
|
models: response
|
|
7353
7377
|
});
|
|
@@ -7375,7 +7399,7 @@ function createSyntheticCodexModel(candidate, template, priority) {
|
|
|
7375
7399
|
supports_search_tool: false,
|
|
7376
7400
|
use_responses_lite: true,
|
|
7377
7401
|
tool_mode: "code_mode_only",
|
|
7378
|
-
multi_agent_version: "
|
|
7402
|
+
multi_agent_version: "v2",
|
|
7379
7403
|
shell_type: "shell_command",
|
|
7380
7404
|
experimental_supported_tools: [],
|
|
7381
7405
|
input_modalities: inputModalities,
|
|
@@ -7543,9 +7567,9 @@ const CODEX_REASONING_EFFORTS = new Set([
|
|
|
7543
7567
|
"max",
|
|
7544
7568
|
"ultra"
|
|
7545
7569
|
]);
|
|
7546
|
-
async function getSyntheticCodexModels(requestHeaders) {
|
|
7570
|
+
async function getSyntheticCodexModels(requestHeaders, providers) {
|
|
7547
7571
|
const copilotModels = getCopilotCodexCandidates();
|
|
7548
|
-
const providerModels = (await Promise.allSettled(
|
|
7572
|
+
const providerModels = (await Promise.allSettled(providers.map((provider) => getProviderCodexCandidates(provider, requestHeaders)))).flatMap((result) => result.status === "fulfilled" ? result.value : []);
|
|
7549
7573
|
const seen = /* @__PURE__ */ new Set();
|
|
7550
7574
|
return [...copilotModels, ...providerModels.flat()].filter((candidate) => {
|
|
7551
7575
|
if (seen.has(candidate.slug)) return false;
|
|
@@ -7598,7 +7622,7 @@ async function getProviderCodexCandidates(provider, requestHeaders) {
|
|
|
7598
7622
|
const candidates = [];
|
|
7599
7623
|
for (const modelId of modelIds) {
|
|
7600
7624
|
const effectiveType = resolveEffectiveProviderType(providerConfig, modelId);
|
|
7601
|
-
if (!isMessagesFallbackProviderType(effectiveType)) continue;
|
|
7625
|
+
if (!isMessagesFallbackProviderType(effectiveType) && effectiveType !== "openai-responses") continue;
|
|
7602
7626
|
const modelConfig = providerConfig.models?.[modelId];
|
|
7603
7627
|
if (modelConfig?.codex?.enabled === false) continue;
|
|
7604
7628
|
candidates.push(createProviderCodexCandidate(providerConfig, modelId, remoteById.get(modelId), modelConfig, effectiveType));
|
|
@@ -7646,6 +7670,8 @@ function createProviderCodexCandidate(providerConfig, modelId, remoteModel, mode
|
|
|
7646
7670
|
const adapterName = effectiveType === "anthropic" ? "Messages" : "Messages-to-Chat";
|
|
7647
7671
|
return {
|
|
7648
7672
|
slug: `${providerConfig.name}/${modelId}`,
|
|
7673
|
+
catalogSlug: modelId,
|
|
7674
|
+
catalogMatchRequired: effectiveType === "openai-responses",
|
|
7649
7675
|
displayName: `${displayName} (${providerConfig.name})`,
|
|
7650
7676
|
description: `${displayName} through the ${providerConfig.name} ${adapterName} adapter.`,
|
|
7651
7677
|
contextWindow: positiveNumber(codexConfig?.contextWindow ?? getFirstPositiveNumber(remoteModel, [
|
|
@@ -7704,7 +7730,10 @@ function getBooleanField(model, field) {
|
|
|
7704
7730
|
}
|
|
7705
7731
|
modelRoutes.get("/", async (c) => {
|
|
7706
7732
|
try {
|
|
7707
|
-
if (isCodexUserAgent(c.req.header("user-agent")))
|
|
7733
|
+
if (isCodexUserAgent(c.req.header("user-agent"))) {
|
|
7734
|
+
const enabledProviders = listEnabledProviders();
|
|
7735
|
+
return await handleMergedCodexModels(c, getSyntheticCodexModels(c.req.raw.headers, enabledProviders), { includeCodexProviderAliases: enabledProviders.includes("codex") });
|
|
7736
|
+
}
|
|
7708
7737
|
const models = await getAggregatedModels(c.req.raw.headers);
|
|
7709
7738
|
return c.json({
|
|
7710
7739
|
object: "list",
|
|
@@ -8265,6 +8294,10 @@ function translateUserContentPart(part, path) {
|
|
|
8265
8294
|
type: "text",
|
|
8266
8295
|
text: requireStringField(part, "text", path)
|
|
8267
8296
|
};
|
|
8297
|
+
if (type === "encrypted_content") return {
|
|
8298
|
+
type: "text",
|
|
8299
|
+
text: requireStringField(part, "encrypted_content", path)
|
|
8300
|
+
};
|
|
8268
8301
|
if (type === "input_image") return translateImagePart(part, path);
|
|
8269
8302
|
if (type === "input_file") return translateFilePart(part, path);
|
|
8270
8303
|
throw new ResponsesMessagesTranslationError(`${path} has unsupported content type '${type ?? "unknown"}'`);
|
|
@@ -9810,4 +9843,4 @@ server.route("/:provider/images", providerImageRoutes);
|
|
|
9810
9843
|
//#endregion
|
|
9811
9844
|
export { server };
|
|
9812
9845
|
|
|
9813
|
-
//# sourceMappingURL=server-
|
|
9846
|
+
//# sourceMappingURL=server-BdY9JFbK.js.map
|