genaicode 2.21.0 → 2.22.0
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/README.md +1 -0
- package/dist/acp/server.d.ts +38 -0
- package/dist/acp/server.js +475 -0
- package/dist/acp/server.js.map +1 -0
- package/dist/cli/args.d.ts +6 -0
- package/dist/cli/args.js +19 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/main.d.ts +3 -1
- package/dist/cli/main.js +31 -0
- package/dist/cli/main.js.map +1 -1
- package/docs/CHANGELOG.md +9 -0
- package/docs/app-agent.md +66 -0
- package/docs/cli.md +19 -3
- package/docs/embedding.md +166 -0
- package/docs/skills/genaicode-embed/SKILL.md +80 -10
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -42,6 +42,7 @@ log in to (`npx genaicode agents` lists what it finds).
|
|
|
42
42
|
| A panel in your dev server | `genaicode/vite`, `createDevOverlay` | [vite.md](docs/vite.md) |
|
|
43
43
|
| A chat component | `genaicode/react` `<AgentChat>` | [react.md](docs/react.md) |
|
|
44
44
|
| An agent inside your own app | `genaicode/app-agent` | [app-agent.md](docs/app-agent.md) |
|
|
45
|
+
| Editors, desktop, game engines | `genaicode acp`, `genaicode/ui` | [embedding.md](docs/embedding.md) |
|
|
45
46
|
| A thin LLM layer | `genaicode`, `genaicode/providers` | [llm.md](docs/llm.md) |
|
|
46
47
|
|
|
47
48
|
```ts
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { AgentEvent, CodingAgent } from '../agents/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* `genaicode acp`: the agent side of the Agent Client Protocol (https://agentclientprotocol.com),
|
|
4
|
+
* version 1, over newline-delimited JSON-RPC. A host in any language (an editor, a game engine's
|
|
5
|
+
* editor, a native app) starts the process, opens sessions and sends prompts; each prompt is one
|
|
6
|
+
* run of the chosen agent CLI, and the agent's own session continues on the next prompt.
|
|
7
|
+
*
|
|
8
|
+
* The host picks the agent, its effort and the approval mode through session config options.
|
|
9
|
+
* Permission prompts reach the host as `session/request_permission`.
|
|
10
|
+
*/
|
|
11
|
+
export declare const ACP_PROTOCOL_VERSION = 1;
|
|
12
|
+
export interface AcpServerOptions {
|
|
13
|
+
/** Agents to offer; only the installed ones are listed. */
|
|
14
|
+
agents: readonly CodingAgent[];
|
|
15
|
+
/** Agent new sessions start with. Default: the first installed one. */
|
|
16
|
+
agent?: string;
|
|
17
|
+
model?: string;
|
|
18
|
+
effort?: string;
|
|
19
|
+
/** Start sessions in auto-approve mode. */
|
|
20
|
+
approveAll?: boolean;
|
|
21
|
+
env?: NodeJS.ProcessEnv;
|
|
22
|
+
version: string;
|
|
23
|
+
input: NodeJS.ReadableStream;
|
|
24
|
+
output: {
|
|
25
|
+
write(chunk: string): unknown;
|
|
26
|
+
};
|
|
27
|
+
/** Ends the connection as if the host closed it: running prompts stop. */
|
|
28
|
+
signal?: AbortSignal;
|
|
29
|
+
}
|
|
30
|
+
/** Serve ACP until `input` ends. Resolves once every running prompt has stopped. */
|
|
31
|
+
export declare function serveAcp(options: AcpServerOptions): Promise<void>;
|
|
32
|
+
/** The prompt's content blocks as the text the agent CLI gets. */
|
|
33
|
+
export declare function promptText(blocks: unknown): string;
|
|
34
|
+
/**
|
|
35
|
+
* Turns the agent's events into ACP `session/update` values. Streamed text goes out as it comes;
|
|
36
|
+
* a final `message` adds only what the stream did not already show.
|
|
37
|
+
*/
|
|
38
|
+
export declare function createEventMapper(): (event: AgentEvent) => Array<Record<string, unknown>>;
|
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { createInterface } from 'node:readline';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { detectAgents } from '../agents/discovery.js';
|
|
5
|
+
import { RpcError, RpcPeer } from '../agents/rpc.js';
|
|
6
|
+
/**
|
|
7
|
+
* `genaicode acp`: the agent side of the Agent Client Protocol (https://agentclientprotocol.com),
|
|
8
|
+
* version 1, over newline-delimited JSON-RPC. A host in any language (an editor, a game engine's
|
|
9
|
+
* editor, a native app) starts the process, opens sessions and sends prompts; each prompt is one
|
|
10
|
+
* run of the chosen agent CLI, and the agent's own session continues on the next prompt.
|
|
11
|
+
*
|
|
12
|
+
* The host picks the agent, its effort and the approval mode through session config options.
|
|
13
|
+
* Permission prompts reach the host as `session/request_permission`.
|
|
14
|
+
*/
|
|
15
|
+
export const ACP_PROTOCOL_VERSION = 1;
|
|
16
|
+
const NO_TIMEOUT = 2 ** 31 - 1;
|
|
17
|
+
/** Serve ACP until `input` ends. Resolves once every running prompt has stopped. */
|
|
18
|
+
export async function serveAcp(options) {
|
|
19
|
+
const env = options.env ?? process.env;
|
|
20
|
+
const installed = detectAgents(options.agents, env)
|
|
21
|
+
.filter(({ path }) => path)
|
|
22
|
+
.map(({ agent }) => agent);
|
|
23
|
+
const sessions = new Map();
|
|
24
|
+
const peer = new RpcPeer((line) => options.output.write(`${line}\n`), {
|
|
25
|
+
notification(method, params) {
|
|
26
|
+
if (method === 'session/cancel')
|
|
27
|
+
sessions.get(sessionIdOf(params))?.run?.abort();
|
|
28
|
+
},
|
|
29
|
+
request(method, params) {
|
|
30
|
+
switch (method) {
|
|
31
|
+
case 'initialize':
|
|
32
|
+
return initialize();
|
|
33
|
+
case 'session/new':
|
|
34
|
+
return newSession(params);
|
|
35
|
+
case 'session/set_config_option':
|
|
36
|
+
return setConfigOption(params);
|
|
37
|
+
case 'session/prompt':
|
|
38
|
+
return prompt(params);
|
|
39
|
+
case 'session/close': {
|
|
40
|
+
const session = takeSession(params);
|
|
41
|
+
session.run?.abort();
|
|
42
|
+
sessions.delete(session.id);
|
|
43
|
+
return {};
|
|
44
|
+
}
|
|
45
|
+
default:
|
|
46
|
+
throw new RpcError(`Method not found: ${method}`, -32601);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
function initialize() {
|
|
51
|
+
return {
|
|
52
|
+
protocolVersion: ACP_PROTOCOL_VERSION,
|
|
53
|
+
agentCapabilities: {
|
|
54
|
+
loadSession: false,
|
|
55
|
+
promptCapabilities: { image: false, audio: false, embeddedContext: true },
|
|
56
|
+
mcpCapabilities: { http: true, sse: false },
|
|
57
|
+
sessionCapabilities: { close: {} },
|
|
58
|
+
},
|
|
59
|
+
agentInfo: { name: 'genaicode', title: 'genaicode', version: options.version },
|
|
60
|
+
authMethods: [],
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/** Agents that can run this session's prompts: with MCP servers, only drivers that attach them. */
|
|
64
|
+
function usable(mcpServers) {
|
|
65
|
+
return mcpServers.length > 0 ? installed.filter((agent) => agent.capabilities.mcp) : installed;
|
|
66
|
+
}
|
|
67
|
+
function newSession(params) {
|
|
68
|
+
if (typeof params?.cwd !== 'string' || params.cwd === '')
|
|
69
|
+
throw invalid('cwd is required.');
|
|
70
|
+
const names = new Set();
|
|
71
|
+
const mcpServers = (params.mcpServers ?? []).map((server) => toMcpServer(server, names));
|
|
72
|
+
const agents = usable(mcpServers);
|
|
73
|
+
const agent = options.agent ? installed.find((candidate) => candidate.name === options.agent) : agents[0];
|
|
74
|
+
if (!agent) {
|
|
75
|
+
throw new RpcError(options.agent
|
|
76
|
+
? `Agent "${options.agent}" is not installed.`
|
|
77
|
+
: installed.length > 0
|
|
78
|
+
? `None of the installed agents (${installed.map((a) => a.name).join(', ')}) supports MCP servers.`
|
|
79
|
+
: `No supported agent CLI found on PATH. Install one of: ${options.agents.map((a) => a.command).join(', ')}.`, -32603);
|
|
80
|
+
}
|
|
81
|
+
if (!agents.includes(agent))
|
|
82
|
+
throw invalid(`${agent.name} does not support MCP servers in genaicode.`);
|
|
83
|
+
const session = {
|
|
84
|
+
id: randomUUID(),
|
|
85
|
+
cwd: params.cwd,
|
|
86
|
+
mcpServers,
|
|
87
|
+
agent,
|
|
88
|
+
effort: effortFor(agent, options.effort),
|
|
89
|
+
mode: options.approveAll ? 'auto-approve' : 'ask',
|
|
90
|
+
};
|
|
91
|
+
sessions.set(session.id, session);
|
|
92
|
+
return { sessionId: session.id, configOptions: configOptions(session) };
|
|
93
|
+
}
|
|
94
|
+
function setConfigOption(params) {
|
|
95
|
+
const session = takeSession(params);
|
|
96
|
+
const value = params.value;
|
|
97
|
+
if (typeof value !== 'string')
|
|
98
|
+
throw invalid(`${params.configId} takes one of its listed values.`);
|
|
99
|
+
switch (params.configId) {
|
|
100
|
+
case 'agent': {
|
|
101
|
+
if (session.run)
|
|
102
|
+
throw invalid('Wait for the running prompt to end before switching agents.');
|
|
103
|
+
const agent = installed.find((candidate) => candidate.name === value);
|
|
104
|
+
if (!agent)
|
|
105
|
+
throw invalid(`Agent "${value}" is not installed.`);
|
|
106
|
+
if (!usable(session.mcpServers).includes(agent)) {
|
|
107
|
+
throw invalid(`${agent.name} does not support MCP servers in genaicode.`);
|
|
108
|
+
}
|
|
109
|
+
if (agent !== session.agent) {
|
|
110
|
+
// The next agent cannot continue the previous one's session.
|
|
111
|
+
session.agent = agent;
|
|
112
|
+
session.agentSessionId = undefined;
|
|
113
|
+
session.effort = effortFor(agent, session.effort);
|
|
114
|
+
}
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
case 'effort':
|
|
118
|
+
if (value !== 'default' && !session.agent.capabilities.effort?.includes(value)) {
|
|
119
|
+
throw invalid(`${session.agent.name} has no effort "${value}".`);
|
|
120
|
+
}
|
|
121
|
+
session.effort = value === 'default' ? undefined : value;
|
|
122
|
+
break;
|
|
123
|
+
case 'mode':
|
|
124
|
+
if (value !== 'ask' && value !== 'auto-approve')
|
|
125
|
+
throw invalid(`Unknown mode "${value}".`);
|
|
126
|
+
session.mode = value;
|
|
127
|
+
break;
|
|
128
|
+
default:
|
|
129
|
+
throw invalid(`Unknown config option "${String(params.configId)}".`);
|
|
130
|
+
}
|
|
131
|
+
return { configOptions: configOptions(session) };
|
|
132
|
+
}
|
|
133
|
+
async function prompt(params) {
|
|
134
|
+
const session = takeSession(params);
|
|
135
|
+
if (session.run)
|
|
136
|
+
throw invalid('A prompt is already running in this session.');
|
|
137
|
+
const text = promptText(params.prompt);
|
|
138
|
+
if (!text)
|
|
139
|
+
throw invalid('The prompt is empty.');
|
|
140
|
+
const update = (value) => peer.notify('session/update', { sessionId: session.id, update: value });
|
|
141
|
+
const toUpdates = createEventMapper();
|
|
142
|
+
const run = session.agent.run({
|
|
143
|
+
prompt: text,
|
|
144
|
+
cwd: session.cwd,
|
|
145
|
+
model: options.model,
|
|
146
|
+
effort: session.effort,
|
|
147
|
+
// A driver that cannot resume starts each prompt fresh instead of refusing it.
|
|
148
|
+
resume: session.agent.capabilities.resume ? session.agentSessionId : undefined,
|
|
149
|
+
env,
|
|
150
|
+
...(session.mcpServers.length > 0 ? { mcpServers: session.mcpServers } : {}),
|
|
151
|
+
// Approvals are decided here, as in `genaicode chat`: not every driver takes
|
|
152
|
+
// `permissions.approval`, but every one that asks goes through onApproval.
|
|
153
|
+
onApproval: (request, signal) => session.mode === 'auto-approve' ? 'approve' : askHost(session.id, request, signal),
|
|
154
|
+
});
|
|
155
|
+
session.run = run;
|
|
156
|
+
let result;
|
|
157
|
+
try {
|
|
158
|
+
for await (const event of run) {
|
|
159
|
+
if (event.type === 'session')
|
|
160
|
+
session.agentSessionId = event.sessionId;
|
|
161
|
+
for (const value of toUpdates(event))
|
|
162
|
+
update(value);
|
|
163
|
+
}
|
|
164
|
+
result = await run.result;
|
|
165
|
+
}
|
|
166
|
+
finally {
|
|
167
|
+
session.run = undefined;
|
|
168
|
+
}
|
|
169
|
+
if (result.sessionId)
|
|
170
|
+
session.agentSessionId = result.sessionId;
|
|
171
|
+
if (result.status === 'aborted')
|
|
172
|
+
return { stopReason: 'cancelled' };
|
|
173
|
+
if (!result.ok)
|
|
174
|
+
throw new RpcError(result.error ?? `${session.agent.name} failed (${result.status}).`, -32603);
|
|
175
|
+
return { stopReason: 'end_turn' };
|
|
176
|
+
}
|
|
177
|
+
async function askHost(sessionId, request, signal) {
|
|
178
|
+
if (signal?.aborted)
|
|
179
|
+
return 'deny';
|
|
180
|
+
const answer = peer.request('session/request_permission', {
|
|
181
|
+
sessionId,
|
|
182
|
+
toolCall: {
|
|
183
|
+
toolCallId: request.id, // Claude: the id of the tool call it asks about
|
|
184
|
+
title: request.summary ?? approvalTitle(request.kind),
|
|
185
|
+
kind: request.kind === 'command' ? 'execute' : request.kind === 'file-change' ? 'edit' : 'other',
|
|
186
|
+
status: 'pending',
|
|
187
|
+
...(request.detail === undefined ? {} : { rawInput: request.detail }),
|
|
188
|
+
},
|
|
189
|
+
options: [
|
|
190
|
+
{
|
|
191
|
+
optionId: 'approve',
|
|
192
|
+
name: request.scope === 'turn' ? 'Allow for this turn' : 'Allow',
|
|
193
|
+
kind: 'allow_once',
|
|
194
|
+
},
|
|
195
|
+
{ optionId: 'deny', name: 'Reject', kind: 'reject_once' },
|
|
196
|
+
],
|
|
197
|
+
}, NO_TIMEOUT);
|
|
198
|
+
const withdrawn = new Promise((resolve) => signal?.addEventListener('abort', () => resolve(undefined)));
|
|
199
|
+
try {
|
|
200
|
+
const response = (await Promise.race([answer, withdrawn]));
|
|
201
|
+
return response?.outcome?.outcome === 'selected' && response.outcome.optionId === 'approve' && !signal?.aborted
|
|
202
|
+
? 'approve'
|
|
203
|
+
: 'deny';
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
return 'deny';
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
function configOptions(session) {
|
|
210
|
+
const config = [
|
|
211
|
+
{
|
|
212
|
+
id: 'agent',
|
|
213
|
+
name: 'Agent',
|
|
214
|
+
description: 'The coding agent CLI that runs the prompts. Switching starts a new conversation.',
|
|
215
|
+
category: 'model',
|
|
216
|
+
type: 'select',
|
|
217
|
+
currentValue: session.agent.name,
|
|
218
|
+
options: usable(session.mcpServers).map((agent) => ({ value: agent.name, name: agent.name })),
|
|
219
|
+
},
|
|
220
|
+
];
|
|
221
|
+
const efforts = session.agent.capabilities.effort ?? [];
|
|
222
|
+
if (efforts.length > 0) {
|
|
223
|
+
config.push({
|
|
224
|
+
id: 'effort',
|
|
225
|
+
name: 'Effort',
|
|
226
|
+
category: 'thought_level',
|
|
227
|
+
type: 'select',
|
|
228
|
+
currentValue: session.effort ?? 'default',
|
|
229
|
+
options: [{ value: 'default', name: 'Default' }, ...efforts.map((value) => ({ value, name: value }))],
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
config.push({
|
|
233
|
+
id: 'mode',
|
|
234
|
+
name: 'Approvals',
|
|
235
|
+
category: 'mode',
|
|
236
|
+
type: 'select',
|
|
237
|
+
currentValue: session.mode,
|
|
238
|
+
options: [
|
|
239
|
+
{ value: 'ask', name: 'Ask', description: 'Ask before the agent runs a command or edits a file.' },
|
|
240
|
+
{ value: 'auto-approve', name: 'Auto-approve', description: 'Approve every permission request.' },
|
|
241
|
+
],
|
|
242
|
+
});
|
|
243
|
+
return config;
|
|
244
|
+
}
|
|
245
|
+
function takeSession(params) {
|
|
246
|
+
const session = sessions.get(sessionIdOf(params));
|
|
247
|
+
if (!session)
|
|
248
|
+
throw invalid('Unknown session.');
|
|
249
|
+
return session;
|
|
250
|
+
}
|
|
251
|
+
const lines = createInterface({ input: options.input, crlfDelay: Infinity });
|
|
252
|
+
// Closing the interface ends the loop below even when the input itself never ends.
|
|
253
|
+
if (options.signal?.aborted)
|
|
254
|
+
lines.close();
|
|
255
|
+
options.signal?.addEventListener('abort', () => lines.close(), { once: true });
|
|
256
|
+
for await (const line of lines) {
|
|
257
|
+
if (line.trim() === '')
|
|
258
|
+
continue;
|
|
259
|
+
let message;
|
|
260
|
+
try {
|
|
261
|
+
message = JSON.parse(line);
|
|
262
|
+
}
|
|
263
|
+
catch {
|
|
264
|
+
options.output.write(`${JSON.stringify({ jsonrpc: '2.0', id: null, error: { code: -32700, message: 'Parse error' } })}\n`);
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
267
|
+
peer.receive(message);
|
|
268
|
+
}
|
|
269
|
+
// The host went away: stop what still runs and let it settle.
|
|
270
|
+
const running = [...sessions.values()].flatMap((session) => (session.run ? [session.run] : []));
|
|
271
|
+
peer.fail(new Error('The client closed the connection.'));
|
|
272
|
+
for (const run of running)
|
|
273
|
+
run.abort();
|
|
274
|
+
await Promise.allSettled(running.map((run) => run.result));
|
|
275
|
+
}
|
|
276
|
+
function toMcpServer(server, taken) {
|
|
277
|
+
// genaicode server names are /^[A-Za-z0-9_-]+$/ and unique; ACP allows any.
|
|
278
|
+
const base = String(server.name ?? '').replace(/[^A-Za-z0-9_-]/g, '_') || 'mcp';
|
|
279
|
+
let name = base;
|
|
280
|
+
for (let n = 2; taken.has(name); n++)
|
|
281
|
+
name = `${base}_${n}`;
|
|
282
|
+
taken.add(name);
|
|
283
|
+
if ('url' in server && typeof server.url === 'string') {
|
|
284
|
+
if (server.type === 'sse')
|
|
285
|
+
throw invalid(`MCP server "${server.name}": SSE is not supported; use HTTP.`);
|
|
286
|
+
return { name, url: server.url, headers: pairs(server.headers) };
|
|
287
|
+
}
|
|
288
|
+
if ('command' in server && typeof server.command === 'string') {
|
|
289
|
+
return { name, command: server.command, args: server.args ?? [], env: pairs(server.env) };
|
|
290
|
+
}
|
|
291
|
+
throw invalid(`MCP server "${String(server.name)}" has neither a url nor a command.`);
|
|
292
|
+
}
|
|
293
|
+
function pairs(list) {
|
|
294
|
+
return Object.fromEntries((list ?? []).map(({ name, value }) => [name, value]));
|
|
295
|
+
}
|
|
296
|
+
function effortFor(agent, effort) {
|
|
297
|
+
return effort !== undefined && agent.capabilities.effort?.includes(effort) ? effort : undefined;
|
|
298
|
+
}
|
|
299
|
+
function sessionIdOf(params) {
|
|
300
|
+
const id = params?.sessionId;
|
|
301
|
+
return typeof id === 'string' ? id : '';
|
|
302
|
+
}
|
|
303
|
+
function invalid(message) {
|
|
304
|
+
return new RpcError(message, -32602);
|
|
305
|
+
}
|
|
306
|
+
function approvalTitle(kind) {
|
|
307
|
+
return kind === 'command' ? 'Run a command' : kind === 'file-change' ? 'Edit files' : 'Permission request';
|
|
308
|
+
}
|
|
309
|
+
/** The prompt's content blocks as the text the agent CLI gets. */
|
|
310
|
+
export function promptText(blocks) {
|
|
311
|
+
if (!Array.isArray(blocks))
|
|
312
|
+
throw invalid('prompt must be an array of content blocks.');
|
|
313
|
+
const parts = [];
|
|
314
|
+
for (const block of blocks) {
|
|
315
|
+
switch (block?.type) {
|
|
316
|
+
case 'text':
|
|
317
|
+
parts.push(String(block.text ?? ''));
|
|
318
|
+
break;
|
|
319
|
+
case 'resource_link':
|
|
320
|
+
parts.push(`@${pathOf(String(block.uri ?? ''))}`);
|
|
321
|
+
break;
|
|
322
|
+
case 'resource': {
|
|
323
|
+
const resource = (block.resource ?? {});
|
|
324
|
+
const where = pathOf(String(resource.uri ?? ''));
|
|
325
|
+
if (typeof resource.text === 'string')
|
|
326
|
+
parts.push(`${where}:\n\`\`\`\n${resource.text}\n\`\`\``);
|
|
327
|
+
else
|
|
328
|
+
parts.push(`@${where}`);
|
|
329
|
+
break;
|
|
330
|
+
}
|
|
331
|
+
default:
|
|
332
|
+
throw invalid(`Unsupported content block "${String(block?.type)}".`);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return parts.join('\n').trim();
|
|
336
|
+
}
|
|
337
|
+
function pathOf(uri) {
|
|
338
|
+
if (!uri.startsWith('file://'))
|
|
339
|
+
return uri;
|
|
340
|
+
try {
|
|
341
|
+
return fileURLToPath(uri);
|
|
342
|
+
}
|
|
343
|
+
catch {
|
|
344
|
+
return uri;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Turns the agent's events into ACP `session/update` values. Streamed text goes out as it comes;
|
|
349
|
+
* a final `message` adds only what the stream did not already show.
|
|
350
|
+
*/
|
|
351
|
+
export function createEventMapper() {
|
|
352
|
+
let streamed = '';
|
|
353
|
+
let messageId = randomUUID();
|
|
354
|
+
let toolCalls = 0;
|
|
355
|
+
const open = new Map();
|
|
356
|
+
const chunk = (text) => ({
|
|
357
|
+
sessionUpdate: 'agent_message_chunk',
|
|
358
|
+
messageId,
|
|
359
|
+
content: { type: 'text', text },
|
|
360
|
+
});
|
|
361
|
+
const nextMessage = () => {
|
|
362
|
+
streamed = '';
|
|
363
|
+
messageId = randomUUID();
|
|
364
|
+
};
|
|
365
|
+
return (event) => {
|
|
366
|
+
switch (event.type) {
|
|
367
|
+
case 'text-delta':
|
|
368
|
+
streamed += event.text;
|
|
369
|
+
return event.text ? [chunk(event.text)] : [];
|
|
370
|
+
case 'message': {
|
|
371
|
+
const rest = event.text.startsWith(streamed) ? event.text.slice(streamed.length) : streamed ? '' : event.text;
|
|
372
|
+
const update = rest ? [chunk(rest)] : [];
|
|
373
|
+
nextMessage();
|
|
374
|
+
return update;
|
|
375
|
+
}
|
|
376
|
+
case 'tool-start': {
|
|
377
|
+
// Text after the tool is a new ACP message, but some drivers end with one `message` holding
|
|
378
|
+
// the whole reply, so `streamed` keeps counting until that message arrives.
|
|
379
|
+
if (streamed)
|
|
380
|
+
messageId = randomUUID();
|
|
381
|
+
const toolCallId = event.id ?? `tool-${++toolCalls}`;
|
|
382
|
+
open.set(event.name, toolCallId);
|
|
383
|
+
return [
|
|
384
|
+
{
|
|
385
|
+
sessionUpdate: 'tool_call',
|
|
386
|
+
toolCallId,
|
|
387
|
+
title: toolTitle(event.name, event.input),
|
|
388
|
+
name: event.name,
|
|
389
|
+
kind: toolKind(event.name),
|
|
390
|
+
status: 'in_progress',
|
|
391
|
+
...(event.input === undefined ? {} : { rawInput: event.input }),
|
|
392
|
+
...locationsOf(event.input),
|
|
393
|
+
},
|
|
394
|
+
];
|
|
395
|
+
}
|
|
396
|
+
case 'tool-end': {
|
|
397
|
+
const toolCallId = event.id ?? (event.name ? open.get(event.name) : undefined);
|
|
398
|
+
if (!toolCallId)
|
|
399
|
+
return [];
|
|
400
|
+
if (event.name)
|
|
401
|
+
open.delete(event.name);
|
|
402
|
+
return [
|
|
403
|
+
{
|
|
404
|
+
sessionUpdate: 'tool_call_update',
|
|
405
|
+
toolCallId,
|
|
406
|
+
status: event.isError ? 'failed' : 'completed',
|
|
407
|
+
...(event.output
|
|
408
|
+
? {
|
|
409
|
+
content: [{ type: 'content', content: { type: 'text', text: event.output } }],
|
|
410
|
+
rawOutput: event.output,
|
|
411
|
+
}
|
|
412
|
+
: {}),
|
|
413
|
+
},
|
|
414
|
+
];
|
|
415
|
+
}
|
|
416
|
+
case 'file-change':
|
|
417
|
+
return [
|
|
418
|
+
{
|
|
419
|
+
sessionUpdate: 'tool_call',
|
|
420
|
+
toolCallId: `files-${++toolCalls}`,
|
|
421
|
+
title: `Changed ${event.paths.join(', ')}`,
|
|
422
|
+
kind: 'edit',
|
|
423
|
+
status: 'completed',
|
|
424
|
+
locations: event.paths.map((path) => ({ path })),
|
|
425
|
+
},
|
|
426
|
+
];
|
|
427
|
+
default:
|
|
428
|
+
return [];
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
function toolKind(name) {
|
|
433
|
+
const lower = name.toLowerCase();
|
|
434
|
+
if (/bash|shell|exec|command|terminal|run/.test(lower))
|
|
435
|
+
return 'execute';
|
|
436
|
+
if (/edit|write|patch|apply|create|file_change/.test(lower))
|
|
437
|
+
return 'edit';
|
|
438
|
+
if (/delete|remove/.test(lower))
|
|
439
|
+
return 'delete';
|
|
440
|
+
if (/grep|glob|search|find|list|ls/.test(lower))
|
|
441
|
+
return 'search';
|
|
442
|
+
if (/read|view|cat|open/.test(lower))
|
|
443
|
+
return 'read';
|
|
444
|
+
if (/fetch|web|http|url/.test(lower))
|
|
445
|
+
return 'fetch';
|
|
446
|
+
if (/think|todo|plan/.test(lower))
|
|
447
|
+
return 'think';
|
|
448
|
+
return 'other';
|
|
449
|
+
}
|
|
450
|
+
function toolTitle(name, input) {
|
|
451
|
+
if (input && typeof input === 'object') {
|
|
452
|
+
const fields = input;
|
|
453
|
+
for (const key of ['command', 'cmd', 'file_path', 'path', 'pattern', 'query', 'url', 'description']) {
|
|
454
|
+
const value = fields[key];
|
|
455
|
+
if (typeof value === 'string' && value.trim())
|
|
456
|
+
return `${name}: ${oneLine(value)}`;
|
|
457
|
+
if (Array.isArray(value) && value.every((part) => typeof part === 'string')) {
|
|
458
|
+
return `${name}: ${oneLine(value.join(' '))}`;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
return name;
|
|
463
|
+
}
|
|
464
|
+
function locationsOf(input) {
|
|
465
|
+
if (!input || typeof input !== 'object')
|
|
466
|
+
return {};
|
|
467
|
+
const fields = input;
|
|
468
|
+
const path = [fields.file_path, fields.path, fields.notebook_path].find((value) => typeof value === 'string' && value !== '');
|
|
469
|
+
return path ? { locations: [{ path }] } : {};
|
|
470
|
+
}
|
|
471
|
+
function oneLine(text) {
|
|
472
|
+
const line = text.replace(/\s+/g, ' ').trim();
|
|
473
|
+
return line.length > 120 ? `${line.slice(0, 117)}...` : line;
|
|
474
|
+
}
|
|
475
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/acp/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAGrD;;;;;;;;GAQG;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAiCtC,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AAE/B,oFAAoF;AACpF,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,OAAyB;IACtD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,C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AE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAC/C,CAAC;AAED,SAAS,OAAO,CAAC,IAAY;IAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IAC9C,OAAO,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAC/D,CAAC"}
|
package/dist/cli/args.d.ts
CHANGED
package/dist/cli/args.js
CHANGED
|
@@ -79,6 +79,25 @@ export function parseCli(argv) {
|
|
|
79
79
|
open: values['no-open'] !== true,
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
|
+
if (command === 'acp') {
|
|
83
|
+
const { values } = parse(() => parseArgs({
|
|
84
|
+
args: rest,
|
|
85
|
+
strict: true,
|
|
86
|
+
options: {
|
|
87
|
+
agent: { type: 'string', short: 'a' },
|
|
88
|
+
model: { type: 'string', short: 'm' },
|
|
89
|
+
effort: { type: 'string' },
|
|
90
|
+
yes: { type: 'boolean', short: 'y' },
|
|
91
|
+
},
|
|
92
|
+
}));
|
|
93
|
+
return {
|
|
94
|
+
kind: 'acp',
|
|
95
|
+
agent: values.agent,
|
|
96
|
+
model: values.model,
|
|
97
|
+
effort: values.effort,
|
|
98
|
+
approveAll: values.yes === true,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
82
101
|
if (command === 'run') {
|
|
83
102
|
const { values, positionals } = parse(() => parseArgs({
|
|
84
103
|
args: rest,
|
package/dist/cli/args.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.js","sourceRoot":"","sources":["../../src/cli/args.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version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AAO,GAAG,IAAI;YAC7D,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,UAAU,EAAE,cAAc,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,eAAe,CAAC,IAAI,CAAC;YACvE,IAAI,EAAE,MAAM,CAAC,IAAI,KAAK,IAAI;SAC3B,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,UAAU,CAAC,oBAAoB,OAAO,EAAE,CAAC,CAAC;AACtD,CAAC;AAED,oEAAoE;AACpE,SAAS,KAAK,CAAI,IAAa;IAC7B,IAAI,CAAC;QACH,OAAO,IAAI,EAAE,CAAC;IAChB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,UAAU,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/E,CAAC;AACH,CAAC;AAED,SAAS,cAAc,CAAC,KAAmC,EAAE,IAAY;IACvE,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QAChG,MAAM,IAAI,UAAU,CAAC,GAAG,IAAI,8CAA8C,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/F,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/cli/main.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ export interface CliEnvironment {
|
|
|
14
14
|
agents?: readonly CodingAgent[];
|
|
15
15
|
/** Both stdin and stdout are terminals: `genaicode` with no arguments opens the chat. */
|
|
16
16
|
interactive?: boolean;
|
|
17
|
+
/** The protocol input of `acp`. Default: `process.stdin`. */
|
|
18
|
+
input?: NodeJS.ReadableStream;
|
|
17
19
|
/** Terminal streams for the chat UI. */
|
|
18
20
|
tty?: {
|
|
19
21
|
stdin: NodeJS.ReadStream;
|
|
@@ -60,6 +62,6 @@ export declare const EXIT_OK = 0;
|
|
|
60
62
|
export declare const EXIT_FAILED = 1;
|
|
61
63
|
export declare const EXIT_USAGE = 2;
|
|
62
64
|
export declare const EXIT_ABORTED = 130;
|
|
63
|
-
export declare const helpText = "genaicode: run the coding-agent CLIs installed on this machine behind one interface.\n\nUsage:\n genaicode Chat with an agent in this terminal (same as \"chat\")\n genaicode chat [options] Chat with an agent in this terminal\n genaicode ui [options] Chat with an agent in the browser (local server)\n genaicode agents [--json] List supported agents and whether each is installed\n genaicode run [options] <prompt...> Run one task (reads the prompt from stdin if omitted)\n genaicode embed [options] [request] Have an agent add genaicode to the project here\n\nChat and UI options:\n -a, --agent <name> Agent to start with (default: the first installed one)\n -C, --cwd <dir> Directory the agent works in (default: current directory)\n -m, --model <id> Model id passed to the agent CLI\n --effort <level> Reasoning effort, in the agent's own vocabulary\n -r, --resume <id> Continue this agent session\n -y, --yes Approve every permission request the agent asks for\n --web (chat) Also open the session in the browser\n --port <n> Port for the browser UI, on 127.0.0.1 (default: a free port)\n --no-open (ui) Print the link instead of opening a browser\n\n Each prompt after the first continues the agent's session (claude, codex, cursor,\n opencode, copilot). Prompts sent while the agent works wait in a queue. Type /help in\n the chat for commands. The terminal and the browser can show one session: /web in the\n chat opens it in the browser, and Enter in \"genaicode ui\" brings it into the terminal.\n\nRun options:\n -a, --agent <name> Agent to use (default: the first installed one, see \"agents\")\n -C, --cwd <dir> Directory the agent works in (default: current directory)\n -m, --model <id> Model id passed to the agent CLI\n --effort <level> Reasoning effort, in the agent's own vocabulary\n --max-turns <n> Turn limit, where the agent supports one\n -r, --resume <id> Continue the agent session with this id (printed after each run)\n --timeout <sec> Stop the agent after this many seconds\n --verify <command> Shell command that checks the work; on failure its output goes\n back to the agent for another attempt\n --max-repairs <n> Repair attempts after a failed check (default 2)\n --json Print agent events as JSON lines instead of text\n\nEmbed options:\n --print Print the agent's instructions instead of starting one\n --ui Follow the agent in the browser instead of this terminal\n -a, -C, -m, --effort, -y, --port, --no-open: as for chat and ui\n\n The agent reads the project and chooses how to wire genaicode in; [request] steers it,\n e.g. \"only the dev panel\". Without a terminal it runs headless like \"run\". The\n instructions also ship as a Claude Code skill: docs/skills/genaicode-embed/SKILL.md.\n\nThe agent uses its own login, billing, and permission defaults. GenAIcode adds no agent\nloop or sandbox of its own, and no prompts but embed's instructions.\nLibrary API: https://github.com/gtanczyk/genaicode#readme\n\nLooking for the legacy 1.x coding agent?\n Run it: npx genaicode@1\n Source: https://github.com/gtanczyk/genaicode/tree/1.x\n";
|
|
65
|
+
export declare const helpText = "genaicode: run the coding-agent CLIs installed on this machine behind one interface.\n\nUsage:\n genaicode Chat with an agent in this terminal (same as \"chat\")\n genaicode chat [options] Chat with an agent in this terminal\n genaicode ui [options] Chat with an agent in the browser (local server)\n genaicode agents [--json] List supported agents and whether each is installed\n genaicode run [options] <prompt...> Run one task (reads the prompt from stdin if omitted)\n genaicode embed [options] [request] Have an agent add genaicode to the project here\n genaicode acp [options] Serve the Agent Client Protocol on stdin/stdout\n\nChat and UI options:\n -a, --agent <name> Agent to start with (default: the first installed one)\n -C, --cwd <dir> Directory the agent works in (default: current directory)\n -m, --model <id> Model id passed to the agent CLI\n --effort <level> Reasoning effort, in the agent's own vocabulary\n -r, --resume <id> Continue this agent session\n -y, --yes Approve every permission request the agent asks for\n --web (chat) Also open the session in the browser\n --port <n> Port for the browser UI, on 127.0.0.1 (default: a free port)\n --no-open (ui) Print the link instead of opening a browser\n\n Each prompt after the first continues the agent's session (claude, codex, cursor,\n opencode, copilot). Prompts sent while the agent works wait in a queue. Type /help in\n the chat for commands. The terminal and the browser can show one session: /web in the\n chat opens it in the browser, and Enter in \"genaicode ui\" brings it into the terminal.\n\nRun options:\n -a, --agent <name> Agent to use (default: the first installed one, see \"agents\")\n -C, --cwd <dir> Directory the agent works in (default: current directory)\n -m, --model <id> Model id passed to the agent CLI\n --effort <level> Reasoning effort, in the agent's own vocabulary\n --max-turns <n> Turn limit, where the agent supports one\n -r, --resume <id> Continue the agent session with this id (printed after each run)\n --timeout <sec> Stop the agent after this many seconds\n --verify <command> Shell command that checks the work; on failure its output goes\n back to the agent for another attempt\n --max-repairs <n> Repair attempts after a failed check (default 2)\n --json Print agent events as JSON lines instead of text\n\nEmbed options:\n --print Print the agent's instructions instead of starting one\n --ui Follow the agent in the browser instead of this terminal\n -a, -C, -m, --effort, -y, --port, --no-open: as for chat and ui\n\n The agent reads the project and chooses how to wire genaicode in; [request] steers it,\n e.g. \"only the dev panel\". Without a terminal it runs headless like \"run\". The\n instructions also ship as a Claude Code skill: docs/skills/genaicode-embed/SKILL.md.\n\nACP options:\n -a, -m, --effort, -y: as for chat (the host can change agent, effort and approvals)\n\n For editors and other apps that speak ACP (https://agentclientprotocol.com): the app\n starts \"genaicode acp\", opens sessions in its own directories and sends prompts.\n\nThe agent uses its own login, billing, and permission defaults. GenAIcode adds no agent\nloop or sandbox of its own, and no prompts but embed's instructions.\nLibrary API: https://github.com/gtanczyk/genaicode#readme\n\nLooking for the legacy 1.x coding agent?\n Run it: npx genaicode@1\n Source: https://github.com/gtanczyk/genaicode/tree/1.x\n";
|
|
64
66
|
/** Run the CLI and return its exit code. */
|
|
65
67
|
export declare function main(cli: CliEnvironment): Promise<number>;
|
package/dist/cli/main.js
CHANGED
|
@@ -4,6 +4,7 @@ import { resolve } from 'node:path';
|
|
|
4
4
|
import { detectAgents } from '../agents/discovery.js';
|
|
5
5
|
import { runWithVerify } from '../agents/verify.js';
|
|
6
6
|
import { defaultAgents } from '../agents/defaults.js';
|
|
7
|
+
import { serveAcp } from '../acp/server.js';
|
|
7
8
|
import { parseCli, UsageError } from './args.js';
|
|
8
9
|
import { embedPrompt, embedRequest, readEmbedInstructions } from './embed.js';
|
|
9
10
|
import { createRenderer, describeResult } from './render.js';
|
|
@@ -20,6 +21,7 @@ Usage:
|
|
|
20
21
|
genaicode agents [--json] List supported agents and whether each is installed
|
|
21
22
|
genaicode run [options] <prompt...> Run one task (reads the prompt from stdin if omitted)
|
|
22
23
|
genaicode embed [options] [request] Have an agent add genaicode to the project here
|
|
24
|
+
genaicode acp [options] Serve the Agent Client Protocol on stdin/stdout
|
|
23
25
|
|
|
24
26
|
Chat and UI options:
|
|
25
27
|
-a, --agent <name> Agent to start with (default: the first installed one)
|
|
@@ -59,6 +61,12 @@ Embed options:
|
|
|
59
61
|
e.g. "only the dev panel". Without a terminal it runs headless like "run". The
|
|
60
62
|
instructions also ship as a Claude Code skill: docs/skills/genaicode-embed/SKILL.md.
|
|
61
63
|
|
|
64
|
+
ACP options:
|
|
65
|
+
-a, -m, --effort, -y: as for chat (the host can change agent, effort and approvals)
|
|
66
|
+
|
|
67
|
+
For editors and other apps that speak ACP (https://agentclientprotocol.com): the app
|
|
68
|
+
starts "genaicode acp", opens sessions in its own directories and sends prompts.
|
|
69
|
+
|
|
62
70
|
The agent uses its own login, billing, and permission defaults. GenAIcode adds no agent
|
|
63
71
|
loop or sandbox of its own, and no prompts but embed's instructions.
|
|
64
72
|
Library API: https://github.com/gtanczyk/genaicode#readme
|
|
@@ -99,7 +107,30 @@ export async function main(cli) {
|
|
|
99
107
|
return runUi(cli, agents, command);
|
|
100
108
|
case 'embed':
|
|
101
109
|
return runEmbed(cli, agents, command);
|
|
110
|
+
case 'acp':
|
|
111
|
+
return runAcp(cli, agents, command);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async function runAcp(cli, agents, options) {
|
|
115
|
+
if (options.agent && !agents.some((agent) => agent.name === options.agent)) {
|
|
116
|
+
cli.stderr.write(`Unknown agent "${options.agent}". Known agents: ${agents.map((a) => a.name).join(', ')}.\n`);
|
|
117
|
+
return EXIT_USAGE;
|
|
102
118
|
}
|
|
119
|
+
const input = cli.input ?? process.stdin;
|
|
120
|
+
await serveAcp({
|
|
121
|
+
agents,
|
|
122
|
+
agent: options.agent,
|
|
123
|
+
model: options.model,
|
|
124
|
+
effort: options.effort,
|
|
125
|
+
approveAll: options.approveAll,
|
|
126
|
+
env: cli.env,
|
|
127
|
+
version: packageVersion(),
|
|
128
|
+
input,
|
|
129
|
+
output: cli.stdout,
|
|
130
|
+
// Ctrl-C ends the connection like the host closing it: running prompts stop.
|
|
131
|
+
signal: cli.signal,
|
|
132
|
+
});
|
|
133
|
+
return EXIT_OK;
|
|
103
134
|
}
|
|
104
135
|
async function runEmbed(cli, agents, options) {
|
|
105
136
|
const cwd = resolve(cli.cwd, options.cwd ?? '.');
|
package/dist/cli/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAqB,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAmB,MAAM,WAAW,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,cAAc,EAAe,MAAM,aAAa,CAAC;AA2D1E,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAC;AACzB,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC;AAC7B,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC;AAC5B,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,C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,CAAC;IAChE,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,cAAc;IACrB,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/C,OAAQ,OAAO,CAAC,oBAAoB,CAAyB,CAAC,OAAO,CAAC;AACxE,CAAC"}
|
package/docs/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
### Added
|
|
6
6
|
|
|
7
|
+
- `genaicode acp`: the Agent Client Protocol (version 1) on stdin/stdout, so editors (Zed,
|
|
8
|
+
JetBrains) and apps in any language (a game engine's editor, a Tauri or native app) can run
|
|
9
|
+
the installed agent CLIs: sessions with MCP servers, streamed text and tool calls, permission
|
|
10
|
+
requests, cancel, and config options for the agent, its effort and approvals. See
|
|
11
|
+
[embedding.md](embedding.md#any-language-the-agent-client-protocol).
|
|
12
|
+
- `genaicode embed` (and its skill) also covers desktop apps, game engine editors and apps in
|
|
13
|
+
other languages through `genaicode acp`, and can let the agent drive the running app (play
|
|
14
|
+
the game) through observe / take control / act / release tools. A Godot example lives in
|
|
15
|
+
`docs/examples/godot`.
|
|
7
16
|
- `autoApprove` in `createAppAgent` answers the agent CLI's own permission prompts the app
|
|
8
17
|
decides itself (e.g. its auto-approve setting); the rest still wait for the user.
|
|
9
18
|
- An `AppTool` may return `{ text, images }`: the images (e.g. a screenshot of the app)
|
package/docs/app-agent.md
CHANGED
|
@@ -74,3 +74,69 @@ and Copilot get the user's own configured servers switched off. The MCP endpoint
|
|
|
74
74
|
bearer and refuses browser requests; every other route asks `authorize` and refuses
|
|
75
75
|
cross-site requests. Without `authorize` only a loopback `Host` is accepted (add names with
|
|
76
76
|
`allowedHosts`), so a DNS-rebinding page cannot reach the agent.
|
|
77
|
+
|
|
78
|
+
## The agent drives the app (a game)
|
|
79
|
+
|
|
80
|
+
The same tools let the agent use the app the way a person does: play a level, click through a
|
|
81
|
+
flow, reproduce a bug. Give it a way to look and a way to act, and make taking control visible.
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
let controlled = false; // the page shows "Agent controls this game" and a Take back control button
|
|
85
|
+
|
|
86
|
+
const agent = createAppAgent({
|
|
87
|
+
name: 'the game in the dev build',
|
|
88
|
+
instructions: 'Call game_take_control before game_act. Observe after each move.',
|
|
89
|
+
tools: [
|
|
90
|
+
{
|
|
91
|
+
name: 'game_observe',
|
|
92
|
+
description: "The game's state and a screenshot of the current frame.",
|
|
93
|
+
run: async () => ({ text: JSON.stringify(game.state()), images: [await game.screenshot()] }),
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: 'game_take_control',
|
|
97
|
+
description: 'Take the controls from the player.',
|
|
98
|
+
run: () => ((controlled = true), 'ok'),
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: 'game_act',
|
|
102
|
+
description: 'Press keys or click, then let the game run for `frames` frames.',
|
|
103
|
+
inputSchema: {
|
|
104
|
+
type: 'object',
|
|
105
|
+
properties: { keys: { type: 'array', items: { type: 'string' } }, frames: { type: 'integer', maximum: 120 } },
|
|
106
|
+
},
|
|
107
|
+
validate: () => {
|
|
108
|
+
if (!controlled) throw new Error('Call game_take_control first.');
|
|
109
|
+
},
|
|
110
|
+
// The schema is a hint to the agent; the bound is enforced here.
|
|
111
|
+
run: async ({ keys, frames }) =>
|
|
112
|
+
game.step(
|
|
113
|
+
Array.isArray(keys) ? keys.map(String) : [],
|
|
114
|
+
Math.min(Math.max(Math.trunc(Number(frames) || 10), 1), 120),
|
|
115
|
+
),
|
|
116
|
+
},
|
|
117
|
+
{ name: 'game_release_control', description: 'Give the controls back.', run: () => ((controlled = false), 'ok') },
|
|
118
|
+
],
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// The player can always take control back, and control never outlives the agent's turn.
|
|
122
|
+
agent.subscribe((state) => {
|
|
123
|
+
if (state.session?.status !== 'running') controlled = false;
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
What makes this work:
|
|
128
|
+
|
|
129
|
+
- **No approval cards for moves.** These tools are not `write`, so each call runs at once. Keep
|
|
130
|
+
`write: true` for what should wait for the user (deleting a save, publishing a build).
|
|
131
|
+
- **Observe returns pixels.** A read tool may return `images`; the agent sees the frame, not only
|
|
132
|
+
the numbers. Keep screenshots small (a few hundred pixels wide) so the turn stays fast.
|
|
133
|
+
- **Bound every move.** `game_act` advances a limited number of frames and returns, so the agent
|
|
134
|
+
plays in short steps and a stuck call cannot hang the turn.
|
|
135
|
+
- **Control is visible and revocable.** Show who drives in the page, let a click give control back
|
|
136
|
+
(the next `game_act` then fails with a message the agent reads), and drop control when the turn
|
|
137
|
+
ends or the user presses Stop.
|
|
138
|
+
- **Pause when nobody acts**, if the game allows it, so the agent's thinking time does not cost
|
|
139
|
+
the player their run.
|
|
140
|
+
|
|
141
|
+
Outside a browser (a Godot or Unity editor, a native app) the game serves the same tools from
|
|
142
|
+
its own MCP server; see [embedding.md](./embedding.md).
|
package/docs/cli.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Command line: run, chat, ui, embed
|
|
1
|
+
# Command line: run, chat, ui, embed, acp
|
|
2
2
|
|
|
3
3
|
[← README](../README.md)
|
|
4
4
|
|
|
@@ -90,8 +90,12 @@ instructions on how to embed genaicode, and the agent reads the project and pick
|
|
|
90
90
|
in: the [Vite overlay](vite.md) for an app on Vite; for any other Node dev server (webpack,
|
|
91
91
|
Next.js, Express...) the same overlay through `createDevOverlay` from `genaicode/ui`; for
|
|
92
92
|
pages with no dev server at all, a small dev-only server of its own with that overlay; the in-app agent (`genaicode/app-agent` with
|
|
93
|
-
`<AppAgentChat>`) when the agent should act on the app
|
|
94
|
-
|
|
93
|
+
`<AppAgentChat>`) when the agent should act on the app's data; a panel over `genaicode acp`
|
|
94
|
+
for a desktop app, a game engine editor (Godot, Unity...) or an app in another language; and
|
|
95
|
+
`npx genaicode ui` next to the dev server when there is nothing to add a panel to. Any of
|
|
96
|
+
them can also let the agent drive the running app (play the game, click through a flow)
|
|
97
|
+
through observe / take control / act / release tools ([embedding.md](embedding.md#let-the-agent-act-on-the-app)).
|
|
98
|
+
Words after `embed` go to the
|
|
95
99
|
agent as your request. You watch and answer in the same chat as `genaicode chat` (`--ui`
|
|
96
100
|
for the browser); without a terminal it runs headless like `run`. The agent installs the
|
|
97
101
|
package, edits the config, runs your checks and reports; it does not commit.
|
|
@@ -103,3 +107,15 @@ The instructions are also a Claude Code skill. Copy
|
|
|
103
107
|
```bash
|
|
104
108
|
mkdir -p .claude/skills && cp -r node_modules/genaicode/docs/skills/genaicode-embed .claude/skills/
|
|
105
109
|
```
|
|
110
|
+
|
|
111
|
+
## For editors and apps in other languages: `genaicode acp`
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
npx genaicode acp -a claude
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
`genaicode acp` serves the [Agent Client Protocol](https://agentclientprotocol.com) on stdin
|
|
118
|
+
and stdout, for editors that speak it (Zed, JetBrains IDEs) and for any app that starts it as a
|
|
119
|
+
child process: a Godot or Unity editor plugin, a Tauri or native app, a Python tool. Sessions,
|
|
120
|
+
streamed replies and tool calls, permission requests and cancel go over the protocol; the host
|
|
121
|
+
picks the agent, effort and approvals per session. See [embedding.md](embedding.md#any-language-the-agent-client-protocol).
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# Embedding genaicode outside the web
|
|
2
|
+
|
|
3
|
+
[← README](../README.md)
|
|
4
|
+
|
|
5
|
+
genaicode runs coding agents on the developer's machine. Web apps get the [Vite panel](./vite.md),
|
|
6
|
+
[`createDevOverlay`](./vite.md) or [`<AppAgentChat>`](./app-agent.md). This page is for every other
|
|
7
|
+
host: desktop apps, game editors, terminal tools and programs that are not written in JavaScript.
|
|
8
|
+
It is about development tools: the agent CLIs, their logins and Node 20+ come from the developer's
|
|
9
|
+
machine, so none of this belongs in an app you ship to end users.
|
|
10
|
+
|
|
11
|
+
| Host | What to use |
|
|
12
|
+
| -------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
|
|
13
|
+
| Electron | `genaicode/agents` in the main process, the chat in a window ([below](#electron)) |
|
|
14
|
+
| Any webview (Tauri, WebView2, Qt, CEF) | a small Node script with `startEmbeddedWeb`, its URL in the webview ([below](#a-webview-in-another-language)) |
|
|
15
|
+
| Any language, a whole conversation | `genaicode acp`: the Agent Client Protocol on stdin/stdout ([below](#any-language-the-agent-client-protocol)) |
|
|
16
|
+
| Any language, one prompt at a time | `genaicode run --json` as a child process ([below](#any-language-one-prompt-at-a-time)) |
|
|
17
|
+
| An app the agent should act on | the app's tools over MCP ([below](#let-the-agent-act-on-the-app)) |
|
|
18
|
+
|
|
19
|
+
## Electron
|
|
20
|
+
|
|
21
|
+
The main process is Node, so the whole API is there. Either show the bundled chat in a window:
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
// main.ts
|
|
25
|
+
import { app, BrowserWindow } from 'electron';
|
|
26
|
+
import { startEmbeddedWeb } from 'genaicode/ui';
|
|
27
|
+
|
|
28
|
+
app.whenReady().then(async () => {
|
|
29
|
+
const web = await startEmbeddedWeb({ cwd: projectDir });
|
|
30
|
+
const win = new BrowserWindow({ width: 480, height: 800 });
|
|
31
|
+
await win.loadURL(web.url); // 127.0.0.1 with its access token: keep it out of logs
|
|
32
|
+
app.on('before-quit', () => void web.close());
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`web.controller` lets the app drive the same session: `submit()` a prompt, `note()` a line into
|
|
37
|
+
the transcript, `approve()` a pending request.
|
|
38
|
+
|
|
39
|
+
Or draw the chat in your own renderer: run `createAppAgent` and `createAppAgentHandler` in the
|
|
40
|
+
main process on 127.0.0.1 and put `<AppAgentChat>` in the renderer ([app-agent.md](./app-agent.md)),
|
|
41
|
+
or build on `createAgentSession` and `<AgentChat>` ([react.md](./react.md)).
|
|
42
|
+
|
|
43
|
+
## A webview in another language
|
|
44
|
+
|
|
45
|
+
A Tauri, .NET or Qt app can show the same chat. Start it from a short Node script next to the app
|
|
46
|
+
and read its URL from stdout:
|
|
47
|
+
|
|
48
|
+
```js
|
|
49
|
+
// genaicode-panel.mjs, started by the app with: node genaicode-panel.mjs <project dir>
|
|
50
|
+
import { startEmbeddedWeb } from 'genaicode/ui';
|
|
51
|
+
|
|
52
|
+
const web = await startEmbeddedWeb({ cwd: process.argv[2] });
|
|
53
|
+
process.stdout.write(JSON.stringify({ url: web.url }) + '\n');
|
|
54
|
+
process.stdin.on('end', () => web.close().then(() => process.exit(0))); // the app went away
|
|
55
|
+
process.stdin.resume();
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The app opens `url` in its webview (top level, not in an iframe: framing needs `frameAncestors`).
|
|
59
|
+
Treat the URL as a secret; it carries the access token.
|
|
60
|
+
|
|
61
|
+
## Any language: the Agent Client Protocol
|
|
62
|
+
|
|
63
|
+
`genaicode acp` speaks the [Agent Client Protocol](https://agentclientprotocol.com) (ACP,
|
|
64
|
+
version 1): JSON-RPC 2.0, one message per line, on stdin and stdout. Editors that support ACP
|
|
65
|
+
(Zed, JetBrains IDEs and others) can run it as an agent as it is, and a host in any language can
|
|
66
|
+
drive it with an ACP client library (TypeScript, Python, Rust, Kotlin...) or a few lines of JSON.
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npx genaicode acp # the first installed agent
|
|
70
|
+
npx genaicode acp -a codex -y # start with Codex, approving every permission request
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The host starts the process and then:
|
|
74
|
+
|
|
75
|
+
1. `initialize` with `protocolVersion: 1`.
|
|
76
|
+
2. `session/new` with `cwd` (the project) and `mcpServers` (HTTP or stdio servers the agent should
|
|
77
|
+
use, e.g. the app's own tools). The reply lists the session's config options.
|
|
78
|
+
3. `session/prompt` with the user's text (also `resource_link` and embedded `resource` blocks).
|
|
79
|
+
While the agent works, the host gets `session/update` notifications: `agent_message_chunk`,
|
|
80
|
+
`tool_call` and `tool_call_update` (with `kind`, a title such as `Bash: npm test`, and the
|
|
81
|
+
file in `locations`). The reply comes when the turn ends: `stopReason: "end_turn"`, or
|
|
82
|
+
`"cancelled"` after a `session/cancel`; a failed run is a JSON-RPC error with the agent's
|
|
83
|
+
message.
|
|
84
|
+
4. When the agent asks for permission, genaicode sends `session/request_permission` with the
|
|
85
|
+
options `approve` and `deny`; the host answers with the one the user picked.
|
|
86
|
+
|
|
87
|
+
Each prompt continues the agent's own session, so the conversation carries on. The config
|
|
88
|
+
options switch, between prompts, `agent` (one of the installed agent CLIs; the next agent starts
|
|
89
|
+
a new conversation), `effort` (when the agent has levels) and `mode` (`ask` or `auto-approve`)
|
|
90
|
+
through `session/set_config_option`. `session/close` stops a session.
|
|
91
|
+
|
|
92
|
+
A complete exchange, one JSON object per line (`>` sent by the host, `<` by genaicode):
|
|
93
|
+
|
|
94
|
+
```text
|
|
95
|
+
> {"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":1}}
|
|
96
|
+
< {"jsonrpc":"2.0","id":1,"result":{"protocolVersion":1,"agentInfo":{"name":"genaicode",...},...}}
|
|
97
|
+
> {"jsonrpc":"2.0","id":2,"method":"session/new","params":{"cwd":"/work/game","mcpServers":[]}}
|
|
98
|
+
< {"jsonrpc":"2.0","id":2,"result":{"sessionId":"5b1c...","configOptions":[...]}}
|
|
99
|
+
> {"jsonrpc":"2.0","id":3,"method":"session/prompt","params":{"sessionId":"5b1c...","prompt":[{"type":"text","text":"Fix the bug in math.js"}]}}
|
|
100
|
+
< {"jsonrpc":"2.0","method":"session/update","params":{"sessionId":"5b1c...","update":{"sessionUpdate":"tool_call","toolCallId":"toolu_01...","title":"Read: /work/game/math.js","kind":"read","status":"in_progress",...}}}
|
|
101
|
+
< {"jsonrpc":"2.0","method":"session/update","params":{"sessionId":"5b1c...","update":{"sessionUpdate":"agent_message_chunk","content":{"type":"text","text":"Fixed: add now adds."},...}}}
|
|
102
|
+
< {"jsonrpc":"2.0","id":3,"result":{"stopReason":"end_turn"}}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
[examples/godot](examples/godot/README.md) is a complete host: a Godot editor dock that chats
|
|
106
|
+
with the agent over ACP in GDScript, and a game that serves its own MCP tools so the agent can
|
|
107
|
+
play it.
|
|
108
|
+
|
|
109
|
+
With an agent that cannot resume (gemini, antigravity) each prompt starts a fresh agent session.
|
|
110
|
+
A session with MCP servers offers only the agents that can attach them (claude, codex, copilot).
|
|
111
|
+
Not supported yet: `session/load` and `session/resume` (sessions live as long as the process),
|
|
112
|
+
images in prompts, SSE MCP servers, and the client's file system and terminal methods (the agent
|
|
113
|
+
CLI reads, writes and runs commands itself).
|
|
114
|
+
|
|
115
|
+
## Any language, one prompt at a time
|
|
116
|
+
|
|
117
|
+
`genaicode run --json` reads the prompt from stdin (`-`) and prints one JSON `AgentEvent` per line:
|
|
118
|
+
`session`, `text-delta`, `message`, `tool-start`, `tool-end`, `file-change`, `usage`, `error`,
|
|
119
|
+
then `done` with the result ([agents.md](./agents.md)). Pass `--resume <sessionId>` from the
|
|
120
|
+
`session` event to continue the conversation on the next prompt.
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
import json, subprocess
|
|
124
|
+
|
|
125
|
+
proc = subprocess.Popen(
|
|
126
|
+
["npx", "genaicode", "run", "--json", "-a", "claude", "-C", project_dir, "-"],
|
|
127
|
+
stdin=subprocess.PIPE, stdout=subprocess.PIPE, text=True,
|
|
128
|
+
)
|
|
129
|
+
proc.stdin.write("Fix the failing test in test_physics.py")
|
|
130
|
+
proc.stdin.close()
|
|
131
|
+
for line in proc.stdout:
|
|
132
|
+
event = json.loads(line)
|
|
133
|
+
if event["type"] == "text-delta":
|
|
134
|
+
print(event["text"], end="")
|
|
135
|
+
elif event["type"] == "done":
|
|
136
|
+
session_id = event["result"].get("sessionId")
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
This is one-way (use `genaicode acp` for a conversation): the agent cannot ask the host for a permission, so steps that need one are
|
|
140
|
+
declined unless you pass `--yes` (approve everything). Stop a run by ending the process.
|
|
141
|
+
|
|
142
|
+
## Let the agent act on the app
|
|
143
|
+
|
|
144
|
+
The agent can do more than edit code: it can use the app, for example play a level in a game and
|
|
145
|
+
look at the frames. The app serves tools over MCP and the agent calls them. In a Node host,
|
|
146
|
+
`genaicode/app-agent` does this with approval cards and a chat ([app-agent.md](./app-agent.md),
|
|
147
|
+
including [a game the agent plays](./app-agent.md#the-agent-drives-the-app-a-game)).
|
|
148
|
+
|
|
149
|
+
An app in another language serves the tools from its own MCP server (there is an MCP SDK for
|
|
150
|
+
most languages) and hands it to the agent through `AgentTask.mcpServers`, e.g. from the Node
|
|
151
|
+
script above:
|
|
152
|
+
|
|
153
|
+
```js
|
|
154
|
+
const web = await startEmbeddedWeb({
|
|
155
|
+
cwd: process.argv[2],
|
|
156
|
+
task: { mcpServers: [{ name: 'game', url: 'http://127.0.0.1:7777/mcp' }] },
|
|
157
|
+
});
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
The [Godot example](examples/godot/README.md) does this from GDScript: the running game serves
|
|
161
|
+
`game_observe`, `game_take_control`, `game_act` and `game_release_control` on 127.0.0.1, and the
|
|
162
|
+
editor dock passes that server to `genaicode acp` in `session/new`.
|
|
163
|
+
|
|
164
|
+
The agent's CLI may ask before it calls a tool of a new server; answer in the chat, or allow the
|
|
165
|
+
server in the agent's own settings. Keep each action short and bounded, and show in the app when
|
|
166
|
+
the agent has the controls.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: genaicode-embed
|
|
3
|
-
description: Embed genaicode in a project so its developers chat with their own coding agent (Claude Code, Codex, Copilot...) from inside the running app. Use when asked to add genaicode, its Vite overlay, a dev agent panel,
|
|
3
|
+
description: Embed genaicode in a project so its developers chat with their own coding agent (Claude Code, Codex, Copilot...) from inside the running app, and optionally let the agent use the app itself (play a game, click through a flow). Use when asked to add genaicode, its Vite overlay, a dev agent panel, an in-app agent drawer (genaicode/app-agent), or an agent panel in a desktop app, a game engine editor (Godot, Unity...) or a non-JavaScript app (genaicode acp).
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Embed genaicode in this project
|
|
@@ -10,9 +10,9 @@ already has installed (Claude Code, Codex, Copilot CLI, Cursor, Gemini, opencode
|
|
|
10
10
|
one API. Your job is to wire it into the project in the current directory so the
|
|
11
11
|
project's developers can talk to their agent from inside the running app.
|
|
12
12
|
|
|
13
|
-
There are
|
|
13
|
+
There are five ways in, plus a last resort. Pick by what the project is, not by what is
|
|
14
14
|
more impressive. Always end with a working way in: "it doesn't fit" is not a result while
|
|
15
|
-
the project has HTML pages a browser can open.
|
|
15
|
+
the project has HTML pages a browser can open or a UI you can add a panel to.
|
|
16
16
|
|
|
17
17
|
1. **Vite dev overlay** (`genaicode/vite`): for any app built with Vite. One plugin line;
|
|
18
18
|
in `vite dev` the page gets a wolf button that opens a chat with the agent working in
|
|
@@ -34,9 +34,21 @@ the project has HTML pages a browser can open.
|
|
|
34
34
|
serves those files on localhost with the overlay from option 2 injected into the HTML
|
|
35
35
|
it serves, and an npm script to start it. The files on disk and the build output stay
|
|
36
36
|
untouched, so size budgets and release builds are not affected.
|
|
37
|
-
5. **
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
5. **Desktop app, game engine or another language** (`genaicode acp`): Electron, Tauri,
|
|
38
|
+
.NET, Qt, a Godot or Unity editor plugin, a Python or Go tool. The app starts
|
|
39
|
+
`npx genaicode acp` as a child process and talks the Agent Client Protocol (JSON-RPC on
|
|
40
|
+
stdin/stdout) to it: a whole conversation with streaming, tool calls, permission questions
|
|
41
|
+
and agent/effort pickers, from any language. Electron can also use `genaicode/ui` in its
|
|
42
|
+
main process directly.
|
|
43
|
+
6. **Last resort**: nothing you can add a panel to (a Rails, Django or Go web app whose
|
|
44
|
+
server you cannot change safely): tell the user to run `npx genaicode ui` (browser) or
|
|
45
|
+
`npx genaicode` (terminal) next to their dev server, and say why.
|
|
46
|
+
|
|
47
|
+
Any of these can also **let the agent drive the app**: the app serves a few MCP tools
|
|
48
|
+
(observe, take control, act, release control) and the agent uses the running app the way a
|
|
49
|
+
person does, e.g. plays the game to test a change, reproduces a bug, walks through a flow.
|
|
50
|
+
Offer it when the app is a game or anything interactive; add it when the user asks for it.
|
|
51
|
+
See "Recipe: let the agent drive the app".
|
|
40
52
|
|
|
41
53
|
The agent CLI always runs on the machine that runs the server, with that machine's
|
|
42
54
|
login and files. Options 1, 2 and 4 exist only in development. The in-app agent is for apps
|
|
@@ -62,7 +74,11 @@ allow, batch what must run into few commands, and do not run the dev server just
|
|
|
62
74
|
is an internal tool with a Node server and a React UI: option 3, alone or next to
|
|
63
75
|
option 1 or 2.
|
|
64
76
|
- Pages but no dev server: option 4.
|
|
65
|
-
-
|
|
77
|
+
- A desktop app, a game engine project (`project.godot`, a Unity `Assets/` folder...),
|
|
78
|
+
or an app in another language with its own UI: option 5.
|
|
79
|
+
- The user wants the agent to play the game or click through the app: add the tools from
|
|
80
|
+
"Recipe: let the agent drive the app" to whichever option you chose.
|
|
81
|
+
- Otherwise: option 6. Say why.
|
|
66
82
|
- If genaicode is already wired in, extend or fix what is there instead of adding a
|
|
67
83
|
second copy.
|
|
68
84
|
3. **Install** `genaicode` as a dev dependency for options 1, 2 and 4, as a regular
|
|
@@ -71,12 +87,15 @@ allow, batch what must run into few commands, and do not run the dev server just
|
|
|
71
87
|
`bun.lockb`/`bun.lock` bun). If you may not run the install, add the dependency to
|
|
72
88
|
`package.json` with the version from your task and tell the user to run it. genaicode
|
|
73
89
|
needs Node 20+ and declares no React peer: the app brings React 18+ for
|
|
74
|
-
`genaicode/react`.
|
|
90
|
+
`genaicode/react`. Option 5 outside Node installs nothing in the project: the app runs
|
|
91
|
+
`npx -y genaicode@<version> acp` (the version from your task) and needs Node 20+ on the
|
|
92
|
+
developer's machine.
|
|
75
93
|
4. **Wire it in** (recipes below), matching the project's style: TypeScript or
|
|
76
94
|
JavaScript, ESM or CJS, its formatter, its folder layout.
|
|
77
95
|
5. **Check it**: run the project's type check, lint and tests if it has them, and a
|
|
78
96
|
production build. For options 1, 2 and 4 the production output must not contain
|
|
79
|
-
genaicode
|
|
97
|
+
genaicode; for option 5 and the drive-the-app tools, release builds must not start
|
|
98
|
+
`genaicode acp` or serve the tools. Fix what you broke; do not "fix" unrelated failures. Remove build output
|
|
80
99
|
you created that the project does not track.
|
|
81
100
|
6. **Report**, starting with how to see it, before anything else: one line with the exact
|
|
82
101
|
command to run and what happens next, e.g. "Run `npm run agent`: the game opens in your
|
|
@@ -238,6 +257,56 @@ createServer(async (req, res) => {
|
|
|
238
257
|
- A page that reloads itself on change (a watch build) is the developer's own; do not
|
|
239
258
|
add a live-reload system for this.
|
|
240
259
|
|
|
260
|
+
## Recipe: desktop, game engines, other languages (`genaicode acp`)
|
|
261
|
+
|
|
262
|
+
`genaicode acp` is a coding agent for the [Agent Client Protocol](https://agentclientprotocol.com)
|
|
263
|
+
(v1): newline-delimited JSON-RPC 2.0 on stdin/stdout. Zed and other ACP editors can use it as
|
|
264
|
+
is. In an app you write a small client:
|
|
265
|
+
|
|
266
|
+
1. Start `npx -y genaicode@<version> acp` (flags: `-a <agent>`, `-m <model>`, `--effort`,
|
|
267
|
+
`-y` to skip permission prompts, only if asked) with the project as working directory.
|
|
268
|
+
On Windows run it through `cmd.exe /c`. Read stdout without blocking the UI thread.
|
|
269
|
+
2. Send `initialize` `{protocolVersion: 1}`, then `session/new`
|
|
270
|
+
`{cwd, mcpServers: [...]}`. Its result has `sessionId` and `configOptions` (agent, effort,
|
|
271
|
+
approval mode): show them as pickers, change them with `session/set_config_option`.
|
|
272
|
+
3. Send `session/prompt` `{sessionId, prompt: [{type: 'text', text}]}`. While it runs,
|
|
273
|
+
`session/update` notifications stream `agent_message_chunk` text, `tool_call` and
|
|
274
|
+
`tool_call_update`; render them in the panel. The result has `stopReason`.
|
|
275
|
+
4. Answer `session/request_permission` requests (Allow / Reject in the panel) with
|
|
276
|
+
`{outcome: {outcome: 'selected', optionId}}`; several can be open at once. Stop sends the
|
|
277
|
+
`session/cancel` notification.
|
|
278
|
+
5. After a prompt, refresh what the host shows from disk (the agent edited files).
|
|
279
|
+
|
|
280
|
+
Put the panel where the host's developers work: an editor dock (Godot `EditorPlugin`, Unity
|
|
281
|
+
`EditorWindow`), a side window, a dev-only menu entry. Keep it out of release builds.
|
|
282
|
+
A complete GDScript client and editor dock: https://github.com/gtanczyk/genaicode/blob/master/docs/examples/godot
|
|
283
|
+
Electron: `startEmbeddedWeb` from `genaicode/ui` in the main process shows the bundled chat in
|
|
284
|
+
a `BrowserWindow` without any protocol code.
|
|
285
|
+
|
|
286
|
+
## Recipe: let the agent drive the app
|
|
287
|
+
|
|
288
|
+
In the running app (development builds only), serve four MCP tools on 127.0.0.1 and pass that
|
|
289
|
+
server to the agent: `mcpServers` in `session/new` for ACP, `tools` of `createAppAgent` for the
|
|
290
|
+
in-app agent, `task.mcpServers` elsewhere.
|
|
291
|
+
|
|
292
|
+
- `game_observe` (or `app_observe`): the state as JSON plus a small screenshot (a few hundred
|
|
293
|
+
pixels wide) as an MCP image.
|
|
294
|
+
- `game_take_control`: the agent takes over. The app shows "Agent controls this game" with a
|
|
295
|
+
Take back control button, and pauses between the agent's moves if it can.
|
|
296
|
+
- `game_act`: press keys or click, run a bounded number of frames (clamp, e.g. 1-120, in code,
|
|
297
|
+
not only in the schema), return the new state. Fails until control is taken, and when the
|
|
298
|
+
user took control back. One act at a time.
|
|
299
|
+
- `game_release_control`: give the controls back. Also release when the agent's turn ends
|
|
300
|
+
or its client disconnects.
|
|
301
|
+
|
|
302
|
+
Listen on 127.0.0.1 only and refuse browser requests (an `Origin` header, a `Host` that is not
|
|
303
|
+
localhost) so a web page cannot drive the app. These tools are not writes, so they need no
|
|
304
|
+
approval card. Details and a TypeScript version: "The agent drives the app (a game)" in
|
|
305
|
+
https://github.com/gtanczyk/genaicode/blob/master/docs/app-agent.md; a GDScript server:
|
|
306
|
+
https://github.com/gtanczyk/genaicode/blob/master/docs/examples/godot/addons/genaicode/game_mcp.gd.
|
|
307
|
+
When you add this, the report says how to try it, e.g. "run the game, then ask the agent:
|
|
308
|
+
Play the game: take control and collect 3 stars."
|
|
309
|
+
|
|
241
310
|
## Recipe: in-app agent
|
|
242
311
|
|
|
243
312
|
Server side, wherever the Node server is created:
|
|
@@ -319,4 +388,5 @@ import 'genaicode/react/styles.css';
|
|
|
319
388
|
- Do not turn on `approveAll` or the agents' "yolo" modes unless the user asks.
|
|
320
389
|
- These recipes are starting points, not templates to paste: adapt them to what the
|
|
321
390
|
project already does. If something does not fit, say what and why instead of forcing it.
|
|
322
|
-
- Docs: https://github.com/gtanczyk/genaicode#readme
|
|
391
|
+
- Docs: https://github.com/gtanczyk/genaicode#readme, outside the web:
|
|
392
|
+
https://github.com/gtanczyk/genaicode/blob/master/docs/embedding.md
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "genaicode",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.22.0",
|
|
4
4
|
"description": "Drive the coding-agent CLIs you already have (Claude Code, Codex, Copilot, Cursor, Gemini, opencode...) behind one API and one CLI, plus a thin provider-neutral LLM layer.",
|
|
5
5
|
"author": "Grzegorz Tańczyk",
|
|
6
6
|
"repository": {
|
|
@@ -89,6 +89,7 @@
|
|
|
89
89
|
"openai": "^5.16.0"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
|
+
"@agentclientprotocol/sdk": "^2.0.2",
|
|
92
93
|
"@types/node": "^20.0.0",
|
|
93
94
|
"@types/react": "^19.3.0",
|
|
94
95
|
"@types/react-dom": "^19.3.0",
|
|
@@ -106,7 +107,8 @@
|
|
|
106
107
|
"react-dom": "^19.3.0",
|
|
107
108
|
"typescript": "^5.0.0",
|
|
108
109
|
"vite": "^6.4.5",
|
|
109
|
-
"vitest": "^4.1.12"
|
|
110
|
+
"vitest": "^4.1.12",
|
|
111
|
+
"zod": "^3.25.76"
|
|
110
112
|
},
|
|
111
113
|
"prettier": {
|
|
112
114
|
"trailingComma": "all",
|