@andorra-labs/code 0.1.9 → 0.1.11

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 (212) hide show
  1. package/README.md +28 -208
  2. package/THIRD_PARTY_NOTICES.md +15 -0
  3. package/dist/src/agent-execution.js +56 -0
  4. package/dist/src/app-server/protocol.d.ts +109 -1
  5. package/dist/src/app-server/protocol.js +8 -1
  6. package/dist/src/app-server.d.ts +59 -1
  7. package/dist/src/app-server.js +418 -63
  8. package/dist/src/auth/index.d.ts +1 -1
  9. package/dist/src/auth/index.js +1 -1
  10. package/dist/src/auth/store.d.ts +17 -1
  11. package/dist/src/auth/store.js +25 -2
  12. package/dist/src/automation-service.js +1 -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 +255 -33
  16. package/dist/src/browser-ui/index.html +9 -9
  17. package/dist/src/browser-ui/style.css +110 -65
  18. package/dist/src/browser-ui/tokens.css +27 -26
  19. package/dist/src/cli.js +10 -5
  20. package/dist/src/coding-tools.d.ts +24 -0
  21. package/dist/src/coding-tools.js +71 -8
  22. package/dist/src/command-screens.js +1 -1
  23. package/dist/src/commands.d.ts +1 -1
  24. package/dist/src/commands.js +2 -2
  25. package/dist/src/completion-gates.d.ts +42 -7
  26. package/dist/src/completion-gates.js +55 -9
  27. package/dist/src/completion.d.ts +9 -1
  28. package/dist/src/completion.js +20 -2
  29. package/dist/src/dashboard-view.js +2 -2
  30. package/dist/src/deadline.js +4 -0
  31. package/dist/src/decision/checks.js +1 -1
  32. package/dist/src/file-diff.d.ts +105 -0
  33. package/dist/src/file-diff.js +244 -0
  34. package/dist/src/graph-manager-chat.js +4 -4
  35. package/dist/src/graph-runner.js +39 -2
  36. package/dist/src/graph-sync.d.ts +8 -0
  37. package/dist/src/graph-sync.js +54 -3
  38. package/dist/src/graph-tool.js +1 -1
  39. package/dist/src/graph-ui/app.js +303 -129
  40. package/dist/src/graph-ui/controls.css +43 -22
  41. package/dist/src/graph-ui/controls.js +31 -1
  42. package/dist/src/graph-ui/embed.js +56 -7
  43. package/dist/src/graph-ui/icons.js +5 -0
  44. package/dist/src/graph-ui/index.html +3 -3
  45. package/dist/src/graph-ui/manager-state.js +2 -2
  46. package/dist/src/graph-ui/manager.css +19 -18
  47. package/dist/src/graph-ui/manager.js +5 -5
  48. package/dist/src/graph-ui/skill-picker.js +5 -5
  49. package/dist/src/graph-ui/studio-canvas.js +16 -16
  50. package/dist/src/graph-ui/studio.css +18 -15
  51. package/dist/src/graph-ui/studio.js +99 -42
  52. package/dist/src/graph-ui/style.css +125 -80
  53. package/dist/src/graph-ui/theme.js +2 -2
  54. package/dist/src/graph-ui/tokens.css +33 -29
  55. package/dist/src/graphs.d.ts +10 -3
  56. package/dist/src/graphs.js +15 -4
  57. package/dist/src/mcp.d.ts +75 -0
  58. package/dist/src/mcp.js +240 -8
  59. package/dist/src/membership-errors.d.ts +7 -1
  60. package/dist/src/membership-errors.js +9 -3
  61. package/dist/src/provider-keys.d.ts +5 -1
  62. package/dist/src/provider-keys.js +7 -3
  63. package/dist/src/provider-settings.d.ts +4 -1
  64. package/dist/src/provider-settings.js +46 -5
  65. package/dist/src/pull-requests.d.ts +42 -6
  66. package/dist/src/pull-requests.js +11 -3
  67. package/dist/src/qa/guidance.js +6 -19
  68. package/dist/src/qa/index.d.ts +0 -2
  69. package/dist/src/qa/index.js +0 -2
  70. package/dist/src/qa/profile/QaProfile.d.ts +5 -1
  71. package/dist/src/qa/profile/QaProfile.js +6 -2
  72. package/dist/src/qa/tools.d.ts +19 -1
  73. package/dist/src/qa/tools.js +20 -145
  74. package/dist/src/react-runtime.js +134 -16
  75. package/dist/src/read-document-doc.d.ts +20 -0
  76. package/dist/src/read-document-doc.js +524 -0
  77. package/dist/src/read-document-docx.d.ts +21 -0
  78. package/dist/src/read-document-docx.js +584 -0
  79. package/dist/src/read-document-text.d.ts +29 -0
  80. package/dist/src/read-document-text.js +67 -0
  81. package/dist/src/read-document-tool.d.ts +48 -0
  82. package/dist/src/read-document-tool.js +162 -0
  83. package/dist/src/read-document.d.ts +78 -0
  84. package/dist/src/read-document.js +353 -0
  85. package/dist/src/read-image.d.ts +29 -2
  86. package/dist/src/read-image.js +42 -17
  87. package/dist/src/remote/engine-pool.js +18 -6
  88. package/dist/src/runtime.d.ts +19 -0
  89. package/dist/src/runtime.js +10 -1
  90. package/dist/src/screen-selection.d.ts +38 -0
  91. package/dist/src/screen-selection.js +103 -0
  92. package/dist/src/session-changes.d.ts +122 -0
  93. package/dist/src/session-changes.js +804 -0
  94. package/dist/src/side-panel.d.ts +6 -1
  95. package/dist/src/side-panel.js +12 -10
  96. package/dist/src/skills/bundled/create-skill/SKILL.md +1 -1
  97. package/dist/src/skills/bundled/diagram/SKILL.md +1 -1
  98. package/dist/src/skills/bundled/graph-manager/SKILL.md +37 -3
  99. package/dist/src/skills/bundled/graph-manager/patterns.md +27 -0
  100. package/dist/src/skills/bundled/provenance.json +4 -4
  101. package/dist/src/skills/runtime-skills.js +3 -3
  102. package/dist/src/stall-recovery.d.ts +15 -0
  103. package/dist/src/stall-recovery.js +17 -0
  104. package/dist/src/telemetry/schema.d.ts +1 -1
  105. package/dist/src/telemetry/schema.js +1 -2
  106. package/dist/src/terminal-ui.d.ts +64 -20
  107. package/dist/src/terminal-ui.js +312 -82
  108. package/dist/src/time-limit.d.ts +53 -0
  109. package/dist/src/time-limit.js +79 -0
  110. package/dist/src/tool-diff-stats.d.ts +9 -0
  111. package/dist/src/tool-diff-stats.js +20 -0
  112. package/dist/src/tool-names.d.ts +1 -1
  113. package/dist/src/tool-result-filter.js +1 -1
  114. package/dist/src/tools.js +118 -9
  115. package/dist/src/transcript.d.ts +11 -0
  116. package/dist/src/transcript.js +15 -3
  117. package/dist/src/types.d.ts +12 -0
  118. package/dist/src/usage-analytics.d.ts +3 -1
  119. package/dist/src/usage-analytics.js +16 -2
  120. package/package.json +6 -26
  121. package/dist/src/qa/api/http-runner.d.ts +0 -3
  122. package/dist/src/qa/api/http-runner.js +0 -47
  123. package/dist/src/qa/git/ChangeDetector.d.ts +0 -26
  124. package/dist/src/qa/git/ChangeDetector.js +0 -177
  125. package/dist/src/qa/git/DiffReviewer.d.ts +0 -28
  126. package/dist/src/qa/git/DiffReviewer.js +0 -115
  127. package/dist/src/qa/orchestrator/ChangeClassifier.d.ts +0 -14
  128. package/dist/src/qa/orchestrator/ChangeClassifier.js +0 -28
  129. package/dist/src/qa/orchestrator/MergeGate.d.ts +0 -14
  130. package/dist/src/qa/orchestrator/MergeGate.js +0 -40
  131. package/dist/src/qa/orchestrator/QaOrchestrator.d.ts +0 -79
  132. package/dist/src/qa/orchestrator/QaOrchestrator.js +0 -373
  133. package/dist/src/qa/runners/CommandRunner.d.ts +0 -22
  134. package/dist/src/qa/runners/CommandRunner.js +0 -96
  135. package/dist/src/qa/runners/TestRunner.d.ts +0 -21
  136. package/dist/src/qa/runners/TestRunner.js +0 -66
  137. package/dist/src/qa/runtime/RuntimeSmoke.d.ts +0 -11
  138. package/dist/src/qa/runtime/RuntimeSmoke.js +0 -78
  139. package/dist/src/qa/runtime-detect.d.ts +0 -10
  140. package/dist/src/qa/runtime-detect.js +0 -72
  141. package/dist/src/qa/security/DependencyScanner.d.ts +0 -19
  142. package/dist/src/qa/security/DependencyScanner.js +0 -167
  143. package/dist/src/qa/security/SecretScanner.d.ts +0 -3
  144. package/dist/src/qa/security/SecretScanner.js +0 -55
  145. package/docs/README.md +0 -36
  146. package/docs/agents/README.md +0 -62
  147. package/docs/agents/install-for-agents.md +0 -56
  148. package/docs/agents/mcp-server.md +0 -212
  149. package/docs/agents/subagent-mode.md +0 -149
  150. package/docs/concepts/README.md +0 -47
  151. package/docs/concepts/jev-actionable-routing.md +0 -113
  152. package/docs/concepts/jev-decision-thresholds.md +0 -412
  153. package/docs/concepts/jev-efficiency.md +0 -217
  154. package/docs/concepts/jev-eval-2026-11-01.md +0 -78
  155. package/docs/concepts/limits.md +0 -52
  156. package/docs/concepts/memory.md +0 -10
  157. package/docs/concepts/security.md +0 -50
  158. package/docs/concepts/workspace-instructions.md +0 -29
  159. package/docs/getting-started/README.md +0 -82
  160. package/docs/getting-started/accounts.md +0 -78
  161. package/docs/getting-started/configure-providers.md +0 -132
  162. package/docs/guides/README.md +0 -13
  163. package/docs/guides/browser.md +0 -39
  164. package/docs/guides/desktop-app.md +0 -414
  165. package/docs/guides/extensions.md +0 -102
  166. package/docs/guides/graph-builder.md +0 -116
  167. package/docs/guides/headless.md +0 -46
  168. package/docs/guides/tui.md +0 -75
  169. package/docs/guides/update.md +0 -70
  170. package/docs/guides/web-search.md +0 -51
  171. package/docs/guides/windows-code-signing.md +0 -319
  172. package/docs/llms.txt +0 -45
  173. package/docs/reference/README.md +0 -7
  174. package/docs/reference/cli.md +0 -76
  175. package/docs/reference/config.md +0 -91
  176. package/docs/reference/slash-commands.md +0 -59
  177. package/docs/superpowers/plans/2026-11-01-claude-console-sign-in.md +0 -111
  178. package/docs/superpowers/plans/2026-11-01-jev-node-opt-in.md +0 -910
  179. package/docs/superpowers/plans/2026-11-02-workflow-pane.md +0 -398
  180. package/docs/superpowers/plans/2026-11-06-graph-soft-delete.md +0 -125
  181. package/docs/superpowers/plans/2026-11-09-orchestrator-delegation.md +0 -295
  182. package/docs/superpowers/plans/2026-11-13-graph-manager-chat.md +0 -203
  183. package/docs/superpowers/plans/2026-11-14-jev-fair-use-pricing.md +0 -79
  184. package/docs/superpowers/specs/2026-10-31-work-line-summary-design.md +0 -50
  185. package/docs/superpowers/specs/2026-11-01-claude-console-sign-in-design.md +0 -176
  186. package/docs/superpowers/specs/2026-11-01-jev-node-opt-in-design.md +0 -164
  187. package/docs/superpowers/specs/2026-11-01-pr-section-design.md +0 -111
  188. package/docs/superpowers/specs/2026-11-02-workflow-pane-design.md +0 -130
  189. package/docs/superpowers/specs/2026-11-06-bundled-skills-design.md +0 -206
  190. package/docs/superpowers/specs/2026-11-09-orchestrator-delegation-design.md +0 -291
  191. package/docs/superpowers/specs/2026-11-13-graph-manager-chat-design.md +0 -182
  192. package/docs/superpowers/specs/2026-11-14-jev-fair-use-pricing-design.md +0 -156
  193. package/scripts/jev-efficiency-eval.mjs +0 -187
  194. package/scripts/jev-efficiency-live.mjs +0 -193
  195. package/scripts/zcode-engine-replay.mjs +0 -223
  196. package/tests/agent-centric-mcp-test-plan.md +0 -208
  197. package/tests/analytics-settings-test-plan.md +0 -165
  198. package/tests/browser-cli-smoke.mjs +0 -276
  199. package/tests/browser-test-plan.md +0 -280
  200. package/tests/chat-side-panel-test-plan.md +0 -309
  201. package/tests/decision-engine-test-plan.md +0 -163
  202. package/tests/default-active-jev-test-plan.md +0 -85
  203. package/tests/harness-extensions-test-plan.md +0 -113
  204. package/tests/jev-all-decisions-test-plan.md +0 -156
  205. package/tests/jev-efficiency/criteria.json +0 -158
  206. package/tests/jev-efficiency/workloads.mjs +0 -242
  207. package/tests/jev-efficiency-test-plan.md +0 -198
  208. package/tests/permissions-sandbox-probe.mjs +0 -74
  209. package/tests/permissions-test-plan.md +0 -191
  210. package/tests/product-telemetry-test-plan.md +0 -536
  211. package/tests/thinking-stream-preview-test-plan.md +0 -136
  212. package/tests/zcode-react-engine-test-plan.md +0 -396
@@ -17,6 +17,7 @@ import { FileReadRequiredError } from './tool-errors.js';
17
17
  import { permissionMode, PLAN_MODE_MUTATION_ERROR } from './permissions.js';
18
18
  import { withGrepRegex } from './grep-regex.js';
19
19
  import { claimReadImages, readImageObservation } from './read-image.js';
20
+ import { READ_PDF_RENDER_PAGES, legacyTextObservation, readDocumentObservation } from './read-document-tool.js';
20
21
  const execFileAsync = promisify(execFile);
21
22
  const excluded = new Set(['.git', 'node_modules', '.andorracode']);
22
23
  const MAX_MODEL_OUTPUT = 24_000;
@@ -26,6 +27,31 @@ const READ_MAX_LINES = 2000;
26
27
  const READ_MAX_LINE_CHARS = 2000;
27
28
  const SEARCH_FILE_LIMIT = 262_144;
28
29
  const SEARCH_SCAN_LIMIT = 16 * 1024 * 1024;
30
+ /**
31
+ * How long a foreground shell command may run when the call names no timeout.
32
+ *
33
+ * Thirty seconds, the earlier default, is shorter than an ordinary package install, compile or
34
+ * test run: the command was killed and the model had to notice, raise the timeout and start it
35
+ * again from nothing. Two minutes covers those without leaving a hung command unnoticed for long.
36
+ */
37
+ export const SHELL_DEFAULT_TIMEOUT_MS = 120_000;
38
+ export const SHELL_MAX_TIMEOUT_MS = 600_000;
39
+ /**
40
+ * What a timed-out command's error tells the model to do next.
41
+ *
42
+ * The bare "timed out after N ms" says the command was stopped but not that the work is lost, nor
43
+ * which of the two ways forward fits: a longer timeout while one is left to ask for, or a
44
+ * background job once the ceiling is reached.
45
+ */
46
+ export function shellTimeoutGuidance(message, timeout) {
47
+ const marker = /^Shell command timed out after \d+ ms/;
48
+ if (!marker.test(message))
49
+ return message;
50
+ const next = timeout < SHELL_MAX_TIMEOUT_MS
51
+ ? `The command was stopped and its work is not finished. If it only needs more time, run it again with a larger timeout (up to ${SHELL_MAX_TIMEOUT_MS}); for work that can exceed that, start it with AsyncProcess and wait on the job.`
52
+ : 'The command was stopped at the largest foreground timeout and its work is not finished. Start it with AsyncProcess instead and wait on the job.';
53
+ return message.replace(marker, found => `${found}. ${next}`);
54
+ }
29
55
  const sandboxFields = {
30
56
  sandbox_permissions: { type: 'string', enum: ['use_default', 'require_escalated'], description: 'Use the workspace sandbox by default; require_escalated requests host/network access with approval.' },
31
57
  justification: { type: 'string', description: 'Required explanation for an explicit escalation request.' },
@@ -221,8 +247,13 @@ async function requireFreshRead(policy, context, resolved, action) {
221
247
  if (!previous?.complete) {
222
248
  // A suggested offset is only meaningful for the content the model last saw. Re-read first so
223
249
  // a file that changed (or shrank) since that page cannot send the model past its end.
224
- if (!previous)
250
+ if (!previous) {
251
+ // A file the text tools cannot hold (a document, an image, text in another encoding) can be
252
+ // looked at with Read but never becomes a recorded read, so "Read it first" would send the
253
+ // model round in a circle. The strict reader's own refusal is the true answer for those.
254
+ await policy.read(context, resolved);
225
255
  throw new FileReadRequiredError(`${action} requires a complete Read (or complete CodeGraph source) of the existing file first. Read ${path.relative(context.workspace, resolved) || resolved} before modifying it.`);
256
+ }
226
257
  if (!matchesFileRead(previous, await policy.read(context, resolved))) {
227
258
  throw new FileReadRequiredError(`${action} refused a stale file: it changed since the last Read/CodeGraph snapshot. Read it again before modifying.`);
228
259
  }
@@ -444,23 +475,50 @@ export function createCodingTools(policy) {
444
475
  } }),
445
476
  };
446
477
  }
447
- const Read = { ...zTool('Read', `Read a UTF-8 workspace file up to 8 MiB with compact line numbers. One call returns at most ${READ_MAX_LINES} lines: for a longer file, continue with the offset the result reports until you have read the whole file. A complete Read — every line, across calls — is remembered so Write/Edit can reject stale or unseen existing files; do not re-read unchanged files after a successful mutation. An image file (PNG, JPEG, GIF, WebP or BMP, up to 20 MiB) is returned as an image you can see, downscaled when large; use this to look at a rendered frame, plot or screenshot instead of inferring it from pixel statistics. offset and limit do not apply to images.`, { type: 'object', properties: {
478
+ const Read = { ...zTool('Read', `Read a UTF-8 workspace file up to 8 MiB with compact line numbers. One call returns at most ${READ_MAX_LINES} lines: for a longer file, continue with the offset the result reports until you have read the whole file. A complete Read — every line, across calls — is remembered so Write/Edit can reject stale or unseen existing files; do not re-read unchanged files after a successful mutation. An image file (PNG, JPEG, GIF, WebP or BMP, up to 20 MiB) is returned as an image you can see, downscaled when large; use this to look at a rendered frame, plot or screenshot instead of inferring it from pixel statistics. offset and limit do not apply to images. A PDF or Word file (.docx, .doc; up to 64 MiB) is returned as its extracted text with line numbers, paged by offset and limit like a text file; for a PDF, pages selects pages and render: true returns those pages as images, which is how to read a scan, a figure or a page with no text layer. A text file that is not UTF-8 (UTF-16, Windows-1252) is shown decoded. Documents and decoded text are read-only: they are not remembered as a Read, and Edit/Write cannot change them.`, { type: 'object', properties: {
448
479
  file_path: { type: 'string', description: 'Workspace-relative or absolute path inside the workspace' },
449
480
  offset: { type: 'integer', minimum: 0, description: '1-based starting line; 0 is accepted as line 1' },
450
481
  limit: { type: 'integer', minimum: 1, maximum: READ_MAX_LINES, description: `Maximum lines to return, at most ${READ_MAX_LINES}` },
482
+ pages: { type: 'string', description: 'PDF only: the pages to read, such as "3", "2-5" or "1,4,7-9". Default: every page' },
483
+ render: { type: 'boolean', description: `PDF only: return the selected pages as images instead of their text, at most ${READ_PDF_RENDER_PAGES} pages per call. Use it for scans, figures, tables, forms and scores` },
451
484
  }, required: ['file_path'], additionalProperties: false }, 'parallel', async (args, context) => {
452
- if (Object.keys(args).some(key => !['file_path', 'offset', 'limit'].includes(key)))
485
+ if (Object.keys(args).some(key => !['file_path', 'offset', 'limit', 'pages', 'render'].includes(key)))
453
486
  throw new Error('Unknown Read argument');
454
487
  const filePath = stringArg(args, 'file_path');
455
488
  const offset = intArg(args, 'offset', { min: 0, max: Number.MAX_SAFE_INTEGER });
456
489
  const limit = intArg(args, 'limit', { min: 1, max: READ_MAX_LINES }) ?? READ_MAX_LINES;
490
+ const pages = stringArg(args, 'pages', true), render = boolArg(args, 'render') ?? false;
457
491
  const resolved = await policy.safePath(context, filePath);
458
492
  // An image is recognized by its signature and shown as pixels. It is not recorded as a
459
493
  // text read: Write and Edit cannot faithfully rewrite a file they only saw as a picture.
460
494
  const image = await policy.readImage?.(context, resolved);
461
495
  if (image)
462
496
  return readImageObservation(context, filePath, image);
463
- const content = await policy.read(context, resolved);
497
+ // A PDF or Word file is likewise recognized by its leading bytes and returned as what it
498
+ // says: its text, or for a PDF its pages as images. Neither is recorded as a text read.
499
+ const documentOptions = { offset, limit, ...(pages === undefined ? {} : { pages }), render, maxOutput: MAX_MODEL_OUTPUT, maxLineChars: READ_MAX_LINE_CHARS };
500
+ const documentBytes = await policy.readDocument?.(context, resolved);
501
+ if (documentBytes) {
502
+ const observation = await readDocumentObservation(context, filePath, documentBytes, documentOptions);
503
+ if (observation !== undefined)
504
+ return observation;
505
+ }
506
+ let content;
507
+ try {
508
+ content = await policy.read(context, resolved);
509
+ }
510
+ catch (error) {
511
+ // Text in an older encoding (UTF-16, Windows-1252) fails the strict UTF-8 reader that
512
+ // Edit depends on. It is still text a model can read, so it is shown decoded, read-only.
513
+ if (!(error instanceof Error) || !/not valid UTF-8|Binary files are not supported/.test(error.message))
514
+ throw error;
515
+ const decoded = await policy.readLegacyText?.(context, resolved);
516
+ if (!decoded)
517
+ throw error;
518
+ return legacyTextObservation(filePath, decoded, documentOptions);
519
+ }
520
+ if (pages !== undefined || render)
521
+ throw new Error('pages and render apply to PDF files only; page through a text file with offset and limit.');
464
522
  const lines = content.split('\n');
465
523
  if (content.endsWith('\n') || content === '')
466
524
  lines.pop();
@@ -852,13 +910,13 @@ export function createCodingTools(policy) {
852
910
  : 'Bash syntax (Git Bash on Windows).';
853
911
  const tool = zTool(name, `Execute a foreground ${actual} command in the workspace. The working directory is the workspace; ${syntax} Output is tail-bounded. Commands follow the current workspace permissions. Restricted modes use the Codex OS sandbox and block network/outside writes; explicit escalation requires justification and approval. Credential environment variables are excluded; credential files remain accessible. This uses the compact command/timeout/description contract while retaining Pi/Andorra process-tree cleanup. Background execution is not exposed${kind === 'powershell' ? '' : ': a command that leaves a job running (cmd &) waits for that job, and the timeout then stops it'}. Start long-running work with AsyncProcess instead${PERSISTENT_JOBS_SUPPORTED ? ', with persist: true for a service the user needs left running after you finish' : ''}.`, { type: 'object', properties: {
854
912
  command: { type: 'string', description: 'Command to execute' },
855
- timeout: { type: 'integer', minimum: 1, maximum: 600000, description: 'Timeout in milliseconds; default 30000' },
913
+ timeout: { type: 'integer', minimum: 1, maximum: SHELL_MAX_TIMEOUT_MS, description: `Timeout in milliseconds; default ${SHELL_DEFAULT_TIMEOUT_MS}, at most ${SHELL_MAX_TIMEOUT_MS}. Set it for a build, install, download or test run you expect to take longer than the default` },
856
914
  description: { type: 'string', description: 'Short active-voice description of what the command does' },
857
915
  ...sandboxFields,
858
916
  }, required: ['command'], additionalProperties: false }, 'sequential', async (args, context) => {
859
917
  if (Object.keys(args).some(key => !['command', 'timeout', 'description', 'sandbox_permissions', 'justification'].includes(key)))
860
918
  throw new Error(`Unknown ${name} argument`);
861
- const command = stringArg(args, 'command'), timeout = intArg(args, 'timeout', { min: 1, max: 600000 }) ?? 30000;
919
+ const command = stringArg(args, 'command'), timeout = intArg(args, 'timeout', { min: 1, max: SHELL_MAX_TIMEOUT_MS }) ?? SHELL_DEFAULT_TIMEOUT_MS;
862
920
  if (args.description !== undefined)
863
921
  stringArg(args, 'description', true);
864
922
  // Before any approval is asked for: no permission mode, full access included, makes ending
@@ -902,8 +960,13 @@ export function createCodingTools(policy) {
902
960
  return nativeObservation(result.content.filter(part => part.type === 'text').map(part => part.text).join('\n'), true);
903
961
  }
904
962
  catch (error) {
905
- if (error instanceof Error && error.message.length > MAX_MODEL_OUTPUT)
906
- throw new Error(nativeObservation(error.message, true));
963
+ if (!(error instanceof Error))
964
+ throw error;
965
+ const message = shellTimeoutGuidance(error.message, timeout);
966
+ if (message.length > MAX_MODEL_OUTPUT)
967
+ throw new Error(nativeObservation(message, true));
968
+ if (message !== error.message)
969
+ throw new Error(message);
907
970
  throw error;
908
971
  }
909
972
  });
@@ -317,7 +317,7 @@ export async function runCommandScreen(line, state, ui, persist, signal, adapter
317
317
  id: DEFAULT_GRAPH.id,
318
318
  label: 'Default',
319
319
  description: 'Andorra Agent only. Reads project instructions and completes the task without an Orchestrator.',
320
- }, { id: ANDORRA_GRAPH_SELECTION, label: 'Andorra', description: free ? 'Premium workflow: Orchestrator -> Andorra Agent -> Done' : 'Paid workflow: Orchestrator -> Andorra Agent -> Done' }, ...withoutDeletedGraphs(saved).filter(graph => graph.id !== 'default').map(graph => ({ id: graph.id, label: `${graph.name} (${graph.id}@${graph.revision})`, description: 'Saved custom graph' })), { id: ':divider', label: '', separator: true }, { id: ':create', label: 'Create new graph', description: atLimit ? 'Free tier includes 1 custom graph. Upgrade to Premium for more graphs.' : 'Open the web graph builder' }, { id: ':edit', label: 'Edit Graphs', bold: true, description: 'Open saved graphs in the web graph builder' }];
320
+ }, { id: ANDORRA_GRAPH_SELECTION, label: 'Andorra', description: free ? 'Premium graph: Orchestrator -> Andorra Agent -> Done' : 'Paid graph: Orchestrator -> Andorra Agent -> Done' }, ...withoutDeletedGraphs(saved).filter(graph => graph.id !== 'default').map(graph => ({ id: graph.id, label: `${graph.name} (${graph.id}@${graph.revision})`, description: 'Saved custom graph' })), { id: ':divider', label: '', separator: true }, { id: ':create', label: 'Create new graph', description: atLimit ? 'Free tier includes 1 custom graph. Upgrade to Premium for more graphs.' : 'Open the web graph builder' }, { id: ':edit', label: 'Edit Graphs', bold: true, description: 'Open saved graphs in the web graph builder' }];
321
321
  while (!signal.aborted) {
322
322
  const selected = await ui.select('Graph', items, { selectedId: state.graph ?? DEFAULT_GRAPH.id, description: 'Choose and save your default graph for this account, or create one in the web builder. After saving, reopen /graph to select it.', signal });
323
323
  if (selected === undefined || signal.aborted)
@@ -6,7 +6,7 @@ import type { Completion, RunResult } from './runtime.js';
6
6
  import type { Usage } from './types.js';
7
7
  import type { CodeIntelligenceManager } from './code-intelligence/CodeIntelligenceManager.js';
8
8
  import { logoutCodex } from './codex-auth.js';
9
- export declare const HELP = "Commands:\n /browser Open the browser workspace (CLI stays available)\n /session Browse and resume saved sessions (newest first)\n /login [--no-browser] Sign in or create an Andorra account (prints the address over SSH)\n /auth logout Remove this machine's saved Andorra account session\n /auth status Show Andorra account session status\n /model [model-id] Open model selection or select a model directly; with a graph that pins node models, asks whether to override them\n /model list Discover models from the active provider\n /providers [id] Choose providers; Right/e edits; Add provider configures\n /subagent [id [model]] Set the provider/model external hosts (Claude/Codex CLI) must use for Andorra subagent runs; off clears it\n /reasoning <level> Set default|none|minimal|low|medium|high|xhigh|max\n /graph [id] Select a graph or open the web graph builder\n /codegraph <action> Code intelligence: status|enable|disable|rebuild; enable|disable --global sets the default for every project\n /dashboard Toggle live dashboard and transcript (TTY only)\n /attach <path> Attach a file or folder to your next task (large pastes and dropped files attach automatically)\n /usage Open session usage (Escape to return)\n /permissions [mode] Choose and remember workspace permissions\n /jev <on|off|status> Turn Jev on or off for nodes that enable it, or show its setting\n /feedback <on|off|status> Show the anonymous-feedback setting; Paid accounts can turn it off\n /yolo <on|off> Turn session-wide Full Access on or off (host files and network)\n /tools List available coding tools\n /skills List, install, enable, disable or remove skills\n /<skillname> [args] Apply an enabled imported skill to this and every later message; qualify duplicate names by catalog ID\n /skill [on|off|remove] Show, pause, resume or end the session's active skill\n /plugins List, install, enable, disable or remove plugins\n /mcp Add, edit, enable, disable or delete MCP servers\n /logout Sign out of your Andorra account (then /login to switch accounts)\n /logout --all Sign out, and delete every other Andorra sign-in saved on this machine\n /logout codex Sign out of every configured Codex (ChatGPT) account\n /status Show workspace and current settings\n /clear Clear the conversation on screen and the retained context (session usage is retained)\n /compact Compact retained conversation history to free context\n /help Show commands\n /exit Quit\nSelection screens: Up/Down to browse, Enter or Space to select, Escape to return.\nCtrl+B toggles dashboard; Ctrl+G pages its graph; Ctrl+N cycles dashboard model statistics (display only).\nCtrl+T expands/collapses todos; Ctrl+O expands/collapses tool details; Ctrl+Y collapses/expands live thinking.\nShift+Arrow/Home/End selects prompt text; Ctrl+C copies and Ctrl+X cuts a selection. The wheel scrolls; Up/Down recall prompts. Shift+drag selects transcript text.\nCtrl+C stops an interactive run; send direction to resume, or press Ctrl+C again to exit (idle Ctrl+C exits too). /yolo on|off applies immediately, including at approvals. /exit quits. Headless Ctrl+C cancels the run; a second press exits.";
9
+ export declare const HELP = "Commands:\n /browser Open the browser workspace (CLI stays available)\n /session Browse and resume saved sessions (newest first)\n /login [--no-browser] Sign in or create an Andorra account (prints the address over SSH)\n /auth logout Remove this machine's saved Andorra account session\n /auth status Show Andorra account session status\n /model [model-id] Open model selection or select a model directly; with a graph that pins node models, asks whether to override them\n /model list Discover models from the active provider\n /providers [id] Choose providers; Right/e edits; Add provider configures\n /subagent [id [model]] Set the provider/model external hosts (Claude/Codex CLI) must use for Andorra subagent runs; off clears it\n /reasoning <level> Set default|none|minimal|low|medium|high|xhigh|max\n /graph [id] Select a graph or open the web graph builder\n /codegraph <action> Code intelligence: status|enable|disable|rebuild; enable|disable --global sets the default for every project\n /dashboard Toggle live dashboard and transcript (TTY only)\n /attach <path> Attach a file or folder to your next task (large pastes and dropped files attach automatically)\n /usage Open session usage (Escape to return)\n /permissions [mode] Choose and remember workspace permissions\n /jev <on|off|status> Turn Jev on or off for nodes that enable it, or show its setting\n /feedback <on|off|status> Show the anonymous-feedback setting; Paid accounts can turn it off\n /yolo <on|off> Turn session-wide Full Access on or off (host files and network)\n /tools List available coding tools\n /skills List, install, enable, disable or remove skills\n /<skillname> [args] Apply an enabled imported skill to this and every later message; qualify duplicate names by catalog ID\n /skill [on|off|remove] Show, pause, resume or end the session's active skill\n /plugins List, install, enable, disable or remove plugins\n /mcp Add, edit, enable, disable or delete MCP servers\n /logout Sign out of your Andorra account (then /login to switch accounts)\n /logout --all Sign out, and delete every other Andorra sign-in saved on this machine\n /logout codex Sign out of every configured Codex (ChatGPT) account\n /status Show workspace and current settings\n /clear Clear the conversation on screen and the retained context (session usage is retained)\n /compact Compact retained conversation history to free context\n /help Show commands\n /exit Quit\nSelection screens: Up/Down to browse, Enter or Space to select, Escape to return.\nCtrl+B toggles dashboard; Ctrl+G pages its graph; Ctrl+N cycles dashboard model statistics (display only).\nCtrl+T expands/collapses todos; Ctrl+O expands/collapses tool details; Ctrl+Y collapses/expands live thinking.\nShift+Arrow/Home/End selects prompt text; Ctrl+C copies and Ctrl+X cuts a selection. The wheel scrolls; Up/Down recall prompts. Drag selects and copies transcript text; double-click copies a word.\nCtrl+C stops an interactive run; send direction to resume, or press Ctrl+C again to exit (idle Ctrl+C exits too). /yolo on|off applies immediately, including at approvals. /exit quits. Headless Ctrl+C cancels the run; a second press exits.";
10
10
  export interface CommandState {
11
11
  config: Config;
12
12
  yolo: boolean;
@@ -54,7 +54,7 @@ export const HELP = `Commands:
54
54
  Selection screens: Up/Down to browse, Enter or Space to select, Escape to return.
55
55
  Ctrl+B toggles dashboard; Ctrl+G pages its graph; Ctrl+N cycles dashboard model statistics (display only).
56
56
  Ctrl+T expands/collapses todos; Ctrl+O expands/collapses tool details; Ctrl+Y collapses/expands live thinking.
57
- Shift+Arrow/Home/End selects prompt text; Ctrl+C copies and Ctrl+X cuts a selection. The wheel scrolls; Up/Down recall prompts. Shift+drag selects transcript text.
57
+ Shift+Arrow/Home/End selects prompt text; Ctrl+C copies and Ctrl+X cuts a selection. The wheel scrolls; Up/Down recall prompts. Drag selects and copies transcript text; double-click copies a word.
58
58
  Ctrl+C stops an interactive run; send direction to resume, or press Ctrl+C again to exit (idle Ctrl+C exits too). /yolo on|off applies immediately, including at approvals. /exit quits. Headless Ctrl+C cancels the run; a second press exits.`;
59
59
  /**
60
60
  * Collapse retained turns into a single summary entry so the next request sends one
@@ -474,7 +474,7 @@ export function handleCommand(line, state) {
474
474
  if (changed)
475
475
  return { text: 'Graph: Default (Andorra Agent)', clear: true };
476
476
  }
477
- return { text: 'Graph: Default - Andorra Agent only. Use the graph selector for the paid Andorra workflow or custom graphs.' };
477
+ return { text: 'Graph: Default - Andorra Agent only. Use the graph selector for the paid Andorra graph or custom graphs.' };
478
478
  case '/permissions':
479
479
  if (!arg)
480
480
  return { text: `Permissions: ${permissionLabel(state.permissions ?? (state.yolo ? 'full-access' : 'ask-for-approval'))}` };
@@ -8,28 +8,63 @@ import type { TodoItem } from './todos.js';
8
8
  * turn read as a run cut off halfway. Both conditions are facts the host already holds, so they are
9
9
  * checked in code rather than left to the prompt.
10
10
  *
11
- * Each gate sends the handoff back at most `MAX_GATE_ASKS` times and is waived after that. A gate
12
- * never spends a completion repair and never fails the run: a model that will not write a summary,
13
- * or that leaves a step open because it cannot be done, ends exactly as it did before the gates
14
- * existed, with the waiver recorded.
11
+ * The `summary` and `todos` gates each send the handoff back at most `MAX_GATE_ASKS` times and are
12
+ * waived after that. A gate never spends a completion repair and never fails the run.
13
+ *
14
+ * The `unfinished` gate is different in kind. It fires when the completion itself says the task is
15
+ * not done: a non-empty `remaining` list, or a "Not done" section in the summary. A run must not end
16
+ * on its own with work it can still do. In a benchmark trial with a fifteen-minute limit the agent
17
+ * had a build that booted but drew no frame, was told a quarter of its time was left, and completed
18
+ * two steps later with "frame output still missing" in its own summary and two minutes unused; the
19
+ * host accepted it, and the trial failed. So a completion that reports unfinished work is sent back
20
+ * to keep working for as long as the agent does work in between, with no cap on how often. It is
21
+ * accepted only when sending it back cannot help: the agent has twice in a row answered the
22
+ * send-back with the same report and no tool call (there is nothing more it can do without the
23
+ * user), the attempt's clock has all but run out, or it is on its last allowed iteration. Each of
24
+ * those is recorded as a waiver with its reason.
25
+ *
26
+ * Earlier the "Not done" section was the way a completion with open plan items got through at once.
27
+ * That made the honest report an exit, and the trial above took it.
15
28
  */
16
- export type FinalAnswerGateId = 'summary' | 'todos';
29
+ export type FinalAnswerGateId = 'summary' | 'todos' | 'unfinished';
17
30
  export declare const MAX_GATE_ASKS = 2;
31
+ /** Consecutive send-backs the agent may answer with no tool call before an unfinished report is accepted. */
32
+ export declare const MAX_IDLE_UNFINISHED_ASKS = 2;
33
+ /** With less than this left on the attempt's clock, another turn could not do any work. */
34
+ export declare const UNFINISHED_MIN_TIME_MS = 20000;
35
+ export type UnfinishedWaiver = 'noFurtherWork' | 'outOfTime';
18
36
  export interface FinalAnswerGateInput {
19
37
  /** The envelope had no summary, so the serialized output is what the user would read. */
20
38
  summaryStoodIn: boolean;
21
39
  /** The run's plan as it stands after any update sent beside the completion. */
22
40
  todos: readonly TodoItem[];
23
- /** How many times each gate has already sent a handoff back in this run. */
41
+ /** The summary as the user will read it; a "Not done" section in it reports unfinished work. */
42
+ summary?: string;
43
+ /** The completion's own list of what the task still lacks; empty or absent when it claims to be done. */
44
+ remaining?: readonly string[];
45
+ /** How many times the summary and plan gates have already sent a handoff back in this run. */
24
46
  asked?: Partial<Record<FinalAnswerGateId, number>>;
47
+ /** Send-backs for unfinished work, in a row, that the agent answered without running any tool. */
48
+ idleUnfinishedAsks?: number;
49
+ /** Time left on the attempt's wall clock; undefined when the attempt has none. */
50
+ timeLeftMs?: number;
25
51
  }
26
52
  export interface FinalAnswerGateResult {
27
53
  /** Gates that send this handoff back. Empty when every failed gate is waived. */
28
54
  gates: FinalAnswerGateId[];
29
- /** Gates that failed again after their asks were spent; the handoff is accepted despite them. */
55
+ /** Gates that failed but let the handoff through; the handoff is accepted despite them. */
30
56
  waived: FinalAnswerGateId[];
31
57
  /** What the model is told. Empty when nothing is sent back. */
32
58
  message: string;
59
+ /** Why an unfinished report was let through, when `waived` includes `unfinished`. */
60
+ unfinishedWaiver?: UnfinishedWaiver;
33
61
  }
62
+ /**
63
+ * Whether the summary has a section that reports unfinished work: a markdown heading, or a line
64
+ * that is only a bold or plain label, reading "Not done" (also "Not completed", "Not finished",
65
+ * "Unfinished", "Remaining work", "Incomplete"). A sentence that merely contains the words does not
66
+ * count: a summary may say "nothing was left not done".
67
+ */
68
+ export declare function declaresUnfinishedWork(summary: string | undefined): boolean;
34
69
  /** Undefined when the handoff passes every gate. */
35
70
  export declare function finalAnswerGate(input: FinalAnswerGateInput): FinalAnswerGateResult | undefined;
@@ -1,25 +1,71 @@
1
1
  export const MAX_GATE_ASKS = 2;
2
- /** Plan items named in the message; a longer plan is counted, not listed. */
2
+ /** Consecutive send-backs the agent may answer with no tool call before an unfinished report is accepted. */
3
+ export const MAX_IDLE_UNFINISHED_ASKS = 2;
4
+ /** With less than this left on the attempt's clock, another turn could not do any work. */
5
+ export const UNFINISHED_MIN_TIME_MS = 20_000;
6
+ /** Plan items and remaining items named in the message; a longer list is counted, not listed. */
3
7
  const MAX_NAMED_TODOS = 8;
8
+ const MAX_NAMED_REMAINING = 5;
9
+ const MAX_REMAINING_CHARS = 160;
10
+ const UNFINISHED_SECTION = /^[ \t]*(?:#{1,6}[ \t]+|\*\*|__)?(?:not (?:done|completed?|finished)|unfinished(?: work)?|remaining work|incomplete)(?:\*\*|__)?[ \t]*:?[ \t]*(?:\*\*|__)?[ \t]*$/im;
11
+ /**
12
+ * Whether the summary has a section that reports unfinished work: a markdown heading, or a line
13
+ * that is only a bold or plain label, reading "Not done" (also "Not completed", "Not finished",
14
+ * "Unfinished", "Remaining work", "Incomplete"). A sentence that merely contains the words does not
15
+ * count: a summary may say "nothing was left not done".
16
+ */
17
+ export function declaresUnfinishedWork(summary) {
18
+ return !!summary && UNFINISHED_SECTION.test(summary);
19
+ }
20
+ function timeLeftPhrase(ms) {
21
+ const seconds = Math.round(ms / 1000);
22
+ if (seconds < 90)
23
+ return `about ${Math.max(5, Math.round(seconds / 5) * 5)} seconds`;
24
+ const minutes = Math.round(seconds / 60);
25
+ return minutes < 90 ? `about ${minutes} minutes` : `about ${Math.round(minutes / 6) / 10} hours`;
26
+ }
4
27
  /** Undefined when the handoff passes every gate. */
5
28
  export function finalAnswerGate(input) {
6
- const unfinished = input.todos.filter(todo => todo.status !== 'completed');
7
- const failed = [...(input.summaryStoodIn ? ['summary'] : []), ...(unfinished.length ? ['todos'] : [])];
29
+ const open = input.todos.filter(todo => todo.status !== 'completed');
30
+ const remaining = (input.remaining ?? []).filter(item => item.trim());
31
+ // A stand-in summary is the serialized output, never the model's own account of the work.
32
+ const reportsUnfinished = !input.summaryStoodIn && (remaining.length > 0 || declaresUnfinishedWork(input.summary));
33
+ // Open plan items the completion accounts for as unfinished belong to the unfinished gate; the
34
+ // plan gate is for a plan left open under a completion that claims to be done.
35
+ const failed = [
36
+ ...(input.summaryStoodIn ? ['summary'] : []),
37
+ ...(reportsUnfinished ? ['unfinished'] : open.length ? ['todos'] : []),
38
+ ];
8
39
  if (!failed.length)
9
40
  return undefined;
10
- const gates = failed.filter(gate => (input.asked?.[gate] ?? 0) < MAX_GATE_ASKS);
41
+ const unfinishedWaiver = !reportsUnfinished ? undefined
42
+ : input.timeLeftMs !== undefined && input.timeLeftMs < UNFINISHED_MIN_TIME_MS ? 'outOfTime'
43
+ : (input.idleUnfinishedAsks ?? 0) >= MAX_IDLE_UNFINISHED_ASKS ? 'noFurtherWork' : undefined;
44
+ const gates = failed.filter(gate => gate === 'unfinished' ? unfinishedWaiver === undefined : (input.asked?.[gate] ?? 0) < MAX_GATE_ASKS);
11
45
  const waived = failed.filter(gate => !gates.includes(gate));
46
+ const waiver = unfinishedWaiver && waived.includes('unfinished') ? { unfinishedWaiver } : {};
12
47
  if (!gates.length)
13
- return { gates, waived, message: '' };
48
+ return { gates, waived, message: '', ...waiver };
14
49
  const parts = [];
15
50
  if (gates.includes('summary')) {
16
51
  parts.push('It has no summary. The summary is the final answer the user reads; without one they see only the raw output object. Send summary as markdown (the outcome first, then what changed, how it was verified, and anything not done) and tests as one line per check that ran, or [] when none did, beside outcome and output.');
17
52
  }
18
53
  if (gates.includes('todos')) {
19
54
  // Ids and statuses only: the plan's text is model-authored and is already in the todo snapshot.
20
- const named = unfinished.slice(0, MAX_NAMED_TODOS).map(todo => `${todo.id} (${todo.status})`).join(', ');
21
- const more = unfinished.length > MAX_NAMED_TODOS ? `, and ${unfinished.length - MAX_NAMED_TODOS} more` : '';
22
- parts.push(`The plan still lists ${unfinished.length} unfinished ${unfinished.length === 1 ? 'item' : 'items'}: ${named}${more}. Do the work that is left, using tools. For work that is already done, send update_todos with the true statuses in the same batch as complete_agent. If an item cannot be finished, leave it open and name it under "## Not done" in the summary.`);
55
+ const named = open.slice(0, MAX_NAMED_TODOS).map(todo => `${todo.id} (${todo.status})`).join(', ');
56
+ const more = open.length > MAX_NAMED_TODOS ? `, and ${open.length - MAX_NAMED_TODOS} more` : '';
57
+ parts.push(`The plan still lists ${open.length} unfinished ${open.length === 1 ? 'item' : 'items'}: ${named}${more}. Do the work that is left, using tools. For work that is already done, send update_todos with the true statuses in the same batch as complete_agent. Do not close an item, or ship a change you do not believe in, only to make the plan read as finished.`);
58
+ }
59
+ if (gates.includes('unfinished')) {
60
+ const named = remaining.slice(0, MAX_NAMED_REMAINING).map(item => {
61
+ const line = item.replace(/\s+/g, ' ').trim();
62
+ return line.length > MAX_REMAINING_CHARS ? `${line.slice(0, MAX_REMAINING_CHARS)}…` : line;
63
+ });
64
+ const what = named.length
65
+ ? ` (${named.join('; ')}${remaining.length > named.length ? `; and ${remaining.length - named.length} more` : ''})`
66
+ : '';
67
+ const time = input.timeLeftMs !== undefined ? ` ${timeLeftPhrase(input.timeLeftMs)} of this run's time limit remain, and time left unused is worth nothing.` : '';
68
+ parts.push(`You report the task as not finished${what}. A run does not end while there is work it can still do: stopping now leaves the task failed.${time} Keep working with tools on what is missing or failing, and if the current approach is stuck, try a different one instead of repeating it. Call complete_agent again when the task is done. Only if nothing more can be done without the user (a credential, a decision, access only they have), say exactly what you need from them under "## Not done" and call complete_agent again.`);
23
69
  }
24
- return { gates, waived, message: `Completion not accepted yet. ${parts.join(' ')} Then call complete_agent again.` };
70
+ return { gates, waived, message: `Completion not accepted yet. ${parts.join(' ')}${gates.includes('unfinished') ? '' : ' Then call complete_agent again.'}`, ...waiver };
25
71
  }
@@ -7,13 +7,21 @@ export declare const FINAL_RESPONSE_GUIDANCE = "Only when this node is responsib
7
7
  * transcript renders markdown (headings, lists, fenced code), so the structure it asks for is
8
8
  * what the user actually sees; a single unbroken paragraph is what this guidance exists to prevent.
9
9
  */
10
- export declare const RESPONSE_STRUCTURE_GUIDANCE = "Write user-facing text, including the final summary, as structured markdown rather than one unbroken paragraph. Lead with the outcome in one or two sentences, then use short headings (## What changed, ## Verified, ## Not done) and bullet lists for parallel items; put every command, file content, and code sample in a fenced code block whose fences sit on their own lines; keep sentences short and omit filler. Inside a JSON string the line breaks are written as \\n escapes, and they are expected: never flatten the summary into one line to keep the JSON valid. In the tests array, write one short line per check: the check that ran, then its outcome.";
10
+ export declare const RESPONSE_STRUCTURE_GUIDANCE = "Write user-facing text, including the final summary, as structured markdown rather than one unbroken paragraph. Lead with the outcome in one or two sentences. Match the length to the work: a small change or a short answer is a few sentences or bullets with no headings; larger work uses short headings (## What changed, ## Not done) and bullet lists for parallel items. Do not list the checks again in the summary, because the tests array is shown beside it. Throughout, put every command, file content, and code sample in a fenced code block whose fences sit on their own lines; keep sentences short and omit filler. Inside a JSON string the line breaks are written as \\n escapes, and they are expected: never flatten the summary into one line to keep the JSON valid. In the tests array, write one short line per check: the check that ran, then its outcome.";
11
11
  /**
12
12
  * The summary is the user's final answer and the transcript renders it as markdown. Weak models
13
13
  * read "valid JSON" as "no newlines" and return one unbroken line, so the field itself says the
14
14
  * breaks are wanted, next to the value they shape.
15
15
  */
16
16
  export declare 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 declare 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 declare 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.";
17
25
  export declare 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. Only when this node is responsible for producing the final user answer, its summary must satisfy the user's response requirements: include complete requested files and exact formatting, including requested code fences, without abbreviation, path substitution, or offers to provide content later. Each fence opens and closes on its own line; a file written to the workspace that the user did not ask to see in the answer is named by path, not reproduced. Intermediate intake, research, and delegation nodes must instead keep a concise handoff and preserve these final-answer acceptance requirements in the downstream task instruction or output; do not implement or reproduce the final deliverable before handing off. 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
26
  /** Control-plane completion remains available when the execution-tool budget is exhausted. */
19
27
  export declare function completionTool(options: RunOptions): ToolSchema;
@@ -7,13 +7,28 @@ export const FINAL_RESPONSE_GUIDANCE = "Only when this node is responsible for p
7
7
  * transcript renders markdown (headings, lists, fenced code), so the structure it asks for is
8
8
  * what the user actually sees; a single unbroken paragraph is what this guidance exists to prevent.
9
9
  */
10
- export const RESPONSE_STRUCTURE_GUIDANCE = `Write user-facing text, including the final summary, as structured markdown rather than one unbroken paragraph. Lead with the outcome in one or two sentences, then use short headings (## What changed, ## Verified, ## Not done) and bullet lists for parallel items; put every command, file content, and code sample in a fenced code block whose fences sit on their own lines; keep sentences short and omit filler. Inside a JSON string the line breaks are written as \\n escapes, and they are expected: never flatten the summary into one line to keep the JSON valid. In the tests array, write one short line per check: the check that ran, then its outcome.`;
10
+ export const RESPONSE_STRUCTURE_GUIDANCE = `Write user-facing text, including the final summary, as structured markdown rather than one unbroken paragraph. Lead with the outcome in one or two sentences. Match the length to the work: a small change or a short answer is a few sentences or bullets with no headings; larger work uses short headings (## What changed, ## Not done) and bullet lists for parallel items. Do not list the checks again in the summary, because the tests array is shown beside it. Throughout, put every command, file content, and code sample in a fenced code block whose fences sit on their own lines; keep sentences short and omit filler. Inside a JSON string the line breaks are written as \\n escapes, and they are expected: never flatten the summary into one line to keep the JSON valid. In the tests array, write one short line per check: the check that ran, then its outcome.`;
11
11
  /**
12
12
  * The summary is the user's final answer and the transcript renders it as markdown. Weak models
13
13
  * read "valid JSON" as "no newlines" and return one unbroken line, so the field itself says the
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
  },
@@ -626,7 +644,7 @@ export function parseCompletion(text, options, reject, notes, stopReason) {
626
644
  const summary = written === undefined ? decodeDoubleEscapedSummary(JSON.stringify(output).slice(0, 2000), notes) : rejectEmbeddedEnvelope(decodeDoubleEscapedSummary(written, notes));
627
645
  return { summary,
628
646
  tests: Array.isArray(value.tests) && value.tests.every((item) => typeof item === 'string') ? value.tests : [], outcome, output,
629
- artifacts: value.artifacts ?? [] };
647
+ artifacts: value.artifacts ?? [], ...(remainingItems(value.remaining) ? { remaining: remainingItems(value.remaining) } : {}) };
630
648
  }
631
649
  if (value && typeof value.summary === 'string' && value.summary.trim()
632
650
  && Array.isArray(value.tests) && value.tests.every((x) => typeof x === 'string')) {
@@ -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)),
@@ -51,7 +51,7 @@ export function checkRunners(line) {
51
51
  }
52
52
  return runners;
53
53
  }
54
- const QA = new Set(['qa.fast', 'qa.test', 'qa.deep', 'qa.security', 'qa.browser']);
54
+ const QA = new Set(['qa.browser']);
55
55
  const object = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
56
56
  export function commandLine(args) {
57
57
  if (!object(args))
@@ -0,0 +1,105 @@
1
+ /**
2
+ * A file's change as a reader checks it: hunks of a line diff with the line numbers of both sides.
3
+ *
4
+ * The transcript used to show an edit as the text the model asked to replace and the text it asked to
5
+ * write. That is the request, not the change: there are no line numbers, and a Write over an existing
6
+ * file shows every line as new. This module diffs the file as it was against the file as it is, the
7
+ * way `git diff` would, and returns the result as data a view can lay out — each line marked as kept,
8
+ * added or removed, numbered on the side it belongs to.
9
+ *
10
+ * The output is bounded twice. The diff itself is exact up to an edit distance the timeout allows;
11
+ * past that the changed middle is shown as removed then added, which is still a true diff, only a
12
+ * coarse one. The lines and characters returned are capped separately, and `hiddenLines` says how
13
+ * many diff lines the cap left out, so a view can say "N more lines" instead of implying the end.
14
+ */
15
+ export interface FileDiffLine {
16
+ kind: 'context' | 'add' | 'del';
17
+ /** The line without its terminator (a trailing CR of a CRLF line is removed too). */
18
+ text: string;
19
+ /** The line's number in the file before the change; absent on an added line. */
20
+ oldLine?: number;
21
+ /** The line's number in the file after the change; absent on a removed line. */
22
+ newLine?: number;
23
+ /** This is the last line of its side and has no line terminator. */
24
+ noNewline?: true;
25
+ /** The text was cut at the per-line bound. */
26
+ clipped?: true;
27
+ }
28
+ /**
29
+ * One hunk in unified-diff terms: a count of 0 is an empty side, whose start is the line before it.
30
+ * The counts describe the whole hunk; when the bound cut it, `lines` stops short of them.
31
+ */
32
+ export interface FileDiffHunk {
33
+ oldStart: number;
34
+ oldLines: number;
35
+ newStart: number;
36
+ newLines: number;
37
+ lines: FileDiffLine[];
38
+ }
39
+ export interface FileDiff {
40
+ hunks: FileDiffHunk[];
41
+ /** Lines the whole change added and removed, whether or not the bound returned them. */
42
+ linesAdded: number;
43
+ linesRemoved: number;
44
+ /** Diff lines (context included) left out by the bound; 0 when the hunks are complete. */
45
+ hiddenLines: number;
46
+ /** A side had more than `DIFF_LINE_LIMIT` lines: there are no hunks, and the counts are coarse. */
47
+ coarse?: true;
48
+ }
49
+ /** One side of a diff: the file's bytes or text, or `null` for a file that does not exist. */
50
+ export type DiffSide = Buffer | string | null;
51
+ export type FileDiffResult = {
52
+ kind: 'text';
53
+ diff: FileDiff;
54
+ }
55
+ /** Either side is not UTF-8 text (a NUL byte, or bytes that do not decode). */
56
+ | {
57
+ kind: 'binary';
58
+ }
59
+ /** A side is past the size the line diff runs on; the counts are a cheaper measure, when it could be taken. */
60
+ | {
61
+ kind: 'too-large';
62
+ linesAdded?: number;
63
+ linesRemoved?: number;
64
+ };
65
+ export interface FileDiffOptions {
66
+ /** Unchanged lines kept around each change. */
67
+ context?: number;
68
+ /** The most diff lines returned, context included. */
69
+ maxLines?: number;
70
+ /** The most characters of line text returned, summed over every returned line. */
71
+ maxChars?: number;
72
+ /** A line longer than this is clipped. */
73
+ lineChars?: number;
74
+ }
75
+ /** Past this size a side is not line-diffed: the write limit of the file tools. */
76
+ export declare const DIFF_BYTE_LIMIT: number;
77
+ /**
78
+ * Past this many lines on either side a text is not split into lines: a newline-dense file inside the byte
79
+ * limit would otherwise cost one string per line before any bound applies.
80
+ */
81
+ export declare const DIFF_LINE_LIMIT = 200000;
82
+ /** The text a side holds, `null` for an absent file, or `undefined` for content that is not UTF-8 text. */
83
+ export declare function decodeText(side: DiffSide): string | null | undefined;
84
+ /** How many lines a text has, without splitting it: a final line without a terminator counts. */
85
+ export declare function lineCount(text: string): number;
86
+ /** The diff between two sides of one file. */
87
+ export declare function fileDiff(before: DiffSide, after: DiffSide, options?: FileDiffOptions): FileDiffResult;
88
+ /**
89
+ * The diff of two texts, as `fileDiff` returns it for text sides.
90
+ *
91
+ * Work and memory are bounded by the change, not the file: the shared head and tail are trimmed before the
92
+ * match, the result is kept as stretches rather than one record per line, and lines past the output bound
93
+ * are counted without being built. A side with more than `DIFF_LINE_LIMIT` lines is not split into lines at
94
+ * all: the counts come from a scan of the shared ends, and `coarse` says there are no hunks for that reason.
95
+ */
96
+ export declare function textDiff(oldText: string, newText: string, options?: FileDiffOptions): FileDiff;
97
+ /**
98
+ * Added and removed counts without splitting either text: the shared head and tail (whole lines) are found
99
+ * by scanning characters from each end, and every line between them counts as changed. Memory is the two
100
+ * strings; time is one pass over them.
101
+ */
102
+ export declare function coarseCounts(oldText: string, newText: string): {
103
+ linesAdded: number;
104
+ linesRemoved: number;
105
+ };