copilot-relay 0.7.0 → 0.7.1
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 +43 -10
- package/dist/main.js.map +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1140,21 +1140,41 @@ const getModelRouting = () => {
|
|
|
1140
1140
|
opusModel: normalizeCopilotModelId(routing.opusModel)
|
|
1141
1141
|
};
|
|
1142
1142
|
};
|
|
1143
|
-
|
|
1144
|
-
const
|
|
1143
|
+
let exposedCache;
|
|
1144
|
+
const sameSelection = (left, right) => {
|
|
1145
|
+
if (Array.isArray(left) && Array.isArray(right)) return left.length === right.length && left.every((id, index) => id === right[index]);
|
|
1146
|
+
return left === right;
|
|
1147
|
+
};
|
|
1148
|
+
const exposedModels = () => {
|
|
1149
|
+
const catalog = currentCatalog();
|
|
1145
1150
|
const routing = getConfiguredModelRouting();
|
|
1151
|
+
const cached = exposedCache;
|
|
1152
|
+
if (cached !== void 0 && cached.catalog === catalog && cached.gptModel === routing.gptModel && cached.opusModel === routing.opusModel && sameSelection(cached.models, routing.models)) return cached;
|
|
1153
|
+
const upstream = resolveExposedModels(routing, catalog);
|
|
1146
1154
|
const slots = [routing.gptModel, routing.opusModel];
|
|
1147
|
-
|
|
1148
|
-
return normalizeClaudeModelId(slots.find((configured) =>
|
|
1155
|
+
const claude = upstream.map((id) => {
|
|
1156
|
+
return normalizeClaudeModelId(slots.find((configured) => canonicalModelId(configured, catalog).toLowerCase() === id.toLowerCase()) ?? id);
|
|
1149
1157
|
});
|
|
1150
|
-
|
|
1158
|
+
exposedCache = {
|
|
1159
|
+
catalog,
|
|
1160
|
+
gptModel: routing.gptModel,
|
|
1161
|
+
opusModel: routing.opusModel,
|
|
1162
|
+
models: Array.isArray(routing.models) ? [...routing.models] : routing.models,
|
|
1163
|
+
upstream,
|
|
1164
|
+
claude,
|
|
1165
|
+
byLowercase: new Map(upstream.map((id) => [id.toLowerCase(), id]))
|
|
1166
|
+
};
|
|
1167
|
+
return exposedCache;
|
|
1168
|
+
};
|
|
1169
|
+
const getExposedModelIds = () => [...exposedModels().claude];
|
|
1151
1170
|
const getUpstreamModelIds = () => {
|
|
1152
1171
|
const routing = getModelRouting();
|
|
1153
1172
|
return [routing.gptModel, routing.opusModel];
|
|
1154
1173
|
};
|
|
1155
1174
|
const routeModelId = (model) => {
|
|
1156
|
-
const
|
|
1157
|
-
const
|
|
1175
|
+
const exposedSet = exposedModels();
|
|
1176
|
+
const requested = canonicalModelId(model.trim(), exposedSet.catalog).toLowerCase();
|
|
1177
|
+
const exposed = exposedSet.byLowercase.get(requested);
|
|
1158
1178
|
if (exposed !== void 0) return exposed;
|
|
1159
1179
|
const routing = getModelRouting();
|
|
1160
1180
|
return requested.includes("opus") ? routing.opusModel : routing.gptModel;
|
|
@@ -1169,10 +1189,22 @@ const parseModelSelection = (value) => {
|
|
|
1169
1189
|
if (ids.some((id) => !modelIdPattern.test(id) || id.toLowerCase() === "auto")) throw new Error(invalidModelsMessage);
|
|
1170
1190
|
return ids;
|
|
1171
1191
|
};
|
|
1192
|
+
const catalogIndexes = /* @__PURE__ */ new WeakMap();
|
|
1193
|
+
const catalogIndex = (catalog) => {
|
|
1194
|
+
const known = catalogIndexes.get(catalog);
|
|
1195
|
+
if (known !== void 0) return known;
|
|
1196
|
+
const index = /* @__PURE__ */ new Map();
|
|
1197
|
+
for (const key of catalog.keys()) {
|
|
1198
|
+
const lower = key.toLowerCase();
|
|
1199
|
+
if (!index.has(lower)) index.set(lower, key);
|
|
1200
|
+
}
|
|
1201
|
+
catalogIndexes.set(catalog, index);
|
|
1202
|
+
return index;
|
|
1203
|
+
};
|
|
1172
1204
|
const canonicalModelId = (id, catalog) => {
|
|
1173
1205
|
const lower = id.replace(/\[1m\]/gi, "").toLowerCase();
|
|
1174
|
-
|
|
1175
|
-
return lower;
|
|
1206
|
+
if (catalog === void 0) return lower;
|
|
1207
|
+
return catalogIndex(catalog).get(lower) ?? lower;
|
|
1176
1208
|
};
|
|
1177
1209
|
const pickerCategories = [
|
|
1178
1210
|
"powerful",
|
|
@@ -2817,7 +2849,6 @@ var RequestTrace = class RequestTrace {
|
|
|
2817
2849
|
},
|
|
2818
2850
|
runtime: {
|
|
2819
2851
|
...policy,
|
|
2820
|
-
models: catalog ? [...catalog.models.entries()] : void 0,
|
|
2821
2852
|
catalogCurrent: catalog?.baseUrl === config.copilotBaseUrl,
|
|
2822
2853
|
...catalog?.fetchedAt !== void 0 && { catalogAgeMs: Math.max(0, (config.admittedAt ?? Date.now()) - catalog.fetchedAt) }
|
|
2823
2854
|
}
|
|
@@ -2845,6 +2876,8 @@ var RequestTrace = class RequestTrace {
|
|
|
2845
2876
|
trace.captureRequested = capture;
|
|
2846
2877
|
traceObserver.getStore()?.(trace);
|
|
2847
2878
|
if (!capture) return trace;
|
|
2879
|
+
const catalog = runtime.modelCatalog ?? config.modelCatalog;
|
|
2880
|
+
trace.manifest.runtime.models = catalog ? [...catalog.models.entries()] : void 0;
|
|
2848
2881
|
try {
|
|
2849
2882
|
if (!uuidPattern.test(id)) throw new Error("Invalid capture identifier.");
|
|
2850
2883
|
const root = path.join(paths.appDir, "captures");
|