agentgui 1.0.418 → 1.0.420

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.
@@ -97,19 +97,42 @@ export function register(router, deps) {
97
97
  return data;
98
98
  });
99
99
 
100
- router.handle('agent.ls', () => {
101
- // Get local agents only (avoid external HTTP calls in WebSocket to prevent recursion)
102
- const localAgents = discoveredAgents.map(agent => ({
103
- id: agent.id,
104
- name: agent.name,
105
- icon: agent.icon,
106
- path: agent.path,
107
- protocol: agent.protocol || 'unknown',
108
- description: agent.description || '',
109
- status: 'available'
110
- }));
111
-
112
- return { agents: localAgents };
100
+ router.handle('agent.ls', () => {
101
+ // Get local agents only (avoid external HTTP calls in WebSocket to prevent recursion)
102
+ const localAgents = discoveredAgents.map(agent => ({
103
+ id: agent.id,
104
+ name: agent.name,
105
+ icon: agent.icon,
106
+ path: agent.path,
107
+ protocol: agent.protocol || 'unknown',
108
+ description: agent.description || '',
109
+ status: 'available'
110
+ }));
111
+
112
+ return { agents: localAgents };
113
+ });
114
+
115
+ router.handle('agent.subagents', async (p) => {
116
+ const agent = discoveredAgents.find(x => x.id === p.id);
117
+ if (!agent) return { subAgents: [] };
118
+ try {
119
+ const port = agent.acpPort || 8080;
120
+ const res = await fetch(`http://localhost:${port}/agents/search`, {
121
+ method: 'POST',
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
136
  });
114
137
 
115
138
  router.handle('agent.get', (p) => {