@andorra-labs/code 0.1.10 → 0.1.12

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 (238) hide show
  1. package/README.md +31 -205
  2. package/THIRD_PARTY_NOTICES.md +30 -0
  3. package/dist/src/agent-execution.js +50 -2
  4. package/dist/src/agent-mcp.js +5 -0
  5. package/dist/src/app-server/protocol.d.ts +9 -1
  6. package/dist/src/app-server/protocol.js +1 -1
  7. package/dist/src/app-server.d.ts +49 -1
  8. package/dist/src/app-server.js +353 -64
  9. package/dist/src/automation-service.js +1 -1
  10. package/dist/src/browser-panel-tool.d.ts +24 -3
  11. package/dist/src/browser-panel-tool.js +80 -6
  12. package/dist/src/browser-runner.js +3 -1
  13. package/dist/src/browser-session.d.ts +8 -0
  14. package/dist/src/browser-session.js +27 -1
  15. package/dist/src/browser-ui/app.js +237 -15
  16. package/dist/src/browser-ui/index.html +5 -5
  17. package/dist/src/browser-ui/style.css +110 -65
  18. package/dist/src/browser-ui/tokens.css +27 -26
  19. package/dist/src/browser-view.d.ts +16 -0
  20. package/dist/src/browser-view.js +38 -2
  21. package/dist/src/claude-provider.js +15 -2
  22. package/dist/src/cli.d.ts +2 -1
  23. package/dist/src/cli.js +175 -43
  24. package/dist/src/code-intelligence/CodeIntelligenceManager.js +1 -1
  25. package/dist/src/codex-provider.js +6 -3
  26. package/dist/src/coding-tools.d.ts +26 -1
  27. package/dist/src/coding-tools.js +104 -33
  28. package/dist/src/command-screens.js +1 -1
  29. package/dist/src/commands.js +1 -1
  30. package/dist/src/completion-gates.d.ts +42 -7
  31. package/dist/src/completion-gates.js +55 -9
  32. package/dist/src/completion.d.ts +51 -1
  33. package/dist/src/completion.js +164 -5
  34. package/dist/src/config.d.ts +1 -0
  35. package/dist/src/config.js +2 -0
  36. package/dist/src/dashboard-view.js +2 -2
  37. package/dist/src/deadline.js +4 -0
  38. package/dist/src/decision/PreparedSteps.js +1 -1
  39. package/dist/src/delegation-changes.js +19 -2
  40. package/dist/src/diff-preview.d.ts +1 -0
  41. package/dist/src/diff-preview.js +12 -3
  42. package/dist/src/engine-streams.d.ts +22 -0
  43. package/dist/src/engine-streams.js +16 -0
  44. package/dist/src/extensions.js +17 -6
  45. package/dist/src/file-read-key.d.ts +8 -0
  46. package/dist/src/file-read-key.js +12 -0
  47. package/dist/src/graph-editor-session.js +2 -1
  48. package/dist/src/graph-health.d.ts +21 -0
  49. package/dist/src/graph-health.js +46 -0
  50. package/dist/src/graph-manager-chat.d.ts +52 -3
  51. package/dist/src/graph-manager-chat.js +62 -17
  52. package/dist/src/graph-runner.js +62 -5
  53. package/dist/src/graph-server.d.ts +1 -1
  54. package/dist/src/graph-server.js +48 -27
  55. package/dist/src/graph-sync.d.ts +8 -0
  56. package/dist/src/graph-sync.js +54 -3
  57. package/dist/src/graph-tool.js +1 -1
  58. package/dist/src/graph-ui/app.js +362 -123
  59. package/dist/src/graph-ui/controls.css +95 -22
  60. package/dist/src/graph-ui/controls.js +31 -1
  61. package/dist/src/graph-ui/embed.js +62 -13
  62. package/dist/src/graph-ui/icons.js +7 -0
  63. package/dist/src/graph-ui/index.html +4 -4
  64. package/dist/src/graph-ui/manager-state.js +143 -5
  65. package/dist/src/graph-ui/manager.css +21 -20
  66. package/dist/src/graph-ui/manager.js +337 -75
  67. package/dist/src/graph-ui/model-picker.js +279 -0
  68. package/dist/src/graph-ui/provider-glyphs/alibaba-cloud.png +0 -0
  69. package/dist/src/graph-ui/provider-glyphs/anthropic.png +0 -0
  70. package/dist/src/graph-ui/provider-glyphs/aws-bedrock.png +0 -0
  71. package/dist/src/graph-ui/provider-glyphs/claude.png +0 -0
  72. package/dist/src/graph-ui/provider-glyphs/deepseek.png +0 -0
  73. package/dist/src/graph-ui/provider-glyphs/fireworks.png +0 -0
  74. package/dist/src/graph-ui/provider-glyphs/kimi.png +0 -0
  75. package/dist/src/graph-ui/provider-glyphs/minimax.png +0 -0
  76. package/dist/src/graph-ui/provider-glyphs/openai.png +0 -0
  77. package/dist/src/graph-ui/provider-glyphs/opencode.png +0 -0
  78. package/dist/src/graph-ui/provider-glyphs/openrouter.png +0 -0
  79. package/dist/src/graph-ui/provider-glyphs/xai.png +0 -0
  80. package/dist/src/graph-ui/provider-glyphs/xiaomi-mimo.png +0 -0
  81. package/dist/src/graph-ui/provider-glyphs/zai.png +0 -0
  82. package/dist/src/graph-ui/skill-picker.js +1 -1
  83. package/dist/src/graph-ui/studio-canvas.js +8 -8
  84. package/dist/src/graph-ui/studio.css +18 -15
  85. package/dist/src/graph-ui/studio.js +92 -35
  86. package/dist/src/graph-ui/style.css +122 -79
  87. package/dist/src/graph-ui/theme.js +2 -2
  88. package/dist/src/graph-ui/tokens.css +33 -29
  89. package/dist/src/graphs.d.ts +5 -2
  90. package/dist/src/graphs.js +10 -9
  91. package/dist/src/mcp.d.ts +52 -14
  92. package/dist/src/mcp.js +285 -128
  93. package/dist/src/membership-errors.d.ts +7 -1
  94. package/dist/src/membership-errors.js +9 -3
  95. package/dist/src/memory/ProjectMemory.d.ts +77 -0
  96. package/dist/src/memory/ProjectMemory.js +310 -0
  97. package/dist/src/memory/index.d.ts +1 -0
  98. package/dist/src/memory/index.js +1 -0
  99. package/dist/src/opencode-provider.js +5 -6
  100. package/dist/src/package-name.d.ts +3 -0
  101. package/dist/src/package-name.js +3 -0
  102. package/dist/src/provider-engine.js +2 -2
  103. package/dist/src/pull-requests.d.ts +42 -6
  104. package/dist/src/pull-requests.js +11 -3
  105. package/dist/src/qa/runtime/PtyManager.js +2 -1
  106. package/dist/src/react-runtime.js +137 -22
  107. package/dist/src/read-document-doc.d.ts +20 -0
  108. package/dist/src/read-document-doc.js +524 -0
  109. package/dist/src/read-document-docx.d.ts +21 -0
  110. package/dist/src/read-document-docx.js +584 -0
  111. package/dist/src/read-document-text.d.ts +29 -0
  112. package/dist/src/read-document-text.js +67 -0
  113. package/dist/src/read-document-tool.d.ts +48 -0
  114. package/dist/src/read-document-tool.js +162 -0
  115. package/dist/src/read-document.d.ts +78 -0
  116. package/dist/src/read-document.js +353 -0
  117. package/dist/src/read-image.d.ts +29 -2
  118. package/dist/src/read-image.js +42 -17
  119. package/dist/src/remote/cert.d.ts +1 -1
  120. package/dist/src/remote/cert.js +2 -7
  121. package/dist/src/remote/client.js +1 -1
  122. package/dist/src/remote/pem.d.ts +6 -0
  123. package/dist/src/remote/pem.js +11 -0
  124. package/dist/src/run-records.js +49 -10
  125. package/dist/src/runtime.d.ts +21 -0
  126. package/dist/src/runtime.js +10 -1
  127. package/dist/src/session-changes.d.ts +6 -1
  128. package/dist/src/session-changes.js +13 -5
  129. package/dist/src/sessions.d.ts +3 -1
  130. package/dist/src/sessions.js +5 -3
  131. package/dist/src/side-panel.d.ts +6 -1
  132. package/dist/src/side-panel.js +12 -10
  133. package/dist/src/sign-in-detection.d.ts +82 -0
  134. package/dist/src/sign-in-detection.js +197 -0
  135. package/dist/src/sign-in-offer.d.ts +35 -0
  136. package/dist/src/sign-in-offer.js +116 -0
  137. package/dist/src/skills/bundled/create-skill/SKILL.md +1 -1
  138. package/dist/src/skills/bundled/diagram/SKILL.md +1 -1
  139. package/dist/src/skills/bundled/graph-manager/SKILL.md +59 -7
  140. package/dist/src/skills/bundled/graph-manager/patterns.md +27 -0
  141. package/dist/src/skills/bundled/provenance.json +4 -4
  142. package/dist/src/skills/runtime-skills.d.ts +6 -0
  143. package/dist/src/skills/runtime-skills.js +16 -3
  144. package/dist/src/stall-recovery.d.ts +6 -2
  145. package/dist/src/stall-recovery.js +7 -2
  146. package/dist/src/stray-files.d.ts +14 -0
  147. package/dist/src/stray-files.js +81 -0
  148. package/dist/src/subagent-run.js +6 -1
  149. package/dist/src/terminal-ui.d.ts +1 -1
  150. package/dist/src/terminal-ui.js +11 -5
  151. package/dist/src/time-limit.d.ts +53 -0
  152. package/dist/src/time-limit.js +79 -0
  153. package/dist/src/tool-activity.js +1 -1
  154. package/dist/src/tool-schema-compatibility.d.ts +7 -2
  155. package/dist/src/tool-schema-compatibility.js +8 -4
  156. package/dist/src/tools.js +92 -7
  157. package/dist/src/transcript.d.ts +5 -0
  158. package/dist/src/transcript.js +12 -4
  159. package/dist/src/types.d.ts +8 -0
  160. package/dist/src/untracked-file-removal.d.ts +3 -0
  161. package/dist/src/untracked-file-removal.js +125 -0
  162. package/dist/src/update-check.js +1 -1
  163. package/dist/src/update.d.ts +11 -1
  164. package/dist/src/update.js +27 -5
  165. package/dist/src/usage-analytics.d.ts +3 -1
  166. package/dist/src/usage-analytics.js +16 -2
  167. package/dist/src/workspace-git-metadata.d.ts +15 -0
  168. package/dist/src/workspace-git-metadata.js +50 -1
  169. package/dist/src/workspace-instructions.js +1 -1
  170. package/package.json +6 -26
  171. package/docs/README.md +0 -36
  172. package/docs/agents/README.md +0 -62
  173. package/docs/agents/install-for-agents.md +0 -56
  174. package/docs/agents/mcp-server.md +0 -212
  175. package/docs/agents/subagent-mode.md +0 -149
  176. package/docs/concepts/README.md +0 -47
  177. package/docs/concepts/jev-actionable-routing.md +0 -113
  178. package/docs/concepts/jev-decision-thresholds.md +0 -412
  179. package/docs/concepts/jev-efficiency.md +0 -217
  180. package/docs/concepts/jev-eval-2026-11-01.md +0 -78
  181. package/docs/concepts/limits.md +0 -52
  182. package/docs/concepts/memory.md +0 -10
  183. package/docs/concepts/security.md +0 -50
  184. package/docs/concepts/workspace-instructions.md +0 -29
  185. package/docs/getting-started/README.md +0 -82
  186. package/docs/getting-started/accounts.md +0 -78
  187. package/docs/getting-started/configure-providers.md +0 -132
  188. package/docs/guides/README.md +0 -13
  189. package/docs/guides/browser.md +0 -39
  190. package/docs/guides/desktop-app.md +0 -414
  191. package/docs/guides/extensions.md +0 -102
  192. package/docs/guides/graph-builder.md +0 -116
  193. package/docs/guides/headless.md +0 -46
  194. package/docs/guides/tui.md +0 -75
  195. package/docs/guides/update.md +0 -70
  196. package/docs/guides/web-search.md +0 -51
  197. package/docs/guides/windows-code-signing.md +0 -319
  198. package/docs/llms.txt +0 -45
  199. package/docs/reference/README.md +0 -7
  200. package/docs/reference/cli.md +0 -76
  201. package/docs/reference/config.md +0 -91
  202. package/docs/reference/slash-commands.md +0 -59
  203. package/docs/superpowers/plans/2026-11-01-claude-console-sign-in.md +0 -111
  204. package/docs/superpowers/plans/2026-11-01-jev-node-opt-in.md +0 -910
  205. package/docs/superpowers/plans/2026-11-02-workflow-pane.md +0 -398
  206. package/docs/superpowers/plans/2026-11-06-graph-soft-delete.md +0 -125
  207. package/docs/superpowers/plans/2026-11-09-orchestrator-delegation.md +0 -295
  208. package/docs/superpowers/plans/2026-11-13-graph-manager-chat.md +0 -203
  209. package/docs/superpowers/plans/2026-11-14-jev-fair-use-pricing.md +0 -79
  210. package/docs/superpowers/specs/2026-10-31-work-line-summary-design.md +0 -50
  211. package/docs/superpowers/specs/2026-11-01-claude-console-sign-in-design.md +0 -176
  212. package/docs/superpowers/specs/2026-11-01-jev-node-opt-in-design.md +0 -164
  213. package/docs/superpowers/specs/2026-11-01-pr-section-design.md +0 -111
  214. package/docs/superpowers/specs/2026-11-02-workflow-pane-design.md +0 -130
  215. package/docs/superpowers/specs/2026-11-06-bundled-skills-design.md +0 -206
  216. package/docs/superpowers/specs/2026-11-09-orchestrator-delegation-design.md +0 -291
  217. package/docs/superpowers/specs/2026-11-13-graph-manager-chat-design.md +0 -182
  218. package/docs/superpowers/specs/2026-11-14-jev-fair-use-pricing-design.md +0 -156
  219. package/scripts/jev-efficiency-eval.mjs +0 -187
  220. package/scripts/jev-efficiency-live.mjs +0 -193
  221. package/scripts/zcode-engine-replay.mjs +0 -223
  222. package/tests/agent-centric-mcp-test-plan.md +0 -208
  223. package/tests/analytics-settings-test-plan.md +0 -165
  224. package/tests/browser-cli-smoke.mjs +0 -276
  225. package/tests/browser-test-plan.md +0 -280
  226. package/tests/chat-side-panel-test-plan.md +0 -309
  227. package/tests/decision-engine-test-plan.md +0 -163
  228. package/tests/default-active-jev-test-plan.md +0 -85
  229. package/tests/harness-extensions-test-plan.md +0 -113
  230. package/tests/jev-all-decisions-test-plan.md +0 -156
  231. package/tests/jev-efficiency/criteria.json +0 -158
  232. package/tests/jev-efficiency/workloads.mjs +0 -242
  233. package/tests/jev-efficiency-test-plan.md +0 -198
  234. package/tests/permissions-sandbox-probe.mjs +0 -74
  235. package/tests/permissions-test-plan.md +0 -191
  236. package/tests/product-telemetry-test-plan.md +0 -536
  237. package/tests/thinking-stream-preview-test-plan.md +0 -136
  238. package/tests/zcode-react-engine-test-plan.md +0 -396
@@ -34,6 +34,13 @@ export interface Completion {
34
34
  outcome?: string;
35
35
  output?: Record<string, unknown>;
36
36
  artifacts?: ArtifactRef[];
37
+ /**
38
+ * What the task still lacks, as the agent itself listed it in the completion that ends a run.
39
+ * Absent when it claimed everything was done. A run-ending completion that carries entries is
40
+ * sent back to keep working (completion-gates.ts); one that is accepted anyway keeps them, so a
41
+ * client can show that the run ended unfinished without reading the summary's wording.
42
+ */
43
+ remaining?: string[];
37
44
  /**
38
45
  * How an attempt ended, carried on the summary a stopped attempt leaves behind.
39
46
  *
@@ -158,6 +165,11 @@ export interface AgentContinuationState {
158
165
  export declare function timerReminderText(prompt: string): string;
159
166
  /** What delivered a retained turn's message instead of the user, as `ConversationTurn.wake` records it. */
160
167
  type RetainedWake = 'timer' | 'auto-fix';
168
+ /**
169
+ * The words a node reads for a message a wake delivered: the agent's own reminder, or the review comments Auto-fix
170
+ * brought, each marked as not coming from the user. A message no wake delivered is the user's, unchanged.
171
+ */
172
+ export declare function wakeMessageText(wake: RetainedWake | undefined, message: string): string;
161
173
  export declare function turnModelTask(turn: {
162
174
  task: string;
163
175
  direction?: string;
@@ -399,6 +411,13 @@ export interface GraphRunOptions extends RunOptions {
399
411
  * conversation already holds it, and every later activation keeps its own policy.
400
412
  */
401
413
  entryHistory?: boolean;
414
+ /**
415
+ * The node a fresh run starts at instead of the graph's entry, when it names a node of the graph that can start
416
+ * without inputs from a predecessor. Set when a wake is addressed to a node (an Auto-fix prompt goes to the node that
417
+ * switched Auto-fix on). Ignored by a resumed run, whose frontier says where it continues, and when it names no
418
+ * such node, in which case the run starts at the entry as usual.
419
+ */
420
+ startNode?: string;
402
421
  /** The configured providers' ids and model lists, for validating adaptive-routing tiers. */
403
422
  configuredModels?: {
404
423
  id: string;
@@ -424,6 +443,8 @@ export interface GraphRunOptions extends RunOptions {
424
443
  memory?: import('./memory/MemoryManager.js').MemoryManager;
425
444
  /** Local, deterministic command lessons; the CLI enables this without persistent memory. */
426
445
  commandMemory?: import('./memory/LocalToolMemory.js').LocalToolMemory;
446
+ /** Per-repository Markdown memory: recalled into each node and written with memory_* tools. */
447
+ projectMemory?: import('./memory/ProjectMemory.js').ProjectMemory;
427
448
  /**
428
449
  * The furthest accepted conversation of each node, on every checkpoint.
429
450
  *
@@ -36,10 +36,19 @@ export { DEFAULT_LIMITS, LIMIT_KEYS, isUnlimited, isUnlimitedAlias, resolveLimit
36
36
  export function timerReminderText(prompt) {
37
37
  return `[Timer] A reminder you set for yourself with set_timer (not a message from the user): ${prompt}`;
38
38
  }
39
+ /**
40
+ * The words a node reads for a message a wake delivered: the agent's own reminder, or the review comments Auto-fix
41
+ * brought, each marked as not coming from the user. A message no wake delivered is the user's, unchanged.
42
+ */
43
+ export function wakeMessageText(wake, message) {
44
+ if (wake === 'auto-fix')
45
+ return `Delivered by Auto-fix (not a message from the user): ${message}`;
46
+ return wake === 'timer' ? timerReminderText(message) : message;
47
+ }
39
48
  export function turnModelTask(turn) {
40
49
  // A wake's message keeps its provenance in every later request: the agent's own reminder (or the comments an
41
50
  // Auto-fix wake brought) must not be replayed as something the user asked for.
42
- const woken = (message) => turn.wake === 'auto-fix' ? `Delivered by Auto-fix (not a message from the user): ${message}` : timerReminderText(message);
51
+ const woken = (message) => wakeMessageText(turn.wake ?? 'timer', message);
43
52
  const text = turn.direction === undefined
44
53
  ? (turn.wake === undefined ? turn.task : woken(turn.task))
45
54
  : `${turn.task}\n\n${turn.wake === undefined ? `Direction given when the attempt continued: ${turn.direction}` : `Delivered when the attempt continued: ${woken(turn.direction)}`}`;
@@ -78,8 +78,13 @@ export declare class SessionChangeStore {
78
78
  * The recorder a run's tools report their writes to. Only files inside `root` (the run's workspace folder)
79
79
  * are tracked: a delegated subagent writes in a worktree of its own, and its change reaches the workspace
80
80
  * through the landing, which reports the files it lands.
81
+ *
82
+ * `review` answers, as a write lands, whether the person reviews this run's writes. A run that does not
83
+ * ask (Full Access) adds no file to the pending set: its writes are kept as they land, and nothing waits
84
+ * on a Keep. A file already pending from a reviewed write stays tracked, so its entry and its Undo still
85
+ * describe what is on disk.
81
86
  */
82
- recorder(sessionId: string, workspace: string, onChange: (changes: AppServerSessionChanges) => void, onError?: (error: unknown) => void): FileChangeRecorder;
87
+ recorder(sessionId: string, workspace: string, onChange: (changes: AppServerSessionChanges) => void, onError?: (error: unknown) => void, review?: () => boolean): FileChangeRecorder;
83
88
  /** Records what a landed write left, for each file it wrote. The caller holds the session's lock. */
84
89
  private recordWrites;
85
90
  /** Updates one file's entry in `state`; answers whether the pending set changed. */
@@ -370,8 +370,13 @@ export class SessionChangeStore {
370
370
  * The recorder a run's tools report their writes to. Only files inside `root` (the run's workspace folder)
371
371
  * are tracked: a delegated subagent writes in a worktree of its own, and its change reaches the workspace
372
372
  * through the landing, which reports the files it lands.
373
+ *
374
+ * `review` answers, as a write lands, whether the person reviews this run's writes. A run that does not
375
+ * ask (Full Access) adds no file to the pending set: its writes are kept as they land, and nothing waits
376
+ * on a Keep. A file already pending from a reviewed write stays tracked, so its entry and its Undo still
377
+ * describe what is on disk.
373
378
  */
374
- recorder(sessionId, workspace, onChange, onError) {
379
+ recorder(sessionId, workspace, onChange, onError, review = () => true) {
375
380
  sessionChangesId(sessionId);
376
381
  let rootPromise;
377
382
  const root = () => rootPromise ??= realpath(workspace).catch(() => path.resolve(workspace));
@@ -451,7 +456,7 @@ export class SessionChangeStore {
451
456
  return;
452
457
  try {
453
458
  if (before.length) {
454
- const changes = await this.recordWrites(sessionId, canonicalRoot, tracked.map((entry, index) => ({ ...entry, before: before[index] })), spilled);
459
+ const changes = await this.recordWrites(sessionId, canonicalRoot, tracked.map((entry, index) => ({ ...entry, before: before[index] })), spilled, review());
455
460
  if (changes)
456
461
  onChange(changes);
457
462
  }
@@ -479,11 +484,11 @@ export class SessionChangeStore {
479
484
  };
480
485
  }
481
486
  /** Records what a landed write left, for each file it wrote. The caller holds the session's lock. */
482
- async recordWrites(sessionId, root, files, spilled = false) {
487
+ async recordWrites(sessionId, root, files, spilled = false, review = true) {
483
488
  const state = await readState(this.home, sessionId);
484
489
  let changed = false;
485
490
  for (const file of files)
486
- changed = await this.recordWrite(sessionId, state, root, file.relative, file.before, file.created) || changed;
491
+ changed = await this.recordWrite(sessionId, state, root, file.relative, file.before, file.created, review) || changed;
487
492
  if (!changed) {
488
493
  // Originals stored while the write began, for files it left as they were, are referenced by nothing.
489
494
  if (spilled)
@@ -496,10 +501,13 @@ export class SessionChangeStore {
496
501
  return snapshot(sessionId, state);
497
502
  }
498
503
  /** Updates one file's entry in `state`; answers whether the pending set changed. */
499
- async recordWrite(sessionId, state, root, relative, before, created) {
504
+ async recordWrite(sessionId, state, root, relative, before, created, review = true) {
500
505
  const target = path.join(root, ...relative.split('/'));
501
506
  if (before.kind === 'other')
502
507
  return false;
508
+ // A write nobody reviews starts no entry; one for a file already pending is still recorded.
509
+ if (!review && !state.changes.some(change => keyOf(change.root, change.path) === keyOf(root, relative)))
510
+ return false;
503
511
  const after = await observe(target, this.baselineLimit);
504
512
  if (after.kind === 'other')
505
513
  return false;
@@ -170,7 +170,9 @@ export declare function carryRailOwnedFields(record: SavedSession, stored: Saved
170
170
  /**
171
171
  * A saved history as a reader displays it. A turn recorded before completion parsing decoded a
172
172
  * twice-escaped summary still holds a backslash and an "n" where its line breaks belong, and its
173
- * markdown draws as one literal paragraph; the stored record is left as written.
173
+ * markdown draws as one literal paragraph. A turn recorded before the host removed completion fields
174
+ * a model echoed as text under its answer (`stripEchoedEnvelope`) still shows them. The stored
175
+ * record is left as written.
174
176
  */
175
177
  export declare function displayHistory(history: ConversationTurn[]): ConversationTurn[];
176
178
  /** Stable opaque grouping key derived from the raw workspace path, before any secret redaction. */
@@ -4,7 +4,7 @@ import { mkdir, readFile, readdir, rename, rm, writeFile } from 'node:fs/promise
4
4
  import { join, resolve } from 'node:path';
5
5
  import { stripVTControlCharacters } from 'node:util';
6
6
  import { setTimeout as delay } from 'node:timers/promises';
7
- import { decodeDoubleEscapedSummary } from './completion.js';
7
+ import { decodeDoubleEscapedSummary, stripEchoedEnvelope } from './completion.js';
8
8
  import { redactSecrets } from './secret-redaction.js';
9
9
  /** Extract a short local task label without a model request. */
10
10
  export const sessionName = (prompt) => {
@@ -132,11 +132,13 @@ export function carryRailOwnedFields(record, stored) {
132
132
  /**
133
133
  * A saved history as a reader displays it. A turn recorded before completion parsing decoded a
134
134
  * twice-escaped summary still holds a backslash and an "n" where its line breaks belong, and its
135
- * markdown draws as one literal paragraph; the stored record is left as written.
135
+ * markdown draws as one literal paragraph. A turn recorded before the host removed completion fields
136
+ * a model echoed as text under its answer (`stripEchoedEnvelope`) still shows them. The stored
137
+ * record is left as written.
136
138
  */
137
139
  export function displayHistory(history) {
138
140
  return history.map(turn => {
139
- const summary = decodeDoubleEscapedSummary(turn.completion.summary);
141
+ const summary = stripEchoedEnvelope(decodeDoubleEscapedSummary(turn.completion.summary), turn.completion.outcome);
140
142
  return summary === turn.completion.summary ? turn : { ...turn, completion: { ...turn.completion, summary } };
141
143
  });
142
144
  }
@@ -13,6 +13,11 @@ import type { TodoItem } from './todos.js';
13
13
  * A row carries styled segments rather than one color so a single row can pair a label with
14
14
  * a value in a semantic color (`+120` green beside `-8` red) the way the reference panel
15
15
  * does. Callers that only care about the text use {@link panelRowText}.
16
+ *
17
+ * Hue means state here as in the window: green for lines added (and a clean tree), red for lines
18
+ * removed and failures, and only where there is something to report - a zero count is gray.
19
+ * Progress, a step that was visited and a terminal that is running are neutral: the accent for
20
+ * what is live, a quiet gray for what is done.
16
21
  */
17
22
  /** The working-tree summary the Git section reports. Produced by `git-summary.ts`. */
18
23
  export interface PanelChanges {
@@ -132,7 +137,7 @@ export declare function panelDuration(milliseconds: number): string;
132
137
  /**
133
138
  * The panel's rows, top to bottom, for a terminal of `columns` x `height`.
134
139
  *
135
- * Sections are anchored: Git tools, Node, Progress and the plan read from the top, while the
140
+ * Sections are anchored: Git tools, Step, Progress and the plan read from the top, while the
136
141
  * terminal list and the graph zoom are held against the bottom - the reader asked for the graph
137
142
  * section to be at the bottom of the panel - with whatever rows the top sections leave as blank
138
143
  * space between them, so a tall terminal does not park the zoom in the middle of the screen.
@@ -105,9 +105,9 @@ function gitSection(data, width) {
105
105
  body.push(pair(label, [{ text: 'clean', color: STATUS.ok }], width));
106
106
  else
107
107
  body.push(pair(label, [
108
- { text: `+${count(changes.insertions)}`, color: STATUS.added },
108
+ { text: `+${count(changes.insertions)}`, color: changes.insertions ? STATUS.added : GRAY },
109
109
  { text: ' ' },
110
- { text: `-${count(changes.deletions)}`, color: STATUS.error },
110
+ { text: `-${count(changes.deletions)}`, color: changes.deletions ? STATUS.error : GRAY },
111
111
  ], width));
112
112
  if (changes?.isGit) {
113
113
  // The summary's own read names the branch, so the row and the counts always describe the
@@ -130,7 +130,7 @@ function nodeSection(data, width) {
130
130
  const entry = data.graph ? data.graph.nodes[data.graph.entry]?.name ?? data.graph.entry : undefined;
131
131
  if (entry)
132
132
  body.push(row({ text: clip(`entry: ${entry}`, width), color: FAINT }));
133
- return [heading('Node', width), ...body];
133
+ return [heading('Step', width), ...body];
134
134
  }
135
135
  const [focus, ...rest] = data.nodes;
136
136
  body.push(row({ text: '● ', color: accentSgr() }, { text: clip(focus.name, width - 2), color: WHITE }));
@@ -143,7 +143,7 @@ function nodeSection(data, width) {
143
143
  // follower nodes are worth one line together, not one line each.
144
144
  if (rest.length)
145
145
  body.push(row({ text: clip(` +${rest.length} more running: ${rest.map(node => node.name).join(', ')}`, width), color: FAINT }));
146
- return [heading('Node', width), ...body];
146
+ return [heading('Step', width), ...body];
147
147
  }
148
148
  function progressSection(data, width) {
149
149
  const total = data.todos.length;
@@ -162,7 +162,9 @@ function progressSection(data, width) {
162
162
  const filled = share >= 1 ? barWidth : share > 0 ? Math.max(1, Math.min(barWidth, Math.floor(share * barWidth))) : 0;
163
163
  return [
164
164
  heading('Progress', width),
165
- row({ text: '█'.repeat(filled), color: STATUS.ok }, { text: '░'.repeat(barWidth - filled), color: FAINT }, { text: ' ' }, { text: label, color: GRAY }),
165
+ // Progress is neutral, as the window draws it: the accent fill on a faint track. Green is a
166
+ // passed check, and a plan two-thirds done has passed nothing yet.
167
+ row({ text: '█'.repeat(filled), color: accentSgr() }, { text: '░'.repeat(barWidth - filled), color: FAINT }, { text: ' ' }, { text: label, color: GRAY }),
166
168
  row({ text: clip(`${done} done · ${active} active · ${waiting} waiting`, width), color: GRAY }),
167
169
  ];
168
170
  }
@@ -234,19 +236,19 @@ function terminalSection(data, width) {
234
236
  // long test-runner invocation must lose its own tail, not the elapsed time a reader is
235
237
  // watching while the row keeps repainting for it.
236
238
  const life = clip(`${session.id} · ${session.command}`, Math.max(1, width - 2 - stringWidth(age)));
237
- return row({ text: session.running ? '● ' : '○ ', color: session.running ? STATUS.ok : FAINT }, { text: life, color: session.running ? GRAY : FAINT }, { text: age, color: session.running ? GRAY : FAINT });
239
+ return row({ text: session.running ? '● ' : '○ ', color: session.running ? accentSgr() : FAINT }, { text: life, color: session.running ? GRAY : FAINT }, { text: age, color: session.running ? GRAY : FAINT });
238
240
  });
239
241
  if (ordered.length > body.length)
240
242
  body.push(row({ text: ` +${ordered.length - body.length} more`, color: FAINT }));
241
243
  return [heading('Terminals', width), ...body];
242
244
  }
243
- const MARK = (visited, active, id) => active.has(id) ? { glyph: '●', color: accentSgr() } : visited.has(id) ? { glyph: '✓', color: STATUS.ok } : { glyph: '○', color: FAINT };
245
+ const MARK = (visited, active, id) => active.has(id) ? { glyph: '●', color: accentSgr() } : visited.has(id) ? { glyph: '✓', color: SUBTLE } : { glyph: '○', color: FAINT };
244
246
  /**
245
247
  * The zoomed view of the graph section the run is in: what leads into the current node and
246
248
  * what it hands off to, with every node marked as visited, current, or not yet reached.
247
249
  *
248
250
  * Only a custom graph gets this: the built-in harness is a single agent node, and a zoom of
249
- * it would say nothing a `Node` row does not already say. Neighbours are capped so a hub node
251
+ * it would say nothing a `Step` row does not already say. Neighbours are capped so a hub node
250
252
  * cannot push the panel's other sections off the screen.
251
253
  */
252
254
  function graphSection(data, width) {
@@ -279,7 +281,7 @@ function graphSection(data, width) {
279
281
  const focusGlyph = active.has(focus) || visited.has(focus) || stopped ? '●' : '○';
280
282
  // A run that stopped on a node it had visited earlier is a stopped position, not a completed
281
283
  // one: the bold stopped marker outranks the historical visit.
282
- const focusColor = active.has(focus) ? accentSgr() : stopped ? ATTENTION : visited.has(focus) ? STATUS.ok : FAINT;
284
+ const focusColor = active.has(focus) ? accentSgr() : stopped ? ATTENTION : visited.has(focus) ? SUBTLE : FAINT;
283
285
  body.push(row({ text: `${focusGlyph} `, color: focusColor }, { text: clip(focusOf(focus), width - 2), color: active.has(focus) ? WHITE : GRAY }));
284
286
  // Distinct routes are distinct rows even when they lead to the same node: a QA node can hand off
285
287
  // to one End through `pass` and through `fail`, and collapsing them by target would hide one.
@@ -301,7 +303,7 @@ function graphSection(data, width) {
301
303
  /**
302
304
  * The panel's rows, top to bottom, for a terminal of `columns` x `height`.
303
305
  *
304
- * Sections are anchored: Git tools, Node, Progress and the plan read from the top, while the
306
+ * Sections are anchored: Git tools, Step, Progress and the plan read from the top, while the
305
307
  * terminal list and the graph zoom are held against the bottom - the reader asked for the graph
306
308
  * section to be at the bottom of the panel - with whatever rows the top sections leave as blank
307
309
  * space between them, so a tall terminal does not park the zoom in the middle of the screen.
@@ -0,0 +1,82 @@
1
+ import type { Config } from './config.js';
2
+ import type { ProviderConfig } from './providers.js';
3
+ /**
4
+ * Finding the vendor CLIs a person is already signed in to, and turning the ones they pick into
5
+ * provider entries.
6
+ *
7
+ * These four provider types run through the CLI's own login, so nothing here reads, copies or stores
8
+ * a credential: detection asks each CLI what it would tell its own user, and an import writes a
9
+ * configuration entry that names the type. Only display text and model ids leave this module.
10
+ */
11
+ export declare const DETECTABLE_SIGN_IN_TYPES: readonly ["claude", "codex", "grok", "opencode"];
12
+ export type DetectableSignInType = typeof DETECTABLE_SIGN_IN_TYPES[number];
13
+ export declare function isDetectableSignInType(value: unknown): value is DetectableSignInType;
14
+ /** One signed-in CLI with no provider yet. `model` is the preselection; OpenCode never has one. */
15
+ export interface DetectedSignIn {
16
+ type: DetectableSignInType;
17
+ email?: string;
18
+ planType?: string;
19
+ detail?: string;
20
+ models: string[];
21
+ model?: string;
22
+ }
23
+ /** What one CLI says about itself, before any of it is trusted for display. */
24
+ export interface SignInProbe {
25
+ signedIn: boolean;
26
+ email?: string;
27
+ planType?: string;
28
+ detail?: string;
29
+ models: string[];
30
+ defaultModel?: string;
31
+ }
32
+ export type SignInProbes = Record<DetectableSignInType, (signal: AbortSignal) => Promise<SignInProbe>>;
33
+ export interface DetectOptions {
34
+ /** Types to leave alone: no process is started for them. Unknown names are ignored. */
35
+ skip?: readonly string[];
36
+ probes?: Partial<SignInProbes>;
37
+ /** The bound on each probe; the slowest reader bounds itself at 45 seconds. */
38
+ timeoutMs?: number;
39
+ }
40
+ export interface DetectionResult {
41
+ signIns: DetectedSignIn[];
42
+ timedOut: DetectableSignInType[];
43
+ }
44
+ /**
45
+ * The readers the product already uses, each behind a look for its executable.
46
+ *
47
+ * The resolvers only inspect the machine — none installs or downloads — so a CLI that is absent
48
+ * answers signed-out without a process being started for it.
49
+ */
50
+ export declare function defaultSignInProbes(): SignInProbes;
51
+ /**
52
+ * Ask every CLI that has no provider yet whether it is signed in.
53
+ *
54
+ * Each probe stands alone: one that fails, is absent or outlives the bound contributes nothing and
55
+ * never fails the call. A type that already has a provider is not asked — for Codex that is any
56
+ * Codex provider, since a second one is always given a fresh, signed-out account slot.
57
+ */
58
+ export declare function detectSignIns(config: Pick<Config, 'providers'>, signal: AbortSignal, options?: DetectOptions): Promise<DetectionResult>;
59
+ export interface SignInImport {
60
+ type: DetectableSignInType;
61
+ model: string;
62
+ }
63
+ /** The provider entry for one detected sign-in with the model the person chose from its catalog. */
64
+ export declare function importedProvider(detected: DetectedSignIn, model: string, taken: (id: string) => boolean): ProviderConfig;
65
+ /**
66
+ * Whether the active provider could start a task as configured. Only two things say it could not:
67
+ * there is no active provider, or it names a key variable that is unset and holds no saved key. A
68
+ * provider that asks for no key at all (a local server, a private gateway) is someone's deliberate
69
+ * choice and is never displaced by an import.
70
+ */
71
+ export declare function providerCanRun(config: Pick<Config, 'provider' | 'providers'>, env?: NodeJS.ProcessEnv): boolean;
72
+ /**
73
+ * The configuration after importing the chosen sign-ins.
74
+ *
75
+ * A type that gained a provider since detection is skipped rather than duplicated: the file is
76
+ * shared with other windows and the CLI. The first entry added becomes the active provider only
77
+ * when the current one could not start a task.
78
+ */
79
+ export declare function applySignInImports(config: Config, detected: readonly DetectedSignIn[], imports: readonly SignInImport[], env?: NodeJS.ProcessEnv): {
80
+ config: Config;
81
+ added: string[];
82
+ };
@@ -0,0 +1,197 @@
1
+ import { resolveClaudeExecutable } from './claude-executable.js';
2
+ import { readClaudeCatalog, readClaudeSignIn } from './claude-provider.js';
3
+ import { resolveCliExecutable } from './cli-executable.js';
4
+ import { readCodexModels } from './codex-auth.js';
5
+ import { resolveCodexExecutable } from './codex-executable.js';
6
+ import { connectCodex } from './codex-rpc.js';
7
+ import { GROK_BASE_URL, GROK_EXECUTABLE, readGrokCatalog } from './grok-provider.js';
8
+ import { OPENCODE_BASE_URL, OPENCODE_EXECUTABLE, readOpenCodeCatalog, sharedOpenCodeServer } from './opencode-cli-provider.js';
9
+ import { uniqueProviderId } from './provider-import.js';
10
+ /**
11
+ * Finding the vendor CLIs a person is already signed in to, and turning the ones they pick into
12
+ * provider entries.
13
+ *
14
+ * These four provider types run through the CLI's own login, so nothing here reads, copies or stores
15
+ * a credential: detection asks each CLI what it would tell its own user, and an import writes a
16
+ * configuration entry that names the type. Only display text and model ids leave this module.
17
+ */
18
+ export const DETECTABLE_SIGN_IN_TYPES = ['claude', 'codex', 'grok', 'opencode'];
19
+ export function isDetectableSignInType(value) {
20
+ return DETECTABLE_SIGN_IN_TYPES.includes(value);
21
+ }
22
+ const SIGNED_OUT = { signedIn: false, models: [] };
23
+ const MAX_MODELS = 5000;
24
+ /** OpenCode lists every model of every upstream provider it has connected; no entry stores all of them. */
25
+ const FIXED_BASE_URL = {
26
+ claude: 'https://api.anthropic.com', codex: 'https://chatgpt.com/backend-api/codex', grok: GROK_BASE_URL, opencode: OPENCODE_BASE_URL,
27
+ };
28
+ const DISPLAY_NAME = { claude: 'Claude', codex: 'ChatGPT', grok: 'Grok', opencode: 'OpenCode' };
29
+ /**
30
+ * The readers the product already uses, each behind a look for its executable.
31
+ *
32
+ * The resolvers only inspect the machine — none installs or downloads — so a CLI that is absent
33
+ * answers signed-out without a process being started for it.
34
+ */
35
+ export function defaultSignInProbes() {
36
+ const present = async (resolve) => { try {
37
+ await resolve();
38
+ return true;
39
+ }
40
+ catch {
41
+ return false;
42
+ } };
43
+ return {
44
+ claude: async (signal) => {
45
+ if (!await present(() => resolveClaudeExecutable()))
46
+ return SIGNED_OUT;
47
+ // Side by side rather than one after the other: each is its own CLI start, and the TUI's whole
48
+ // look is bounded in seconds.
49
+ const [account, catalog] = await Promise.all([readClaudeSignIn(signal), readClaudeCatalog(signal)]);
50
+ if (!account.signedIn || !catalog.signedIn)
51
+ return SIGNED_OUT;
52
+ const { models } = catalog;
53
+ return { signedIn: true, models, ...(account.email ? { email: account.email } : {}), ...(account.planType ? { planType: account.planType } : {}) };
54
+ },
55
+ codex: async (signal) => {
56
+ if (!await present(() => resolveCodexExecutable({ signal })))
57
+ return SIGNED_OUT;
58
+ // The default home: a detected login is the one the person's own codex command uses. The
59
+ // connection is this probe's own and follows its signal, so a look that is abandoned stops the
60
+ // app-server it started instead of leaving it to finish on its own clock.
61
+ const rpc = await connectCodex(signal);
62
+ try {
63
+ const account = (await rpc.request('account/read', { refreshToken: false }))?.account;
64
+ if (account?.type !== 'chatgpt')
65
+ return SIGNED_OUT;
66
+ const models = await readCodexModels(rpc);
67
+ signal.throwIfAborted();
68
+ const preferred = models.find(model => model.isDefault)?.id;
69
+ return { signedIn: true, models: models.map(model => model.id), ...(preferred ? { defaultModel: preferred } : {}),
70
+ ...(typeof account.email === 'string' ? { email: account.email } : {}), ...(typeof account.planType === 'string' ? { planType: account.planType } : {}) };
71
+ }
72
+ finally {
73
+ rpc.close();
74
+ }
75
+ },
76
+ grok: async (signal) => {
77
+ if (!await present(() => resolveCliExecutable(GROK_EXECUTABLE)))
78
+ return SIGNED_OUT;
79
+ const catalog = await readGrokCatalog(signal);
80
+ return { signedIn: catalog.signedIn, models: catalog.models, ...(catalog.email ? { email: catalog.email } : {}) };
81
+ },
82
+ opencode: async (signal) => {
83
+ if (!await present(() => resolveCliExecutable(OPENCODE_EXECUTABLE)))
84
+ return SIGNED_OUT;
85
+ const catalog = await readOpenCodeCatalog(signal, sharedOpenCodeServer());
86
+ const count = catalog.connected.length;
87
+ return { signedIn: count > 0, models: catalog.models.map(model => model.id), detail: `${count} provider${count === 1 ? '' : 's'} connected` };
88
+ },
89
+ };
90
+ }
91
+ function displayText(value, max) {
92
+ return typeof value === 'string' && value.trim() && value.length <= max && !/[\u0000-\u001f\u007f]/.test(value) ? value : undefined;
93
+ }
94
+ function usableModels(models) {
95
+ const kept = [];
96
+ if (!Array.isArray(models))
97
+ return kept;
98
+ for (const model of models) {
99
+ if (kept.length >= MAX_MODELS)
100
+ break;
101
+ if (typeof model === 'string' && model.trim() && model.length <= 500 && !/[\u0000-\u001f\u007f]/.test(model) && !kept.includes(model))
102
+ kept.push(model);
103
+ }
104
+ return kept;
105
+ }
106
+ function describe(type, probe) {
107
+ if (probe.signedIn !== true)
108
+ return undefined;
109
+ const models = usableModels(probe.models);
110
+ if (!models.length)
111
+ return undefined;
112
+ const email = displayText(probe.email, 320);
113
+ const planType = displayText(probe.planType, 100);
114
+ const detail = displayText(probe.detail, 200);
115
+ // OpenCode's catalog spans upstream providers the person may pay for per use: choosing one is theirs.
116
+ const model = type === 'opencode' ? undefined : probe.defaultModel !== undefined && models.includes(probe.defaultModel) ? probe.defaultModel : models[0];
117
+ return { type, ...(email ? { email } : {}), ...(planType ? { planType } : {}), ...(detail ? { detail } : {}), models, ...(model ? { model } : {}) };
118
+ }
119
+ /**
120
+ * Ask every CLI that has no provider yet whether it is signed in.
121
+ *
122
+ * Each probe stands alone: one that fails, is absent or outlives the bound contributes nothing and
123
+ * never fails the call. A type that already has a provider is not asked — for Codex that is any
124
+ * Codex provider, since a second one is always given a fresh, signed-out account slot.
125
+ */
126
+ export async function detectSignIns(config, signal, options = {}) {
127
+ const probes = { ...(options.probes && DETECTABLE_SIGN_IN_TYPES.every(type => options.probes?.[type]) ? {} : defaultSignInProbes()), ...options.probes };
128
+ const timeoutMs = options.timeoutMs ?? 45_000;
129
+ const timedOut = [];
130
+ const wanted = DETECTABLE_SIGN_IN_TYPES.filter(type => !options.skip?.includes(type) && !config.providers.some(provider => provider.type === type));
131
+ const found = await Promise.all(wanted.map(async (type) => {
132
+ const deadline = AbortSignal.timeout(timeoutMs);
133
+ const bounded = AbortSignal.any([signal, deadline]);
134
+ try {
135
+ const probe = await new Promise((resolve, reject) => {
136
+ // A reader that ignores its signal must not hold the call past the bound.
137
+ bounded.addEventListener('abort', () => reject(new Error('aborted')), { once: true });
138
+ if (bounded.aborted) {
139
+ reject(new Error('aborted'));
140
+ return;
141
+ }
142
+ probes[type](bounded).then(resolve, reject);
143
+ });
144
+ return describe(type, probe);
145
+ }
146
+ catch {
147
+ if (deadline.aborted && !signal.aborted)
148
+ timedOut.push(type);
149
+ return undefined;
150
+ }
151
+ }));
152
+ return { signIns: found.filter((item) => item !== undefined), timedOut: DETECTABLE_SIGN_IN_TYPES.filter(type => timedOut.includes(type)) };
153
+ }
154
+ /** The provider entry for one detected sign-in with the model the person chose from its catalog. */
155
+ export function importedProvider(detected, model, taken) {
156
+ if (!detected.models.includes(model))
157
+ throw new Error(`${model} is not one of the models ${DISPLAY_NAME[detected.type]} lists.`);
158
+ const models = detected.type === 'opencode' ? [model] : [model, ...detected.models.filter(item => item !== model)];
159
+ return { id: uniqueProviderId(taken, detected.type), type: detected.type, baseUrl: FIXED_BASE_URL[detected.type], model, models, name: DISPLAY_NAME[detected.type] };
160
+ }
161
+ /**
162
+ * Whether the active provider could start a task as configured. Only two things say it could not:
163
+ * there is no active provider, or it names a key variable that is unset and holds no saved key. A
164
+ * provider that asks for no key at all (a local server, a private gateway) is someone's deliberate
165
+ * choice and is never displaced by an import.
166
+ */
167
+ export function providerCanRun(config, env = process.env) {
168
+ const active = config.providers.find(provider => provider.id === config.provider);
169
+ if (!active)
170
+ return false;
171
+ return !(active.apiKeyEnv && !env[active.apiKeyEnv] && !active.apiKey);
172
+ }
173
+ /**
174
+ * The configuration after importing the chosen sign-ins.
175
+ *
176
+ * A type that gained a provider since detection is skipped rather than duplicated: the file is
177
+ * shared with other windows and the CLI. The first entry added becomes the active provider only
178
+ * when the current one could not start a task.
179
+ */
180
+ export function applySignInImports(config, detected, imports, env = process.env) {
181
+ const providers = [...config.providers];
182
+ const added = [];
183
+ for (const choice of imports) {
184
+ const found = detected.find(item => item.type === choice.type);
185
+ if (!found)
186
+ throw new Error(`${DISPLAY_NAME[choice.type] ?? 'That tool'} was not detected as signed in.`);
187
+ const entry = importedProvider(found, choice.model, id => providers.some(provider => provider.id === id));
188
+ if (providers.some(provider => provider.type === choice.type))
189
+ continue;
190
+ providers.push(entry);
191
+ added.push(entry.id);
192
+ }
193
+ const next = { ...config, providers };
194
+ if (added.length && !providerCanRun(config, env))
195
+ next.provider = added[0];
196
+ return { config: next, added };
197
+ }
@@ -0,0 +1,35 @@
1
+ import { type DetectionResult } from './sign-in-detection.js';
2
+ /**
3
+ * The terminal's one-time offer to add the vendor CLIs a person is already signed in to.
4
+ *
5
+ * It runs before the interface starts, the way the update offer does, so it is bounded hard: the
6
+ * tools get eight seconds between them, and a tool that does not answer in time is tried again on
7
+ * the next launch, three launches at most. Nothing here may fail startup.
8
+ */
9
+ export interface SignInOfferState {
10
+ done?: boolean;
11
+ attempts?: number; /** Tools already answered about while another was still being retried. */
12
+ answered?: string[];
13
+ }
14
+ export declare function readSignInOfferState(home?: string): Promise<SignInOfferState>;
15
+ export declare function writeSignInOfferState(state: SignInOfferState, home?: string): Promise<void>;
16
+ /**
17
+ * What a typed answer chooses among `count` listed accounts: every index for an empty answer or
18
+ * yes, `'none'` for no, the named ones for numbers, and undefined for anything else.
19
+ */
20
+ export declare function parseSignInAnswer(answer: string, count: number): number[] | 'none' | undefined;
21
+ export interface SignInOfferOptions {
22
+ home?: string;
23
+ env?: NodeJS.ProcessEnv;
24
+ ask: (question: string) => Promise<string>;
25
+ write: (text: string) => void;
26
+ /** Overridable so a test never spawns a CLI. */
27
+ detect?: (home: string, signal: AbortSignal, skip: readonly string[]) => Promise<DetectionResult>;
28
+ }
29
+ /**
30
+ * Offer once per configuration home. Returns the ids of the providers added; never throws.
31
+ *
32
+ * OpenCode is named but never added here: its models span upstream providers that may bill per use,
33
+ * and choosing one is what the `/providers` screen is for.
34
+ */
35
+ export declare function offerSignInImport(options: SignInOfferOptions): Promise<string[]>;