agentgui 1.0.421 → 1.0.423
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/lib/ws-handlers-session.js +46 -39
- package/package.json +1 -1
- package/static/js/client.js +5 -0
|
@@ -60,6 +60,14 @@ function checkAgentAuth(agent) {
|
|
|
60
60
|
return s;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
async function acpFetch(port, path, body = null) {
|
|
64
|
+
const opts = { headers: { 'Content-Type': 'application/json' }, signal: AbortSignal.timeout(3000) };
|
|
65
|
+
if (body !== null) { opts.method = 'POST'; opts.body = JSON.stringify(body); }
|
|
66
|
+
const res = await fetch(`http://localhost:${port}${path}`, opts);
|
|
67
|
+
if (!res.ok) return null;
|
|
68
|
+
return res.json();
|
|
69
|
+
}
|
|
70
|
+
|
|
63
71
|
export function register(router, deps) {
|
|
64
72
|
const { db, discoveredAgents, getModelsForAgent, modelCache,
|
|
65
73
|
getAgentDescriptor, activeScripts, broadcastSync, startGeminiOAuth,
|
|
@@ -88,51 +96,23 @@ export function register(router, deps) {
|
|
|
88
96
|
router.handle('sess.exec', (p) => {
|
|
89
97
|
const limit = Math.min(parseInt(p.limit || '1000'), 5000);
|
|
90
98
|
const offset = Math.max(parseInt(p.offset || '0'), 0);
|
|
91
|
-
|
|
92
|
-
const data = {
|
|
93
|
-
sessionId: p.id, events: [], total: 0, limit, offset, hasMore: false,
|
|
94
|
-
metadata: { status: 'pending', startTime: Date.now(), duration: 0, eventCount: 0 }
|
|
95
|
-
};
|
|
96
|
-
if (filterType) data.events = data.events.filter(e => e.type === filterType);
|
|
97
|
-
return data;
|
|
99
|
+
return { sessionId: p.id, events: [], total: 0, limit, offset, hasMore: false, metadata: { status: 'pending', startTime: Date.now(), duration: 0, eventCount: 0 } };
|
|
98
100
|
});
|
|
99
101
|
|
|
100
|
-
router.handle('agent.ls', () => {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
path: agent.path,
|
|
107
|
-
protocol: agent.protocol || 'unknown',
|
|
108
|
-
description: agent.description || '',
|
|
109
|
-
status: 'available'
|
|
110
|
-
}));
|
|
111
|
-
|
|
112
|
-
return { agents: localAgents };
|
|
113
|
-
});
|
|
102
|
+
router.handle('agent.ls', () => ({
|
|
103
|
+
agents: discoveredAgents.map(a => ({
|
|
104
|
+
id: a.id, name: a.name, icon: a.icon, path: a.path,
|
|
105
|
+
protocol: a.protocol || 'unknown', description: a.description || '', status: 'available'
|
|
106
|
+
}))
|
|
107
|
+
}));
|
|
114
108
|
|
|
115
109
|
router.handle('agent.subagents', async (p) => {
|
|
116
110
|
const agent = discoveredAgents.find(x => x.id === p.id);
|
|
117
|
-
if (!agent) return { subAgents: [] };
|
|
111
|
+
if (!agent || agent.protocol !== 'acp') return { subAgents: [] };
|
|
118
112
|
try {
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
headers: { 'Content-Type': 'application/json' },
|
|
123
|
-
body: JSON.stringify({}),
|
|
124
|
-
signal: AbortSignal.timeout(3000)
|
|
125
|
-
});
|
|
126
|
-
if (!res.ok) return { subAgents: [] };
|
|
127
|
-
const data = await res.json();
|
|
128
|
-
const subAgents = (data.agents || []).map(a => ({
|
|
129
|
-
id: a.agent_id || a.id,
|
|
130
|
-
name: a.metadata?.ref?.name || a.name || a.agent_id || a.id
|
|
131
|
-
}));
|
|
132
|
-
return { subAgents };
|
|
133
|
-
} catch (_) {
|
|
134
|
-
return { subAgents: [] };
|
|
135
|
-
}
|
|
113
|
+
const data = await acpFetch(agent.acpPort || 8080, '/agents/search', {});
|
|
114
|
+
return { subAgents: (data?.agents || []).map(a => ({ id: a.agent_id || a.id, name: a.metadata?.ref?.name || a.name || a.agent_id || a.id })) };
|
|
115
|
+
} catch (_) { return { subAgents: [] }; }
|
|
136
116
|
});
|
|
137
117
|
|
|
138
118
|
router.handle('agent.get', (p) => {
|
|
@@ -150,6 +130,33 @@ export function register(router, deps) {
|
|
|
150
130
|
router.handle('agent.models', async (p) => {
|
|
151
131
|
const cached = modelCache.get(p.id);
|
|
152
132
|
if (cached && (Date.now() - cached.ts) < 300000) return { models: cached.models };
|
|
133
|
+
const agent = discoveredAgents.find(x => x.id === p.id);
|
|
134
|
+
if (agent?.protocol === 'acp') {
|
|
135
|
+
const port = agent.acpPort || 8080;
|
|
136
|
+
try {
|
|
137
|
+
const data = await acpFetch(port, '/v1/models');
|
|
138
|
+
const models = (data?.data || data?.models || []).map(m => ({
|
|
139
|
+
id: m.id || m.model_id,
|
|
140
|
+
label: m.name || m.display_name || m.id || m.model_id
|
|
141
|
+
})).filter(m => m.id);
|
|
142
|
+
if (models.length > 0) { modelCache.set(p.id, { models, ts: Date.now() }); return { models }; }
|
|
143
|
+
} catch (_) {}
|
|
144
|
+
try {
|
|
145
|
+
const data = await acpFetch(port, '/agents/search', {});
|
|
146
|
+
const allModels = new Map();
|
|
147
|
+
for (const a of (data?.agents || [])) {
|
|
148
|
+
for (const m of (a.metadata?.models || a.specs?.models || [])) {
|
|
149
|
+
const id = m.id || m;
|
|
150
|
+
if (id) allModels.set(id, m.name || m.label || id);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (allModels.size > 0) {
|
|
154
|
+
const models = Array.from(allModels.entries()).map(([id, label]) => ({ id, label }));
|
|
155
|
+
modelCache.set(p.id, { models, ts: Date.now() });
|
|
156
|
+
return { models };
|
|
157
|
+
}
|
|
158
|
+
} catch (_) {}
|
|
159
|
+
}
|
|
153
160
|
try {
|
|
154
161
|
const models = await getModelsForAgent(p.id);
|
|
155
162
|
modelCache.set(p.id, { models, ts: Date.now() });
|
package/package.json
CHANGED
package/static/js/client.js
CHANGED
|
@@ -363,6 +363,7 @@ class AgentGUIClient {
|
|
|
363
363
|
this.ui.cliSelector.addEventListener('change', () => {
|
|
364
364
|
if (!this._agentLocked) {
|
|
365
365
|
this.loadSubAgentsForCli(this.ui.cliSelector.value);
|
|
366
|
+
this.loadModelsForAgent(this.ui.cliSelector.value);
|
|
366
367
|
this.saveAgentAndModelToConversation();
|
|
367
368
|
}
|
|
368
369
|
});
|
|
@@ -1874,6 +1875,7 @@ class AgentGUIClient {
|
|
|
1874
1875
|
.map(a => `<option value="${a.id}">${a.name}</option>`)
|
|
1875
1876
|
.join('');
|
|
1876
1877
|
this.ui.agentSelector.style.display = 'inline-block';
|
|
1878
|
+
this.loadModelsForAgent(this.getEffectiveAgentId());
|
|
1877
1879
|
}
|
|
1878
1880
|
} catch (_) {
|
|
1879
1881
|
// No sub-agents available for this CLI tool — keep hidden
|
|
@@ -1951,6 +1953,9 @@ class AgentGUIClient {
|
|
|
1951
1953
|
this._agentLocked = false;
|
|
1952
1954
|
if (this.ui.cliSelector) {
|
|
1953
1955
|
this.ui.cliSelector.disabled = false;
|
|
1956
|
+
if (this.ui.cliSelector.options.length > 0) {
|
|
1957
|
+
this.ui.cliSelector.style.display = 'inline-block';
|
|
1958
|
+
}
|
|
1954
1959
|
}
|
|
1955
1960
|
if (this.ui.agentSelector) {
|
|
1956
1961
|
this.ui.agentSelector.disabled = false;
|