agentgui 1.0.344 → 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 -14
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -306,18 +306,36 @@ const AGENT_MODEL_COMMANDS = {
|
|
|
306
306
|
'kilo': 'kilo models',
|
|
307
307
|
};
|
|
308
308
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
{ id: 'claude-opus-4-5', label: 'Claude Opus 4.5' },
|
|
316
|
-
{ id: 'claude-sonnet-4-0', label: 'Claude Sonnet 4' },
|
|
317
|
-
{ id: 'claude-opus-4-0', label: 'Claude Opus 4' },
|
|
318
|
-
],
|
|
319
|
-
};
|
|
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
|
+
}
|
|
320
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
|
+
}
|
|
321
339
|
|
|
322
340
|
async function fetchClaudeModelsFromAPI() {
|
|
323
341
|
const apiKey = process.env.ANTHROPIC_API_KEY;
|
|
@@ -339,7 +357,7 @@ async function fetchClaudeModelsFromAPI() {
|
|
|
339
357
|
if (items.length === 0) return resolve(null);
|
|
340
358
|
const models = [{ id: '', label: 'Default' }];
|
|
341
359
|
for (const m of items) {
|
|
342
|
-
const label = m.display_name || m.id
|
|
360
|
+
const label = m.display_name || modelIdToLabel(m.id);
|
|
343
361
|
models.push({ id: m.id, label });
|
|
344
362
|
}
|
|
345
363
|
resolve(models);
|
|
@@ -443,8 +461,12 @@ async function getModelsForAgent(agentId) {
|
|
|
443
461
|
} catch (_) {}
|
|
444
462
|
}
|
|
445
463
|
|
|
446
|
-
if (
|
|
447
|
-
|
|
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
|
+
}
|
|
448
470
|
}
|
|
449
471
|
|
|
450
472
|
return [];
|