@jeffreycao/copilot-api 2.7.9 → 2.7.11
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-HJmO_wDI.js → server-Dvvc9z2P.js} +49 -9
- package/dist/server-Dvvc9z2P.js.map +1 -0
- package/dist/{start-Zh1mijTN.js → start-Dqv75dA4.js} +2 -2
- package/dist/{start-Zh1mijTN.js.map → start-Dqv75dA4.js.map} +1 -1
- package/package.json +1 -1
- package/dist/server-HJmO_wDI.js.map +0 -1
package/dist/main.js
CHANGED
|
@@ -30,7 +30,7 @@ if (isMcpFastPath(process.argv)) {
|
|
|
30
30
|
const { auth } = await import("./auth-BzYvzeW0.js");
|
|
31
31
|
const { debug } = await import("./debug-CmL-V7Ov.js");
|
|
32
32
|
const { mcp } = await import("./mcp-Dd_hxxuG.js");
|
|
33
|
-
const { start } = await import("./start-
|
|
33
|
+
const { start } = await import("./start-Dqv75dA4.js");
|
|
34
34
|
const { provider } = await import("./provider-CzziTLqX.js");
|
|
35
35
|
await runMain(defineCommand({
|
|
36
36
|
meta: {
|
|
@@ -510,6 +510,10 @@ const CODEX_LUNA_PRICING = { tiers: [{
|
|
|
510
510
|
output: .75
|
|
511
511
|
}] };
|
|
512
512
|
const builtinProviderModelRegistry = new class BuiltinProviderModelRegistry {
|
|
513
|
+
static providerDefaults = {
|
|
514
|
+
codex: { supportPdf: true },
|
|
515
|
+
xai: { supportPdf: true }
|
|
516
|
+
};
|
|
513
517
|
static catalog = {
|
|
514
518
|
xai: { "grok-4.7": {
|
|
515
519
|
contextWindow: 5e5,
|
|
@@ -878,6 +882,9 @@ const builtinProviderModelRegistry = new class BuiltinProviderModelRegistry {
|
|
|
878
882
|
if (provider === "opencode-go") return getOpencodeGoModelIds();
|
|
879
883
|
return Object.keys(this.modelCatalog[provider] ?? {});
|
|
880
884
|
}
|
|
885
|
+
getProviderDefaults(providerName) {
|
|
886
|
+
return BuiltinProviderModelRegistry.providerDefaults[this.normalizeKey(providerName)];
|
|
887
|
+
}
|
|
881
888
|
normalizeKey(value) {
|
|
882
889
|
return value.trim().toLowerCase();
|
|
883
890
|
}
|
|
@@ -4083,6 +4090,25 @@ const imageRoutes = new Hono();
|
|
|
4083
4090
|
imageRoutes.post("/generations", handleImagesGenerations);
|
|
4084
4091
|
imageRoutes.post("/edits", handleImagesEdits);
|
|
4085
4092
|
//#endregion
|
|
4093
|
+
//#region src/lib/model-pdf-support.ts
|
|
4094
|
+
function resolveModelPdfSupport(provider, options) {
|
|
4095
|
+
if (options.supportPdf !== void 0) return options.supportPdf;
|
|
4096
|
+
return options.builtinSupportPdf === true || provider === "github-copilot" && Array.isArray(options.supportedMediaTypes) && options.supportedMediaTypes.includes("application/pdf") || Array.isArray(options.catalogInputModalities) && options.catalogInputModalities.includes("pdf");
|
|
4097
|
+
}
|
|
4098
|
+
function getProviderModelPdfSupport(modelId, provider, selectedModel) {
|
|
4099
|
+
const rawId = selectedModel?.id ?? modelId;
|
|
4100
|
+
const modelConfig = provider.models?.[rawId] ?? provider.models?.[modelId];
|
|
4101
|
+
const catalogProvider = provider.modelsDevProviderId || provider.name;
|
|
4102
|
+
const catalog = getModelsDevModel(catalogProvider, rawId) ?? getModelsDevModel(catalogProvider, modelId);
|
|
4103
|
+
const builtin = builtinProviderModelRegistry.getModelConfig(provider.name, rawId);
|
|
4104
|
+
return resolveModelPdfSupport(provider.name, {
|
|
4105
|
+
supportPdf: modelConfig?.supportPdf,
|
|
4106
|
+
catalogInputModalities: catalog?.modalities?.input,
|
|
4107
|
+
supportedMediaTypes: selectedModel?.capabilities.limits.vision?.supported_media_types,
|
|
4108
|
+
builtinSupportPdf: builtin?.supportPdf ?? builtinProviderModelRegistry.getProviderDefaults(provider.name)?.supportPdf
|
|
4109
|
+
});
|
|
4110
|
+
}
|
|
4111
|
+
//#endregion
|
|
4086
4112
|
//#region src/lib/claude-models.ts
|
|
4087
4113
|
const DISCOVERY_MODEL_PREFIX = "my-claude-";
|
|
4088
4114
|
const DISCOVERY_MODEL_SUFFIX = "[1m]";
|
|
@@ -4767,9 +4793,10 @@ const normalizeClaudeCodeBillingHeaderInSystem = (payload) => {
|
|
|
4767
4793
|
text: normalizeClaudeCodeBillingHeader(block.text)
|
|
4768
4794
|
} : block);
|
|
4769
4795
|
};
|
|
4796
|
+
const supportsMidSystemMessages = (model) => model.startsWith("gpt") || model.startsWith("codex") || model.startsWith("claude");
|
|
4770
4797
|
const normalizeSystemMessages = (payload) => {
|
|
4771
4798
|
normalizeClaudeCodeBillingHeaderInSystem(payload);
|
|
4772
|
-
if (
|
|
4799
|
+
if (supportsMidSystemMessages(payload.model)) return;
|
|
4773
4800
|
if (!payload.messages.some((msg) => msg.role === "system")) return;
|
|
4774
4801
|
const normalizedMessages = [];
|
|
4775
4802
|
let system = payload.system;
|
|
@@ -5167,10 +5194,11 @@ async function handleProviderCountTokensForProvider(c, options) {
|
|
|
5167
5194
|
type: "invalid_request_error"
|
|
5168
5195
|
} }, 404);
|
|
5169
5196
|
const modelConfig = providerConfig.models?.[modelId];
|
|
5170
|
-
const
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
|
|
5197
|
+
const effectiveType = resolveEffectiveProviderType(providerConfig, modelId);
|
|
5198
|
+
const openAIPayload = translateToOpenAI(anthropicPayload, {
|
|
5199
|
+
supportPdf: getProviderModelPdfSupport(modelId, providerConfig),
|
|
5200
|
+
...effectiveType === "openai-compatible" && { toolContentSupportType: modelConfig?.toolContentSupportType ?? [] }
|
|
5201
|
+
});
|
|
5174
5202
|
const selectedModel = createFallbackModel(modelId);
|
|
5175
5203
|
const tokenCount = await getTokenCount(openAIPayload, selectedModel);
|
|
5176
5204
|
const finalTokenCount = tokenCount.input + tokenCount.output;
|
|
@@ -5246,11 +5274,14 @@ async function handleCountTokens(c) {
|
|
|
5246
5274
|
const anthropicResult = await countTokensViaAnthropic(c, anthropicPayload);
|
|
5247
5275
|
if (anthropicResult) return anthropicResult;
|
|
5248
5276
|
const anthropicBeta = c.req.header("anthropic-beta");
|
|
5249
|
-
const openAIPayload = translateToOpenAI(anthropicPayload);
|
|
5250
5277
|
const requestedModel = anthropicPayload.model;
|
|
5251
5278
|
const resolve = resolveCountTokensModel(requestedModel);
|
|
5252
5279
|
const selectedModel = resolve.model;
|
|
5253
5280
|
anthropicPayload.model = selectedModel.id;
|
|
5281
|
+
const openAIPayload = translateToOpenAI(anthropicPayload, { supportPdf: getProviderModelPdfSupport(requestedModel, {
|
|
5282
|
+
...getRawProviderConfig(GITHUB_COPILOT_PROVIDER),
|
|
5283
|
+
name: GITHUB_COPILOT_PROVIDER
|
|
5284
|
+
}, selectedModel) });
|
|
5254
5285
|
if (resolve.fallback) consola.warn(`Model '${requestedModel}' not found, using o200k_base fallback tokenizer`);
|
|
5255
5286
|
const tokenCount = await getTokenCount(openAIPayload, selectedModel);
|
|
5256
5287
|
if (anthropicPayload.tools && anthropicPayload.tools.length > 0) {
|
|
@@ -8511,7 +8542,7 @@ const handleOpenAICompatibleProviderMessages = async (c, options) => {
|
|
|
8511
8542
|
};
|
|
8512
8543
|
const createOpenAICompatiblePayload = (payload, modelConfig, providerConfig) => {
|
|
8513
8544
|
const openAIPayload = translateToOpenAI(payload, {
|
|
8514
|
-
supportPdf:
|
|
8545
|
+
supportPdf: getProviderModelPdfSupport(payload.model, providerConfig),
|
|
8515
8546
|
toolContentSupportType: modelConfig?.toolContentSupportType ?? []
|
|
8516
8547
|
});
|
|
8517
8548
|
const isDashScopeProvider = isDashScopeAliyunProvider(providerConfig);
|
|
@@ -8954,6 +8985,10 @@ const messagesApiFlowDependencies = {
|
|
|
8954
8985
|
const handleWithChatCompletions = async (c, anthropicPayload, options) => {
|
|
8955
8986
|
const { logger, selectedModel, subagentMarker, requestId, sessionId, compactType } = options;
|
|
8956
8987
|
const openAIPayload = translateToOpenAI(anthropicPayload, {
|
|
8988
|
+
supportPdf: getProviderModelPdfSupport(anthropicPayload.model, {
|
|
8989
|
+
...getRawProviderConfig(GITHUB_COPILOT_PROVIDER),
|
|
8990
|
+
name: GITHUB_COPILOT_PROVIDER
|
|
8991
|
+
}, selectedModel),
|
|
8957
8992
|
validateReasoningEffort: true,
|
|
8958
8993
|
reasoningEffortSupport: selectedModel?.capabilities.supports.reasoning_effort
|
|
8959
8994
|
});
|
|
@@ -11662,7 +11697,12 @@ function toOpencodeModel(model, contextWindow) {
|
|
|
11662
11697
|
]), catalog?.limit?.context, builtin?.contextWindow, 2e5);
|
|
11663
11698
|
const inputLimit = positiveInteger(getFirstPositiveNumber(limits, ["max_prompt_tokens"]), catalog?.limit?.input);
|
|
11664
11699
|
const supportedMediaTypes = stringList(getRecordField(limits, "vision")?.supported_media_types);
|
|
11665
|
-
const supportPdf =
|
|
11700
|
+
const supportPdf = resolveModelPdfSupport(provider, {
|
|
11701
|
+
supportPdf: modelConfig?.supportPdf,
|
|
11702
|
+
supportedMediaTypes,
|
|
11703
|
+
catalogInputModalities: catalog?.modalities?.input,
|
|
11704
|
+
builtinSupportPdf: builtin?.supportPdf ?? builtinProviderModelRegistry.getProviderDefaults(provider)?.supportPdf
|
|
11705
|
+
});
|
|
11666
11706
|
const input = [...stringList(modelConfig?.inputModalities) ?? stringList(model.input_modalities ?? getRecordField(model, "modalities")?.input ?? model.modalities ?? getRecordField(model, "architecture")?.input_modalities) ?? (typeof supports?.vision === "boolean" ? ["text", ...supports.vision ? ["image"] : []] : void 0) ?? catalog?.modalities?.input ?? builtin?.inputModalities ?? ["text"]].filter((modality) => modality !== "pdf" || supportPdf);
|
|
11667
11707
|
if (supportPdf && !input.includes("pdf")) input.push("pdf");
|
|
11668
11708
|
const efforts = normalizeEffortValues(stringList(modelConfig?.reasoningEfforts ?? model.reasoning_efforts ?? supports?.reasoning_effort) ?? catalogEffortValues(catalog) ?? builtin?.reasoningEfforts);
|
|
@@ -13371,4 +13411,4 @@ createServer();
|
|
|
13371
13411
|
//#endregion
|
|
13372
13412
|
export { createServer };
|
|
13373
13413
|
|
|
13374
|
-
//# sourceMappingURL=server-
|
|
13414
|
+
//# sourceMappingURL=server-Dvvc9z2P.js.map
|