@andorra-labs/code 0.1.5 → 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 (224) hide show
  1. package/dist/src/account-presentation.js +3 -3
  2. package/dist/src/agent-execution.d.ts +2 -0
  3. package/dist/src/agent-execution.js +526 -41
  4. package/dist/src/agent-mcp-catalog.d.ts +21 -0
  5. package/dist/src/agent-mcp-catalog.js +40 -0
  6. package/dist/src/agent-mcp.d.ts +36 -3
  7. package/dist/src/agent-mcp.js +114 -45
  8. package/dist/src/app-server/protocol.d.ts +57 -5
  9. package/dist/src/app-server/protocol.js +18 -1
  10. package/dist/src/app-server/workspace.d.ts +9 -1
  11. package/dist/src/app-server/workspace.js +50 -3
  12. package/dist/src/app-server.d.ts +115 -41
  13. package/dist/src/app-server.js +1316 -221
  14. package/dist/src/auth/AuthManager.d.ts +33 -1
  15. package/dist/src/auth/AuthManager.js +138 -10
  16. package/dist/src/auth/callback-page.d.ts +4 -0
  17. package/dist/src/auth/callback-page.js +70 -0
  18. package/dist/src/auth/callback.d.ts +39 -0
  19. package/dist/src/auth/callback.js +146 -22
  20. package/dist/src/auth/index.d.ts +10 -6
  21. package/dist/src/auth/index.js +2 -2
  22. package/dist/src/auth/store.d.ts +142 -3
  23. package/dist/src/auth/store.js +334 -13
  24. package/dist/src/auth/types.d.ts +17 -1
  25. package/dist/src/auth-commands.d.ts +11 -2
  26. package/dist/src/auth-commands.js +14 -7
  27. package/dist/src/automation-runner.d.ts +9 -0
  28. package/dist/src/automation-runner.js +22 -1
  29. package/dist/src/automation-tool.js +18 -3
  30. package/dist/src/automations.d.ts +5 -0
  31. package/dist/src/automations.js +11 -1
  32. package/dist/src/browser-captcha-tool.d.ts +54 -0
  33. package/dist/src/browser-captcha-tool.js +374 -0
  34. package/dist/src/browser-panel-tool.d.ts +7 -0
  35. package/dist/src/browser-panel-tool.js +74 -3
  36. package/dist/src/browser-runner.js +19 -4
  37. package/dist/src/browser-server.js +21 -1
  38. package/dist/src/browser-session.d.ts +16 -0
  39. package/dist/src/browser-session.js +35 -0
  40. package/dist/src/browser-ui/app.js +193 -3
  41. package/dist/src/browser-ui/style.css +15 -1
  42. package/dist/src/browser-view.d.ts +72 -4
  43. package/dist/src/browser-view.js +229 -17
  44. package/dist/src/capabilities.d.ts +9 -3
  45. package/dist/src/capabilities.js +20 -5
  46. package/dist/src/capsolver.d.ts +60 -0
  47. package/dist/src/capsolver.js +101 -0
  48. package/dist/src/claude-provider.d.ts +6 -0
  49. package/dist/src/claude-provider.js +34 -3
  50. package/dist/src/cli-executable.d.ts +33 -0
  51. package/dist/src/cli-executable.js +64 -0
  52. package/dist/src/cli-process.d.ts +47 -0
  53. package/dist/src/cli-process.js +113 -0
  54. package/dist/src/cli-sign-in.d.ts +68 -0
  55. package/dist/src/cli-sign-in.js +224 -0
  56. package/dist/src/cli.js +84 -26
  57. package/dist/src/code-intelligence/CodeIntelligenceManager.d.ts +1 -1
  58. package/dist/src/code-intelligence/CodeIntelligenceManager.js +5 -5
  59. package/dist/src/codex-provider.js +12 -0
  60. package/dist/src/coding-tools.d.ts +5 -0
  61. package/dist/src/coding-tools.js +98 -53
  62. package/dist/src/command-output-tap.d.ts +16 -0
  63. package/dist/src/command-output-tap.js +45 -0
  64. package/dist/src/command-screens.js +3 -3
  65. package/dist/src/commands.d.ts +15 -2
  66. package/dist/src/commands.js +14 -13
  67. package/dist/src/completion.d.ts +23 -5
  68. package/dist/src/completion.js +380 -17
  69. package/dist/src/config.d.ts +61 -0
  70. package/dist/src/config.js +276 -12
  71. package/dist/src/context-budget.d.ts +7 -0
  72. package/dist/src/context-budget.js +18 -1
  73. package/dist/src/deadline.js +6 -0
  74. package/dist/src/decision/FactContinuations.d.ts +41 -6
  75. package/dist/src/decision/FactContinuations.js +211 -64
  76. package/dist/src/decision/PreparedSteps.js +3 -1
  77. package/dist/src/decision/checks.d.ts +25 -0
  78. package/dist/src/decision/checks.js +77 -6
  79. package/dist/src/delegation-changes.d.ts +109 -0
  80. package/dist/src/delegation-changes.js +431 -0
  81. package/dist/src/extensions.d.ts +1 -0
  82. package/dist/src/extensions.js +16 -3
  83. package/dist/src/graph-provider-portability.js +2 -2
  84. package/dist/src/graph-quota.d.ts +1 -1
  85. package/dist/src/graph-quota.js +1 -1
  86. package/dist/src/graph-runner.js +35 -21
  87. package/dist/src/graph-selection.d.ts +6 -0
  88. package/dist/src/graph-selection.js +10 -0
  89. package/dist/src/graph-server.d.ts +8 -0
  90. package/dist/src/graph-server.js +76 -6
  91. package/dist/src/graph-sync.d.ts +65 -0
  92. package/dist/src/graph-sync.js +433 -13
  93. package/dist/src/graph-tool.d.ts +52 -0
  94. package/dist/src/graph-tool.js +136 -0
  95. package/dist/src/graph-ui/app.js +272 -50
  96. package/dist/src/graph-ui/controls.js +6 -0
  97. package/dist/src/graph-ui/drafts.js +39 -0
  98. package/dist/src/graph-ui/embed.js +1 -1
  99. package/dist/src/graph-ui/icons.js +1 -0
  100. package/dist/src/graph-ui/index.html +2 -2
  101. package/dist/src/graph-ui/skill-picker.js +242 -0
  102. package/dist/src/graph-ui/studio.css +7 -5
  103. package/dist/src/graph-ui/style.css +65 -12
  104. package/dist/src/graphs.d.ts +60 -5
  105. package/dist/src/graphs.js +191 -37
  106. package/dist/src/grok-provider.d.ts +50 -0
  107. package/dist/src/grok-provider.js +186 -0
  108. package/dist/src/handoffs.d.ts +13 -0
  109. package/dist/src/handoffs.js +31 -1
  110. package/dist/src/hardened-runtime.d.ts +4 -4
  111. package/dist/src/hardened-runtime.js +109 -9
  112. package/dist/src/managed-sign-in.d.ts +38 -0
  113. package/dist/src/managed-sign-in.js +169 -0
  114. package/dist/src/markdown.d.ts +5 -0
  115. package/dist/src/markdown.js +5 -2
  116. package/dist/src/mcp.js +11 -0
  117. package/dist/src/membership.d.ts +8 -1
  118. package/dist/src/membership.js +15 -5
  119. package/dist/src/model-metadata.js +14 -2
  120. package/dist/src/model-override.d.ts +10 -0
  121. package/dist/src/model-override.js +20 -0
  122. package/dist/src/opencode-cli-provider.d.ts +122 -0
  123. package/dist/src/opencode-cli-provider.js +415 -0
  124. package/dist/src/opencode-provider.js +23 -8
  125. package/dist/src/palette.d.ts +2 -0
  126. package/dist/src/palette.js +2 -0
  127. package/dist/src/permissions.d.ts +19 -1
  128. package/dist/src/permissions.js +30 -1
  129. package/dist/src/powershell-pool.d.ts +11 -2
  130. package/dist/src/powershell-pool.js +34 -5
  131. package/dist/src/provider-connection.js +36 -0
  132. package/dist/src/provider-engine.d.ts +2 -1
  133. package/dist/src/provider-engine.js +64 -13
  134. package/dist/src/provider-import.js +6 -1
  135. package/dist/src/provider-keys.d.ts +48 -0
  136. package/dist/src/provider-keys.js +121 -0
  137. package/dist/src/provider-settings.js +22 -3
  138. package/dist/src/providers.d.ts +12 -1
  139. package/dist/src/providers.js +27 -8
  140. package/dist/src/pull-requests.d.ts +123 -20
  141. package/dist/src/pull-requests.js +334 -84
  142. package/dist/src/qa/qa-authorize.js +9 -1
  143. package/dist/src/qa/runtime/ProcessManager.d.ts +6 -0
  144. package/dist/src/qa/runtime/ProcessManager.js +16 -0
  145. package/dist/src/react-runtime.js +106 -7
  146. package/dist/src/read-image.d.ts +30 -0
  147. package/dist/src/read-image.js +97 -0
  148. package/dist/src/remote/engine-pool.js +1 -1
  149. package/dist/src/run-progress.js +6 -1
  150. package/dist/src/run-records.d.ts +133 -27
  151. package/dist/src/run-records.js +320 -40
  152. package/dist/src/runtime.d.ts +38 -1
  153. package/dist/src/runtime.js +27 -4
  154. package/dist/src/save-lock.d.ts +11 -0
  155. package/dist/src/save-lock.js +29 -2
  156. package/dist/src/secret-redaction.d.ts +13 -0
  157. package/dist/src/secret-redaction.js +71 -0
  158. package/dist/src/session-summary.d.ts +10 -4
  159. package/dist/src/session-summary.js +14 -7
  160. package/dist/src/sessions.js +8 -2
  161. package/dist/src/shell.js +4 -1
  162. package/dist/src/side-panel.d.ts +1 -1
  163. package/dist/src/side-panel.js +1 -1
  164. package/dist/src/skill-commands.d.ts +2 -0
  165. package/dist/src/skill-commands.js +2 -0
  166. package/dist/src/skills/bundled/create-agent/SKILL.md +81 -0
  167. package/dist/src/skills/bundled/create-skill/SKILL.md +81 -0
  168. package/dist/src/skills/bundled/doctor/SKILL.md +43 -0
  169. package/dist/src/skills/bundled/graph-manager/SKILL.md +100 -0
  170. package/dist/src/skills/bundled/graph-manager/errors.md +38 -0
  171. package/dist/src/skills/bundled/graph-manager/patterns.md +78 -0
  172. package/dist/src/skills/bundled/manage-mcp/SKILL.md +75 -0
  173. package/dist/src/skills/bundled/manage-mcp/probe.md +165 -0
  174. package/dist/src/skills/bundled/manage-skills/SKILL.md +67 -0
  175. package/dist/src/skills/bundled/provenance.json +50 -0
  176. package/dist/src/skills/bundled/write-instructions/SKILL.md +42 -0
  177. package/dist/src/skills/invocable-skills.d.ts +41 -0
  178. package/dist/src/skills/invocable-skills.js +49 -0
  179. package/dist/src/skills/prompt-skills.d.ts +1 -0
  180. package/dist/src/skills/prompt-skills.js +33 -0
  181. package/dist/src/skills/runtime-skills.d.ts +4 -0
  182. package/dist/src/skills/runtime-skills.js +21 -0
  183. package/dist/src/structured-step.d.ts +55 -0
  184. package/dist/src/structured-step.js +85 -0
  185. package/dist/src/subagent-run.d.ts +1 -1
  186. package/dist/src/subagent-run.js +29 -33
  187. package/dist/src/telemetry/schema.d.ts +2 -2
  188. package/dist/src/telemetry/schema.js +3 -2
  189. package/dist/src/terminal-ui.d.ts +38 -0
  190. package/dist/src/terminal-ui.js +126 -28
  191. package/dist/src/timers.d.ts +21 -2
  192. package/dist/src/timers.js +12 -4
  193. package/dist/src/tool-dependencies.js +4 -0
  194. package/dist/src/tool-names.d.ts +18 -0
  195. package/dist/src/tool-names.js +26 -0
  196. package/dist/src/tools.d.ts +9 -0
  197. package/dist/src/tools.js +159 -20
  198. package/dist/src/trajectory.js +32 -12
  199. package/dist/src/transcript.js +5 -0
  200. package/dist/src/types.d.ts +36 -0
  201. package/dist/src/web-search.d.ts +59 -0
  202. package/dist/src/web-search.js +216 -0
  203. package/docs/agents/README.md +2 -2
  204. package/docs/agents/mcp-server.md +28 -3
  205. package/docs/agents/subagent-mode.md +7 -4
  206. package/docs/concepts/README.md +1 -1
  207. package/docs/concepts/security.md +4 -2
  208. package/docs/getting-started/accounts.md +15 -4
  209. package/docs/getting-started/configure-providers.md +30 -3
  210. package/docs/guides/README.md +1 -0
  211. package/docs/guides/browser.md +12 -0
  212. package/docs/guides/desktop-app.md +11 -4
  213. package/docs/guides/graph-builder.md +9 -1
  214. package/docs/guides/web-search.md +47 -0
  215. package/docs/reference/cli.md +4 -3
  216. package/docs/reference/config.md +4 -4
  217. package/docs/reference/slash-commands.md +2 -1
  218. package/docs/superpowers/plans/2026-11-06-graph-soft-delete.md +125 -0
  219. package/docs/superpowers/plans/2026-11-09-orchestrator-delegation.md +295 -0
  220. package/docs/superpowers/specs/2026-11-01-pr-section-design.md +7 -0
  221. package/docs/superpowers/specs/2026-11-06-bundled-skills-design.md +206 -0
  222. package/docs/superpowers/specs/2026-11-09-orchestrator-delegation-design.md +291 -0
  223. package/package.json +1 -1
  224. package/tests/permissions-test-plan.md +2 -1
@@ -3,6 +3,7 @@ import path from 'node:path';
3
3
  import { randomUUID } from 'node:crypto';
4
4
  import { execFile } from 'node:child_process';
5
5
  import { promisify } from 'node:util';
6
+ import { StringDecoder } from 'node:string_decoder';
6
7
  import { andorraCreateReadTool, andorraCreateWriteTool, andorraCreateEditTool, andorraCreateFindTool, andorraCreateGrepTool, andorraCreateLsTool, andorraCreateBashTool, andorraCreatePowerShellTool, } from '../vendor/engine/runtime/coding-agent/core/tools/index.js';
7
8
  import { andorraGetToolPath } from '../vendor/engine/runtime/coding-agent/utils/tools-manager.js';
8
9
  import { defaultShellKind, runShell, runNativeProcess } from './shell.js';
@@ -12,8 +13,9 @@ import { getQaProcessManager } from './qa/runtime/ProcessManager.js';
12
13
  import { clipText } from './text.js';
13
14
  import { matchesFileRead, storeFileRead } from './file-read-state.js';
14
15
  import { FileReadRequiredError } from './tool-errors.js';
15
- import { permissionMode } from './permissions.js';
16
+ import { permissionMode, PLAN_MODE_MUTATION_ERROR } from './permissions.js';
16
17
  import { withGrepRegex } from './grep-regex.js';
18
+ import { claimReadImages, readImageObservation } from './read-image.js';
17
19
  const execFileAsync = promisify(execFile);
18
20
  const excluded = new Set(['.git', 'node_modules', '.andorracode']);
19
21
  const MAX_MODEL_OUTPUT = 24_000;
@@ -37,31 +39,54 @@ async function shellPermission(policy, name, args, context) {
37
39
  throw new Error('Escalation requires a nonempty justification');
38
40
  const mode = permissionMode(context);
39
41
  let explicitlyApproved = false;
42
+ let escalationAuthorized = false;
43
+ // Plan mode researches read-only: an escalation (host and network access) would be a change no
44
+ // plan has been approved for, so it is refused with the same guidance as a file mutation.
45
+ if (mode === 'plan' && requested === 'require_escalated')
46
+ throw new Error(PLAN_MODE_MUTATION_ERROR);
40
47
  if (!mode || mode === 'full-access' || requested === 'require_escalated') {
41
48
  await policy.authorize(name, { ...args, warning: 'UNSANDBOXED: entire host and network access.' }, {
42
49
  ...context, approve: async (...approval) => {
43
50
  const approved = await context.approve(...approval);
51
+ // A live permission switch settles outstanding prompts with policy-changed. Never
52
+ // allow an old escalation request to be re-approved after the run enters Plan.
53
+ if (requested === 'require_escalated' && permissionMode(context) === 'plan')
54
+ throw new Error(PLAN_MODE_MUTATION_ERROR);
44
55
  if (approved === true)
45
56
  explicitlyApproved = true;
46
57
  return approved;
47
58
  },
48
59
  });
60
+ // Authorization may have awaited other hooks while the run switched modes.
61
+ if (requested === 'require_escalated' && permissionMode(context) === 'plan')
62
+ throw new Error(PLAN_MODE_MUTATION_ERROR);
63
+ escalationAuthorized = requested === 'require_escalated';
49
64
  }
50
65
  // Evaluate synchronously at spawn, after filesystem/launcher discovery awaits.
51
66
  // Only a real per-call user grant can preserve unsandboxed execution when a
52
67
  // previously automatic Full Access grant has since been revoked.
53
68
  return () => {
54
69
  const live = permissionMode(context);
70
+ // Spawn-time recheck is essential: even a previously granted escalation cannot
71
+ // escape the read-only boundary if the run switched into Plan in the meantime.
72
+ if (requested === 'require_escalated' && live === 'plan')
73
+ throw new Error(PLAN_MODE_MUTATION_ERROR);
55
74
  if (explicitlyApproved)
56
75
  return undefined;
76
+ // An escalation this call's own authorization granted is an audited host grant: a shell is never a
77
+ // workspace-policy mutation, so without an explicit answer the journaled decision was Full Access
78
+ // policy — typically the user switching the run to Full Access while this prompt was open. It holds
79
+ // while Full Access is still in force at spawn; a revocation since then falls through below.
80
+ if (escalationAuthorized && live === 'full-access')
81
+ return undefined;
57
82
  // A later Full Access selection cannot create an unaudited host grant.
58
83
  // Keep an initially restricted call restricted; a subsequent call can
59
84
  // acquire Full Access through authorize and its journal events.
60
85
  if (mode && mode !== 'full-access' && live === 'full-access')
61
- return mode === 'read-only' ? 'read-only' : 'workspace-write';
86
+ return mode === 'read-only' || mode === 'plan' ? 'read-only' : 'workspace-write';
62
87
  if (!live || live === 'full-access')
63
88
  return undefined;
64
- return live === 'read-only' ? 'read-only' : 'workspace-write';
89
+ return live === 'read-only' || live === 'plan' ? 'read-only' : 'workspace-write';
65
90
  };
66
91
  }
67
92
  function nativeObservation(text, shell = false) {
@@ -266,54 +291,59 @@ export function createCodingTools(policy) {
266
291
  } }),
267
292
  };
268
293
  }
269
- const Read = zTool('Read', `Read a UTF-8 workspace file up to 8 MiB with compact line numbers. One call returns at most ${READ_MAX_LINES} lines: for a longer file, continue with the offset the result reports until you have read the whole file. A complete Read — every line, across calls — is remembered so Write/Edit can reject stale or unseen existing files; do not re-read unchanged files after a successful mutation.`, { type: 'object', properties: {
270
- file_path: { type: 'string', description: 'Workspace-relative or absolute path inside the workspace' },
271
- offset: { type: 'integer', minimum: 0, description: '1-based starting line; 0 is accepted as line 1' },
272
- limit: { type: 'integer', minimum: 1, maximum: READ_MAX_LINES, description: `Maximum lines to return, at most ${READ_MAX_LINES}` },
273
- }, required: ['file_path'], additionalProperties: false }, 'parallel', async (args, context) => {
274
- if (Object.keys(args).some(key => !['file_path', 'offset', 'limit'].includes(key)))
275
- throw new Error('Unknown Read argument');
276
- const filePath = stringArg(args, 'file_path');
277
- const offset = intArg(args, 'offset', { min: 0, max: Number.MAX_SAFE_INTEGER });
278
- const limit = intArg(args, 'limit', { min: 1, max: READ_MAX_LINES }) ?? READ_MAX_LINES;
279
- const resolved = await policy.safePath(context, filePath);
280
- const content = await policy.read(context, resolved);
281
- const lines = content.split('\n');
282
- if (content.endsWith('\n') || content === '')
283
- lines.pop();
284
- const first = Math.max(1, offset ?? 1);
285
- if (!lines.length) {
286
- await rememberReadRange(context, resolved, content, 1, 0, 0);
287
- return '[Empty file]';
288
- }
289
- if (first > lines.length)
290
- throw new Error(`Offset ${first} is beyond end of file (${lines.length} lines total)`);
291
- const lastRequested = Math.min(lines.length, first + limit - 1);
292
- // The runtime clips every tool result at MAX_MODEL_OUTPUT before the model sees it, so a
293
- // page that overflows would lose its tail and the continuation footer while still being
294
- // recorded as read. Stop on the last whole line that fits, and record only that line.
295
- const budget = MAX_MODEL_OUTPUT - 200;
296
- let rendered = '';
297
- let emittedLast = first - 1;
298
- for (let line = first; line <= lastRequested; line++) {
299
- const body = lines[line - 1] ?? '';
300
- const shown = body.length > READ_MAX_LINE_CHARS ? `${body.slice(0, READ_MAX_LINE_CHARS)}... (line truncated to ${READ_MAX_LINE_CHARS} chars)` : body;
301
- const next = `${line}\t${shown}${line < lastRequested ? '\n' : ''}`;
302
- if (rendered.length + next.length > budget)
303
- break;
304
- rendered += next;
305
- emittedLast = line;
306
- }
307
- if (emittedLast < first) {
308
- // A truncated line always fits this budget, so this is a defensive guard, not a path.
309
- rendered = `${first}\t${(lines[first - 1] ?? '').slice(0, READ_MAX_LINE_CHARS)}`;
310
- emittedLast = first;
311
- }
312
- await rememberReadRange(context, resolved, content, first, emittedLast, lines.length);
313
- if (emittedLast < lines.length)
314
- rendered += `\n[Showing lines ${first}-${emittedLast} of ${lines.length}. Use offset=${emittedLast + 1} to continue.]`;
315
- return rendered;
316
- });
294
+ const Read = { ...zTool('Read', `Read a UTF-8 workspace file up to 8 MiB with compact line numbers. One call returns at most ${READ_MAX_LINES} lines: for a longer file, continue with the offset the result reports until you have read the whole file. A complete Read — every line, across calls — is remembered so Write/Edit can reject stale or unseen existing files; do not re-read unchanged files after a successful mutation. An image file (PNG, JPEG, GIF, WebP or BMP, up to 20 MiB) is returned as an image you can see, downscaled when large; use this to look at a rendered frame, plot or screenshot instead of inferring it from pixel statistics. offset and limit do not apply to images.`, { type: 'object', properties: {
295
+ file_path: { type: 'string', description: 'Workspace-relative or absolute path inside the workspace' },
296
+ offset: { type: 'integer', minimum: 0, description: '1-based starting line; 0 is accepted as line 1' },
297
+ limit: { type: 'integer', minimum: 1, maximum: READ_MAX_LINES, description: `Maximum lines to return, at most ${READ_MAX_LINES}` },
298
+ }, required: ['file_path'], additionalProperties: false }, 'parallel', async (args, context) => {
299
+ if (Object.keys(args).some(key => !['file_path', 'offset', 'limit'].includes(key)))
300
+ throw new Error('Unknown Read argument');
301
+ const filePath = stringArg(args, 'file_path');
302
+ const offset = intArg(args, 'offset', { min: 0, max: Number.MAX_SAFE_INTEGER });
303
+ const limit = intArg(args, 'limit', { min: 1, max: READ_MAX_LINES }) ?? READ_MAX_LINES;
304
+ const resolved = await policy.safePath(context, filePath);
305
+ // An image is recognized by its signature and shown as pixels. It is not recorded as a
306
+ // text read: Write and Edit cannot faithfully rewrite a file they only saw as a picture.
307
+ const image = await policy.readImage?.(context, resolved);
308
+ if (image)
309
+ return readImageObservation(context, filePath, image);
310
+ const content = await policy.read(context, resolved);
311
+ const lines = content.split('\n');
312
+ if (content.endsWith('\n') || content === '')
313
+ lines.pop();
314
+ const first = Math.max(1, offset ?? 1);
315
+ if (!lines.length) {
316
+ await rememberReadRange(context, resolved, content, 1, 0, 0);
317
+ return '[Empty file]';
318
+ }
319
+ if (first > lines.length)
320
+ throw new Error(`Offset ${first} is beyond end of file (${lines.length} lines total)`);
321
+ const lastRequested = Math.min(lines.length, first + limit - 1);
322
+ // The runtime clips every tool result at MAX_MODEL_OUTPUT before the model sees it, so a
323
+ // page that overflows would lose its tail and the continuation footer while still being
324
+ // recorded as read. Stop on the last whole line that fits, and record only that line.
325
+ const budget = MAX_MODEL_OUTPUT - 200;
326
+ let rendered = '';
327
+ let emittedLast = first - 1;
328
+ for (let line = first; line <= lastRequested; line++) {
329
+ const body = lines[line - 1] ?? '';
330
+ const shown = body.length > READ_MAX_LINE_CHARS ? `${body.slice(0, READ_MAX_LINE_CHARS)}... (line truncated to ${READ_MAX_LINE_CHARS} chars)` : body;
331
+ const next = `${line}\t${shown}${line < lastRequested ? '\n' : ''}`;
332
+ if (rendered.length + next.length > budget)
333
+ break;
334
+ rendered += next;
335
+ emittedLast = line;
336
+ }
337
+ if (emittedLast < first) {
338
+ // A truncated line always fits this budget, so this is a defensive guard, not a path.
339
+ rendered = `${first}\t${(lines[first - 1] ?? '').slice(0, READ_MAX_LINE_CHARS)}`;
340
+ emittedLast = first;
341
+ }
342
+ await rememberReadRange(context, resolved, content, first, emittedLast, lines.length);
343
+ if (emittedLast < lines.length)
344
+ rendered += `\n[Showing lines ${first}-${emittedLast} of ${lines.length}. Use offset=${emittedLast + 1} to continue.]`;
345
+ return rendered;
346
+ }), resultImages: claimReadImages };
317
347
  const Write = zTool('Write', 'Create a new file or completely replace an existing file. Existing files must first be fully Read (or supplied completely by CodeGraph) and must still match that snapshot. Prefer Edit for partial changes.', { type: 'object', properties: {
318
348
  file_path: { type: 'string', description: 'Workspace-relative or absolute path inside the workspace' },
319
349
  content: { type: 'string', description: 'Complete replacement file content' },
@@ -679,8 +709,18 @@ export function createCodingTools(policy) {
679
709
  const launchPolicy = await shellPermission(policy, name, args, context);
680
710
  const cwd = await policy.safePath(context, '.');
681
711
  const operations = { exec: async (value, directory, options) => {
712
+ // The same chunks that feed the vendored tool's accumulator also feed the live transcript:
713
+ // a reader who expands the running call sees the command's output as it prints. The
714
+ // decoder keeps a chunk boundary from splitting a multi-byte character on the way
715
+ // through; the observation the tool builds remains the authoritative text.
716
+ const decoder = new StringDecoder('utf8');
717
+ const report = options.onData;
718
+ const onData = (data) => {
719
+ report(data);
720
+ context.onCommandOutput?.(decoder.write(data));
721
+ };
682
722
  try {
683
- await runShell(value, directory, timeout, context.signal, kind, options.onData, undefined, launchPolicy);
723
+ await runShell(value, directory, timeout, context.signal, kind, onData, undefined, launchPolicy);
684
724
  return { exitCode: 0 };
685
725
  }
686
726
  catch (error) {
@@ -690,6 +730,11 @@ export function createCodingTools(policy) {
690
730
  return { exitCode: Number(code[1]) };
691
731
  throw error;
692
732
  }
733
+ finally {
734
+ const tail = decoder.end();
735
+ if (tail)
736
+ context.onCommandOutput?.(tail);
737
+ }
693
738
  } };
694
739
  const current = kind === 'powershell'
695
740
  ? andorraCreatePowerShellTool(cwd, { operations, persistOutput: false, exposeSessionEnvironment: false })
@@ -867,7 +912,7 @@ export function createCodingTools(policy) {
867
912
  const timeout = intArg(args, 'timeout', { min: 1, max: 600000 }) ?? 30000;
868
913
  const launchPolicy = await shellPermission(policy, 'PowerShellFast', args, context);
869
914
  const cwd = await policy.safePath(context, '.');
870
- return nativeObservation(await runPooledPowerShell(command, cwd, timeout, context.signal, launchPolicy), true);
915
+ return nativeObservation(await runPooledPowerShell(command, cwd, timeout, context.signal, launchPolicy, context.onCommandOutput), true);
871
916
  });
872
917
  const ShellMetrics = zTool('ShellMetrics', 'Return bounded per-process command timing statistics (p50/p95/p99), startup/validation, execution, first-output and cleanup phases without leaking command arguments.', { type: 'object', properties: {}, additionalProperties: false }, 'parallel', async () => JSON.stringify(commandTimingSummary()));
873
918
  const platformShell = process.platform === 'win32' ? canonicalShell('PowerShell', 'powershell') : canonicalShell('Bash', 'bash');
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The live-output tap for one running command tool call.
3
+ *
4
+ * A shell command's row in the transcript shows its output while the command still runs, not only
5
+ * after it exits: the tool forwards every chunk as the command prints it (the pooled worker's
6
+ * stream, a foreground shell's `onData`), and this tap turns that firehose into the throttled
7
+ * `node.tool.output` events the timeline reads. At most one event per interval, plus a trailing
8
+ * flush, keeps a chatty suite from flooding the journal; the call's own completion remains the
9
+ * authoritative record, and `stop` retires the tap the moment execution settles so a late chunk
10
+ * can never append to a row the completion already closed.
11
+ */
12
+ export interface CommandOutputTap {
13
+ push(chunk: string): void;
14
+ stop(): void;
15
+ }
16
+ export declare function createCommandOutputTap(emit: (chunk: string) => void, now?: () => number): CommandOutputTap;
@@ -0,0 +1,45 @@
1
+ import { monotonicNow } from './duration.js';
2
+ const FLUSH_INTERVAL_MS = 1_000;
3
+ /** What a quiet gap may queue between flushes: the tap carries the newest text, never all of it. */
4
+ const PENDING_LIMIT = 8_192;
5
+ export function createCommandOutputTap(emit, now = monotonicNow) {
6
+ let pending = '';
7
+ let timer;
8
+ // The first chunk flushes at once: a reader who expands a running call sees its opening output
9
+ // without waiting out an interval that began before anything printed.
10
+ let lastFlush = Number.NEGATIVE_INFINITY;
11
+ let stopped = false;
12
+ const flush = () => {
13
+ timer = undefined;
14
+ if (stopped || !pending)
15
+ return;
16
+ const chunk = pending;
17
+ pending = '';
18
+ lastFlush = now();
19
+ emit(chunk);
20
+ };
21
+ return {
22
+ push(chunk) {
23
+ if (stopped || !chunk)
24
+ return;
25
+ pending += chunk;
26
+ if (pending.length > PENDING_LIMIT)
27
+ pending = pending.slice(-PENDING_LIMIT);
28
+ const since = now() - lastFlush;
29
+ if (timer === undefined && since >= FLUSH_INTERVAL_MS)
30
+ flush();
31
+ else if (timer === undefined) {
32
+ timer = setTimeout(flush, FLUSH_INTERVAL_MS - since);
33
+ timer.unref();
34
+ }
35
+ },
36
+ stop() {
37
+ stopped = true;
38
+ if (timer !== undefined) {
39
+ clearTimeout(timer);
40
+ timer = undefined;
41
+ }
42
+ pending = '';
43
+ },
44
+ };
45
+ }
@@ -4,7 +4,7 @@ import { editProviderSettings } from './provider-settings.js';
4
4
  import { retireRemovedCodexAccounts, retireUnsavedCodexAccounts } from './codex-auth.js';
5
5
  import { droppedAnthropicAccounts, retireAnthropicAccounts } from './anthropic-console-auth.js';
6
6
  import { importProvidersFromRemote } from './provider-import.js';
7
- import { DEFAULT_HARNESS, listGraphs } from './graphs.js';
7
+ import { DEFAULT_HARNESS, listGraphs, withoutDeletedGraphs } from './graphs.js';
8
8
  import { graphStorageDirectory } from './graph-account.js';
9
9
  import { configuredGraphSelection, currentGraphSubject, saveGraphSelection } from './graph-selection.js';
10
10
  import { getMembership, loadAccessibleGraph, requireGraphMembership, ANDORRA_GRAPH_SELECTION } from './membership.js';
@@ -316,8 +316,8 @@ export async function runCommandScreen(line, state, ui, persist, signal, adapter
316
316
  const items = [{
317
317
  id: DEFAULT_HARNESS.id,
318
318
  label: 'Default',
319
- description: 'Software Engineer only. Reads project instructions and completes the task without an Orchestrator.',
320
- }, { id: ANDORRA_GRAPH_SELECTION, label: 'Andorra', description: free ? 'Premium workflow: Orchestrator -> Software Engineer -> Done' : 'Paid workflow: Orchestrator -> Software Engineer -> Done' }, ...saved.filter(graph => graph.id !== 'default').map(graph => ({ id: graph.id, label: `${graph.name} (${graph.id}@${graph.revision})`, description: 'Saved custom graph' })), { id: ':divider', label: '', separator: true }, { id: ':create', label: 'Create new graph', description: atLimit ? 'Free tier includes 1 custom graph. Upgrade to Premium for more graphs.' : 'Open the web graph builder' }, { id: ':edit', label: 'Edit Graphs', bold: true, description: 'Open saved graphs in the web graph builder' }];
319
+ description: 'Andorra Agent only. Reads project instructions and completes the task without an Orchestrator.',
320
+ }, { id: ANDORRA_GRAPH_SELECTION, label: 'Andorra', description: free ? 'Premium workflow: Orchestrator -> Andorra Agent -> Done' : 'Paid workflow: Orchestrator -> Andorra Agent -> Done' }, ...withoutDeletedGraphs(saved).filter(graph => graph.id !== 'default').map(graph => ({ id: graph.id, label: `${graph.name} (${graph.id}@${graph.revision})`, description: 'Saved custom graph' })), { id: ':divider', label: '', separator: true }, { id: ':create', label: 'Create new graph', description: atLimit ? 'Free tier includes 1 custom graph. Upgrade to Premium for more graphs.' : 'Open the web graph builder' }, { id: ':edit', label: 'Edit Graphs', bold: true, description: 'Open saved graphs in the web graph builder' }];
321
321
  while (!signal.aborted) {
322
322
  const selected = await ui.select('Graph', items, { selectedId: state.graph ?? DEFAULT_HARNESS.id, description: 'Choose and save your default graph for this account, or create one in the web builder. After saving, reopen /graph to select it.', signal });
323
323
  if (selected === undefined || signal.aborted)
@@ -6,7 +6,7 @@ import type { Completion, RunResult } from './runtime.js';
6
6
  import type { Usage } from './types.js';
7
7
  import type { CodeIntelligenceManager } from './code-intelligence/CodeIntelligenceManager.js';
8
8
  import { logoutCodex } from './codex-auth.js';
9
- export declare const HELP = "Commands:\n /browser Open the browser workspace (CLI stays available)\n /session Browse and resume saved sessions (newest first)\n /login Open browser sign-in or create an Andorra account\n /auth logout Remove this machine's saved Andorra account session\n /auth status Show Andorra account session status\n /model [model-id] Open model selection or select a model directly; with a graph that pins node models, asks whether to override them\n /model list Discover models from the active provider\n /providers [id] Choose providers; Right/e edits; Add provider configures\n /subagent [id [model]] Set the provider/model external hosts (Claude/Codex CLI) must use for Andorra subagent runs; off clears it\n /reasoning <level> Set default|none|minimal|low|medium|high|xhigh|max\n /graph [id] Select a graph or open the web graph builder\n /codegraph <action> Code intelligence: status|enable|disable|rebuild; enable|disable --global sets the default for every project\n /dashboard Toggle live dashboard and transcript (TTY only)\n /attach <path> Attach a file or folder to your next task (large pastes and dropped files attach automatically)\n /usage Open session usage (Escape to return)\n /permissions [mode] Choose and remember workspace permissions\n /jev <on|off|status> Turn Jev on or off for nodes that enable it, or show its setting\n /feedback <on|off|status> Show the anonymous-feedback setting; Paid accounts can turn it off\n /yolo <on|off> Turn session-wide Full Access on or off (host files and network)\n /tools List available coding tools\n /skills List, install, enable, disable or remove skills\n /<skillname> [args] Apply an enabled imported skill; qualify duplicate names by catalog ID\n /plugins List, install, enable, disable or remove plugins\n /mcp Add, edit, enable, disable or delete MCP servers\n /logout Sign out of your Andorra account (then /login to switch accounts)\n /logout codex Sign out of every configured Codex (ChatGPT) account\n /status Show workspace and current settings\n /clear Clear the conversation on screen and the retained context (session usage is retained)\n /compact Compact retained conversation history to free context\n /help Show commands\n /exit Quit\nSelection screens: Up/Down to browse, Enter or Space to select, Escape to return.\nCtrl+B toggles dashboard; Ctrl+G pages its graph; Ctrl+N cycles dashboard model statistics (display only).\nCtrl+T expands/collapses todos; Ctrl+O expands/collapses tool details; Ctrl+Y collapses/expands live thinking.\nShift+Arrow/Home/End selects prompt text; Ctrl+C copies and Ctrl+X cuts a selection. The wheel scrolls; Up/Down recall prompts. Shift+drag selects transcript text.\nCtrl+C stops an interactive run; send direction to resume, or press Ctrl+C again to exit (idle Ctrl+C exits too). /yolo on|off applies immediately, including at approvals. /exit quits. Headless Ctrl+C cancels the run; a second press exits.";
9
+ export declare const HELP = "Commands:\n /browser Open the browser workspace (CLI stays available)\n /session Browse and resume saved sessions (newest first)\n /login [--no-browser] Sign in or create an Andorra account (prints the address over SSH)\n /auth logout Remove this machine's saved Andorra account session\n /auth status Show Andorra account session status\n /model [model-id] Open model selection or select a model directly; with a graph that pins node models, asks whether to override them\n /model list Discover models from the active provider\n /providers [id] Choose providers; Right/e edits; Add provider configures\n /subagent [id [model]] Set the provider/model external hosts (Claude/Codex CLI) must use for Andorra subagent runs; off clears it\n /reasoning <level> Set default|none|minimal|low|medium|high|xhigh|max\n /graph [id] Select a graph or open the web graph builder\n /codegraph <action> Code intelligence: status|enable|disable|rebuild; enable|disable --global sets the default for every project\n /dashboard Toggle live dashboard and transcript (TTY only)\n /attach <path> Attach a file or folder to your next task (large pastes and dropped files attach automatically)\n /usage Open session usage (Escape to return)\n /permissions [mode] Choose and remember workspace permissions\n /jev <on|off|status> Turn Jev on or off for nodes that enable it, or show its setting\n /feedback <on|off|status> Show the anonymous-feedback setting; Paid accounts can turn it off\n /yolo <on|off> Turn session-wide Full Access on or off (host files and network)\n /tools List available coding tools\n /skills List, install, enable, disable or remove skills\n /<skillname> [args] Apply an enabled imported skill; qualify duplicate names by catalog ID\n /plugins List, install, enable, disable or remove plugins\n /mcp Add, edit, enable, disable or delete MCP servers\n /logout Sign out of your Andorra account (then /login to switch accounts)\n /logout --all Sign out, and delete every other Andorra sign-in saved on this machine\n /logout codex Sign out of every configured Codex (ChatGPT) account\n /status Show workspace and current settings\n /clear Clear the conversation on screen and the retained context (session usage is retained)\n /compact Compact retained conversation history to free context\n /help Show commands\n /exit Quit\nSelection screens: Up/Down to browse, Enter or Space to select, Escape to return.\nCtrl+B toggles dashboard; Ctrl+G pages its graph; Ctrl+N cycles dashboard model statistics (display only).\nCtrl+T expands/collapses todos; Ctrl+O expands/collapses tool details; Ctrl+Y collapses/expands live thinking.\nShift+Arrow/Home/End selects prompt text; Ctrl+C copies and Ctrl+X cuts a selection. The wheel scrolls; Up/Down recall prompts. Shift+drag selects transcript text.\nCtrl+C stops an interactive run; send direction to resume, or press Ctrl+C again to exit (idle Ctrl+C exits too). /yolo on|off applies immediately, including at approvals. /exit quits. Headless Ctrl+C cancels the run; a second press exits.";
10
10
  export interface CommandState {
11
11
  config: Config;
12
12
  yolo: boolean;
@@ -26,6 +26,10 @@ export interface CommandState {
26
26
  graph?: string;
27
27
  codeIntel?: CodeIntelligenceManager;
28
28
  notify?: (message: string) => void;
29
+ /** Ask for one line of text, such as the sign-in address pasted back from another device. */
30
+ readLine?: (prompt: string, signal: AbortSignal) => Promise<string>;
31
+ /** Put text on the viewer's clipboard: the full-screen terminal wraps a long sign-in address. */
32
+ copyText?: (text: string) => void;
29
33
  /** A run is in flight: settings saved now apply to the next run, and the reply says so. */
30
34
  running?: boolean;
31
35
  /** Ask whether a model change should replace the graph's per-node model selections. */
@@ -62,6 +66,12 @@ export interface ConversationTurn {
62
66
  direction?: string;
63
67
  /** Disk-backed attachments the turn was submitted with; the replay path re-references them by path. */
64
68
  attachments?: import('./attachments.js').UserAttachmentRef[];
69
+ /**
70
+ * Set when this turn's opening message was delivered by a wake rather than sent by the user: the agent's
71
+ * own `set_timer` reminder (`timer`), or the review comments an Auto-fix wake brought (`auto-fix`).
72
+ * The text is the task, or the direction of a continued attempt; a client labels it as what it is.
73
+ */
74
+ wake?: TurnWake;
65
75
  /**
66
76
  * The messages the user typed into the attempt while it was running, in the order it read them.
67
77
  *
@@ -72,9 +82,12 @@ export interface ConversationTurn {
72
82
  */
73
83
  steers?: {
74
84
  text: string;
75
- attachments?: import('./attachments.js').UserAttachmentRef[];
85
+ attachments?: import('./attachments.js').UserAttachmentRef[]; /** A wake's reminder read mid-run, not the user's message. */
86
+ wake?: TurnWake;
76
87
  }[];
77
88
  }
89
+ /** What delivered a turn's message instead of the user (see `ConversationTurn.wake`). */
90
+ export type TurnWake = 'timer' | 'auto-fix';
78
91
  /**
79
92
  * Collapse retained turns into a single summary entry so the next request sends one
80
93
  * condensed user/assistant pair instead of every full completion.
@@ -20,7 +20,7 @@ const REASONING_USAGE = 'Usage: /reasoning default|none|minimal|low|medium|high|
20
20
  export const HELP = `Commands:
21
21
  /browser Open the browser workspace (CLI stays available)
22
22
  /session Browse and resume saved sessions (newest first)
23
- /login Open browser sign-in or create an Andorra account
23
+ /login [--no-browser] Sign in or create an Andorra account (prints the address over SSH)
24
24
  /auth logout Remove this machine's saved Andorra account session
25
25
  /auth status Show Andorra account session status
26
26
  /model [model-id] Open model selection or select a model directly; with a graph that pins node models, asks whether to override them
@@ -43,6 +43,7 @@ export const HELP = `Commands:
43
43
  /plugins List, install, enable, disable or remove plugins
44
44
  /mcp Add, edit, enable, disable or delete MCP servers
45
45
  /logout Sign out of your Andorra account (then /login to switch accounts)
46
+ /logout --all Sign out, and delete every other Andorra sign-in saved on this machine
46
47
  /logout codex Sign out of every configured Codex (ChatGPT) account
47
48
  /status Show workspace and current settings
48
49
  /clear Clear the conversation on screen and the retained context (session usage is retained)
@@ -201,9 +202,9 @@ export function subagentClearRequested(line, providers) {
201
202
  export async function executeCommand(line, state, persist, signal, graphAccess = { load: loadAccessibleGraph, requirePaid: requireGraphMembership }, graphSubject = currentGraphSubject, logout = logoutCodex) {
202
203
  // `/logout` is the Andorra account's sign-out, the counterpart of `/login`; a provider's managed
203
204
  // sign-in is named explicitly, so signing out of the account never touches provider sessions.
204
- if (/^\/logout\s+\S/.test(line.trim())) {
205
+ if (/^\/logout\s+\S/.test(line.trim()) && !/^\/logout\s+--all$/.test(line.trim())) {
205
206
  if (!/^\/logout\s+codex$/.test(line.trim()))
206
- return { text: 'Usage: /logout | /logout codex' };
207
+ return { text: 'Usage: /logout [--all] | /logout codex' };
207
208
  const codex = state.config.providers.filter(candidate => candidate.type === 'codex');
208
209
  if (!codex.length)
209
210
  return { text: 'No Codex provider is configured, so there is no Codex sign-in to log out of. Use /logout to sign out of your Andorra account.' };
@@ -253,9 +254,9 @@ export async function executeCommand(line, state, persist, signal, graphAccess =
253
254
  const codegraphScope = codegraph?.[2] === undefined ? 'repository' : codegraph[2] === '--global' ? 'global' : undefined;
254
255
  let result;
255
256
  if (/^\/(login|logout|auth)(?:\s|$)/.test(line.trim())) {
256
- const command = /^\/(login|logout)\s*$|^\/auth\s+(status|logout)\s*$/.exec(line.trim());
257
- const action = command?.[1] ?? command?.[2];
258
- result = { text: command ? await executeAuthCommand(action, { signal, print: state.notify }) : 'Usage: /login | /logout | /auth logout | /auth status' };
257
+ const command = /^\/(login)(?:\s+(--no-browser))?\s*$|^\/(logout)(?:\s+(--all))?\s*$|^\/auth\s+(status|logout)\s*$/.exec(line.trim());
258
+ const action = command?.[1] ?? command?.[3] ?? command?.[5];
259
+ result = { text: command ? await executeAuthCommand(action, { signal, print: state.notify, noBrowser: Boolean(command[2]), everywhere: Boolean(command[4]), readCallback: state.readLine, copyAddress: state.copyText }) : 'Usage: /login [--no-browser] | /logout [--all] | /auth logout | /auth status' };
259
260
  if (action === 'logout' || action === 'login') {
260
261
  delete draft.graph;
261
262
  result.clear = true;
@@ -297,7 +298,7 @@ export async function executeCommand(line, state, persist, signal, graphAccess =
297
298
  draft.graph = id;
298
299
  // This form has no UI to confirm on, so the warning that the switch starts fresh travels
299
300
  // in the returned text; an unchanged graph clears nothing and carries no warning.
300
- result = { text: `Graph: ${id === 'default' ? 'Default' : graph.name} (${id === 'default' ? 'Software Engineer only' : `${graph.id}@${graph.revision}`})${changed ? ". This session's context is cleared and the new graph starts fresh." : ''}${unavailable ? ` ${unavailable} The graph is selected anyway; a task on it starts only once it can run on this machine, or after /model overrides every node with one provider you have.` : ''}`, clear: changed, save };
301
+ result = { text: `Graph: ${id === 'default' ? 'Default' : graph.name} (${id === 'default' ? 'Andorra Agent only' : `${graph.id}@${graph.revision}`})${changed ? ". This session's context is cleared and the new graph starts fresh." : ''}${unavailable ? ` ${unavailable} The graph is selected anyway; a task on it starts only once it can run on this machine, or after /model overrides every node with one provider you have.` : ''}`, clear: changed, save };
301
302
  }
302
303
  catch (error) {
303
304
  return { text: `Graph unavailable: ${error instanceof Error ? error.message : id}. Use /graph to browse saved graphs.` };
@@ -333,8 +334,8 @@ export async function executeCommand(line, state, persist, signal, graphAccess =
333
334
  result = handleCommand(line, draft);
334
335
  }
335
336
  const permissionsChanged = draft.permissions !== state.permissions;
336
- // Cache writes must stop before Read Only is persisted or exposed to the run.
337
- if (permissionsChanged && draft.permissions === 'read-only')
337
+ // Cache writes must stop before Read Only or Plan is persisted or exposed to the run.
338
+ if (permissionsChanged && (draft.permissions === 'read-only' || draft.permissions === 'plan'))
338
339
  await state.codeIntel?.setPermissions(draft.permissions);
339
340
  if (result.save && feedbackWrite) {
340
341
  // The preference belongs to the installation, so its change is written to the file's current
@@ -373,7 +374,7 @@ export async function executeCommand(line, state, persist, signal, graphAccess =
373
374
  delete state.config.externalSubagent;
374
375
  state.yolo = draft.yolo;
375
376
  state.permissions = draft.permissions;
376
- if (permissionsChanged && draft.permissions !== 'read-only')
377
+ if (permissionsChanged && draft.permissions !== 'read-only' && draft.permissions !== 'plan')
377
378
  await state.codeIntel?.setPermissions(draft.permissions);
378
379
  if (draft.graph === undefined)
379
380
  delete state.graph;
@@ -470,14 +471,14 @@ export function handleCommand(line, state) {
470
471
  const changed = state.graph !== undefined;
471
472
  delete state.graph;
472
473
  if (changed)
473
- return { text: 'Graph: Default (Software Engineer only)', clear: true };
474
+ return { text: 'Graph: Default (Andorra Agent)', clear: true };
474
475
  }
475
- return { text: 'Graph: Default - Software Engineer only. Use the graph selector for the paid Andorra workflow or custom graphs.' };
476
+ return { text: 'Graph: Default - Andorra Agent only. Use the graph selector for the paid Andorra workflow or custom graphs.' };
476
477
  case '/permissions':
477
478
  if (!arg)
478
479
  return { text: `Permissions: ${permissionLabel(state.permissions ?? (state.yolo ? 'full-access' : 'ask-for-approval'))}` };
479
480
  if (!isPermissionMode(arg))
480
- return { text: 'Usage: /permissions read-only|ask-for-approval|approve-for-me|full-access' };
481
+ return { text: 'Usage: /permissions read-only|plan|ask-for-approval|approve-for-me|full-access' };
481
482
  state.config.workspacePermissions = { ...state.config.workspacePermissions, [workspacePermissionKey(state.workspace)]: arg };
482
483
  state.permissions = arg;
483
484
  state.yolo = arg === 'full-access';
@@ -17,17 +17,35 @@ export declare const SUMMARY_DESCRIPTION = "Markdown shown to the user as the fi
17
17
  export declare const COMPLETION_GUIDANCE = "Finish with complete_agent alone or final JSON. Todos/artifacts do not finish a node. Compare deliverables and verification evidence with acceptance criteria. Fulfill assigned requirements: intake/research nodes hand off downstream work; implementation nodes finish implementation and verification, not a progress checkpoint. Continue available work. For a concrete external blocker, report the blocker and unfinished work honestly. Use a blocked outcome if available; otherwise the sole outcome permits a terminal report, not a claim that the task is done. Only when this node is responsible for producing the final user answer, its summary must satisfy the user's response requirements: include complete requested files and exact formatting, including requested code fences, without abbreviation, path substitution, or offers to provide content later. Each fence opens and closes on its own line; a file written to the workspace that the user did not ask to see in the answer is named by path, not reproduced. Intermediate intake, research, and delegation nodes must instead keep a concise handoff and preserve these final-answer acceptance requirements in the downstream task instruction or output; do not implement or reproduce the final deliverable before handing off. Preserve required fields and valid JSON; escape quotes and Windows backslashes or use C:/repo/file.ts, and write each summary line break as \\n rather than dropping it. Never claim unperformed work.";
18
18
  /** Control-plane completion remains available when the execution-tool budget is exhausted. */
19
19
  export declare function completionTool(options: RunOptions): ToolSchema;
20
- /** Only a direct, sole model control call can request completion, never a tool observation. */
20
+ export declare const COMPLETION_ALONE_ERROR = "complete_agent must be called alone; no tools in this batch were executed.";
21
+ /**
22
+ * Only a direct, sole model control call can request completion, never a tool observation.
23
+ *
24
+ * The one companion allowed is `update_todos`: closing the plan and handing off in the same batch is
25
+ * the natural last move, and it changes no workspace state. Rejecting it threw the todo update away
26
+ * too, so every repair prompt then showed the model a plan that still said "in progress" for work it
27
+ * had finished, and the model spent its repairs arguing with that stale list. The todo calls are
28
+ * returned for the runtime to apply before it judges the handoff; anything else still voids the batch.
29
+ */
21
30
  export declare function completionResponse(response: ModelResponse): ModelResponse & {
22
31
  completionError?: string;
23
32
  completionSource: 'complete_agent' | 'final_text';
33
+ completionTodoCalls?: ModelResponse['toolCalls'];
24
34
  };
25
35
  /**
26
36
  * Undo one extra layer of string escaping in a summary. Some models JSON-escape the summary again
27
37
  * inside already-JSON tool arguments, so the parsed text holds a backslash and an "n" where its
28
- * line breaks belong, and the transcript draws its markdown as one literal paragraph. The decode
29
- * runs only when the text has no real line break and at least two escaped paragraph breaks, so a
30
- * summary that merely mentions an escape sequence, or a Windows path, is left as written.
38
+ * line breaks belong, and the transcript draws its markdown as one literal paragraph.
39
+ *
40
+ * Two shapes are decoded. A summary escaped throughout has no real line break and at least two
41
+ * escaped paragraph breaks; every escape in it is undone. A model can also switch to the extra
42
+ * escaping partway through, leaving a few real line breaks and the rest escaped: one `## heading`
43
+ * then swallows everything after it. That mixed summary is decoded only when at least two escaped
44
+ * breaks outside code open markdown structure (a heading, list item, quote, table, fence, or a
45
+ * paragraph break before text). Only its `\"` outside code, and its `\n` outside code on the lines
46
+ * holding that structure, are undone, so inline code, real fenced blocks and the lines the model
47
+ * wrote correctly keep the escapes and Windows paths they show. A summary that merely mentions an
48
+ * escape sequence, or a Windows path, is left as written.
31
49
  * Sessions saved before this decode ran still hold the escaped text, so their readers apply it too
32
50
  * (`displayHistory` in sessions.ts).
33
51
  */
@@ -42,4 +60,4 @@ export declare function decodeDoubleEscapedSummary(summary: string, notes?: stri
42
60
  * rejection for either burns a repair on a coin flip and can end a node whose work is already
43
61
  * done, so they are coerced and recorded instead.
44
62
  */
45
- export declare function parseCompletion(text: string, options: RunOptions, reject: (reason: string) => void, notes?: string[]): Completion | undefined;
63
+ export declare function parseCompletion(text: string, options: RunOptions, reject: (reason: string) => void, notes?: string[], stopReason?: string): Completion | undefined;