@andorra-labs/code 0.1.6 → 0.1.7

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 (108) hide show
  1. package/dist/src/agent-execution.js +404 -25
  2. package/dist/src/agent-mcp-catalog.d.ts +21 -0
  3. package/dist/src/agent-mcp-catalog.js +40 -0
  4. package/dist/src/agent-mcp.d.ts +19 -3
  5. package/dist/src/agent-mcp.js +18 -44
  6. package/dist/src/app-server/protocol.d.ts +25 -3
  7. package/dist/src/app-server/protocol.js +5 -1
  8. package/dist/src/app-server/workspace.d.ts +8 -1
  9. package/dist/src/app-server/workspace.js +43 -2
  10. package/dist/src/app-server.js +88 -3
  11. package/dist/src/auth/AuthManager.d.ts +33 -1
  12. package/dist/src/auth/AuthManager.js +138 -10
  13. package/dist/src/auth/callback-page.d.ts +4 -0
  14. package/dist/src/auth/callback-page.js +70 -0
  15. package/dist/src/auth/callback.d.ts +39 -0
  16. package/dist/src/auth/callback.js +146 -22
  17. package/dist/src/auth/index.d.ts +10 -6
  18. package/dist/src/auth/index.js +2 -2
  19. package/dist/src/auth/store.d.ts +142 -3
  20. package/dist/src/auth/store.js +334 -13
  21. package/dist/src/auth/types.d.ts +17 -1
  22. package/dist/src/auth-commands.d.ts +11 -2
  23. package/dist/src/auth-commands.js +14 -7
  24. package/dist/src/automation-tool.js +10 -2
  25. package/dist/src/automations.d.ts +5 -0
  26. package/dist/src/automations.js +10 -0
  27. package/dist/src/capabilities.d.ts +9 -3
  28. package/dist/src/capabilities.js +7 -3
  29. package/dist/src/cli.js +31 -4
  30. package/dist/src/codex-provider.js +12 -0
  31. package/dist/src/coding-tools.d.ts +5 -0
  32. package/dist/src/coding-tools.js +54 -48
  33. package/dist/src/commands.d.ts +5 -1
  34. package/dist/src/commands.js +7 -6
  35. package/dist/src/completion.js +46 -0
  36. package/dist/src/config.d.ts +48 -0
  37. package/dist/src/config.js +248 -10
  38. package/dist/src/context-budget.d.ts +7 -0
  39. package/dist/src/context-budget.js +18 -1
  40. package/dist/src/decision/FactContinuations.d.ts +41 -6
  41. package/dist/src/decision/FactContinuations.js +211 -64
  42. package/dist/src/decision/PreparedSteps.js +3 -1
  43. package/dist/src/decision/checks.d.ts +25 -0
  44. package/dist/src/decision/checks.js +77 -6
  45. package/dist/src/delegation-changes.d.ts +109 -0
  46. package/dist/src/delegation-changes.js +431 -0
  47. package/dist/src/graph-server.d.ts +1 -0
  48. package/dist/src/graph-server.js +15 -3
  49. package/dist/src/graph-sync.d.ts +15 -0
  50. package/dist/src/graph-sync.js +50 -1
  51. package/dist/src/graph-tool.d.ts +52 -0
  52. package/dist/src/graph-tool.js +136 -0
  53. package/dist/src/graph-ui/app.js +212 -43
  54. package/dist/src/graph-ui/controls.js +6 -0
  55. package/dist/src/graph-ui/drafts.js +39 -0
  56. package/dist/src/graph-ui/embed.js +1 -1
  57. package/dist/src/graph-ui/index.html +2 -2
  58. package/dist/src/graph-ui/studio.css +7 -5
  59. package/dist/src/graph-ui/style.css +46 -12
  60. package/dist/src/graphs.d.ts +15 -2
  61. package/dist/src/graphs.js +42 -13
  62. package/dist/src/hardened-runtime.d.ts +4 -4
  63. package/dist/src/hardened-runtime.js +109 -9
  64. package/dist/src/powershell-pool.d.ts +9 -0
  65. package/dist/src/powershell-pool.js +16 -0
  66. package/dist/src/provider-keys.d.ts +48 -0
  67. package/dist/src/provider-keys.js +121 -0
  68. package/dist/src/pull-requests.d.ts +14 -5
  69. package/dist/src/pull-requests.js +28 -10
  70. package/dist/src/qa/runtime/ProcessManager.d.ts +6 -0
  71. package/dist/src/qa/runtime/ProcessManager.js +16 -0
  72. package/dist/src/react-runtime.js +30 -2
  73. package/dist/src/read-image.d.ts +30 -0
  74. package/dist/src/read-image.js +97 -0
  75. package/dist/src/secret-redaction.d.ts +13 -0
  76. package/dist/src/secret-redaction.js +71 -0
  77. package/dist/src/session-summary.d.ts +10 -4
  78. package/dist/src/session-summary.js +14 -7
  79. package/dist/src/sessions.js +4 -1
  80. package/dist/src/skills/bundled/graph-manager/SKILL.md +14 -11
  81. package/dist/src/skills/bundled/provenance.json +1 -1
  82. package/dist/src/telemetry/schema.d.ts +1 -1
  83. package/dist/src/telemetry/schema.js +1 -1
  84. package/dist/src/terminal-ui.d.ts +9 -0
  85. package/dist/src/terminal-ui.js +14 -0
  86. package/dist/src/tool-dependencies.js +4 -0
  87. package/dist/src/tools.d.ts +9 -0
  88. package/dist/src/tools.js +116 -11
  89. package/dist/src/transcript.js +5 -0
  90. package/dist/src/types.d.ts +13 -0
  91. package/dist/src/web-search.d.ts +59 -0
  92. package/dist/src/web-search.js +216 -0
  93. package/docs/agents/README.md +2 -2
  94. package/docs/agents/mcp-server.md +15 -2
  95. package/docs/concepts/README.md +1 -1
  96. package/docs/concepts/security.md +2 -2
  97. package/docs/getting-started/accounts.md +15 -4
  98. package/docs/getting-started/configure-providers.md +1 -1
  99. package/docs/guides/README.md +1 -0
  100. package/docs/guides/desktop-app.md +1 -1
  101. package/docs/guides/graph-builder.md +1 -1
  102. package/docs/guides/web-search.md +47 -0
  103. package/docs/reference/cli.md +4 -3
  104. package/docs/reference/config.md +3 -3
  105. package/docs/reference/slash-commands.md +2 -1
  106. package/docs/superpowers/plans/2026-11-09-orchestrator-delegation.md +295 -0
  107. package/docs/superpowers/specs/2026-11-09-orchestrator-delegation-design.md +291 -0
  108. package/package.json +1 -1
@@ -3,5 +3,5 @@
3
3
  <head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Graph studio - Andorra Code</title><link rel="icon" type="image/png" href="/andorra-logo.png"><link rel="stylesheet" href="/tokens.css"><link rel="stylesheet" href="/style.css"><link rel="stylesheet" href="/library.css"><link rel="stylesheet" href="/studio.css"><link rel="stylesheet" href="/controls.css"><script src="/theme.js"></script></head>
4
4
  <body>
5
5
  <aside class="rail" id="library-rail"><div id="rail-resize" role="separator" aria-label="Resize library sidebar" aria-orientation="vertical" aria-controls="library-rail" tabindex="0"></div><div class="rail-body" tabindex="0" aria-label="Graph and node library"><div class="section-label">Your graphs <button id="new-graph" aria-label="Create graph" title="Create graph" data-icon="plus"></button></div><input id="search" type="search" placeholder="Find a graph" aria-label="Find a graph"><nav id="graphs" aria-label="Graphs" tabindex="0"></nav><div class="section-label library-label">Node library</div><input id="node-search" type="search" placeholder="Search nodes..." aria-label="Search nodes"><nav id="node-library" aria-label="Node library"></nav><p class="hint">Drag a node onto the canvas, or select it and press Enter to add it. Connect each outcome to one or more destinations.</p></div><footer class="rail-footer">Your account <span id="sync-status" role="status">Saved locally; cloud sync pending</span></footer></aside>
6
- <main><header class="chrome"><div id="host-chrome" class="host-chrome" hidden></div><div class="graph-heading"><strong id="graph-title">Graph studio</strong><span id="revision">Loading graphs...</span><span id="host-notice" class="chip chip-accent" role="status" hidden></span></div><div class="chrome-actions" id="chrome-actions"><button id="toggle-inspector" class="icon-button" aria-expanded="true" aria-label="Inspector" title="Show or hide the inspector" data-icon="panel-right"></button><div class="menu" id="more-wrap"><button id="more" class="icon-button" aria-haspopup="menu" aria-expanded="false" aria-controls="more-menu" aria-label="More actions" title="More actions" data-icon="more"></button><div id="more-menu" class="menu-list" role="menu" aria-label="More actions" hidden><button id="duplicate" type="button" role="menuitem" data-icon="copy">Duplicate</button></div></div><button id="save" class="primary">Save revision</button></div></header><div class="workspace"><section id="canvas" aria-label="Graph canvas"><div id="scene"><svg id="edges" aria-label="Graph connections"></svg><div id="nodes"></div></div><div id="empty">Create a graph to get started.</div><div id="canvas-hint" class="canvas-hint" role="note"><span id="canvas-hint-text">Drag the background to pan - Scroll to zoom</span><button id="canvas-hint-close" type="button" class="icon-button" aria-label="Dismiss canvas tips" title="Dismiss" data-icon="x"></button></div><div class="canvas-toolbar" role="toolbar" aria-label="Canvas controls"><button id="undo" aria-label="Undo" title="Undo (Ctrl/Cmd+Z)" data-icon="undo"></button><button id="redo" aria-label="Redo" title="Redo (Ctrl/Cmd+Y)" data-icon="redo"></button><span class="toolbar-divider" aria-hidden="true"></span><button id="zoom-out" aria-label="Zoom out" title="Zoom out" data-icon="zoom-out"></button><output id="zoom" aria-label="Zoom level">100%</output><button id="zoom-in" aria-label="Zoom in" title="Zoom in" data-icon="zoom-in"></button><button id="fit" aria-label="Fit graph" title="Fit graph" data-icon="fit"></button><button id="layout" aria-label="Arrange" title="Arrange nodes" data-icon="arrange"></button></div></section><aside id="inspector"><div id="resize" role="separator" aria-label="Resize inspector" aria-orientation="vertical" tabindex="0"></div><header class="panel-header"><strong id="inspector-title">Graph settings</strong><button id="graph-settings" class="btn-small">Graph</button></header><div id="inspector-body"></div></aside></div><footer class="status"><span id="status" role="status" aria-live="polite">Connecting to your workspace...</span><span class="status-actions"><button id="theme-toggle" type="button" hidden>Light</button><button id="export">Export JSON</button></span></footer></main>
7
- <script src="/compat.js" defer></script><script src="/icons.js" defer></script><script src="/controls.js" defer></script><script src="/skill-picker.js" defer></script><script src="/edge-router.js" defer></script><script src="/app.js" defer></script><script src="/embed.js" defer></script><script src="/sidebar.js" defer></script><script src="/studio.js" defer></script><script src="/studio-canvas.js" defer></script></body></html>
6
+ <main><header class="chrome"><div id="host-chrome" class="host-chrome" hidden></div><div class="graph-heading"><strong id="graph-title">Graph studio</strong><span id="revision">Loading graphs...</span><span id="host-notice" class="chip chip-accent" role="status" hidden></span></div><div class="chrome-actions" id="chrome-actions"><button id="toggle-inspector" class="icon-button" aria-expanded="true" aria-label="Inspector" title="Show or hide the inspector" data-icon="panel-right"></button><div class="menu" id="more-wrap"><button id="more" class="icon-button" aria-haspopup="menu" aria-expanded="false" aria-controls="more-menu" aria-label="More actions" title="More actions" data-icon="more"></button><div id="more-menu" class="menu-list" role="menu" aria-label="More actions" hidden><button id="duplicate" type="button" role="menuitem" data-icon="copy">Duplicate</button></div></div><button id="save" class="primary">Save revision</button></div></header><div class="workspace"><section id="canvas" aria-label="Graph canvas"><div id="scene"><svg id="edges" aria-label="Graph connections"></svg><div id="nodes"></div></div><div id="empty">Create a graph to get started.</div><div id="canvas-hint" class="canvas-hint" role="note"><span id="canvas-hint-text">Drag the background to pan - Scroll to zoom</span><button id="canvas-hint-close" type="button" class="icon-button" aria-label="Dismiss canvas tips" title="Dismiss" data-icon="x"></button></div><div class="canvas-toolbar" role="toolbar" aria-label="Canvas controls"><button id="undo" aria-label="Undo" title="Undo (Ctrl/Cmd+Z)" data-icon="undo"></button><button id="redo" aria-label="Redo" title="Redo (Ctrl/Cmd+Y)" data-icon="redo"></button><span class="toolbar-divider" aria-hidden="true"></span><button id="zoom-out" aria-label="Zoom out" title="Zoom out" data-icon="zoom-out"></button><output id="zoom" aria-label="Zoom level">100%</output><button id="zoom-in" aria-label="Zoom in" title="Zoom in" data-icon="zoom-in"></button><button id="fit" aria-label="Fit graph" title="Fit graph" data-icon="fit"></button><button id="layout" aria-label="Arrange" title="Arrange nodes" data-icon="arrange"></button></div></section><aside id="inspector"><div id="resize" role="separator" aria-label="Resize inspector" aria-orientation="vertical" tabindex="0"></div><header class="panel-header"><strong id="inspector-title">Graph settings</strong><button id="graph-settings" class="btn-small" title="Show the graph's own settings">Graph settings</button></header><div id="inspector-body"></div></aside></div><footer class="status"><span id="status" role="status" aria-live="polite">Connecting to your workspace...</span><span class="status-actions"><button id="theme-toggle" type="button" hidden>Light</button><button id="export">Export JSON</button></span></footer></main>
7
+ <script src="/compat.js" defer></script><script src="/icons.js" defer></script><script src="/controls.js" defer></script><script src="/skill-picker.js" defer></script><script src="/edge-router.js" defer></script><script src="/drafts.js" defer></script><script src="/app.js" defer></script><script src="/embed.js" defer></script><script src="/sidebar.js" defer></script><script src="/studio.js" defer></script><script src="/studio-canvas.js" defer></script></body></html>
@@ -73,14 +73,16 @@
73
73
 
74
74
  #studio-minimap {
75
75
  position: absolute; bottom: var(--space-4); right: var(--space-4); width: 160px; height: 100px;
76
- border: 1px solid var(--border); background: var(--bg-input); border-radius: 8px;
77
- box-shadow: var(--shadow-menu); z-index: 4; cursor: crosshair;
76
+ border: 1px solid var(--border); background: var(--bg-input); border-radius: var(--card-radius);
77
+ box-shadow: var(--shadow-menu); z-index: 4; cursor: crosshair; overflow: hidden;
78
78
  }
79
- #studio-minimap .studio-minimap-node { fill: var(--text-3); stroke: var(--border-strong); }
80
- #studio-minimap .studio-minimap-end { fill: var(--ok); }
79
+ /* The map is a sketch of the canvas: nodes are quiet blocks in the card's own outline colour, so
80
+ the viewport's frame is the brightest thing on it. */
81
+ #studio-minimap .studio-minimap-node { fill: var(--border-strong); stroke: none; rx: 2px; }
82
+ #studio-minimap .studio-minimap-end { fill: var(--ok); stroke: none; rx: 2px; opacity: .8; }
81
83
  /* The viewport is a faint wash. A webview without `color-mix()` keeps the fallback, which leaves
82
84
  the rectangle unfilled rather than drawing it as a solid block. */
83
- #studio-minimap .studio-minimap-viewport { fill: transparent; fill: color-mix(in srgb, var(--accent) 10%, transparent); stroke: var(--text-3); stroke-width: 1; pointer-events: none; }
85
+ #studio-minimap .studio-minimap-viewport { fill: transparent; fill: color-mix(in srgb, var(--accent) 10%, transparent); stroke: var(--border-strong); stroke-width: 1; rx: 3px; vector-effect: non-scaling-stroke; pointer-events: none; }
84
86
 
85
87
  /* Node run states. The live state is the register's own "alive" colour; the settled states are
86
88
  the two colours the chrome allows, done and error. */
@@ -113,7 +113,9 @@ textarea { resize: vertical; min-height: 140px; line-height: 1.5; }
113
113
  }
114
114
  .rail > * { position: relative; z-index: 1; }
115
115
 
116
- .rail-footer span { display: block; font-size: var(--type-xs); font-weight: var(--weight-regular); color: var(--text-3); margin-top: var(--space-1); }
116
+ /* The footer is one status line under a quiet label: a dot, then what the account's sync is doing. */
117
+ .rail-footer span { display: flex; align-items: baseline; gap: 6px; font-size: var(--type-xs); font-weight: var(--weight-regular); color: var(--text-2); margin-top: 2px; line-height: 1.4; }
118
+ .rail-footer span::before { content: ''; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); transform: translateY(-1px); }
117
119
 
118
120
  /* The window title already names the product, so the rail opens straight onto the graphs. */
119
121
  .rail-body { padding: var(--space-3) var(--space-2) var(--space-4); overflow: auto; flex: 1; min-height: 0; }
@@ -129,9 +131,34 @@ textarea { resize: vertical; min-height: 140px; line-height: 1.5; }
129
131
  .section-label button:hover:not(:disabled) { background: var(--rail-wash); color: var(--text); }
130
132
 
131
133
  #search, #node-search { margin-bottom: var(--space-3); }
134
+ /* The rail's two filters rest as a quiet wash with a magnifier, not an outlined box: the rail is a
135
+ list of rows, and an outline at rest read as a form. The outline returns under the pointer and
136
+ the accent ring on focus. The glyph is a mid grey that holds on both grounds. */
137
+ .rail input[type="search"] {
138
+ padding-left: 30px; border-color: transparent; background-color: var(--rail-wash);
139
+ background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23858585' stroke-width='2' stroke-linecap='round'><circle cx='11' cy='11' r='7'/><path d='m20 20-3.6-3.6'/></svg>");
140
+ background-repeat: no-repeat; background-position: 9px 50%; background-size: 14px 14px;
141
+ }
142
+ .rail input[type="search"]:hover { border-color: var(--border-strong); }
143
+ .rail input[type="search"]:focus-visible { border-color: var(--accent); background-color: var(--bg-input); }
132
144
 
133
145
  /* Rows: one anatomy, everywhere. */
134
- #graphs { display: grid; gap: 1px; }
146
+ #graphs { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1px; }
147
+ /* Drafts are a second, quieter group under the saved graphs. */
148
+ .graph-drafts-head {
149
+ display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
150
+ margin-top: var(--space-2); padding: var(--space-1) var(--space-2) 2px;
151
+ font-size: var(--type-xs); color: var(--text-3);
152
+ }
153
+ .graph-drafts-clear, .graph-drafts-toggle {
154
+ border: 0; background: transparent; min-height: 0; height: auto; width: auto;
155
+ padding: 2px var(--space-1); border-radius: var(--row-radius);
156
+ font: inherit; font-size: var(--type-xs); color: var(--text-3); cursor: pointer;
157
+ }
158
+ .graph-drafts-clear:hover:not(:disabled), .graph-drafts-toggle:hover { background: var(--rail-wash); color: var(--text); }
159
+ .graph-drafts-toggle { justify-self: start; margin: 2px var(--space-1) 0; }
160
+ .graph-row.draft-row span { color: var(--text-2); }
161
+ .graph-row.draft-row small { font-variant-numeric: tabular-nums; }
135
162
  .graph-row {
136
163
  display: flex; align-items: center; justify-content: space-between; width: 100%;
137
164
  min-height: var(--row-height); padding: 0 var(--space-2); gap: var(--space-2);
@@ -163,7 +190,7 @@ textarea { resize: vertical; min-height: 140px; line-height: 1.5; }
163
190
 
164
191
  .hint { color: var(--text-3); line-height: 1.5; font-size: var(--type-xs); margin: var(--space-3) var(--space-2); }
165
192
 
166
- .rail-footer { padding: 10px var(--space-3); border-top: 1px solid var(--border); font-size: var(--type-row); color: var(--text-2); }
193
+ .rail-footer { padding: var(--space-2) var(--space-3) 10px; border-top: 1px solid var(--border); font-size: var(--type-xs); color: var(--text-3); }
167
194
 
168
195
  /* The workspace ----------------------------------------------------------- */
169
196
 
@@ -371,11 +398,13 @@ body.prompt-fullscreen #inspector { z-index: 60; }
371
398
  .section h3 .info-tip { margin-left: var(--space-1); }
372
399
 
373
400
  .section { border-top: 1px solid var(--border); padding-top: var(--space-4); margin-top: var(--space-4); }
374
- .section h3 { display: flex; align-items: center; font-size: var(--type-xs); font-weight: var(--weight-strong); margin: 0 0 var(--space-4); color: var(--text-2); }
401
+ /* A heading names a group of fields, so it reads a step above their labels rather than as one. */
402
+ .section h3 { display: flex; align-items: center; font-size: var(--type-row); font-weight: var(--weight-strong); margin: 0 0 var(--space-3); color: var(--text); }
375
403
  .section > button + button { margin-left: var(--space-1); }
376
404
  .section > .primary { max-width: 100%; white-space: normal; }
377
405
 
378
- .disclosure > summary { font-size: var(--type-xs); cursor: pointer; color: var(--text-2); font-weight: var(--weight-strong); margin-bottom: var(--space-4); }
406
+ .disclosure > summary { font-size: var(--type-row); cursor: pointer; color: var(--text); font-weight: var(--weight-strong); margin-bottom: var(--space-3); }
407
+ .disclosure > summary:hover { color: var(--text); }
379
408
  /* A closed group keeps the gap an open one gets from its last field, so the heading does not sit
380
409
  on the field that follows it. */
381
410
  .disclosure:not([open]) > summary { margin-bottom: 0; }
@@ -410,7 +439,11 @@ body.prompt-fullscreen #inspector { z-index: 60; }
410
439
 
411
440
  /* A validation problem is an error, and errors are the one colour the chrome allows. */
412
441
  .validation { font-size: var(--type-xs); line-height: 1.5; padding-left: 18px; color: var(--err-text); }
413
- .valid { color: var(--text-2); font-size: var(--type-xs); }
442
+ .valid { display: flex; align-items: center; gap: var(--space-2); margin: 0; color: var(--text-2); font-size: var(--type-xs); }
443
+ /* A graph that passed validation says so with the one "done" colour the chrome allows. */
444
+ .valid.ok::before { content: ''; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
445
+ /* The graph's id is a reference, not a field: one quiet line that never wraps the panel. */
446
+ .graph-meta { margin: calc(-1 * var(--space-1)) 0 var(--space-3); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; user-select: text; -webkit-user-select: text; }
414
447
  .danger { color: var(--err-text); }
415
448
 
416
449
  .actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
@@ -425,13 +458,13 @@ body.prompt-fullscreen #inspector { z-index: 60; }
425
458
  /* The status strip -------------------------------------------------------- */
426
459
 
427
460
  .status {
428
- height: 36px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
429
- gap: var(--space-4); border-top: 1px solid var(--border); padding: 0 var(--space-3); font-size: var(--type-xs);
430
- color: var(--text-2); background: var(--bg-surface);
461
+ height: 30px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
462
+ gap: var(--space-4); border-top: 1px solid var(--border); padding: 0 var(--space-2) 0 var(--space-3); font-size: var(--type-xs);
463
+ color: var(--text-3); background: var(--bg-surface);
431
464
  }
432
465
  .status button {
433
- border: 0; background: transparent; font-size: var(--type-xs); height: 24px; min-height: 0; padding: 0 var(--space-2);
434
- border-radius: var(--row-radius); color: var(--text-2);
466
+ border: 0; background: transparent; font-size: var(--type-xs); height: 22px; min-height: 0; padding: 0 var(--space-2);
467
+ border-radius: var(--row-radius); color: var(--text-3);
435
468
  }
436
469
  .status button:hover:not(:disabled) { background: var(--bg-card); color: var(--text); }
437
470
  .status.error { color: var(--err-text); }
@@ -466,7 +499,8 @@ body.prompt-fullscreen #inspector { z-index: 60; }
466
499
  .rail-body.is-scrolling::-webkit-scrollbar-thumb, #graphs.is-scrolling::-webkit-scrollbar-thumb,
467
500
  .rail-body:focus-visible::-webkit-scrollbar-thumb, #graphs:focus-visible::-webkit-scrollbar-thumb { background: var(--text-3); }
468
501
  .rail-body::-webkit-scrollbar-button, #graphs::-webkit-scrollbar-button { display: none; }
469
- #graphs { max-height: 150px; overflow: auto; }
502
+ /* Tall enough to browse: about ten rows, and never more than the node library can spare. */
503
+ #graphs { max-height: clamp(150px, 42vh, 420px); overflow-x: hidden; overflow-y: auto; }
470
504
  @media (forced-colors: active) { .rail-body, #graphs { scrollbar-color: auto; } }
471
505
 
472
506
  /* Narrow windows --------------------------------------------------------- */
@@ -177,7 +177,7 @@ export interface Graph {
177
177
  [key: string]: unknown;
178
178
  };
179
179
  }
180
- export declare const GRAPH_TOOLS: readonly ["Read", "Write", "Edit", "Glob", "Grep", "Bash", "PowerShell", "NativeExec", "AsyncProcess", "PowerShellFast", "ShellMetrics", "read_file", "list_files", "search_files", "write_file", "edit_file", "read", "write", "edit", "find", "grep", "ls", "powershell", "bash", "shell", "git_read", "read_artifact", "write_artifact", "repo_explore", "memory_search", "set_timer", "pull_request", "qa.inspect_project", "qa.status", "qa.fast", "qa.deep", "qa.test", "qa.terminal", "qa.security", "qa.browser", "qa.browser_session", "browser.solve_captcha", "read_skill_resource", "browser.panel", "browser.incognito"];
180
+ export declare const GRAPH_TOOLS: readonly ["Read", "Write", "Edit", "Glob", "Grep", "Bash", "PowerShell", "NativeExec", "AsyncProcess", "PowerShellFast", "ShellMetrics", "read_file", "list_files", "search_files", "write_file", "edit_file", "read", "write", "edit", "find", "grep", "ls", "powershell", "bash", "shell", "git_read", "read_artifact", "write_artifact", "repo_explore", "memory_search", "set_timer", "pull_request", "graphs", "qa.inspect_project", "qa.status", "qa.fast", "qa.deep", "qa.test", "qa.terminal", "qa.security", "qa.browser", "qa.browser_session", "browser.solve_captcha", "web_search", "read_skill_resource", "browser.panel", "browser.incognito"];
181
181
  /** QA tool names are an explicit allowlist; gating keys off membership, never a name prefix. */
182
182
  export declare const QA_TOOL_NAMES: readonly string[];
183
183
  export declare const isQaToolName: (name: string) => boolean;
@@ -231,9 +231,22 @@ export declare function effectiveCapabilities(node: {
231
231
  export declare function intakeCapabilities(node: {
232
232
  capabilities?: CapabilityPolicy;
233
233
  }): CapabilityPolicy;
234
- export declare function permitsBuiltInTool(node: Pick<GraphNode, 'capabilities' | 'tools'>, name: string, child?: boolean): boolean;
234
+ /** The second completion outcome of a delegating Orchestrator: subagents did the work and it landed. */
235
+ export declare const DELIVERED_OUTCOME = "delivered";
236
+ /**
237
+ * Who a tool set is being built for: `false` the node's own agent, `true` an ordinary child, and
238
+ * `'delegated-worktree'` a writing child of a delegating Orchestrator running in its own worktree.
239
+ * Only the last may run commands; it does so inside its worktree, which is a working directory,
240
+ * not a sandbox, so commands go through the same approval rules as the parent's shell.
241
+ */
242
+ export type CommandScope = boolean | 'delegated-worktree';
243
+ export declare function isWritingRole(role: SubagentRole): boolean;
244
+ /** An Orchestrator delegates implementation when spawning is on and at least one role may write. */
245
+ export declare function delegatesWriting(node: GraphNode): boolean;
246
+ export declare function permitsBuiltInTool(node: Pick<GraphNode, 'capabilities' | 'tools'>, name: string, child?: CommandScope): boolean;
235
247
  export declare function capabilitySubset(child: CapabilityPolicy, parent: CapabilityPolicy): boolean;
236
248
  export declare function nodeOutcomes(node: GraphNode): string[];
249
+ export declare function minimumGraphToolCalls(graph: Graph): number;
237
250
  export interface GraphValidationOptions {
238
251
  providers?: {
239
252
  id: string;
@@ -5,7 +5,7 @@ import { configDirectory } from './config.js';
5
5
  import { acquireSaveLock, archiveUnpublishedSnapshot, removeLockedFolder, SaveLockBusyError } from './save-lock.js';
6
6
  import { validateMappingConstants, validateMappings, validateSchema, validateValue, schemaAt, nodeOutputSchema } from './handoffs.js';
7
7
  import { CANONICAL_CODING_TOOLS, canonicalToolName, canonicalizeToolList, toolNameMatches } from './tool-names.js';
8
- export const GRAPH_TOOLS = [...CANONICAL_CODING_TOOLS, 'NativeExec', 'AsyncProcess', 'PowerShellFast', 'ShellMetrics', 'read_file', 'list_files', 'search_files', 'write_file', 'edit_file', 'read', 'write', 'edit', 'find', 'grep', 'ls', 'powershell', 'bash', 'shell', 'git_read', 'read_artifact', 'write_artifact', 'repo_explore', 'memory_search', 'set_timer', 'pull_request', 'qa.inspect_project', 'qa.status', 'qa.fast', 'qa.deep', 'qa.test', 'qa.terminal', 'qa.security', 'qa.browser', 'qa.browser_session', 'browser.solve_captcha', 'read_skill_resource', 'browser.panel', 'browser.incognito'];
8
+ export const GRAPH_TOOLS = [...CANONICAL_CODING_TOOLS, 'NativeExec', 'AsyncProcess', 'PowerShellFast', 'ShellMetrics', 'read_file', 'list_files', 'search_files', 'write_file', 'edit_file', 'read', 'write', 'edit', 'find', 'grep', 'ls', 'powershell', 'bash', 'shell', 'git_read', 'read_artifact', 'write_artifact', 'repo_explore', 'memory_search', 'set_timer', 'pull_request', 'graphs', 'qa.inspect_project', 'qa.status', 'qa.fast', 'qa.deep', 'qa.test', 'qa.terminal', 'qa.security', 'qa.browser', 'qa.browser_session', 'browser.solve_captcha', 'web_search', 'read_skill_resource', 'browser.panel', 'browser.incognito'];
9
9
  /** QA tool names are an explicit allowlist; gating keys off membership, never a name prefix. */
10
10
  export const QA_TOOL_NAMES = ['qa.inspect_project', 'qa.status', 'qa.fast', 'qa.deep', 'qa.test', 'qa.terminal', 'qa.security', 'qa.browser'];
11
11
  export const isQaToolName = (name) => QA_TOOL_NAMES.includes(name);
@@ -199,14 +199,25 @@ export function intakeCapabilities(node) {
199
199
  return { filesystem: policy.filesystem === 'none' ? 'none' : 'read', shell: 'disabled',
200
200
  git: policy.git === 'none' ? 'none' : 'read', github: 'none', browser: policy.browser, deployment: 'none' };
201
201
  }
202
- const canRunCommands = (policy, child) => !child && policy.shell === 'allowed' && policy.filesystem === 'read-write' && policy.git === 'write';
202
+ /** The second completion outcome of a delegating Orchestrator: subagents did the work and it landed. */
203
+ export const DELIVERED_OUTCOME = 'delivered';
204
+ export function isWritingRole(role) {
205
+ return role.capabilities?.filesystem === 'read-write' || role.capabilities?.git === 'write';
206
+ }
207
+ /** An Orchestrator delegates implementation when spawning is on and at least one role may write. */
208
+ export function delegatesWriting(node) {
209
+ return node.type === 'agent' && node.agentRole === 'orchestrator' && node.subagents?.enabled === true && node.maxSubagents !== 0
210
+ && (node.subagents.roles ?? []).some(isWritingRole);
211
+ }
212
+ const canRunCommands = (policy, child) => child !== true && policy.shell === 'allowed' && policy.filesystem === 'read-write' && policy.git === 'write';
203
213
  export function permitsBuiltInTool(node, name, child = false) {
204
214
  if (node.tools !== undefined && !node.tools.some(configured => toolNameMatches(configured, name)))
205
215
  return false;
206
216
  const policy = effectiveCapabilities(node);
207
217
  const canonical = canonicalToolName(name);
208
- // The solve tool only acts on this agent's own qa.browser_session pages, so it follows the same policy.
209
- if (name === 'qa.browser_session' || name === 'browser.solve_captcha')
218
+ // The solve tool only acts on this agent's own qa.browser_session pages, so it follows the same policy;
219
+ // web_search reaches the internet the way the browser does, so the browser policy governs it too.
220
+ if (name === 'qa.browser_session' || name === 'browser.solve_captcha' || name === 'web_search')
210
221
  return policy.browser === 'playwright';
211
222
  if (['Read', 'Glob', 'Grep', 'repo_explore', 'read_skill_resource'].includes(canonical))
212
223
  return policy.filesystem !== 'none';
@@ -243,7 +254,10 @@ export function nodeOutcomes(node) {
243
254
  return [node.modifiers.loop.until.outcome];
244
255
  if (node.type === 'approval')
245
256
  return ['approved', 'rejected'];
246
- return node.completion?.mode === 'outcomes' ? node.completion.outcomes : [node.completion?.outcome ?? 'completed'];
257
+ if (node.completion?.mode === 'outcomes')
258
+ return node.completion.outcomes;
259
+ const outcome = node.completion?.outcome ?? 'completed';
260
+ return delegatesWriting(node) ? [outcome, DELIVERED_OUTCOME] : [outcome];
247
261
  }
248
262
  function guaranteedGraphInvocations(graph) {
249
263
  const nodes = Object.values(graph.nodes);
@@ -257,7 +271,9 @@ function guaranteedGraphInvocations(graph) {
257
271
  for (const node of nodes) {
258
272
  if (node.id === boundary)
259
273
  continue;
260
- const alternatives = nodeOutcomes(node).map(outcome => {
274
+ // An unrouted delivered port is not a path the run can take, so it does not weaken what the
275
+ // completed route guarantees; once routed it is a real alternative like any other outcome.
276
+ const alternatives = nodeOutcomes(node).filter(outcome => outcome !== DELIVERED_OUTCOME || !delegatesWriting(node) || routes(node.id, outcome).length > 0).map(outcome => {
261
277
  const reached = new Set();
262
278
  for (const edge of routes(node.id, outcome))
263
279
  for (const id of guaranteed.get(edge.target))
@@ -287,7 +303,7 @@ function guaranteedGraphInvocations(graph) {
287
303
  const required = guarantees().get(graph.entry);
288
304
  return { required, loopBodies };
289
305
  }
290
- function minimumGraphToolCalls(graph) {
306
+ export function minimumGraphToolCalls(graph) {
291
307
  const { required, loopBodies } = guaranteedGraphInvocations(graph);
292
308
  const calls = new Map([...required].map(id => [id, graph.nodes[id].agentRole === 'orchestrator' ? 2 : graph.nodes[id].type === 'action' ? 1 : 0]));
293
309
  for (const [loopId, body] of loopBodies) {
@@ -757,14 +773,26 @@ function validateGraphInternal(value, options = {}) {
757
773
  fail(`${label}: task-only context cannot supply required inputs for role ${r.id}; select selected context or make the role inputs optional`);
758
774
  if (r.capabilities)
759
775
  capabilities(r.capabilities, `${label} role ${r.id}`);
760
- const parent = node.agentRole === 'orchestrator' && spawningEnabled ? intakeCapabilities(node) : effectiveCapabilities(node);
776
+ // A writing role on an Orchestrator is a delegated one: delegatesWriting(node) && isWritingRole(r),
777
+ // spelled out per role so that roles not yet shape-checked by this loop are never inspected.
778
+ const delegated = node.agentRole === 'orchestrator' && spawningEnabled && isWritingRole(r);
779
+ if (delegated && (s.workspace ?? 'shared-read-only') !== 'worktree')
780
+ fail(`${label}: writing roles on an Orchestrator require separate worktrees; select Separate Git worktree`);
781
+ if (delegated && node.completion?.mode === 'outcomes')
782
+ fail(`${label}: Orchestrator delegation needs a single completion outcome; remove declared outcomes or the writing roles`);
783
+ if (delegated && node.completion?.mode === 'single' && node.completion.outcome === DELIVERED_OUTCOME)
784
+ fail(`${label}: the outcome name ${DELIVERED_OUTCOME} is reserved for Orchestrator delegation; rename the completion outcome`);
785
+ // Two ceilings: the Orchestrator itself and its read-only roles stay under the intake ceiling;
786
+ // a delegated writing role is measured against the node's configured capabilities.
787
+ const parent = node.agentRole === 'orchestrator' && spawningEnabled && !delegated ? intakeCapabilities(node) : effectiveCapabilities(node);
761
788
  const child = r.capabilities ?? { ...parent, ...((s.workspace ?? 'shared-read-only') === 'shared-read-only' ? { filesystem: parent.filesystem === 'none' ? 'none' : 'read', git: parent.git === 'none' ? 'none' : 'read', shell: 'disabled' } : {}) };
762
789
  if (!capabilitySubset(child, parent))
763
- fail(`${label}: role ${r.id} capability exceeds parent${node.agentRole === 'orchestrator' ? ' intake read-only ceiling; reduce child permissions' : '; reduce child permissions or explicitly grant them to the parent'}`);
764
- if (r.tools?.some(t => !permitsBuiltInTool({ ...node, capabilities: parent }, t)))
790
+ fail(`${label}: role ${r.id} capability exceeds parent${node.agentRole === 'orchestrator' && !delegated ? ' intake read-only ceiling; reduce child permissions' : '; reduce child permissions or explicitly grant them to the parent'}`);
791
+ // The delegation ceiling is the node's capabilities alone: the Orchestrator's own tool list is its intake kit.
792
+ if (r.tools?.some(t => !permitsBuiltInTool(delegated ? { capabilities: parent } : { ...node, capabilities: parent }, t)))
765
793
  fail(`${label}: role ${r.id} tools exceed effective parent capabilities; reduce its tools or explicitly grant parent permissions`);
766
- if (r.tools?.some(t => !permitsBuiltInTool({ capabilities: child }, t, true)))
767
- fail(`${label}: role ${r.id} tools exceed its child capabilities; remove unavailable tools (subagents cannot use the host shell)`);
794
+ if (r.tools?.some(t => !permitsBuiltInTool({ capabilities: child }, t, delegated ? 'delegated-worktree' : true)))
795
+ fail(`${label}: role ${r.id} tools exceed its child capabilities; remove unavailable tools${delegated ? '' : ' (subagents cannot use the host shell)'}`);
768
796
  const writes = child.filesystem === 'read-write' || child.git === 'write';
769
797
  if (spawningEnabled && s.workspace === 'worktree' && writes && parent.git !== 'write')
770
798
  fail(`${label}: writing worktree role ${r.id} requires parent Git write access; grant Git write or select a read-only role`);
@@ -869,8 +897,9 @@ function validateGraphInternal(value, options = {}) {
869
897
  }
870
898
  if (node.type === 'condition' && (node.condition.source === id || canReach(graph.entry, id, node.condition.source)))
871
899
  fail(`Condition ${id}: source ${node.condition.source} must execute on every path before this condition; route through the source first`);
900
+ // A delegating Orchestrator's delivered port is optional: unrouted, the graph behaves like intake.
872
901
  for (const outcome of nodeOutcomes(node))
873
- if (!(node.completion?.mode === 'outcomes' && node.completion.requireRoutes === false) && !(outgoing.get(id) ?? []).some(e => e.outcome === outcome))
902
+ if (!(node.completion?.mode === 'outcomes' && node.completion.requireRoutes === false) && !(outcome === DELIVERED_OUTCOME && delegatesWriting(node)) && !(outgoing.get(id) ?? []).some(e => e.outcome === outcome))
874
903
  fail(`node ${id}: required outcome ${outcome} has no route; connect its output port`);
875
904
  if (node.type === 'join' && node.join?.mode === 'all') {
876
905
  const edges = (incoming.get(id) ?? []).filter(edge => !edge.bootstrap);
@@ -2,11 +2,11 @@ import { type HardenedRunOptions } from './react-runtime.js';
2
2
  import type { RunResult } from './runtime.js';
3
3
  export type { HardenedRunOptions, ToolExecutionMode, BeforeToolCallContext, BeforeToolCallResult, AfterToolCallContext, AfterToolCallResult } from './react-runtime.js';
4
4
  /**
5
- * Facts select concrete continuations at the coding-adapter boundary; the one React engine still
6
- * validates and executes every call, hook, approval, budget and completion contract. A synthetic
7
- * continuation returns requests: 0 and never invokes the actual coding adapter or its onRequest.
8
- * Questions mode retains its existing implementation in the same engine.
5
+ * The files a run starts with, as paths and sizes, so the first model turn can read what it needs
6
+ * instead of spending a turn on `ls`. Bounded in depth, entries and time spent; undefined for an
7
+ * empty or unreadable workspace. File names are workspace data, so the caller labels them untrusted.
9
8
  */
9
+ export declare function workspaceListing(root: string): Promise<string | undefined>;
10
10
  export declare class AndorraAgentEngine {
11
11
  execute(options: HardenedRunOptions): Promise<RunResult>;
12
12
  }
@@ -1,4 +1,6 @@
1
1
  import { randomUUID } from 'node:crypto';
2
+ import { readdir, stat } from 'node:fs/promises';
3
+ import { join } from 'node:path';
2
4
  import { applyToolMenu } from './decision/applyToolMenu.js';
3
5
  import { answerOnlyTask } from './decision/optimizationPolicy.js';
4
6
  import { AndorraAgentEngine as ReactEngine } from './react-runtime.js';
@@ -9,7 +11,7 @@ import { toolFamily } from './decision/toolFamilies.js';
9
11
  import { redactSecrets } from './memory/redaction.js';
10
12
  import { factTaskText } from './decision/facts.js';
11
13
  import { isVerificationCheck } from './decision/checks.js';
12
- import { FactContinuations, FACT_CONTINUATION_GUIDANCE, PREPARE_FINISH, taskConstraints, localCheckResult, prepareFinishArguments, prepareFinishDescription } from './decision/FactContinuations.js';
14
+ import { FactContinuations, FACT_CONTINUATION_GUIDANCE, FINISH_SUMMARY_DESCRIPTION, PREPARE_FINISH, taskConstraints, localCheckResult, prepareFinishArguments, prepareFinishDescription } from './decision/FactContinuations.js';
13
15
  import { bypassGeneration } from './decision/ContinuationAdapter.js';
14
16
  /**
15
17
  * Facts select concrete continuations at the coding-adapter boundary; the one React engine still
@@ -17,6 +19,54 @@ import { bypassGeneration } from './decision/ContinuationAdapter.js';
17
19
  * continuation returns requests: 0 and never invokes the actual coding adapter or its onRequest.
18
20
  * Questions mode retains its existing implementation in the same engine.
19
21
  */
22
+ const LISTING_SKIP = new Set(['.git', 'node_modules', '.venv', 'venv', '__pycache__', 'dist', 'build', 'target', '.codegraph', '.andorra', '.pytest_cache', '.mypy_cache', '.next', 'coverage', '.DS_Store']);
23
+ const LISTING_FILES = 60;
24
+ /**
25
+ * The files a run starts with, as paths and sizes, so the first model turn can read what it needs
26
+ * instead of spending a turn on `ls`. Bounded in depth, entries and time spent; undefined for an
27
+ * empty or unreadable workspace. File names are workspace data, so the caller labels them untrusted.
28
+ */
29
+ export async function workspaceListing(root) {
30
+ const lines = [];
31
+ let more = 0, visited = 0;
32
+ const walk = async (dir, rel, depth) => {
33
+ let entries;
34
+ try {
35
+ entries = await readdir(dir, { withFileTypes: true });
36
+ }
37
+ catch {
38
+ return;
39
+ }
40
+ entries.sort((a, b) => a.name.localeCompare(b.name));
41
+ for (const entry of entries) {
42
+ if (LISTING_SKIP.has(entry.name) || ++visited > 2000)
43
+ continue;
44
+ const path = rel ? `${rel}/${entry.name}` : entry.name;
45
+ if (entry.isDirectory()) {
46
+ if (depth < 4)
47
+ await walk(join(dir, entry.name), path, depth + 1);
48
+ else
49
+ lines.length < LISTING_FILES ? lines.push(`${path}/`) : more++;
50
+ }
51
+ else if (entry.isFile()) {
52
+ if (lines.length >= LISTING_FILES) {
53
+ more++;
54
+ continue;
55
+ }
56
+ let size = 0;
57
+ try {
58
+ size = (await stat(join(dir, entry.name))).size;
59
+ }
60
+ catch { /* Listed without a size. */ }
61
+ lines.push(`${path} (${size})`);
62
+ }
63
+ }
64
+ };
65
+ await walk(root, '', 0);
66
+ if (!lines.length)
67
+ return undefined;
68
+ return `Untrusted workspace data. Files present when this run started, as path (bytes); read the ones you need directly instead of listing the directory first:\n${lines.join('\n')}${more ? `\n(${more} more not listed)` : ''}`;
69
+ }
20
70
  export class AndorraAgentEngine {
21
71
  async execute(options) {
22
72
  const runId = options.runId ?? randomUUID();
@@ -63,34 +113,77 @@ export class AndorraAgentEngine {
63
113
  });
64
114
  // The shell the model actually has, for the description's example and bare-command repair.
65
115
  const shell = permitted.find(t => t.exitZeroOnReturn)?.name ?? catalog('shell')?.name;
116
+ // What complete_agent would require beyond the answer itself. A node with one outcome and no
117
+ // output contract leaves the model nothing to choose, so the runtime fills those fields in.
118
+ const policy = options.completionPolicy;
119
+ const outcomes = policy ? policy.mode === 'single' ? [policy.outcome] : policy.outcomes : undefined;
120
+ const completionProperties = completionTool(options).parameters.properties;
66
121
  const prepareFinish = {
67
122
  name: PREPARE_FINISH, executionMode: 'sequential',
68
123
  description: prepareFinishDescription(shell),
69
124
  prepareArguments: args => prepareFinishArguments(args, { has: name => !!catalog(name), shell }),
70
125
  parameters: { type: 'object', properties: {
71
- checks: { type: 'array', maxItems: 8, items: { type: 'object', properties: { name: { type: 'string' }, arguments: { type: 'object' } }, required: ['name', 'arguments'], additionalProperties: false } },
72
- completion: completionTool(options).parameters,
73
- verificationTodoIds: { type: 'array', maxItems: 32, items: { type: 'string' }, description: 'Existing verification-only todo ids to complete after every declared check passes; never implementation items.' },
74
- }, required: ['checks', 'completion'], additionalProperties: false },
126
+ checks: { type: 'array', maxItems: 8, items: { type: 'string' }, description: 'Verification commands, one per entry, exactly as you would run each in the shell. [] when the verification is not a command.' },
127
+ summary: { type: 'string', description: FINISH_SUMMARY_DESCRIPTION },
128
+ ...(outcomes && outcomes.length > 1 ? { outcome: completionProperties.outcome } : {}),
129
+ ...(outcomes && options.outputSchema ? { output: completionProperties.output } : {}),
130
+ }, required: ['checks'], additionalProperties: false },
131
+ // The advertised shape is the short one. Earlier shapes (a nested completion, checks as tool
132
+ // calls) stay callable, and the plan itself is validated when it is staged, where a slip can be
133
+ // answered without discarding the summary the model already wrote.
134
+ validationParameters: { type: 'object' },
75
135
  execute: async (args, context) => {
76
136
  context.signal.throwIfAborted();
77
- router.stage(args, calls.at(-1)?.name === PREPARE_FINISH && calls.filter(c => c.name === PREPARE_FINISH).length === 1);
78
- return 'Finish plan prepared, not completed. Required checks and normal completion validation still have to succeed.';
137
+ const given = args.completion;
138
+ const completion = given && typeof given === 'object' && !Array.isArray(given) ? { ...given } : undefined;
139
+ if (completion && outcomes) {
140
+ if (completion.outcome === undefined && outcomes.length === 1)
141
+ completion.outcome = outcomes[0];
142
+ if (completion.output === undefined && !options.outputSchema)
143
+ completion.output = {};
144
+ }
145
+ router.stage(completion ? { ...args, completion } : args, calls.at(-1)?.name === PREPARE_FINISH && calls.filter(c => c.name === PREPARE_FINISH).length === 1,
146
+ // Alone means nothing in the batch produced a result the model has not seen; a todo update does not.
147
+ calls.every(c => [PREPARE_FINISH, 'update_todos', 'update_widget'].includes(c.name)));
148
+ return 'Finish plan prepared, not completed. Required checks and normal completion validation still have to succeed. If a check fails, fix it and call prepare_finish again with the checks only; the saved summary is reused.';
79
149
  },
80
150
  };
151
+ const listing = await workspaceListing(options.context.workspace).catch(() => undefined);
152
+ /** The same message at the same early position in every request, so the cached prefix holds. */
153
+ const withListing = (messages) => {
154
+ const first = listing ? messages.findIndex(message => message.role === 'user') : -1;
155
+ return first < 0 ? messages : [...messages.slice(0, first + 1), { role: 'user', content: listing }, ...messages.slice(first + 1)];
156
+ };
81
157
  const wrapAdapter = (adapter) => ({
82
158
  ...(adapter.listModels ? { listModels: adapter.listModels.bind(adapter) } : {}),
83
159
  generate: bypassGeneration(async (request) => {
84
160
  if (!request.tools.some(t => t.name === 'complete_agent'))
85
161
  return adapter.generate(request);
86
162
  const finishing = !steered && !opaqueProtocol && router.finishing;
163
+ const followUp = !steered && !opaqueProtocol && !finishing ? router.followUp : undefined;
164
+ const nudge = !steered && !opaqueProtocol && !finishing && !followUp ? router.nudge : undefined;
165
+ if (!opaqueProtocol)
166
+ request = { ...request, messages: withListing(request.messages) };
87
167
  if (steered || opaqueProtocol)
88
168
  request = { ...request, tools: request.tools.filter(t => t.name !== PREPARE_FINISH) };
89
169
  router.modelResumed();
90
170
  const response = await adapter.generate(finishing ? {
91
171
  ...request,
92
172
  // Keep schemas stable for prefix caching. This is guidance, not a claimed bypass.
93
- messages: [...request.messages, { role: 'user', content: 'Runtime: the recorded required checks passed on the current workspace and no todo is open. Complete now using complete_agent; reopen a todo only for genuinely unfinished required work. Do not add discretionary QA.' }],
173
+ messages: [...request.messages, { role: 'user', content: router.hasDraft
174
+ // The answer exists already: submitting it costs a few tokens, writing it again costs it all.
175
+ ? 'Runtime: the recorded required checks passed on the current workspace and no todo is open. Complete now: call prepare_finish alone with checks [] to submit the summary you already wrote; reopen a todo only for genuinely unfinished required work. Do not add discretionary QA.'
176
+ : 'Runtime: the recorded required checks passed on the current workspace and no todo is open. Complete now using complete_agent; reopen a todo only for genuinely unfinished required work. Do not add discretionary QA.' }],
177
+ mutableTail: (request.mutableTail ?? 0) + 1,
178
+ } : followUp ? {
179
+ ...request,
180
+ messages: [...request.messages, { role: 'user', content: `Runtime: after your edits the runtime ran \`${followUp}\` again and it passed on the current workspace. If the task is complete, finish now: call prepare_finish alone with checks [] and your summary. Do not run that check again, do not update todos first (they are closed for you) and do not add discretionary QA. Continue working only if something the task requires is still missing.` }],
181
+ mutableTail: (request.mutableTail ?? 0) + 1,
182
+ } : nudge ? {
183
+ ...request,
184
+ messages: [...request.messages, { role: 'user', content: nudge === 'after_write'
185
+ ? 'Runtime: if these edits complete the task, verify and finish in one step: call prepare_finish now with the check commands and your summary. The runtime runs the checks, returns their output to you if one fails, and submits the summary if they pass, so do not run them yourself first. If required work remains, continue with it instead.'
186
+ : 'Runtime: when your next edits should fix this, put prepare_finish (the check commands and your summary) last in that same batch. The runtime then runs the checks and finishes if they pass, or returns their output to you.' }],
94
187
  mutableTail: (request.mutableTail ?? 0) + 1,
95
188
  } : request);
96
189
  calls = response.toolCalls;
@@ -153,6 +246,11 @@ export class AndorraAgentEngine {
153
246
  acceptedAutomatic = automatic;
154
247
  router.completionAccepted();
155
248
  }
249
+ if (ours && event.type === 'node.tool.completed' && typeof d.toolCallId === 'string' && typeof d.durationMs === 'number') {
250
+ const seen = observed.get(d.toolCallId);
251
+ if (seen)
252
+ seen.durationMs = d.durationMs;
253
+ }
156
254
  if (ours && ['node.tool.completed', 'node.tool.failed', 'node.tool.skipped'].includes(event.type) && typeof d.toolCallId === 'string' && !observed.has(d.toolCallId)) {
157
255
  const call = calls.find(c => c.id === d.toolCallId);
158
256
  if (call) {
@@ -237,7 +335,9 @@ export class AndorraAgentEngine {
237
335
  const observation = { call: call.toolCall, args: call.args, output: safe,
238
336
  isError: after?.isError ?? call.isError, executionSucceeded: !call.isError,
239
337
  truncated: safe !== projected || projected !== output || clipped,
240
- family: toolFamily(call.tool), readOnly: retrySafe(call.tool) };
338
+ family: toolFamily(call.tool), readOnly: retrySafe(call.tool),
339
+ // A shell that returns only on exit 0 is exact evidence for any command it ran.
340
+ ...(!(after?.isError ?? call.isError) && call.tool.exitZeroOnReturn ? { exitCode: 0 } : {}) };
241
341
  // Structured QA status is exact local evidence even when its privacy projection omits
242
342
  // source details. Only the projected, redacted form may ever be sent to Jev.
243
343
  if (isVerificationCheck(call.tool.name, observation.family, call.args)) {
@@ -23,4 +23,13 @@ export declare class PowerShellWorker {
23
23
  dispose(error?: Error): Promise<void>;
24
24
  }
25
25
  export declare function runPooledPowerShell(command: string, workspace: string, timeout: number, signal: AbortSignal, launchPolicy: () => ShellSandbox | undefined, onOutput?: (text: string) => void): Promise<string>;
26
+ /** The workspaces that currently hold a pooled interpreter. */
27
+ export declare function pooledPowerShellWorkspaces(): string[];
28
+ /**
29
+ * Ends the pooled interpreter of `root` and of every folder under it, and waits until each process
30
+ * tree is gone. For a workspace that is about to be deleted: an idle interpreter stays alive for
31
+ * `IDLE_MS` with the workspace as its current directory, which keeps Windows from removing the
32
+ * folder. A command still running there fails as disposed. Never throws.
33
+ */
34
+ export declare function disposePooledPowerShellUnder(root: string): Promise<void>;
26
35
  export declare function disposePooledPowerShell(): Promise<void>;
@@ -242,6 +242,22 @@ export async function runPooledPowerShell(command, workspace, timeout, signal, l
242
242
  throw error;
243
243
  }
244
244
  }
245
+ /** The workspaces that currently hold a pooled interpreter. */
246
+ export function pooledPowerShellWorkspaces() { return [...workers.keys()]; }
247
+ /**
248
+ * Ends the pooled interpreter of `root` and of every folder under it, and waits until each process
249
+ * tree is gone. For a workspace that is about to be deleted: an idle interpreter stays alive for
250
+ * `IDLE_MS` with the workspace as its current directory, which keeps Windows from removing the
251
+ * folder. A command still running there fails as disposed. Never throws.
252
+ */
253
+ export async function disposePooledPowerShellUnder(root) {
254
+ const base = path.resolve(root).toLowerCase();
255
+ const owned = [...workers.values()].filter(worker => {
256
+ const inside = path.relative(base, path.resolve(worker.workspace).toLowerCase());
257
+ return inside === '' || (!inside.startsWith('..') && !path.isAbsolute(inside));
258
+ });
259
+ await Promise.all(owned.map(worker => worker.dispose().catch(() => { })));
260
+ }
245
261
  export async function disposePooledPowerShell() {
246
262
  await Promise.all([...workers.values()].map(worker => worker.dispose()));
247
263
  workers.clear();