agentgui 1.0.714 → 1.0.716

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.
@@ -1,332 +1,47 @@
1
- const agentDescriptorCache = new Map();
2
-
3
- function generateClaudeCodeDescriptor(agent) {
4
- return {
5
- metadata: {
6
- ref: {
7
- name: agent.name,
8
- version: '1.0.0',
9
- url: agent.path
10
- },
11
- description: 'Claude Code is an AI coding agent that can read, write, and execute code with streaming output support. It provides comprehensive code editing, file management, and terminal execution capabilities.'
12
- },
13
- specs: {
14
- capabilities: {
15
- threads: true,
16
- interrupts: false,
17
- callbacks: false,
18
- streaming: {
19
- values: false,
20
- custom: true
21
- }
22
- },
23
- input: {
24
- type: 'object',
25
- properties: {
26
- content: {
27
- type: 'string',
28
- description: 'The user prompt or instruction to send to the agent'
29
- },
30
- model: {
31
- type: 'string',
32
- description: 'Optional model identifier to use for this run'
33
- }
34
- },
35
- required: ['content']
36
- },
37
- output: {
38
- type: 'object',
39
- properties: {
40
- result: {
41
- type: 'string',
42
- description: 'The final response or result from the agent'
43
- },
44
- events: {
45
- type: 'array',
46
- description: 'Stream of execution events (tool calls, outputs, etc.)',
47
- items: { type: 'object' }
48
- }
49
- }
50
- },
51
- custom_streaming_update: {
52
- type: 'object',
53
- properties: {
54
- type: {
55
- type: 'string',
56
- enum: ['text', 'tool_use', 'tool_result', 'error']
57
- },
58
- data: { type: 'object' }
59
- }
60
- },
61
- thread_state: {
62
- type: 'object',
63
- description: 'Conversation history with messages and session state',
64
- properties: {
65
- messages: {
66
- type: 'array',
67
- items: { type: 'object' }
68
- },
69
- sessionId: { type: 'string' }
70
- }
71
- },
72
- config: {
73
- type: 'object',
74
- properties: {
75
- workingDirectory: {
76
- type: 'string',
77
- description: 'Working directory for file operations'
78
- },
79
- model: {
80
- type: 'string',
81
- description: 'Default model to use'
82
- }
83
- }
84
- }
85
- }
86
- };
87
- }
88
-
89
- function generateGeminiDescriptor(agent) {
90
- return {
91
- metadata: {
92
- ref: {
93
- name: agent.name,
94
- version: '1.0.0',
95
- url: agent.path
96
- },
97
- description: 'Gemini CLI is Google AI coding agent with streaming support, code execution, and file management capabilities.'
98
- },
99
- specs: {
100
- capabilities: {
101
- threads: true,
102
- interrupts: false,
103
- callbacks: false,
104
- streaming: {
105
- values: false,
106
- custom: true
107
- }
108
- },
109
- input: {
110
- type: 'object',
111
- properties: {
112
- content: {
113
- type: 'string',
114
- description: 'The user prompt or instruction to send to the agent'
115
- },
116
- model: {
117
- type: 'string',
118
- description: 'Optional model identifier to use for this run'
119
- }
120
- },
121
- required: ['content']
122
- },
123
- output: {
124
- type: 'object',
125
- properties: {
126
- result: {
127
- type: 'string',
128
- description: 'The final response or result from the agent'
129
- },
130
- events: {
131
- type: 'array',
132
- description: 'Stream of execution events',
133
- items: { type: 'object' }
134
- }
135
- }
136
- },
137
- custom_streaming_update: {
138
- type: 'object',
139
- properties: {
140
- type: { type: 'string' },
141
- data: { type: 'object' }
142
- }
143
- },
144
- thread_state: {
145
- type: 'object',
146
- description: 'Conversation history and session state',
147
- properties: {
148
- messages: {
149
- type: 'array',
150
- items: { type: 'object' }
151
- }
152
- }
153
- },
154
- config: {
155
- type: 'object',
156
- properties: {
157
- workingDirectory: {
158
- type: 'string',
159
- description: 'Working directory for file operations'
160
- },
161
- model: {
162
- type: 'string',
163
- description: 'Model identifier'
164
- }
165
- }
166
- }
167
- }
168
- };
169
- }
170
-
171
- function generateOpenCodeDescriptor(agent) {
172
- return {
173
- metadata: {
174
- ref: {
175
- name: agent.name,
176
- version: '1.0.0',
177
- url: agent.path
178
- },
179
- description: 'OpenCode is a multi-provider AI coding agent with streaming support and comprehensive code manipulation capabilities.'
180
- },
181
- specs: {
182
- capabilities: {
183
- threads: true,
184
- interrupts: false,
185
- callbacks: false,
186
- streaming: {
187
- values: false,
188
- custom: true
189
- }
190
- },
191
- input: {
192
- type: 'object',
193
- properties: {
194
- content: {
195
- type: 'string',
196
- description: 'The user prompt or instruction'
197
- },
198
- model: {
199
- type: 'string',
200
- description: 'Model identifier'
201
- }
202
- },
203
- required: ['content']
204
- },
205
- output: {
206
- type: 'object',
207
- properties: {
208
- result: { type: 'string' },
209
- events: {
210
- type: 'array',
211
- items: { type: 'object' }
212
- }
213
- }
214
- },
215
- custom_streaming_update: {
216
- type: 'object',
217
- properties: {
218
- type: { type: 'string' },
219
- data: { type: 'object' }
220
- }
221
- },
222
- thread_state: {
223
- type: 'object',
224
- properties: {
225
- messages: {
226
- type: 'array',
227
- items: { type: 'object' }
228
- }
229
- }
230
- },
231
- config: {
232
- type: 'object',
233
- properties: {
234
- workingDirectory: { type: 'string' },
235
- model: { type: 'string' }
236
- }
237
- }
238
- }
239
- };
240
- }
241
-
242
- function generateGenericDescriptor(agent) {
243
- return {
244
- metadata: {
245
- ref: {
246
- name: agent.name,
247
- version: '1.0.0',
248
- url: agent.path
249
- },
250
- description: `${agent.name} is an AI coding agent with basic streaming and execution capabilities.`
251
- },
252
- specs: {
253
- capabilities: {
254
- threads: true,
255
- interrupts: false,
256
- callbacks: false,
257
- streaming: {
258
- values: false,
259
- custom: true
260
- }
261
- },
262
- input: {
263
- type: 'object',
264
- properties: {
265
- content: {
266
- type: 'string',
267
- description: 'User prompt or instruction'
268
- }
269
- },
270
- required: ['content']
271
- },
272
- output: {
273
- type: 'object',
274
- properties: {
275
- result: { type: 'string' }
276
- }
277
- },
278
- custom_streaming_update: {
279
- type: 'object',
280
- properties: {
281
- type: { type: 'string' },
282
- data: { type: 'object' }
283
- }
284
- },
285
- thread_state: {
286
- type: 'object',
287
- properties: {
288
- messages: {
289
- type: 'array',
290
- items: { type: 'object' }
291
- }
292
- }
293
- },
294
- config: {
295
- type: 'object',
296
- properties: {
297
- workingDirectory: { type: 'string' }
298
- }
299
- }
300
- }
301
- };
302
- }
303
-
304
- function generateAgentDescriptor(agent) {
305
- switch (agent.id) {
306
- case 'claude-code':
307
- return generateClaudeCodeDescriptor(agent);
308
- case 'gemini':
309
- return generateGeminiDescriptor(agent);
310
- case 'opencode':
311
- return generateOpenCodeDescriptor(agent);
312
- default:
313
- return generateGenericDescriptor(agent);
314
- }
315
- }
316
-
317
- export function initializeDescriptors(agents) {
318
- agentDescriptorCache.clear();
319
- for (const agent of agents) {
320
- const descriptor = generateAgentDescriptor(agent);
321
- agentDescriptorCache.set(agent.id, descriptor);
322
- }
323
- return agentDescriptorCache.size;
324
- }
325
-
326
- export function getAgentDescriptor(agentId) {
327
- return agentDescriptorCache.get(agentId) || null;
328
- }
329
-
330
- export function getAllDescriptors() {
331
- return Object.fromEntries(agentDescriptorCache);
332
- }
1
+ const agentDescriptorCache = new Map();
2
+
3
+ const AGENT_DESCRIPTIONS = {
4
+ 'claude-code': 'Claude Code is an AI coding agent that can read, write, and execute code with streaming output support. It provides comprehensive code editing, file management, and terminal execution capabilities.',
5
+ 'gemini': 'Gemini CLI is Google AI coding agent with streaming support, code execution, and file management capabilities.',
6
+ 'opencode': 'OpenCode is a multi-provider AI coding agent with streaming support and comprehensive code manipulation capabilities.',
7
+ };
8
+
9
+ const BASE_SPECS = {
10
+ capabilities: { threads: true, interrupts: false, callbacks: false, streaming: { values: false, custom: true } },
11
+ input: { type: 'object', properties: { content: { type: 'string', description: 'The user prompt or instruction to send to the agent' } }, required: ['content'] },
12
+ output: { type: 'object', properties: { result: { type: 'string' } } },
13
+ custom_streaming_update: { type: 'object', properties: { type: { type: 'string' }, data: { type: 'object' } } },
14
+ thread_state: { type: 'object', properties: { messages: { type: 'array', items: { type: 'object' } } } },
15
+ config: { type: 'object', properties: { workingDirectory: { type: 'string' } } },
16
+ };
17
+
18
+ function buildDescriptor(agent) {
19
+ const description = AGENT_DESCRIPTIONS[agent.id] || `${agent.name} is an AI coding agent with basic streaming and execution capabilities.`;
20
+ const specs = JSON.parse(JSON.stringify(BASE_SPECS));
21
+ if (agent.id === 'claude-code' || agent.id === 'gemini' || agent.id === 'opencode') {
22
+ specs.input.properties.model = { type: 'string', description: 'Optional model identifier to use for this run' };
23
+ specs.output.properties.events = { type: 'array', description: 'Stream of execution events', items: { type: 'object' } };
24
+ specs.config.properties.model = { type: 'string' };
25
+ }
26
+ if (agent.id === 'claude-code') {
27
+ specs.thread_state.description = 'Conversation history with messages and session state';
28
+ specs.thread_state.properties.sessionId = { type: 'string' };
29
+ specs.config.properties.model.description = 'Default model to use';
30
+ specs.config.properties.workingDirectory.description = 'Working directory for file operations';
31
+ }
32
+ return { metadata: { ref: { name: agent.name, version: '1.0.0', url: agent.path }, description }, specs };
33
+ }
34
+
35
+ export function initializeDescriptors(agents) {
36
+ agentDescriptorCache.clear();
37
+ for (const agent of agents) agentDescriptorCache.set(agent.id, buildDescriptor(agent));
38
+ return agentDescriptorCache.size;
39
+ }
40
+
41
+ export function getAgentDescriptor(agentId) {
42
+ return agentDescriptorCache.get(agentId) || null;
43
+ }
44
+
45
+ export function getAllDescriptors() {
46
+ return Object.fromEntries(agentDescriptorCache);
47
+ }
@@ -0,0 +1,125 @@
1
+ import { acpProtocolHandler } from './acp-protocol.js';
2
+
3
+ const SIMPLE_ACP_AGENTS = [
4
+ { id: 'goose', name: 'Goose', command: 'goose' },
5
+ { id: 'openhands', name: 'OpenHands', command: 'openhands' },
6
+ { id: 'augment', name: 'Augment Code', command: 'augment' },
7
+ { id: 'cline', name: 'Cline', command: 'cline' },
8
+ { id: 'kimi', name: 'Kimi CLI', command: 'kimi' },
9
+ { id: 'qwen', name: 'Qwen Code', command: 'qwen-code' },
10
+ { id: 'codex', name: 'Codex CLI', command: 'codex' },
11
+ { id: 'mistral', name: 'Mistral Vibe', command: 'mistral-vibe' },
12
+ { id: 'kiro', name: 'Kiro CLI', command: 'kiro' },
13
+ { id: 'fast-agent', name: 'fast-agent', command: 'fast-agent' },
14
+ ];
15
+
16
+ function parseClaudeOutput(line) {
17
+ try {
18
+ const entry = JSON.parse(line);
19
+ if (!entry || typeof entry !== 'object') return null;
20
+ if (entry.type === 'user' && entry.isMeta === true) return null;
21
+ if (entry.isApiErrorMessage === true && entry.error === 'rate_limit') {
22
+ entry._rateLimitDetected = true;
23
+ }
24
+ if (entry.type === 'assistant' && entry.message) {
25
+ entry._isFragment = entry.message.stop_reason === null || entry.message.stop_reason === undefined;
26
+ }
27
+ if (entry.type === 'system' && entry.subtype === 'turn_duration' && entry.durationMs) {
28
+ entry._turnDurationMs = entry.durationMs;
29
+ }
30
+ if (entry.type === 'system' && entry.subtype === 'compact_boundary' && entry.compactMetadata) {
31
+ entry._preTokens = entry.compactMetadata.preTokens;
32
+ }
33
+ if (entry.message?.usage) {
34
+ const u = entry.message.usage;
35
+ entry._cacheUsage = {
36
+ cache_creation: u.cache_creation_input_tokens || u['cache_creation.ephemeral_1h_input_tokens'] || u['cache_creation.ephemeral_5m_input_tokens'] || 0,
37
+ cache_read: u.cache_read_input_tokens || 0
38
+ };
39
+ }
40
+ return entry;
41
+ } catch {
42
+ return null;
43
+ }
44
+ }
45
+
46
+ export function registerAllAgents(registry) {
47
+ registry.register({
48
+ id: 'claude-code',
49
+ name: 'Claude Code',
50
+ command: 'claude',
51
+ protocol: 'direct',
52
+ supportsStdin: false,
53
+ closeStdin: true,
54
+ useJsonRpcStdin: false,
55
+ supportedFeatures: ['streaming', 'resume', 'system-prompt', 'permissions-skip', 'steering'],
56
+ spawnEnv: { MAX_THINKING_TOKENS: '0', AGENTGUI_SUBPROCESS: '1' },
57
+ buildArgs(prompt, config) {
58
+ const { verbose = true, outputFormat = 'stream-json', print = true, resumeSessionId = null, systemPrompt = null, model = null } = config;
59
+ const flags = [];
60
+ if (print) flags.push('--print');
61
+ if (verbose) flags.push('--verbose');
62
+ flags.push(`--output-format=${outputFormat}`);
63
+ if (model) flags.push('--model', model);
64
+ if (resumeSessionId) flags.push('--resume', resumeSessionId);
65
+ if (systemPrompt) flags.push('--append-system-prompt', systemPrompt);
66
+ flags.push('--dangerously-skip-permissions');
67
+ flags.push(typeof prompt === 'string' ? prompt : String(prompt));
68
+ return flags;
69
+ },
70
+ parseOutput: parseClaudeOutput,
71
+ });
72
+
73
+ registry.register({
74
+ id: 'opencode',
75
+ name: 'OpenCode',
76
+ command: 'opencode',
77
+ protocol: 'acp',
78
+ supportsStdin: false,
79
+ npxPackage: 'opencode-ai',
80
+ supportedFeatures: ['streaming', 'resume', 'acp-protocol'],
81
+ buildArgs: () => ['acp'],
82
+ protocolHandler: acpProtocolHandler,
83
+ });
84
+
85
+ registry.register({
86
+ id: 'gemini',
87
+ name: 'Gemini CLI',
88
+ command: 'gemini',
89
+ protocol: 'acp',
90
+ supportsStdin: false,
91
+ npxPackage: '@google/gemini-cli',
92
+ supportedFeatures: ['streaming', 'resume', 'acp-protocol'],
93
+ buildArgs(prompt, config) {
94
+ const args = ['--experimental-acp', '--yolo'];
95
+ if (config?.model) args.push('--model', config.model);
96
+ return args;
97
+ },
98
+ protocolHandler: acpProtocolHandler,
99
+ });
100
+
101
+ registry.register({
102
+ id: 'kilo',
103
+ name: 'Kilo CLI',
104
+ command: 'kilo',
105
+ protocol: 'acp',
106
+ supportsStdin: false,
107
+ npxPackage: '@kilocode/cli',
108
+ supportedFeatures: ['streaming', 'resume', 'acp-protocol', 'models'],
109
+ buildArgs: () => ['acp'],
110
+ protocolHandler: acpProtocolHandler,
111
+ });
112
+
113
+ for (const agent of SIMPLE_ACP_AGENTS) {
114
+ registry.register({
115
+ id: agent.id,
116
+ name: agent.name,
117
+ command: agent.command,
118
+ protocol: 'acp',
119
+ supportsStdin: false,
120
+ supportedFeatures: ['streaming', 'resume', 'acp-protocol'],
121
+ buildArgs: () => ['acp'],
122
+ protocolHandler: acpProtocolHandler,
123
+ });
124
+ }
125
+ }