@simonren/quorum 0.11.0 → 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.
@@ -143,6 +143,16 @@ export class CliAdapter {
143
143
  // A bare number is not a status: `file.ts:403:5` in a stack trace must not
144
144
  // read as HTTP 403. Require a status-ish word within a few characters.
145
145
  const httpStatus = (codes) => new RegExp(`\\b(?:http|status|code|error|response)\\b[^\\n\\d]{0,20}\\b(?:${codes})\\b`, 'i').test(stderr);
146
+ // Auth before timeout: agy reports a failed OAuth handshake as
147
+ // "authentication failed or timed out", which is a login problem, not a
148
+ // slow review, and must not be answered with "raise inactivityTimeoutMs".
149
+ const auth = [
150
+ 'unauthorized', 'forbidden', 'authentication', 'not logged in', 'not authenticated', 'invalid api key', 'invalid_api_key',
151
+ 'missing api key', 'token expired', 'please log in', 'please login', 'please run /login', ...this.extraAuthPatterns,
152
+ ];
153
+ if (has(auth) || httpStatus('401|403')) {
154
+ return { type: 'auth_error', message: `Authentication failed: ${excerpt}`, details: { stderr } };
155
+ }
146
156
  if (/\btimed? ?out\b/i.test(stderr)) {
147
157
  return { type: 'timeout', message: `${this.getCapabilities().name} reported a timeout: ${excerpt}` };
148
158
  }
@@ -153,13 +163,6 @@ export class CliAdapter {
153
163
  if (has(rateLimit) || httpStatus('429')) {
154
164
  return { type: 'rate_limit', message: `${this.getCapabilities().name} rate limit or quota: ${excerpt}` };
155
165
  }
156
- const auth = [
157
- 'unauthorized', 'forbidden', 'authentication', 'not logged in', 'not authenticated', 'invalid api key', 'invalid_api_key',
158
- 'missing api key', 'token expired', 'please log in', 'please login', 'please run /login', ...this.extraAuthPatterns,
159
- ];
160
- if (has(auth) || httpStatus('401|403')) {
161
- return { type: 'auth_error', message: `Authentication failed: ${excerpt}`, details: { stderr } };
162
- }
163
166
  return { type: 'cli_error', message: excerpt || 'Unknown error' };
164
167
  }
165
168
  getSuggestion(error) {
@@ -16,6 +16,12 @@
16
16
  * agy has no read-only switch, so the tool handlers fingerprint the working
17
17
  * tree before and after every run and flag any change (`integrity.ts`)
18
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
19
25
  */
20
26
  import { ReviewerCapabilities } from './base.js';
21
27
  import { CliAdapter, CliOutcome, RunContext, RunLimits } from './cli-adapter.js';
@@ -25,12 +31,21 @@ import { CliAdapter, CliOutcome, RunContext, RunLimits } from './cli-adapter.js'
25
31
  * so refuse early with a message that says what to shrink.
26
32
  */
27
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;
28
41
  export declare class GeminiAdapter extends CliAdapter {
29
42
  readonly id = "gemini";
30
43
  protected readonly binary = "agy";
31
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";
32
- protected readonly authHint = "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";
33
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[];
34
49
  getCapabilities(): ReviewerCapabilities;
35
50
  protected getLimits(): RunLimits;
36
51
  protected runCli(prompt: string, workingDir: string, ctx: RunContext): Promise<CliOutcome>;
@@ -16,6 +16,12 @@
16
16
  * agy has no read-only switch, so the tool handlers fingerprint the working
17
17
  * tree before and after every run and flag any change (`integrity.ts`)
18
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
19
25
  */
20
26
  import { registerAdapter } from './base.js';
21
27
  import { CliAdapter } from './cli-adapter.js';
@@ -28,12 +34,23 @@ const AGY_INSTALL_CMD = 'curl -fsSL https://antigravity.google/cli/install.sh |
28
34
  * so refuse early with a message that says what to shrink.
29
35
  */
30
36
  export const MAX_ARGV_PROMPT_BYTES = 120_000;
37
+ /** stderr of an agy run that died in the pre-prompt handshake. */
38
+ const AUTH_HANDSHAKE_FAILURE = /authentication (?:failed or timed out|required)|eligibility check failed/i;
39
+ /**
40
+ * A handshake failure surfaces within ~60s (startup, the ~10s auth deadline,
41
+ * then up to two 10s TLS attempts for the eligibility check). An auth error
42
+ * after this window came from a run that had already started reviewing, and
43
+ * re-running that would double the cost, not fix the login.
44
+ */
45
+ export const AUTH_RETRY_WINDOW_MS = 90_000;
31
46
  export class GeminiAdapter extends CliAdapter {
32
47
  id = 'gemini';
33
48
  binary = 'agy';
34
49
  installHint = `Install with: ${AGY_INSTALL_CMD}, then run \`agy\` and complete the Google OAuth sign-in`;
35
- authHint = 'Run `agy` and complete the Google OAuth sign-in';
50
+ 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';
36
51
  extraRateLimitPatterns = ['resource exhausted', 'resource_exhausted'];
52
+ /** agy's account-eligibility check runs before the prompt; its failure is a login-stage problem, not a slow review. */
53
+ extraAuthPatterns = ['eligibility check failed'];
37
54
  getCapabilities() {
38
55
  return {
39
56
  name: 'Gemini',
@@ -70,17 +87,23 @@ export class GeminiAdapter extends CliAdapter {
70
87
  '--print', prompt,
71
88
  ];
72
89
  const cliStartTime = Date.now();
90
+ const seconds = () => Math.round((Date.now() - cliStartTime) / 1000);
73
91
  console.error(`[gemini] Running ${ctx.kind} via agy${cfg.model ? ` (${cfg.model})` : ''}...`);
74
- const executor = new CliExecutor({
92
+ const runOnce = () => new CliExecutor({
75
93
  command: this.binary,
76
94
  args,
77
95
  cwd: workingDir,
78
96
  inactivityTimeoutMs: limits.inactivityTimeoutMs,
79
97
  maxTimeoutMs: limits.maxTimeoutMs,
80
98
  maxBufferSize: limits.maxBufferSize,
81
- });
82
- const result = await executor.run();
83
- console.error(`[gemini] ✓ complete (${Math.round((Date.now() - cliStartTime) / 1000)}s)`);
99
+ }).run();
100
+ let result = await runOnce();
101
+ if (result.exitCode !== 0 && Date.now() - cliStartTime < AUTH_RETRY_WINDOW_MS && AUTH_HANDSHAKE_FAILURE.test(result.stderr)) {
102
+ // The handshake is transient (slow network to Google), one retry usually lands.
103
+ console.error(`[gemini] agy auth handshake failed after ${seconds()}s; retrying once`);
104
+ result = await runOnce();
105
+ }
106
+ console.error(`[gemini] ✓ complete (${seconds()}s)`);
84
107
  return {
85
108
  stdout: result.rawStdout,
86
109
  stderr: result.stderr,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simonren/quorum",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "description": "MCP server for Claude Code — a quorum of AI models (Codex, Gemini, Claude Fable with fresh context) for standard + adversarial review and consultation, synthesized by Claude Code",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",