agentgui 1.0.345 → 1.0.346
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/package.json +1 -1
- package/server.js +36 -15
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -306,19 +306,36 @@ const AGENT_MODEL_COMMANDS = {
|
|
|
306
306
|
'kilo': 'kilo models',
|
|
307
307
|
};
|
|
308
308
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
{ id: 'claude-haiku-4-5', label: 'Claude Haiku 4.5' },
|
|
316
|
-
{ id: 'claude-opus-4-5', label: 'Claude Opus 4.5' },
|
|
317
|
-
{ id: 'claude-sonnet-4-0', label: 'Claude Sonnet 4' },
|
|
318
|
-
{ id: 'claude-opus-4-0', label: 'Claude Opus 4' },
|
|
319
|
-
],
|
|
320
|
-
};
|
|
309
|
+
function modelIdToLabel(id) {
|
|
310
|
+
const base = id.replace(/^claude-/, '').replace(/-\d{8}$/, '');
|
|
311
|
+
const m = base.match(/^(\w+)-(\d+)(?:-(\d+))?$/);
|
|
312
|
+
if (m) return `${m[1].charAt(0).toUpperCase() + m[1].slice(1)} ${m[3] ? m[2] + '.' + m[3] : m[2]}`;
|
|
313
|
+
return base.replace(/-/g, ' ').replace(/\b\w/g, c => c.toUpperCase());
|
|
314
|
+
}
|
|
321
315
|
|
|
316
|
+
function extractModelsFromClaudeCLI() {
|
|
317
|
+
try {
|
|
318
|
+
const cliPath = path.resolve('./node_modules/@anthropic-ai/claude-code/cli.js');
|
|
319
|
+
if (!fs.existsSync(cliPath)) return null;
|
|
320
|
+
const src = fs.readFileSync(cliPath, 'utf8');
|
|
321
|
+
const re = /=\{firstParty:"(claude-[^"]+)",bedrock:"[^"]+",vertex:"[^"]+"/g;
|
|
322
|
+
const ids = new Set();
|
|
323
|
+
let m;
|
|
324
|
+
while ((m = re.exec(src)) !== null) ids.add(m[1]);
|
|
325
|
+
if (ids.size === 0) return null;
|
|
326
|
+
const models = [{ id: '', label: 'Default' }];
|
|
327
|
+
const sorted = [...ids].sort((a, b) => {
|
|
328
|
+
const va = a.replace(/claude-/, '').replace(/-\d{8}$/, '');
|
|
329
|
+
const vb = b.replace(/claude-/, '').replace(/-\d{8}$/, '');
|
|
330
|
+
return vb.localeCompare(va);
|
|
331
|
+
});
|
|
332
|
+
for (const id of sorted) {
|
|
333
|
+
if (id.startsWith('claude-3-')) continue;
|
|
334
|
+
models.push({ id, label: modelIdToLabel(id) });
|
|
335
|
+
}
|
|
336
|
+
return models;
|
|
337
|
+
} catch { return null; }
|
|
338
|
+
}
|
|
322
339
|
|
|
323
340
|
async function fetchClaudeModelsFromAPI() {
|
|
324
341
|
const apiKey = process.env.ANTHROPIC_API_KEY;
|
|
@@ -340,7 +357,7 @@ async function fetchClaudeModelsFromAPI() {
|
|
|
340
357
|
if (items.length === 0) return resolve(null);
|
|
341
358
|
const models = [{ id: '', label: 'Default' }];
|
|
342
359
|
for (const m of items) {
|
|
343
|
-
const label = m.display_name || m.id
|
|
360
|
+
const label = m.display_name || modelIdToLabel(m.id);
|
|
344
361
|
models.push({ id: m.id, label });
|
|
345
362
|
}
|
|
346
363
|
resolve(models);
|
|
@@ -444,8 +461,12 @@ async function getModelsForAgent(agentId) {
|
|
|
444
461
|
} catch (_) {}
|
|
445
462
|
}
|
|
446
463
|
|
|
447
|
-
if (
|
|
448
|
-
|
|
464
|
+
if (agentId === 'claude-code') {
|
|
465
|
+
const cliModels = extractModelsFromClaudeCLI();
|
|
466
|
+
if (cliModels) {
|
|
467
|
+
modelCache.set(agentId, { models: cliModels, timestamp: Date.now() });
|
|
468
|
+
return cliModels;
|
|
469
|
+
}
|
|
449
470
|
}
|
|
450
471
|
|
|
451
472
|
return [];
|