@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
@@ -14,6 +14,21 @@ export const RESPONSE_STRUCTURE_GUIDANCE = `Write user-facing text, including th
14
14
  * breaks are wanted, next to the value they shape.
15
15
  */
16
16
  export const SUMMARY_DESCRIPTION = 'Markdown shown to the user as the final answer. Write line breaks as \\n escapes: lead with the outcome, then short headings and bullet lists, and open and close each fenced code block on its own line. Never one unbroken paragraph.';
17
+ /** Entries kept from a completion's `remaining` list. */
18
+ export const REMAINING_LIMIT = 20;
19
+ /**
20
+ * The completion states, as data rather than somewhere in its prose, what the task still lacks.
21
+ * A summary that said "frame output still missing" ended a run with time on the clock, because
22
+ * nothing the host could read told it the task was unfinished (completion-gates.ts).
23
+ */
24
+ export const REMAINING_DESCRIPTION = 'Everything the task asks for that is still missing, failing or unverified, one short entry each. [] only when every requirement is met and you have checked it. Be exact: this is read by the runtime, not only by the user.';
25
+ /** The `remaining` entries of a completion envelope: nonempty strings, bounded, or undefined when it has none. */
26
+ function remainingItems(value) {
27
+ if (!Array.isArray(value))
28
+ return undefined;
29
+ const items = value.filter((item) => typeof item === 'string' && item.trim().length > 0).slice(0, REMAINING_LIMIT).map(item => item.slice(0, 500));
30
+ return items.length ? items : undefined;
31
+ }
17
32
  export const COMPLETION_GUIDANCE = `Finish with complete_agent alone or final JSON. Todos/artifacts do not finish a node. Compare deliverables and verification evidence with acceptance criteria. Fulfill assigned requirements: intake/research nodes hand off downstream work; implementation nodes finish implementation and verification, not a progress checkpoint. Continue available work. For a concrete external blocker, report the blocker and unfinished work honestly. Use a blocked outcome if available; otherwise the sole outcome permits a terminal report, not a claim that the task is done. ${FINAL_RESPONSE_GUIDANCE} Preserve required fields and valid JSON; escape quotes and Windows backslashes or use C:/repo/file.ts, and write each summary line break as \\n rather than dropping it. Never claim unperformed work.`;
18
33
  /** Expand Andorra's artifact shorthand into provider-visible JSON Schema at every depth. */
19
34
  function providerOutputSchema(schema) {
@@ -73,6 +88,9 @@ export function completionTool(options) {
73
88
  type: 'object',
74
89
  properties: {
75
90
  summary: { type: 'string', description: SUMMARY_DESCRIPTION }, tests: { type: 'array', items: { type: 'string', description: 'One short line: the check that ran, then its outcome.' } },
91
+ // Only the completion that ends a run carries it: a node that hands off to another node
92
+ // reports through its outcome and output, and its schema stays as it was.
93
+ ...(options.finalAnswerOutcomes?.length ? { remaining: { type: 'array', maxItems: REMAINING_LIMIT, items: { type: 'string' }, description: REMAINING_DESCRIPTION } } : {}),
76
94
  ...(outcomes ? { artifacts: { type: 'array', maxItems: 50, items: { type: 'object', properties: { type: { type: 'string' }, ref: { type: 'string' } }, required: ['type', 'ref'], additionalProperties: false } } } : {}),
77
95
  ...(outcomes ? { outcome: { type: 'string', enum: outcomes }, output: providerOutputSchema(options.outputSchema ?? { type: 'object' }) } : {}),
78
96
  },
@@ -247,7 +265,8 @@ function parseCompletionJson(text, stopReason, notes) {
247
265
  * line breaks belong, and the transcript draws its markdown as one literal paragraph.
248
266
  *
249
267
  * Two shapes are decoded. A summary escaped throughout has no real line break and at least two
250
- * escaped paragraph breaks; every escape in it is undone. A model can also switch to the extra
268
+ * escaped paragraph breaks, or at least two escaped breaks outside code that open markdown
269
+ * structure (one paragraph break and a list is enough); every escape in it is undone. A model can also switch to the extra
251
270
  * escaping partway through, leaving a few real line breaks and the rest escaped: one `## heading`
252
271
  * then swallows everything after it. That mixed summary is decoded only when at least two escaped
253
272
  * breaks outside code open markdown structure (a heading, list item, quote, table, fence, or a
@@ -260,7 +279,9 @@ function parseCompletionJson(text, stopReason, notes) {
260
279
  */
261
280
  export function decodeDoubleEscapedSummary(summary, notes) {
262
281
  if (!summary.includes('\n')) {
263
- if ((summary.match(/\\n\\n/g)?.length ?? 0) < 2)
282
+ // One escaped paragraph break followed by an escaped list ("Done.\n\nReport:\n- a\n- b") is as
283
+ // clearly layout as two paragraph breaks, so escaped structure outside code counts too.
284
+ if ((summary.match(/\\n\\n/g)?.length ?? 0) < 2 && escapedStructureCount(summary) < 2)
264
285
  return summary;
265
286
  notes?.push('completion summary arrived with its newlines escaped twice and was decoded');
266
287
  const decoded = { n: '\n', r: '\r', t: '\t', '"': '"', '\\': '\\' };
@@ -289,6 +310,15 @@ export function decodeDoubleEscapedSummary(summary, notes) {
289
310
  // `\\` is matched as a unit and kept, so an escaped backslash before an "n" is never read as a break.
290
311
  return mapOutsideCode(summary, (prose, line) => prose.replace(/\\(\\|n|")/g, (escape, char) => char === '"' ? '"' : char === 'n' && structuralLines.has(line) ? '\n' : escape));
291
312
  }
313
+ /** How many escaped breaks outside code open markdown structure, as the mixed-summary scan counts them. */
314
+ function escapedStructureCount(summary) {
315
+ let count = 0;
316
+ mapOutsideCode(summary, (prose, _line, beforeCode) => {
317
+ count += (beforeCode ? `${prose}\`` : prose).match(ESCAPED_STRUCTURE)?.length ?? 0;
318
+ return prose;
319
+ });
320
+ return count;
321
+ }
292
322
  /**
293
323
  * An escaped break that stands for markdown structure: a whole run of `\n` before a block opener,
294
324
  * or a whole run of two or more before text. "Regex \n\n matches" (a run before a space) is prose,
@@ -540,6 +570,135 @@ function rejectEmbeddedEnvelope(summary) {
540
570
  throw new Error(`Completion summary contains the completion envelope itself (its "${field}" field and what follows were written inside the summary string). Send summary, tests, outcome and output as separate complete_agent arguments: summary holds only the answer text in markdown, with no JSON fields after it.`);
541
571
  return summary;
542
572
  }
573
+ /** Where a completion envelope written as text could begin. */
574
+ const ENVELOPE_START = /\{\s*"summary"\s*:/g;
575
+ /**
576
+ * Replace a completion envelope a model wrote as message text, so the transcript never shows raw
577
+ * JSON. Two live shapes, both glm-5.3-flash on GX10:
578
+ * - Run 3a8378f0 ended a QA report with "Submitting the report." and then the whole envelope as
579
+ * text, `{"summary":"…\n\n## 1. Target…","tests":[…],"prUrl":"…"}`, about 12 KB, instead of
580
+ * calling complete_agent. The runtime rightly sent it back; the caller passes a `note` saying so,
581
+ * which stands in for the envelope (the report itself arrives later through complete_agent).
582
+ * - Session bbedcfbf narrated beside its tool calls as `{"summary":"Starting the PR comment fixer
583
+ * round…","tests":[]}`. With no `note`, the envelope's summary stands in for it, decoded like a
584
+ * completion's, so the narration still reads as prose.
585
+ *
586
+ * Only an envelope that ends the text is replaced: a JSON object whose `summary` is a string, which
587
+ * parses on its own from its opening brace to the end of the text (closing brackets the model left
588
+ * off are supplied, as for a completion), bare or as the whole of a final fenced block. One shown in
589
+ * inline code, one followed by more prose, and otherwise malformed JSON are left as written.
590
+ */
591
+ export function withoutTrailingEnvelope(text, note) {
592
+ for (const match of text.matchAll(ENVELOPE_START)) {
593
+ let before = text.slice(0, match.index);
594
+ let rest = text.slice(match.index).trimEnd();
595
+ const fence = /(?:^|\n) {0,3}(`{3,}|~{3,})[\w-]*[ \t]*\n$/.exec(before);
596
+ if (fence) {
597
+ const closer = new RegExp(`\\n {0,3}${fence[1][0] === '`' ? '`' : '~'}{${fence[1].length},}$`).exec(rest);
598
+ if (!closer)
599
+ continue;
600
+ rest = rest.slice(0, closer.index);
601
+ before = before.slice(0, fence.index);
602
+ }
603
+ // The parser closes an envelope the model left one or two brackets short, which is how run
604
+ // 3a8378f0 ended (its `output` object never closed). Its other repair, dropping text after a
605
+ // whole envelope, is refused here: prose after the JSON means the envelope does not end the text.
606
+ let value;
607
+ const repairs = [];
608
+ try {
609
+ value = parseCompletionJson(rest, undefined, repairs);
610
+ }
611
+ catch {
612
+ continue;
613
+ }
614
+ if (repairs.some(note => note.includes('after its closing brace')))
615
+ continue;
616
+ const summary = value && typeof value === 'object' && !Array.isArray(value) ? value.summary : undefined;
617
+ if (typeof summary !== 'string')
618
+ continue;
619
+ return [before.trimEnd(), note ?? decodeDoubleEscapedSummary(summary).trim()].filter(Boolean).join('\n\n');
620
+ }
621
+ return text;
622
+ }
623
+ /**
624
+ * A completion field the model echoed as a plain-text line at the end of its summary
625
+ * (`outcome: completed`). Bold or backticked keys (`**tests:**`, `` `outcome`: ``) count too, but a
626
+ * backtick must close right after the key: `` `outcome: completed` `` is an example in inline code,
627
+ * not an echoed field.
628
+ */
629
+ const ECHOED_FIELD_LINE = /^\s*(?:[-*+]\s+)?(?:\*\*|__)?(?:`(summary|tests|outcome|output|artifacts|remaining)`|(summary|tests|outcome|output|artifacts|remaining))(?:\*\*|__)?\s*:(?:\*\*|__)?\s*(.*)$/i;
630
+ /** A line that continues the echoed field above it: a list item or indented text under `tests:`. */
631
+ const ECHOED_CONTINUATION = /^\s*(?:[-*+]\s|\d+[.)]\s|\s{2,}\S)/;
632
+ /**
633
+ * Remove the completion fields a model copied into the end of its summary as text. Some models
634
+ * call complete_agent with every field set and then also write the same fields out under the
635
+ * answer:
636
+ *
637
+ * Browser is open.
638
+ *
639
+ * summary: Browser panel opened successfully on example.com.
640
+ * tests: none — no checks were required.
641
+ * outcome: completed
642
+ * output: {}
643
+ *
644
+ * The transcript draws the summary as the answer, so those lines reached the user as a raw field
645
+ * dump. Unlike an embedded JSON envelope (`rejectEmbeddedEnvelope`), the arguments themselves are
646
+ * intact, so there is nothing for a retry to repair: the trailing block is dropped and recorded.
647
+ *
648
+ * Only a block at the very end is touched, outside code, after a blank line (or making up the whole
649
+ * summary), in which every line is a field line or continues one, and which holds an `outcome:` line
650
+ * and at least one other field. When the completion carries an outcome, the echoed line must name
651
+ * that same outcome, so an answer that ends on "Tests: 12 passed" and "Output: dist/" is not an echo.
652
+ * A summary that shows the fields in a code block is left as written. When the block is the whole
653
+ * summary, its `summary:` field, with the lines under it, becomes the answer.
654
+ */
655
+ export function stripEchoedEnvelope(summary, outcome, notes) {
656
+ const lines = summary.replace(/\s+$/, '').split('\n');
657
+ const code = codeBlockLines(lines);
658
+ const fields = new Set();
659
+ let echoedSummary;
660
+ let echoedOutcome;
661
+ let start = lines.length;
662
+ let sawField = false;
663
+ // Lines under the field above them, collected while scanning upward until that field is reached.
664
+ let continuation = [];
665
+ for (let index = lines.length - 1; index >= 0; index -= 1) {
666
+ const line = lines[index];
667
+ if (line.trim() === '')
668
+ break;
669
+ if (code[index])
670
+ return summary;
671
+ const field = ECHOED_FIELD_LINE.exec(line);
672
+ if (field) {
673
+ const key = (field[1] ?? field[2]).toLowerCase();
674
+ fields.add(key);
675
+ if (key === 'summary')
676
+ echoedSummary = [field[3], ...continuation].join('\n').trim();
677
+ if (key === 'outcome')
678
+ echoedOutcome = field[3].replace(/[`*_"'.]/g, '').trim().toLowerCase();
679
+ sawField = true;
680
+ continuation = [];
681
+ }
682
+ else if (ECHOED_CONTINUATION.test(line))
683
+ continuation.unshift(line);
684
+ else
685
+ return summary;
686
+ start = index;
687
+ }
688
+ // The block's first line must be a field: a list that only continues prose above is not an echo.
689
+ if (!sawField || !ECHOED_FIELD_LINE.test(lines[start] ?? ''))
690
+ return summary;
691
+ if (fields.size < 2 || echoedOutcome === undefined)
692
+ return summary;
693
+ if (outcome !== undefined && echoedOutcome !== outcome.toLowerCase())
694
+ return summary;
695
+ const kept = lines.slice(0, start).join('\n').replace(/\s+$/, '');
696
+ const answer = kept || echoedSummary?.replace(/^\*\*|\*\*$/g, '').trim();
697
+ if (!answer)
698
+ return summary;
699
+ notes?.push(`completion summary ended with its own ${[...fields].join(', ')} fields written out as text, removed by the host`);
700
+ return answer;
701
+ }
543
702
  /**
544
703
  * Parse one completion, accepting mechanically imperfect envelopes that are semantically correct.
545
704
  *
@@ -623,14 +782,14 @@ export function parseCompletion(text, options, reject, notes, stopReason) {
623
782
  // serialized, and an output field named `tests` is legitimate there.
624
783
  if (written === undefined)
625
784
  notes?.push(OUTPUT_STOOD_IN_NOTE);
626
- const summary = written === undefined ? decodeDoubleEscapedSummary(JSON.stringify(output).slice(0, 2000), notes) : rejectEmbeddedEnvelope(decodeDoubleEscapedSummary(written, notes));
785
+ const summary = written === undefined ? decodeDoubleEscapedSummary(JSON.stringify(output).slice(0, 2000), notes) : stripEchoedEnvelope(rejectEmbeddedEnvelope(decodeDoubleEscapedSummary(written, notes)), outcome, notes);
627
786
  return { summary,
628
787
  tests: Array.isArray(value.tests) && value.tests.every((item) => typeof item === 'string') ? value.tests : [], outcome, output,
629
- artifacts: value.artifacts ?? [] };
788
+ artifacts: value.artifacts ?? [], ...(remainingItems(value.remaining) ? { remaining: remainingItems(value.remaining) } : {}) };
630
789
  }
631
790
  if (value && typeof value.summary === 'string' && value.summary.trim()
632
791
  && Array.isArray(value.tests) && value.tests.every((x) => typeof x === 'string')) {
633
- return { summary: rejectEmbeddedEnvelope(decodeDoubleEscapedSummary(value.summary, notes)), tests: value.tests };
792
+ return { summary: stripEchoedEnvelope(rejectEmbeddedEnvelope(decodeDoubleEscapedSummary(value.summary, notes)), typeof value.outcome === "string" ? value.outcome : undefined, notes), tests: value.tests };
634
793
  }
635
794
  throw new Error("Completion needs a nonempty summary and a tests array of strings");
636
795
  }
@@ -44,6 +44,7 @@ export interface Config {
44
44
  memory?: MemoryConfig;
45
45
  analytics?: AnalyticsConfig;
46
46
  commandMemory?: boolean;
47
+ projectMemory?: boolean;
47
48
  jevEnabled?: boolean;
48
49
  decisions?: DecisionConfig;
49
50
  efficiency?: EfficiencyConfig;
@@ -128,6 +128,8 @@ export function validateConfig(value) {
128
128
  throw new Error('jevEnabled must be a boolean');
129
129
  if (c.commandMemory !== undefined && typeof c.commandMemory !== 'boolean')
130
130
  throw new Error('commandMemory must be a boolean');
131
+ if (c.projectMemory !== undefined && typeof c.projectMemory !== 'boolean')
132
+ throw new Error('projectMemory must be a boolean');
131
133
  if (c.systemPromptOverride !== undefined && (typeof c.systemPromptOverride !== 'string' || !c.systemPromptOverride.trim() || c.systemPromptOverride.length > MAX_SYSTEM_PROMPT_OVERRIDE)) {
132
134
  throw new Error(`systemPromptOverride must be nonempty text of up to ${MAX_SYSTEM_PROMPT_OVERRIDE} characters`);
133
135
  }
@@ -1,6 +1,6 @@
1
1
  import stringWidth from 'string-width';
2
2
  import { stripVTControlCharacters } from 'node:util';
3
- import { DIM, FAINT, GRAY, STATUS, SUBTLE, WHITE, accentSgr } from './palette.js';
3
+ import { DIM, FAINT, GRAY, SUBTLE, WHITE, accentSgr } from './palette.js';
4
4
  import { panelRowText } from './side-panel.js';
5
5
  /**
6
6
  * The dashboard (Ctrl+B): session tokens, task timing, the Todo list and the graph
@@ -202,7 +202,7 @@ export function dashboardRows(view, width, height) {
202
202
  const active = view.todos.filter(todo => todo.status === 'in_progress').length;
203
203
  const todoSummary = row(seg(`${done} done`, GRAY), seg(' · ', FAINT), seg(`${active} active`, GRAY), seg(' · ', FAINT), seg(`${view.todos.length - done - active} pending`, GRAY));
204
204
  const todoItems = [...view.todos.filter(todo => todo.status !== 'completed'), ...view.todos.filter(todo => todo.status === 'completed')];
205
- const todoRow = (todo) => todo.status === 'completed' ? row(seg('✓ ', STATUS.ok), seg(todo.text, GRAY))
205
+ const todoRow = (todo) => todo.status === 'completed' ? row(seg('✓ ', SUBTLE), seg(todo.text, GRAY))
206
206
  : todo.status === 'in_progress' ? row(seg('● ', accentSgr()), seg(todo.text, WHITE)) : row(seg('○ ', FAINT), seg(todo.text, GRAY));
207
207
  const todoBody = (size) => {
208
208
  const capacity = Math.max(0, size - 1);
@@ -153,8 +153,12 @@ export function bindUserWaits(context, budget, signal = budget.signal) {
153
153
  };
154
154
  const askUser = context.askUser;
155
155
  const approvePlan = context.approvePlan;
156
+ const waitOutside = context.waitOutside;
156
157
  return {
157
158
  ...context,
159
+ // A wait on someone outside the run (a pull request's reviewer) is no more the run's work than an answer from
160
+ // the user is. Each enclosing budget wraps the one inside it, so every clock from the run's down is paused.
161
+ waitOutside: work => awaiting(() => waitOutside ? waitOutside(work) : work()),
158
162
  signal,
159
163
  userSignal: context.userSignal ?? context.signal,
160
164
  approve: (name, args, promptSignal) => awaiting(() => context.approve(name, args, promptSignal)),
@@ -7,7 +7,7 @@ const kinds = ['investigate', 'retry', 'change_strategy', 'verify', 'complete'];
7
7
  const triggerKinds = new Set(['investigate', 'verify']);
8
8
  // Landing or dropping a delegated change is a decision taken after reviewing it, so neither can be
9
9
  // prepared ahead and run before the review.
10
- const forbidden = new Set([PREPARE_STEPS, 'complete_agent', 'update_todos', 'ask_user', 'spawn_subagent', 'accept_change', 'discard_change']);
10
+ const forbidden = new Set([PREPARE_STEPS, 'complete_agent', 'update_todos', 'ask_user', 'spawn_subagent', 'accept_change', 'discard_change', 'remove_untracked_file']);
11
11
  const object = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
12
12
  export function boundedDecisionText(text, bytes) {
13
13
  const value = redactSecrets(text).text;
@@ -10,6 +10,7 @@ import { promisify } from 'node:util';
10
10
  import { chmod, copyFile, lstat, mkdir, mkdtemp, readFile, readdir, readlink, realpath, rm, rmdir, symlink, writeFile } from 'node:fs/promises';
11
11
  import { tmpdir } from 'node:os';
12
12
  import { basename, dirname, join } from 'node:path';
13
+ import { isWindowsDeviceName } from './stray-files.js';
13
14
  const exec = promisify(execFile);
14
15
  /** Characters of a change's diff that are inlined into the spawn observation. */
15
16
  export const DELEGATION_DIFF_LIMIT = 20_000;
@@ -26,7 +27,9 @@ const REMOVE_RETRIES = { maxRetries: 5, retryDelay: 100 };
26
27
  // repository must not get to run its own programs because a subagent was spawned. safecrlf is off
27
28
  // because a snapshot takes the files as they are: with `core.safecrlf=true` Git refuses to add a
28
29
  // file whose line endings its own conversion would change, and the snapshot would fail.
29
- const HARDENED = ['-c', 'core.hooksPath=', '-c', 'core.fsmonitor=false', '-c', 'core.safecrlf=false'];
30
+ // longpaths is on because one file whose path is over Windows' 260 characters would otherwise fail
31
+ // the snapshot, and with it every delegation, until the user removed the file by hand.
32
+ const HARDENED = ['-c', 'core.hooksPath=', '-c', 'core.fsmonitor=false', '-c', 'core.safecrlf=false', '-c', 'core.longpaths=true'];
30
33
  // Patches are made with the diff-tree plumbing, not porcelain `git diff`: porcelain honours the
31
34
  // user's diff.noprefix, diff.external, colour and textconv settings, any of which turns a clean
32
35
  // merge into a patch `git apply` rejects or rewrites. Plumbing ignores them by default; the
@@ -76,10 +79,24 @@ const RUNTIME_FILES = ':(exclude,glob)**/.andorra/runtime/**';
76
79
  async function writeWorkingTree(root, start, signal) {
77
80
  return withTemporaryIndex(async (env) => {
78
81
  await git(root, ['read-tree', start], { signal, env });
79
- await git(root, ['add', '-A', '--', '.', RUNTIME_FILES], { signal, env, timeout: BULK_TIMEOUT_MS, maxBuffer: ADD_MAX_BUFFER });
82
+ const unreadable = await deviceNamedFiles(root, env, signal);
83
+ await git(root, ['add', '-A', '--', '.', RUNTIME_FILES, ...unreadable.map(path => `:(exclude,literal)${path}`)], { signal, env, timeout: BULK_TIMEOUT_MS, maxBuffer: ADD_MAX_BUFFER });
80
84
  return (await git(root, ['write-tree'], { signal, env })).trim();
81
85
  });
82
86
  }
87
+ // More names than this are left in: the exclusions travel on the command line, which Windows bounds.
88
+ const DEVICE_NAMED_LIMIT = 100;
89
+ /**
90
+ * Untracked files Windows reads as a device (`nul`, `con`), which Git cannot open there: adding one
91
+ * fails the whole `git add`. Such a file is a shell accident, never work, and nothing on Windows can
92
+ * write one through an ordinary path, so every tree made here leaves it out the same way.
93
+ */
94
+ async function deviceNamedFiles(root, env, signal) {
95
+ if (process.platform !== 'win32')
96
+ return [];
97
+ const untracked = await git(root, ['ls-files', '-o', '--exclude-standard', '-z', '--', '.', RUNTIME_FILES], { signal, env, timeout: BULK_TIMEOUT_MS, maxBuffer: ADD_MAX_BUFFER });
98
+ return untracked.split('\0').filter(path => path && path.split('/').some(isWindowsDeviceName)).slice(0, DEVICE_NAMED_LIMIT);
99
+ }
83
100
  /** A dangling commit holding `tree`; it is never referenced by a ref. */
84
101
  async function commitTree(root, tree, parent, message, signal) {
85
102
  return (await git(root, ['commit-tree', tree, '-p', parent, '-m', message], { signal, env: SNAPSHOT_IDENTITY })).trim();
@@ -2,5 +2,6 @@ export interface FileChangePreview {
2
2
  text: string;
3
3
  detail?: string;
4
4
  }
5
+ export declare function registerEditArgumentPreparer(prepare: ((args: Record<string, unknown>) => unknown) | undefined): void;
5
6
  /** Proposed tool arguments only: writes may overwrite an existing file. */
6
7
  export declare function formatFileChange(name: string, args: Record<string, unknown>): FileChangePreview | undefined;
@@ -1,12 +1,21 @@
1
1
  import { stripVTControlCharacters } from 'node:util';
2
2
  import { clipText } from './text.js';
3
3
  import { canonicalToolName } from './tool-names.js';
4
- import { andorraCreateEditTool } from '../vendor/engine/runtime/coding-agent/core/tools/edit.js';
5
4
  const PREVIEW_LINES = 12;
6
5
  const DETAIL_LINES = 200;
7
6
  const LINE_WIDTH = 300;
8
- // Construction only defines metadata. Previewing never invokes the tool executor.
9
- const prepareEditArguments = andorraCreateEditTool('.').prepareArguments;
7
+ /**
8
+ * The edit tool's own argument normalizer, registered by the coding tools when they load.
9
+ *
10
+ * Importing the vendored edit tool here would load its schema library with every transcript
11
+ * renderer, including the first terminal frame. An `edit` call only exists once the coding tools
12
+ * have been created, and they register the normalizer as they load, so a preview never needs it
13
+ * earlier; a call rendered before that (a resumed transcript) previews its arguments as written.
14
+ */
15
+ let prepareEditArguments;
16
+ export function registerEditArgumentPreparer(prepare) {
17
+ prepareEditArguments = prepare;
18
+ }
10
19
  /** Keep file content from controlling the terminal or disguising diff markers. */
11
20
  function printable(value) {
12
21
  return stripVTControlCharacters(value)
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The vendored provider SDK adapters, loaded on the first model request instead of at startup.
3
+ *
4
+ * Each adapter imports its vendor SDK (`openai`, `@anthropic-ai/sdk`, `@google/genai` and the
5
+ * Google auth stack behind it), several hundred files between them. Nothing before the first model
6
+ * call needs them, so importing them statically made every launch — including `andorra --version`
7
+ * and the first terminal frame — wait for the whole set to resolve and compile. The promise is
8
+ * shared, so concurrent first requests load the set once.
9
+ */
10
+ type Completions = typeof import('../vendor/engine/runtime/ai/api/openai-completions.js');
11
+ type Responses = typeof import('../vendor/engine/runtime/ai/api/openai-responses.js');
12
+ type Messages = typeof import('../vendor/engine/runtime/ai/api/anthropic-messages.js');
13
+ type GoogleShared = typeof import('../vendor/engine/runtime/ai/api/google-shared.js');
14
+ export interface EngineStreams {
15
+ chatStream: Completions['andorraStream'];
16
+ responsesStream: Responses['andorraStream'];
17
+ messagesStream: Messages['andorraStream'];
18
+ convertGoogleMessages: GoogleShared['andorraConvertMessages'];
19
+ convertGoogleTools: GoogleShared['andorraConvertTools'];
20
+ }
21
+ export declare function loadEngineStreams(): Promise<EngineStreams>;
22
+ export {};
@@ -0,0 +1,16 @@
1
+ let loading;
2
+ export function loadEngineStreams() {
3
+ loading ??= Promise.all([
4
+ import('../vendor/engine/runtime/ai/api/openai-completions.js'),
5
+ import('../vendor/engine/runtime/ai/api/openai-responses.js'),
6
+ import('../vendor/engine/runtime/ai/api/anthropic-messages.js'),
7
+ import('../vendor/engine/runtime/ai/api/google-shared.js'),
8
+ ]).then(([completions, responses, messages, google]) => ({
9
+ chatStream: completions.andorraStream,
10
+ responsesStream: responses.andorraStream,
11
+ messagesStream: messages.andorraStream,
12
+ convertGoogleMessages: google.andorraConvertMessages,
13
+ convertGoogleTools: google.andorraConvertTools,
14
+ }), error => { loading = undefined; throw error; });
15
+ return loading;
16
+ }
@@ -9,6 +9,7 @@ import { acquireSaveLock, SaveLockBusyError } from './save-lock.js';
9
9
  import { configDirectory, validateMcpServer } from './config.js';
10
10
  export { validateMcpServer } from './config.js';
11
11
  import { resolveBuiltinSkill } from './skills/invocable-skills.js';
12
+ import { bundledSkillCatalog, bundledSkillDirectory } from './skills/runtime-skills.js';
12
13
  import { isBuiltinSlashCommand } from './skill-commands.js';
13
14
  const unzip = promisify(gunzip);
14
15
  const MAX_ARCHIVE_BYTES = 64 * 1024 * 1024;
@@ -539,12 +540,22 @@ export async function installBundle(kind, source, config, signal, directory = co
539
540
  await rm(stage, { recursive: true, force: true });
540
541
  }
541
542
  }
542
- async function skillEntry(id, config, directory, signal) {
543
+ async function skillEntry(id, config, directory, allowBuiltin = false) {
543
544
  skillIdValid(id);
544
- const found = (await listBundles('skills', config, { directory, signal })).find(item => item.id === id);
545
- if (!found)
545
+ const found = (await listBundles('skills', config, { directory })).find(item => item.id === id);
546
+ if (found)
547
+ return found;
548
+ // Andorra's own skills are not installed bundles, but their files ship with this package; serving
549
+ // them keeps a client's skill view consistent with what a run can load. Only listing and reading
550
+ // resolve them; writes and removals stay installed-only, so a client cannot edit files inside
551
+ // this package.
552
+ if (!allowBuiltin)
546
553
  throw new Error('Skill is unavailable');
547
- return found;
554
+ const base = bundledSkillDirectory(id);
555
+ if (!base)
556
+ throw new Error('Skill is unavailable');
557
+ const catalog = bundledSkillCatalog().find(item => item.id === id);
558
+ return { id, name: id.split(':').at(-1) ?? id, description: catalog?.description ?? 'Built-in skill', enabled: true, path: base };
548
559
  }
549
560
  function resourceTarget(skill, path) {
550
561
  if (!path || isAbsolute(path) || /[\0]/.test(path))
@@ -556,7 +567,7 @@ function resourceTarget(skill, path) {
556
567
  return { base, target };
557
568
  }
558
569
  export async function listSkillResources(id, config, directory = configDirectory()) {
559
- const skill = await skillEntry(id, config, directory);
570
+ const skill = await skillEntry(id, config, directory, true);
560
571
  const paths = [];
561
572
  let count = 0;
562
573
  const base = skill.repository?.path ?? skill.path;
@@ -578,7 +589,7 @@ export async function listSkillResources(id, config, directory = configDirectory
578
589
  return paths.sort();
579
590
  }
580
591
  export async function readSkillResource(id, path, config, directory = configDirectory()) {
581
- const skill = await skillEntry(id, config, directory);
592
+ const skill = await skillEntry(id, config, directory, true);
582
593
  const { base, target } = resourceTarget(skill, path);
583
594
  return boundedRead(target, base, undefined, MAX_SKILL_DOCUMENT_BYTES);
584
595
  }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The key a file-read record is stored under: the resolved path, case-folded on Windows.
3
+ *
4
+ * Kept free of imports so producers of the same state (the CodeGraph complete-source seed) can
5
+ * share the canonical tools' key without loading the tools themselves. It must be applied to a path
6
+ * normalized the same way the policy's safePath normalizes it, or the entries never match.
7
+ */
8
+ export declare function stateKey(resolved: string): string;
@@ -0,0 +1,12 @@
1
+ import path from 'node:path';
2
+ /**
3
+ * The key a file-read record is stored under: the resolved path, case-folded on Windows.
4
+ *
5
+ * Kept free of imports so producers of the same state (the CodeGraph complete-source seed) can
6
+ * share the canonical tools' key without loading the tools themselves. It must be applied to a path
7
+ * normalized the same way the policy's safePath normalizes it, or the entries never match.
8
+ */
9
+ export function stateKey(resolved) {
10
+ const key = path.resolve(resolved);
11
+ return process.platform === 'win32' ? key.toLowerCase() : key;
12
+ }
@@ -1,7 +1,8 @@
1
1
  import { execFile } from 'node:child_process';
2
2
  import { randomUUID } from 'node:crypto';
3
- import { startGraphServer } from './graph-server.js';
4
3
  import { requireGraphMembership } from './membership.js';
4
+ // The editor server pulls in the automation scheduler and graph sync; it loads when first opened.
5
+ const startGraphServer = async () => (await import('./graph-server.js')).startGraphServer();
5
6
  function openBrowser(url, signal) {
6
7
  const command = process.platform === 'win32' ? 'rundll32.exe' : process.platform === 'darwin' ? 'open' : 'xdg-open';
7
8
  const args = process.platform === 'win32' ? ['url.dll,FileProtocolHandler', url] : [url];
@@ -83,6 +83,27 @@ export interface GraphResumeScope {
83
83
  export declare function resumeModelNodes(graph: Graph, resume?: GraphResumeScope): string[] | undefined;
84
84
  /** Probe inference itself, rather than trusting a provider's possibly stale model listing. */
85
85
  export declare function checkGraphModelHealth(graph: Graph, config: Config, signal: AbortSignal, dependencies?: GraphModelHealthDependencies): Promise<GraphModelHealthResult>;
86
+ /** What the Default graph's selection check needs: the session pair, a shared answer cache, and a bound. */
87
+ export interface SessionModelCheckDependencies {
88
+ createAdapter?: (provider: ProviderConfig) => ModelAdapter;
89
+ verified?: GraphModelHealthDependencies['verified'];
90
+ /** Bound for the model listing, and for the reply probe a provider without a listing falls back to. */
91
+ timeoutMs?: number;
92
+ /** The label the failure names the nodes by. */
93
+ nodes?: string[];
94
+ }
95
+ /**
96
+ * Whether the session's own provider still offers its model — the check selecting Default needs.
97
+ *
98
+ * Default is one agent that runs the session pair and nothing else, so checking it as a graph
99
+ * asks that one model for a reply: a whole inference turn (seconds on a hosted model, a full
100
+ * thread on Codex) before the selection settles. This asks the provider's model listing instead,
101
+ * which answers in a fraction of that, and passes at once when the pair answered a probe recently.
102
+ * The run's own preflight still probes inference before any work starts, so a model the listing
103
+ * names but that cannot answer is still refused where it matters. A provider without a listing,
104
+ * or whose listing fails, is probed for a reply as before.
105
+ */
106
+ export declare function checkSessionModelHealth(config: Config, signal: AbortSignal, dependencies?: SessionModelCheckDependencies): Promise<GraphModelHealthResult>;
86
107
  export declare function formatGraphHealthFailure(result: GraphModelHealthResult, remediation?: string): string;
87
108
  /**
88
109
  * The health failures that must stop work before it starts.
@@ -224,6 +224,52 @@ export async function checkGraphModelHealth(graph, config, signal, dependencies
224
224
  const unavailable = failures.filter((failure) => failure !== undefined);
225
225
  return { healthy: unavailable.length === 0, failures: unavailable };
226
226
  }
227
+ /**
228
+ * Whether the session's own provider still offers its model — the check selecting Default needs.
229
+ *
230
+ * Default is one agent that runs the session pair and nothing else, so checking it as a graph
231
+ * asks that one model for a reply: a whole inference turn (seconds on a hosted model, a full
232
+ * thread on Codex) before the selection settles. This asks the provider's model listing instead,
233
+ * which answers in a fraction of that, and passes at once when the pair answered a probe recently.
234
+ * The run's own preflight still probes inference before any work starts, so a model the listing
235
+ * names but that cannot answer is still refused where it matters. A provider without a listing,
236
+ * or whose listing fails, is probed for a reply as before.
237
+ */
238
+ export async function checkSessionModelHealth(config, signal, dependencies = {}) {
239
+ signal.throwIfAborted();
240
+ const nodes = dependencies.nodes ?? ['Andorra Agent'];
241
+ const provider = config.providers.find(p => p.id === config.provider);
242
+ const model = provider?.model ?? '(default model)';
243
+ if (!provider)
244
+ return { healthy: false, failures: [{ provider: config.provider, model, nodes, reason: 'Provider is not configured.' }] };
245
+ if (dependencies.verified?.has(provider, model))
246
+ return { healthy: true, failures: [] };
247
+ const timeoutMs = dependencies.timeoutMs ?? 30_000;
248
+ const adapter = (dependencies.createAdapter ?? createAdapter)(provider);
249
+ if (adapter.listModels) {
250
+ let models;
251
+ try {
252
+ models = await adapter.listModels(AbortSignal.any([signal, AbortSignal.timeout(timeoutMs)]));
253
+ }
254
+ catch {
255
+ signal.throwIfAborted();
256
+ }
257
+ if (models !== undefined && models.length > 0) {
258
+ return models.includes(model) ? { healthy: true, failures: [] } : { healthy: false, failures: [{
259
+ provider: provider.id, model, nodes, providerError: true,
260
+ reason: 'The provider does not offer this model. Choose another one with /model.',
261
+ }] };
262
+ }
263
+ }
264
+ const reply = { provider: provider.id, model, nodes };
265
+ const probeGraph = { schemaVersion: 3, id: 'session-model', name: 'Session model', revision: 1, entry: 'agent',
266
+ nodes: { agent: { id: 'agent', name: nodes[0], type: 'agent' } }, edges: [] };
267
+ const result = await checkGraphModelHealth(probeGraph, config, signal, {
268
+ timeoutMs, ...(dependencies.createAdapter ? { createAdapter: dependencies.createAdapter } : {}),
269
+ ...(dependencies.verified ? { verified: dependencies.verified } : {}),
270
+ });
271
+ return { healthy: result.healthy, failures: result.failures.map(failure => ({ ...failure, ...reply })) };
272
+ }
227
273
  export function formatGraphHealthFailure(result, remediation = 'Open /graph > Edit Graphs, fix the model selections, then reload the graph to check again.') {
228
274
  if (result.healthy)
229
275
  return '';