agentgui 1.0.989 → 1.0.991
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/agent-discovery.js +2 -82
- package/lib/process-message.js +2 -4
- package/lib/server-startup.js +0 -1
- package/lib/server-utils.js +1 -9
- package/package.json +1 -1
- package/server.js +1 -1
- package/test.js +7 -7
package/lib/agent-discovery.js
CHANGED
|
@@ -23,13 +23,6 @@ const BINARIES = [
|
|
|
23
23
|
{ cmd: 'hermes', id: 'hermes', name: 'Hermes Agent', icon: 'h', protocol: 'acp' },
|
|
24
24
|
];
|
|
25
25
|
|
|
26
|
-
const CLI_WRAPPERS = [
|
|
27
|
-
{ id: 'cli-opencode', name: 'OpenCode', icon: 'O', protocol: 'cli-wrapper', acpId: 'opencode' },
|
|
28
|
-
{ id: 'cli-gemini', name: 'Gemini', icon: 'G', protocol: 'cli-wrapper', acpId: 'gemini' },
|
|
29
|
-
{ id: 'cli-kilo', name: 'Kilo', icon: 'K', protocol: 'cli-wrapper', acpId: 'kilo' },
|
|
30
|
-
{ id: 'cli-codex', name: 'Codex', icon: 'X', protocol: 'cli-wrapper', acpId: 'codex' },
|
|
31
|
-
];
|
|
32
|
-
|
|
33
26
|
export function findCommand(cmd, rootDir) {
|
|
34
27
|
if (!cmd) return null;
|
|
35
28
|
const isWindows = os.platform() === 'win32';
|
|
@@ -66,57 +59,6 @@ export function findCommand(cmd, rootDir) {
|
|
|
66
59
|
return null;
|
|
67
60
|
}
|
|
68
61
|
|
|
69
|
-
export async function queryACPServerAgents(baseUrl) {
|
|
70
|
-
const endpoint = baseUrl.endsWith('/') ? baseUrl + 'agents/search' : baseUrl + '/agents/search';
|
|
71
|
-
try {
|
|
72
|
-
const response = await fetch(endpoint, {
|
|
73
|
-
method: 'POST',
|
|
74
|
-
headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' },
|
|
75
|
-
body: JSON.stringify({}),
|
|
76
|
-
signal: AbortSignal.timeout(5000)
|
|
77
|
-
});
|
|
78
|
-
if (!response.ok) {
|
|
79
|
-
console.error(`Failed to query ACP agents from ${baseUrl}: ${response.status}`);
|
|
80
|
-
return [];
|
|
81
|
-
}
|
|
82
|
-
const data = await response.json();
|
|
83
|
-
if (!data?.agents || !Array.isArray(data.agents)) {
|
|
84
|
-
console.error(`Invalid agents response from ${baseUrl}`);
|
|
85
|
-
return [];
|
|
86
|
-
}
|
|
87
|
-
return data.agents.map(agent => ({
|
|
88
|
-
id: agent.agent_id || agent.id,
|
|
89
|
-
name: agent.metadata?.ref?.name || agent.name || 'Unknown Agent',
|
|
90
|
-
metadata: {
|
|
91
|
-
ref: {
|
|
92
|
-
name: agent.metadata?.ref?.name,
|
|
93
|
-
version: agent.metadata?.ref?.version,
|
|
94
|
-
url: agent.metadata?.ref?.url,
|
|
95
|
-
tags: agent.metadata?.ref?.tags
|
|
96
|
-
},
|
|
97
|
-
description: agent.metadata?.description,
|
|
98
|
-
author: agent.metadata?.author,
|
|
99
|
-
license: agent.metadata?.license
|
|
100
|
-
},
|
|
101
|
-
specs: agent.specs ? {
|
|
102
|
-
capabilities: agent.specs.capabilities,
|
|
103
|
-
input_schema: agent.specs.input_schema || agent.specs.input,
|
|
104
|
-
output_schema: agent.specs.output_schema || agent.specs.output,
|
|
105
|
-
thread_state_schema: agent.specs.thread_state_schema || agent.specs.thread_state,
|
|
106
|
-
config_schema: agent.specs.config_schema || agent.specs.config,
|
|
107
|
-
custom_streaming_update_schema: agent.specs.custom_streaming_update_schema || agent.specs.custom_streaming_update
|
|
108
|
-
} : null,
|
|
109
|
-
custom_data: agent.custom_data,
|
|
110
|
-
icon: agent.metadata?.ref?.name?.charAt(0) || 'A',
|
|
111
|
-
protocol: 'acp',
|
|
112
|
-
path: baseUrl
|
|
113
|
-
}));
|
|
114
|
-
} catch (error) {
|
|
115
|
-
console.error(`ACP agents query failed for ${baseUrl}: ${error.message}`);
|
|
116
|
-
return [];
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
62
|
export function discoverAgents(rootDir) {
|
|
121
63
|
const agents = [];
|
|
122
64
|
for (const bin of BINARIES) {
|
|
@@ -130,30 +72,8 @@ export function discoverAgents(rootDir) {
|
|
|
130
72
|
}
|
|
131
73
|
}
|
|
132
74
|
|
|
133
|
-
console.log('[discoverAgents]
|
|
134
|
-
|
|
135
|
-
if (agents.some(a => a.id === wrapper.acpId)) {
|
|
136
|
-
console.log(`[discoverAgents] Adding CLI wrapper for ${wrapper.id}`);
|
|
137
|
-
agents.push(wrapper);
|
|
138
|
-
} else {
|
|
139
|
-
console.log(`[discoverAgents] Skipping CLI wrapper ${wrapper.id} (ACP agent ${wrapper.acpId} not found)`);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
const wrappedAcpIds = new Set(CLI_WRAPPERS.filter(w => agents.some(a => a.id === w.acpId)).map(w => w.acpId));
|
|
143
|
-
const filtered = agents.filter(a => !wrappedAcpIds.has(a.id));
|
|
144
|
-
console.log('[discoverAgents] Final agent count:', filtered.length, 'Agent IDs:', filtered.map(a => a.id).join(', '));
|
|
145
|
-
return filtered;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export async function discoverExternalACPServers(discoveredAgents) {
|
|
149
|
-
const externalAgents = [];
|
|
150
|
-
for (const agent of discoveredAgents.filter(a => a.protocol === 'acp' && a.acpPort)) {
|
|
151
|
-
try {
|
|
152
|
-
const agents = await queryACPServerAgents(`http://localhost:${agent.acpPort}`);
|
|
153
|
-
externalAgents.push(...agents);
|
|
154
|
-
} catch (_) {}
|
|
155
|
-
}
|
|
156
|
-
return externalAgents;
|
|
75
|
+
console.log('[discoverAgents] Final agent count:', agents.length, 'Agent IDs:', agents.map(a => a.id).join(', '));
|
|
76
|
+
return agents;
|
|
157
77
|
}
|
|
158
78
|
|
|
159
79
|
export async function initializeAgentDiscovery(discoveredAgents, rootDir, logError) {
|
package/lib/process-message.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function createProcessMessage({ queries, activeExecutions, rateLimitState, execMachine, broadcastSync, runClaudeWithStreaming, cleanupExecution,
|
|
1
|
+
export function createProcessMessage({ queries, activeExecutions, rateLimitState, execMachine, broadcastSync, runClaudeWithStreaming, cleanupExecution, STARTUP_CWD, buildSystemPrompt, parseRateLimitResetTime, touchACP, getJsonlWatcher, debugLog, logError, scheduleRetry, drainMessageQueue, createEventHandler }) {
|
|
2
2
|
async function processMessageWithStreaming(conversationId, messageId, sessionId, content, agentId, model, subAgent) {
|
|
3
3
|
const startTime = Date.now();
|
|
4
4
|
touchACP(agentId);
|
|
@@ -31,9 +31,7 @@ export function createProcessMessage({ queries, activeExecutions, rateLimitState
|
|
|
31
31
|
// Resolve agent before building stateRef so isJsonlBacked can be set correctly.
|
|
32
32
|
// claude-code (protocol: direct) writes JSONL -> JsonlParser owns event broadcasting.
|
|
33
33
|
// All other agents (protocol: acp) rely solely on onEvent for streaming.
|
|
34
|
-
|
|
35
|
-
const wrapperAgent = discoveredAgents.find(a => a.id === resolvedAgentId && a.protocol === 'cli-wrapper' && a.acpId);
|
|
36
|
-
if (wrapperAgent) resolvedAgentId = wrapperAgent.acpId;
|
|
34
|
+
const resolvedAgentId = agentId || 'claude-code';
|
|
37
35
|
const isJsonlBacked = resolvedAgentId === 'claude-code';
|
|
38
36
|
// stateRef tracks eventCount (for session response metadata) and resumeSessionId
|
|
39
37
|
const stateRef = { eventCount: 0, resumeSessionId: conv?.claudeSessionId || null };
|
package/lib/server-startup.js
CHANGED
|
@@ -41,7 +41,6 @@ export function createOnServerReady({ queries, broadcastSync, warmAssetCache, st
|
|
|
41
41
|
console.log('[ACP] On-demand startup enabled (ACP tools start when first used)');
|
|
42
42
|
setTimeout(() => {
|
|
43
43
|
const acpStatus = getACPStatus();
|
|
44
|
-
for (const s of acpStatus) { if (s.healthy) { const agent = discoveredAgents.find(a => a.id === s.id); if (agent) agent.acpPort = s.port; } }
|
|
45
44
|
if (acpStatus.length > 0) console.log(`[ACP] Tools ready: ${acpStatus.filter(s => s.healthy).map(s => s.id + ':' + s.port).join(', ') || 'none healthy yet'}`);
|
|
46
45
|
}, 6000);
|
|
47
46
|
}).catch(err => console.error('[ACP] Startup error:', err.message));
|
package/lib/server-utils.js
CHANGED
|
@@ -45,18 +45,10 @@ export function makeGetModelsForAgent(deps) {
|
|
|
45
45
|
{ id: 'opus', label: 'Opus' }
|
|
46
46
|
];
|
|
47
47
|
} else {
|
|
48
|
-
|
|
49
|
-
// but discoverAgents() replaces each found ACP agent with its cli-wrapper
|
|
50
|
-
// entry whose own id is prefixed ('cli-opencode') and whose acpId carries
|
|
51
|
-
// the original id. Match on acpId too so model discovery resolves the
|
|
52
|
-
// wrapper instead of finding nothing and silently returning [] models.
|
|
53
|
-
const agent = discoveredAgents.find(a => a.id === agentId || a.acpId === agentId);
|
|
48
|
+
const agent = discoveredAgents.find(a => a.id === agentId);
|
|
54
49
|
if (agent?.protocol === 'acp') {
|
|
55
50
|
await ensureRunning(agentId);
|
|
56
51
|
try { models = await queryACPModels(agentId); } catch (_) {}
|
|
57
|
-
} else if (agent?.protocol === 'cli-wrapper' && agent.acpId) {
|
|
58
|
-
await ensureRunning(agent.acpId);
|
|
59
|
-
try { models = await queryACPModels(agent.acpId); } catch (_) {}
|
|
60
52
|
}
|
|
61
53
|
}
|
|
62
54
|
modelCache.set(agentId, { models, timestamp: Date.now() });
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -9,7 +9,7 @@ import { createHistoryRouter } from 'ccsniff';
|
|
|
9
9
|
import { queries } from './database.js';
|
|
10
10
|
import { runClaudeWithStreaming } from './lib/claude-runner-run.js';
|
|
11
11
|
import { initializeDescriptors, getAgentDescriptor } from './lib/agent-descriptors.js';
|
|
12
|
-
import {
|
|
12
|
+
import { initializeAgentDiscovery } from './lib/agent-discovery.js';
|
|
13
13
|
import { register as registerWsHandlers } from './lib/ws-handlers-util.js';
|
|
14
14
|
import { BROADCAST_TYPES } from './lib/broadcast.js';
|
|
15
15
|
import { WSOptimizer } from './lib/ws-optimizer.js';
|
package/test.js
CHANGED
|
@@ -340,13 +340,13 @@ await ok('cross-tab-storage: "updated in another tab" banner on stale load', ()
|
|
|
340
340
|
}
|
|
341
341
|
});
|
|
342
342
|
|
|
343
|
-
await ok('agents.models:
|
|
344
|
-
//
|
|
345
|
-
//
|
|
346
|
-
//
|
|
347
|
-
//
|
|
343
|
+
await ok('agents.models: ACP agent reaches ensureRunning + queryACPModels (not empty)', async () => {
|
|
344
|
+
// discoveredAgents and the client both use the canonical registry id
|
|
345
|
+
// ('opencode', protocol 'acp'). getModelsForAgent must start the ACP server
|
|
346
|
+
// and query it - a regression once silently returned [] for every ACP agent
|
|
347
|
+
// because of an id-scheme mismatch.
|
|
348
348
|
const { makeGetModelsForAgent } = await import('./lib/server-utils.js');
|
|
349
|
-
const discoveredAgents = [{ id: '
|
|
349
|
+
const discoveredAgents = [{ id: 'opencode', protocol: 'acp' }];
|
|
350
350
|
const calls = [];
|
|
351
351
|
const getModels = makeGetModelsForAgent({
|
|
352
352
|
modelCache: new Map(),
|
|
@@ -355,7 +355,7 @@ await ok('agents.models: resolves cli-wrapper by acpId (registry id, not wrapper
|
|
|
355
355
|
queryACPModels: async (id) => { calls.push(['query', id]); return [{ id: 'm1', label: 'M1' }]; },
|
|
356
356
|
});
|
|
357
357
|
const models = await getModels('opencode');
|
|
358
|
-
assert.deepEqual(calls, [['ensure', 'opencode'], ['query', 'opencode']], 'should ensureRunning + query
|
|
358
|
+
assert.deepEqual(calls, [['ensure', 'opencode'], ['query', 'opencode']], 'should ensureRunning + query the ACP agent');
|
|
359
359
|
assert.equal(models.length, 1, 'should return the ACP-provided models, not an empty list');
|
|
360
360
|
});
|
|
361
361
|
|