@andorra-labs/code 0.1.10 → 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 (155) hide show
  1. package/README.md +28 -208
  2. package/THIRD_PARTY_NOTICES.md +15 -0
  3. package/dist/src/agent-execution.js +36 -0
  4. package/dist/src/app-server/protocol.d.ts +1 -0
  5. package/dist/src/app-server.d.ts +34 -1
  6. package/dist/src/app-server.js +264 -54
  7. package/dist/src/automation-service.js +1 -1
  8. package/dist/src/browser-session.d.ts +8 -0
  9. package/dist/src/browser-session.js +27 -1
  10. package/dist/src/browser-ui/app.js +237 -15
  11. package/dist/src/browser-ui/index.html +5 -5
  12. package/dist/src/browser-ui/style.css +110 -65
  13. package/dist/src/browser-ui/tokens.css +27 -26
  14. package/dist/src/coding-tools.d.ts +24 -0
  15. package/dist/src/coding-tools.js +71 -8
  16. package/dist/src/command-screens.js +1 -1
  17. package/dist/src/commands.js +1 -1
  18. package/dist/src/completion-gates.d.ts +42 -7
  19. package/dist/src/completion-gates.js +55 -9
  20. package/dist/src/completion.d.ts +8 -0
  21. package/dist/src/completion.js +19 -1
  22. package/dist/src/dashboard-view.js +2 -2
  23. package/dist/src/deadline.js +4 -0
  24. package/dist/src/graph-manager-chat.js +13 -13
  25. package/dist/src/graph-runner.js +39 -2
  26. package/dist/src/graph-server.js +9 -9
  27. package/dist/src/graph-sync.d.ts +8 -0
  28. package/dist/src/graph-sync.js +54 -3
  29. package/dist/src/graph-tool.js +1 -1
  30. package/dist/src/graph-ui/app.js +262 -93
  31. package/dist/src/graph-ui/controls.css +43 -22
  32. package/dist/src/graph-ui/controls.js +31 -1
  33. package/dist/src/graph-ui/embed.js +62 -13
  34. package/dist/src/graph-ui/icons.js +4 -0
  35. package/dist/src/graph-ui/index.html +3 -3
  36. package/dist/src/graph-ui/manager-state.js +2 -2
  37. package/dist/src/graph-ui/manager.css +19 -18
  38. package/dist/src/graph-ui/manager.js +11 -11
  39. package/dist/src/graph-ui/skill-picker.js +1 -1
  40. package/dist/src/graph-ui/studio-canvas.js +8 -8
  41. package/dist/src/graph-ui/studio.css +18 -15
  42. package/dist/src/graph-ui/studio.js +92 -35
  43. package/dist/src/graph-ui/style.css +122 -79
  44. package/dist/src/graph-ui/theme.js +2 -2
  45. package/dist/src/graph-ui/tokens.css +33 -29
  46. package/dist/src/graphs.d.ts +3 -2
  47. package/dist/src/graphs.js +3 -2
  48. package/dist/src/membership-errors.d.ts +7 -1
  49. package/dist/src/membership-errors.js +9 -3
  50. package/dist/src/pull-requests.d.ts +42 -6
  51. package/dist/src/pull-requests.js +11 -3
  52. package/dist/src/react-runtime.js +121 -14
  53. package/dist/src/read-document-doc.d.ts +20 -0
  54. package/dist/src/read-document-doc.js +524 -0
  55. package/dist/src/read-document-docx.d.ts +21 -0
  56. package/dist/src/read-document-docx.js +584 -0
  57. package/dist/src/read-document-text.d.ts +29 -0
  58. package/dist/src/read-document-text.js +67 -0
  59. package/dist/src/read-document-tool.d.ts +48 -0
  60. package/dist/src/read-document-tool.js +162 -0
  61. package/dist/src/read-document.d.ts +78 -0
  62. package/dist/src/read-document.js +353 -0
  63. package/dist/src/read-image.d.ts +29 -2
  64. package/dist/src/read-image.js +42 -17
  65. package/dist/src/runtime.d.ts +19 -0
  66. package/dist/src/runtime.js +10 -1
  67. package/dist/src/session-changes.d.ts +6 -1
  68. package/dist/src/session-changes.js +13 -5
  69. package/dist/src/side-panel.d.ts +6 -1
  70. package/dist/src/side-panel.js +12 -10
  71. package/dist/src/skills/bundled/create-skill/SKILL.md +1 -1
  72. package/dist/src/skills/bundled/diagram/SKILL.md +1 -1
  73. package/dist/src/skills/bundled/graph-manager/SKILL.md +37 -3
  74. package/dist/src/skills/bundled/graph-manager/patterns.md +27 -0
  75. package/dist/src/skills/bundled/provenance.json +4 -4
  76. package/dist/src/skills/runtime-skills.js +3 -3
  77. package/dist/src/stall-recovery.d.ts +6 -2
  78. package/dist/src/stall-recovery.js +7 -2
  79. package/dist/src/terminal-ui.js +2 -2
  80. package/dist/src/time-limit.d.ts +53 -0
  81. package/dist/src/time-limit.js +79 -0
  82. package/dist/src/tools.js +92 -7
  83. package/dist/src/transcript.js +1 -1
  84. package/dist/src/types.d.ts +6 -0
  85. package/dist/src/usage-analytics.d.ts +3 -1
  86. package/dist/src/usage-analytics.js +16 -2
  87. package/package.json +6 -26
  88. package/docs/README.md +0 -36
  89. package/docs/agents/README.md +0 -62
  90. package/docs/agents/install-for-agents.md +0 -56
  91. package/docs/agents/mcp-server.md +0 -212
  92. package/docs/agents/subagent-mode.md +0 -149
  93. package/docs/concepts/README.md +0 -47
  94. package/docs/concepts/jev-actionable-routing.md +0 -113
  95. package/docs/concepts/jev-decision-thresholds.md +0 -412
  96. package/docs/concepts/jev-efficiency.md +0 -217
  97. package/docs/concepts/jev-eval-2026-11-01.md +0 -78
  98. package/docs/concepts/limits.md +0 -52
  99. package/docs/concepts/memory.md +0 -10
  100. package/docs/concepts/security.md +0 -50
  101. package/docs/concepts/workspace-instructions.md +0 -29
  102. package/docs/getting-started/README.md +0 -82
  103. package/docs/getting-started/accounts.md +0 -78
  104. package/docs/getting-started/configure-providers.md +0 -132
  105. package/docs/guides/README.md +0 -13
  106. package/docs/guides/browser.md +0 -39
  107. package/docs/guides/desktop-app.md +0 -414
  108. package/docs/guides/extensions.md +0 -102
  109. package/docs/guides/graph-builder.md +0 -116
  110. package/docs/guides/headless.md +0 -46
  111. package/docs/guides/tui.md +0 -75
  112. package/docs/guides/update.md +0 -70
  113. package/docs/guides/web-search.md +0 -51
  114. package/docs/guides/windows-code-signing.md +0 -319
  115. package/docs/llms.txt +0 -45
  116. package/docs/reference/README.md +0 -7
  117. package/docs/reference/cli.md +0 -76
  118. package/docs/reference/config.md +0 -91
  119. package/docs/reference/slash-commands.md +0 -59
  120. package/docs/superpowers/plans/2026-11-01-claude-console-sign-in.md +0 -111
  121. package/docs/superpowers/plans/2026-11-01-jev-node-opt-in.md +0 -910
  122. package/docs/superpowers/plans/2026-11-02-workflow-pane.md +0 -398
  123. package/docs/superpowers/plans/2026-11-06-graph-soft-delete.md +0 -125
  124. package/docs/superpowers/plans/2026-11-09-orchestrator-delegation.md +0 -295
  125. package/docs/superpowers/plans/2026-11-13-graph-manager-chat.md +0 -203
  126. package/docs/superpowers/plans/2026-11-14-jev-fair-use-pricing.md +0 -79
  127. package/docs/superpowers/specs/2026-10-31-work-line-summary-design.md +0 -50
  128. package/docs/superpowers/specs/2026-11-01-claude-console-sign-in-design.md +0 -176
  129. package/docs/superpowers/specs/2026-11-01-jev-node-opt-in-design.md +0 -164
  130. package/docs/superpowers/specs/2026-11-01-pr-section-design.md +0 -111
  131. package/docs/superpowers/specs/2026-11-02-workflow-pane-design.md +0 -130
  132. package/docs/superpowers/specs/2026-11-06-bundled-skills-design.md +0 -206
  133. package/docs/superpowers/specs/2026-11-09-orchestrator-delegation-design.md +0 -291
  134. package/docs/superpowers/specs/2026-11-13-graph-manager-chat-design.md +0 -182
  135. package/docs/superpowers/specs/2026-11-14-jev-fair-use-pricing-design.md +0 -156
  136. package/scripts/jev-efficiency-eval.mjs +0 -187
  137. package/scripts/jev-efficiency-live.mjs +0 -193
  138. package/scripts/zcode-engine-replay.mjs +0 -223
  139. package/tests/agent-centric-mcp-test-plan.md +0 -208
  140. package/tests/analytics-settings-test-plan.md +0 -165
  141. package/tests/browser-cli-smoke.mjs +0 -276
  142. package/tests/browser-test-plan.md +0 -280
  143. package/tests/chat-side-panel-test-plan.md +0 -309
  144. package/tests/decision-engine-test-plan.md +0 -163
  145. package/tests/default-active-jev-test-plan.md +0 -85
  146. package/tests/harness-extensions-test-plan.md +0 -113
  147. package/tests/jev-all-decisions-test-plan.md +0 -156
  148. package/tests/jev-efficiency/criteria.json +0 -158
  149. package/tests/jev-efficiency/workloads.mjs +0 -242
  150. package/tests/jev-efficiency-test-plan.md +0 -198
  151. package/tests/permissions-sandbox-probe.mjs +0 -74
  152. package/tests/permissions-test-plan.md +0 -191
  153. package/tests/product-telemetry-test-plan.md +0 -536
  154. package/tests/thinking-stream-preview-test-plan.md +0 -136
  155. package/tests/zcode-react-engine-test-plan.md +0 -396
@@ -105,9 +105,9 @@ function gitSection(data, width) {
105
105
  body.push(pair(label, [{ text: 'clean', color: STATUS.ok }], width));
106
106
  else
107
107
  body.push(pair(label, [
108
- { text: `+${count(changes.insertions)}`, color: STATUS.added },
108
+ { text: `+${count(changes.insertions)}`, color: changes.insertions ? STATUS.added : GRAY },
109
109
  { text: ' ' },
110
- { text: `-${count(changes.deletions)}`, color: STATUS.error },
110
+ { text: `-${count(changes.deletions)}`, color: changes.deletions ? STATUS.error : GRAY },
111
111
  ], width));
112
112
  if (changes?.isGit) {
113
113
  // The summary's own read names the branch, so the row and the counts always describe the
@@ -130,7 +130,7 @@ function nodeSection(data, width) {
130
130
  const entry = data.graph ? data.graph.nodes[data.graph.entry]?.name ?? data.graph.entry : undefined;
131
131
  if (entry)
132
132
  body.push(row({ text: clip(`entry: ${entry}`, width), color: FAINT }));
133
- return [heading('Node', width), ...body];
133
+ return [heading('Step', width), ...body];
134
134
  }
135
135
  const [focus, ...rest] = data.nodes;
136
136
  body.push(row({ text: '● ', color: accentSgr() }, { text: clip(focus.name, width - 2), color: WHITE }));
@@ -143,7 +143,7 @@ function nodeSection(data, width) {
143
143
  // follower nodes are worth one line together, not one line each.
144
144
  if (rest.length)
145
145
  body.push(row({ text: clip(` +${rest.length} more running: ${rest.map(node => node.name).join(', ')}`, width), color: FAINT }));
146
- return [heading('Node', width), ...body];
146
+ return [heading('Step', width), ...body];
147
147
  }
148
148
  function progressSection(data, width) {
149
149
  const total = data.todos.length;
@@ -162,7 +162,9 @@ function progressSection(data, width) {
162
162
  const filled = share >= 1 ? barWidth : share > 0 ? Math.max(1, Math.min(barWidth, Math.floor(share * barWidth))) : 0;
163
163
  return [
164
164
  heading('Progress', width),
165
- row({ text: '█'.repeat(filled), color: STATUS.ok }, { text: '░'.repeat(barWidth - filled), color: FAINT }, { text: ' ' }, { text: label, color: GRAY }),
165
+ // Progress is neutral, as the window draws it: the accent fill on a faint track. Green is a
166
+ // passed check, and a plan two-thirds done has passed nothing yet.
167
+ row({ text: '█'.repeat(filled), color: accentSgr() }, { text: '░'.repeat(barWidth - filled), color: FAINT }, { text: ' ' }, { text: label, color: GRAY }),
166
168
  row({ text: clip(`${done} done · ${active} active · ${waiting} waiting`, width), color: GRAY }),
167
169
  ];
168
170
  }
@@ -234,19 +236,19 @@ function terminalSection(data, width) {
234
236
  // long test-runner invocation must lose its own tail, not the elapsed time a reader is
235
237
  // watching while the row keeps repainting for it.
236
238
  const life = clip(`${session.id} · ${session.command}`, Math.max(1, width - 2 - stringWidth(age)));
237
- return row({ text: session.running ? '● ' : '○ ', color: session.running ? STATUS.ok : FAINT }, { text: life, color: session.running ? GRAY : FAINT }, { text: age, color: session.running ? GRAY : FAINT });
239
+ return row({ text: session.running ? '● ' : '○ ', color: session.running ? accentSgr() : FAINT }, { text: life, color: session.running ? GRAY : FAINT }, { text: age, color: session.running ? GRAY : FAINT });
238
240
  });
239
241
  if (ordered.length > body.length)
240
242
  body.push(row({ text: ` +${ordered.length - body.length} more`, color: FAINT }));
241
243
  return [heading('Terminals', width), ...body];
242
244
  }
243
- const MARK = (visited, active, id) => active.has(id) ? { glyph: '●', color: accentSgr() } : visited.has(id) ? { glyph: '✓', color: STATUS.ok } : { glyph: '○', color: FAINT };
245
+ const MARK = (visited, active, id) => active.has(id) ? { glyph: '●', color: accentSgr() } : visited.has(id) ? { glyph: '✓', color: SUBTLE } : { glyph: '○', color: FAINT };
244
246
  /**
245
247
  * The zoomed view of the graph section the run is in: what leads into the current node and
246
248
  * what it hands off to, with every node marked as visited, current, or not yet reached.
247
249
  *
248
250
  * Only a custom graph gets this: the built-in harness is a single agent node, and a zoom of
249
- * it would say nothing a `Node` row does not already say. Neighbours are capped so a hub node
251
+ * it would say nothing a `Step` row does not already say. Neighbours are capped so a hub node
250
252
  * cannot push the panel's other sections off the screen.
251
253
  */
252
254
  function graphSection(data, width) {
@@ -279,7 +281,7 @@ function graphSection(data, width) {
279
281
  const focusGlyph = active.has(focus) || visited.has(focus) || stopped ? '●' : '○';
280
282
  // A run that stopped on a node it had visited earlier is a stopped position, not a completed
281
283
  // one: the bold stopped marker outranks the historical visit.
282
- const focusColor = active.has(focus) ? accentSgr() : stopped ? ATTENTION : visited.has(focus) ? STATUS.ok : FAINT;
284
+ const focusColor = active.has(focus) ? accentSgr() : stopped ? ATTENTION : visited.has(focus) ? SUBTLE : FAINT;
283
285
  body.push(row({ text: `${focusGlyph} `, color: focusColor }, { text: clip(focusOf(focus), width - 2), color: active.has(focus) ? WHITE : GRAY }));
284
286
  // Distinct routes are distinct rows even when they lead to the same node: a QA node can hand off
285
287
  // to one End through `pass` and through `fail`, and collapsing them by target would hide one.
@@ -301,7 +303,7 @@ function graphSection(data, width) {
301
303
  /**
302
304
  * The panel's rows, top to bottom, for a terminal of `columns` x `height`.
303
305
  *
304
- * Sections are anchored: Git tools, Node, Progress and the plan read from the top, while the
306
+ * Sections are anchored: Git tools, Step, Progress and the plan read from the top, while the
305
307
  * terminal list and the graph zoom are held against the bottom - the reader asked for the graph
306
308
  * section to be at the bottom of the panel - with whatever rows the top sections leave as blank
307
309
  * space between them, so a tall terminal does not park the zoom in the middle of the screen.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: create-skill
3
- description: "Write a new Andorra Code skill: a SKILL.md that tells an agent how to do a recurring task. Use when the user wants to capture a workflow, checklist or house style as a reusable /command, or asks how to make a skill."
3
+ description: "Write a new Andorra Code skill: a SKILL.md that tells an agent how to do a recurring task. Use when the user wants to capture a process, checklist or house style as a reusable /command, or asks how to make a skill."
4
4
  ---
5
5
 
6
6
  # Create a skill
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: diagram
3
- description: "Draw a UML-style diagram in a reply instead of hand-typed arrows. Use when about to describe or explain a graph, workflow, routing, state machine, call sequence, data model or code structure to the user, including when reviewing an Andorra graph."
3
+ description: "Draw a UML-style diagram in a reply instead of hand-typed arrows. Use when about to describe or explain a graph, process, routing, state machine, call sequence, data model or code structure to the user, including when reviewing an Andorra graph."
4
4
  ---
5
5
 
6
6
  # Explain with a diagram
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: graph-manager
3
- description: "Design, create, edit, delete or restore Andorra Code graphs (multi-agent workflows) from the user's requirements, through Andorra's graph tools. Use when the user wants a new workflow, wants to change how an existing graph routes work, or wants a graph removed or brought back."
3
+ description: "Design, create, edit, delete or restore Andorra Code graphs (multi-agent pipelines) through Andorra's graph tools. Use when the user wants a new graph (one that reviews or fixes pull requests included), wants to change how a graph routes work, or wants a graph removed or restored."
4
4
  ---
5
5
 
6
6
  # Manage graphs
@@ -41,6 +41,9 @@ Ask until you can answer each of these:
41
41
  - Which provider and model each agent uses: list them with `andorra_providers_list` and use those ids only.
42
42
  - What each agent may touch (read only, write files, run shell, open pull requests).
43
43
  - What input a run needs beyond the task text.
44
+ - When the workflow opens, reviews or fixes pull requests: which agent owns the PR and its review comments.
45
+ Build it with the "Pull request with review fixes" pattern in `patterns.md`: that agent switches Auto-fix on
46
+ itself and loops on the reviews, and the graph's entry stays where it is.
44
47
 
45
48
  Then sketch the nodes and routes. When the `diagram` skill is in your catalog, load it and draw the sketch
46
49
  as a state diagram instead; do the same whenever you describe or review an existing graph for the user.
@@ -71,6 +74,26 @@ only what the request needs: `andorra_graph_node_patch` for a node's instruction
71
74
  `andorra_graph_node_remove` / `andorra_graph_edge_remove` to take parts out (the entry node cannot be removed
72
75
  until another node is the entry).
73
76
 
77
+ **Adding an outcome to a node that already routes.** A node's outcomes name the conditions it routes on, and
78
+ the names stop fitting once the node branches. Before adding the new outcome, read the node's existing
79
+ outcomes, their written criteria and the routes they drive, and decide what each one now means beside the new
80
+ one:
81
+
82
+ - A lone `completed` (or another catch-all such as `done` or `next`) no longer says anything once a second
83
+ outcome exists. Rename it for the kind of work it actually routes: an Orchestrator that sent everything to
84
+ the Software Engineer as `completed` and now also sends releases to a Release Manager has `implement` and
85
+ `release`, not `completed` and `release`.
86
+ - Rewrite each existing criterion so the outcomes are mutually exclusive and together cover every case the
87
+ node can meet; a criterion written when the node had one exit usually claims everything.
88
+ - Keep a name that still fits; rename only where the new branch made it vague or overlapping.
89
+
90
+ To apply a rename, switch the node to `completion: { mode: "outcomes", outcomes: [...], criteria: {...} }`
91
+ with `andorra_graph_node_patch`, then `andorra_graph_edge_upsert` every route that used the old name with the
92
+ new `outcome` and the edge's existing `id` (an upsert without the id adds a second edge and leaves the old
93
+ one on a port the node no longer has). Also update anything else that names the
94
+ old outcome: a loop modifier's `until.outcome` on that node, and the node's instruction if it tells the agent
95
+ which outcome to report. Name the renames when you show the user what changed.
96
+
74
97
  The built-in `default` graph cannot be edited: create a new graph with the shape you want instead.
75
98
 
76
99
  **Place every node.** A node's `position` (`{x, y}`) is the top-left corner of its card on the editor's
@@ -85,7 +108,16 @@ and the upsert reply's `placed` says where it went.
85
108
 
86
109
  1. `andorra_graph_validate` and fix every issue it reports; `errors.md` in this skill maps each code to its
87
110
  fix. Do not publish around an issue.
88
- 2. Show the user what changed: nodes added, removed or changed, and routes.
111
+ 2. Describe the change to the user in chat, in plain words, before publishing. Outside Full Access, publishing
112
+ asks the user to approve or deny, and that prompt shows only the raw call; under Full Access it publishes
113
+ without a prompt, so do not promise one. Either way this description is what the user verifies against:
114
+ - the graph's name and id, and the revision it replaces;
115
+ - each node added, removed or changed, and for a changed node what it now does differently (instruction,
116
+ model, capabilities, completion outcomes), not just that it changed;
117
+ - each route added or removed, and any change to the entry or the limits;
118
+ - what a run of the graph will now do that it did not before, including anything the user did not ask for
119
+ that the change brings with it;
120
+ - the updated diagram, when the `diagram` skill is available.
89
121
  3. `andorra_graph_publish`. A `REVISION_CONFLICT` means someone saved a newer revision: begin a new edit draft
90
122
  from the latest, reapply your changes, validate and publish again.
91
123
  4. If the user stops partway, `andorra_graph_discard` the draft.
@@ -96,7 +128,9 @@ Deleting is a soft delete: the graph leaves every list and new runs refuse it, b
96
128
  it can be restored.
97
129
 
98
130
  1. Read the graph's latest `revision` (`andorra_graph_get` or `andorra_graphs_list`).
99
- 2. Ask the user in chat to confirm deleting that graph, naming it. Do not delete without a clear yes.
131
+ 2. Ask the user in chat to confirm deleting that graph, naming it and saying what it does, which revision is
132
+ the latest, and that new runs will refuse it. Do not delete without a clear yes. Before a restore, say the
133
+ same about the graph that comes back.
100
134
  3. `andorra_graph_delete` with `id`, `expectedRevision` and `confirm` set to the same `id`.
101
135
  - `GRAPH_IN_USE`: an automation runs this graph; tell the user which ones and stop.
102
136
  - A free account's deleted graph still counts as its one custom graph; it can be restored, not replaced.
@@ -67,6 +67,33 @@ check (loop modifier) --pass--> done
67
67
  `pass` or runs out of attempts. It exposes only the `pass` port; use it when the same agent fixes and
68
68
  rechecks its own work.
69
69
 
70
+ ## Pull request with review fixes (Auto-fix)
71
+
72
+ ```
73
+ orchestrator --completed--> pr-owner --completed--> done
74
+ ```
75
+
76
+ Use this whenever the workflow opens a pull request, reviews one, or answers its review comments.
77
+
78
+ - One agent owns the PR end to end: it opens or attaches the PR, switches Auto-fix on itself (the `pull_request`
79
+ tool, `action: "attach"` or `"update"` with `autoFix: true`), and fixes the review comments. Auto-fix prompts
80
+ go back to the node that switched Auto-fix on (or, when none did, to the node that attached the PR), not to
81
+ the graph's entry. So that call belongs in the PR owner's instruction, never in an Orchestrator or planner
82
+ that hands the work on.
83
+ - Do not move the entry, demote an Orchestrator, or add edges back into the owner to steer Auto-fix there. A
84
+ prompt is never routed through the graph's edges; it is addressed to the node.
85
+ - The owner's instruction is a loop it runs itself: push the fix, resolve the threads it fixed, reply to the
86
+ findings it disputes, then wait for the next review. If the `pull_request` tool offers an `await_review`
87
+ action, call it and repeat until it reports the PR merged or closed (or the round cap below): the agent keeps
88
+ its whole conversation, and waiting costs no tokens. Without that action, end the turn once the round is
89
+ pushed; Auto-fix wakes this same node with the next comments, continuing its attempt when it stopped short.
90
+ - Never wait with `sleep`, a shell polling loop, or `set_timer` (timers are for reminders the user asked for).
91
+ Waiting inside a tool call is the only wait that does not hold the model.
92
+ - Give the owner shell, file-write and network access (it runs `git` and `gh`), and a `limits.wallTimeMs` with
93
+ room for several fix rounds: a 15-minute ceiling stops it in the middle of a fix.
94
+ - Put the exit rule in its instruction: stop when the PR is merged or closed (Auto-fix then switches itself
95
+ off), when the reviewer signs off, or after a fixed number of rounds the user chose.
96
+
70
97
  ## Single agent with a human approval
71
98
 
72
99
  ```
@@ -689,7 +689,7 @@
689
689
  {
690
690
  "source": "src/skills/bundled/create-skill/SKILL.md",
691
691
  "asset": "create-skill/SKILL.md",
692
- "sha256": "d3dbb7565597460d3114bb934eb5d9b8112fc2e52849c6ee1b67fea745a68436"
692
+ "sha256": "fd25af06f9545e27d2db3ba34c0d912574b27b1f04c61399c27f078d5e6cf5b0"
693
693
  },
694
694
  {
695
695
  "source": "src/skills/bundled/manage-skills/SKILL.md",
@@ -714,7 +714,7 @@
714
714
  {
715
715
  "source": "src/skills/bundled/graph-manager/SKILL.md",
716
716
  "asset": "graph-manager/SKILL.md",
717
- "sha256": "ffd7ce9f4cb088f35e666941fafb2ece2fab805bb96e70e40c93af530332f2b1"
717
+ "sha256": "06019dce82a2ea72f4121f37111481f8bdd63d39b2d1ac1ab479405424cc7708"
718
718
  },
719
719
  {
720
720
  "source": "src/skills/bundled/graph-manager/errors.md",
@@ -724,12 +724,12 @@
724
724
  {
725
725
  "source": "src/skills/bundled/graph-manager/patterns.md",
726
726
  "asset": "graph-manager/patterns.md",
727
- "sha256": "c80a27c1af42d99ae48fb16b0c9727ae5f977cedfb7258966d76d5a4e2f0c9c3"
727
+ "sha256": "bf57e2421697360cc293109b5eaa84ecff0d93fc5dcd957a34d8173ca91b1e2c"
728
728
  },
729
729
  {
730
730
  "source": "src/skills/bundled/diagram/SKILL.md",
731
731
  "asset": "diagram/SKILL.md",
732
- "sha256": "369b04625432bc0a3f302eba0c9ce0ca7fe9455a5b4c27d105bd393520ae0c8d"
732
+ "sha256": "2840d736a0001ca82dc002056648ac2b73bdc3f6ce3f710a3d1832a548bbd4dc"
733
733
  }
734
734
  ],
735
735
  "additionalCopyright": [
@@ -22,14 +22,14 @@ const bundled = [
22
22
  { id: 'andorra:control-browser', path: 'control-browser/SKILL.md', description: 'Use the available persistent browser runtime to navigate, inspect and interact with web pages.', source: 'bundled', requiredTools: ['qa.browser_session'] },
23
23
  // Andorra's own setup skills: written for the agent, typeable as /name, loaded on matching requests.
24
24
  { id: 'andorra:manage-mcp', path: 'manage-mcp/SKILL.md', description: "Add, change, test, turn off or remove an MCP server in Andorra Code. Use when the user wants to connect a tool server (GitHub, a database, a browser, an internal API), asks why an MCP server's tools are missing, or wants one disconnected.", source: 'bundled' },
25
- { id: 'andorra:create-skill', path: 'create-skill/SKILL.md', description: "Write a new Andorra Code skill: a SKILL.md that tells an agent how to do a recurring task. Use when the user wants to capture a workflow, checklist or house style as a reusable /command, or asks how to make a skill.", source: 'bundled', loadWhen: 'before writing a new skill or turning something into one' },
25
+ { id: 'andorra:create-skill', path: 'create-skill/SKILL.md', description: "Write a new Andorra Code skill: a SKILL.md that tells an agent how to do a recurring task. Use when the user wants to capture a process, checklist or house style as a reusable /command, or asks how to make a skill.", source: 'bundled', loadWhen: 'before writing a new skill or turning something into one' },
26
26
  { id: 'andorra:manage-skills', path: 'manage-skills/SKILL.md', description: "List, install, turn on or off, and remove Andorra Code skills and plugins. Use when the user asks what skills they have, wants to add a skill from GitHub or a folder, disable one, or clean up skills they no longer use.", source: 'bundled', loadWhen: 'before installing, copying, listing, turning on or off, or removing a skill or plugin' },
27
27
  { id: 'andorra:create-agent', path: 'create-agent/SKILL.md', description: "Design a reusable Andorra Code Agent (a role with its own instructions, model, capabilities and input/output contract) and produce a file the user imports into their Agent library. Use when the user wants a custom reviewer, tester, researcher or other role to reuse across graphs.", source: 'bundled' },
28
28
  { id: 'andorra:doctor', path: 'doctor/SKILL.md', description: "Check that Andorra Code is set up and healthy: Node, sign-in, configuration, providers, MCP servers, disk space. Use when something does not work (no models, tools missing, sign-in errors, tasks failing at start) or the user asks to check their setup.", source: 'bundled' },
29
29
  { id: 'andorra:write-instructions', path: 'write-instructions/SKILL.md', description: "Create or improve a repository's agent instructions (ANDORRA.md or AGENTS.md): build and test commands, conventions, and rules agents must follow. Use when the user wants agents to work the way their team does, or asks to set up or tighten project instructions.", source: 'bundled' },
30
- { id: 'andorra:graph-manager', path: 'graph-manager/SKILL.md', description: "Design, create, edit, delete or restore Andorra Code graphs (multi-agent workflows) from the user's requirements, through Andorra's graph MCP tools. Use when the user wants a new workflow, wants to change how an existing graph routes work, or wants a graph removed or brought back.", source: 'bundled' },
30
+ { id: 'andorra:graph-manager', path: 'graph-manager/SKILL.md', description: "Design, create, edit, delete or restore Andorra Code graphs (multi-agent pipelines) from the user's requirements, through Andorra's graph tools. Use when the user wants a new graph, wants to change how an existing graph routes work, or wants a graph removed or brought back.", source: 'bundled' },
31
31
  // Loaded by the agent on its own when a reply has a shape to show; the desktop transcript draws the fence it writes.
32
- { id: 'andorra:diagram', path: 'diagram/SKILL.md', description: "Draw a UML-style diagram in a reply instead of hand-typed arrows. Use when about to describe or explain a graph, workflow, routing, state machine, call sequence, data model or code structure to the user, including when reviewing an Andorra graph.", source: 'bundled', loadWhen: 'before describing or explaining a graph, workflow, state machine, call sequence or code structure to the user' },
32
+ { id: 'andorra:diagram', path: 'diagram/SKILL.md', description: "Draw a UML-style diagram in a reply instead of hand-typed arrows. Use when about to describe or explain a graph, process, routing, state machine, call sequence, data model or code structure to the user, including when reviewing an Andorra graph.", source: 'bundled', loadWhen: 'before describing or explaining a graph, workflow, state machine, call sequence or code structure to the user' },
33
33
  ];
34
34
  /** Andorra's own skills, as registered: what a person can type and the agent can load by id. */
35
35
  export function bundledSkillCatalog() {
@@ -21,10 +21,14 @@ export declare function unavailableToolsSentence(unavailable: readonly string[])
21
21
  * call, which is exactly what a stall looks like, and "call complete_agent when the requirements
22
22
  * are finished" reads as a ban on handing off before they are. A live run asked the user to sign in
23
23
  * twice, was sent back both times, and started the interactive login itself instead; the user never
24
- * saw either request. Only an Orchestrator has `ask_user`, so every other node asks through its
25
- * handoff: the summary is what the user reads, and their next message continues the conversation.
24
+ * saw either request. A node without `ask_user` (a headless run, a delegated child, a later graph
25
+ * stage) asks through its handoff: the summary is what the user reads, and their next message
26
+ * continues the conversation. A node that has the tool is pointed at it first by
27
+ * {@link ASK_USER_GUIDANCE}, because a question it asks that way pauses the run for the answer.
26
28
  */
27
29
  export declare const USER_BLOCKED_GUIDANCE = "The exception is work that cannot continue without the user: a question only they can answer, or a login, approval or other action only they can perform. Do not work around it or retry it. Call complete_agent alone now (with a blocked outcome if one is declared) and put the question or the exact action needed first in the summary, followed by what is done and what remains; the user reads the summary and answers in their next message.";
30
+ /** Added for a node that has `ask_user`: a question belongs in that tool, not in a reply or a handoff. */
31
+ export declare const ASK_USER_GUIDANCE = "If your reply asked the user a question, call ask_user with that question now instead: a question written in a reply does not pause the run, and the tool waits for their answer.";
28
32
  /** The continuation sent after a graph-node turn that ended without a tool call or a handoff. */
29
33
  export declare function stalledTurnGuidance(input: {
30
34
  dropped: boolean;
@@ -64,10 +64,14 @@ export function unavailableToolsSentence(unavailable) {
64
64
  * call, which is exactly what a stall looks like, and "call complete_agent when the requirements
65
65
  * are finished" reads as a ban on handing off before they are. A live run asked the user to sign in
66
66
  * twice, was sent back both times, and started the interactive login itself instead; the user never
67
- * saw either request. Only an Orchestrator has `ask_user`, so every other node asks through its
68
- * handoff: the summary is what the user reads, and their next message continues the conversation.
67
+ * saw either request. A node without `ask_user` (a headless run, a delegated child, a later graph
68
+ * stage) asks through its handoff: the summary is what the user reads, and their next message
69
+ * continues the conversation. A node that has the tool is pointed at it first by
70
+ * {@link ASK_USER_GUIDANCE}, because a question it asks that way pauses the run for the answer.
69
71
  */
70
72
  export const USER_BLOCKED_GUIDANCE = 'The exception is work that cannot continue without the user: a question only they can answer, or a login, approval or other action only they can perform. Do not work around it or retry it. Call complete_agent alone now (with a blocked outcome if one is declared) and put the question or the exact action needed first in the summary, followed by what is done and what remains; the user reads the summary and answers in their next message.';
73
+ /** Added for a node that has `ask_user`: a question belongs in that tool, not in a reply or a handoff. */
74
+ export const ASK_USER_GUIDANCE = 'If your reply asked the user a question, call ask_user with that question now instead: a question written in a reply does not pause the run, and the tool waits for their answer.';
71
75
  /** The continuation sent after a graph-node turn that ended without a tool call or a handoff. */
72
76
  export function stalledTurnGuidance(input) {
73
77
  const parts = [
@@ -77,6 +81,7 @@ export function stalledTurnGuidance(input) {
77
81
  input.available.length ? `This node's tools are: ${list(input.available)}.` : '',
78
82
  unavailableToolsSentence(input.unavailable),
79
83
  'Your next response must call one of this node\'s tools. A progress update does not hand off this graph node. When its requirements and verification are finished, call complete_agent alone with the declared outcome and output.',
84
+ input.available.includes('ask_user') ? ASK_USER_GUIDANCE : '',
80
85
  USER_BLOCKED_GUIDANCE,
81
86
  ];
82
87
  return parts.filter(Boolean).join(' ');
@@ -2946,13 +2946,13 @@ export class TerminalUI extends EventEmitter {
2946
2946
  return [
2947
2947
  clip(brand.at(-1), available),
2948
2948
  ...(viewportHeight >= 2 ? [clip(`● ${activity}`, available)] : []),
2949
- ...(viewportHeight >= 3 ? [clip(`Workflow · ${graphName}`, available)] : []),
2949
+ ...(viewportHeight >= 3 ? [clip(`Graph · ${graphName}`, available)] : []),
2950
2950
  ...(status.graphNeedsOverride && viewportHeight >= 4 ? [paint(clip(OVERRIDE_HINT, available), ATTENTION)] : []),
2951
2951
  ];
2952
2952
  return [
2953
2953
  '', ...brand, '',
2954
2954
  clip(`● ${activity}`, available),
2955
- clip(`Workflow · ${graphName}${nodeCount}`, available),
2955
+ clip(`Graph · ${graphName}${nodeCount}`, available),
2956
2956
  ...(status.graphNeedsOverride ? [paint(clip(OVERRIDE_HINT, available), ATTENTION)] : []),
2957
2957
  '',
2958
2958
  ...(viewportHeight >= 10 ? ['Describe a task to get started.'] : []),
@@ -0,0 +1,53 @@
1
+ /**
2
+ * What a model working under a wall-clock limit is told about it.
3
+ *
4
+ * The runtime has always enforced `limits.wallTimeMs`: when the clock runs out the attempt is
5
+ * stopped where it stands. The model was never told there was a clock. In a benchmark run with a
6
+ * fifteen-minute limit the agent spent the whole allowance at full reasoning effort on one build,
7
+ * was stopped with nothing usable on disk, and never knew the end was near; the trials that
8
+ * survived a stop did so only because their output happened to be written already.
9
+ *
10
+ * So a bounded attempt is told three things: that there is a limit and what it means for how to
11
+ * work (once, in the system prompt, where it never changes and so never disturbs the cached
12
+ * prefix), and how much time is left as it runs down (a short runtime message when half, a quarter
13
+ * and a tenth remain, appended at the tail of the conversation). An unbounded attempt, which is the
14
+ * default, is told nothing.
15
+ * @module time-limit
16
+ */
17
+ /**
18
+ * Below this a limit is too short for a notice to be acted on; the prompt line still applies.
19
+ * A node inside a graph is handed what is left of the graph's limit, a few milliseconds under the
20
+ * configured figure, so a configured two minutes must sit clear of this floor.
21
+ */
22
+ export declare const TIME_NOTICE_MIN_LIMIT_MS = 90000;
23
+ interface Stage {
24
+ id: 'half' | 'quarter' | 'tenth';
25
+ remaining: number;
26
+ text: (left: string) => string;
27
+ }
28
+ /** "about 7 minutes" or "about 40 seconds": the model plans in round figures, not milliseconds. */
29
+ export declare function formatTimeLeft(ms: number): string;
30
+ /** The system-prompt paragraph for an attempt that has `limitMs` of wall-clock time. */
31
+ export declare function timeLimitPrompt(limitMs: number): string;
32
+ /**
33
+ * A system prompt with the time-limit paragraph for `limitMs`, replacing any it already holds.
34
+ *
35
+ * A resumed attempt restores the stopped attempt's conversation, system message included, while
36
+ * its limit is narrowed to what was left of the clock. Left alone, the restored prompt would still
37
+ * promise the original fifteen minutes to a run that has one; and with less than the notice floor
38
+ * left, no later notice would correct it.
39
+ */
40
+ export declare function withTimeLimitPrompt(system: string, limitMs: number | undefined): string;
41
+ export interface TimeLimitNotice {
42
+ stage: Stage['id'];
43
+ text: string;
44
+ }
45
+ /**
46
+ * The notices for one attempt. `next` is asked before each model request with the time still
47
+ * left; it answers at most once per stage, and when several stages passed during one long step it
48
+ * answers only for the most urgent, since the earlier ones describe a moment that is gone.
49
+ */
50
+ export declare function createTimeLimitNotices(limitMs: number): {
51
+ next(remainingMs: number | undefined): TimeLimitNotice | undefined;
52
+ };
53
+ export {};
@@ -0,0 +1,79 @@
1
+ /**
2
+ * What a model working under a wall-clock limit is told about it.
3
+ *
4
+ * The runtime has always enforced `limits.wallTimeMs`: when the clock runs out the attempt is
5
+ * stopped where it stands. The model was never told there was a clock. In a benchmark run with a
6
+ * fifteen-minute limit the agent spent the whole allowance at full reasoning effort on one build,
7
+ * was stopped with nothing usable on disk, and never knew the end was near; the trials that
8
+ * survived a stop did so only because their output happened to be written already.
9
+ *
10
+ * So a bounded attempt is told three things: that there is a limit and what it means for how to
11
+ * work (once, in the system prompt, where it never changes and so never disturbs the cached
12
+ * prefix), and how much time is left as it runs down (a short runtime message when half, a quarter
13
+ * and a tenth remain, appended at the tail of the conversation). An unbounded attempt, which is the
14
+ * default, is told nothing.
15
+ * @module time-limit
16
+ */
17
+ /**
18
+ * Below this a limit is too short for a notice to be acted on; the prompt line still applies.
19
+ * A node inside a graph is handed what is left of the graph's limit, a few milliseconds under the
20
+ * configured figure, so a configured two minutes must sit clear of this floor.
21
+ */
22
+ export const TIME_NOTICE_MIN_LIMIT_MS = 90_000;
23
+ /** Most urgent last, so the stage that applies is the last one whose share has been reached. */
24
+ const STAGES = [
25
+ { id: 'half', remaining: 0.5, text: left => `Runtime: half of this run's time limit is used; ${left} remain. Check that every output the task requires already exists in a usable form, write any that does not, then keep going.` },
26
+ { id: 'quarter', remaining: 0.25, text: left => `Runtime: ${left} remain of this run's time limit. Put the best version you have of every required output on disk now, then keep working on what is still missing or failing. Do not finish early: time left unused is worth nothing, and a task reported as unfinished is not accepted while time remains.` },
27
+ { id: 'tenth', remaining: 0.1, text: left => `Runtime: ${left} remain and the run is stopped when the time is up. Keep the required outputs on disk in their best state at every moment from here on, and spend what is left on small, quick fixes to what is still failing. Finish only if the task is done.` },
28
+ ];
29
+ /** "about 7 minutes" or "about 40 seconds": the model plans in round figures, not milliseconds. */
30
+ export function formatTimeLeft(ms) {
31
+ const seconds = Math.max(0, Math.round(ms / 1000));
32
+ if (seconds < 90)
33
+ return `about ${Math.max(5, Math.round(seconds / 5) * 5)} seconds`;
34
+ const minutes = Math.round(seconds / 60);
35
+ if (minutes < 90)
36
+ return `about ${minutes} minutes`;
37
+ const hours = Math.round(minutes / 6) / 10;
38
+ return `about ${hours} hours`;
39
+ }
40
+ /** The system-prompt paragraph for an attempt that has `limitMs` of wall-clock time. */
41
+ export function timeLimitPrompt(limitMs) {
42
+ return `This run has a wall-clock limit of ${formatTimeLeft(limitMs)}. When the time is up the run is stopped where it stands and only what is already on disk counts, so write a working version of every required output early and improve it afterwards rather than saving it for the end. Size commands, installs and your own deliberation to the time available. Use all of it: do not end the run early with the task unfinished. The runtime tells you when half, a quarter and a tenth of the time remain.`;
43
+ }
44
+ const PROMPT_LINE = /\nThis run has a wall-clock limit of [^\n]*/g;
45
+ /**
46
+ * A system prompt with the time-limit paragraph for `limitMs`, replacing any it already holds.
47
+ *
48
+ * A resumed attempt restores the stopped attempt's conversation, system message included, while
49
+ * its limit is narrowed to what was left of the clock. Left alone, the restored prompt would still
50
+ * promise the original fifteen minutes to a run that has one; and with less than the notice floor
51
+ * left, no later notice would correct it.
52
+ */
53
+ export function withTimeLimitPrompt(system, limitMs) {
54
+ const stripped = system.replace(PROMPT_LINE, '');
55
+ return limitMs ? `${stripped}\n${timeLimitPrompt(limitMs)}` : stripped;
56
+ }
57
+ /**
58
+ * The notices for one attempt. `next` is asked before each model request with the time still
59
+ * left; it answers at most once per stage, and when several stages passed during one long step it
60
+ * answers only for the most urgent, since the earlier ones describe a moment that is gone.
61
+ */
62
+ export function createTimeLimitNotices(limitMs) {
63
+ let announced = -1;
64
+ return {
65
+ next(remainingMs) {
66
+ if (remainingMs === undefined || limitMs < TIME_NOTICE_MIN_LIMIT_MS)
67
+ return undefined;
68
+ let reached = -1;
69
+ for (const [index, stage] of STAGES.entries())
70
+ if (remainingMs <= limitMs * stage.remaining)
71
+ reached = index;
72
+ if (reached <= announced)
73
+ return undefined;
74
+ announced = reached;
75
+ const stage = STAGES[reached];
76
+ return { stage: stage.id, text: stage.text(formatTimeLeft(remainingMs)) };
77
+ },
78
+ };
79
+ }
package/dist/src/tools.js CHANGED
@@ -14,6 +14,8 @@ import { andorraCreateWriteTool } from '../vendor/engine/runtime/coding-agent/co
14
14
  import { andorraWithFileMutationQueue } from '../vendor/engine/runtime/coding-agent/core/tools/file-mutation-queue.js';
15
15
  import { andorraDetectSupportedImageMimeType } from '../vendor/engine/runtime/coding-agent/utils/mime.js';
16
16
  import { READ_IMAGE_FILE_LIMIT } from './read-image.js';
17
+ import { decodeLegacyText, sniffDocument } from './read-document.js';
18
+ import { READ_DOCUMENT_FILE_LIMIT } from './read-document-tool.js';
17
19
  import { clipText } from './text.js';
18
20
  import { pullRequestSettings } from './pull-requests.js';
19
21
  import { approveOperation } from './capabilities.js';
@@ -244,6 +246,56 @@ async function readImage(context, name) {
244
246
  await handle.close();
245
247
  }
246
248
  }
249
+ /**
250
+ * The whole of a regular file whose leading bytes `accept` recognizes, or undefined when they are
251
+ * not recognized or the path is not a regular file. Same guards as the text and image readers:
252
+ * the path policy, a non-blocking open, the size bound checked on the open handle, and one byte
253
+ * past the bound read so a file that grows mid-read is refused rather than truncated.
254
+ */
255
+ async function readRecognized(context, name, limit, what, accept) {
256
+ const resolved = await safePath(context, name);
257
+ if (!(await stat(resolved)).isFile())
258
+ return undefined;
259
+ context.signal.throwIfAborted();
260
+ const handle = await open(resolved, constants.O_RDONLY | (process.platform === 'win32' ? 0 : constants.O_NONBLOCK));
261
+ try {
262
+ const info = await handle.stat();
263
+ if (!info.isFile())
264
+ return undefined;
265
+ const head = Buffer.alloc(4100);
266
+ const sniffed = await handle.read(head, 0, head.length, 0);
267
+ if (!accept(head.subarray(0, sniffed.bytesRead)))
268
+ return undefined;
269
+ if (info.size > limit)
270
+ throw new Error(`${what} exceeds the ${limit / (1024 * 1024)} MiB read limit`);
271
+ const chunks = [];
272
+ let size = 0;
273
+ while (size <= limit) {
274
+ context.signal.throwIfAborted();
275
+ const chunk = Buffer.alloc(Math.min(256 * 1024, limit + 1 - size));
276
+ const result = await handle.read(chunk, 0, chunk.length, size);
277
+ if (!result.bytesRead)
278
+ break;
279
+ size += result.bytesRead;
280
+ chunks.push(chunk.subarray(0, result.bytesRead));
281
+ }
282
+ if (size > limit)
283
+ throw new Error(`${what} grew beyond the read limit`);
284
+ return Buffer.concat(chunks, size);
285
+ }
286
+ finally {
287
+ await handle.close();
288
+ }
289
+ }
290
+ /** The bytes of a file that opens like a PDF, a zip (docx) or a compound file (doc); undefined otherwise. */
291
+ function readDocument(context, name) {
292
+ return readRecognized(context, name, READ_DOCUMENT_FILE_LIMIT, 'File', head => sniffDocument(head) !== undefined);
293
+ }
294
+ /** A text file in an older encoding, decoded; undefined when the bytes do not look like text. */
295
+ async function readLegacyText(context, name) {
296
+ const bytes = await readRecognized(context, name, FILE_LIMIT, 'File', () => true);
297
+ return bytes ? decodeLegacyText(bytes) : undefined;
298
+ }
247
299
  function assertMutationPermission(context) {
248
300
  if (!context.pinFilePaths && !context.fileMutationApproval?.explicit && (permissionMode(context) === 'read-only' || permissionMode(context) === 'plan'))
249
301
  throw new Error('Permission denied: file mutation grant was revoked');
@@ -285,7 +337,12 @@ async function atomicWrite(context, name, content, expectedContent) {
285
337
  context.signal.throwIfAborted();
286
338
  await mutationPermission(context, name);
287
339
  assertMutationPermission(context);
288
- const handle = await open(temporary, 'wx', 0o600);
340
+ // A replacement starts private and takes the old file's mode below, so its content is never
341
+ // briefly more readable than the file it replaces. A new file has no mode to inherit: it is
342
+ // created like any other program creates one (0666 narrowed by the process umask), not 0600,
343
+ // which left files the agent wrote unreadable to a web server, a test runner or any other
344
+ // account that was meant to use them.
345
+ const handle = await open(temporary, 'wx', existing ? 0o600 : 0o666);
289
346
  created = true;
290
347
  try {
291
348
  await mutationPermission(context, name);
@@ -637,6 +694,21 @@ function qaPermissionTool(tool) {
637
694
  return tool.execute(args, context);
638
695
  } };
639
696
  }
697
+ const AWAIT_REVIEW_DEFAULT_MINUTES = 360;
698
+ /** What a review wait tells the agent to do next. */
699
+ function reviewWaitAnswer(ended, minutes, signal) {
700
+ switch (ended.kind) {
701
+ case 'comments': return `${ended.prompt}
702
+
703
+ When this round is pushed and its threads are answered, call pull_request with action await_review again to wait for the next review.`;
704
+ case 'finished': return `${ended.pullRequest.url} is ${ended.pullRequest.state}, so Auto-fix is off and there is no review left to wait for. Finish your work and report.`;
705
+ case 'off': return `Auto-fix is off for ${ended.pullRequest.url}, so no review will be waited for. Finish your work and report; switch Auto-fix on only if the user asks.`;
706
+ case 'none': return 'No pull request is tracked for this session, so there is no review to wait for.';
707
+ case 'timeout': return `No new review arrived in ${minutes} minute${minutes === 1 ? '' : 's'}. Call await_review again to keep waiting, or finish and report.`;
708
+ case 'steered': return 'The user sent you a message while you were waiting for a review. Read and answer it; call await_review again afterwards if the review loop should continue.';
709
+ case 'aborted': throw signal.reason instanceof Error ? signal.reason : new Error('The run was stopped while it waited for a review.');
710
+ }
711
+ }
640
712
  export function createTools() {
641
713
  return [
642
714
  createAutomationTool(),
@@ -778,12 +850,13 @@ export function createTools() {
778
850
  context.wakesArmed?.push(timer.id);
779
851
  return `Timer ${timer.id.slice(0, 8)} armed: your prompt will be delivered in ${args.seconds} second${args.seconds === 1 ? '' : 's'}, at ${new Date(timer.fireAt).toISOString()}. It fires once.`;
780
852
  }),
781
- { ...tool('pull_request', 'Show or change the pull request this session tracks in the desktop Plan card. A PR you open with `gh pr create` is attached automatically; use attach for one opened another way. update changes its settings when the user asks: mergeWhenReady enables GitHub auto-merge (gh pr merge --auto), draft converts to a draft or marks it ready, autoFix wakes you with a prompt when a code-review bot (Codex, CodeRabbit, Greptile, Copilot) comments and switches itself off once the PR is merged or closed. dismiss removes it from the card. Only change a setting the user asked you to change.', {
782
- action: { type: 'string', enum: ['status', 'attach', 'update', 'dismiss'], description: 'status shows the tracked PR; attach starts tracking url; update changes settings; dismiss stops tracking' },
853
+ { ...tool('pull_request', 'Show or change the pull request this session tracks in the desktop Plan card. A PR you open with `gh pr create` is attached automatically; use attach for one opened another way. update changes its settings when the user asks: mergeWhenReady enables GitHub auto-merge (gh pr merge --auto), draft converts to a draft or marks it ready, autoFix wakes you with a prompt when a code-review bot (Codex, CodeRabbit, Greptile, Copilot) comments and switches itself off once the PR is merged or closed. await_review keeps you in this run while Auto-fix is on: it waits, without using the model, until new review comments arrive (and returns them), the PR is merged or closed, the user messages you, or timeoutMinutes pass. Use it to own the review loop: fix a round, push, resolve the threads you fixed, then call await_review again, until the PR is merged or closed. Never wait for a review with sleep, a shell loop or set_timer. dismiss removes it from the card. Only change a setting the user asked you to change.', {
854
+ action: { type: 'string', enum: ['status', 'attach', 'update', 'await_review', 'dismiss'], description: 'status shows the tracked PR; attach starts tracking url; update changes settings; await_review waits for the next review round; dismiss stops tracking' },
783
855
  url: property('The GitHub pull request URL (attach only)'),
784
856
  autoFix: { type: 'boolean', description: 'Wake this session when a code-review bot (Codex, CodeRabbit, Greptile, Copilot) comments, until the PR is merged or closed' },
785
857
  mergeWhenReady: { type: 'boolean', description: 'GitHub auto-merge once checks and reviews pass' },
786
858
  draft: { type: 'boolean', description: 'true converts to a draft, false marks it ready for review' },
859
+ timeoutMinutes: { type: 'integer', minimum: 1, maximum: 1440, description: `How long await_review waits for a review before returning (1 to 1440, default ${AWAIT_REVIEW_DEFAULT_MINUTES})` },
787
860
  }, ['action'], async (args, context) => {
788
861
  const control = context.pullRequests;
789
862
  if (!control)
@@ -803,21 +876,33 @@ export function createTools() {
803
876
  const url = string(args, 'url');
804
877
  if (Object.keys(settings).length)
805
878
  await approve();
806
- return `Tracking ${describe(await control.attach(url, settings))}`;
879
+ return `Tracking ${describe(await control.attach(url, settings, context.wakeOrigin))}`;
807
880
  }
808
881
  case 'update': {
809
882
  if (!Object.keys(settings).length)
810
883
  throw new Error('update needs at least one of autoFix, mergeWhenReady, draft');
811
884
  await approve();
812
- return `Updated ${describe(await control.update(settings))}`;
885
+ return `Updated ${describe(await control.update(settings, context.wakeOrigin))}`;
886
+ }
887
+ case 'await_review': {
888
+ if (!control.awaitReview)
889
+ throw new Error('await_review is unavailable here; this surface cannot hold a run open for a review. End your turn: Auto-fix wakes you when comments arrive.');
890
+ const minutes = args.timeoutMinutes === undefined ? AWAIT_REVIEW_DEFAULT_MINUTES : args.timeoutMinutes;
891
+ if (typeof minutes !== 'number' || !Number.isSafeInteger(minutes) || minutes < 1 || minutes > 1_440)
892
+ throw new Error('timeoutMinutes must be an integer from 1 to 1440');
893
+ const awaitReview = control.awaitReview.bind(control);
894
+ const wait = () => awaitReview(context.signal, minutes * 60_000, context.wakeOrigin);
895
+ // Waiting on a reviewer is not the run's work: its time limits are paused for as long as this waits.
896
+ const ended = await (context.waitOutside ? context.waitOutside(wait) : wait());
897
+ return reviewWaitAnswer(ended, minutes, context.signal);
813
898
  }
814
899
  case 'dismiss':
815
900
  await control.dismiss();
816
901
  return 'The pull request is no longer tracked for this session.';
817
- default: throw new Error('action must be status, attach, update, or dismiss');
902
+ default: throw new Error('action must be status, attach, update, await_review, or dismiss');
818
903
  }
819
904
  }), family: 'git', executionMode: 'sequential' },
820
- ...createCodingTools({ safePath, read, readImage, atomicWrite, authorize, files, fileLimit: FILE_LIMIT }),
905
+ ...createCodingTools({ safePath, read, readImage, readDocument, readLegacyText, atomicWrite, authorize, files, fileLimit: FILE_LIMIT }),
821
906
  ...createQaTools().map(qaPermissionTool),
822
907
  createBrowserSessionTool(authorize),
823
908
  createSolveCaptchaTool(authorize),