genaicode 2.9.1 → 2.13.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.
Files changed (94) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/README.md +142 -16
  3. package/dist/agents/cli-agent.d.ts +6 -3
  4. package/dist/agents/cli-agent.js +57 -35
  5. package/dist/agents/cli-agent.js.map +1 -1
  6. package/dist/agents/drivers/antigravity.d.ts +7 -1
  7. package/dist/agents/drivers/antigravity.js +27 -2
  8. package/dist/agents/drivers/antigravity.js.map +1 -1
  9. package/dist/agents/drivers/claude-approvals.d.ts +86 -0
  10. package/dist/agents/drivers/claude-approvals.js +277 -0
  11. package/dist/agents/drivers/claude-approvals.js.map +1 -0
  12. package/dist/agents/drivers/claude.d.ts +12 -2
  13. package/dist/agents/drivers/claude.js +73 -11
  14. package/dist/agents/drivers/claude.js.map +1 -1
  15. package/dist/agents/drivers/codex-approvals.d.ts +10 -0
  16. package/dist/agents/drivers/codex-approvals.js +102 -0
  17. package/dist/agents/drivers/codex-approvals.js.map +1 -0
  18. package/dist/agents/drivers/codex-live.d.ts +12 -1
  19. package/dist/agents/drivers/codex-live.js +46 -32
  20. package/dist/agents/drivers/codex-live.js.map +1 -1
  21. package/dist/agents/drivers/codex.d.ts +10 -1
  22. package/dist/agents/drivers/codex.js +48 -2
  23. package/dist/agents/drivers/codex.js.map +1 -1
  24. package/dist/agents/drivers/copilot.d.ts +9 -1
  25. package/dist/agents/drivers/copilot.js +31 -1
  26. package/dist/agents/drivers/copilot.js.map +1 -1
  27. package/dist/agents/drivers/cursor.d.ts +10 -1
  28. package/dist/agents/drivers/cursor.js +48 -5
  29. package/dist/agents/drivers/cursor.js.map +1 -1
  30. package/dist/agents/drivers/gemini.d.ts +11 -1
  31. package/dist/agents/drivers/gemini.js +46 -2
  32. package/dist/agents/drivers/gemini.js.map +1 -1
  33. package/dist/agents/drivers/muse-approvals.d.ts +19 -0
  34. package/dist/agents/drivers/muse-approvals.js +156 -0
  35. package/dist/agents/drivers/muse-approvals.js.map +1 -0
  36. package/dist/agents/drivers/muse-live.d.ts +5 -1
  37. package/dist/agents/drivers/muse-live.js +21 -109
  38. package/dist/agents/drivers/muse-live.js.map +1 -1
  39. package/dist/agents/drivers/opencode.d.ts +7 -1
  40. package/dist/agents/drivers/opencode.js +28 -2
  41. package/dist/agents/drivers/opencode.js.map +1 -1
  42. package/dist/agents/drivers/permission-args.d.ts +14 -0
  43. package/dist/agents/drivers/permission-args.js +40 -0
  44. package/dist/agents/drivers/permission-args.js.map +1 -0
  45. package/dist/agents/drivers/vibe.d.ts +9 -1
  46. package/dist/agents/drivers/vibe.js +40 -2
  47. package/dist/agents/drivers/vibe.js.map +1 -1
  48. package/dist/agents/hosted.js +6 -0
  49. package/dist/agents/hosted.js.map +1 -1
  50. package/dist/agents/live-agent.d.ts +49 -4
  51. package/dist/agents/live-agent.js +84 -15
  52. package/dist/agents/live-agent.js.map +1 -1
  53. package/dist/agents/permissions.d.ts +27 -0
  54. package/dist/agents/permissions.js +79 -0
  55. package/dist/agents/permissions.js.map +1 -0
  56. package/dist/agents/prepare.d.ts +12 -1
  57. package/dist/agents/prepare.js +18 -3
  58. package/dist/agents/prepare.js.map +1 -1
  59. package/dist/agents/rpc.d.ts +13 -2
  60. package/dist/agents/rpc.js +20 -2
  61. package/dist/agents/rpc.js.map +1 -1
  62. package/dist/agents/runtime.d.ts +2 -0
  63. package/dist/agents/runtime.js +10 -0
  64. package/dist/agents/runtime.js.map +1 -1
  65. package/dist/agents/session.d.ts +9 -1
  66. package/dist/agents/session.js +71 -16
  67. package/dist/agents/session.js.map +1 -1
  68. package/dist/agents/types.d.ts +56 -7
  69. package/dist/agents.d.ts +21 -13
  70. package/dist/agents.js +14 -9
  71. package/dist/agents.js.map +1 -1
  72. package/dist/react/agent-chat.css +506 -0
  73. package/dist/react/agent-chat.d.ts +65 -0
  74. package/dist/react/agent-chat.js +148 -0
  75. package/dist/react/agent-chat.js.map +1 -0
  76. package/dist/react/format.d.ts +16 -0
  77. package/dist/react/format.js +95 -0
  78. package/dist/react/format.js.map +1 -0
  79. package/dist/react/markdown.d.ts +6 -0
  80. package/dist/react/markdown.js +163 -0
  81. package/dist/react/markdown.js.map +1 -0
  82. package/dist/react.d.ts +19 -0
  83. package/dist/react.js +17 -0
  84. package/dist/react.js.map +1 -0
  85. package/dist/ui/index.js +78 -136
  86. package/dist/ui/web-client.js +520 -13
  87. package/dist/ui.d.ts +71 -0
  88. package/dist/ui.js +25 -0
  89. package/dist/ui.js.map +1 -0
  90. package/dist/vite/overlay.js +132 -8
  91. package/dist/vite/overlay.js.map +1 -1
  92. package/docs/agents.md +130 -19
  93. package/docs/semver.md +2 -0
  94. package/package.json +22 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,71 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.12.0 — 2026-10-08
4
+
5
+ ### Added
6
+
7
+ - `task.permissions`: `{ approval: 'ask' | 'auto-approve' | 'deny', sandbox: 'workspace-write' |
8
+ 'read-only' | 'unrestricted' }`, or the `'yolo'` preset (auto-approve, unrestricted). Each
9
+ driver translates it into the agent's own options and declares what it accepts in
10
+ `capabilities.permissions`; an unsupported value or combination fails the run with an error
11
+ instead of starting it in another mode. The sandbox bounds approvals, and `auto-approve`
12
+ grants exactly the scope the agent asked for. Prompts decided by the policy keep their
13
+ `approval-request` / `approval-resolved` events, marked `automatic: true`, and show as
14
+ "Auto-approved" in `createAgentSession`, `<AgentChat>` and `genaicode chat`.
15
+ - For apps with their own argument lists: `applyPermissionArgs`, the per-agent
16
+ `*PermissionFlags` functions, `codexThreadPolicy`, `decideApproval`, `claudeSandboxRefuses`
17
+ and a `sandbox` option for `claudeApprovalTool`.
18
+
19
+ - `claude()` answers permission prompts: with `task.onApproval`, it serves Claude Code's
20
+ `--permission-prompt-tool` from a private loopback MCP endpoint (random port and bearer
21
+ token) next to the task's own `mcpServers`, and raises `MCP_TOOL_TIMEOUT` so Claude waits
22
+ for a person. The permission mode (`acceptEdits` by default) still applies first. Approving
23
+ allows exactly the input Claude asked about; `capabilities.approvals` is now true.
24
+ - `codexLive()` answers Codex permission profile requests (`item/permissions/requestApproval`):
25
+ approving grants the requested categories for the current turn, denying grants none.
26
+ - `ApprovalRequest.scope`: `once` (also when absent) or `turn`, what approving grants.
27
+ - `onApproval(request, signal)`: `signal` aborts when the request is withdrawn, the turn ends,
28
+ the process exits or the task is stopped, so an app can close the question. Late answers,
29
+ like errors and a missing handler, deny. `createAgentSession` drops withdrawn requests from
30
+ `approvals`; `<AgentChat>` and `genaicode chat` label turn-scoped approvals.
31
+ - The vendor protocols for apps with their own driver or MCP server: `codexApprovals`,
32
+ `museApprovals` (for a `LiveSession`), `claudeApprovalTool`, `claudeApprovalArgs`,
33
+ `claudeApprovalEnv`, `claudeApprovalRequest` and `startClaudeApprovalServer`.
34
+ - `LiveSession.signal`, `LiveSession.approve(request, signal?)`, the request context
35
+ (`id`, `signal`) passed to `onRequest` handlers, `RpcPeer.cancel(id)`, and a `prepare`
36
+ for `cliAgent` that can be async and gets a `PrepareContext` (`emit`, `signal`).
37
+
38
+ ### Fixed
39
+
40
+ - `codexLive()` rejects approval requests from another thread or turn, and declines an answer
41
+ given after the turn ended or after the server withdrew the request.
42
+ - `museLive()` no longer falls back to an approve-for-session choice when Muse offers no
43
+ one-time approval; it denies instead. Requests of another session or turn are ignored, and an
44
+ approval resolved elsewhere (`approval/resolved`, `alreadyTerminal`) closes its question.
45
+
46
+ ## 2.11.0 — 2026-10-06
47
+
48
+ ### Added
49
+
50
+ - `genaicode/react`: `<AgentChat>`, the `genaicode ui` chat as a presentational React
51
+ component for apps that run their own `createAgentSession` and stream its `SessionState`
52
+ to the page. It renders turns, streaming Markdown (no raw HTML; links open in a new tab),
53
+ collapsible tool calls, edited files, errors, approvals, queued prompts and the busy
54
+ state, and reports `onSend`, `onStop` and `onApprove`. Slots for host content:
55
+ `renderPrompt`, `renderAfterTurn`, `renderFooter`, `notices`, `header`, `headerExtras`,
56
+ `emptyState`, `formatToolName`. Themed with `--gc-*` CSS custom properties; styles in
57
+ `genaicode/react/styles.css`. React (18+) comes from the app and is not a declared
58
+ dependency. `Markdown` and the display helpers are exported too.
59
+ - `genaicode ui` and the `genaicode/vite` panel are now drawn by `<AgentChat>`.
60
+ - `genaicode/ui`: `startEmbeddedWeb` for hosts that frame the whole `genaicode ui` page,
61
+ typed with `task` (`mcpServers`, `timeoutMs`...), `env`, `transformPrompt` and
62
+ `frameAncestors`. The UI bundle loads only when it is called.
63
+ - `createAgentSession({ transformPrompt })` rewrites each prompt (and steered input) before
64
+ it reaches the agent; the transcript keeps the text given to `send()`.
65
+
66
+ - The `genaicode/vite` panel can be resized: drag its left or top edge (or focus an edge and use
67
+ the arrow keys), double-click an edge to reset it. The size is remembered across reloads.
68
+
3
69
  ## 2.9.1 — 2026-09-29
4
70
 
5
71
  ### Fixed
package/README.md CHANGED
@@ -106,23 +106,25 @@ for await (const event of run) {
106
106
  const result = await run.result; // { status, ok, text, sessionId, usage, error, ... }
107
107
  ```
108
108
 
109
- | Agent | Driver | Extras |
110
- | ---------------- | ----------------------------- | ------------------------------------------ |
111
- | Claude Code | `claude()` | MCP servers, max turns, effort, cost |
112
- | Codex | `codex()`, `codexLive()` | MCP servers; live: `steer()`, approvals |
113
- | GitHub Copilot | `copilot()` | MCP servers, allow/deny tool patterns |
114
- | Cursor | `cursor()` | streamed text deltas |
115
- | Gemini CLI | `gemini()` | approval mode |
116
- | opencode | `opencode()` | `provider/model` ids, variants |
117
- | Mistral Vibe | `vibe()` | agent profile, max turns, max price |
118
- | Antigravity CLI | `antigravity()` | sandbox, effort, usage |
119
- | Muse | `muse()`, `museLive()` | max turns; live: `steer()`, approvals |
120
- | Your own CLI/API | `cliAgent()`, `hostedAgent()` | plug in any JSON-lines CLI or hosted agent |
109
+ | Agent | Driver | Extras |
110
+ | ---------------- | ----------------------------- | ----------------------------------------------- |
111
+ | Claude Code | `claude()` | MCP servers, approvals, max turns, effort, cost |
112
+ | Codex | `codex()`, `codexLive()` | MCP servers; live: `steer()`, approvals |
113
+ | GitHub Copilot | `copilot()` | MCP servers, allow/deny tool patterns |
114
+ | Cursor | `cursor()` | streamed text deltas |
115
+ | Gemini CLI | `gemini()` | approval mode |
116
+ | opencode | `opencode()` | `provider/model` ids, variants |
117
+ | Mistral Vibe | `vibe()` | agent profile, max turns, max price |
118
+ | Antigravity CLI | `antigravity()` | sandbox, effort, usage |
119
+ | Muse | `muse()`, `museLive()` | max turns; live: `steer()`, approvals |
120
+ | Your own CLI/API | `cliAgent()`, `hostedAgent()` | plug in any JSON-lines CLI or hosted agent |
121
121
 
122
122
  On top of the drivers:
123
123
 
124
- - **Steer a running task** with `run.steer(text)`, and answer permission prompts with
125
- `onApproval` (live drivers).
124
+ - **Steer a running task** with `run.steer(text)` (live drivers), and answer permission
125
+ prompts with `onApproval` (Claude, live Codex and Muse).
126
+ - **Pick approval and sandbox policy** with `permissions: { approval, sandbox }` (or
127
+ `'yolo'`); each driver maps it to the agent's own flags and refuses what it cannot honor.
126
128
  - **Attach MCP servers per task** with `mcpServers`. Header secrets stay out of argv.
127
129
  - **Verify and repair**: `runWithVerify` runs your check (tests, lint) after the agent and
128
130
  sends failures back for another attempt.
@@ -130,8 +132,8 @@ On top of the drivers:
130
132
  from the agent's environment, so it bills its own login.
131
133
 
132
134
  Importing `genaicode` never spawns anything; only `genaicode/agents` does. The agent uses
133
- its own credentials, billing, and permission settings. GenAIcode does not sandbox it,
134
- choose a model, or retry it. See [docs/agents.md](docs/agents.md) for events, options per
135
+ its own credentials and billing, and its own permission settings unless `permissions` sets
136
+ them; any sandbox is the agent's own. GenAIcode does not choose a model or retry it. See [docs/agents.md](docs/agents.md) for events, options per
135
137
  driver, and writing your own driver.
136
138
 
137
139
  ### From the command line
@@ -164,10 +166,32 @@ can say "now add a test for that". Prompts sent while the agent works wait in a
164
166
  run next; Esc stops the agent. `/agent`, `/model` and `/new` switch agent, model and
165
167
  session; `/help` lists the rest.
166
168
 
169
+ <p align="center">
170
+ <picture>
171
+ <source media="(prefers-reduced-motion: reduce)" srcset="media/screenshots/chat-terminal.png">
172
+ <img alt="genaicode chat in a terminal: the agent fixes a failing test, then takes queued follow-ups." src="media/screenshots/chat-terminal.gif" width="49%">
173
+ </picture>
174
+ <picture>
175
+ <source media="(prefers-reduced-motion: reduce) and (prefers-color-scheme: dark)" srcset="media/screenshots/wolf-dark.png">
176
+ <source media="(prefers-reduced-motion: reduce)" srcset="media/screenshots/wolf-light.png">
177
+ <source media="(prefers-color-scheme: dark)" srcset="media/screenshots/chat-browser-dark.gif">
178
+ <source media="(prefers-color-scheme: light)" srcset="media/screenshots/chat-browser-light.gif">
179
+ <img alt="genaicode ui in a browser: the same fix and a follow-up." src="media/screenshots/chat-browser-light.gif" width="49%">
180
+ </picture>
181
+ </p>
182
+
167
183
  The wolf from genaicode 1.0 is back. When the agent asks for approval or finishes, the
168
184
  browser UI barks if its tab is in the background and counts those events in the tab title.
169
185
  The terminal UI rings the terminal bell instead. `/bark off` (or the Bark button) quiets it.
170
186
 
187
+ <p align="center">
188
+ <picture>
189
+ <source media="(prefers-color-scheme: dark)" srcset="media/screenshots/wolf-dark.png">
190
+ <source media="(prefers-color-scheme: light)" srcset="media/screenshots/wolf-light.png">
191
+ <img alt="The browser UI with the wolf behind a finished turn." src="media/screenshots/wolf-light.png" width="80%">
192
+ </picture>
193
+ </p>
194
+
171
195
  `genaicode ui` listens on the loopback address and prints a link with a random access
172
196
  token. The page, the event stream and every command need that token; only the bundled
173
197
  script and the four mascot files (`/app.js`, `/assets/…`) are served without it, since they
@@ -187,6 +211,14 @@ import genaicode from 'genaicode/vite';
187
211
  export default defineConfig({ plugins: [genaicode()] });
188
212
  ```
189
213
 
214
+ <p align="center">
215
+ <picture>
216
+ <source media="(prefers-color-scheme: dark)" srcset="media/screenshots/vite-dark.png">
217
+ <source media="(prefers-color-scheme: light)" srcset="media/screenshots/vite-light.png">
218
+ <img alt="The genaicode panel over a Vite app: the agent fixed the page's two errors." src="media/screenshots/vite-light.png" width="80%">
219
+ </picture>
220
+ </p>
221
+
190
222
  In `vite dev`, the app gets the wolf in its corner. It opens the same chat as `genaicode ui`
191
223
  in a panel, with the agent working in the project root. The wolf counts the page's errors
192
224
  (build errors, uncaught exceptions, unhandled rejections, `console.error`), and "Fix N
@@ -196,6 +228,100 @@ Builds are untouched. The chat runs on its own port on 127.0.0.1 even when Vite
196
228
  `--host`, lets only the app's origins frame it, and hands its token (and takes "fix" requests)
197
229
  only from the app's own pages on this machine.
198
230
 
231
+ ### In your own React app
232
+
233
+ `genaicode/react` is the same chat as a component. It draws a `SessionState` your app gives
234
+ it and calls you back; it runs, fetches and stores nothing, so your server owns the session,
235
+ its MCP servers and its prompts. React 18 or newer comes from your app: genaicode does not
236
+ declare or install it.
237
+
238
+ ```ts
239
+ // server (Node): one session, streamed to the page
240
+ import { createAgentSession, claude } from 'genaicode/agents';
241
+
242
+ const session = createAgentSession({
243
+ agent: claude(),
244
+ cwd: process.cwd(),
245
+ task: { mcpServers: [{ name: 'ops', url: 'http://127.0.0.1:4000/mcp' }] },
246
+ // The agent gets the context; the transcript keeps what the user typed.
247
+ transformPrompt: (text) => `${briefing}\n\nOperator message:\n${text}`,
248
+ });
249
+
250
+ app.get('/api/agent/events', (req, res) => {
251
+ res.writeHead(200, { 'content-type': 'text/event-stream', 'cache-control': 'no-store' });
252
+ const push = (state) => res.write(`data: ${JSON.stringify(state)}\n\n`);
253
+ push(session.get());
254
+ res.on('close', session.subscribe(push));
255
+ });
256
+ app.post('/api/agent/send', (req, res) => {
257
+ session.send(req.body.text);
258
+ res.json({ ok: true });
259
+ });
260
+ app.post('/api/agent/stop', (req, res) => {
261
+ session.stop();
262
+ res.json({ ok: true });
263
+ });
264
+ app.post('/api/agent/approve', (req, res) => res.json({ ok: session.approve(req.body.id, req.body.decision) }));
265
+ ```
266
+
267
+ ```tsx
268
+ // page
269
+ import { useEffect, useState } from 'react';
270
+ import { AgentChat, type SessionState } from 'genaicode/react';
271
+ import 'genaicode/react/styles.css';
272
+
273
+ const post = (path: string, body: object = {}) =>
274
+ fetch(path, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) });
275
+
276
+ export function AgentDrawer() {
277
+ const [state, setState] = useState<SessionState | null>(null);
278
+ useEffect(() => {
279
+ const events = new EventSource('/api/agent/events');
280
+ events.onmessage = (event) => setState(JSON.parse(event.data));
281
+ return () => events.close();
282
+ }, []);
283
+ return (
284
+ <AgentChat
285
+ state={state}
286
+ onSend={(text) => post('/api/agent/send', { text })}
287
+ onStop={() => post('/api/agent/stop')}
288
+ onApprove={(id, decision) => post('/api/agent/approve', { id, decision })}
289
+ formatToolName={(name) => name.replace(/^mcp__ops__/, '')}
290
+ renderFooter={() => <MyApprovalCards />}
291
+ headerExtras={<button onClick={() => post('/api/agent/reset')}>New</button>}
292
+ />
293
+ );
294
+ }
295
+ ```
296
+
297
+ `<AgentChat>` fills its container's height. It shows turns with streaming Markdown (no raw
298
+ HTML; links open in a new tab), collapsible tool calls, edited files, errors, the agent's
299
+ own approval requests, queued prompts and a working indicator, and an input where Enter
300
+ sends, Shift+Enter adds a line and Esc stops. Props:
301
+
302
+ | Prop | |
303
+ | ------------------------------------------------------------------------------ | ---------------------------------------------------------------- |
304
+ | `state` | `SessionState`, or null before there is a session |
305
+ | `onSend(text)`, `onStop()` | Enter or Send; Stop or Esc. No `onStop`, no Stop button |
306
+ | `onApprove(id, decision)` | answers `state.approvals`; without it they show as waiting |
307
+ | `renderPrompt(text, turn?)` | how a sent prompt shows (return null to hide it) |
308
+ | `renderAfterTurn(turn, i)`, `renderFooter()` | your content after a turn, or at the end |
309
+ | `notices` | `{ id, afterTurn, text, tone? }[]`: your own lines between turns |
310
+ | `header`, `headerExtras` | replace the header (null for none), or add to its right end |
311
+ | `emptyState`, `placeholder`, `hint` | text before the first turn, in and under the input |
312
+ | `formatToolName(name)`, `disabled`, `autoFocus`, `theme`, `className`, `style` | |
313
+
314
+ Theme it with CSS custom properties on the component or any ancestor: `--gc-bg`,
315
+ `--gc-panel`, `--gc-border`, `--gc-text`, `--gc-muted`, `--gc-accent`, `--gc-accent-text`,
316
+ `--gc-error`, `--gc-font`, `--gc-mono`, `--gc-font-size`, `--gc-radius`, `--gc-max-width`
317
+ (and `--gc-ok`, `--gc-warn`, plus soft shades mixed from these unless set). Unset ones keep
318
+ the `genaicode ui` look, light or dark by `prefers-color-scheme`, or by `theme="light"` /
319
+ `"dark"`. `genaicode ui` and the Vite panel draw this same component.
320
+
321
+ To show the whole `genaicode ui` page in a frame instead, `startEmbeddedWeb` from
322
+ `genaicode/ui` serves it on 127.0.0.1 with your `task` (`mcpServers`, `timeoutMs`...), `env`
323
+ and `transformPrompt`, and returns its tokenized `url` and a `controller` to send prompts.
324
+
199
325
  ## Chaining prompts
200
326
 
201
327
  A chain remembers successful user and assistant turns. Each new prompt sees the complete
@@ -1,4 +1,4 @@
1
- import { type PreparedRun } from './prepare.js';
1
+ import { type PrepareContext, type PreparedRun } from './prepare.js';
2
2
  import { type AgentOutcome } from './runtime.js';
3
3
  import type { AgentCapabilities, AgentEvent, AgentTask, CodingAgent } from './types.js';
4
4
  export type { AgentOutcome } from './runtime.js';
@@ -15,8 +15,11 @@ export interface CliAgentDefinition {
15
15
  capabilities?: AgentCapabilities;
16
16
  /** Full argument list for a task, prompt included. */
17
17
  args(task: AgentTask): string[];
18
- /** Replaces `args` when a task needs setup: extra env, temp files to clean up. */
19
- prepare?(task: AgentTask): PreparedRun;
18
+ /**
19
+ * Replaces `args` when a task needs setup: extra env, temp files to clean up, a local
20
+ * server to start first. The process starts once it resolves.
21
+ */
22
+ prepare?(task: AgentTask, context: PrepareContext): PreparedRun | Promise<PreparedRun>;
20
23
  createParser(): AgentOutputParser;
21
24
  /** Adjust the child environment (the caller's `task.env` or `process.env`). */
22
25
  env?(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
@@ -1,6 +1,6 @@
1
- import { planSpawn } from './prepare.js';
1
+ import { planSpawnAsync } from './prepare.js';
2
2
  import { startProcess } from './process.js';
3
- import { invalidCwd, RunRecorder } from './runtime.js';
3
+ import { invalidCwd, linkAbort, RunRecorder } from './runtime.js';
4
4
  /**
5
5
  * Build a `CodingAgent` from a headless CLI: spawn, decode its JSON lines, and
6
6
  * fold them into an `AgentResult`. Drivers such as `claude()` are thin definitions.
@@ -16,41 +16,63 @@ export function cliAgent(definition) {
16
16
  function runCliAgent(definition, task) {
17
17
  const recorder = new RunRecorder(definition.name, definition.command);
18
18
  const iterate = () => recorder.events.iterate();
19
- const plan = planSpawn(definition, task, invalidCwd(task.cwd));
20
- if (!plan.ok) {
21
- const result = recorder.finish({ exitCode: null, signal: null, reason: 'spawn-error', error: new Error(plan.error) }, undefined);
22
- return { result: Promise.resolve(result), abort() { }, [Symbol.asyncIterator]: iterate };
23
- }
24
- const parser = definition.createParser();
25
- const handle = startProcess({
26
- command: definition.command,
27
- args: plan.args,
28
- cwd: task.cwd,
29
- env: plan.env,
30
- timeoutMs: task.timeoutMs,
31
- signal: task.signal,
32
- onLine(line) {
33
- let value;
34
- try {
35
- value = JSON.parse(line);
36
- }
37
- catch {
38
- recorder.emit({ type: 'raw', line });
39
- return;
40
- }
41
- for (const event of parser.event(value))
42
- recorder.emit(event);
43
- },
44
- onStderr: (text) => recorder.emit({ type: 'stderr', text }),
45
- });
46
- // A consumer that falls behind pauses the agent instead of buffering its output without bound.
47
- recorder.events.onPressure = (paused) => (paused ? handle.pause() : handle.resume());
48
- return {
49
- result: handle.exit.then((exit) => {
19
+ const lifetime = new AbortController();
20
+ linkAbort(task.signal, lifetime);
21
+ let handle;
22
+ let stopped = false;
23
+ const context = { emit: (event) => recorder.emit(event), signal: lifetime.signal };
24
+ const start = (plan) => {
25
+ const parser = definition.createParser();
26
+ const started = startProcess({
27
+ command: definition.command,
28
+ args: plan.args,
29
+ cwd: task.cwd,
30
+ env: plan.env,
31
+ timeoutMs: task.timeoutMs,
32
+ signal: task.signal,
33
+ onLine(line) {
34
+ let value;
35
+ try {
36
+ value = JSON.parse(line);
37
+ }
38
+ catch {
39
+ recorder.emit({ type: 'raw', line });
40
+ return;
41
+ }
42
+ for (const event of parser.event(value))
43
+ recorder.emit(event);
44
+ },
45
+ onStderr: (text) => recorder.emit({ type: 'stderr', text }),
46
+ });
47
+ handle = started;
48
+ // A consumer that falls behind pauses the agent instead of buffering its output without bound.
49
+ recorder.events.onPressure = (paused) => (paused ? started.pause() : started.resume());
50
+ return started.exit.then((exit) => {
51
+ lifetime.abort();
50
52
  plan.cleanup();
51
53
  return recorder.finish(exit, parser.outcome?.());
52
- }),
53
- abort: handle.kill,
54
+ });
55
+ };
56
+ const result = planSpawnAsync(definition, task, invalidCwd(task.cwd), context).then((plan) => {
57
+ if (!plan.ok) {
58
+ lifetime.abort();
59
+ return recorder.finish({ exitCode: null, signal: null, reason: 'spawn-error', error: new Error(plan.error) }, undefined);
60
+ }
61
+ // Stopped while `prepare` was still running.
62
+ if (stopped || task.signal?.aborted) {
63
+ lifetime.abort();
64
+ plan.cleanup();
65
+ return recorder.finish({ exitCode: null, signal: null, reason: 'aborted' }, undefined);
66
+ }
67
+ return start(plan);
68
+ });
69
+ return {
70
+ result,
71
+ abort() {
72
+ stopped = true;
73
+ lifetime.abort();
74
+ handle?.kill();
75
+ },
54
76
  [Symbol.asyncIterator]: iterate,
55
77
  };
56
78
  }
@@ -1 +1 @@
1
- {"version":3,"file":"cli-agent.js","sourceRoot":"","sources":["../../src/agents/cli-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAoB,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAqB,MAAM,cAAc,CAAC;AA0B1E;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,UAA8B;IACrD,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,OAAO,EA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AO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;QAC3F,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;YACb,QAAQ,CAAC,KAAK,EAAE,CAAC;YACjB,OAAO,QAAQ,CAAC,MAAM,CACpB,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,EACrF,SAAS,CACV,CAAC;QACJ,CAAC;QACD,6CAA6C;QAC7C,IAAI,OAAO,IAAI,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;YACpC,QAAQ,CAAC,KAAK,EAAE,CAAC;YACjB,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,OAAO,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,SAAS,CAAC,CAAC;QACzF,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,MAAM;QACN,KAAK;YACH,OAAO,GAAG,IAAI,CAAC;YACf,QAAQ,CAAC,KAAK,EAAE,CAAC;YACjB,MAAM,EAAE,IAAI,EAAE,CAAC;QACjB,CAAC;QACD,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,OAAO;KAChC,CAAC;AACJ,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { type AgentOutputParser } from '../cli-agent.js';
2
- import type { AgentTask, CodingAgent } from '../types.js';
2
+ import { type PermissionFlags } from '../permissions.js';
3
+ import type { AgentPermissions, AgentTask, CodingAgent } from '../types.js';
3
4
  export interface AntigravityAgentOptions {
4
5
  /** Executable name or path. Default `agy`. */
5
6
  command?: string;
@@ -10,6 +11,11 @@ export interface AntigravityAgentOptions {
10
11
  }
11
12
  /** Antigravity CLI in print mode (`agy --output-format stream-json --print ...`). */
12
13
  export declare function antigravity(options?: AntigravityAgentOptions): CodingAgent;
14
+ /**
15
+ * Antigravity flags for `permissions`: `workspace-write` runs terminal commands in its sandbox
16
+ * (`--sandbox`), `unrestricted` leaves it off. Approval policies are not offered.
17
+ */
18
+ export declare function antigravityPermissionFlags(permissions: AgentPermissions): PermissionFlags;
13
19
  export declare function antigravityArgs(task: AgentTask, options?: AntigravityAgentOptions): string[];
14
20
  /** Decodes `--output-format stream-json`: `init`, `step_update` and `result` events. */
15
21
  export declare function createAntigravityParser(): AgentOutputParser;
@@ -1,18 +1,43 @@
1
1
  import { cliAgent } from '../cli-agent.js';
2
+ import { exclusiveOption, resolvePermissions } from '../permissions.js';
2
3
  import { isObject, numberField, stringField } from './json.js';
3
4
  /** Antigravity CLI in print mode (`agy --output-format stream-json --print ...`). */
4
5
  export function antigravity(options = {}) {
5
6
  return cliAgent({
6
7
  name: 'antigravity',
7
8
  command: options.command ?? 'agy',
8
- capabilities: { effort: ['low', 'medium', 'high'], usage: true },
9
+ capabilities: {
10
+ effort: ['low', 'medium', 'high'],
11
+ usage: true,
12
+ permissions: { sandbox: ['workspace-write', 'unrestricted'] },
13
+ },
9
14
  args: (task) => antigravityArgs(task, options),
10
15
  createParser: createAntigravityParser,
11
16
  });
12
17
  }
18
+ /**
19
+ * Antigravity flags for `permissions`: `workspace-write` runs terminal commands in its sandbox
20
+ * (`--sandbox`), `unrestricted` leaves it off. Approval policies are not offered.
21
+ */
22
+ export function antigravityPermissionFlags(permissions) {
23
+ const { approval, sandbox } = permissions;
24
+ if (approval)
25
+ throw new Error(`antigravity cannot run with permissions.approval '${approval}'.`);
26
+ if (sandbox === 'read-only')
27
+ throw new Error("antigravity cannot run with permissions.sandbox 'read-only'.");
28
+ return {
29
+ args: sandbox === 'workspace-write' ? ['--sandbox'] : [],
30
+ replaces: sandbox ? { '--sandbox': 'flag' } : {},
31
+ };
32
+ }
13
33
  export function antigravityArgs(task, options = {}) {
14
34
  const args = ['--mode', options.mode ?? 'accept-edits'];
15
- if (options.sandbox ?? true)
35
+ const permissions = resolvePermissions(task.permissions);
36
+ exclusiveOption('antigravity', 'sandbox', options.sandbox !== undefined, 'sandbox', !!permissions.sandbox);
37
+ const flags = antigravityPermissionFlags(permissions);
38
+ if (permissions.sandbox)
39
+ args.push(...flags.args);
40
+ else if (options.sandbox ?? true)
16
41
  args.push('--sandbox');
17
42
  args.push('--output-format', 'stream-json');
18
43
  if (task.model)
@@ -1 +1 @@
1
- {"version":3,"file":"antigravity.js","sourceRoot":"","sources":["../../../src/agents/drivers/antigravity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAA6C,MAAM,iBAAiB,CAAC;AAEtF,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAW/D,qFAAqF;AACrF,MAAM,UAAU,WAAW,CAAC,UAAmC,EAAE;IAC/D,OAAO,QAAQ,CAAC;QACd,IAAI,EAAE,aAAa;QACnB,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,KAAK;QACjC,YAAY,EAAE,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE;QAChE,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC;QAC9C,YAAY,EAAE,uBAAuB;KACtC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAe,EAAE,UAAmC,EAAE;IACpF,MAAM,IAAI,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,IAAI,cAAc,CAAC,CAAC;IACxD,IAAI,OAAO,CAAC,OAAO,IAAI,IAAI;QAAE,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACpD,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC;IAC5C,IAA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EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gCACrD,GAAG,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gCACvD,GAAG,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gCACrD,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;6BACpD;yBACF,CAAC,CAAC;oBACL,CAAC;oBACD,MAAM;gBACR,CAAC;YACH,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,86 @@
1
+ import type { PermissionFlags } from '../permissions.js';
2
+ import type { AgentPermissions, ApprovalHandler, ApprovalRequest, SandboxPolicy } from '../types.js';
3
+ import { type JsonObject } from './json.js';
4
+ /** Name of the permission prompt tool `claudeApprovalTool` serves. */
5
+ export declare const CLAUDE_APPROVAL_TOOL = "approve";
6
+ /** An MCP `tools/call` result. */
7
+ export interface McpToolResult {
8
+ content: {
9
+ type: 'text';
10
+ text: string;
11
+ }[];
12
+ isError?: boolean;
13
+ }
14
+ /**
15
+ * Claude Code's permission prompt tool (`--permission-prompt-tool`) as an MCP tool an app
16
+ * can serve from its own MCP server. Claude calls it with the tool name and input it wants
17
+ * to use; the answer allows exactly that input, or denies.
18
+ */
19
+ export interface ClaudeApprovalTool {
20
+ name: string;
21
+ description: string;
22
+ inputSchema: JsonObject;
23
+ /**
24
+ * Answer one call: ask `onApproval`, then reply in Claude's format. Malformed arguments,
25
+ * a missing or throwing handler, and `signal` aborting (the caller disconnected) all deny.
26
+ */
27
+ call(args: unknown, signal?: AbortSignal): Promise<McpToolResult>;
28
+ }
29
+ export interface ClaudeApprovalToolOptions {
30
+ /** Tool name. Default `approve`. */
31
+ name?: string;
32
+ /**
33
+ * The run's `permissions.sandbox`: requests that would step outside it are denied without
34
+ * asking (see `claudeSandboxRefuses`). Needs `cwd`.
35
+ */
36
+ sandbox?: SandboxPolicy;
37
+ /** The run's working directory. */
38
+ cwd?: string;
39
+ }
40
+ /** Build the permission prompt tool around an approval handler. */
41
+ export declare function claudeApprovalTool(onApproval: ApprovalHandler | undefined, options?: ClaudeApprovalToolOptions): ClaudeApprovalTool;
42
+ /** The approval request for one permission prompt tool call, or undefined when the call is malformed. */
43
+ export declare function claudeApprovalRequest(args: unknown): ApprovalRequest | undefined;
44
+ /**
45
+ * Whether a permission prompt asks for something outside `sandbox`, so neither a person nor
46
+ * `auto-approve` may grant it. `read-only`: anything but a reading tool, `ExitPlanMode`
47
+ * included. `workspace-write`: an edit outside `cwd`, and any `Bash` prompt (Claude's sandbox
48
+ * runs sandboxed commands without asking, so a prompt means an unsandboxed one).
49
+ */
50
+ export declare function claudeSandboxRefuses(args: unknown, sandbox: SandboxPolicy, cwd: string): boolean;
51
+ /**
52
+ * Claude Code flags for `permissions`. `read-only` is plan mode; `workspace-write` turns on
53
+ * Claude's sandbox for Bash (writes limited to `cwd` and temp, see `--settings`), with edits in
54
+ * `cwd` accepted; `unrestricted` turns the sandbox off. `ask` and `auto-approve` need the
55
+ * permission prompt tool (`claudeApprovalTool` with the same sandbox); `deny` runs without it,
56
+ * so Claude refuses what it would have asked about.
57
+ */
58
+ export declare function claudePermissionFlags(permissions: AgentPermissions): PermissionFlags;
59
+ /**
60
+ * Environment for a Claude process whose permission prompts wait on a person. Claude gives up
61
+ * on an MCP tool call after 60 s by default (`MCP_TOOL_TIMEOUT`), which would fail the tool
62
+ * call while the question is still open. Empty when `env` already sets a timeout.
63
+ */
64
+ export declare function claudeApprovalEnv(env?: NodeJS.ProcessEnv): Record<string, string>;
65
+ /** Claude Code arguments that route its permission prompts to `tool` on MCP server `server`. */
66
+ export declare function claudeApprovalArgs(server: string, tool?: string): string[];
67
+ export interface ClaudeApprovalServer {
68
+ /** The MCP server to add to Claude's `--mcp-config`. Its bearer token is in `headers`. */
69
+ server: {
70
+ name: string;
71
+ url: string;
72
+ headers: Record<string, string>;
73
+ };
74
+ /** `--permission-prompt-tool` for that server. */
75
+ args: string[];
76
+ /** Stop serving. Open questions are withdrawn (their signals abort) and denied. */
77
+ close(): Promise<void>;
78
+ }
79
+ /**
80
+ * Serve `claudeApprovalTool` alone over MCP (streamable HTTP, JSON responses) on a random
81
+ * loopback port, behind a random bearer token. `name` is the MCP server name. For apps that
82
+ * have no MCP server of their own to mount the tool on; `claude()` uses it for `task.onApproval`.
83
+ */
84
+ export declare function startClaudeApprovalServer(onApproval: ApprovalHandler | undefined, options?: {
85
+ name?: string;
86
+ } & Pick<ClaudeApprovalToolOptions, 'sandbox' | 'cwd'>): Promise<ClaudeApprovalServer>;