copilot-relay 0.5.2 → 0.5.3
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 +31 -4
- package/dist/main.js.map +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -5401,12 +5401,14 @@ function normalizeResponsesToolSchema(schema) {
|
|
|
5401
5401
|
|
|
5402
5402
|
//#endregion
|
|
5403
5403
|
//#region src/copilot/responses.ts
|
|
5404
|
+
const minResponsesOutputTokens = 16;
|
|
5405
|
+
const responsesOutputTokens = (maxTokens) => typeof maxTokens === "number" && Number.isInteger(maxTokens) && maxTokens > 0 && maxTokens < minResponsesOutputTokens ? minResponsesOutputTokens : maxTokens;
|
|
5404
5406
|
function buildResponsesRequestPayload(payload, reasoningEffort) {
|
|
5405
5407
|
return {
|
|
5406
5408
|
model: payload.model,
|
|
5407
5409
|
input: translateMessagesToResponsesInput(payload.messages),
|
|
5408
5410
|
stream: payload.stream,
|
|
5409
|
-
max_output_tokens: payload.max_tokens,
|
|
5411
|
+
max_output_tokens: responsesOutputTokens(payload.max_tokens),
|
|
5410
5412
|
temperature: payload.temperature,
|
|
5411
5413
|
top_p: payload.top_p,
|
|
5412
5414
|
user: sanitizeUserIdentifier(payload.user),
|
|
@@ -10653,11 +10655,35 @@ const claudeAppDataDir = ({ platform, env, home } = currentPlatform()) => {
|
|
|
10653
10655
|
return path.posix.join(configHome, "Claude-3p");
|
|
10654
10656
|
};
|
|
10655
10657
|
const standardDataDir = (dataDir) => dataDir.replace(/-3p$/, "");
|
|
10658
|
+
const otherVendorMarker = /ark-code|astron|command-r|deepseek|doubao|gemini|gemma|glm|gpt|grok|hermes|hy3|kimi|lfm|\bling\b|llama|longcat|mimo|minimax|mistral|mixtral|moonshot|nemotron|openai|phi-|qianfan|qwen|tc-code|\bunic\b|yi-|stepfun|step-3|seed-|bytedance|hunyuan|granite|amazon\.nova|nova-|devstral|ministral|ernie|codex|arcee|trinity|abab|phi\d|\bk2\.|\bm2\.|jamba|arctic|solar|mercury|zamba|kat-coder|\bds-|dpsk/;
|
|
10659
|
+
const looksAnthropic = (id) => {
|
|
10660
|
+
const lower = id.toLowerCase();
|
|
10661
|
+
return !otherVendorMarker.test(lower) && [
|
|
10662
|
+
"claude",
|
|
10663
|
+
"anthropic",
|
|
10664
|
+
"opus",
|
|
10665
|
+
"sonnet",
|
|
10666
|
+
"haiku",
|
|
10667
|
+
"fable",
|
|
10668
|
+
"mythos"
|
|
10669
|
+
].some((word) => lower.includes(word));
|
|
10670
|
+
};
|
|
10671
|
+
const routesToTier = (name, tier) => name.toLowerCase().includes("opus") === (tier === "opus");
|
|
10672
|
+
/**
|
|
10673
|
+
* The name the app sends for a model: its own ID when the app accepts it and the relay routes that
|
|
10674
|
+
* ID to the model's own slot, otherwise a Claude-style route for its tier, such as
|
|
10675
|
+
* claude-sonnet-relay. Each tier therefore has its own name. The relay sends every model name without "opus"
|
|
10676
|
+
* to gptModel and every one with it to opusModel, so the route reaches the same upstream model. The
|
|
10677
|
+
* route names no real Claude model, so the app and its Claude Code take none of that model's
|
|
10678
|
+
* built-in context window or tuning; supports1m on the entry says what the window is.
|
|
10679
|
+
*/
|
|
10680
|
+
const appModelName = (model) => looksAnthropic(model.id) && routesToTier(model.id, model.tier) ? model.id : `claude-${model.tier}-relay`;
|
|
10656
10681
|
const inferenceModel = (model) => {
|
|
10657
10682
|
const promptTokens = model.capabilities?.limits?.max_prompt_tokens ?? 0;
|
|
10658
|
-
const
|
|
10683
|
+
const name = appModelName(model);
|
|
10684
|
+
const label = model.capabilities?.name?.trim() || (name === model.id ? void 0 : model.id);
|
|
10659
10685
|
return {
|
|
10660
|
-
name
|
|
10686
|
+
name,
|
|
10661
10687
|
...label ? { labelOverride: label } : {},
|
|
10662
10688
|
...promptTokens >= 1e6 ? { supports1m: true } : {},
|
|
10663
10689
|
anthropicFamilyTier: model.tier
|
|
@@ -10730,7 +10756,8 @@ const applyClaudeAppSetup = async (input) => {
|
|
|
10730
10756
|
inferenceGatewayBaseUrl: input.baseUrl,
|
|
10731
10757
|
inferenceGatewayApiKey: input.apiKey || existingKey || "copilot-relay",
|
|
10732
10758
|
inferenceCredentialKind: "static",
|
|
10733
|
-
inferenceModels: input.models.map(inferenceModel)
|
|
10759
|
+
inferenceModels: input.models.map(inferenceModel),
|
|
10760
|
+
modelDiscoveryEnabled: false
|
|
10734
10761
|
};
|
|
10735
10762
|
const desktopSnapshot = await readFileSnapshot(path.join(dataDir, "claude_desktop_config.json"));
|
|
10736
10763
|
const desktop = {
|