betahi-copilot-bridge 0.20.13 → 0.20.15
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 +1 -1
- package/dist/main.js +23 -27
- package/dist/main.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<h1 align="center">copilot-bridge</h1>
|
|
2
2
|
|
|
3
3
|
<p align="center">
|
|
4
|
-
<a href="https://www.npmjs.com/package/betahi-copilot-bridge"><img src="https://img.shields.io/npm/v/betahi-copilot-bridge.svg?v=0.20.
|
|
4
|
+
<a href="https://www.npmjs.com/package/betahi-copilot-bridge"><img src="https://img.shields.io/npm/v/betahi-copilot-bridge.svg?v=0.20.15" alt="npm version"></a>
|
|
5
5
|
<a href="https://github.com/betahi/copilot-bridge/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/betahi-copilot-bridge.svg" alt="license"></a>
|
|
6
6
|
</p>
|
|
7
7
|
|
package/dist/main.js
CHANGED
|
@@ -823,17 +823,11 @@ const MODEL_CAPABILITIES = [
|
|
|
823
823
|
},
|
|
824
824
|
...[{
|
|
825
825
|
id: "claude-opus-4.7",
|
|
826
|
-
|
|
827
|
-
"
|
|
828
|
-
"
|
|
829
|
-
"
|
|
830
|
-
"xhigh",
|
|
831
|
-
"max"
|
|
826
|
+
aliases: [
|
|
827
|
+
"claude-opus-4.7-1m",
|
|
828
|
+
"claude-opus-4.7-[1m]",
|
|
829
|
+
"claude-opus-4.7-1m-internal"
|
|
832
830
|
],
|
|
833
|
-
defaultEffort: "medium"
|
|
834
|
-
}, {
|
|
835
|
-
id: "claude-opus-4.7-1m-internal",
|
|
836
|
-
aliases: ["claude-opus-4.7-1m"],
|
|
837
831
|
supported: [
|
|
838
832
|
"low",
|
|
839
833
|
"medium",
|
|
@@ -854,19 +848,7 @@ const MODEL_CAPABILITIES = [
|
|
|
854
848
|
})),
|
|
855
849
|
{
|
|
856
850
|
id: "claude-opus-4.6",
|
|
857
|
-
|
|
858
|
-
reasoning: {
|
|
859
|
-
supported: [
|
|
860
|
-
"low",
|
|
861
|
-
"medium",
|
|
862
|
-
"high",
|
|
863
|
-
"max"
|
|
864
|
-
],
|
|
865
|
-
default: "medium"
|
|
866
|
-
}
|
|
867
|
-
},
|
|
868
|
-
{
|
|
869
|
-
id: "claude-opus-4.6-1m",
|
|
851
|
+
aliases: ["claude-opus-4.6-1m", "claude-opus-4.6-[1m]"],
|
|
870
852
|
fallback: "chat-completions",
|
|
871
853
|
reasoning: {
|
|
872
854
|
supported: [
|
|
@@ -1123,15 +1105,20 @@ const summarizeToolsForDiagnostics = (tools) => {
|
|
|
1123
1105
|
//#endregion
|
|
1124
1106
|
//#region src/services/copilot/responses.ts
|
|
1125
1107
|
const RESPONSES_ONLY_MODEL_PATTERN = /^(?:gpt-5\.5|gpt-5\.4-mini|gpt-5\.3-codex)(?:-|$)/i;
|
|
1108
|
+
const COPILOT_RESPONSES_MIN_OUTPUT_TOKENS = 16;
|
|
1126
1109
|
function shouldUseResponsesApiForModel(model) {
|
|
1127
1110
|
return RESPONSES_ONLY_MODEL_PATTERN.test(model);
|
|
1128
1111
|
}
|
|
1112
|
+
function normalizeResponsesMaxOutputTokens(value) {
|
|
1113
|
+
if (value === null || value === void 0) return value;
|
|
1114
|
+
return Math.max(COPILOT_RESPONSES_MIN_OUTPUT_TOKENS, value);
|
|
1115
|
+
}
|
|
1129
1116
|
function buildResponsesRequestPayload(payload, reasoningEffort) {
|
|
1130
1117
|
return {
|
|
1131
1118
|
model: payload.model,
|
|
1132
1119
|
input: translateMessagesToResponsesInput(payload.messages),
|
|
1133
1120
|
stream: payload.stream,
|
|
1134
|
-
max_output_tokens: payload.max_tokens,
|
|
1121
|
+
max_output_tokens: normalizeResponsesMaxOutputTokens(payload.max_tokens),
|
|
1135
1122
|
temperature: payload.temperature,
|
|
1136
1123
|
top_p: payload.top_p,
|
|
1137
1124
|
user: sanitizeUserIdentifier(payload.user),
|
|
@@ -1725,10 +1712,16 @@ embeddingRoutes.post("/", async (c) => {
|
|
|
1725
1712
|
//#region src/lib/models-resolver.ts
|
|
1726
1713
|
const normalizeModelId = (modelId) => modelId.trim().toLowerCase().replaceAll(/[\s._-]+/g, "");
|
|
1727
1714
|
const mapClaudeOneMillionModelId = (modelId) => {
|
|
1728
|
-
if (modelId === "claude-opus-4.
|
|
1715
|
+
if (modelId === "claude-opus-4.6-1m") return "claude-opus-4.6";
|
|
1716
|
+
if (modelId === "claude-opus-4.7-1m") return "claude-opus-4.7";
|
|
1717
|
+
if (modelId === "claude-opus-4.7-1m-internal") return "claude-opus-4.7";
|
|
1729
1718
|
if (modelId === "claude-opus-4.8-1m") return "claude-opus-4.8";
|
|
1730
1719
|
return modelId;
|
|
1731
1720
|
};
|
|
1721
|
+
const isClaudeOneMillionAlias = (modelId) => {
|
|
1722
|
+
const id = modelId.trim().toLowerCase();
|
|
1723
|
+
return /^claude-opus-4[.-][678](?:-\d{8})?-?\[1m\]$/.test(id) || /^claude-opus-4[.-][678]-1m(?:-internal)?(?:-\d{8})?$/.test(id);
|
|
1724
|
+
};
|
|
1732
1725
|
const stripSnapshotSuffix = (modelId) => {
|
|
1733
1726
|
const id = modelId.trim().toLowerCase().replace(/-\[1m\]$/, "-1m").replace(/\[1m\]$/, "-1m");
|
|
1734
1727
|
const mappedId = mapClaudeOneMillionModelId(id);
|
|
@@ -1789,7 +1782,10 @@ const getBestPrefixMatches = (models, aliasCandidates) => {
|
|
|
1789
1782
|
};
|
|
1790
1783
|
const resolveModel = (requestedModelId, models = runtimeState.models?.data) => {
|
|
1791
1784
|
if (!models || models.length === 0) return;
|
|
1792
|
-
const
|
|
1785
|
+
const requestedExactMatch = models.find((model) => model.id === requestedModelId);
|
|
1786
|
+
if (requestedExactMatch && !isClaudeOneMillionAlias(requestedModelId)) return requestedExactMatch;
|
|
1787
|
+
const canonicalModelId = stripSnapshotSuffix(requestedModelId);
|
|
1788
|
+
const exactMatch = models.find((model) => model.id === canonicalModelId);
|
|
1793
1789
|
if (exactMatch) return exactMatch;
|
|
1794
1790
|
const aliasCandidates = getAliasCandidates(requestedModelId);
|
|
1795
1791
|
const normalizedAliases = new Set(aliasCandidates.map((candidate) => normalizeModelId(candidate)));
|
|
@@ -4168,7 +4164,7 @@ const startServer = (config) => serve({
|
|
|
4168
4164
|
|
|
4169
4165
|
//#endregion
|
|
4170
4166
|
//#region src/start.ts
|
|
4171
|
-
const getPublicModelId = (id) => id
|
|
4167
|
+
const getPublicModelId = (id) => id;
|
|
4172
4168
|
const unique = (ids) => [...new Set(ids)];
|
|
4173
4169
|
const AUTO_MODEL_PRIORITY = [
|
|
4174
4170
|
"gpt-5.3-codex",
|