agentgui 1.0.307 → 1.0.309
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 +48 -45
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -319,40 +319,11 @@ const modelCache = new Map();
|
|
|
319
319
|
|
|
320
320
|
const AGENT_MODEL_COMMANDS = {
|
|
321
321
|
'claude-code': 'claude models',
|
|
322
|
+
'gemini': 'gemini models',
|
|
322
323
|
'opencode': 'opencode models',
|
|
323
324
|
'kilo': 'kilo models',
|
|
324
325
|
};
|
|
325
326
|
|
|
326
|
-
const AGENT_DEFAULT_MODELS = {
|
|
327
|
-
'claude-code': [
|
|
328
|
-
{ id: '', label: 'Default' },
|
|
329
|
-
{ id: 'sonnet', label: 'Sonnet' },
|
|
330
|
-
{ id: 'opus', label: 'Opus' },
|
|
331
|
-
{ id: 'haiku', label: 'Haiku' },
|
|
332
|
-
{ id: 'claude-sonnet-4-5-20250929', label: 'Sonnet 4.5' },
|
|
333
|
-
{ id: 'claude-sonnet-4-6-20260219', label: 'Sonnet 4.6' },
|
|
334
|
-
{ id: 'claude-opus-4-6', label: 'Opus 4.6' },
|
|
335
|
-
{ id: 'claude-haiku-4-5-20251001', label: 'Haiku 4.5' }
|
|
336
|
-
],
|
|
337
|
-
'gemini': [
|
|
338
|
-
{ id: '', label: 'Default' },
|
|
339
|
-
{ id: 'gemini-2.5-pro', label: 'Gemini 2.5 Pro' },
|
|
340
|
-
{ id: 'gemini-2.5-flash', label: 'Gemini 2.5 Flash' },
|
|
341
|
-
{ id: 'gemini-2.0-flash', label: 'Gemini 2.0 Flash' }
|
|
342
|
-
],
|
|
343
|
-
'goose': [
|
|
344
|
-
{ id: '', label: 'Default' },
|
|
345
|
-
{ id: 'claude-sonnet-4-5', label: 'Sonnet 4.5' },
|
|
346
|
-
{ id: 'claude-opus-4-5', label: 'Opus 4.5' }
|
|
347
|
-
],
|
|
348
|
-
'codex': [
|
|
349
|
-
{ id: '', label: 'Default' },
|
|
350
|
-
{ id: 'o4-mini', label: 'o4-mini' },
|
|
351
|
-
{ id: 'o3', label: 'o3' },
|
|
352
|
-
{ id: 'o3-mini', label: 'o3-mini' }
|
|
353
|
-
]
|
|
354
|
-
};
|
|
355
|
-
|
|
356
327
|
async function fetchClaudeModelsFromAPI() {
|
|
357
328
|
const apiKey = process.env.ANTHROPIC_API_KEY;
|
|
358
329
|
if (!apiKey) return null;
|
|
@@ -387,19 +358,57 @@ async function fetchClaudeModelsFromAPI() {
|
|
|
387
358
|
} catch { return null; }
|
|
388
359
|
}
|
|
389
360
|
|
|
361
|
+
async function fetchGeminiModelsFromAPI() {
|
|
362
|
+
const apiKey = process.env.GOOGLE_GENAI_API_KEY;
|
|
363
|
+
if (!apiKey) return null;
|
|
364
|
+
try {
|
|
365
|
+
const https = await import('https');
|
|
366
|
+
return new Promise((resolve) => {
|
|
367
|
+
const req = https.default.request({
|
|
368
|
+
hostname: 'generativelanguage.googleapis.com',
|
|
369
|
+
path: '/v1beta/models?key=' + apiKey,
|
|
370
|
+
method: 'GET',
|
|
371
|
+
timeout: 8000
|
|
372
|
+
}, (res) => {
|
|
373
|
+
let body = '';
|
|
374
|
+
res.on('data', d => body += d);
|
|
375
|
+
res.on('end', () => {
|
|
376
|
+
try {
|
|
377
|
+
const data = JSON.parse(body);
|
|
378
|
+
const items = (data.models || []).filter(m => m.name && m.name.includes('gemini'));
|
|
379
|
+
if (items.length === 0) return resolve(null);
|
|
380
|
+
const models = [{ id: '', label: 'Default' }];
|
|
381
|
+
for (const m of items) {
|
|
382
|
+
const modelId = m.name.replace(/^models\//, '');
|
|
383
|
+
const label = modelId.replace(/-/g, ' ').replace(/\b\w/g, c => c.toUpperCase());
|
|
384
|
+
models.push({ id: modelId, label });
|
|
385
|
+
}
|
|
386
|
+
resolve(models);
|
|
387
|
+
} catch { resolve(null); }
|
|
388
|
+
});
|
|
389
|
+
});
|
|
390
|
+
req.on('error', () => resolve(null));
|
|
391
|
+
req.on('timeout', () => { req.destroy(); resolve(null); });
|
|
392
|
+
req.end();
|
|
393
|
+
});
|
|
394
|
+
} catch { return null; }
|
|
395
|
+
}
|
|
396
|
+
|
|
390
397
|
async function getModelsForAgent(agentId) {
|
|
391
398
|
const cached = modelCache.get(agentId);
|
|
392
399
|
if (cached && Date.now() - cached.timestamp < 3600000) {
|
|
393
400
|
return cached.models;
|
|
394
401
|
}
|
|
395
402
|
|
|
403
|
+
let models = null;
|
|
404
|
+
|
|
396
405
|
if (agentId === 'claude-code') {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
406
|
+
models = await fetchClaudeModelsFromAPI();
|
|
407
|
+
} else if (agentId === 'gemini') {
|
|
408
|
+
models = await fetchGeminiModelsFromAPI();
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
if (models) {
|
|
403
412
|
modelCache.set(agentId, { models, timestamp: Date.now() });
|
|
404
413
|
return models;
|
|
405
414
|
}
|
|
@@ -409,7 +418,7 @@ async function getModelsForAgent(agentId) {
|
|
|
409
418
|
const result = execSync(AGENT_MODEL_COMMANDS[agentId], { encoding: 'utf-8', timeout: 15000 });
|
|
410
419
|
const lines = result.split('\n').map(l => l.trim()).filter(Boolean);
|
|
411
420
|
if (lines.length > 0) {
|
|
412
|
-
|
|
421
|
+
models = [{ id: '', label: 'Default' }];
|
|
413
422
|
for (const line of lines) {
|
|
414
423
|
models.push({ id: line, label: line });
|
|
415
424
|
}
|
|
@@ -419,23 +428,17 @@ async function getModelsForAgent(agentId) {
|
|
|
419
428
|
} catch (_) {}
|
|
420
429
|
}
|
|
421
430
|
|
|
422
|
-
if (AGENT_DEFAULT_MODELS[agentId]) {
|
|
423
|
-
const models = AGENT_DEFAULT_MODELS[agentId];
|
|
424
|
-
modelCache.set(agentId, { models, timestamp: Date.now() });
|
|
425
|
-
return models;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
431
|
const { getRegisteredAgents } = await import('./lib/claude-runner.js');
|
|
429
432
|
const agents = getRegisteredAgents();
|
|
430
433
|
const agent = agents.find(a => a.id === agentId);
|
|
431
|
-
|
|
434
|
+
|
|
432
435
|
if (agent && agent.command) {
|
|
433
436
|
const modelCmd = `${agent.command} models`;
|
|
434
437
|
try {
|
|
435
438
|
const result = execSync(modelCmd, { encoding: 'utf-8', timeout: 15000 });
|
|
436
439
|
const lines = result.split('\n').map(l => l.trim()).filter(Boolean);
|
|
437
440
|
if (lines.length > 0) {
|
|
438
|
-
|
|
441
|
+
models = [{ id: '', label: 'Default' }];
|
|
439
442
|
for (const line of lines) {
|
|
440
443
|
models.push({ id: line, label: line });
|
|
441
444
|
}
|