agentgui 1.0.430 → 1.0.431
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 +2 -81
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -442,87 +442,8 @@ function modelIdToLabel(id) {
|
|
|
442
442
|
return base.replace(/-/g, ' ').replace(/\b\w/g, c => c.toUpperCase());
|
|
443
443
|
}
|
|
444
444
|
|
|
445
|
-
async function
|
|
446
|
-
|
|
447
|
-
if (!apiKey) return null;
|
|
448
|
-
try {
|
|
449
|
-
const https = await import('https');
|
|
450
|
-
return new Promise((resolve) => {
|
|
451
|
-
const req = https.default.request({
|
|
452
|
-
hostname: 'api.anthropic.com', path: '/v1/models', method: 'GET',
|
|
453
|
-
headers: { 'x-api-key': apiKey, 'anthropic-version': '2023-06-01' },
|
|
454
|
-
timeout: 8000
|
|
455
|
-
}, (res) => {
|
|
456
|
-
let body = '';
|
|
457
|
-
res.on('data', d => body += d);
|
|
458
|
-
res.on('end', () => {
|
|
459
|
-
try {
|
|
460
|
-
const data = JSON.parse(body);
|
|
461
|
-
const items = (data.data || []).filter(m => m.id && m.id.startsWith('claude-'));
|
|
462
|
-
if (items.length === 0) return resolve(null);
|
|
463
|
-
const models = items.map(m => ({ id: m.id, label: m.display_name || modelIdToLabel(m.id) }));
|
|
464
|
-
resolve(models);
|
|
465
|
-
} catch { resolve(null); }
|
|
466
|
-
});
|
|
467
|
-
});
|
|
468
|
-
req.on('error', () => resolve(null));
|
|
469
|
-
req.on('timeout', () => { req.destroy(); resolve(null); });
|
|
470
|
-
req.end();
|
|
471
|
-
});
|
|
472
|
-
} catch { return null; }
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
async function fetchGeminiModelsFromAPI() {
|
|
476
|
-
const apiKey = process.env.GOOGLE_GENAI_API_KEY;
|
|
477
|
-
if (!apiKey) return null;
|
|
478
|
-
try {
|
|
479
|
-
const https = await import('https');
|
|
480
|
-
return new Promise((resolve) => {
|
|
481
|
-
const req = https.default.request({
|
|
482
|
-
hostname: 'generativelanguage.googleapis.com',
|
|
483
|
-
path: '/v1beta/models?key=' + apiKey,
|
|
484
|
-
method: 'GET',
|
|
485
|
-
timeout: 8000
|
|
486
|
-
}, (res) => {
|
|
487
|
-
let body = '';
|
|
488
|
-
res.on('data', d => body += d);
|
|
489
|
-
res.on('end', () => {
|
|
490
|
-
try {
|
|
491
|
-
const data = JSON.parse(body);
|
|
492
|
-
const items = (data.models || []).filter(m => m.name && m.name.includes('gemini'));
|
|
493
|
-
if (items.length === 0) return resolve(null);
|
|
494
|
-
const models = items.map(m => {
|
|
495
|
-
const modelId = m.name.replace(/^models\//, '');
|
|
496
|
-
return { id: modelId, label: modelId.replace(/-/g, ' ').replace(/\b\w/g, c => c.toUpperCase()) };
|
|
497
|
-
});
|
|
498
|
-
resolve(models);
|
|
499
|
-
} catch { resolve(null); }
|
|
500
|
-
});
|
|
501
|
-
});
|
|
502
|
-
req.on('error', () => resolve(null));
|
|
503
|
-
req.on('timeout', () => { req.destroy(); resolve(null); });
|
|
504
|
-
req.end();
|
|
505
|
-
});
|
|
506
|
-
} catch { return null; }
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
async function getModelsForAgent(agentId) {
|
|
510
|
-
const cached = modelCache.get(agentId);
|
|
511
|
-
if (cached && Date.now() - cached.timestamp < 3600000) {
|
|
512
|
-
return cached.models;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
let models = null;
|
|
516
|
-
|
|
517
|
-
if (agentId === 'claude-code') {
|
|
518
|
-
models = await fetchClaudeModelsFromAPI();
|
|
519
|
-
} else if (agentId === 'gemini') {
|
|
520
|
-
models = await fetchGeminiModelsFromAPI();
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
const result = models || [];
|
|
524
|
-
modelCache.set(agentId, { models: result, timestamp: Date.now() });
|
|
525
|
-
return result;
|
|
445
|
+
async function getModelsForAgent() {
|
|
446
|
+
return [];
|
|
526
447
|
}
|
|
527
448
|
|
|
528
449
|
const GEMINI_SCOPES = [
|