bridgerapi 1.8.0 → 1.9.0
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/cli.js +65 -13
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -120,7 +120,12 @@ var SKIP_TOKENS = /* @__PURE__ */ new Set([
|
|
|
120
120
|
"version",
|
|
121
121
|
"verbose",
|
|
122
122
|
"debug",
|
|
123
|
-
"quiet"
|
|
123
|
+
"quiet",
|
|
124
|
+
"output-format",
|
|
125
|
+
"approval-mode",
|
|
126
|
+
"list-models",
|
|
127
|
+
"api-key",
|
|
128
|
+
"base-url"
|
|
124
129
|
]);
|
|
125
130
|
function extractModelIds(text) {
|
|
126
131
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -130,6 +135,21 @@ function extractModelIds(text) {
|
|
|
130
135
|
}
|
|
131
136
|
return [...seen];
|
|
132
137
|
}
|
|
138
|
+
async function tryDiscover(bin, strategies) {
|
|
139
|
+
for (const args of strategies) {
|
|
140
|
+
try {
|
|
141
|
+
const out = (0, import_child_process.execFileSync)(bin, args, {
|
|
142
|
+
encoding: "utf8",
|
|
143
|
+
timeout: 5e3,
|
|
144
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
145
|
+
});
|
|
146
|
+
const found = extractModelIds(out);
|
|
147
|
+
if (found.length > 0) return found;
|
|
148
|
+
} catch {
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return [];
|
|
152
|
+
}
|
|
133
153
|
async function* spawnStream(cmd2, args, stdin) {
|
|
134
154
|
const proc = (0, import_child_process.spawn)(cmd2, args, { env: process.env, stdio: ["pipe", "pipe", "pipe"] });
|
|
135
155
|
if (stdin !== void 0) proc.stdin.end(stdin);
|
|
@@ -217,6 +237,14 @@ var ClaudeBackend = class {
|
|
|
217
237
|
return Boolean(which("claude")) || (0, import_fs2.existsSync)(`${HOME}/.local/bin/claude`);
|
|
218
238
|
}
|
|
219
239
|
async models() {
|
|
240
|
+
const bin = which("claude") || this.bin;
|
|
241
|
+
const found = await tryDiscover(bin, [
|
|
242
|
+
["models"],
|
|
243
|
+
["models", "list"],
|
|
244
|
+
["model", "list"],
|
|
245
|
+
["--list-models"]
|
|
246
|
+
]);
|
|
247
|
+
if (found.length > 0) return found;
|
|
220
248
|
return [
|
|
221
249
|
"claude-opus-4-6",
|
|
222
250
|
"claude-opus-4-6-fast",
|
|
@@ -259,6 +287,14 @@ var GeminiBackend = class {
|
|
|
259
287
|
return Boolean(which("gemini")) || (0, import_fs2.existsSync)(this.bin);
|
|
260
288
|
}
|
|
261
289
|
async models() {
|
|
290
|
+
const bin = which("gemini") || this.bin;
|
|
291
|
+
const found = await tryDiscover(bin, [
|
|
292
|
+
["models"],
|
|
293
|
+
["models", "list"],
|
|
294
|
+
["--list-models"],
|
|
295
|
+
["list-models"]
|
|
296
|
+
]);
|
|
297
|
+
if (found.length > 0) return found;
|
|
262
298
|
return [
|
|
263
299
|
"gemini-3.1-pro-preview",
|
|
264
300
|
"gemini-3-pro-preview",
|
|
@@ -312,6 +348,13 @@ var CodexBackend = class {
|
|
|
312
348
|
return Boolean(which("codex"));
|
|
313
349
|
}
|
|
314
350
|
async models() {
|
|
351
|
+
const found = await tryDiscover(this.bin, [
|
|
352
|
+
["models"],
|
|
353
|
+
["models", "list"],
|
|
354
|
+
["--list-models"],
|
|
355
|
+
["list-models"]
|
|
356
|
+
]);
|
|
357
|
+
if (found.length > 0) return found;
|
|
315
358
|
return [
|
|
316
359
|
"gpt-5-codex",
|
|
317
360
|
"gpt-5.1-codex",
|
|
@@ -359,6 +402,12 @@ var CopilotBackend = class {
|
|
|
359
402
|
}
|
|
360
403
|
}
|
|
361
404
|
async models() {
|
|
405
|
+
const found = await tryDiscover(this.bin, [
|
|
406
|
+
["copilot", "models"],
|
|
407
|
+
["copilot", "models", "list"],
|
|
408
|
+
["copilot", "--list-models"]
|
|
409
|
+
]);
|
|
410
|
+
if (found.length > 0) return found;
|
|
362
411
|
return ["copilot"];
|
|
363
412
|
}
|
|
364
413
|
async runBlocking(prompt, model2) {
|
|
@@ -1062,22 +1111,25 @@ async function cmdBackendAdd() {
|
|
|
1062
1111
|
console.log(` ${JSON.stringify(def, null, 2).split("\n").join("\n ")}`);
|
|
1063
1112
|
console.log();
|
|
1064
1113
|
}
|
|
1065
|
-
function cmdBackendList() {
|
|
1066
|
-
const cfg = loadConfig();
|
|
1114
|
+
async function cmdBackendList() {
|
|
1067
1115
|
console.log();
|
|
1068
|
-
console.log("
|
|
1116
|
+
console.log(" Backends:\n");
|
|
1069
1117
|
for (const b of BACKENDS) {
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
for (const b of cfg.customBackends) {
|
|
1077
|
-
console.log(` ? ${b.name} [${b.prefixes.join(", ")}] (bin: ${b.bin})`);
|
|
1118
|
+
if (!b.available()) {
|
|
1119
|
+
const hint = INSTALL_HINTS[b.name] ?? "not installed";
|
|
1120
|
+
console.log(` \u2717 ${b.name}`);
|
|
1121
|
+
console.log(` \u2192 ${hint}
|
|
1122
|
+
`);
|
|
1123
|
+
continue;
|
|
1078
1124
|
}
|
|
1125
|
+
process.stdout.write(` \u2713 ${b.name} (discovering models\u2026)\r`);
|
|
1126
|
+
const modelList = await b.models();
|
|
1127
|
+
const preview = modelList.slice(0, 6).join(" ");
|
|
1128
|
+
const extra = modelList.length > 6 ? ` +${modelList.length - 6} more` : "";
|
|
1129
|
+
console.log(` \u2713 ${b.name} `);
|
|
1130
|
+
console.log(` ${preview}${extra}
|
|
1131
|
+
`);
|
|
1079
1132
|
}
|
|
1080
|
-
console.log();
|
|
1081
1133
|
}
|
|
1082
1134
|
async function cmdChat(model2, backendFlag) {
|
|
1083
1135
|
const cfg = loadConfig();
|