@andorra-labs/code 0.1.5 → 0.1.6

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 (164) hide show
  1. package/dist/src/account-presentation.js +3 -3
  2. package/dist/src/agent-execution.d.ts +2 -0
  3. package/dist/src/agent-execution.js +126 -20
  4. package/dist/src/agent-mcp.d.ts +18 -1
  5. package/dist/src/agent-mcp.js +103 -8
  6. package/dist/src/app-server/protocol.d.ts +33 -3
  7. package/dist/src/app-server/protocol.js +14 -1
  8. package/dist/src/app-server/workspace.d.ts +1 -0
  9. package/dist/src/app-server/workspace.js +7 -1
  10. package/dist/src/app-server.d.ts +115 -41
  11. package/dist/src/app-server.js +1229 -219
  12. package/dist/src/automation-runner.d.ts +9 -0
  13. package/dist/src/automation-runner.js +22 -1
  14. package/dist/src/automation-tool.js +8 -1
  15. package/dist/src/automations.js +1 -1
  16. package/dist/src/browser-captcha-tool.d.ts +54 -0
  17. package/dist/src/browser-captcha-tool.js +374 -0
  18. package/dist/src/browser-panel-tool.d.ts +7 -0
  19. package/dist/src/browser-panel-tool.js +74 -3
  20. package/dist/src/browser-runner.js +19 -4
  21. package/dist/src/browser-server.js +21 -1
  22. package/dist/src/browser-session.d.ts +16 -0
  23. package/dist/src/browser-session.js +35 -0
  24. package/dist/src/browser-ui/app.js +193 -3
  25. package/dist/src/browser-ui/style.css +15 -1
  26. package/dist/src/browser-view.d.ts +72 -4
  27. package/dist/src/browser-view.js +229 -17
  28. package/dist/src/capabilities.js +13 -2
  29. package/dist/src/capsolver.d.ts +60 -0
  30. package/dist/src/capsolver.js +101 -0
  31. package/dist/src/claude-provider.d.ts +6 -0
  32. package/dist/src/claude-provider.js +34 -3
  33. package/dist/src/cli-executable.d.ts +33 -0
  34. package/dist/src/cli-executable.js +64 -0
  35. package/dist/src/cli-process.d.ts +47 -0
  36. package/dist/src/cli-process.js +113 -0
  37. package/dist/src/cli-sign-in.d.ts +68 -0
  38. package/dist/src/cli-sign-in.js +224 -0
  39. package/dist/src/cli.js +53 -22
  40. package/dist/src/code-intelligence/CodeIntelligenceManager.d.ts +1 -1
  41. package/dist/src/code-intelligence/CodeIntelligenceManager.js +5 -5
  42. package/dist/src/coding-tools.js +44 -5
  43. package/dist/src/command-output-tap.d.ts +16 -0
  44. package/dist/src/command-output-tap.js +45 -0
  45. package/dist/src/command-screens.js +3 -3
  46. package/dist/src/commands.d.ts +10 -1
  47. package/dist/src/commands.js +7 -7
  48. package/dist/src/completion.d.ts +23 -5
  49. package/dist/src/completion.js +334 -17
  50. package/dist/src/config.d.ts +13 -0
  51. package/dist/src/config.js +28 -2
  52. package/dist/src/deadline.js +6 -0
  53. package/dist/src/extensions.d.ts +1 -0
  54. package/dist/src/extensions.js +16 -3
  55. package/dist/src/graph-provider-portability.js +2 -2
  56. package/dist/src/graph-quota.d.ts +1 -1
  57. package/dist/src/graph-quota.js +1 -1
  58. package/dist/src/graph-runner.js +35 -21
  59. package/dist/src/graph-selection.d.ts +6 -0
  60. package/dist/src/graph-selection.js +10 -0
  61. package/dist/src/graph-server.d.ts +7 -0
  62. package/dist/src/graph-server.js +61 -3
  63. package/dist/src/graph-sync.d.ts +50 -0
  64. package/dist/src/graph-sync.js +383 -12
  65. package/dist/src/graph-ui/app.js +61 -8
  66. package/dist/src/graph-ui/icons.js +1 -0
  67. package/dist/src/graph-ui/index.html +1 -1
  68. package/dist/src/graph-ui/skill-picker.js +242 -0
  69. package/dist/src/graph-ui/style.css +19 -0
  70. package/dist/src/graphs.d.ts +46 -4
  71. package/dist/src/graphs.js +152 -27
  72. package/dist/src/grok-provider.d.ts +50 -0
  73. package/dist/src/grok-provider.js +186 -0
  74. package/dist/src/handoffs.d.ts +13 -0
  75. package/dist/src/handoffs.js +31 -1
  76. package/dist/src/managed-sign-in.d.ts +38 -0
  77. package/dist/src/managed-sign-in.js +169 -0
  78. package/dist/src/markdown.d.ts +5 -0
  79. package/dist/src/markdown.js +5 -2
  80. package/dist/src/mcp.js +11 -0
  81. package/dist/src/membership.d.ts +8 -1
  82. package/dist/src/membership.js +15 -5
  83. package/dist/src/model-metadata.js +14 -2
  84. package/dist/src/model-override.d.ts +10 -0
  85. package/dist/src/model-override.js +20 -0
  86. package/dist/src/opencode-cli-provider.d.ts +122 -0
  87. package/dist/src/opencode-cli-provider.js +415 -0
  88. package/dist/src/opencode-provider.js +23 -8
  89. package/dist/src/palette.d.ts +2 -0
  90. package/dist/src/palette.js +2 -0
  91. package/dist/src/permissions.d.ts +19 -1
  92. package/dist/src/permissions.js +30 -1
  93. package/dist/src/powershell-pool.d.ts +2 -2
  94. package/dist/src/powershell-pool.js +18 -5
  95. package/dist/src/provider-connection.js +36 -0
  96. package/dist/src/provider-engine.d.ts +2 -1
  97. package/dist/src/provider-engine.js +64 -13
  98. package/dist/src/provider-import.js +6 -1
  99. package/dist/src/provider-settings.js +22 -3
  100. package/dist/src/providers.d.ts +12 -1
  101. package/dist/src/providers.js +27 -8
  102. package/dist/src/pull-requests.d.ts +111 -17
  103. package/dist/src/pull-requests.js +308 -76
  104. package/dist/src/qa/qa-authorize.js +9 -1
  105. package/dist/src/react-runtime.js +76 -5
  106. package/dist/src/remote/engine-pool.js +1 -1
  107. package/dist/src/run-progress.js +6 -1
  108. package/dist/src/run-records.d.ts +133 -27
  109. package/dist/src/run-records.js +320 -40
  110. package/dist/src/runtime.d.ts +38 -1
  111. package/dist/src/runtime.js +27 -4
  112. package/dist/src/save-lock.d.ts +11 -0
  113. package/dist/src/save-lock.js +29 -2
  114. package/dist/src/sessions.js +4 -1
  115. package/dist/src/shell.js +4 -1
  116. package/dist/src/side-panel.d.ts +1 -1
  117. package/dist/src/side-panel.js +1 -1
  118. package/dist/src/skill-commands.d.ts +2 -0
  119. package/dist/src/skill-commands.js +2 -0
  120. package/dist/src/skills/bundled/create-agent/SKILL.md +81 -0
  121. package/dist/src/skills/bundled/create-skill/SKILL.md +81 -0
  122. package/dist/src/skills/bundled/doctor/SKILL.md +43 -0
  123. package/dist/src/skills/bundled/graph-manager/SKILL.md +97 -0
  124. package/dist/src/skills/bundled/graph-manager/errors.md +38 -0
  125. package/dist/src/skills/bundled/graph-manager/patterns.md +78 -0
  126. package/dist/src/skills/bundled/manage-mcp/SKILL.md +75 -0
  127. package/dist/src/skills/bundled/manage-mcp/probe.md +165 -0
  128. package/dist/src/skills/bundled/manage-skills/SKILL.md +67 -0
  129. package/dist/src/skills/bundled/provenance.json +50 -0
  130. package/dist/src/skills/bundled/write-instructions/SKILL.md +42 -0
  131. package/dist/src/skills/invocable-skills.d.ts +41 -0
  132. package/dist/src/skills/invocable-skills.js +49 -0
  133. package/dist/src/skills/prompt-skills.d.ts +1 -0
  134. package/dist/src/skills/prompt-skills.js +33 -0
  135. package/dist/src/skills/runtime-skills.d.ts +4 -0
  136. package/dist/src/skills/runtime-skills.js +21 -0
  137. package/dist/src/structured-step.d.ts +55 -0
  138. package/dist/src/structured-step.js +85 -0
  139. package/dist/src/subagent-run.d.ts +1 -1
  140. package/dist/src/subagent-run.js +29 -33
  141. package/dist/src/telemetry/schema.d.ts +2 -2
  142. package/dist/src/telemetry/schema.js +3 -2
  143. package/dist/src/terminal-ui.d.ts +29 -0
  144. package/dist/src/terminal-ui.js +112 -28
  145. package/dist/src/timers.d.ts +21 -2
  146. package/dist/src/timers.js +12 -4
  147. package/dist/src/tool-names.d.ts +18 -0
  148. package/dist/src/tool-names.js +26 -0
  149. package/dist/src/tools.js +45 -11
  150. package/dist/src/trajectory.js +32 -12
  151. package/dist/src/types.d.ts +23 -0
  152. package/docs/agents/mcp-server.md +13 -1
  153. package/docs/agents/subagent-mode.md +7 -4
  154. package/docs/concepts/security.md +2 -0
  155. package/docs/getting-started/configure-providers.md +29 -2
  156. package/docs/guides/browser.md +12 -0
  157. package/docs/guides/desktop-app.md +10 -3
  158. package/docs/guides/graph-builder.md +8 -0
  159. package/docs/reference/config.md +2 -2
  160. package/docs/superpowers/plans/2026-11-06-graph-soft-delete.md +125 -0
  161. package/docs/superpowers/specs/2026-11-01-pr-section-design.md +7 -0
  162. package/docs/superpowers/specs/2026-11-06-bundled-skills-design.md +206 -0
  163. package/package.json +1 -1
  164. package/tests/permissions-test-plan.md +2 -1
@@ -3,9 +3,25 @@ import { COMPLETION_TOOL } from './completion.js';
3
3
  import { createCodexAdapter } from './codex-provider.js';
4
4
  import { createClaudeAdapter } from './claude-provider.js';
5
5
  import { createOpenCodeAdapter } from './opencode-provider.js';
6
+ import { createGrokAdapter } from './grok-provider.js';
7
+ import { createOpenCodeCliAdapter } from './opencode-cli-provider.js';
6
8
  import { providerAuthHeaders } from './anthropic-credentials.js';
7
9
  import { generateEngineResponse, isEngineContextOverflow } from './provider-engine.js';
8
10
  export const REASONING_EFFORTS = ['none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
11
+ /** Every provider type a configuration may name. */
12
+ export const PROVIDER_TYPES = ['openai-compatible', 'anthropic', 'codex', 'claude', 'opencode-go', 'grok', 'opencode'];
13
+ /**
14
+ * Types that run through a vendor CLI's own sign-in on this machine instead of a key Andorra holds.
15
+ *
16
+ * They carry no credential fields, use a fixed marker base URL, and bound each request themselves,
17
+ * so configuration rejects key and timeout overrides on them rather than silently ignoring them.
18
+ */
19
+ export const SIGN_IN_PROVIDER_TYPES = ['codex', 'claude', 'grok', 'opencode'];
20
+ export function isSignInProviderType(type) {
21
+ return SIGN_IN_PROVIDER_TYPES.includes(type);
22
+ }
23
+ /** The product name messages use for a sign-in type. */
24
+ const SIGN_IN_PRODUCT = { codex: 'Codex', claude: 'Claude', grok: 'Grok', opencode: 'OpenCode' };
9
25
  /**
10
26
  * Inactivity bound for inference, and wall-clock bound for other HTTP requests,
11
27
  * in milliseconds, when a provider does not configure its own.
@@ -42,10 +58,8 @@ export function assertRequestTimeout(provider) {
42
58
  const value = provider.requestTimeoutMs;
43
59
  if (value === undefined)
44
60
  return;
45
- if (provider.type === 'codex')
46
- throw new Error('Codex providers bound each request at ten minutes; requestTimeoutMs is not supported');
47
- if (provider.type === 'claude')
48
- throw new Error('Claude providers bound each request at ten minutes; requestTimeoutMs is not supported');
61
+ if (isSignInProviderType(provider.type))
62
+ throw new Error(`${SIGN_IN_PRODUCT[provider.type]} providers bound each request at ten minutes; requestTimeoutMs is not supported`);
49
63
  if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 0 || value > MAX_REQUEST_TIMEOUT_MS) {
50
64
  throw new Error(`Provider requestTimeoutMs must be 0 (no timeout) or an integer of milliseconds up to ${MAX_REQUEST_TIMEOUT_MS}`);
51
65
  }
@@ -64,10 +78,8 @@ export function assertStreamIdleTimeout(provider) {
64
78
  const value = provider.streamIdleTimeoutMs;
65
79
  if (value === undefined)
66
80
  return;
67
- if (provider.type === 'codex')
68
- throw new Error('Codex providers bound each request at ten minutes; streamIdleTimeoutMs is not supported');
69
- if (provider.type === 'claude')
70
- throw new Error('Claude providers bound each request at ten minutes; streamIdleTimeoutMs is not supported');
81
+ if (isSignInProviderType(provider.type))
82
+ throw new Error(`${SIGN_IN_PRODUCT[provider.type]} providers bound each request at ten minutes; streamIdleTimeoutMs is not supported`);
71
83
  if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 0 || value > MAX_REQUEST_TIMEOUT_MS) {
72
84
  throw new Error(`Provider streamIdleTimeoutMs must be 0 (no bound) or an integer of milliseconds up to ${MAX_REQUEST_TIMEOUT_MS}`);
73
85
  }
@@ -255,6 +267,9 @@ export function assertProviderCredentials(provider) {
255
267
  if (provider.type === 'claude' && (provider.apiKey !== undefined || provider.apiKeyEnv !== undefined)) {
256
268
  throw new Error('Claude providers use Claude Code sign-in; API key overrides are not supported.');
257
269
  }
270
+ if ((provider.type === 'grok' || provider.type === 'opencode') && (provider.apiKey !== undefined || provider.apiKeyEnv !== undefined)) {
271
+ throw new Error(`${SIGN_IN_PRODUCT[provider.type]} providers use their CLI sign-in; API key overrides are not supported.`);
272
+ }
258
273
  if (provider.apiKey !== undefined && (typeof provider.apiKey !== 'string' || !/^[\x21-\x7e]+$/.test(provider.apiKey))) {
259
274
  throw new Error('API key must be nonempty and contain no whitespace or control characters.');
260
275
  }
@@ -836,6 +851,10 @@ export function createAdapter(config) {
836
851
  return createCodexAdapter(config);
837
852
  if (config.type === 'claude')
838
853
  return createClaudeAdapter(config);
854
+ if (config.type === 'grok')
855
+ return createGrokAdapter(config);
856
+ if (config.type === 'opencode')
857
+ return createOpenCodeCliAdapter(config);
839
858
  if (config.type === 'opencode-go')
840
859
  return createOpenCodeAdapter(config);
841
860
  let base;
@@ -13,9 +13,9 @@ export interface SessionPullRequest {
13
13
  number: number;
14
14
  title?: string;
15
15
  state: PullRequestState;
16
+ /** Wake the session when review comments arrive. Never on for a merged or closed PR: it switches itself off. */
16
17
  autoFix: boolean;
17
18
  mergeWhenReady: boolean;
18
- autoArchive: boolean;
19
19
  /** When the PR was attached: a top-level comment older than this was never the session's to answer. */
20
20
  attachedAt: string;
21
21
  /** The newest review comment Auto-fix has already handed to the agent. */
@@ -30,16 +30,24 @@ export interface SessionPullRequest {
30
30
  };
31
31
  /** The selections of the run that attached or last configured the PR, so an Auto-fix run continues under them. */
32
32
  carry?: WakeCarry;
33
- /** Set once Auto-archive has filed the session, so a merged PR is not archived again on every poll. */
34
- archivedAt?: string;
33
+ /** The signed-in `gh` account that can read this PR; every call for it runs as this account. */
34
+ ghUser?: string;
35
+ /** Why the watcher last could not read this PR; cleared by the next successful read. */
36
+ watchError?: string;
35
37
  updatedAt: string;
36
38
  }
37
39
  export type PullRequestState = 'open' | 'draft' | 'merged' | 'closed';
40
+ /** Whether GitHub is done with the PR: once merged or closed there is nothing left to fix, merge or convert. */
41
+ export declare const isFinishedPullRequest: (state: PullRequestState) => boolean;
42
+ /**
43
+ * A merged or closed PR with Auto-fix switched off and its pending wake forgotten: there is nothing left to fix, so
44
+ * the setting stops on its own instead of staying on for a PR that can no longer change. An open PR is unchanged.
45
+ */
46
+ export declare function settleFinishedPullRequest(pullRequest: SessionPullRequest): SessionPullRequest;
38
47
  /** The settings a caller may change; `draft` converts the PR to a draft or marks it ready. */
39
48
  export interface PullRequestSettings {
40
49
  autoFix?: boolean;
41
50
  mergeWhenReady?: boolean;
42
- autoArchive?: boolean;
43
51
  draft?: boolean;
44
52
  }
45
53
  export interface PullRequestRef {
@@ -62,15 +70,71 @@ export declare function listPullRequests(home: string): Promise<{
62
70
  pullRequest: SessionPullRequest;
63
71
  }[]>;
64
72
  export declare function withPullRequest<T>(home: string, sessionId: string, work: () => Promise<T>): Promise<T>;
65
- /** Runs `gh` with the given arguments and resolves to its stdout; a nonzero exit rejects with its stderr. */
66
- export type GhRunner = (args: readonly string[]) => Promise<string>;
73
+ /**
74
+ * Runs `gh` with the given arguments and resolves to its stdout; a nonzero exit rejects with its stderr.
75
+ * With `user`, the command runs as that signed-in account, whichever one `gh` has active.
76
+ */
77
+ export type GhRunner = (args: readonly string[], options?: {
78
+ user?: string;
79
+ }) => Promise<string>;
80
+ /** Runs one `gh` command in the given environment and resolves to its stdout. */
81
+ export type GhExec = (args: readonly string[], env: NodeJS.ProcessEnv) => Promise<string>;
82
+ export declare function createGhRunner(exec?: GhExec): GhRunner;
67
83
  export declare const runGh: GhRunner;
68
- /** The PR's title, state and auto-merge as GitHub reports them now. */
69
- export declare function viewPullRequest(gh: GhRunner, url: string): Promise<{
84
+ /** The PR's title, state and auto-merge as GitHub reports them. */
85
+ export interface PullRequestView {
70
86
  title: string;
71
87
  state: PullRequestState;
72
88
  autoMerge: boolean;
89
+ }
90
+ /** The PR's title, state and auto-merge as GitHub reports them now, read as `user` when given. */
91
+ export declare function viewPullRequest(gh: GhRunner, url: string, user?: string): Promise<PullRequestView>;
92
+ /** The signed-in github.com accounts `gh` can use, the active one first. */
93
+ export declare function ghAccounts(gh: GhRunner): Promise<string[]>;
94
+ /**
95
+ * Whether a `gh` failure says the account cannot see the PR (or has no usable token, including a saved account that
96
+ * was signed out), rather than an outage. A rate limit answers 403 too, but it is an outage: the account may well
97
+ * see the PR once the limit lifts.
98
+ */
99
+ export declare function isGhAccessError(error: unknown): boolean;
100
+ /** Whether a `gh auth status` failure means this `gh` cannot list accounts at all (an older gh without `--json`). */
101
+ export declare function isGhListingUnsupported(error: unknown): boolean;
102
+ /**
103
+ * The first signed-in account that can read the PR, with what it read; `undefined` when none can, or when `gh`
104
+ * cannot list accounts at all (an older gh). The active account is tried first, so a PR it can read never switches
105
+ * accounts. A failure that is not about access (an outage, including a listing that fails for any other reason or
106
+ * answers something that is not JSON) is thrown: it does not mean nobody can read the PR. `undefined` means either
107
+ * nobody can read it or `gh` cannot list accounts, so callers that must tell those apart use
108
+ * `readPullRequestAsAnyAccount`.
109
+ */
110
+ export declare function findPullRequestAccount(gh: GhRunner, url: string): Promise<{
111
+ user: string;
112
+ seen: PullRequestView;
113
+ } | undefined>;
114
+ /**
115
+ * Read a PR as whichever signed-in account can see it: when a PR is attached, and when the watcher must detect the
116
+ * account again. `ghUser` names the account that read it whenever `gh` can list accounts; without a list the
117
+ * environment's account is asked. Callers record "no account can read it" ONLY on `unreadable`, which means every
118
+ * listed account (or, without a list, the environment's) was refused. A result with only `failed` is an outage (the
119
+ * error that stopped the detection), or a `gh` that cannot list accounts and whose environment read also failed for
120
+ * a reason other than access; the PR is then tracked as open until the watcher reads it.
121
+ */
122
+ export declare function readPullRequestAsAnyAccount(gh: GhRunner, url: string): Promise<{
123
+ seen?: PullRequestView;
124
+ ghUser?: string;
125
+ unreadable?: true;
126
+ failed?: unknown;
73
127
  }>;
128
+ /**
129
+ * `gh` bound to the account saved on the record, or the active account when none is saved. The bound runner must
130
+ * never be passed to `ghAccounts` or `findPullRequestAccount`: with a token injected, `gh auth status` reports
131
+ * only that token's account.
132
+ */
133
+ export declare function ghFor(gh: GhRunner, pullRequest: {
134
+ ghUser?: string;
135
+ }): GhRunner;
136
+ /** What the Pull request row says when no signed-in account can read the PR. */
137
+ export declare const noAccountMessage: (url: string) => string;
74
138
  /** A freshly attached PR with every setting off. */
75
139
  export declare function newPullRequest(ref: PullRequestRef, now?: Date): SessionPullRequest;
76
140
  /**
@@ -85,6 +149,16 @@ export declare function newPullRequest(ref: PullRequestRef, now?: Date): Session
85
149
  * that was skipped because the stored flag already said "off" would leave the PR merging against the user's word.
86
150
  */
87
151
  export declare function applyPullRequestSettings(gh: GhRunner, current: SessionPullRequest, changes: PullRequestSettings, now?: Date): Promise<SessionPullRequest>;
152
+ /**
153
+ * Apply settings as the record's account, and when that account can no longer see the PR (signed out, access
154
+ * removed), find one that can, keep it on the result, and apply once more. The watcher only re-detects the PRs it
155
+ * polls, so this is how a menu change recovers for a PR with Auto-fix off. Any other failure, or
156
+ * a re-detection that finds the same account or nobody, throws the original error; an outage while re-detecting is
157
+ * named as such, with the access error as its cause. The retry cannot apply a GitHub-side change twice, because
158
+ * `applyPullRequestSettings` re-decides each change against a fresh `pr view`, so a step that succeeded before the
159
+ * access error is skipped on the second attempt.
160
+ */
161
+ export declare function applyPullRequestSettingsAsReadableAccount(gh: GhRunner, current: SessionPullRequest, changes: PullRequestSettings, now?: Date): Promise<SessionPullRequest>;
88
162
  /** A session's pull request as its run's `pull_request` tool reaches it; bound to that session by the engine. */
89
163
  export interface PullRequestControl {
90
164
  status(): Promise<SessionPullRequest | undefined>;
@@ -122,6 +196,8 @@ export declare function newReviewComments(gh: GhRunner, pullRequest: SessionPull
122
196
  /**
123
197
  * The prompt Auto-fix delivers. It names the PR and how much is new, never the comments themselves: their text
124
198
  * is third-party content, and the agent reads it through `gh` as tool output rather than as the user's words.
199
+ * When the PR is read as a saved account, the prompt names it (the engine's own record, not third-party text) and
200
+ * says how to run `gh` as it: the agent's shell runs as the active keyring account, which may not see the PR.
125
201
  */
126
202
  export declare function autoFixPrompt(pullRequest: SessionPullRequest, found: {
127
203
  threads: number;
@@ -148,8 +224,6 @@ export interface PullRequestWatcherOptions {
148
224
  intervalMs?: number;
149
225
  /** A PR's stored state changed. */
150
226
  onUpdated: (sessionId: string, pullRequest: SessionPullRequest) => void;
151
- /** File the session away; `false` (a run is active) or a rejection is retried on the next poll. */
152
- archive: (sessionId: string) => Promise<boolean>;
153
227
  /** Arm an Auto-fix prompt for the session, continuing under `carry`; returns the wake's id. */
154
228
  wake: (sessionId: string, prompt: string, carry: WakeCarry | undefined) => string;
155
229
  /** Whether this engine still holds the wake `id`, armed and not yet delivered. */
@@ -158,10 +232,13 @@ export interface PullRequestWatcherOptions {
158
232
  /** Overridable for tests; defaults to the home's exclusive watcher lease. */
159
233
  claim?: () => Promise<boolean>;
160
234
  }
161
- /** Whether a PR still needs the watcher: something is switched on that only polling can act on. */
235
+ /**
236
+ * Whether a PR still needs the watcher: an unfinished PR until GitHub calls it finished, so the card's state chip
237
+ * never goes stale. A merged or closed PR never does.
238
+ */
162
239
  export declare function pullRequestNeedsWatch(pullRequest: SessionPullRequest): boolean;
163
240
  /**
164
- * Polls the PRs whose sessions asked for Auto-fix or Auto-archive.
241
+ * Polls every unfinished PR, and wakes the agent for new review comments on the ones with Auto-fix on.
165
242
  *
166
243
  * The timer is unref'd and every poll is serialized: a slow `gh` never stacks a second poll on the first.
167
244
  */
@@ -177,15 +254,32 @@ export declare class PullRequestWatcher {
177
254
  /** One pass over every watched PR. Public so a test (or a just-changed setting) can run one now. */
178
255
  poll(): Promise<void>;
179
256
  private pass;
257
+ /**
258
+ * The PR as GitHub reports it, read as the record's account (the active one when none is saved). An account that
259
+ * cannot see it is replaced by one that can (`account`: the login to save, or `null` to clear a stale one when only
260
+ * the environment's account could read it; absent: no change). When no signed-in account can, the record says so,
261
+ * once, and this poll skips the PR. Any other failure (an outage, a rate limit) is thrown to the pass, which logs it.
262
+ */
263
+ private read;
180
264
  private check;
181
265
  }
182
266
  /**
183
- * Whether an Auto-fix wake should still be delivered: its session still tracks a PR with Auto-fix on, and that
184
- * PR's pending wake is this one. Read at delivery, not at arming — the PR can be dismissed, replaced or switched
185
- * off while the wake waits out a busy engine, from this engine or another, and a prompt telling the agent to
186
- * fix and push must not outlive the user's word that it should stop.
267
+ * Whether an Auto-fix wake should be delivered now, decided at delivery rather than at arming, with GitHub asked
268
+ * first.
269
+ *
270
+ * The PR can be dismissed, replaced or switched off while the wake waits out a busy engine, from this engine or
271
+ * another, and a prompt telling the agent to fix and push must not outlive the user's word that it should stop. Nor
272
+ * is the record's state enough: a PR merged or closed by hand on GitHub is only seen at the watcher's next poll, so
273
+ * GitHub is read every time instead of trusting the record.
274
+ *
275
+ * `deliver` is true only when the PR is open on GitHub and the record still asks for this wake. A finished PR is
276
+ * saved as GitHub reports it, with Auto-fix switched off, and returned as `pullRequest` for the caller to publish.
277
+ * A failed read throws: the caller keeps the wake and asks again later rather than sending it unconfirmed.
187
278
  */
188
- export declare function autoFixWakeWanted(home: string, sessionId: string, wakeId: string): Promise<boolean>;
279
+ export declare function confirmAutoFixWake(home: string, gh: GhRunner, sessionId: string, wakeId: string): Promise<{
280
+ deliver: boolean;
281
+ pullRequest?: SessionPullRequest;
282
+ }>;
189
283
  /** Forget the pending Auto-fix wake on a record that keeps the PR (Auto-fix switched off). */
190
284
  export declare function withoutPendingFix(pullRequest: SessionPullRequest): SessionPullRequest;
191
285
  /**