@jeffreycao/copilot-api 2.6.24 → 2.6.26
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 -2
- package/README.zh-CN.md +2 -2
- package/dist/{auth-CiQGjfAS.js → auth-BUdtezdW.js} +6 -4
- package/dist/auth-BUdtezdW.js.map +1 -0
- package/dist/auth-BYKwBiQx.js +2 -0
- package/dist/{config-B_pC8QXv.js → config-B2OaAnpL.js} +24 -370
- package/dist/config-B2OaAnpL.js.map +1 -0
- package/dist/config-store-CARrUljo.js +371 -0
- package/dist/config-store-CARrUljo.js.map +1 -0
- package/dist/{debug-C4rsL806.js → debug-CcfAczV9.js} +3 -2
- package/dist/{debug-C4rsL806.js.map → debug-CcfAczV9.js.map} +1 -1
- package/dist/github-copilot-provider-DlQZgaCT.js +79 -0
- package/dist/github-copilot-provider-DlQZgaCT.js.map +1 -0
- package/dist/main.js +6 -4
- package/dist/main.js.map +1 -1
- package/dist/{models-DG6m2Cfd.js → models-CHdnmX1S.js} +2 -2
- package/dist/{models-DG6m2Cfd.js.map → models-CHdnmX1S.js.map} +1 -1
- package/dist/provider-DktH3jcC.js +36 -0
- package/dist/provider-DktH3jcC.js.map +1 -0
- package/dist/provider-management-z3m7cUkp.js +61 -0
- package/dist/provider-management-z3m7cUkp.js.map +1 -0
- package/dist/{server-D-oBVjPR.js → server-JC3AQpcl.js} +177 -65
- package/dist/server-JC3AQpcl.js.map +1 -0
- package/dist/{start-DqY0wdWh.js → start-bv97pvAG.js} +12 -9
- package/dist/{start-DqY0wdWh.js.map → start-bv97pvAG.js.map} +1 -1
- package/dist/{token-6Ld3Ff3c.js → token-DgVri1k7.js} +16 -63
- package/dist/token-DgVri1k7.js.map +1 -0
- package/package.json +2 -1
- package/dist/auth-CiQGjfAS.js.map +0 -1
- package/dist/auth-D2amX0hm.js +0 -2
- package/dist/config-B_pC8QXv.js.map +0 -1
- package/dist/server-D-oBVjPR.js.map +0 -1
- package/dist/token-6Ld3Ff3c.js.map +0 -1
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { a as getAnthropicApiKey, f as isAlphaSearchCodexPriorityEnabled, h as isResponsesApiWebSocketEnabled, i as getAlphaSearchModel, l as getMessageApiWebSearchModel, m as isResponsesApiWebSearchEnabled, o as getClaudeAutoModel, p as isMessagesApiEnabled, s as getClaudeTokenMultiplier, u as getUpstreamTransportConfig, x as PATHS } from "./config-store-CARrUljo.js";
|
|
2
|
+
import { C as resolveMappedModel, S as isGpt56OrAbove, _ as getReasoningEffortForModel, b as isContextManagementEnabledForMessages, d as getOpencodeGoModelRecords, g as getModelResponsesApiCompactThreshold$1, h as getModelMappings, i as listEnabledProviders, l as getOpencodeGoModelConfig, m as getExtraPromptForModel, n as getRawProviderConfig, o as resolveEffectiveProviderType, s as resolveProviderConfigForModel, t as getProviderConfig, u as getOpencodeGoModelIds, v as getSmallModel, w as setModelMappings, x as isContextManagementEnabledForResponses, y as getSmallModelForProvider } from "./config-B2OaAnpL.js";
|
|
3
|
+
import { i as HTTPError, r as isGitHubCopilotEnabled, s as forwardError } from "./github-copilot-provider-DlQZgaCT.js";
|
|
4
|
+
import { $ as stripInternalRequestHeaders, B as forwardCodexResponses, C as copilotWebSocketHeaders, E as prepareMessageProxyHeaders, G as createResponsesHttpEventStream, H as requestContext, J as getResponsesStreamTerminalDisposition, K as createResponsesSafeStream, M as compactTextOnlyGuard, N as createAuthMiddleware, O as compactAutoContinuePromptStarts, P as getConfiguredAdminApiKeys, R as CODEX_API_BASE_URL, T as prepareInteractionHeaders, U as resolveTraceId$1, V as generateTraceId, W as fetchUpstreamWithLifecycle, X as createWebSocketUrl, Y as createPooledWebSocketStream, Z as state, b as copilotBaseUrl, d as getUUID, f as isAsyncIterable, g as getCopilotUsage, h as parseUserIdMetadata, j as compactSystemPromptStarts, k as compactMessageSections, l as generateRequestIdFromPayload, m as isResponsesStream, o as setupCodexToken, p as isNullish, q as encodePoolKeyPart, u as getRootSessionId, w as prepareForCompact, x as copilotHeaders, z as buildCodexRequestHeaders } from "./token-DgVri1k7.js";
|
|
3
5
|
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-BgFcDbNQ.js";
|
|
4
|
-
import {
|
|
6
|
+
import { n as isProviderCodexModelVisible, t as getProviderCodexModels } from "./provider-management-z3m7cUkp.js";
|
|
7
|
+
import { i as toClientModelId, r as normalizeSdkModelId, t as findEndpointModel } from "./models-CHdnmX1S.js";
|
|
5
8
|
import consola from "consola";
|
|
6
9
|
import { createHash } from "node:crypto";
|
|
7
10
|
import fs, { createWriteStream, readFileSync, rmSync } from "node:fs";
|
|
@@ -423,34 +426,25 @@ const dashscopePeakWindows = [{
|
|
|
423
426
|
endMinuteUtc: 840,
|
|
424
427
|
startMinuteUtc: 0
|
|
425
428
|
}];
|
|
429
|
+
//#endregion
|
|
430
|
+
//#region src/lib/builtin-provider-models.ts
|
|
431
|
+
const CODEX_LUNA_PRICING = { tiers: [{
|
|
432
|
+
cacheCreationInput: .125,
|
|
433
|
+
cachedInput: .01,
|
|
434
|
+
input: .1,
|
|
435
|
+
maxInputTokens: 272e3,
|
|
436
|
+
output: .5
|
|
437
|
+
}, {
|
|
438
|
+
cacheCreationInput: .25,
|
|
439
|
+
cachedInput: .02,
|
|
440
|
+
input: .2,
|
|
441
|
+
output: .75
|
|
442
|
+
}] };
|
|
426
443
|
const builtinProviderModelRegistry = new class BuiltinProviderModelRegistry {
|
|
427
444
|
static catalog = {
|
|
428
445
|
codex: {
|
|
429
|
-
"
|
|
430
|
-
|
|
431
|
-
input: 1.75,
|
|
432
|
-
output: 14
|
|
433
|
-
} },
|
|
434
|
-
"gpt-5.4": { pricing: { tiers: [{
|
|
435
|
-
cachedInput: .25,
|
|
436
|
-
input: 2.5,
|
|
437
|
-
maxInputTokens: 272e3,
|
|
438
|
-
output: 15
|
|
439
|
-
}, {
|
|
440
|
-
cachedInput: .5,
|
|
441
|
-
input: 5,
|
|
442
|
-
output: 22.5
|
|
443
|
-
}] } },
|
|
444
|
-
"gpt-5.4-mini": { pricing: { tiers: [{
|
|
445
|
-
cachedInput: .075,
|
|
446
|
-
input: .75,
|
|
447
|
-
maxInputTokens: 272e3,
|
|
448
|
-
output: 4.5
|
|
449
|
-
}, {
|
|
450
|
-
cachedInput: .15,
|
|
451
|
-
input: 1.5,
|
|
452
|
-
output: 6.75
|
|
453
|
-
}] } },
|
|
446
|
+
"codex-auto-review": { pricing: CODEX_LUNA_PRICING },
|
|
447
|
+
"gpt-reserve": { pricing: CODEX_LUNA_PRICING },
|
|
454
448
|
"gpt-5.5": { pricing: { tiers: [{
|
|
455
449
|
cachedInput: .5,
|
|
456
450
|
input: 5,
|
|
@@ -509,18 +503,7 @@ const builtinProviderModelRegistry = new class BuiltinProviderModelRegistry {
|
|
|
509
503
|
input: 20,
|
|
510
504
|
output: 75
|
|
511
505
|
}] } },
|
|
512
|
-
"gpt-6-luna": { pricing:
|
|
513
|
-
cacheCreationInput: .125,
|
|
514
|
-
cachedInput: .01,
|
|
515
|
-
input: .1,
|
|
516
|
-
maxInputTokens: 272e3,
|
|
517
|
-
output: .5
|
|
518
|
-
}, {
|
|
519
|
-
cacheCreationInput: .25,
|
|
520
|
-
cachedInput: .02,
|
|
521
|
-
input: .2,
|
|
522
|
-
output: .75
|
|
523
|
-
}] } },
|
|
506
|
+
"gpt-6-luna": { pricing: CODEX_LUNA_PRICING },
|
|
524
507
|
"gpt-6-sol": { pricing: { tiers: [{
|
|
525
508
|
cacheCreationInput: 2.5,
|
|
526
509
|
cachedInput: .2,
|
|
@@ -1488,7 +1471,8 @@ function resolveTokenUsageCost(input) {
|
|
|
1488
1471
|
const outputPrice = normalizePrice(pricing.output);
|
|
1489
1472
|
const cacheReadPrice = resolveCacheReadPrice(pricing, input);
|
|
1490
1473
|
const cacheCreationPrice = resolveCacheCreationPrice(pricing);
|
|
1491
|
-
const
|
|
1474
|
+
const baseCostNanos = costNanosForTokens(input.input_tokens, inputPrice) + costNanosForTokens(input.output_tokens, outputPrice) + costNanosForTokens(input.cache_read_input_tokens, cacheReadPrice) + costNanosForTokens(input.cache_creation_input_tokens, cacheCreationPrice);
|
|
1475
|
+
const totalCostNanos = Math.round(baseCostNanos * resolveCodexServiceTierMultiplier(input, providerName));
|
|
1492
1476
|
if (totalCostNanos <= 0) return null;
|
|
1493
1477
|
return {
|
|
1494
1478
|
currency,
|
|
@@ -1496,6 +1480,15 @@ function resolveTokenUsageCost(input) {
|
|
|
1496
1480
|
total_cost_nanos: totalCostNanos
|
|
1497
1481
|
};
|
|
1498
1482
|
}
|
|
1483
|
+
function resolveCodexServiceTierMultiplier(input, providerName) {
|
|
1484
|
+
if (providerName.toLowerCase() !== "codex") return 1;
|
|
1485
|
+
switch (input.serviceTier?.trim().toLowerCase()) {
|
|
1486
|
+
case "priority":
|
|
1487
|
+
case "fast": return 2;
|
|
1488
|
+
case "ultrafast": return 6;
|
|
1489
|
+
default: return 1;
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1499
1492
|
function resolveReportedProviderCost(input) {
|
|
1500
1493
|
const cost = normalizePrice(input.cost);
|
|
1501
1494
|
if (cost === null) return null;
|
|
@@ -1523,7 +1516,8 @@ function resolveProviderPricing(providerName, model, configuredPricing) {
|
|
|
1523
1516
|
pricing: configuredPricing,
|
|
1524
1517
|
source: "config"
|
|
1525
1518
|
};
|
|
1526
|
-
const
|
|
1519
|
+
const pricingModel = providerName.toLowerCase() === "codex" && model.trim().toLowerCase() === "gpt-5.6" ? "gpt-5.6-sol" : model;
|
|
1520
|
+
const builtinPricing = builtinProviderModelRegistry.getModelConfig(providerName, pricingModel)?.pricing;
|
|
1527
1521
|
if (!builtinPricing) return null;
|
|
1528
1522
|
return {
|
|
1529
1523
|
pricing: builtinPricing,
|
|
@@ -7788,7 +7782,22 @@ const CODEX_MODELS = [
|
|
|
7788
7782
|
"xhigh",
|
|
7789
7783
|
"max"
|
|
7790
7784
|
]
|
|
7791
|
-
}
|
|
7785
|
+
},
|
|
7786
|
+
...["codex-auto-review", "gpt-reserve"].map((id) => ({
|
|
7787
|
+
contextWindow: 872e3,
|
|
7788
|
+
id,
|
|
7789
|
+
input: ["text", "image"],
|
|
7790
|
+
maxTokens: 128e3,
|
|
7791
|
+
name: id,
|
|
7792
|
+
reasoningEfforts: [
|
|
7793
|
+
"none",
|
|
7794
|
+
"low",
|
|
7795
|
+
"medium",
|
|
7796
|
+
"high",
|
|
7797
|
+
"xhigh",
|
|
7798
|
+
"max"
|
|
7799
|
+
]
|
|
7800
|
+
}))
|
|
7792
7801
|
];
|
|
7793
7802
|
const CODEX_MODELS_URL = `${CODEX_API_BASE_URL}/codex/models`;
|
|
7794
7803
|
const CODEX_MODELS_TIMEOUT_MS = 15e3;
|
|
@@ -9019,6 +9028,71 @@ messageRoutes.post("/count_tokens", async (c) => {
|
|
|
9019
9028
|
return await forwardError(c, error);
|
|
9020
9029
|
}
|
|
9021
9030
|
});
|
|
9031
|
+
const DEFAULT_EXCLUSION_THRESHOLD = 20;
|
|
9032
|
+
const DEFAULT_EXCLUDED_MODELS = /* @__PURE__ */ new Set([
|
|
9033
|
+
"gpt-5.6-sol",
|
|
9034
|
+
"gpt-5.6-terra",
|
|
9035
|
+
"gpt-5.6-luna",
|
|
9036
|
+
"gpt-5.5",
|
|
9037
|
+
"claude-sonnet-5",
|
|
9038
|
+
"gemini-3.5-flash",
|
|
9039
|
+
"gemini-3.6-flash",
|
|
9040
|
+
"gemini-3.7-flash",
|
|
9041
|
+
"gpt-5.3-codex",
|
|
9042
|
+
"gpt-5.4-mini",
|
|
9043
|
+
"gpt-5.4",
|
|
9044
|
+
"grok-4.5",
|
|
9045
|
+
"gpt-5-mini",
|
|
9046
|
+
"mai-code-1.1-flash"
|
|
9047
|
+
]);
|
|
9048
|
+
function isModernCodexClient(url, headers) {
|
|
9049
|
+
const versions = [
|
|
9050
|
+
new URL(url).searchParams.get("client_version"),
|
|
9051
|
+
headers.get("version"),
|
|
9052
|
+
headers.get("user-agent")?.match(/\bcodex[^/\s]*\/(\d+\.\d+\.\d+)/iu)?.[1]
|
|
9053
|
+
];
|
|
9054
|
+
for (const version of versions) {
|
|
9055
|
+
const match = version?.match(/^(\d+)\.(\d+)\.(\d+)(?:[-+].*)?$/u);
|
|
9056
|
+
if (!match) continue;
|
|
9057
|
+
return Number(match[1]) > 0 || Number(match[2]) >= 160;
|
|
9058
|
+
}
|
|
9059
|
+
return false;
|
|
9060
|
+
}
|
|
9061
|
+
function normalizeCodexInstructions(model, modern, fallback) {
|
|
9062
|
+
if (!modern) return model;
|
|
9063
|
+
const { base_instructions: legacy, ...normalized } = model;
|
|
9064
|
+
const messages = model.model_messages;
|
|
9065
|
+
if (typeof messages?.instructions_template !== "string") normalized.model_messages = {
|
|
9066
|
+
...messages ?? fallback,
|
|
9067
|
+
instructions_template: typeof legacy === "string" ? legacy : fallback.instructions_template
|
|
9068
|
+
};
|
|
9069
|
+
return normalized;
|
|
9070
|
+
}
|
|
9071
|
+
function serializeCodexModelCatalog(response, options) {
|
|
9072
|
+
const models = response.models.map((model) => normalizeCodexInstructions(model, options.modern, options.fallback));
|
|
9073
|
+
if (options.headers.get("x-full-model-catalog")?.trim().toLowerCase() === "true") return JSON.stringify({
|
|
9074
|
+
...response,
|
|
9075
|
+
models
|
|
9076
|
+
});
|
|
9077
|
+
const envelope = JSON.stringify({
|
|
9078
|
+
...response,
|
|
9079
|
+
models: []
|
|
9080
|
+
});
|
|
9081
|
+
let bytes = Buffer.byteLength(envelope, "utf8");
|
|
9082
|
+
if (bytes > 1048576) return null;
|
|
9083
|
+
const selected = /* @__PURE__ */ new Set();
|
|
9084
|
+
const ordered = [...models.length > DEFAULT_EXCLUSION_THRESHOLD ? models.filter((model) => options.explicitSlugs.has(model.slug) || !DEFAULT_EXCLUDED_MODELS.has(model.slug.split("/").at(-1) ?? model.slug)) : models].sort((a, b) => Number(options.explicitSlugs.has(b.slug)) - Number(options.explicitSlugs.has(a.slug)));
|
|
9085
|
+
for (const model of ordered) {
|
|
9086
|
+
const additionalBytes = Buffer.byteLength(JSON.stringify(model), "utf8") + (selected.size > 0 ? 1 : 0);
|
|
9087
|
+
if (bytes + additionalBytes > 1048576) continue;
|
|
9088
|
+
selected.add(model);
|
|
9089
|
+
bytes += additionalBytes;
|
|
9090
|
+
}
|
|
9091
|
+
return JSON.stringify({
|
|
9092
|
+
...response,
|
|
9093
|
+
models: models.filter((model) => selected.has(model))
|
|
9094
|
+
});
|
|
9095
|
+
}
|
|
9022
9096
|
//#endregion
|
|
9023
9097
|
//#region src/routes/models/models.json
|
|
9024
9098
|
var models = [
|
|
@@ -10568,7 +10642,7 @@ const COPILOT_PRIORITY_BASE = 2e3;
|
|
|
10568
10642
|
const OPENCODE_GO_PRIORITY_BASE = 3e3;
|
|
10569
10643
|
const PROVIDER_PRIORITY_BASE = 4e3;
|
|
10570
10644
|
const FALLBACK_CODEX_MODELS = models;
|
|
10571
|
-
const FALLBACK_BASE_INSTRUCTIONS = FALLBACK_CODEX_MODELS.find((model) => model.base_instructions?.trim())?.base_instructions ?? "";
|
|
10645
|
+
const FALLBACK_BASE_INSTRUCTIONS = FALLBACK_CODEX_MODELS.find((model) => model.base_instructions?.trim())?.base_instructions ?? FALLBACK_CODEX_MODELS.find((model) => model.model_messages?.instructions_template?.trim())?.model_messages.instructions_template ?? "";
|
|
10572
10646
|
function isCodexUserAgent(userAgent) {
|
|
10573
10647
|
return CODEX_USER_AGENT_PATTERN.test(userAgent?.trim() ?? "");
|
|
10574
10648
|
}
|
|
@@ -10589,7 +10663,18 @@ async function handleCodexModelsProxy(c, resolvedProviderConfig) {
|
|
|
10589
10663
|
message: "Provider 'codex' not found or disabled",
|
|
10590
10664
|
type: "invalid_request_error"
|
|
10591
10665
|
} }, 404);
|
|
10592
|
-
|
|
10666
|
+
const upstreamResponse = await forwardCodexModels(c.req.url, c.req.raw.headers);
|
|
10667
|
+
if (!upstreamResponse.ok) return createProviderProxyResponse(upstreamResponse);
|
|
10668
|
+
const catalog = await upstreamResponse.json().catch(() => null);
|
|
10669
|
+
if (!isCodexModelsResponse(catalog)) return c.json({ error: {
|
|
10670
|
+
message: "Invalid Codex model catalog",
|
|
10671
|
+
type: "api_error"
|
|
10672
|
+
} }, 502);
|
|
10673
|
+
const providerConfig = getRawProviderConfig("codex");
|
|
10674
|
+
return createCodexCatalogResponse(c, {
|
|
10675
|
+
...catalog,
|
|
10676
|
+
models: catalog.models.filter((model) => isProviderCodexModelVisible(providerConfig, model.slug))
|
|
10677
|
+
}, new Set(getProviderCodexModels(providerConfig)), FALLBACK_CODEX_MODELS[0].model_messages);
|
|
10593
10678
|
}
|
|
10594
10679
|
async function handleMergedCodexModels(c, candidatesRequest, options = {}) {
|
|
10595
10680
|
const [upstreamCatalogResult, candidates] = await Promise.all([tryGetCodexCatalog(c), Promise.resolve(candidatesRequest).catch((error) => {
|
|
@@ -10600,8 +10685,25 @@ async function handleMergedCodexModels(c, candidatesRequest, options = {}) {
|
|
|
10600
10685
|
const upstreamModels = upstreamCatalog?.models ?? FALLBACK_CODEX_MODELS;
|
|
10601
10686
|
const template = selectTemplate(upstreamModels);
|
|
10602
10687
|
const catalogModelsBySlug = new Map(upstreamModels.map((model) => [model.slug, model]));
|
|
10603
|
-
const
|
|
10604
|
-
const
|
|
10688
|
+
const codexConfig = getRawProviderConfig("codex");
|
|
10689
|
+
const copilotConfig = getRawProviderConfig("github-copilot");
|
|
10690
|
+
const visibleUpstreamModels = upstreamModels.filter((model) => isProviderCodexModelVisible(codexConfig, model.slug) && (upstreamCatalog !== void 0 || codexConfig !== null || isProviderCodexModelVisible(copilotConfig, model.slug)));
|
|
10691
|
+
const explicitSlugs = /* @__PURE__ */ new Set();
|
|
10692
|
+
const codexSelection = getProviderCodexModels(codexConfig);
|
|
10693
|
+
for (const model of visibleUpstreamModels) if (codexSelection?.includes(model.slug)) {
|
|
10694
|
+
explicitSlugs.add(model.slug);
|
|
10695
|
+
explicitSlugs.add(`codex/${model.slug}`);
|
|
10696
|
+
}
|
|
10697
|
+
const visibleCandidates = candidates.filter((candidate) => {
|
|
10698
|
+
const providerName = candidate.providerName ?? "github-copilot";
|
|
10699
|
+
const modelId = candidate.catalogSlug ?? (candidate.providerName ? candidate.slug.slice(providerName.length + 1) : candidate.slug);
|
|
10700
|
+
const config = getRawProviderConfig(providerName);
|
|
10701
|
+
if (!isProviderCodexModelVisible(config, modelId)) return false;
|
|
10702
|
+
if (getProviderCodexModels(config)?.includes(modelId)) explicitSlugs.add(candidate.slug);
|
|
10703
|
+
return true;
|
|
10704
|
+
});
|
|
10705
|
+
const seenSlugs = new Set(visibleUpstreamModels.map((model) => model.slug));
|
|
10706
|
+
const codexProviderAliases = options.includeCodexProviderAliases ? visibleUpstreamModels.flatMap((model, index) => {
|
|
10605
10707
|
const slug = `codex/${model.slug}`;
|
|
10606
10708
|
if (seenSlugs.has(slug)) return [];
|
|
10607
10709
|
seenSlugs.add(slug);
|
|
@@ -10610,7 +10712,7 @@ async function handleMergedCodexModels(c, candidatesRequest, options = {}) {
|
|
|
10610
10712
|
priority: CODEX_ALIAS_PRIORITY_BASE + index
|
|
10611
10713
|
}];
|
|
10612
10714
|
}) : [];
|
|
10613
|
-
const syntheticModels =
|
|
10715
|
+
const syntheticModels = visibleCandidates.filter((candidate) => !seenSlugs.has(candidate.slug)).flatMap((candidate, index) => {
|
|
10614
10716
|
const priorityBase = getCandidatePriorityBase(candidate);
|
|
10615
10717
|
const catalogModel = candidate.catalogSlug ? catalogModelsBySlug.get(candidate.catalogSlug) : void 0;
|
|
10616
10718
|
if (catalogModel) return [{
|
|
@@ -10621,20 +10723,30 @@ async function handleMergedCodexModels(c, candidatesRequest, options = {}) {
|
|
|
10621
10723
|
return [createSyntheticCodexModel(candidate, template, priorityBase + index)];
|
|
10622
10724
|
});
|
|
10623
10725
|
const models = [
|
|
10624
|
-
...
|
|
10726
|
+
...visibleUpstreamModels,
|
|
10625
10727
|
...codexProviderAliases,
|
|
10626
10728
|
...syntheticModels
|
|
10627
10729
|
].sort((a, b) => getModelPriority(a) - getModelPriority(b));
|
|
10628
|
-
|
|
10730
|
+
return createCodexCatalogResponse(c, {
|
|
10629
10731
|
...upstreamCatalog ?? {},
|
|
10630
10732
|
models
|
|
10631
|
-
};
|
|
10632
|
-
|
|
10633
|
-
|
|
10634
|
-
|
|
10635
|
-
|
|
10636
|
-
|
|
10637
|
-
|
|
10733
|
+
}, explicitSlugs, template.model_messages ?? FALLBACK_CODEX_MODELS[0].model_messages);
|
|
10734
|
+
}
|
|
10735
|
+
function createCodexCatalogResponse(c, response, explicitSlugs, fallback) {
|
|
10736
|
+
const body = serializeCodexModelCatalog(response, {
|
|
10737
|
+
headers: c.req.raw.headers,
|
|
10738
|
+
modern: isModernCodexClient(c.req.url, c.req.raw.headers),
|
|
10739
|
+
explicitSlugs,
|
|
10740
|
+
fallback
|
|
10741
|
+
});
|
|
10742
|
+
if (body === null) return c.json({ error: {
|
|
10743
|
+
message: "Codex model catalog metadata exceeds 1 MiB",
|
|
10744
|
+
type: "api_error"
|
|
10745
|
+
} }, 502);
|
|
10746
|
+
return c.body(body, 200, {
|
|
10747
|
+
"Content-Type": "application/json",
|
|
10748
|
+
"Cache-Control": "private, no-store"
|
|
10749
|
+
});
|
|
10638
10750
|
}
|
|
10639
10751
|
function createCatalogAlias(model, slug, providerName) {
|
|
10640
10752
|
const alias = {
|
|
@@ -10722,10 +10834,7 @@ async function tryGetCodexCatalog(c) {
|
|
|
10722
10834
|
logger$8.warn("models.codex.catalog_invalid");
|
|
10723
10835
|
return null;
|
|
10724
10836
|
}
|
|
10725
|
-
return {
|
|
10726
|
-
catalog: body,
|
|
10727
|
-
etag: response.headers.get("ETag")
|
|
10728
|
-
};
|
|
10837
|
+
return { catalog: body };
|
|
10729
10838
|
} catch (error) {
|
|
10730
10839
|
logger$8.warn("models.codex.catalog_error", { error });
|
|
10731
10840
|
return null;
|
|
@@ -10848,7 +10957,7 @@ async function getProviderModels(provider, requestHeaders) {
|
|
|
10848
10957
|
}
|
|
10849
10958
|
}
|
|
10850
10959
|
async function getAggregatedModels(requestHeaders) {
|
|
10851
|
-
const copilotModels = state.models?.data.map(normalizeCopilotModel) ?? [];
|
|
10960
|
+
const copilotModels = isGitHubCopilotEnabled() ? state.models?.data.map(normalizeCopilotModel) ?? [] : [];
|
|
10852
10961
|
const providerModelsByProvider = await Promise.all(listEnabledProviders().map((provider) => getProviderModels(provider, requestHeaders)));
|
|
10853
10962
|
const models = [...copilotModels, ...providerModelsByProvider.flat()];
|
|
10854
10963
|
const seenModelIds = /* @__PURE__ */ new Set();
|
|
@@ -10880,6 +10989,7 @@ async function getSyntheticCodexModels(requestHeaders, providers) {
|
|
|
10880
10989
|
}
|
|
10881
10990
|
function getCopilotCodexCandidates() {
|
|
10882
10991
|
const candidates = [];
|
|
10992
|
+
if (!isGitHubCopilotEnabled()) return candidates;
|
|
10883
10993
|
for (const model of state.models?.data ?? []) try {
|
|
10884
10994
|
if (isCopilotCodexCandidate(model)) candidates.push(createCopilotCodexCandidate(model));
|
|
10885
10995
|
} catch (error) {
|
|
@@ -10904,6 +11014,7 @@ function createCopilotCodexCandidate(model) {
|
|
|
10904
11014
|
const reasoningEfforts = normalizeReasoningEfforts(model.capabilities.supports.reasoning_effort);
|
|
10905
11015
|
return {
|
|
10906
11016
|
slug: toClientModelId(model.id),
|
|
11017
|
+
catalogSlug: model.id,
|
|
10907
11018
|
displayName: model.name,
|
|
10908
11019
|
description: describeCopilotAdapter(model),
|
|
10909
11020
|
contextWindow: positiveNumber(model.capabilities.limits.max_prompt_tokens, 256e3),
|
|
@@ -11027,12 +11138,12 @@ modelRoutes.get("/", async (c) => {
|
|
|
11027
11138
|
if (isCodexUserAgent(c.req.header("user-agent"))) {
|
|
11028
11139
|
const enabledProviders = listEnabledProviders();
|
|
11029
11140
|
const codexProviderName = enabledProviders.find((provider) => provider === "codex");
|
|
11030
|
-
return await handleMergedCodexModels(c, getSyntheticCodexModels(c.req.raw.headers, enabledProviders), {
|
|
11141
|
+
return await handleMergedCodexModels(c, getSyntheticCodexModels(stripInternalRequestHeaders(c.req.raw.headers), enabledProviders), {
|
|
11031
11142
|
includeCodexProviderAliases: codexProviderName !== void 0,
|
|
11032
11143
|
codexProviderName
|
|
11033
11144
|
});
|
|
11034
11145
|
}
|
|
11035
|
-
const models = await getAggregatedModels(c.req.raw.headers);
|
|
11146
|
+
const models = await getAggregatedModels(stripInternalRequestHeaders(c.req.raw.headers));
|
|
11036
11147
|
return c.json({
|
|
11037
11148
|
object: "list",
|
|
11038
11149
|
data: models,
|
|
@@ -12203,6 +12314,7 @@ const createProviderResponsesUsageRecorder = (payload, provider, modelConfig, pr
|
|
|
12203
12314
|
pricing: modelConfig?.pricing,
|
|
12204
12315
|
pricingCurrency,
|
|
12205
12316
|
providerName: provider,
|
|
12317
|
+
serviceTier: payload.service_tier,
|
|
12206
12318
|
sessionId: sessionAffinity ?? ""
|
|
12207
12319
|
});
|
|
12208
12320
|
};
|
|
@@ -12672,4 +12784,4 @@ createServer();
|
|
|
12672
12784
|
//#endregion
|
|
12673
12785
|
export { createServer };
|
|
12674
12786
|
|
|
12675
|
-
//# sourceMappingURL=server-
|
|
12787
|
+
//# sourceMappingURL=server-JC3AQpcl.js.map
|