@koalaauto/agentchannel 3.53.3 → 3.54.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 (38) hide show
  1. package/dist/src/adapters/antigravity.d.ts +144 -0
  2. package/dist/src/adapters/antigravity.js +319 -0
  3. package/dist/src/adapters/claude.d.ts +24 -0
  4. package/dist/src/adapters/claude.js +2 -0
  5. package/dist/src/adapters/codex.d.ts +24 -1
  6. package/dist/src/adapters/codex.js +2 -1
  7. package/dist/src/adapters/fake.d.ts +6 -3
  8. package/dist/src/adapters/fake.js +21 -5
  9. package/dist/src/adapters/index.d.ts +2 -0
  10. package/dist/src/adapters/index.js +7 -1
  11. package/dist/src/adapters/kiro.d.ts +20 -2
  12. package/dist/src/adapters/kiro.js +2 -2
  13. package/dist/src/adapters/spec.d.ts +164 -0
  14. package/dist/src/adapters/spec.js +104 -0
  15. package/dist/src/adapters/types.d.ts +4 -7
  16. package/dist/src/agycheck.d.ts +21 -0
  17. package/dist/src/agycheck.js +58 -0
  18. package/dist/src/args.d.ts +1 -1
  19. package/dist/src/args.js +3 -2
  20. package/dist/src/cli-run.js +15 -9
  21. package/dist/src/doctor.d.ts +3 -3
  22. package/dist/src/doctor.js +13 -7
  23. package/dist/src/envcheck.d.ts +8 -0
  24. package/dist/src/envcheck.js +12 -0
  25. package/dist/src/onboard.js +1 -1
  26. package/dist/src/prompts.d.ts +7 -1
  27. package/dist/src/prompts.js +25 -5
  28. package/dist/src/runner/context.d.ts +2 -2
  29. package/dist/src/runner/context.js +3 -3
  30. package/dist/src/runner/runner.d.ts +6 -0
  31. package/dist/src/runner/runner.js +63 -25
  32. package/dist/src/runtimecheck.d.ts +26 -0
  33. package/dist/src/runtimecheck.js +20 -0
  34. package/dist/src/sandboxcheck.d.ts +2 -1
  35. package/dist/src/sandboxcheck.js +10 -5
  36. package/dist/src/version.d.ts +1 -1
  37. package/dist/src/version.js +1 -1
  38. package/package.json +1 -1
@@ -0,0 +1,144 @@
1
+ import type { RuntimeModels } from './models.js';
2
+ import { type AdapterEvent, type AdapterResult, type AdapterRunOptions, type RuntimeAdapter } from './types.js';
3
+ import type { Perm } from '../perm.js';
4
+ /**
5
+ * Antigravity runtime: each run is one headless `agy -p <prompt> --output-format stream-json` on this machine, logged in
6
+ * with the owner's Google account (the login is a file under the real ~/.gemini, so the run keeps the real HOME).
7
+ *
8
+ * The run gets no `ach` and no hub credentials: a sandboxed command has no network, so it could not reach the hub anyway.
9
+ * The runner completes or fails the task and posts answers from the run's final text.
10
+ *
11
+ * Permission levels, as tried by hand with agy 1.5.13 on Linux (2026-11-20; recordings in test/fixtures/antigravity):
12
+ * - read: no commands at all (one allowed command reads any file), no writes, no URL tools, no MCP; file reads only.
13
+ * - workdir: `--sandbox`, commands run inside agy's own sandbox without asking: they write the work dir and /tmp, have no
14
+ * network, and see a filtered HOME (no runner config, no tokens). The file tools run outside it, held by deny rules.
15
+ * - full: `--dangerously-skip-permissions`.
16
+ * What it does not hold: files outside HOME are readable (other checkouts on the machine, /tmp), and its web search tool
17
+ * cannot be turned off by any rule (spec: `reads: 'machine'`, `limits.net: false`).
18
+ *
19
+ * An action nobody could approve is auto-denied and agy then reports status SUCCESS, exit 0, with an empty response and
20
+ * `denied_actions`: that is a failed run here. A rule that denies an action outright is only a tool error to the model, and
21
+ * the run goes on, so every profile denies by rule what it does not allow.
22
+ */
23
+ export declare const AGY_INSTALL = "curl -fsSL https://antigravity.google/cli/install.sh | bash";
24
+ /** Ubuntu stops unprivileged user namespaces through AppArmor; agy builds its sandbox from them (not bwrap), so it needs its own profile. */
25
+ export declare const AGY_APPARMOR: string;
26
+ /** The paths of `paths` a sandboxed command could read: the sandbox hides the home directory and nothing else. Pure. */
27
+ export declare function agyExposed(paths: string[], realHome?: string): string[];
28
+ /** The settings of one run (`--settings`, never saved): its permission rules. Pure. */
29
+ export declare function agySettings(o: {
30
+ perm: Perm;
31
+ denyReadPaths?: string[];
32
+ }): Record<string, unknown> | undefined;
33
+ /** The level a run really gets: only a work run writes; every other run (answer, mention, read-ahead) reads. */
34
+ export declare function agyPerm(perm: Perm, mode: AdapterRunOptions['mode']): Perm;
35
+ export declare function agyArgs(o: {
36
+ prompt: string;
37
+ perm: Perm;
38
+ model?: string;
39
+ effort?: string;
40
+ resume?: string;
41
+ denyReadPaths?: string[];
42
+ readRoots?: string[];
43
+ outputSchema?: unknown;
44
+ }): string[];
45
+ /** The environment agy runs with: the agent env without the hub's run variables, and the runner's real HOME (its login is there). */
46
+ export declare function agyEnv(agentEnv: Record<string, string>, o: {
47
+ realHome?: string;
48
+ }): Record<string, string>;
49
+ /** agy as the runner starts it: ACH_ANTIGRAVITY_BIN, else `agy` (on PATH, or where its installer puts it). */
50
+ export declare function agyBin(env: Record<string, string | undefined>): string;
51
+ /** PATH with the installer's directory (~/.local/bin) added: a service's PATH often lacks it. */
52
+ export declare function agyPath(env: Record<string, string | undefined>, realHome?: string): string;
53
+ /**
54
+ * Turns `--output-format stream-json` (one JSON object per line: `init`, `step_update`, `result`) into adapter events and the
55
+ * run's outcome. A tool step comes ACTIVE, then DONE or ERROR: one tool_start and one tool_end (a step seen only when it is
56
+ * over gets both). Text comes as deltas of an `agent_response` step: one text event per step. There are no thinking events.
57
+ */
58
+ export declare class AgyOutput {
59
+ private onEvent;
60
+ sessionId?: string;
61
+ model?: string;
62
+ status?: string;
63
+ runError?: string;
64
+ denied: string[];
65
+ /** usage of the conversation so far (a resumed one counts its earlier turns too) */
66
+ tokens?: {
67
+ input: number;
68
+ output: number;
69
+ };
70
+ private buf;
71
+ private response;
72
+ private structured;
73
+ private texts;
74
+ private lastText;
75
+ private open;
76
+ constructor(onEvent: (e: AdapterEvent) => void);
77
+ push(chunk: string): void;
78
+ end(): void;
79
+ /**
80
+ * The agent's final message: the structured output when a schema was asked for (the response can carry prose around
81
+ * it), else the result's response, else what it last said.
82
+ */
83
+ finalText(): string;
84
+ private line;
85
+ private session;
86
+ private step;
87
+ private flushText;
88
+ private result;
89
+ }
90
+ /**
91
+ * The outcome of a finished agy process. A run is good only when the process, the status and the final message all say so:
92
+ * agy reports SUCCESS with nothing in it when an action was auto-denied, and exits 0 then. Pure.
93
+ */
94
+ export declare function agyOutcome(o: {
95
+ code: number | null;
96
+ out: Pick<AgyOutput, 'status' | 'runError' | 'denied'>;
97
+ finalText: string;
98
+ stderr: string;
99
+ aborted?: boolean;
100
+ spawnError?: string;
101
+ }): {
102
+ ok: boolean;
103
+ error?: string;
104
+ };
105
+ /** `agy models` prints "<slug>\t<label>" per line (after a "Fetching..." line). Pure. */
106
+ export declare function agyModels(out: string): RuntimeModels | undefined;
107
+ export interface AntigravityAdapterOptions {
108
+ model?: string;
109
+ env?: Record<string, string | undefined>;
110
+ /** Tests: the program to start instead of agy. */
111
+ bin?: string;
112
+ }
113
+ export declare class AntigravityAdapter implements RuntimeAdapter {
114
+ private o;
115
+ readonly name = "antigravity";
116
+ readonly spec: {
117
+ readonly name: "antigravity";
118
+ readonly label: "Antigravity";
119
+ readonly where: "local";
120
+ readonly ach: false;
121
+ readonly structuredAnswers: true;
122
+ readonly perms: readonly Perm[];
123
+ readonly limits: {
124
+ readonly net: false;
125
+ readonly denyRead: true;
126
+ };
127
+ readonly reads: "machine";
128
+ readonly budget: false;
129
+ readonly ownerMemory: "prompt";
130
+ readonly ownFiles: readonly [];
131
+ readonly login: {
132
+ readonly command: "agy";
133
+ };
134
+ readonly check: "tool";
135
+ };
136
+ constructor(o?: AntigravityAdapterOptions);
137
+ listModels(o: {
138
+ env: Record<string, string>;
139
+ cwd: string;
140
+ realHome?: string;
141
+ }): Promise<RuntimeModels>;
142
+ private bin;
143
+ run(opts: AdapterRunOptions): Promise<AdapterResult>;
144
+ }
@@ -0,0 +1,319 @@
1
+ import { execFile } from 'node:child_process';
2
+ import { join, relative, isAbsolute } from 'node:path';
3
+ import { RUNTIME_SPECS } from './spec.js';
4
+ import { spawnGroup } from './procgroup.js';
5
+ import { modelId } from './types.js';
6
+ /**
7
+ * Antigravity runtime: each run is one headless `agy -p <prompt> --output-format stream-json` on this machine, logged in
8
+ * with the owner's Google account (the login is a file under the real ~/.gemini, so the run keeps the real HOME).
9
+ *
10
+ * The run gets no `ach` and no hub credentials: a sandboxed command has no network, so it could not reach the hub anyway.
11
+ * The runner completes or fails the task and posts answers from the run's final text.
12
+ *
13
+ * Permission levels, as tried by hand with agy 1.5.13 on Linux (2026-11-20; recordings in test/fixtures/antigravity):
14
+ * - read: no commands at all (one allowed command reads any file), no writes, no URL tools, no MCP; file reads only.
15
+ * - workdir: `--sandbox`, commands run inside agy's own sandbox without asking: they write the work dir and /tmp, have no
16
+ * network, and see a filtered HOME (no runner config, no tokens). The file tools run outside it, held by deny rules.
17
+ * - full: `--dangerously-skip-permissions`.
18
+ * What it does not hold: files outside HOME are readable (other checkouts on the machine, /tmp), and its web search tool
19
+ * cannot be turned off by any rule (spec: `reads: 'machine'`, `limits.net: false`).
20
+ *
21
+ * An action nobody could approve is auto-denied and agy then reports status SUCCESS, exit 0, with an empty response and
22
+ * `denied_actions`: that is a failed run here. A rule that denies an action outright is only a tool error to the model, and
23
+ * the run goes on, so every profile denies by rule what it does not allow.
24
+ */
25
+ export const AGY_INSTALL = 'curl -fsSL https://antigravity.google/cli/install.sh | bash';
26
+ /** Ubuntu stops unprivileged user namespaces through AppArmor; agy builds its sandbox from them (not bwrap), so it needs its own profile. */
27
+ export const AGY_APPARMOR = `printf '%s\\n' 'abi <abi/4.0>,' 'include <tunables/global>' 'profile agy /home/*/.local/bin/agy flags=(unconfined) {' ' userns,' ' include if exists <local/agy>' '}' ` +
28
+ `| sudo tee /etc/apparmor.d/agy >/dev/null && sudo apparmor_parser -r /etc/apparmor.d/agy`;
29
+ const AGY_SANDBOX_HINT = 'on Ubuntu, AppArmor must let agy create user namespaces: see `ach doctor`';
30
+ /** The paths of `paths` a sandboxed command could read: the sandbox hides the home directory and nothing else. Pure. */
31
+ export function agyExposed(paths, realHome) {
32
+ const inside = (p) => {
33
+ if (!realHome)
34
+ return false;
35
+ const r = relative(realHome, p);
36
+ return !!r && !r.startsWith('..') && !isAbsolute(r);
37
+ };
38
+ return paths.filter((p) => !inside(p));
39
+ }
40
+ /** The settings of one run (`--settings`, never saved): its permission rules. Pure. */
41
+ export function agySettings(o) {
42
+ if (o.perm === 'full')
43
+ return undefined;
44
+ const secrets = (o.denyReadPaths ?? []).flatMap((p) => [`read_file(${p})`, `write_file(${p})`]);
45
+ const net = ['read_url(*)', 'execute_url(*)', 'download_url(*)', 'mcp(*)'];
46
+ if (o.perm === 'read')
47
+ return { permissions: { deny: ['command(*)', 'unsandboxed(*)', 'write_file(*)', ...net, ...secrets] } };
48
+ return { toolPermission: 'proceed-in-sandbox', enableTerminalSandbox: true, permissions: { deny: ['unsandboxed(*)', ...net, ...secrets] } };
49
+ }
50
+ /** The level a run really gets: only a work run writes; every other run (answer, mention, read-ahead) reads. */
51
+ export function agyPerm(perm, mode) {
52
+ return mode && mode !== 'work' ? 'read' : perm;
53
+ }
54
+ export function agyArgs(o) {
55
+ const settings = agySettings(o);
56
+ return [
57
+ '--print',
58
+ o.prompt,
59
+ '--output-format',
60
+ 'stream-json',
61
+ ...(o.resume ? ['--conversation', o.resume] : []),
62
+ ...(o.model ? ['--model', o.model] : []),
63
+ ...(o.effort && /^[a-z]{2,12}$/.test(o.effort) ? ['--effort', o.effort] : []),
64
+ ...(o.perm === 'full' ? ['--dangerously-skip-permissions'] : []),
65
+ ...(o.perm === 'workdir' ? ['--sandbox'] : []),
66
+ ...(settings ? ['--settings', JSON.stringify(settings)] : []),
67
+ ...(o.readRoots ?? []).flatMap((d) => ['--add-dir', d]),
68
+ ...(o.outputSchema ? ['--json-schema', JSON.stringify(o.outputSchema)] : []),
69
+ ];
70
+ }
71
+ /** The environment agy runs with: the agent env without the hub's run variables, and the runner's real HOME (its login is there). */
72
+ export function agyEnv(agentEnv, o) {
73
+ const env = {};
74
+ for (const [k, v] of Object.entries(agentEnv))
75
+ if (!/^ACH_/.test(k))
76
+ env[k] = v;
77
+ if (o.realHome)
78
+ env.HOME = o.realHome;
79
+ return env;
80
+ }
81
+ /** agy as the runner starts it: ACH_ANTIGRAVITY_BIN, else `agy` (on PATH, or where its installer puts it). */
82
+ export function agyBin(env) {
83
+ return env.ACH_ANTIGRAVITY_BIN?.trim() || 'agy';
84
+ }
85
+ /** PATH with the installer's directory (~/.local/bin) added: a service's PATH often lacks it. */
86
+ export function agyPath(env, realHome) {
87
+ const local = realHome ? join(realHome, '.local', 'bin') : '';
88
+ const path = env.PATH ?? '';
89
+ return local && !path.split(':').includes(local) ? [path, local].filter(Boolean).join(':') : path;
90
+ }
91
+ /**
92
+ * Turns `--output-format stream-json` (one JSON object per line: `init`, `step_update`, `result`) into adapter events and the
93
+ * run's outcome. A tool step comes ACTIVE, then DONE or ERROR: one tool_start and one tool_end (a step seen only when it is
94
+ * over gets both). Text comes as deltas of an `agent_response` step: one text event per step. There are no thinking events.
95
+ */
96
+ export class AgyOutput {
97
+ onEvent;
98
+ sessionId;
99
+ model;
100
+ status;
101
+ runError;
102
+ denied = [];
103
+ /** usage of the conversation so far (a resumed one counts its earlier turns too) */
104
+ tokens;
105
+ buf = '';
106
+ response = '';
107
+ structured = '';
108
+ texts = new Map();
109
+ lastText = '';
110
+ open = new Set();
111
+ constructor(onEvent) {
112
+ this.onEvent = onEvent;
113
+ }
114
+ push(chunk) {
115
+ this.buf += chunk;
116
+ let i;
117
+ while ((i = this.buf.indexOf('\n')) >= 0) {
118
+ this.line(this.buf.slice(0, i));
119
+ this.buf = this.buf.slice(i + 1);
120
+ }
121
+ }
122
+ end() {
123
+ if (this.buf.trim())
124
+ this.line(this.buf);
125
+ this.buf = '';
126
+ for (const [i] of this.texts)
127
+ this.flushText(i);
128
+ }
129
+ /**
130
+ * The agent's final message: the structured output when a schema was asked for (the response can carry prose around
131
+ * it), else the result's response, else what it last said.
132
+ */
133
+ finalText() {
134
+ return (this.structured || this.response || this.lastText).trim();
135
+ }
136
+ line(raw) {
137
+ const s = raw.trim();
138
+ if (!s)
139
+ return;
140
+ let d;
141
+ try {
142
+ d = JSON.parse(s);
143
+ }
144
+ catch {
145
+ return; // not an event (a notice on stdout): stderr carries what matters
146
+ }
147
+ if (!d || typeof d !== 'object')
148
+ return;
149
+ if (d.event === 'init')
150
+ return this.session(d.conversation_id, d.init?.model);
151
+ if (d.event === 'step_update' && d.step_update)
152
+ return this.step(d.step_update);
153
+ if (d.event === 'result' && d.result)
154
+ return this.result(d.result);
155
+ }
156
+ session(id, model) {
157
+ if (modelId(model))
158
+ this.model = String(model);
159
+ if (typeof id !== 'string' || !id || this.sessionId === id)
160
+ return;
161
+ this.sessionId = id;
162
+ this.onEvent({ type: 'session', data: id });
163
+ }
164
+ step(s) {
165
+ this.session(s.conversation_id);
166
+ const i = Number(s.step_index);
167
+ if (s.step_type === 'agent_response') {
168
+ if (typeof s.text_delta === 'string')
169
+ this.texts.set(i, (this.texts.get(i) ?? '') + s.text_delta);
170
+ if (s.state !== 'ACTIVE')
171
+ this.flushText(i);
172
+ return;
173
+ }
174
+ if (s.step_type !== 'tool')
175
+ return;
176
+ const info = s.tool_info ?? {};
177
+ const id = `step-${i}`;
178
+ if (!this.open.has(i)) {
179
+ this.open.add(i);
180
+ this.onEvent({ type: 'tool_start', data: { id, name: String(info.name ?? s.tool_name ?? 'tool'), input: info.parameters ?? {} } });
181
+ }
182
+ if (s.state === 'ACTIVE')
183
+ return;
184
+ this.open.delete(i);
185
+ const err = info.error ? String(info.error.message ?? info.error.type ?? 'error') : undefined;
186
+ this.onEvent({ type: 'tool_end', data: { id, ...(err || s.state === 'ERROR' ? { is_error: true } : {}), output: String(err ?? info.output ?? '').slice(0, 20_000) } });
187
+ }
188
+ flushText(i) {
189
+ const t = (this.texts.get(i) ?? '').trim();
190
+ this.texts.delete(i);
191
+ if (!t)
192
+ return;
193
+ this.lastText = t;
194
+ this.onEvent({ type: 'text', data: t });
195
+ }
196
+ result(r) {
197
+ this.session(r.conversation_id);
198
+ this.status = typeof r.status === 'string' ? r.status : undefined;
199
+ if (typeof r.response === 'string')
200
+ this.response = r.response;
201
+ if (r.structured_output && typeof r.structured_output === 'object')
202
+ this.structured = JSON.stringify(r.structured_output);
203
+ if (typeof r.error === 'string' && r.error)
204
+ this.runError = r.error;
205
+ if (Array.isArray(r.denied_actions))
206
+ this.denied = r.denied_actions.map((a) => String(a?.action ?? a?.display_name ?? 'action'));
207
+ const u = r.usage;
208
+ if (u && typeof u === 'object') {
209
+ this.tokens = { input: Number(u.input_tokens ?? 0) + Number(u.cache_read_tokens ?? 0), output: Number(u.output_tokens ?? 0) };
210
+ this.onEvent({ type: 'usage', data: { input_tokens: this.tokens.input, output_tokens: this.tokens.output } });
211
+ }
212
+ }
213
+ }
214
+ /**
215
+ * The outcome of a finished agy process. A run is good only when the process, the status and the final message all say so:
216
+ * agy reports SUCCESS with nothing in it when an action was auto-denied, and exits 0 then. Pure.
217
+ */
218
+ export function agyOutcome(o) {
219
+ if (o.aborted)
220
+ return { ok: false, error: 'aborted' };
221
+ if (o.spawnError)
222
+ return { ok: false, error: o.spawnError };
223
+ if (/sandbox is not available/i.test(o.stderr)) {
224
+ return { ok: false, error: `Antigravity's sandbox is not available on this machine, so this run was not allowed to run commands (${AGY_SANDBOX_HINT})` };
225
+ }
226
+ if (o.out.denied.length) {
227
+ return { ok: false, error: `Antigravity stopped: it needed a permission this run does not have and nobody could approve (${[...new Set(o.out.denied)].join(', ')})` };
228
+ }
229
+ const tail = o.stderr.split('\n').map((l) => l.trim()).filter(Boolean).slice(-3).join(' | ');
230
+ if (o.out.runError)
231
+ return { ok: false, error: /authentication/i.test(o.out.runError) ? `Antigravity is not logged in on this machine (authentication required): ${o.out.runError}` : `agy: ${o.out.runError}` };
232
+ if (o.code !== 0 || (o.out.status && o.out.status !== 'SUCCESS'))
233
+ return { ok: false, error: `agy ended with ${o.out.status ?? `exit ${o.code}`}${tail ? `: ${tail}` : ''}`.slice(0, 2000) };
234
+ if (!o.finalText)
235
+ return { ok: false, error: `agy reported ${o.out.status ?? 'success'} with no final message${tail ? `: ${tail}` : ''}`.slice(0, 2000) };
236
+ return { ok: true };
237
+ }
238
+ /** `agy models` prints "<slug>\t<label>" per line (after a "Fetching..." line). Pure. */
239
+ export function agyModels(out) {
240
+ const models = out
241
+ .split('\n')
242
+ .map((l) => l.trim().split('\t'))
243
+ .filter((p) => p.length >= 2 && modelId(p[0]))
244
+ .map(([id, label]) => ({ id, ...(label && label !== id ? { label: label.slice(0, 80) } : {}) }));
245
+ return models.length ? { models } : undefined;
246
+ }
247
+ export class AntigravityAdapter {
248
+ o;
249
+ name = 'antigravity';
250
+ spec = RUNTIME_SPECS.antigravity;
251
+ constructor(o = {}) {
252
+ this.o = o;
253
+ }
254
+ async listModels(o) {
255
+ const env = { ...agyEnv(o.env, { realHome: o.realHome }) };
256
+ env.PATH = agyPath(env, o.realHome);
257
+ return new Promise((resolve, reject) => {
258
+ execFile(this.bin(), ['models'], { env, cwd: o.cwd, timeout: 30_000, maxBuffer: 1 << 20 }, (err, stdout, stderr) => {
259
+ const list = agyModels(String(stdout));
260
+ if (list)
261
+ resolve(list);
262
+ else
263
+ reject(new Error(`agy models: ${err?.message ?? String(stderr).trim().split('\n').slice(-2).join(' ') ?? 'no models listed'}`));
264
+ });
265
+ });
266
+ }
267
+ bin() {
268
+ return this.o.bin ?? agyBin(this.o.env ?? process.env);
269
+ }
270
+ run(opts) {
271
+ const model = opts.model ?? this.o.model;
272
+ const perm = agyPerm(opts.perm, opts.mode);
273
+ const out = new AgyOutput(opts.onEvent);
274
+ let stderr = '';
275
+ // a sandboxed command sees every file outside the home directory: the runner's secrets must not be among them
276
+ const exposed = perm === 'workdir' ? agyExposed(opts.denyReadPaths ?? [], opts.realHome) : [];
277
+ if (exposed.length) {
278
+ const error = `not run: Antigravity's sandbox hides only the home directory, and the runner keeps its key outside it (${exposed[0]}); keep the agent home under the home directory, or run with full access`;
279
+ opts.onEvent({ type: 'error', data: error });
280
+ return Promise.resolve({ finalText: '', ok: false, error });
281
+ }
282
+ return new Promise((resolve) => {
283
+ const env = agyEnv(opts.env, { realHome: opts.realHome });
284
+ env.PATH = agyPath(env, opts.realHome);
285
+ let done = false;
286
+ const finish = (code, spawnError) => {
287
+ if (done)
288
+ return;
289
+ done = true;
290
+ out.end();
291
+ const finalText = out.finalText();
292
+ const { ok, error } = agyOutcome({ code, out, finalText, stderr, aborted: opts.signal.aborted, spawnError });
293
+ const used = out.model ?? (modelId(model) ? model : undefined);
294
+ resolve({ finalText, sessionId: out.sessionId, ok, ...(error ? { error } : {}), ...(used ? { model: used } : {}) });
295
+ };
296
+ let child;
297
+ try {
298
+ child = spawnGroup(this.bin(), agyArgs({ prompt: opts.prompt, perm, model, effort: opts.effort, resume: opts.resume, denyReadPaths: opts.denyReadPaths, readRoots: opts.readRoots, outputSchema: opts.outputSchema }), {
299
+ cwd: opts.cwd,
300
+ env,
301
+ signal: opts.signal,
302
+ onStderr: (t) => {
303
+ stderr = (stderr + t).slice(-4000);
304
+ opts.onEvent({ type: 'error', data: t });
305
+ },
306
+ });
307
+ }
308
+ catch (e) {
309
+ finish(null, `agy: ${e?.message ?? e}`);
310
+ return;
311
+ }
312
+ child.stdin?.end();
313
+ child.stdout?.setEncoding('utf8');
314
+ child.stdout?.on('data', (d) => out.push(d));
315
+ child.on('error', (e) => finish(null, e?.code === 'ENOENT' ? `agy not found (${this.bin()}): install it (${AGY_INSTALL}) or set ACH_ANTIGRAVITY_BIN` : String(e?.message ?? e)));
316
+ child.on('close', (code) => finish(code));
317
+ });
318
+ }
319
+ }
@@ -143,6 +143,30 @@ export interface ClaudeAdapterOptions {
143
143
  export declare class ClaudeAdapter implements RuntimeAdapter {
144
144
  private o;
145
145
  readonly name = "claude";
146
+ readonly spec: {
147
+ readonly name: "claude";
148
+ readonly label: "Claude Code";
149
+ readonly where: "local";
150
+ readonly ach: true;
151
+ readonly structuredAnswers: false;
152
+ readonly perms: readonly Perm[];
153
+ readonly limits: {
154
+ readonly net: true;
155
+ readonly denyRead: true;
156
+ };
157
+ readonly reads: "scoped";
158
+ readonly budget: true;
159
+ readonly ownerMemory: "native";
160
+ readonly ownFiles: readonly [];
161
+ readonly lightModel: {
162
+ readonly model: "claude-haiku-5-5";
163
+ readonly effort: "low";
164
+ };
165
+ readonly login: {
166
+ readonly command: "claude auth login";
167
+ };
168
+ readonly check: "sandbox";
169
+ };
146
170
  constructor(o?: ClaudeAdapterOptions);
147
171
  /**
148
172
  * Run, asking for the thinking summary. The default model cannot be seen from here (Claude Code settings may select an older
@@ -1,4 +1,5 @@
1
1
  import { mkdtempSync, realpathSync, rmSync } from 'node:fs';
2
+ import { RUNTIME_SPECS } from './spec.js';
2
3
  import { homedir, tmpdir } from 'node:os';
3
4
  import { join } from 'node:path';
4
5
  import { CAPS_SERVER } from '../caps.js';
@@ -377,6 +378,7 @@ export function effortOf(input) {
377
378
  export class ClaudeAdapter {
378
379
  o;
379
380
  name = 'claude';
381
+ spec = RUNTIME_SPECS.claude;
380
382
  constructor(o = {}) {
381
383
  this.o = o;
382
384
  }
@@ -118,7 +118,30 @@ export declare function codexSessionModel(codexHome: string | undefined, threadI
118
118
  export declare class CodexAdapter implements RuntimeAdapter {
119
119
  private o;
120
120
  readonly name = "codex";
121
- readonly structuredAnswers = true;
121
+ readonly spec: {
122
+ readonly name: "codex";
123
+ readonly label: "Codex";
124
+ readonly where: "local";
125
+ readonly ach: true;
126
+ readonly structuredAnswers: true;
127
+ readonly perms: readonly Perm[];
128
+ readonly limits: {
129
+ readonly net: true;
130
+ readonly denyRead: true;
131
+ };
132
+ readonly reads: "scoped";
133
+ readonly budget: false;
134
+ readonly ownerMemory: "prompt";
135
+ readonly ownFiles: readonly ["AGENTS.md"];
136
+ readonly lightModel: {
137
+ readonly model: "gpt-6.1-sol";
138
+ readonly effort: "medium";
139
+ };
140
+ readonly login: {
141
+ readonly command: "codex login";
142
+ };
143
+ readonly check: "sandbox";
144
+ };
122
145
  constructor(o?: {
123
146
  model?: string;
124
147
  price?: PriceTable;
@@ -1,4 +1,5 @@
1
1
  import { execFileSync } from 'node:child_process';
2
+ import { RUNTIME_SPECS } from './spec.js';
2
3
  import { closeSync, existsSync, openSync, readdirSync, readSync, statSync } from 'node:fs';
3
4
  import { join } from 'node:path';
4
5
  import { readable, systemPaths } from './scope.js';
@@ -313,7 +314,7 @@ export function codexSessionModel(codexHome, threadId) {
313
314
  export class CodexAdapter {
314
315
  o;
315
316
  name = 'codex';
316
- structuredAnswers = true;
317
+ spec = RUNTIME_SPECS.codex;
317
318
  constructor(o = {}) {
318
319
  this.o = o;
319
320
  }
@@ -1,3 +1,4 @@
1
+ import type { RuntimeSpec } from './spec.js';
1
2
  import type { AdapterResult, AdapterRunOptions, RuntimeAdapter } from './types.js';
2
3
  export interface AchCallResult {
3
4
  code: number;
@@ -69,15 +70,17 @@ export interface FakeAdapterOptions {
69
70
  models?: import('./models.js').RuntimeModels;
70
71
  /** Behave like kiro: no `ach` in the run; the runner reports the final text (implies structuredAnswers). */
71
72
  remote?: boolean;
73
+ /** Any other part of the runtime's spec (a tool that cannot limit the network, one that enforces `read` only, ...). */
74
+ spec?: Partial<RuntimeSpec>;
72
75
  }
73
76
  /** Default: spawn this package's CLI with node. */
74
77
  export declare const spawnAch: AchCall;
75
78
  /** Scripted runtime for tests. Never calls a model. */
76
79
  export declare class FakeAdapter implements RuntimeAdapter {
77
80
  private o;
78
- readonly name = "fake";
79
- readonly structuredAnswers: boolean;
80
- readonly remote: boolean;
81
+ /** `fake`, or the runtime it stands in for (`spec.name`). */
82
+ readonly name: string;
83
+ readonly spec: RuntimeSpec;
81
84
  runs: FakeRunInfo[];
82
85
  achCalls: {
83
86
  args: string[];
@@ -1,4 +1,5 @@
1
1
  import { spawn } from 'node:child_process';
2
+ import { PERMS } from '../perm.js';
2
3
  import { fileURLToPath } from 'node:url';
3
4
  /** Default: spawn this package's CLI with node. */
4
5
  export const spawnAch = (args, env, cwd) => new Promise((res) => {
@@ -28,15 +29,30 @@ function sleep(ms, signal) {
28
29
  /** Scripted runtime for tests. Never calls a model. */
29
30
  export class FakeAdapter {
30
31
  o;
31
- name = 'fake';
32
- structuredAnswers;
33
- remote;
32
+ /** `fake`, or the runtime it stands in for (`spec.name`). */
33
+ name;
34
+ spec;
34
35
  runs = [];
35
36
  achCalls = [];
36
37
  constructor(o) {
37
38
  this.o = o;
38
- this.structuredAnswers = !!o.structuredAnswers || !!o.remote;
39
- this.remote = !!o.remote;
39
+ this.spec = {
40
+ name: 'fake',
41
+ label: 'Fake',
42
+ where: o.remote ? 'cloud' : 'local',
43
+ ach: !o.remote,
44
+ structuredAnswers: !!o.structuredAnswers || !!o.remote,
45
+ perms: PERMS,
46
+ limits: { net: true, denyRead: true },
47
+ reads: 'scoped',
48
+ budget: false,
49
+ ownerMemory: 'prompt',
50
+ ownFiles: [],
51
+ login: { key: 'FAKE_KEY' },
52
+ check: 'tool',
53
+ ...o.spec,
54
+ };
55
+ this.name = this.spec.name;
40
56
  }
41
57
  modelListings = 0;
42
58
  get listModels() {
@@ -1,8 +1,10 @@
1
1
  import type { RuntimeAdapter } from './types.js';
2
2
  export * from './types.js';
3
+ export * from './spec.js';
3
4
  export { ClaudeAdapter } from './claude.js';
4
5
  export { CodexAdapter } from './codex.js';
5
6
  export { KiroAdapter } from './kiro.js';
7
+ export { AntigravityAdapter } from './antigravity.js';
6
8
  export { FakeAdapter } from './fake.js';
7
9
  export * from './paths.js';
8
10
  /** The git common dir of a worktree (readable for git log/diff; never writable, S10). */
@@ -3,10 +3,14 @@ import { resolve } from 'node:path';
3
3
  import { ClaudeAdapter } from './claude.js';
4
4
  import { CodexAdapter } from './codex.js';
5
5
  import { KiroAdapter } from './kiro.js';
6
+ import { AntigravityAdapter } from './antigravity.js';
7
+ import { runtimeList } from './spec.js';
6
8
  export * from './types.js';
9
+ export * from './spec.js';
7
10
  export { ClaudeAdapter } from './claude.js';
8
11
  export { CodexAdapter } from './codex.js';
9
12
  export { KiroAdapter } from './kiro.js';
13
+ export { AntigravityAdapter } from './antigravity.js';
10
14
  export { FakeAdapter } from './fake.js';
11
15
  export * from './paths.js';
12
16
  /** The git common dir of a worktree (readable for git log/diff; never writable, S10). */
@@ -26,5 +30,7 @@ export function makeAdapter(runtime, o = {}) {
26
30
  return new CodexAdapter({ model: o.model });
27
31
  if (runtime === 'kiro')
28
32
  return new KiroAdapter({ model: o.model, env: o.env });
29
- throw new Error(`Unknown runtime "${runtime}" (use claude, codex or kiro)`);
33
+ if (runtime === 'antigravity')
34
+ return new AntigravityAdapter({ model: o.model, env: o.env });
35
+ throw new Error(`Unknown runtime "${runtime}" (use ${runtimeList()})`);
30
36
  }