@simonren/quorum 0.9.1 → 0.11.1

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 (68) hide show
  1. package/README.md +91 -48
  2. package/commands/multi-consult.md +47 -72
  3. package/commands/multi-review.md +68 -99
  4. package/dist/adapters/base.d.ts +53 -70
  5. package/dist/adapters/base.js +21 -79
  6. package/dist/adapters/claude.d.ts +38 -17
  7. package/dist/adapters/claude.js +93 -185
  8. package/dist/adapters/cli-adapter.d.ts +78 -0
  9. package/dist/adapters/cli-adapter.js +220 -0
  10. package/dist/adapters/codex.d.ts +18 -13
  11. package/dist/adapters/codex.js +64 -200
  12. package/dist/adapters/gemini.d.ts +45 -21
  13. package/dist/adapters/gemini.js +81 -152
  14. package/dist/adapters/index.d.ts +8 -5
  15. package/dist/adapters/index.js +7 -8
  16. package/dist/config.d.ts +98 -28
  17. package/dist/config.js +44 -25
  18. package/dist/consult-prompt.d.ts +6 -5
  19. package/dist/consult-prompt.js +48 -23
  20. package/dist/decoders/claude.d.ts +6 -0
  21. package/dist/decoders/claude.js +10 -1
  22. package/dist/doctor.d.ts +20 -0
  23. package/dist/doctor.js +91 -0
  24. package/dist/executor.d.ts +58 -46
  25. package/dist/executor.js +218 -129
  26. package/dist/guards.d.ts +29 -0
  27. package/dist/guards.js +72 -0
  28. package/dist/handoff.d.ts +79 -229
  29. package/dist/handoff.js +411 -402
  30. package/dist/index.d.ts +8 -12
  31. package/dist/index.js +81 -106
  32. package/dist/integrity.d.ts +16 -0
  33. package/dist/integrity.js +49 -0
  34. package/dist/sections.d.ts +22 -0
  35. package/dist/sections.js +31 -0
  36. package/dist/server.d.ts +9 -0
  37. package/dist/server.js +36 -0
  38. package/dist/tools/consult.d.ts +17 -76
  39. package/dist/tools/consult.js +72 -188
  40. package/dist/tools/format.d.ts +35 -0
  41. package/dist/tools/format.js +85 -0
  42. package/dist/tools/review.d.ts +55 -0
  43. package/dist/tools/review.js +120 -0
  44. package/dist/types.d.ts +20 -103
  45. package/dist/types.js +18 -29
  46. package/package.json +7 -4
  47. package/dist/cli/check.d.ts +0 -20
  48. package/dist/cli/check.js +0 -78
  49. package/dist/cli/codex.d.ts +0 -11
  50. package/dist/cli/codex.js +0 -255
  51. package/dist/cli/gemini.d.ts +0 -12
  52. package/dist/cli/gemini.js +0 -253
  53. package/dist/context.d.ts +0 -1538
  54. package/dist/context.js +0 -383
  55. package/dist/decoders/gemini.d.ts +0 -33
  56. package/dist/decoders/gemini.js +0 -58
  57. package/dist/errors.d.ts +0 -46
  58. package/dist/errors.js +0 -198
  59. package/dist/pipeline.d.ts +0 -135
  60. package/dist/pipeline.js +0 -462
  61. package/dist/prompt-v2.d.ts +0 -38
  62. package/dist/prompt-v2.js +0 -391
  63. package/dist/prompt.d.ts +0 -71
  64. package/dist/prompt.js +0 -309
  65. package/dist/schema.d.ts +0 -660
  66. package/dist/schema.js +0 -536
  67. package/dist/tools/feedback.d.ts +0 -91
  68. package/dist/tools/feedback.js +0 -117
@@ -1,20 +1,25 @@
1
1
  /**
2
- * Codex CLI Adapter
2
+ * Codex CLI adapter.
3
3
  *
4
- * Implements the ReviewerAdapter interface for OpenAI's Codex CLI.
5
- * Returns raw text — no JSON parsing or schema enforcement.
6
- * CC handles interpretation of the reviewer's response.
4
+ * Spawns `codex exec --json` in a read-only sandbox with the prompt on stdin
5
+ * and decodes the JSONL event stream. Because Codex is byte-silent on stdout
6
+ * for the whole of a reasoning block, liveness is proven out of band by
7
+ * watching the session rollout file (`codex-liveness.ts`).
7
8
  */
8
- import { ReviewerAdapter, ReviewerCapabilities, ReviewRequest, ReviewResult, ConsultRequest, ConsultResult } from './base.js';
9
- export declare class CodexAdapter implements ReviewerAdapter {
9
+ import { ReviewerCapabilities } from './base.js';
10
+ import { CliAdapter, CliOutcome, RunContext, RunLimits } from './cli-adapter.js';
11
+ export declare class CodexAdapter extends CliAdapter {
10
12
  readonly id = "codex";
13
+ protected readonly binary = "codex";
14
+ protected readonly installHint = "Install with: npm install -g @openai/codex-cli, then run `codex login`";
15
+ protected readonly authHint = "Run `codex login` to authenticate";
16
+ protected extraRateLimitPatterns: string[];
11
17
  getCapabilities(): ReviewerCapabilities;
12
- isAvailable(): Promise<boolean>;
13
- runReview(request: ReviewRequest): Promise<ReviewResult>;
14
- private runCli;
15
- private handleException;
16
- private categorizeError;
17
- private getSuggestion;
18
- runConsult(request: ConsultRequest): Promise<ConsultResult>;
18
+ protected getLimits(ctx: RunContext): RunLimits;
19
+ /** Request value > per-kind config default. */
20
+ private effortFor;
21
+ /** Request value > per-kind config default. Explicit 'default' emits no flag. */
22
+ private tierFor;
23
+ protected runCli(prompt: string, workingDir: string, ctx: RunContext): Promise<CliOutcome>;
19
24
  }
20
25
  export declare const codexAdapter: CodexAdapter;
@@ -1,89 +1,53 @@
1
1
  /**
2
- * Codex CLI Adapter
2
+ * Codex CLI adapter.
3
3
  *
4
- * Implements the ReviewerAdapter interface for OpenAI's Codex CLI.
5
- * Returns raw text — no JSON parsing or schema enforcement.
6
- * CC handles interpretation of the reviewer's response.
4
+ * Spawns `codex exec --json` in a read-only sandbox with the prompt on stdin
5
+ * and decodes the JSONL event stream. Because Codex is byte-silent on stdout
6
+ * for the whole of a reasoning block, liveness is proven out of band by
7
+ * watching the session rollout file (`codex-liveness.ts`).
7
8
  */
8
- import { spawn } from 'child_process';
9
- import { existsSync } from 'fs';
10
- import { registerAdapter, } from './base.js';
9
+ import { registerAdapter } from './base.js';
10
+ import { CliAdapter } from './cli-adapter.js';
11
11
  import { CliExecutor } from '../executor.js';
12
12
  import { CodexEventDecoder } from '../decoders/index.js';
13
13
  import { watchCodexThreadLiveness } from '../codex-liveness.js';
14
- import { buildSimpleHandoff, buildHandoffPrompt, buildAdversarialHandoffPrompt, selectRole, } from '../handoff.js';
15
- import { buildConsultPrompt } from '../consult-prompt.js';
16
14
  import { getConfig } from '../config.js';
17
- // =============================================================================
18
- // CODEX ADAPTER
19
- // =============================================================================
20
- export class CodexAdapter {
15
+ export class CodexAdapter extends CliAdapter {
21
16
  id = 'codex';
17
+ binary = 'codex';
18
+ installHint = 'Install with: npm install -g @openai/codex-cli, then run `codex login`';
19
+ authHint = 'Run `codex login` to authenticate';
20
+ extraRateLimitPatterns = ['usage limit', 'insufficient_quota'];
22
21
  getCapabilities() {
23
22
  return {
24
23
  name: 'Codex',
25
- description: 'OpenAI Codex - excels at correctness analysis, edge cases, and performance optimization',
26
- strengths: ['correctness', 'performance', 'security', 'testing'],
27
- weaknesses: ['documentation'],
28
- hasFilesystemAccess: true,
29
- supportsStructuredOutput: false,
30
- maxContextTokens: 128000,
31
- reasoningLevels: ['high', 'xhigh'],
24
+ description: 'OpenAI Codex CLI in a read-only sandbox; reasoning effort and service tier are configurable',
32
25
  };
33
26
  }
34
- async isAvailable() {
35
- return new Promise((resolve) => {
36
- let settled = false;
37
- const done = (result) => { if (!settled) {
38
- settled = true;
39
- clearTimeout(timer);
40
- resolve(result);
41
- } };
42
- const proc = spawn('codex', ['--version'], {
43
- stdio: ['ignore', 'pipe', 'pipe'],
44
- });
45
- proc.on('close', (code) => done(code === 0));
46
- proc.on('error', () => done(false));
47
- const timer = setTimeout(() => { proc.kill(); done(false); }, 5000);
48
- });
27
+ getLimits(ctx) {
28
+ const cfg = getConfig().codex;
29
+ const effort = this.effortFor(ctx);
30
+ return {
31
+ inactivityTimeoutMs: cfg.inactivityTimeoutMs[effort] ?? cfg.inactivityTimeoutMs.high,
32
+ maxTimeoutMs: cfg.maxTimeoutMs,
33
+ maxBufferSize: cfg.maxBufferSize,
34
+ };
49
35
  }
50
- async runReview(request) {
51
- const startTime = Date.now();
52
- if (!existsSync(request.workingDir)) {
53
- return {
54
- success: false,
55
- error: { type: 'cli_error', message: `Working directory does not exist: ${request.workingDir}` },
56
- suggestion: 'Check that the working directory path is correct',
57
- executionTimeMs: Date.now() - startTime,
58
- };
59
- }
60
- try {
61
- const handoff = buildSimpleHandoff(request.workingDir, request.ccOutput, request.analyzedFiles, request.focusAreas, request.customPrompt);
62
- const prompt = request.reviewMode === 'adversarial'
63
- ? buildAdversarialHandoffPrompt({ handoff })
64
- : buildHandoffPrompt({ handoff, role: selectRole(request.focusAreas) });
65
- const cfg = getConfig().codex;
66
- const result = await this.runCli(prompt, request.workingDir, request.reasoningEffort ?? cfg.reasoningEffort, request.serviceTier);
67
- if (result.exitCode !== 0) {
68
- const error = this.categorizeError(result.stderr);
69
- return { success: false, error, suggestion: this.getSuggestion(error), executionTimeMs: Date.now() - startTime };
70
- }
71
- if (!result.stdout.trim()) {
72
- return {
73
- success: false,
74
- error: { type: 'cli_error', message: 'Codex returned empty response' },
75
- suggestion: 'Try again or use /multi-review instead',
76
- executionTimeMs: Date.now() - startTime,
77
- };
78
- }
79
- return { success: true, output: result.stdout, executionTimeMs: Date.now() - startTime };
80
- }
81
- catch (error) {
82
- return this.handleException(error, startTime);
83
- }
36
+ /** Request value > per-kind config default. */
37
+ effortFor(ctx) {
38
+ const cfg = getConfig().codex;
39
+ return ctx.reasoningEffort ?? (ctx.kind === 'consult' ? cfg.consultReasoningEffort : cfg.reasoningEffort);
40
+ }
41
+ /** Request value > per-kind config default. Explicit 'default' emits no flag. */
42
+ tierFor(ctx) {
43
+ const cfg = getConfig().codex;
44
+ return ctx.serviceTier ?? (ctx.kind === 'consult' ? cfg.consultServiceTier : cfg.serviceTier);
84
45
  }
85
- async runCli(prompt, workingDir, reasoningEffort, serviceTier) {
46
+ async runCli(prompt, workingDir, ctx) {
86
47
  const cfg = getConfig().codex;
48
+ const reasoningEffort = this.effortFor(ctx);
49
+ const effectiveTier = this.tierFor(ctx);
50
+ const limits = this.getLimits(ctx);
87
51
  const args = [
88
52
  'exec',
89
53
  '--json', // JSONL streaming events
@@ -93,43 +57,38 @@ export class CodexAdapter {
93
57
  '--sandbox', 'read-only',
94
58
  '--skip-git-repo-check',
95
59
  '-C', workingDir,
96
- '-', // Read prompt from stdin
60
+ '-', // prompt on stdin
97
61
  ];
98
- // Caller-supplied serviceTier overrides config. Explicit 'default' is an
99
- // opt-out and emits no flag (uses Codex API default).
100
- const effectiveTier = serviceTier ?? cfg.serviceTier;
101
62
  if (effectiveTier !== 'default') {
102
63
  args.push('-c', `service_tier=${effectiveTier}`);
103
64
  }
104
65
  const decoder = new CodexEventDecoder();
105
66
  const cliStartTime = Date.now();
106
67
  const tierLabel = effectiveTier !== 'default' ? ` [${effectiveTier}]` : '';
107
- console.error(`[codex] Running with ${reasoningEffort} reasoning${tierLabel}...`);
68
+ console.error(`[codex] Running ${ctx.kind} with ${reasoningEffort} reasoning${tierLabel}...`);
108
69
  decoder.onProgress = (eventType, detail) => {
109
70
  const elapsed = Math.round((Date.now() - cliStartTime) / 1000);
110
- const detailStr = detail ? ` — ${detail}` : '';
111
- console.error(`[codex] ${eventType}${detailStr} (${elapsed}s)`);
71
+ console.error(`[codex] ${eventType}${detail ? ` — ${detail}` : ''} (${elapsed}s)`);
112
72
  };
113
- // `codex exec --json` stays byte-silent for the whole of a reasoning block
114
- // — minutes at a time on xhigh — so stdout alone cannot distinguish
115
- // "thinking hard" from "hung", and the inactivity timer kills healthy runs
116
- // mid-thought. Codex keeps appending reasoning summaries to its session
117
- // rollout file throughout, so watch that file and treat growth as liveness.
118
- // The watcher is best-effort: if the rollout file cannot be found we simply
119
- // fall back to the stdout-only behaviour.
73
+ // Liveness: Codex keeps appending reasoning summaries to its rollout file
74
+ // while stdout is silent. Growth of that file resets the inactivity timer.
75
+ // Best-effort — if the file cannot be found we fall back to stdout-only.
120
76
  let stopLiveness;
77
+ // Set once the run has settled so a late line can never start a watcher
78
+ // after the `.finally` below has already had its only chance to stop it.
79
+ let disposed = false;
121
80
  const executor = new CliExecutor({
122
- command: 'codex',
81
+ command: this.binary,
123
82
  args,
124
83
  cwd: workingDir,
125
84
  stdin: prompt,
126
- inactivityTimeoutMs: cfg.inactivityTimeoutMs[reasoningEffort] ?? cfg.inactivityTimeoutMs.high,
127
- maxTimeoutMs: cfg.maxTimeoutMs,
128
- maxBufferSize: cfg.maxBufferSize,
85
+ inactivityTimeoutMs: limits.inactivityTimeoutMs,
86
+ maxTimeoutMs: limits.maxTimeoutMs,
87
+ maxBufferSize: limits.maxBufferSize,
129
88
  onLine: (line) => {
130
89
  decoder.processLine(line);
131
90
  const threadId = decoder.getThreadId();
132
- if (stopLiveness === undefined && threadId !== null) {
91
+ if (!disposed && stopLiveness === undefined && threadId !== null) {
133
92
  stopLiveness = watchCodexThreadLiveness({
134
93
  threadId,
135
94
  onActivity: () => executor.noteActivity(),
@@ -137,126 +96,31 @@ export class CodexAdapter {
137
96
  }
138
97
  },
139
98
  });
140
- // `.finally` rather than a try/finally so a TIMEOUT/MAX_TIMEOUT rejection
141
- // still tears the watcher down before it propagates.
142
- const result = await executor.run().finally(() => stopLiveness?.());
143
- const elapsed = Math.round((Date.now() - cliStartTime) / 1000);
144
- console.error(`[codex] ✓ complete (${elapsed}s)`);
145
- // A genuine fatal error (a top-level `error` event or `turn.failed`) is
146
- // TERMINAL and wins even when a — possibly intermediate/stale — agent_message
147
- // exists. `codex exec` runs a multi-turn agent loop, so a turn can emit a
148
- // message and a later turn can fail; without this check, that failure would
149
- // be reported as a successful review with stale content.
99
+ // `.finally` so a TIMEOUT/MAX_TIMEOUT rejection still tears the watcher down.
100
+ const result = await executor.run().finally(() => { disposed = true; stopLiveness?.(); });
101
+ console.error(`[codex] ✓ complete (${Math.round((Date.now() - cliStartTime) / 1000)}s)`);
102
+ // A fatal error (top-level `error` or `turn.failed`) is terminal and wins
103
+ // even when a — possibly intermediate/stale — agent_message exists: `codex
104
+ // exec` runs a multi-turn loop, so a turn can emit a message and a later
105
+ // turn can fail.
150
106
  const fatalError = decoder.getFatalError();
151
107
  if (fatalError) {
152
- const combined = result.stderr ? `${fatalError}\n\nCLI stderr: ${result.stderr}` : fatalError;
153
- return { stdout: '', stderr: combined, exitCode: 1, truncated: false };
108
+ return { stdout: '', stderr: this.combineDiagnostics(fatalError, result.stderr), exitCode: 1, truncated: false };
154
109
  }
155
- // No fatal error: a completed response wins even if a NON-fatal error-item
156
- // appeared earlier. Codex emits its "Skill descriptions were shortened to fit
157
- // the 2% skills context budget" notice as an item.completed/type:error event —
158
- // purely informational ("Codex can still see every skill"); the turn still
159
- // completes and produces an agent_message. Use `!== null` (not truthiness) so
160
- // an empty-string response is preserved for the caller's empty-response
161
- // handling rather than misclassified as "no result event".
162
- // (Checking getError() first discarded otherwise-successful reviews.)
110
+ // No fatal error: a completed response wins even if a NON-fatal item-level
111
+ // error appeared earlier (e.g. the informational "skills shortened" notice).
112
+ // `!== null` so an empty-string response reaches empty-response handling.
163
113
  const finalResponse = decoder.getFinalResponse();
164
114
  if (finalResponse !== null) {
165
- return {
166
- stdout: finalResponse,
167
- stderr: result.stderr,
168
- exitCode: result.exitCode,
169
- truncated: result.truncated,
170
- };
115
+ return { stdout: finalResponse, stderr: result.stderr, exitCode: result.exitCode, truncated: result.truncated };
171
116
  }
172
- // No response: surface a non-fatal item-level error if one was captured.
173
117
  const decoderError = decoder.getError();
174
118
  if (decoderError) {
175
- const combined = result.stderr ? `${decoderError}\n\nCLI stderr: ${result.stderr}` : decoderError;
176
- return { stdout: '', stderr: combined, exitCode: 1, truncated: false };
177
- }
178
- if (decoder.hasNoOutput()) {
179
- const combined = result.stderr ? `No output from Codex\n\nCLI stderr: ${result.stderr}` : 'No output from Codex';
180
- return { stdout: '', stderr: combined, exitCode: 1, truncated: false };
181
- }
182
- const combined = result.stderr ? `No result event from Codex\n\nCLI stderr: ${result.stderr}` : 'No result event from Codex';
183
- return { stdout: '', stderr: combined, exitCode: 1, truncated: false };
184
- }
185
- handleException(error, startTime) {
186
- const err = error;
187
- if (err.code === 'ENOENT') {
188
- return { success: false, error: { type: 'cli_not_found', message: 'Codex CLI not found' },
189
- suggestion: 'Install with: npm install -g @openai/codex-cli', executionTimeMs: Date.now() - startTime };
190
- }
191
- if (err.message === 'TIMEOUT') {
192
- return { success: false, error: { type: 'timeout', message: 'Codex timed out — no events received' },
193
- suggestion: 'Try a smaller scope or use /multi-review', executionTimeMs: Date.now() - startTime };
194
- }
195
- if (err.message === 'MAX_TIMEOUT') {
196
- return { success: false, error: { type: 'timeout', message: 'Task exceeded 60 minute maximum' },
197
- suggestion: 'Try a smaller scope', executionTimeMs: Date.now() - startTime };
198
- }
199
- return { success: false, error: { type: 'cli_error', message: err.message }, executionTimeMs: Date.now() - startTime };
200
- }
201
- categorizeError(stderr) {
202
- const lower = stderr.toLowerCase();
203
- if (lower.includes('rate limit') || lower.includes('rate_limit')) {
204
- return { type: 'rate_limit', message: `Codex rate limit: ${stderr.slice(0, 500)}` };
205
- }
206
- if (lower.includes('unauthorized') || lower.includes('authentication') || stderr.includes('401') || stderr.includes('403')) {
207
- return { type: 'auth_error', message: `Authentication failed: ${stderr.slice(0, 500)}`, details: { stderr } };
208
- }
209
- if (lower.includes('invalid_json_schema') || lower.includes('invalid_request_error')) {
210
- return { type: 'cli_error', message: `API error: ${stderr.slice(0, 500)}` };
211
- }
212
- return { type: 'cli_error', message: stderr.slice(0, 500) || 'Unknown error' };
213
- }
214
- getSuggestion(error) {
215
- switch (error.type) {
216
- case 'rate_limit': return 'Wait and retry, or use /multi-review instead';
217
- case 'auth_error': return 'Run `codex login` to authenticate';
218
- case 'cli_not_found': return 'Install with: npm install -g @openai/codex-cli';
219
- default: return 'Check the error message and try again';
220
- }
221
- }
222
- async runConsult(request) {
223
- const startTime = Date.now();
224
- if (!existsSync(request.workingDir)) {
225
- return {
226
- success: false,
227
- error: { type: 'cli_error', message: `Working directory does not exist: ${request.workingDir}` },
228
- suggestion: 'Check that the working directory path is correct',
229
- executionTimeMs: Date.now() - startTime,
230
- };
231
- }
232
- try {
233
- const prompt = buildConsultPrompt(request);
234
- // Consult-specific defaults live in config (Zod defaults to xhigh + fast).
235
- // Request value > config value > Zod default. Users who want to cap cost
236
- // can set codex.consultServiceTier: "flex" without touching review.
237
- const cfg = getConfig().codex;
238
- const reasoningEffort = request.reasoningEffort ?? cfg.consultReasoningEffort;
239
- const serviceTier = request.serviceTier ?? cfg.consultServiceTier;
240
- const result = await this.runCli(prompt, request.workingDir, reasoningEffort, serviceTier);
241
- if (result.exitCode !== 0) {
242
- const error = this.categorizeError(result.stderr);
243
- return { success: false, error, suggestion: this.getSuggestion(error), executionTimeMs: Date.now() - startTime };
244
- }
245
- if (!result.stdout.trim()) {
246
- return {
247
- success: false,
248
- error: { type: 'cli_error', message: 'Codex returned empty response' },
249
- suggestion: 'Try again or use /multi-review instead',
250
- executionTimeMs: Date.now() - startTime,
251
- };
252
- }
253
- return { success: true, output: result.stdout, executionTimeMs: Date.now() - startTime };
254
- }
255
- catch (error) {
256
- return this.handleException(error, startTime);
119
+ return { stdout: '', stderr: this.combineDiagnostics(decoderError, result.stderr), exitCode: 1, truncated: false };
257
120
  }
121
+ const reason = decoder.hasNoOutput() ? 'No output from Codex' : 'No result event from Codex';
122
+ return { stdout: '', stderr: this.combineDiagnostics(reason, result.stderr), exitCode: 1, truncated: false };
258
123
  }
259
124
  }
260
- // Register the adapter
261
- registerAdapter(new CodexAdapter());
262
125
  export const codexAdapter = new CodexAdapter();
126
+ registerAdapter(codexAdapter);
@@ -1,29 +1,53 @@
1
1
  /**
2
- * Gemini Adapter (via Antigravity CLI `agy`)
2
+ * Gemini adapter (via the Antigravity CLI, `agy`).
3
3
  *
4
- * Google replaced `gemini-cli` with the Antigravity CLI (`agy`) at I/O 2026.
5
- * The free-tier `gemini` binary stops serving requests on 2026-06-18, so this
6
- * adapter now spawns `agy --print` with the prompt on stdin. The model is still
7
- * Gemini under the hood — only the CLI brand changed — so the adapter id and
8
- * config key remain `gemini`.
4
+ * Google replaced `gemini-cli` with the Antigravity CLI at I/O 2026; the
5
+ * free-tier `gemini` binary stopped serving requests on 2026-06-18. The model
6
+ * is still Gemini, so the adapter id and config key remain `gemini`.
9
7
  *
10
- * Differences from the old gemini-cli adapter:
11
- * - No `--output-format stream-json` → no live progress events
12
- * - `--model` is optional → set `gemini.model` in the quorum config to
13
- * override agy's own settings (`agy models` lists valid ids)
14
- * - `--include-directories` → `--add-dir`
15
- * - `--approval-mode plan` → folded into `--sandbox`
8
+ * agy specifics:
9
+ * - the prompt must be the positional after `--print` (stdin alone makes agy
10
+ * print --help and exit 0), so the prompt size is bounded by the OS argv
11
+ * limit — see MAX_ARGV_PROMPT_BYTES
12
+ * - no streaming output, so the inactivity timeout is a total-runtime cap;
13
+ * agy has its own print-mode timeout (default 5m) which is set to match
14
+ * - `--sandbox` restricts the terminal only. agy's file tools CAN still write
15
+ * to the workspace (verified with `--sandbox` and with `--mode plan`), and
16
+ * agy has no read-only switch, so the tool handlers fingerprint the working
17
+ * tree before and after every run and flag any change (`integrity.ts`)
18
+ * - `--add-dir` scopes reads; `--model` is optional (`gemini.model`)
19
+ * - every print run does a silent OAuth handshake (keyring token, a few round
20
+ * trips to cloudcode-pa.googleapis.com, then an eligibility check that
21
+ * fetches the profile picture from lh3.googleusercontent.com) before the
22
+ * prompt is sent. On a slow route it fails with "authentication failed or
23
+ * timed out" (~10s) or "Eligibility check failed … TLS handshake timeout"
24
+ * (~50s) even though the login is fine — see the retry below
16
25
  */
17
- import { ReviewerAdapter, ReviewerCapabilities, ReviewRequest, ReviewResult, ConsultRequest, ConsultResult } from './base.js';
18
- export declare class GeminiAdapter implements ReviewerAdapter {
26
+ import { ReviewerCapabilities } from './base.js';
27
+ import { CliAdapter, CliOutcome, RunContext, RunLimits } from './cli-adapter.js';
28
+ /**
29
+ * Linux caps a single argv string at 128 KiB (MAX_ARG_STRLEN); macOS caps the
30
+ * whole argv+env block. A prompt beyond this would make spawn fail with E2BIG,
31
+ * so refuse early with a message that says what to shrink.
32
+ */
33
+ export declare const MAX_ARGV_PROMPT_BYTES = 120000;
34
+ /**
35
+ * A handshake failure surfaces within ~60s (startup, the ~10s auth deadline,
36
+ * then up to two 10s TLS attempts for the eligibility check). An auth error
37
+ * after this window came from a run that had already started reviewing, and
38
+ * re-running that would double the cost, not fix the login.
39
+ */
40
+ export declare const AUTH_RETRY_WINDOW_MS = 90000;
41
+ export declare class GeminiAdapter extends CliAdapter {
19
42
  readonly id = "gemini";
43
+ protected readonly binary = "agy";
44
+ protected readonly installHint = "Install with: curl -fsSL https://antigravity.google/cli/install.sh | bash, then run `agy` and complete the Google OAuth sign-in";
45
+ protected readonly authHint = "Run `agy` and complete the Google OAuth sign-in. If `agy` already works by hand, its pre-prompt handshake with Google timed out: retry, and check the route to *.googleapis.com and lh3.googleusercontent.com";
46
+ protected extraRateLimitPatterns: string[];
47
+ /** agy's account-eligibility check runs before the prompt; its failure is a login-stage problem, not a slow review. */
48
+ protected extraAuthPatterns: string[];
20
49
  getCapabilities(): ReviewerCapabilities;
21
- isAvailable(): Promise<boolean>;
22
- runReview(request: ReviewRequest): Promise<ReviewResult>;
23
- private runCli;
24
- private handleException;
25
- private categorizeError;
26
- private getSuggestion;
27
- runConsult(request: ConsultRequest): Promise<ConsultResult>;
50
+ protected getLimits(): RunLimits;
51
+ protected runCli(prompt: string, workingDir: string, ctx: RunContext): Promise<CliOutcome>;
28
52
  }
29
53
  export declare const geminiAdapter: GeminiAdapter;