@andorra-labs/code 0.1.12 → 0.1.14

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 (617) hide show
  1. package/dist/src/account-presentation.d.ts +1 -37
  2. package/dist/src/account-presentation.js +6 -43
  3. package/dist/src/activity.d.ts +0 -25
  4. package/dist/src/activity.js +1 -23
  5. package/dist/src/agent-definitions.d.ts +0 -26
  6. package/dist/src/agent-definitions.js +0 -43
  7. package/dist/src/agent-execution.d.ts +0 -2
  8. package/dist/src/agent-execution.js +347 -554
  9. package/dist/src/agent-mcp-catalog.d.ts +0 -8
  10. package/dist/src/agent-mcp-catalog.js +0 -2
  11. package/dist/src/agent-mcp.d.ts +0 -56
  12. package/dist/src/agent-mcp.js +11 -155
  13. package/dist/src/agent-modifiers.d.ts +0 -1
  14. package/dist/src/agent-modifiers.js +25 -68
  15. package/dist/src/analytics.d.ts +0 -66
  16. package/dist/src/analytics.js +0 -45
  17. package/dist/src/andorra/endpoint.d.ts +7 -0
  18. package/dist/src/andorra/endpoint.js +46 -0
  19. package/dist/src/andorra/entry.d.ts +21 -0
  20. package/dist/src/andorra/entry.js +100 -0
  21. package/dist/src/andorra/errors.d.ts +2 -0
  22. package/dist/src/andorra/errors.js +39 -0
  23. package/dist/src/andorra/hosted.d.ts +52 -0
  24. package/dist/src/andorra/hosted.js +126 -0
  25. package/dist/src/andorra/monitor.d.ts +151 -0
  26. package/dist/src/andorra/monitor.js +393 -0
  27. package/dist/src/andorra/notices.d.ts +7 -0
  28. package/dist/src/andorra/notices.js +15 -0
  29. package/dist/src/andorra/opt-in.d.ts +58 -0
  30. package/dist/src/andorra/opt-in.js +112 -0
  31. package/dist/src/andorra/request-watch.d.ts +6 -0
  32. package/dist/src/andorra/request-watch.js +10 -0
  33. package/dist/src/andorra/state.d.ts +86 -0
  34. package/dist/src/andorra/state.js +238 -0
  35. package/dist/src/andorra/terminal.d.ts +68 -0
  36. package/dist/src/andorra/terminal.js +125 -0
  37. package/dist/src/andorra/usage-format.d.ts +9 -0
  38. package/dist/src/andorra/usage-format.js +19 -0
  39. package/dist/src/anthropic-console-auth.d.ts +0 -24
  40. package/dist/src/anthropic-console-auth.js +0 -37
  41. package/dist/src/anthropic-credentials.d.ts +0 -25
  42. package/dist/src/anthropic-credentials.js +9 -29
  43. package/dist/src/app-server/protocol.d.ts +18 -246
  44. package/dist/src/app-server/protocol.js +1 -132
  45. package/dist/src/app-server/reasoning.d.ts +0 -31
  46. package/dist/src/app-server/reasoning.js +0 -54
  47. package/dist/src/app-server/terminal.d.ts +0 -36
  48. package/dist/src/app-server/terminal.js +3 -39
  49. package/dist/src/app-server/workspace.d.ts +0 -167
  50. package/dist/src/app-server/workspace.js +4 -406
  51. package/dist/src/app-server.d.ts +52 -925
  52. package/dist/src/app-server.js +828 -3076
  53. package/dist/src/artifacts.d.ts +0 -10
  54. package/dist/src/artifacts.js +1 -11
  55. package/dist/src/attachments.d.ts +4 -98
  56. package/dist/src/attachments.js +10 -130
  57. package/dist/src/auth/AuthManager.d.ts +9 -93
  58. package/dist/src/auth/AuthManager.js +164 -186
  59. package/dist/src/auth/callback-page.d.ts +0 -1
  60. package/dist/src/auth/callback-page.js +0 -4
  61. package/dist/src/auth/callback.d.ts +0 -25
  62. package/dist/src/auth/callback.js +1 -29
  63. package/dist/src/auth/deployment.d.ts +1 -16
  64. package/dist/src/auth/deployment.js +1 -16
  65. package/dist/src/auth/index.d.ts +1 -12
  66. package/dist/src/auth/index.js +1 -12
  67. package/dist/src/auth/lock.d.ts +0 -1
  68. package/dist/src/auth/lock.js +0 -1
  69. package/dist/src/auth/store.d.ts +33 -108
  70. package/dist/src/auth/store.js +55 -130
  71. package/dist/src/auth/types.d.ts +0 -8
  72. package/dist/src/auth-commands.d.ts +0 -5
  73. package/dist/src/auth-commands.js +0 -1
  74. package/dist/src/automation-runner.d.ts +0 -9
  75. package/dist/src/automation-runner.js +0 -11
  76. package/dist/src/automation-service.d.ts +0 -10
  77. package/dist/src/automation-service.js +3 -17
  78. package/dist/src/automation-tool.js +0 -5
  79. package/dist/src/automation-worker-shutdown.d.ts +0 -1
  80. package/dist/src/automation-worker-shutdown.js +0 -3
  81. package/dist/src/automations.d.ts +23 -2
  82. package/dist/src/automations.js +91 -12
  83. package/dist/src/background-tasks.d.ts +0 -23
  84. package/dist/src/background-tasks.js +0 -11
  85. package/dist/src/boot-trace.d.ts +0 -13
  86. package/dist/src/boot-trace.js +1 -14
  87. package/dist/src/browser-activity.js +0 -2
  88. package/dist/src/browser-bridge.d.ts +0 -2
  89. package/dist/src/browser-bridge.js +0 -27
  90. package/dist/src/browser-captcha-tool.d.ts +0 -13
  91. package/dist/src/browser-captcha-tool.js +3 -35
  92. package/dist/src/browser-extensions-tool.d.ts +24 -0
  93. package/dist/src/browser-extensions-tool.js +137 -0
  94. package/dist/src/browser-extensions.d.ts +127 -0
  95. package/dist/src/browser-extensions.js +729 -0
  96. package/dist/src/browser-observation.d.ts +0 -15
  97. package/dist/src/browser-observation.js +1 -22
  98. package/dist/src/browser-panel-tool.d.ts +1 -37
  99. package/dist/src/browser-panel-tool.js +3 -73
  100. package/dist/src/browser-runner.d.ts +0 -1
  101. package/dist/src/browser-runner.js +5 -46
  102. package/dist/src/browser-server.d.ts +0 -6
  103. package/dist/src/browser-server.js +6 -229
  104. package/dist/src/browser-session.d.ts +0 -25
  105. package/dist/src/browser-session.js +1 -71
  106. package/dist/src/browser-stealth.d.ts +19 -13
  107. package/dist/src/browser-stealth.js +22 -38
  108. package/dist/src/browser-ui/app.js +7 -174
  109. package/dist/src/browser-ui/style.css +0 -68
  110. package/dist/src/browser-ui/tokens.css +15 -97
  111. package/dist/src/browser-view.d.ts +106 -295
  112. package/dist/src/browser-view.js +551 -587
  113. package/dist/src/capabilities.d.ts +0 -8
  114. package/dist/src/capabilities.js +0 -29
  115. package/dist/src/capsolver.d.ts +0 -13
  116. package/dist/src/capsolver.js +0 -15
  117. package/dist/src/clarification-ui.d.ts +0 -7
  118. package/dist/src/clarification-ui.js +0 -8
  119. package/dist/src/claude-executable.d.ts +0 -1
  120. package/dist/src/claude-executable.js +1 -2
  121. package/dist/src/claude-provider.d.ts +6 -19
  122. package/dist/src/claude-provider.js +155 -63
  123. package/dist/src/cli-executable.d.ts +0 -16
  124. package/dist/src/cli-executable.js +0 -7
  125. package/dist/src/cli-process.d.ts +0 -26
  126. package/dist/src/cli-process.js +0 -18
  127. package/dist/src/cli-sign-in.d.ts +0 -20
  128. package/dist/src/cli-sign-in.js +1 -17
  129. package/dist/src/cli.d.ts +1 -55
  130. package/dist/src/cli.js +118 -742
  131. package/dist/src/code-intelligence/CodeIntelligenceManager.d.ts +4 -59
  132. package/dist/src/code-intelligence/CodeIntelligenceManager.js +26 -99
  133. package/dist/src/code-intelligence/ContextLedger.d.ts +0 -4
  134. package/dist/src/code-intelligence/ContextLedger.js +0 -10
  135. package/dist/src/code-intelligence/ContextRouter.d.ts +0 -6
  136. package/dist/src/code-intelligence/ContextRouter.js +0 -8
  137. package/dist/src/code-intelligence/codegraph/CodeGraphProjectSession.d.ts +0 -2
  138. package/dist/src/code-intelligence/codegraph/CodeGraphProjectSession.js +5 -12
  139. package/dist/src/code-intelligence/codegraph/CodeGraphProvider.d.ts +0 -6
  140. package/dist/src/code-intelligence/codegraph/CodeGraphProvider.js +0 -6
  141. package/dist/src/code-intelligence/codegraph/CodeGraphSyncBarrier.d.ts +0 -5
  142. package/dist/src/code-intelligence/codegraph/CodeGraphSyncBarrier.js +1 -17
  143. package/dist/src/code-intelligence/codegraph/repoExploreTool.d.ts +0 -5
  144. package/dist/src/code-intelligence/codegraph/repoExploreTool.js +0 -5
  145. package/dist/src/code-intelligence/repository.d.ts +0 -9
  146. package/dist/src/code-intelligence/repository.js +1 -11
  147. package/dist/src/code-intelligence/types.d.ts +0 -8
  148. package/dist/src/codex-auth.d.ts +0 -44
  149. package/dist/src/codex-auth.js +0 -45
  150. package/dist/src/codex-browser-auth.d.ts +0 -13
  151. package/dist/src/codex-browser-auth.js +3 -20
  152. package/dist/src/codex-errors.js +0 -2
  153. package/dist/src/codex-executable.d.ts +0 -2
  154. package/dist/src/codex-executable.js +1 -7
  155. package/dist/src/codex-provider.d.ts +0 -13
  156. package/dist/src/codex-provider.js +0 -28
  157. package/dist/src/codex-rpc.d.ts +0 -10
  158. package/dist/src/codex-rpc.js +0 -12
  159. package/dist/src/coding-tools.d.ts +4 -26
  160. package/dist/src/coding-tools.js +161 -181
  161. package/dist/src/command-metrics.d.ts +0 -4
  162. package/dist/src/command-output-tap.d.ts +0 -11
  163. package/dist/src/command-output-tap.js +0 -3
  164. package/dist/src/command-screens.d.ts +41 -1
  165. package/dist/src/command-screens.js +316 -113
  166. package/dist/src/commands.d.ts +12 -63
  167. package/dist/src/commands.js +98 -127
  168. package/dist/src/completion-gates.d.ts +0 -47
  169. package/dist/src/completion-gates.js +0 -14
  170. package/dist/src/completion.d.ts +0 -98
  171. package/dist/src/completion.js +2 -239
  172. package/dist/src/config.d.ts +15 -115
  173. package/dist/src/config.js +123 -172
  174. package/dist/src/context-budget.d.ts +0 -22
  175. package/dist/src/context-budget.js +0 -44
  176. package/dist/src/context-compaction.d.ts +29 -6
  177. package/dist/src/context-compaction.js +94 -25
  178. package/dist/src/context-selection.d.ts +0 -24
  179. package/dist/src/context-selection.js +0 -34
  180. package/dist/src/dashboard-view.d.ts +2 -2
  181. package/dist/src/dashboard-view.js +11 -37
  182. package/dist/src/dashboard.d.ts +0 -2
  183. package/dist/src/dashboard.js +0 -9
  184. package/dist/src/deadline.d.ts +0 -45
  185. package/dist/src/deadline.js +0 -54
  186. package/dist/src/decision/ContinuationAdapter.d.ts +0 -5
  187. package/dist/src/decision/ContinuationAdapter.js +0 -5
  188. package/dist/src/decision/DecisionEngine.d.ts +0 -4
  189. package/dist/src/decision/DecisionManager.d.ts +0 -1
  190. package/dist/src/decision/DecisionManager.js +2 -7
  191. package/dist/src/decision/DecisionPolicy.d.ts +0 -1
  192. package/dist/src/decision/DecisionPolicy.js +0 -1
  193. package/dist/src/decision/FactContinuations.d.ts +11 -43
  194. package/dist/src/decision/FactContinuations.js +126 -95
  195. package/dist/src/decision/FactServiceGate.d.ts +0 -1
  196. package/dist/src/decision/FactServiceGate.js +0 -4
  197. package/dist/src/decision/PreparedSteps.d.ts +0 -15
  198. package/dist/src/decision/PreparedSteps.js +1 -11
  199. package/dist/src/decision/applyToolMenu.d.ts +0 -1
  200. package/dist/src/decision/applyToolMenu.js +2 -6
  201. package/dist/src/decision/checks.d.ts +15 -28
  202. package/dist/src/decision/checks.js +118 -49
  203. package/dist/src/decision/facts.d.ts +0 -16
  204. package/dist/src/decision/facts.js +0 -30
  205. package/dist/src/decision/guidancePolicy.js +0 -1
  206. package/dist/src/decision/hostedPolicy.d.ts +0 -6
  207. package/dist/src/decision/hostedPolicy.js +0 -7
  208. package/dist/src/decision/hostedSkills.d.ts +0 -19
  209. package/dist/src/decision/hostedSkills.js +0 -19
  210. package/dist/src/decision/optimizationPolicy.d.ts +0 -3
  211. package/dist/src/decision/optimizationPolicy.js +1 -4
  212. package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +0 -7
  213. package/dist/src/decision/providers/AndorraDecisionProvider.js +4 -27
  214. package/dist/src/decision/providers/HttpDecisionProvider.d.ts +0 -2
  215. package/dist/src/decision/providers/HttpDecisionProvider.js +0 -6
  216. package/dist/src/decision/routeTools.d.ts +0 -8
  217. package/dist/src/decision/routeTools.js +1 -8
  218. package/dist/src/decision/toolFamilies.d.ts +0 -1
  219. package/dist/src/decision/toolFamilies.js +1 -2
  220. package/dist/src/decision/toolMenu.d.ts +0 -3
  221. package/dist/src/decision/toolMenu.js +0 -4
  222. package/dist/src/decision/types.d.ts +1 -6
  223. package/dist/src/default-graph.d.ts +0 -9
  224. package/dist/src/default-graph.js +0 -9
  225. package/dist/src/delegation-changes.d.ts +0 -56
  226. package/dist/src/delegation-changes.js +4 -130
  227. package/dist/src/diff-preview.d.ts +0 -1
  228. package/dist/src/diff-preview.js +0 -17
  229. package/dist/src/duration.d.ts +0 -50
  230. package/dist/src/duration.js +0 -50
  231. package/dist/src/efficiency.d.ts +0 -39
  232. package/dist/src/efficiency.js +0 -16
  233. package/dist/src/engine/protocol.d.ts +0 -2
  234. package/dist/src/engine/protocol.js +0 -2
  235. package/dist/src/engine-streams.d.ts +0 -9
  236. package/dist/src/extensions.d.ts +3 -2
  237. package/dist/src/extensions.js +63 -35
  238. package/dist/src/favicons.d.ts +0 -26
  239. package/dist/src/favicons.js +0 -34
  240. package/dist/src/file-diff.d.ts +2 -58
  241. package/dist/src/file-diff.js +0 -32
  242. package/dist/src/file-read-key.d.ts +0 -7
  243. package/dist/src/file-read-key.js +0 -7
  244. package/dist/src/file-read-state.d.ts +0 -1
  245. package/dist/src/file-read-state.js +0 -4
  246. package/dist/src/firefox-cookies.d.ts +0 -34
  247. package/dist/src/firefox-cookies.js +1 -55
  248. package/dist/src/git-identity-audit.d.ts +27 -0
  249. package/dist/src/git-identity-audit.js +286 -0
  250. package/dist/src/git-identity-guard.d.ts +4 -0
  251. package/dist/src/git-identity-guard.js +998 -0
  252. package/dist/src/git-identity-hold.d.ts +12 -0
  253. package/dist/src/git-identity-hold.js +81 -0
  254. package/dist/src/git-summary.d.ts +0 -58
  255. package/dist/src/git-summary.js +2 -212
  256. package/dist/src/goal-completion-verification.d.ts +2 -2
  257. package/dist/src/goal-completion-verification.js +3 -6
  258. package/dist/src/graph-account.d.ts +0 -21
  259. package/dist/src/graph-account.js +0 -17
  260. package/dist/src/graph-editor-session.d.ts +0 -1
  261. package/dist/src/graph-editor-session.js +0 -3
  262. package/dist/src/graph-health.d.ts +9 -61
  263. package/dist/src/graph-health.js +34 -59
  264. package/dist/src/graph-manager-chat.d.ts +36 -153
  265. package/dist/src/graph-manager-chat.js +161 -182
  266. package/dist/src/graph-provider-portability.d.ts +1 -21
  267. package/dist/src/graph-provider-portability.js +6 -45
  268. package/dist/src/graph-quota.d.ts +0 -33
  269. package/dist/src/graph-quota.js +1 -44
  270. package/dist/src/graph-runner.d.ts +0 -1
  271. package/dist/src/graph-runner.js +58 -391
  272. package/dist/src/graph-selection.d.ts +0 -14
  273. package/dist/src/graph-selection.js +2 -15
  274. package/dist/src/graph-server.d.ts +2 -10
  275. package/dist/src/graph-server.js +39 -101
  276. package/dist/src/graph-studio-features.d.ts +0 -5
  277. package/dist/src/graph-studio-features.js +2 -42
  278. package/dist/src/graph-sync.d.ts +0 -78
  279. package/dist/src/graph-sync.js +5 -201
  280. package/dist/src/graph-tool.d.ts +0 -18
  281. package/dist/src/graph-tool.js +0 -27
  282. package/dist/src/graph-ui/app.js +176 -492
  283. package/dist/src/graph-ui/compat.js +0 -7
  284. package/dist/src/graph-ui/controls.css +0 -48
  285. package/dist/src/graph-ui/controls.js +0 -88
  286. package/dist/src/graph-ui/drafts.js +0 -12
  287. package/dist/src/graph-ui/edge-router.js +0 -62
  288. package/dist/src/graph-ui/embed.js +0 -59
  289. package/dist/src/graph-ui/icons.js +0 -8
  290. package/dist/src/graph-ui/library.css +0 -5
  291. package/dist/src/graph-ui/manager-markdown.js +0 -11
  292. package/dist/src/graph-ui/manager-state.js +1 -78
  293. package/dist/src/graph-ui/manager.css +0 -18
  294. package/dist/src/graph-ui/manager.js +43 -185
  295. package/dist/src/graph-ui/model-picker.js +0 -29
  296. package/dist/src/graph-ui/sidebar.js +2 -3
  297. package/dist/src/graph-ui/skill-picker.js +373 -39
  298. package/dist/src/graph-ui/studio-canvas.js +3 -38
  299. package/dist/src/graph-ui/studio.css +0 -18
  300. package/dist/src/graph-ui/studio.js +3 -71
  301. package/dist/src/graph-ui/style.css +16 -136
  302. package/dist/src/graph-ui/theme.js +1 -26
  303. package/dist/src/graph-ui/tokens.css +19 -118
  304. package/dist/src/graphs.d.ts +6 -157
  305. package/dist/src/graphs.js +66 -269
  306. package/dist/src/grep-regex-worker.js +0 -2
  307. package/dist/src/grep-regex.d.ts +1 -5
  308. package/dist/src/grep-regex.js +6 -8
  309. package/dist/src/grok-provider.d.ts +0 -17
  310. package/dist/src/grok-provider.js +1 -26
  311. package/dist/src/handoffs.d.ts +0 -11
  312. package/dist/src/handoffs.js +0 -13
  313. package/dist/src/hardened-runtime.d.ts +0 -10
  314. package/dist/src/hardened-runtime.js +9 -47
  315. package/dist/src/harness-home.d.ts +21 -0
  316. package/dist/src/harness-home.js +87 -0
  317. package/dist/src/host-process-guard.d.ts +0 -50
  318. package/dist/src/host-process-guard.js +0 -641
  319. package/dist/src/limits.d.ts +0 -64
  320. package/dist/src/limits.js +0 -62
  321. package/dist/src/managed-sign-in.d.ts +0 -12
  322. package/dist/src/managed-sign-in.js +0 -16
  323. package/dist/src/markdown.d.ts +0 -28
  324. package/dist/src/markdown.js +1 -175
  325. package/dist/src/mcp.d.ts +0 -99
  326. package/dist/src/mcp.js +4 -170
  327. package/dist/src/membership-errors.d.ts +0 -14
  328. package/dist/src/membership-errors.js +1 -14
  329. package/dist/src/membership.d.ts +9 -59
  330. package/dist/src/membership.js +20 -91
  331. package/dist/src/memory/LocalToolMemory.d.ts +0 -1
  332. package/dist/src/memory/LocalToolMemory.js +2 -7
  333. package/dist/src/memory/MemoryDistiller.js +0 -15
  334. package/dist/src/memory/MemoryManager.d.ts +0 -3
  335. package/dist/src/memory/MemoryManager.js +6 -18
  336. package/dist/src/memory/MemoryPolicy.d.ts +0 -2
  337. package/dist/src/memory/MemoryPolicy.js +0 -2
  338. package/dist/src/memory/MemoryProvider.d.ts +0 -6
  339. package/dist/src/memory/MemoryRetriever.js +0 -7
  340. package/dist/src/memory/PermissionMemoryProvider.d.ts +0 -1
  341. package/dist/src/memory/PermissionMemoryProvider.js +0 -1
  342. package/dist/src/memory/ProjectMemory.d.ts +5 -40
  343. package/dist/src/memory/ProjectMemory.js +22 -47
  344. package/dist/src/memory/ToolFailureLessons.d.ts +0 -3
  345. package/dist/src/memory/ToolFailureLessons.js +0 -6
  346. package/dist/src/memory/providers/NoOpMemoryProvider.d.ts +0 -1
  347. package/dist/src/memory/providers/NoOpMemoryProvider.js +0 -1
  348. package/dist/src/memory/redaction.d.ts +0 -5
  349. package/dist/src/memory/redaction.js +0 -11
  350. package/dist/src/memory/repository.d.ts +0 -6
  351. package/dist/src/memory/repository.js +2 -12
  352. package/dist/src/memory/types.d.ts +0 -1
  353. package/dist/src/model-context-windows.d.ts +2 -0
  354. package/dist/src/model-context-windows.js +24 -0
  355. package/dist/src/model-health-cache.d.ts +0 -38
  356. package/dist/src/model-health-cache.js +2 -50
  357. package/dist/src/model-metadata.d.ts +1 -18
  358. package/dist/src/model-metadata.js +42 -45
  359. package/dist/src/model-override.d.ts +0 -36
  360. package/dist/src/model-override.js +0 -43
  361. package/dist/src/model-tiers.d.ts +0 -13
  362. package/dist/src/model-tiers.js +0 -23
  363. package/dist/src/opencode-catalog.d.ts +0 -2
  364. package/dist/src/opencode-catalog.js +0 -11
  365. package/dist/src/opencode-cli-provider.d.ts +0 -35
  366. package/dist/src/opencode-cli-provider.js +1 -44
  367. package/dist/src/opencode-provider.d.ts +0 -2
  368. package/dist/src/opencode-provider.js +1 -16
  369. package/dist/src/package-name.d.ts +0 -2
  370. package/dist/src/package-name.js +0 -2
  371. package/dist/src/paged-transcript.d.ts +0 -11
  372. package/dist/src/paged-transcript.js +2 -20
  373. package/dist/src/palette.d.ts +1 -63
  374. package/dist/src/palette.js +1 -64
  375. package/dist/src/permissions.d.ts +0 -15
  376. package/dist/src/permissions.js +17 -21
  377. package/dist/src/powershell-pool.d.ts +0 -9
  378. package/dist/src/powershell-pool.js +3 -26
  379. package/dist/src/process-warnings.d.ts +4 -0
  380. package/dist/src/process-warnings.js +103 -0
  381. package/dist/src/profile.d.ts +0 -43
  382. package/dist/src/profile.js +0 -43
  383. package/dist/src/project-reservation.d.ts +11 -0
  384. package/dist/src/project-reservation.js +143 -0
  385. package/dist/src/provider-connection.d.ts +0 -18
  386. package/dist/src/provider-connection.js +15 -39
  387. package/dist/src/provider-engine.d.ts +0 -21
  388. package/dist/src/provider-engine.js +1 -96
  389. package/dist/src/provider-import.d.ts +0 -49
  390. package/dist/src/provider-import.js +0 -60
  391. package/dist/src/provider-keys.d.ts +1 -36
  392. package/dist/src/provider-keys.js +5 -48
  393. package/dist/src/provider-settings.d.ts +16 -3
  394. package/dist/src/provider-settings.js +36 -52
  395. package/dist/src/providers.d.ts +14 -219
  396. package/dist/src/providers.js +69 -326
  397. package/dist/src/pull-requests.d.ts +0 -173
  398. package/dist/src/pull-requests.js +5 -195
  399. package/dist/src/qa/browser/PlaywrightRunner.d.ts +0 -7
  400. package/dist/src/qa/browser/PlaywrightRunner.js +2 -16
  401. package/dist/src/qa/command-policy.d.ts +0 -23
  402. package/dist/src/qa/command-policy.js +0 -30
  403. package/dist/src/qa/guidance.d.ts +0 -21
  404. package/dist/src/qa/guidance.js +0 -20
  405. package/dist/src/qa/profile/ProjectInspector.d.ts +0 -4
  406. package/dist/src/qa/profile/ProjectInspector.js +0 -6
  407. package/dist/src/qa/profile/QaConfigLoader.d.ts +0 -7
  408. package/dist/src/qa/profile/QaConfigLoader.js +0 -6
  409. package/dist/src/qa/profile/QaProfile.d.ts +0 -7
  410. package/dist/src/qa/profile/QaProfile.js +0 -7
  411. package/dist/src/qa/profile/yaml.d.ts +0 -9
  412. package/dist/src/qa/profile/yaml.js +0 -13
  413. package/dist/src/qa/qa-authorize.d.ts +0 -19
  414. package/dist/src/qa/qa-authorize.js +4 -11
  415. package/dist/src/qa/runtime/ProcessManager.d.ts +0 -31
  416. package/dist/src/qa/runtime/ProcessManager.js +4 -41
  417. package/dist/src/qa/runtime/PtyManager.d.ts +0 -4
  418. package/dist/src/qa/runtime/PtyManager.js +1 -7
  419. package/dist/src/qa/runtime/changes.d.ts +0 -11
  420. package/dist/src/qa/runtime/changes.js +1 -3
  421. package/dist/src/qa/tools.d.ts +0 -10
  422. package/dist/src/qa/tools.js +0 -12
  423. package/dist/src/qa/types.d.ts +0 -13
  424. package/dist/src/react-runtime.d.ts +2 -21
  425. package/dist/src/react-runtime.js +107 -422
  426. package/dist/src/read-document-doc.d.ts +0 -6
  427. package/dist/src/read-document-doc.js +0 -55
  428. package/dist/src/read-document-docx.d.ts +0 -16
  429. package/dist/src/read-document-docx.js +2 -69
  430. package/dist/src/read-document-text.d.ts +0 -17
  431. package/dist/src/read-document-text.js +0 -22
  432. package/dist/src/read-document-tool.d.ts +0 -31
  433. package/dist/src/read-document-tool.js +0 -30
  434. package/dist/src/read-document.d.ts +0 -49
  435. package/dist/src/read-document.js +1 -67
  436. package/dist/src/read-image.d.ts +0 -32
  437. package/dist/src/read-image.js +0 -33
  438. package/dist/src/remote/cert.d.ts +0 -18
  439. package/dist/src/remote/cert.js +0 -44
  440. package/dist/src/remote/client.d.ts +0 -70
  441. package/dist/src/remote/client.js +1 -116
  442. package/dist/src/remote/command.js +0 -17
  443. package/dist/src/remote/engine-pool.d.ts +0 -152
  444. package/dist/src/remote/engine-pool.js +22 -339
  445. package/dist/src/remote/errors.d.ts +0 -15
  446. package/dist/src/remote/errors.js +0 -7
  447. package/dist/src/remote/network.d.ts +0 -26
  448. package/dist/src/remote/network.js +1 -34
  449. package/dist/src/remote/pairing.d.ts +16 -51
  450. package/dist/src/remote/pairing.js +50 -57
  451. package/dist/src/remote/pem.d.ts +0 -4
  452. package/dist/src/remote/pem.js +0 -4
  453. package/dist/src/remote/roots.d.ts +0 -20
  454. package/dist/src/remote/roots.js +0 -8
  455. package/dist/src/remote/serve.d.ts +0 -47
  456. package/dist/src/remote/serve.js +0 -30
  457. package/dist/src/remote/server.d.ts +0 -14
  458. package/dist/src/remote/server.js +1 -79
  459. package/dist/src/remote/types.d.ts +1 -32
  460. package/dist/src/remote/types.js +0 -10
  461. package/dist/src/run-control.d.ts +2 -9
  462. package/dist/src/run-control.js +9 -13
  463. package/dist/src/run-progress.d.ts +0 -170
  464. package/dist/src/run-progress.js +0 -285
  465. package/dist/src/run-records.d.ts +0 -443
  466. package/dist/src/run-records.js +14 -687
  467. package/dist/src/run-temp.d.ts +12 -0
  468. package/dist/src/run-temp.js +50 -0
  469. package/dist/src/runtime.d.ts +12 -228
  470. package/dist/src/runtime.js +2 -128
  471. package/dist/src/sandbox-child.js +0 -1
  472. package/dist/src/save-lock.d.ts +0 -12
  473. package/dist/src/save-lock.js +0 -28
  474. package/dist/src/screen-selection.d.ts +0 -23
  475. package/dist/src/screen-selection.js +0 -22
  476. package/dist/src/secret-redaction.d.ts +0 -12
  477. package/dist/src/secret-redaction.js +0 -45
  478. package/dist/src/session-changes.d.ts +4 -80
  479. package/dist/src/session-changes.js +25 -130
  480. package/dist/src/session-goal.d.ts +129 -0
  481. package/dist/src/session-goal.js +230 -0
  482. package/dist/src/session-monitor.d.ts +1 -10
  483. package/dist/src/session-monitor.js +2 -39
  484. package/dist/src/session-reaper.d.ts +0 -15
  485. package/dist/src/session-reaper.js +0 -14
  486. package/dist/src/session-skills.d.ts +15 -44
  487. package/dist/src/session-skills.js +75 -60
  488. package/dist/src/session-summary.d.ts +0 -26
  489. package/dist/src/session-summary.js +0 -32
  490. package/dist/src/session-title.d.ts +0 -1
  491. package/dist/src/session-title.js +0 -2
  492. package/dist/src/sessions.d.ts +3 -122
  493. package/dist/src/sessions.js +9 -178
  494. package/dist/src/shell.d.ts +3 -20
  495. package/dist/src/shell.js +8 -72
  496. package/dist/src/side-panel.d.ts +5 -99
  497. package/dist/src/side-panel.js +76 -133
  498. package/dist/src/sign-in-detection.d.ts +0 -39
  499. package/dist/src/sign-in-detection.js +0 -43
  500. package/dist/src/sign-in-offer.d.ts +1 -19
  501. package/dist/src/sign-in-offer.js +0 -13
  502. package/dist/src/skill-commands.d.ts +0 -1
  503. package/dist/src/skill-commands.js +1 -4
  504. package/dist/src/skills/bundled/control-browser/SKILL.md +1 -1
  505. package/dist/src/skills/bundled/graph-manager/errors.md +1 -1
  506. package/dist/src/skills/bundled/provenance.json +738 -738
  507. package/dist/src/skills/invocable-skills.d.ts +0 -18
  508. package/dist/src/skills/invocable-skills.js +0 -17
  509. package/dist/src/skills/project-skills.d.ts +0 -1
  510. package/dist/src/skills/project-skills.js +0 -3
  511. package/dist/src/skills/prompt-skills.js +0 -14
  512. package/dist/src/skills/runtime-skills.d.ts +0 -13
  513. package/dist/src/skills/runtime-skills.js +0 -37
  514. package/dist/src/stall-recovery.d.ts +0 -25
  515. package/dist/src/stall-recovery.js +0 -38
  516. package/dist/src/stray-files.d.ts +0 -9
  517. package/dist/src/stray-files.js +0 -16
  518. package/dist/src/structured-step.d.ts +0 -22
  519. package/dist/src/structured-step.js +0 -22
  520. package/dist/src/subagent-run.d.ts +2 -163
  521. package/dist/src/subagent-run.js +18 -376
  522. package/dist/src/subagent-tree.d.ts +32 -0
  523. package/dist/src/subagent-tree.js +128 -0
  524. package/dist/src/telemetry/aggregate.d.ts +0 -37
  525. package/dist/src/telemetry/aggregate.js +0 -40
  526. package/dist/src/telemetry/capture-core.d.ts +0 -87
  527. package/dist/src/telemetry/capture-core.js +0 -67
  528. package/dist/src/telemetry/capture.d.ts +0 -1
  529. package/dist/src/telemetry/capture.js +0 -3
  530. package/dist/src/telemetry/classify.d.ts +0 -58
  531. package/dist/src/telemetry/classify.js +0 -60
  532. package/dist/src/telemetry/decision-capture.d.ts +0 -1
  533. package/dist/src/telemetry/emitter.d.ts +0 -30
  534. package/dist/src/telemetry/emitter.js +1 -62
  535. package/dist/src/telemetry/gate.d.ts +0 -29
  536. package/dist/src/telemetry/gate.js +0 -22
  537. package/dist/src/telemetry/identity.d.ts +0 -13
  538. package/dist/src/telemetry/identity.js +0 -29
  539. package/dist/src/telemetry/outbox.d.ts +0 -64
  540. package/dist/src/telemetry/outbox.js +1 -108
  541. package/dist/src/telemetry/schema.d.ts +1 -49
  542. package/dist/src/telemetry/schema.js +3 -84
  543. package/dist/src/telemetry/state.d.ts +0 -53
  544. package/dist/src/telemetry/state.js +0 -64
  545. package/dist/src/telemetry/surface.d.ts +0 -31
  546. package/dist/src/telemetry/surface.js +1 -39
  547. package/dist/src/telemetry/uploader.d.ts +0 -11
  548. package/dist/src/telemetry/uploader.js +0 -46
  549. package/dist/src/telemetry/uploads.d.ts +0 -11
  550. package/dist/src/telemetry/uploads.js +0 -11
  551. package/dist/src/telemetry/version.d.ts +0 -4
  552. package/dist/src/telemetry/version.js +0 -14
  553. package/dist/src/telemetry/workspace.d.ts +0 -7
  554. package/dist/src/telemetry/workspace.js +1 -22
  555. package/dist/src/terminal-ui.d.ts +33 -521
  556. package/dist/src/terminal-ui.js +145 -884
  557. package/dist/src/test-edit-guard.d.ts +74 -0
  558. package/dist/src/test-edit-guard.js +269 -0
  559. package/dist/src/text.d.ts +0 -1
  560. package/dist/src/text.js +0 -1
  561. package/dist/src/time-limit.d.ts +0 -36
  562. package/dist/src/time-limit.js +0 -37
  563. package/dist/src/timers.d.ts +0 -161
  564. package/dist/src/timers.js +0 -126
  565. package/dist/src/todos.d.ts +0 -1
  566. package/dist/src/todos.js +0 -3
  567. package/dist/src/token-rate.d.ts +0 -94
  568. package/dist/src/token-rate.js +0 -154
  569. package/dist/src/tool-activity.d.ts +0 -6
  570. package/dist/src/tool-activity.js +0 -7
  571. package/dist/src/tool-availability.d.ts +0 -13
  572. package/dist/src/tool-availability.js +1 -14
  573. package/dist/src/tool-call-clock.d.ts +1 -4
  574. package/dist/src/tool-call-clock.js +0 -13
  575. package/dist/src/tool-catalog.d.ts +0 -11
  576. package/dist/src/tool-catalog.js +0 -23
  577. package/dist/src/tool-dependencies.d.ts +0 -5
  578. package/dist/src/tool-dependencies.js +0 -4
  579. package/dist/src/tool-diff-stats.d.ts +0 -23
  580. package/dist/src/tool-diff-stats.js +0 -49
  581. package/dist/src/tool-errors.d.ts +9 -7
  582. package/dist/src/tool-errors.js +13 -6
  583. package/dist/src/tool-failure-tracker.d.ts +3 -11
  584. package/dist/src/tool-failure-tracker.js +19 -27
  585. package/dist/src/tool-names.d.ts +0 -16
  586. package/dist/src/tool-names.js +0 -12
  587. package/dist/src/tool-profile.d.ts +6 -0
  588. package/dist/src/tool-profile.js +23 -0
  589. package/dist/src/tool-result-filter.d.ts +0 -19
  590. package/dist/src/tool-result-filter.js +1 -66
  591. package/dist/src/tool-schema-compatibility.d.ts +0 -6
  592. package/dist/src/tool-schema-compatibility.js +0 -9
  593. package/dist/src/tools.d.ts +0 -4
  594. package/dist/src/tools.js +11 -114
  595. package/dist/src/trajectory.d.ts +0 -13
  596. package/dist/src/trajectory.js +23 -79
  597. package/dist/src/transcript.d.ts +0 -41
  598. package/dist/src/transcript.js +5 -60
  599. package/dist/src/types.d.ts +4 -168
  600. package/dist/src/untracked-file-removal.js +0 -20
  601. package/dist/src/update-check.d.ts +0 -14
  602. package/dist/src/update-check.js +1 -15
  603. package/dist/src/update.d.ts +0 -35
  604. package/dist/src/update.js +0 -100
  605. package/dist/src/usage-analytics.d.ts +17 -17
  606. package/dist/src/usage-analytics.js +168 -209
  607. package/dist/src/web-search.d.ts +0 -23
  608. package/dist/src/web-search.js +1 -27
  609. package/dist/src/widgets.d.ts +0 -25
  610. package/dist/src/widgets.js +0 -24
  611. package/dist/src/workspace-facts.d.ts +0 -12
  612. package/dist/src/workspace-facts.js +1 -18
  613. package/dist/src/workspace-git-metadata.d.ts +0 -16
  614. package/dist/src/workspace-git-metadata.js +0 -21
  615. package/dist/src/workspace-instructions.d.ts +3 -15
  616. package/dist/src/workspace-instructions.js +6 -19
  617. package/package.json +13 -2
@@ -6,79 +6,55 @@ import { stripVTControlCharacters } from 'node:util';
6
6
  import stringWidth from 'string-width';
7
7
  import { DashboardMetrics } from './dashboard.js';
8
8
  import { dashboardRows } from './dashboard-view.js';
9
+ import { goalStatusLabel } from './session-goal.js';
9
10
  import { transcriptColor } from './transcript.js';
10
11
  import { ToolCallClock, toolHeaderRows } from './tool-call-clock.js';
11
12
  import { formatDuration, formatHms } from './duration.js';
12
13
  import { PagedTranscript } from './paged-transcript.js';
13
14
  import { emptySelection, highlightRow, selectedSpan, selectedText, wordAt } from './screen-selection.js';
14
- import { accentSgr, ATTACHMENT_TOKEN, ATTENTION, DIM, FAINT, GRAY, SKILL_CHIP, SUBTLE, WHITE } from './palette.js';
15
- import { isCustomGraph, panelRowText, panelWidth, PANEL_MIN_COLUMNS, PANEL_MIN_ROWS, sidePanelRows } from './side-panel.js';
15
+ import { accentSgr, ATTACHMENT_TOKEN, ATTENTION, DIM, FAINT, GRAY, SKILL_CHIP, STATUS, SUBTLE, WHITE } from './palette.js';
16
+ import { usageTone } from './andorra/usage-format.js';
17
+ import { isCustomGraph, panelRowText, panelWidth, PANEL_MIN_COLUMNS, PANEL_MIN_ROWS, sidePanelRows, subagentTreeRows } from './side-panel.js';
16
18
  import { TokenRateMeter } from './token-rate.js';
19
+ import { SubagentTracker } from './subagent-tree.js';
17
20
  import { attachmentLabel, droppedPaths, formatBytes, isLargePaste, MAX_ATTACHMENTS } from './attachments.js';
21
+ import { holdWarnings } from './process-warnings.js';
18
22
  const segmenter = new Intl.Segmenter(undefined, { granularity: 'grapheme' });
19
23
  const graphemes = (text) => [...segmenter.segment(text)].map(part => part.segment);
20
- /**
21
- * Attachment tokens live in the composer draft as one code point each from Supplementary
22
- * Private Use Area-B, which no font or input method emits. `clean` strips that plane from
23
- * everything typed or pasted, so only `addAttachment` can put a token into the draft.
24
- */
25
24
  const TOKEN_BASE = 0x100000;
26
25
  const isToken = (part) => (part.codePointAt(0) ?? 0) >= TOKEN_BASE;
27
- /**
28
- * The skill chip: the leading `/name` of a picked skill, held as one code point so Backspace, Delete,
29
- * the arrows and selections treat it as a unit. It sits at the top of the private-use plane, above
30
- * every attachment marker, and like them it cannot be typed or pasted (`clean` strips the plane).
31
- */
32
26
  const SKILL_TOKEN = String.fromCodePoint(0x10FFFD);
33
- /** Graphemes of a draft, keeping each token its own element even when a combining mark follows it. */
34
27
  const composerGraphemes = (text) => graphemes(text).flatMap(part => isToken(part) && part.length > 2 ? [part.slice(0, 2), part.slice(2)] : [part]);
35
28
  const clean = (text) => stripVTControlCharacters(text).replace(/\r\n?/g, '\n').replace(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u202a-\u202e\u2066-\u2069]/g, '').replace(/[\u{100000}-\u{10FFFF}]/gu, '').replace(/\t/g, ' ');
36
29
  const oneLine = (text) => clean(text).replace(/\n/g, ' ');
37
- const commands = ['/model', '/providers', '/subagent', '/reasoning', '/graph', '/codegraph', '/dashboard', '/browser', '/attach', '/skills', '/skill', '/plugins', '/mcp', '/usage', '/permissions', '/yolo', '/jev', '/feedback', '/tools', '/session', '/status', '/clear', '/compact', '/help', '/login', '/logout', '/auth status', '/auth logout', '/exit', '/quit'];
38
- /**
39
- * The arguments the popup offers once a command and a space are typed. The read-only choice comes
40
- * first wherever there is one, so a second Enter on a freshly opened list reports rather than
41
- * changes a setting.
42
- */
30
+ const commands = ['/model', '/providers', '/subagent', '/reasoning', '/graph', '/codegraph', '/dashboard', '/browser', '/attach', '/skills', '/skill', '/plugins', '/mcp', '/usage', '/permissions', '/yolo', '/jev', '/feedback', '/tools', '/session', '/status', '/clear', '/compact', '/goal', '/help', '/login', '/logout', '/auth status', '/auth logout', '/exit', '/quit'];
43
31
  const argumentCompletions = {
44
- '/jev': ['/jev status', '/jev on', '/jev off'],
32
+ '/jev': ['/jev status', '/jev on', '/jev off', '/jev global on', '/jev global off'],
45
33
  '/feedback': ['/feedback status', '/feedback on', '/feedback off'],
46
34
  '/yolo': ['/yolo off', '/yolo on'],
47
35
  '/reasoning': ['default', 'none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'].map(level => `/reasoning ${level}`),
48
36
  '/codegraph': ['/codegraph status', '/codegraph enable', '/codegraph disable', '/codegraph rebuild', '/codegraph enable --global', '/codegraph disable --global'],
49
37
  '/attach': [],
38
+ '/goal': ['/goal clear'],
50
39
  '/logout': ['/logout codex'],
51
40
  '/skill': ['/skill off', '/skill on', '/skill remove'],
52
41
  };
53
- /**
54
- * Commands that do nothing useful bare. Enter or Tab on one fills in the command and a space and
55
- * waits for the argument instead of running it; `/logout` is complete on its own.
56
- */
57
42
  const argumentRequired = new Set(['/jev', '/feedback', '/yolo', '/reasoning', '/codegraph', '/attach']);
58
43
  const completionOptions = (query, skills = []) => {
59
44
  const command = /^(\/\S+)\s/.exec(query)?.[1];
60
- // A command typed in full is offered first, so `/skill` runs itself rather than `/skills`, which
61
- // a shorter prefix such as `/sk` still reaches first.
62
45
  return (command === undefined ? [...commands, ...skills] : argumentCompletions[command] ?? []).filter(option => option.startsWith(query))
63
46
  .sort((a, b) => Number(b === query) - Number(a === query));
64
47
  };
65
- /**
66
- * Whether the composer text is a command name, or a command with arguments, that the popup completes.
67
- * A command that is complete on its own lists its arguments only once one is being typed: `/logout `
68
- * must submit the bare sign-out, not have Enter pick `/logout codex` from a list nobody asked for.
69
- */
70
48
  const completable = (query) => {
71
49
  if (/^\/\S*$/.test(query))
72
50
  return true;
73
51
  const [, command, argument] = /^(\/\S+) (\S*)$/.exec(query) ?? [];
74
52
  return command !== undefined && Object.hasOwn(argumentCompletions, command) && (argument !== '' || argumentRequired.has(command));
75
53
  };
76
- /** A fixed-width, two-line terminal wordmark for the default Andorra CLI. */
77
54
  const ANDORRA_WORDMARK = [
78
55
  '▄▀█ █▄ █ █▀▄ █▀█ █▀█ █▀█ ▄▀█',
79
56
  '█▀█ █ ▀█ █▄▀ █▄█ █▀▄ █▀▄ █▀█',
80
57
  ];
81
- /** Said under the workflow name while the selected graph cannot bind to this machine's providers. */
82
58
  const OVERRIDE_HINT = 'Choose a model to override the nodes with · /model';
83
59
  const commandDescriptions = {
84
60
  '/browser': 'Open the browser workspace',
@@ -91,93 +67,48 @@ const commandDescriptions = {
91
67
  '/skill': 'Show the active skill', '/skill off': 'Pause the active skill', '/skill on': 'Resume the active skill', '/skill remove': 'End the active skill',
92
68
  '/skills': 'Manage and install skills', '/plugins': 'Manage and install plugins',
93
69
  '/mcp': 'Manage MCP servers',
94
- '/jev': 'Turn Jev on or off for nodes that enable it', '/jev on': 'Enable Jev', '/jev off': 'Disable Jev', '/jev status': 'Show saved Jev setting',
70
+ '/jev': 'Turn Jev on or off for this session', '/jev on': 'Turn Jev on for this session', '/jev off': 'Turn Jev off for this session', '/jev status': 'Show the session and global Jev settings',
71
+ '/jev global on': 'Turn the Global Jev switch on', '/jev global off': 'Turn Jev off for every session and agent',
95
72
  '/feedback': 'Show the anonymous-feedback setting; Paid accounts can turn it off', '/feedback on': 'Allow anonymous product feedback', '/feedback off': 'Stop anonymous product feedback (Paid plan)', '/feedback status': 'Show saved feedback setting',
96
73
  '/graph': 'Choose a graph', '/codegraph': 'Code intelligence status and actions', '/usage': 'Usage and token totals', '/yolo': 'Turn automatic approvals on or off', '/yolo on': 'Approve everything for this session', '/yolo off': 'Restore Ask for approval',
97
74
  '/permissions': 'Choose workspace permissions',
98
75
  '/tools': 'Available coding tools', '/status': 'Workspace and settings', '/clear': 'Clear conversation',
99
76
  '/compact': 'Compact conversation history',
77
+ '/goal': 'Set, show or clear the session goal', '/goal clear': 'Remove the session goal',
100
78
  '/help': 'Show command help', '/exit': 'Exit Andorra', '/quit': 'Alias for /exit',
101
79
  };
102
- /**
103
- * The session command a submitted line starts with, if any.
104
- *
105
- * The first whitespace-delimited token must match a known command's root exactly. A leading-slash
106
- * test alone would swallow legitimate steering text that merely mentions a path such as
107
- * `/src/app.ts`, and an unknown `/notacommand` is not a session command either.
108
- * @param value - the submitted composer text.
109
- * @returns the command token, or undefined when the text is ordinary input.
110
- */
111
80
  const submittedCommand = (value) => {
112
81
  const [token] = value.trim().split(/\s+/);
113
82
  return commands.some(command => command.split(/\s+/)[0] === token) ? token : undefined;
114
83
  };
115
- /**
116
- * The hint shown when a session command is typed while a task is working.
117
- *
118
- * Commands run between tasks: a started run has its history snapshotted and stays pinned to
119
- * its graph revision, so executing one mid-run would misreport what the run actually used.
120
- * The hint names the command and the way out instead of queueing the text as an instruction
121
- * the model would then follow.
122
- * @param command - the recognized command token that was submitted.
123
- */
124
84
  const workingCommandHint = (command) => `${command} doesn't run while a task is working. Press Ctrl+C to stop this task, then run ${command}.`
125
85
  + (command === '/graph' ? ' Switching graphs clears the previous graph progress and starts fresh.' : '');
126
- /** Commands the run input handler executes live during a run, plus its exits; they must reach it. */
127
86
  const liveRunCommands = ['/browser', '/attach', '/yolo', '/permissions', '/jev', '/help', '/status', '/usage', '/tools', '/exit', '/quit'];
128
87
  const paint = (text, color = GRAY) => typeof color === 'number'
129
88
  ? `\x1b[38;5;${color}m${text}\x1b[0m`
130
89
  : `\x1b[${color}m${text}\x1b[0m`;
131
- /**
132
- * Foreground sequence for the Andorra accent.
133
- *
134
- * Resolved per render rather than at module load: truecolor support is read from the
135
- * environment, which a test or embedder may set after this module is imported, and
136
- * caching the first answer would pin the fallback for the whole process.
137
- */
138
90
  const accentPaint = () => accentSgr();
139
- /** Thousands as `1.2k`, the shape both footer token readouts need to stay on one row. */
140
91
  const compactNumber = (value) => Intl.NumberFormat('en', { notation: 'compact', maximumFractionDigits: 1 }).format(value);
141
92
  const MAX_INPUT = 65_536;
142
- /**
143
- * Bracketed-paste accumulation ceiling. An in-flight paste may exceed the inline limit because
144
- * a large paste never inlines: it spools to an attachment, whose own cap this matches.
145
- */
146
93
  const PASTE_ACCUMULATE_LIMIT = 1_048_576;
147
94
  const INPUT_BURST_MS = 40;
148
- /** Two presses on one cell within this window select the word under it. */
149
95
  const DOUBLE_CLICK_MS = 400;
150
- /** The legacy X10 mouse report prefix: ESC [ M, followed by three payload bytes. */
151
96
  const LEGACY_MOUSE = Buffer.from([0x1b, 0x5b, 0x4d]);
152
- /** The bracketed-paste terminator, as bytes. */
153
97
  const PASTE_END = Buffer.from('\x1b[201~', 'latin1');
154
- /** How many trailing bytes of `buffer` could still grow into a `LEGACY_MOUSE` prefix. */
155
98
  const legacyMousePrefixLength = (buffer) => {
156
99
  for (let length = Math.min(2, buffer.length); length > 0; length--)
157
100
  if (buffer.subarray(buffer.length - length).equals(LEGACY_MOUSE.subarray(0, length)))
158
101
  return length;
159
102
  return 0;
160
103
  };
161
- /** Rows an echoed prompt may occupy before the tail is replaced by an omission marker. */
162
104
  const MAX_PROMPT_ROWS = 200;
163
- /** Long submitted prompts collapse in chat history until the user expands them with Ctrl+O. */
164
105
  const PROMPT_COLLAPSE_AFTER_ROWS = 12;
165
106
  const PROMPT_COLLAPSED_BODY_ROWS = 6;
166
- /**
167
- * Characters of streamed reasoning retained for the live preview. Only the tail ever
168
- * renders, so the buffer is a bounded window, not the full reasoning transcript.
169
- */
170
107
  const THINKING_KEEP = 4_000;
171
- /** Rows the reasoning preview expands to when opened. */
108
+ const AGENT_FALLBACK_MAX_ROWS = 7;
109
+ const AGENT_FALLBACK_MAX_COLUMNS = 60;
172
110
  const THINKING_ROWS = 6;
173
- /** Minimum milliseconds between preview repaints; faster streams coalesce into one render. */
174
111
  const THINKING_PAINT_MS = 80;
175
- /**
176
- * Ownership token for the composer while steering.
177
- *
178
- * A deferred Enter is only delivered when the surface that armed it still owns the
179
- * composer, so this stands in for `pending` when the steering composer is the owner.
180
- */
181
112
  const STEERING_OWNER = Symbol('steering');
182
113
  const commandPopupRows = (width, height, inputRows, matches) => width < 12 || height < 9
183
114
  ? 0 : Math.min(6, Math.max(1, matches), Math.max(0, height - inputRows - 11));
@@ -232,7 +163,6 @@ function wrap(text, width) {
232
163
  }
233
164
  return result;
234
165
  }
235
- /** Display-column span [start, end) of the selected graphemes on one wrapped composer row. */
236
166
  function selectedColumns(text, positions, [from, to], row) {
237
167
  let start = Infinity, end = -Infinity;
238
168
  for (let index = from; index < to; index++) {
@@ -244,10 +174,6 @@ function selectedColumns(text, positions, [from, to], row) {
244
174
  }
245
175
  return start < end ? [start, end] : undefined;
246
176
  }
247
- /**
248
- * Paint one composer row: attachment token columns in bold, and the selected column span in
249
- * reverse video over whichever color it covers.
250
- */
251
177
  function composerRow(text, color, selection, tokens) {
252
178
  let painted = '', run = '', style = '';
253
179
  let column = 0;
@@ -267,14 +193,12 @@ function composerRow(text, color, selection, tokens) {
267
193
  flush();
268
194
  return painted;
269
195
  }
270
- /** The display-column spans the draft's tokens occupy on one composer row. */
271
196
  function tokenColumns(draft, visible, positions, row) {
272
197
  const spans = [];
273
198
  draft.forEach((part, index) => { const position = positions[index]; if (isToken(part) && position?.row === row)
274
199
  spans.push([position.column, position.column + stringWidth(visible[index]), part === SKILL_TOKEN ? 'skill' : 'attachment']); });
275
200
  return spans;
276
201
  }
277
- /** Whitespace as one editor element; a token label is a single element that contains spaces. */
278
202
  const blank = (part) => /^\s+$/u.test(part);
279
203
  function editor(text, width) {
280
204
  const lines = [''];
@@ -335,7 +259,6 @@ function editor(text, width) {
335
259
  }
336
260
  return { lines, positions };
337
261
  }
338
- /** Full-screen terminal presentation; provider/runtime behavior remains owned by the CLI. */
339
262
  export class TerminalUI extends EventEmitter {
340
263
  input;
341
264
  output;
@@ -345,30 +268,10 @@ export class TerminalUI extends EventEmitter {
345
268
  keys = new PassThrough();
346
269
  decoder = new StringDecoder('utf8');
347
270
  status;
348
- /**
349
- * Graph nodes the user currently has running, in the order they started.
350
- *
351
- * `provider` and `model` are what each node's own executor reported, not what the graph file
352
- * configured, so a retry that falls back to another profile moves the footer with it.
353
- *
354
- * `resolved` carries the reasoning effort and context window of that same resolution. It stays
355
- * absent until a run reports them, and an absent `resolved` keeps the session's own numbers on
356
- * the footer; a present one whose fields are undefined means that node's model has no effort or
357
- * window of its own, which the footer shows as `provider default` and as no window at all
358
- * rather than falling back to the session's unrelated values.
359
- */
360
271
  activeNodes = new Map();
361
- /**
362
- * Node ids the current run has finished, in visit order.
363
- *
364
- * The side panel's zoom marks the run's trail with it, so it survives the run's end - a
365
- * reader looking at a finished run can still see where it went - and is cleared only when
366
- * the next run starts, which is the point the trail stops describing what is on screen.
367
- */
368
- /** Whether the last frame drew without the panel, so its return can be announced once. */
369
272
  panelWasHidden = true;
370
273
  visitedNodes = new Set();
371
- /** The node a stopped run ended on, kept as the panel's position until the next run starts. */
274
+ subagents = new SubagentTracker();
372
275
  stoppedNode;
373
276
  toolClock = new ToolCallClock();
374
277
  toolClockTimer;
@@ -389,38 +292,21 @@ export class TerminalUI extends EventEmitter {
389
292
  dashboardNotices = [];
390
293
  nodeModels = new Map();
391
294
  toggleDashboard() { this.dashboard = !this.dashboard; this.scroll = 0; this.scheduleRender(); }
392
- /** Start of a run: open the dashboard's run window. */
393
295
  startTask() { this.runActive = true; this.dashboardMetrics.startTask(); this.dashboardNotices = []; this.nodeModels.clear(); this.scheduleRender(); }
394
- /** End of a run: close the dashboard's run window. */
395
296
  finishTask() { this.runActive = false; this.dashboardMetrics.finishTask(); this.scheduleRender(); }
396
297
  resetDashboardSession(usage) { this.dashboardMetrics.resetSession(usage); this.dashboardModel = 0; this.dashboardGraphOffset = 0; this.nodeModels.clear(); this.dashboardNotices = []; this.scheduleRender(); }
397
- /** Clock backing the per-node speed meters; see {@link TerminalOptions.tokenClock}. */
398
298
  tokenClock;
399
- /**
400
- * One cumulative speed meter per generating identity, each stamped with the provider, model
401
- * and reasoning effort its requests were measured under.
402
- *
403
- * Parallel nodes interleave model calls (`src/graph-runner.ts` runs branch workers side by
404
- * side), so a single shared meter would have one node's first request discard the other's
405
- * in-flight window and both nodes' totals alternate between wipes. Keys extend the nodeId
406
- * with the parallel `copy` number the modifier stamps on every forwarded event, because two
407
- * copies of one node can resolve different models and retry independently. Keeping the
408
- * accumulation per identity means a switch simply displays the new identity's own average,
409
- * and returning to an earlier one resumes the average it built.
410
- */
411
299
  speedMeters = new Map();
412
- /** The executor's `invocationId` → the meter key whose marker opened that request's window. */
413
300
  speedInvocations = new Map();
414
- /** The node whose requests the readout currently follows: the most recent to open a call. */
415
301
  activeSpeedNode;
416
- /** The parallel copy of {@link activeSpeedNode} the readout follows, when one is named. */
417
302
  activeSpeedCopy;
418
- /** The exact meter key the readout displays - a node, a node's copy, or a distillation. */
419
303
  activeSpeedKey;
420
304
  handleRuntimeEvent(event) {
421
305
  if (this.closed)
422
306
  return;
423
307
  this.dashboardMetrics.handle(event);
308
+ if (this.subagents.handle(event, nodeId => oneLine(String(this.status.graph?.nodes[nodeId]?.name ?? this.activeNodes.get(nodeId)?.name ?? nodeId))))
309
+ this.scheduleRender();
424
310
  if (event.type === 'agent.session.started' && !event.data.subagentId) {
425
311
  const session = event.data;
426
312
  const nodeId = session.nodeId, provider = session.provider, model = session.model;
@@ -430,13 +316,7 @@ export class TerminalUI extends EventEmitter {
430
316
  const modelLabel = typeof model === 'string' ? oneLine(model) : undefined;
431
317
  const effort = typeof session.reasoningEffort === 'string' ? oneLine(session.reasoningEffort) : undefined;
432
318
  if (providerLabel !== undefined && modelLabel !== undefined)
433
- this.nodeModels.set(nodeId, oneLine(`${providerLabel}/${modelLabel}`));
434
- // The executor re-announces a node's resolution when a whole-agent retry falls back to
435
- // the node's other profile: same nodeId, different provider, model or effort. The
436
- // accumulated average measured the previous resolution, so it is rebuilt from zero
437
- // under the new one - while a repeat of the same resolution, which every ordinary run
438
- // emits, keeps it. Parallel copies carry their own `copy` number, so one copy's
439
- // fallback never resets a sibling copy still running on the primary model.
319
+ this.nodeModels.set(nodeId, oneLine(`${providerLabel}/${this.modelText(provider, model)}`));
440
320
  this.stampSpeedMeter(this.speedKey(nodeId, typeof session.copy === 'number' ? session.copy : undefined), providerLabel, modelLabel, effort);
441
321
  }
442
322
  if (event.type.startsWith('dashboard.'))
@@ -446,31 +326,7 @@ export class TerminalUI extends EventEmitter {
446
326
  if (event.type.startsWith('node.tool.'))
447
327
  this.scheduleRender();
448
328
  const data = event.data;
449
- // The executor emits `agent.turn.started` and `agent.iteration.started` back-to-back
450
- // around one model call (`src/hardened-runtime.ts`), so they are aliases of a single
451
- // boundary: opening a window for both would queue two per request, and since a completion
452
- // closes only one, the leftover start would be consumed by a *later* completion and every
453
- // reading would age against an ever-longer window. `iteration.started` is the marker every
454
- // other consumer already uses, so it alone opens the window the main call's tokens spread
455
- // across. Context compaction runs its own model calls between iterations and emits no
456
- // iteration marker (the next one belongs to the main request): its batch-level start
457
- // event opens the first window, and because a rejected summary attempt has already spent
458
- // that window on its usage, every attempt re-emits
459
- // `agent.context.compaction.attempt.started` so the retry gets a fresh one. All of these
460
- // events carry the executor's `invocationId`, and the same id names the request on its
461
- // usage delta, so each window is keyed by it: concurrent requests (branch workers,
462
- // parallel copies, subagents) completing out of order each spread over their own window
463
- // instead of the oldest one still open.
464
- // Goal verification calls the adapter outside every iteration marker with this run's
465
- // invocationId - the id whose iteration window the main response already closed - so its
466
- // own boundary re-opens the key and its completion spreads over the verification request
467
- // instead of the one-second synthetic fallback, whose false spike would then be held.
468
329
  if (event.type === 'agent.iteration.started' || event.type === 'agent.context.compaction.started' || event.type === 'agent.context.compaction.attempt.started' || event.type === 'agent.completion.verification.started') {
469
- // The speed readout averages one generating identity at a time. Every marker above
470
- // carries the `nodeId` the emit wrapper stamped on it - and, inside a parallel copy,
471
- // the `copy` number the modifier added - so the readout follows the copy generating
472
- // now, and because the accumulation lives per identity a switch neither wipes the
473
- // previous one's totals nor its still-open request window.
474
330
  const nodeId = typeof data.nodeId === 'string' ? data.nodeId : 'engineer';
475
331
  const invocationId = typeof data.invocationId === 'string' ? data.invocationId : undefined;
476
332
  const copy = typeof data.copy === 'number' ? data.copy : undefined;
@@ -489,19 +345,9 @@ export class TerminalUI extends EventEmitter {
489
345
  }
490
346
  }
491
347
  entry.meter.beginRequest(invocationId);
492
- // The focus moved: the node row and the speed readout now describe another copy or node, so
493
- // the frame is repainted even though no token reading has arrived yet.
494
348
  this.scheduleRender();
495
349
  return;
496
350
  }
497
- // Memory distillation calls the adapter directly, outside every executor marker, so the
498
- // dashboard adapter's start event is the only boundary it emits. Its metadata names the
499
- // operation and carries the invocation id the distiller stamps on its usage deltas, plus
500
- // the provider and model that actually perform it - finalization runs on the graph's own
501
- // resolution, not inside any node's iteration, so without a nodeId of its own it is keyed
502
- // by that resolution instead of whichever node generated last. Main model calls also pass
503
- // through the dashboard adapter but are already covered by their iteration marker, so
504
- // only the distillation operation opens a window here.
505
351
  if (event.type === 'dashboard.model.started' && data.operation === 'memory.distillation') {
506
352
  const invocationId = typeof data.invocationId === 'string' ? data.invocationId : undefined;
507
353
  const provider = typeof data.provider === 'string' ? oneLine(data.provider) : undefined;
@@ -517,8 +363,6 @@ export class TerminalUI extends EventEmitter {
517
363
  if (model !== undefined)
518
364
  entry.model = model;
519
365
  entry.meter.beginRequest(invocationId);
520
- // Distillation is work the user can watch decode: the readout follows the meter that
521
- // performed it, whether or not an iteration marker already named one.
522
366
  this.activeSpeedKey = key;
523
367
  if (typeof data.nodeId === 'string') {
524
368
  this.activeSpeedNode = data.nodeId;
@@ -526,19 +370,12 @@ export class TerminalUI extends EventEmitter {
526
370
  }
527
371
  return;
528
372
  }
529
- // Run boundaries no longer reset the speed readout: each node's cumulative average stays
530
- // up across runs, and the readout simply follows whichever node generates next.
531
373
  if (['graph.started', 'graph.completed', 'graph.stopped'].includes(event.type)) {
532
374
  this.activeNodes.clear();
533
- // The trail belongs to the run that walked it, and so does the position it stopped at:
534
- // a new run starts over from its own entry.
535
375
  if (event.type === 'graph.started') {
536
376
  this.visitedNodes.clear();
537
377
  this.stoppedNode = undefined;
538
378
  }
539
- // A run that was cancelled, exhausted or failed names the node it stopped on. That node
540
- // never completes, so without keeping it the zoom would show the last completed
541
- // predecessor as the position and the node the run actually died on as untouched.
542
379
  if (event.type === 'graph.stopped')
543
380
  this.stoppedNode = typeof data.nodeId === 'string' ? data.nodeId : undefined;
544
381
  this.scheduleRender();
@@ -548,19 +385,11 @@ export class TerminalUI extends EventEmitter {
548
385
  return;
549
386
  if (event.type === 'graph.node.completed') {
550
387
  this.activeNodes.delete(data.nodeId);
551
- // A node reached twice (a bounded cycle) is moved to the end of the trail rather than left
552
- // where it was first inserted: the set's order is the visit order the panel's focus reads,
553
- // so a repeated visit has to be the last one recorded even though the id stays unique.
554
388
  this.visitedNodes.delete(data.nodeId);
555
389
  this.visitedNodes.add(data.nodeId);
556
390
  this.scheduleRender();
557
391
  return;
558
392
  }
559
- // The executor reports the provider and model a node is actually running on, including the
560
- // profile a retry falls back to, so the footer follows a mid-node switch. A delegated child
561
- // repeats its parent's nodeId, and an ordinary prompt run reports the synthetic 'engineer'
562
- // id with no graph node behind it, so only a node the graph already reported as started is
563
- // updated: nothing else may put a node name on the footer.
564
393
  if (event.type === 'agent.session.started') {
565
394
  const progress = this.activeNodes.get(data.nodeId);
566
395
  if (!progress || typeof data.subagentId === 'string')
@@ -569,22 +398,12 @@ export class TerminalUI extends EventEmitter {
569
398
  const model = typeof data.model === 'string' ? oneLine(data.model) : undefined;
570
399
  if (!provider && !model)
571
400
  return;
572
- // The CLI adds the effort and window of that same resolution (`withNodeModelResolution` in
573
- // cli.ts). `contextWindow` being present at all - even as undefined - marks the node's own
574
- // resolution as authoritative, so its unknown window cannot inherit the session's.
575
401
  const resolved = Object.hasOwn(data, 'contextWindow')
576
402
  ? { reasoningEffort: typeof data.reasoningEffort === 'string' ? oneLine(data.reasoningEffort) : undefined,
577
403
  contextWindow: typeof data.contextWindow === 'number' && Number.isFinite(data.contextWindow) && data.contextWindow > 0 ? data.contextWindow : undefined }
578
404
  : progress.resolved;
579
- // Parallel copies of one node can resolve different profiles - one falls back while another
580
- // stays on the primary model - so the resolution is kept per copy as well as for the node:
581
- // the last announcement must not become the whole node's model.
582
405
  const copiesResolved = new Map(progress.copiesResolved ?? []);
583
406
  const copyIndex = typeof data.copy === 'number' ? data.copy : 0;
584
- // The copy keeps the *complete* resolution it announced - effort and window alongside the
585
- // provider and model - because the footer names one model, and a copy's thinking settings
586
- // belong to that same resolution: inheriting the node's would describe this copy with a
587
- // sibling's effort, which the rate comparison then reads as a mismatch and suppresses.
588
407
  const ownResolution = Object.hasOwn(data, 'contextWindow')
589
408
  ? resolved
590
409
  : typeof data.reasoningEffort === 'string' ? { reasoningEffort: oneLine(data.reasoningEffort), contextWindow: undefined } : undefined;
@@ -616,49 +435,16 @@ export class TerminalUI extends EventEmitter {
616
435
  const nodes = [...this.activeNodes.values()];
617
436
  return nodes.slice(0, 2).map(node => [node.name, node.loop, node.copies.size ? `copy ${[...node.copies].sort((a, b) => a - b).join(',')}/${node.totalCopies}` : ''].filter(Boolean).join(' - ')).join(' + ') + (nodes.length > 2 ? ` +${nodes.length - 2} more` : '');
618
437
  }
619
- /**
620
- * The columns the chat column actually draws in, panel and gutter excluded.
621
- *
622
- * Everything that measures chat content outside the render pass - input navigation, the
623
- * echoed-prompt frame, the docked selection card, the command popup's own visibility gate -
624
- * has to measure against this rather than the terminal width, or a draft that the composer
625
- * wrapped onto two rows is treated as one by the arrow keys, and a stored card is built
626
- * wider than the transcript that must re-wrap it.
627
- */
628
438
  chatColumns() {
629
439
  const columns = Math.max(1, this.output.columns || 80), height = Math.max(1, this.output.rows || 24);
630
440
  const panel = this.panelColumns(columns, height);
631
441
  return Math.max(1, columns - panel - (panel ? 1 : 0));
632
442
  }
633
- /**
634
- * Columns the transcript itself would have with the panel drawn.
635
- *
636
- * A prompt echo is stored in the transcript and re-wrapped there, so its frame has to be built for
637
- * that column rather than for whatever surface is on screen when the text is submitted: a task sent
638
- * from the Ctrl+B dashboard (or from a modal) would otherwise freeze a full-width box whose rows the
639
- * transcript splits as soon as the panel returns. This is `chatColumns()` with the two full-screen
640
- * surfaces ignored.
641
- */
642
443
  transcriptColumns() {
643
444
  const columns = Math.max(1, this.output.columns || 80), height = Math.max(1, this.output.rows || 24);
644
445
  const panel = columns < PANEL_MIN_COLUMNS || height < PANEL_MIN_ROWS ? 0 : panelWidth(columns);
645
446
  return Math.max(1, columns - panel - (panel ? 1 : 0));
646
447
  }
647
- /**
648
- * Columns the side panel occupies this frame, or 0 when it is not drawn.
649
- *
650
- * The panel is a second column of the same frame, so its width has to be known before the
651
- * chat column renders: below {@link PANEL_MIN_COLUMNS} the chat column would be squeezed
652
- * past the point where its own wrapping and the command popup still read well, and the two
653
- * full-screen surfaces - the dashboard (which already reports the same state) and a modal
654
- * screen (which is a focused flow) - keep the frame to themselves.
655
- */
656
- /**
657
- * Whether the side panel is on screen for the current terminal and surface.
658
- *
659
- * Exposed because the panel is the only consumer of the CLI's Git summary: a caller that would
660
- * spawn processes to fill it can ask first, and skip the work while nothing can display it.
661
- */
662
448
  panelVisible() {
663
449
  return this.panelColumns(Math.max(1, this.output.columns || 80), Math.max(1, this.output.rows || 24)) > 0;
664
450
  }
@@ -667,33 +453,19 @@ export class TerminalUI extends EventEmitter {
667
453
  return 0;
668
454
  return panelWidth(width);
669
455
  }
670
- /**
671
- * The side panel's rows for this frame.
672
- *
673
- * Assembled per render rather than cached: the rows carry a clock (how long a background
674
- * terminal has been running) and follow the node set the run is publishing, and the packing
675
- * only ever walks a handful of sections.
676
- * @param columns - total columns the panel occupies, divider and gutter included.
677
- * @param height - rows the panel may use, the whole frame height.
678
- */
679
456
  panelRows(columns, height) {
680
457
  if (!columns)
681
458
  return [];
682
459
  const entries = [...this.activeNodes.entries()];
683
- // The node the reader is watching - the one the speed readout follows - leads the section,
684
- // and the rest follow so a parallel run still names every node that is working.
685
460
  const focus = this.activeSpeedNode !== undefined && this.activeNodes.has(this.activeSpeedNode) ? this.activeSpeedNode : entries[0]?.[0];
686
461
  const nodes = entries
687
462
  .sort(([left], [right]) => (left === focus ? -1 : right === focus ? 1 : 0))
688
463
  .map(([id, node]) => {
689
464
  const detail = [node.loop, node.copies.size ? `copy ${[...node.copies].sort((a, b) => a - b).join(',')}/${node.totalCopies}` : ''].filter(Boolean).join(' · ');
690
- // The row describes the copy the reader is watching: when the speed readout follows a
691
- // parallel copy, that copy's own resolution is the one to name - another copy's fallback
692
- // must not be reported as this one's model.
693
465
  const perCopy = id === focus && this.activeSpeedCopy !== undefined ? node.copiesResolved?.get(this.activeSpeedCopy) : undefined;
694
466
  const provider = perCopy?.provider ?? node.provider;
695
467
  const model = perCopy?.model ?? node.model;
696
- const label = provider !== undefined || model !== undefined ? `${provider ?? this.status.provider} / ${model ?? this.status.model}` : '';
468
+ const label = provider !== undefined || model !== undefined ? `${this.providerText(provider ?? this.status.provider)} / ${this.modelText(provider ?? this.status.provider, model ?? this.status.model)}` : '';
697
469
  return { id, name: node.name, ...(detail ? { detail } : {}), ...(label ? { model: label } : {}) };
698
470
  });
699
471
  return sidePanelRows({
@@ -706,16 +478,10 @@ export class TerminalUI extends EventEmitter {
706
478
  ...(this.stoppedNode ? { stoppedNode: this.stoppedNode } : {}),
707
479
  todos: this.todos,
708
480
  terminals: this.status.terminals ?? [],
481
+ agents: this.subagents.groups(),
709
482
  now: this.tokenClock ? this.tokenClock() : Date.now(),
710
483
  }, Math.max(8, columns - 2), height);
711
484
  }
712
- /**
713
- * Compose the chat column's rows with the panel's into the frame's rows.
714
- *
715
- * Each row is padded to the chat width so the divider column stays unbroken, then carries
716
- * the panel cell for that row. A painted row is measured with `stringWidth`, which ignores
717
- * escape sequences, so padding cannot be confused by the color the chat row already holds.
718
- */
719
485
  composePanel(lines, rows, columns, chatWidth) {
720
486
  if (!columns)
721
487
  return lines;
@@ -729,38 +495,56 @@ export class TerminalUI extends EventEmitter {
729
495
  return padded + (text ? ` ${divider} ${text}` : ` ${divider}`);
730
496
  });
731
497
  }
498
+ /** What a person reads for a model: its display name when the provider has one (Andorra), else the id. */
499
+ // Model names are published only for the hosted Andorra provider, whose saved id is lower case;
500
+ // every other provider is shown by the id the user gave it.
501
+ providerText(provider) {
502
+ const names = this.status.modelNames;
503
+ return names && Object.hasOwn(names, provider) ? 'Andorra' : provider;
504
+ }
505
+ modelText(provider, model) {
506
+ const names = this.status.modelNames;
507
+ const own = names && Object.hasOwn(names, provider) ? names[provider] : undefined;
508
+ const name = own && Object.hasOwn(own, model) ? own[model] : undefined;
509
+ return typeof name === 'string' && name ? name : model;
510
+ }
732
511
  /**
733
- * The model currently answering, as its footer label plus the thinking effort and context window
734
- * that belong to it.
735
- *
736
- * While a graph node is active this names the node the user is watching - the one whose
737
- * requests the speed readout follows, or the first-started one when no speed identity is
738
- * named - followed by the provider and model that node actually resolved and by the effort
739
- * and window of that same resolution, so the whole line describes one model. With no active
740
- * node it is the session's own selection, and no node is named for an idle prompt or for a
741
- * plain run that never started a graph node.
512
+ * The footer's Andorra usage segment, while an Andorra model is in play: the selected model, the model of the node
513
+ * answering, or an agent node of the shown graph resolves to an Andorra provider (a node without one runs the selected model).
514
+ * `forms` lists the texts to try, longest first; the footer shows the first that fits.
742
515
  */
516
+ andorraSegment() {
517
+ const usage = this.status.andorraUsage;
518
+ const andorra = new Set(this.status.andorraProviders ?? []);
519
+ if (!usage || andorra.size === 0)
520
+ return undefined;
521
+ const active = this.displayNode();
522
+ const inPlay = andorra.has(this.status.provider) || (active?.provider !== undefined && andorra.has(active.provider))
523
+ || Object.values(this.status.graph?.nodes ?? {}).some(node => node.type === 'agent' && node.provider !== undefined && andorra.has(node.provider));
524
+ if (!inPlay)
525
+ return undefined;
526
+ if (usage.kind === 'not-available')
527
+ return { forms: ['Andorra: Not available', 'Andorra n/a'], color: FAINT };
528
+ const tone = usageTone(usage.usedPercent);
529
+ return { forms: [`Andorra ${usage.usedPercent}%`], color: tone === 'full' ? STATUS.error : tone === 'warn' ? STATUS.warn : GRAY };
530
+ }
743
531
  activeModel() {
744
532
  const node = this.displayNode();
745
533
  if (!node)
746
- return { label: oneLine(`${this.status.provider} / ${this.status.model}`), reasoningEffort: this.status.reasoningEffort, contextWindow: this.status.contextWindow };
534
+ return { label: oneLine(`${this.providerText(this.status.provider)} / ${this.modelText(this.status.provider, this.status.model)}`), reasoningEffort: this.status.reasoningEffort, contextWindow: this.status.contextWindow };
747
535
  const more = this.activeNodes.size > 1 ? ` +${this.activeNodes.size - 1} more` : '';
748
- // The row names the copy the readout follows, so it names that copy's resolution too: two
749
- // copies of one node can run different profiles, and the last announcement is not the model
750
- // generating now.
751
536
  const perCopy = this.activeSpeedCopy !== undefined ? node.copiesResolved?.get(this.activeSpeedCopy) : undefined;
752
537
  const provider = perCopy?.provider ?? node.provider ?? this.status.provider;
753
538
  const model = perCopy?.model ?? node.model ?? this.status.model;
754
- // The whole line describes one resolution: when the followed copy announced its own, that one
755
- // answers for the effort and the window too, not the node's last announcement from a sibling.
756
539
  const resolved = perCopy?.resolved ?? node.resolved;
757
540
  return {
758
- label: oneLine(`${node.name}${more} · ${provider} / ${model}`),
541
+ label: oneLine(`${node.name}${more} · ${this.providerText(provider)} / ${this.modelText(provider, model)}`),
759
542
  reasoningEffort: resolved ? resolved.reasoningEffort : this.status.reasoningEffort,
760
543
  contextWindow: resolved ? resolved.contextWindow : this.status.contextWindow,
761
544
  };
762
545
  }
763
546
  started = false;
547
+ releaseWarnings;
764
548
  closed = false;
765
549
  wasRaw = false;
766
550
  wasPaused = false;
@@ -775,47 +559,22 @@ export class TerminalUI extends EventEmitter {
775
559
  todoOffset = 0;
776
560
  todoPageSize = 0;
777
561
  scroll = 0;
778
- /** Whether a run is streaming. */
779
562
  runActive = false;
780
- /**
781
- * The drag selection over the drawn frame, in screen cells.
782
- *
783
- * The app holds mouse reporting for the whole session so the wheel arrives as a wheel report
784
- * and never as the Up/Down bytes that recall input history. Holding the mouse takes the drag
785
- * away from the terminal, so the app draws the selection itself and copies it on release.
786
- */
787
563
  selection;
788
- /** The last left press, kept to recognize a double-click on the same cell. */
789
564
  lastPress;
790
- /** The frame as composed, before the selection highlight is laid over it. */
791
565
  frame = [];
792
- /**
793
- * Live reasoning preview state. `thinkingActive` marks a stream in progress; the text
794
- * is the bounded tail the preview renders from.
795
- */
796
566
  thinking = '';
797
567
  thinkingActive = false;
798
- /** The preview opens expanded on every stream; Ctrl+Y collapses the current one. */
799
568
  thinkingExpanded = true;
800
569
  expandedPromptIds = new Set();
801
- /** Prompts the reader explicitly collapsed; an explicit toggle wins over Ctrl+O (see promptExpanded). */
802
570
  collapsedPromptIds = new Set();
803
- /** Every prompt box the transcript currently holds, so Ctrl+O can invert each one on screen. */
804
571
  promptBoxIds = new Set();
805
572
  expandedPromptVisible = false;
806
573
  nextPromptId = 1;
807
574
  thinkingPaintedAt = 0;
808
575
  thinkingFlush;
809
- /**
810
- * The rows currently on screen, so a repaint can rewrite only what changed.
811
- *
812
- * See {@link writeFrame}: a terminal drops an in-progress drag selection when the app
813
- * rewrites the cells under it, and a run repaints eight times a second for its animation.
814
- */
815
576
  drawn = [];
816
- /** Terminal size `drawn` was produced at; a resize invalidates the comparison. */
817
577
  drawnSize = '';
818
- /** The caret sequence last emitted, so an unmoved caret costs no extra write. */
819
578
  drawnCursor = '';
820
579
  history = [];
821
580
  historyIndex = 0;
@@ -823,15 +582,6 @@ export class TerminalUI extends EventEmitter {
823
582
  completion;
824
583
  dismissedCompletion;
825
584
  incoming = '';
826
- /**
827
- * Raw bytes not yet decoded to `incoming`.
828
- *
829
- * Legacy mouse reports are framed here, on bytes, before UTF-8 decoding: their payload
830
- * is three value-plus-32 bytes that the decoder would buffer while an incomplete
831
- * sequence (column 192, row 128 ends in E0 A0) and collapse when the pair forms a
832
- * valid one (column 162, row 128 encodes as C2 A0), so no string-domain measurement
833
- * can see a report in time without risking the keystroke that follows it.
834
- */
835
585
  rawIncoming = Buffer.alloc(0);
836
586
  rawTimer;
837
587
  pasting = false;
@@ -844,36 +594,18 @@ export class TerminalUI extends EventEmitter {
844
594
  plainQuestion;
845
595
  modal;
846
596
  modalInput = false;
847
- /**
848
- * The last selection screen that was answered.
849
- *
850
- * Setup closes a selection screen and then asks for a value, which used to leave the home
851
- * card where the list had been: the reader lost both the list and the entry it led to the
852
- * moment they started typing. The card is kept here so a typed field can be answered with
853
- * the list still on screen (see selectionCard).
854
- */
855
597
  lastSelection;
856
598
  escapeTimer;
857
599
  workingTimer;
858
- /** The panel's one-second age clock; see render(). */
859
600
  panelTimer;
860
601
  workingSince;
861
602
  workingElapsed = 0;
862
- /**
863
- * Whether the composer accepts input while a run is active.
864
- *
865
- * Enabled for the duration of an interactive run so the user can steer it. Text
866
- * submitted in this mode is queued rather than resolved as a question answer.
867
- */
868
603
  steering = false;
869
604
  runInputHandler;
870
605
  localCommandHandler;
871
606
  commandInput = false;
872
- /** Handle active commands and resumed direction synchronously; true consumes the input. */
873
607
  setRunInputHandler(handler) { this.runInputHandler = handler; }
874
- /** Observe slash commands consumed by the view without submitting them to the run. */
875
608
  setLocalCommandHandler(handler) { this.localCommandHandler = handler; }
876
- /** Settle the current approval after an explicit session permission change. */
877
609
  resolveQuestion(value) {
878
610
  const pending = this.pending;
879
611
  if (!pending)
@@ -882,14 +614,12 @@ export class TerminalUI extends EventEmitter {
882
614
  pending.resolve(value);
883
615
  this.scheduleRender();
884
616
  }
885
- /** Submit from the browser only while the terminal is accepting a conversation prompt. */
886
617
  acceptConversationPrompt(value) {
887
618
  if (!this.pending?.conversationPrompt || this.modal)
888
619
  return false;
889
620
  this.resolveQuestion(value);
890
621
  return true;
891
622
  }
892
- /** Current runtime question for connected GUI surfaces. Conversation prompts stay in the composer. */
893
623
  browserPendingIdentity;
894
624
  browserQuestionNumber = 0;
895
625
  browserQuestion() {
@@ -904,40 +634,15 @@ export class TerminalUI extends EventEmitter {
904
634
  return { id: `terminal-${this.browserQuestionNumber}`, kind: pending.kind, question, approvalDetailsRequired: pending.kind === 'approval', approvalDetails: pending.approvalDetails, choices: pending.choices?.map(item => ({ id: item.id, label: item.label })) };
905
635
  }
906
636
  steered = [];
907
- /**
908
- * Attachments queued in the composer draft — large pastes spooled to text, dropped file
909
- * paths, clipboard images. Each sits in the draft as an inline token (its `marker` code
910
- * point), drawn as a bold label and edited as one character. They ride the next submitted
911
- * task (or the next queued steer) and are drained by the CLI, mirroring how `steered` is
912
- * drained at turn boundaries.
913
- */
914
637
  attachments = [];
915
- /** The skills the `/` popup offers after the built-in commands, with the description it shows. */
916
638
  skillCommands = [];
917
- /** The command the skill chip in the draft stands for, while one is there. */
918
639
  skillChip;
919
640
  attachmentSeq = 0;
920
- /**
921
- * Generation of the composer's attachment surface. Advanced by every draft clear and steer
922
- * submission: an asynchronous clipboard probe that started before one of those lands nowhere,
923
- * because the composer it was reading for is gone (steering keeps the same owner all run).
924
- */
925
641
  clipboardProbe = 0;
926
642
  clipboardImageProbe;
927
643
  clipboardTextWriter;
928
- /**
929
- * Where the composer's Shift+Arrow selection started; it runs from here to the cursor.
930
- * `selectionValue` is the draft it was made in: replacing the draft (a submission, history
931
- * recall, a completion) swaps the array, which drops the selection without bookkeeping.
932
- */
933
644
  selectionAnchor;
934
645
  selectionValue;
935
- /**
936
- * A half-typed steer parked while a question temporarily takes the composer.
937
- *
938
- * Questions and steering share `value`; without this a partially typed steer would be
939
- * wiped the moment the runtime asks for an approval or clarification.
940
- */
941
646
  steerDraft;
942
647
  steerCursor = 0;
943
648
  constructor(options) {
@@ -964,38 +669,27 @@ export class TerminalUI extends EventEmitter {
964
669
  this.input.setRawMode?.(true);
965
670
  this.input.ref?.();
966
671
  this.started = true;
672
+ if (this.output.isTTY)
673
+ this.releaseWarnings = holdWarnings();
967
674
  this.input.on('data', this.onData);
968
675
  this.input.on('end', this.onEnd);
969
676
  this.output.on('resize', this.onResize);
970
677
  this.input.resume();
971
- // The app holds mouse reporting (?1002h/?1006h) from here to close(), so the wheel always
972
- // arrives as a wheel report and scrolls the transcript: at the resting prompt, while a run
973
- // streams and on every screen. Leaving the wheel to the terminal is not an option in the
974
- // alternate screen. Windows Terminal, VTE and iTerm2 turn an uncaptured wheel into Up/Down
975
- // sequences byte-identical to the arrow keys (alternate scroll mode, ?1007), which either
976
- // recalls input history on every wheel tick or forces the arrows to give history up. With
977
- // the mouse held, Up/Down stay purely keyboard, and ?1007 is switched off so a terminal
978
- // that ignores the capture still sends nothing for the wheel. Button-event tracking (?1002)
979
- // also reports the drag, which the app draws and copies itself (see `mouse`); the
980
- // terminal's own selection stays reachable through its bypass, Shift+drag in most. Legacy
981
- // ESC[M reports from terminals without the SGR encoding are framed in `consumeRaw`.
982
- // writeFrame only rewrites rows that changed. Entering the alternate screen blanks it, so
983
- // nothing drawn before is still there to diff.
984
678
  this.drawn = [];
985
679
  this.drawnSize = '';
986
680
  this.drawnCursor = '';
987
- // The alternate screen is left before it is entered. A session that died without closing
988
- // (a dropped SSH connection) leaves the tab in the alternate screen, and Windows Terminal
989
- // sizes a second alternate buffer from its main viewport, whose resize it defers until the
990
- // alternate screen is left: after the window grew, every row of a frame drawn for the real
991
- // width wrapped on the stale, narrower grid. Leaving first applies that deferred resize;
992
- // where the main screen is already active the reset changes nothing.
993
- this.output.write('\x1b[?1049l\x1b[?1049h\x1b[?2004h\x1b[?25l\x1b[?1007l\x1b[?1002h\x1b[?1006h');
681
+ // A stale alternate screen (a session that died without closing) is left before ours is
682
+ // entered, so Windows Terminal applies the resize it deferred. Leaving restores the saved
683
+ // cursor even on the main screen, where nothing was saved yet and the cursor goes home,
684
+ // and entering then saves that home position for the exit to restore: the shell prompt came
685
+ // back on row 1 over the old screen. Saving the cursor first (ESC 7) makes the leave a no-op.
686
+ this.output.write('\x1b7\x1b[?1049l\x1b[?1049h\x1b[?2004h\x1b[?25l\x1b[?1007l\x1b[?1002h\x1b[?1006h');
994
687
  this.render();
995
688
  }
996
689
  question(prompt = '', options = {}) {
997
690
  if (this.closed)
998
691
  return Promise.reject(new Error('Terminal is closed'));
692
+ this.yieldScreen();
999
693
  if (this.pending)
1000
694
  return Promise.reject(new Error('A terminal question is already active'));
1001
695
  if (this.modal)
@@ -1004,8 +698,6 @@ export class TerminalUI extends EventEmitter {
1004
698
  return Promise.reject(new DOMException('Question aborted', 'AbortError'));
1005
699
  if (!this.started)
1006
700
  this.start();
1007
- // A question (approval or clarification) can interrupt a run while a steer is half typed.
1008
- // Park it, so taking the composer for the question does not silently discard the draft.
1009
701
  if (this.steering && this.value.length) {
1010
702
  this.steerDraft = this.parkedDraft();
1011
703
  this.steerCursor = this.cursor;
@@ -1032,6 +724,7 @@ export class TerminalUI extends EventEmitter {
1032
724
  async chooseQuestion(prompt, items, options = {}) {
1033
725
  if (!items.length || items.some(item => !item.id))
1034
726
  throw new Error('Question choices require nonempty IDs');
727
+ this.yieldScreen();
1035
728
  if (this.pending || this.modal)
1036
729
  throw new Error('A terminal question or screen is already active');
1037
730
  const displayedPrompt = prompt === 'Choose an answer' ? this.dashboardNotices.at(-1) ?? prompt : prompt;
@@ -1039,8 +732,6 @@ export class TerminalUI extends EventEmitter {
1039
732
  this.print(prompt);
1040
733
  const answer = this.question('↑↓ Choose · Enter confirm · Esc cancel', { ...options, history: false });
1041
734
  const pending = this.pending;
1042
- // Keep tool identity alongside its arguments so the browser snapshot sanitizer
1043
- // can apply tool-specific privacy rules before any details leave the CLI.
1044
735
  if (pending && options.kind === 'approval')
1045
736
  pending.approvalDetails = options.approvalDetails;
1046
737
  if (pending) {
@@ -1052,13 +743,38 @@ export class TerminalUI extends EventEmitter {
1052
743
  this.scheduleRender();
1053
744
  return (await answer) || undefined;
1054
745
  }
746
+ yieldScreen() {
747
+ if (this.modal?.yieldToQuestions)
748
+ this.finishModal(undefined, new DOMException('Screen yielded to a question', 'AbortError'));
749
+ }
1055
750
  select(title, items, options = {}) {
1056
751
  let selected = Math.max(0, items.findIndex(item => item.id === options.selectedId));
1057
752
  while (items[selected]?.separator)
1058
753
  selected++;
1059
- return this.openModal({ kind: 'select', title, items: [...items], lines: [], selected, selectedId: options.selectedId, ...options });
754
+ const { refresh, ...rest } = options;
755
+ const opened = this.openModal({ kind: 'select', title, items: [...items], lines: [], selected, selectedId: options.selectedId, ...rest });
756
+ if (!refresh)
757
+ return opened;
758
+ const modal = this.modal;
759
+ const stop = refresh(next => {
760
+ // Only while this very select is the screen on top: a sub-screen opened from it is never redrawn under.
761
+ if (!modal || this.modal !== modal)
762
+ return;
763
+ const highlighted = modal.items[modal.selected]?.id;
764
+ modal.items = [...next];
765
+ const kept = modal.items.findIndex(item => item.id === highlighted && !item.separator);
766
+ modal.selected = kept >= 0 ? kept : Math.max(0, Math.min(modal.selected, modal.items.length - 1));
767
+ if (kept < 0)
768
+ this.moveSelection(modal, 0);
769
+ this.scheduleRender();
770
+ });
771
+ const done = () => { try {
772
+ stop();
773
+ }
774
+ catch { /* the caller's cleanup never breaks the screen */ } };
775
+ opened.then(done, done);
776
+ return opened;
1060
777
  }
1061
- /** Move the select highlight, carrying the movement past separator rows: separators are visual line breaks, never choices. */
1062
778
  moveSelection(modal, movement, homeEnd) {
1063
779
  const selectable = (index) => index >= 0 && index < modal.items.length && !modal.items[index].separator;
1064
780
  let target = homeEnd === 'home' ? 0 : homeEnd === 'end' ? modal.items.length - 1 : Math.max(0, Math.min(modal.items.length - 1, modal.selected + movement));
@@ -1115,8 +831,6 @@ export class TerminalUI extends EventEmitter {
1115
831
  if (!modal)
1116
832
  return;
1117
833
  this.modal = undefined;
1118
- // Only a selection that was actually made is worth docking: a cancelled list leads to no
1119
- // field, and the caller returns to the conversation instead.
1120
834
  if (modal.kind === 'select' && !error && typeof value === 'string')
1121
835
  this.lastSelection = { title: modal.title, description: modal.description, items: modal.items.map(item => ({ ...item })), selected: modal.selected };
1122
836
  this.updateWorkingClock();
@@ -1146,31 +860,13 @@ export class TerminalUI extends EventEmitter {
1146
860
  this.transcript.append(entry);
1147
861
  this.scheduleRender();
1148
862
  }
1149
- /**
1150
- * Echo submitted text as its own bordered box.
1151
- *
1152
- * The box mirrors the live input field's frame and color so the text reads as the
1153
- * same surface the user typed into, rather than a `You >` transcript prefix. The
1154
- * frame itself identifies the text as user input, so a submitted prompt is left
1155
- * untitled; only a surface that is genuinely something other than a task prompt —
1156
- * a clarification answer — passes a title. The frame is sized to the terminal at
1157
- * echo time; a later resize re-wraps the body but keeps the original box, which is
1158
- * an accepted trade for not rewriting history on resize. The finished box is drawn right-aligned against the transcript's right margin (see wrapTranscript), so a submission reads as the user's speech bubble and re-aligns when the window is resized.
1159
- * @param text - the submitted text to echo.
1160
- * @param title - optional top-border label; omitted draws a plain frame.
1161
- */
1162
863
  printPrompt(text, title = '') {
1163
- // The width the transcript will show this box at, not the width of the surface submitting it.
1164
864
  const width = Math.max(12, this.transcriptColumns()) - 4;
1165
- // Reserve the four frame characters ('│ ', ' │') plus the two-space transcript indent,
1166
- // so a body row can never exceed the width the render pass wraps at.
1167
865
  const bodyWidth = Math.max(1, width - 4);
1168
866
  const titleBudget = Math.max(0, width - 4);
1169
867
  const label = oneLine(title).trim();
1170
868
  const frameTitle = label ? clip(` ${label} `, titleBudget) : '';
1171
869
  const rows = clean(String(text)).slice(0, 100_000).split('\n').flatMap(line => wrap(line, bodyWidth));
1172
- // Expansion preserves the existing bounded-history contract: the model still receives the
1173
- // full submitted input, while the transcript stores at most MAX_PROMPT_ROWS rendered rows.
1174
870
  const omitted = rows.length - MAX_PROMPT_ROWS;
1175
871
  const marker = omitted > 0 ? wrap(`… ${omitted + 1} more rows omitted`, bodyWidth) : [];
1176
872
  const fullBody = omitted > 0 ? [...rows.slice(0, MAX_PROMPT_ROWS - marker.length), ...marker] : rows;
@@ -1183,13 +879,9 @@ export class TerminalUI extends EventEmitter {
1183
879
  return [top, ...body.map(line => '│ ' + pad(line, inner) + ' │'), bottom].join('\n');
1184
880
  };
1185
881
  if (rows.length <= PROMPT_COLLAPSE_AFTER_ROWS) {
1186
- // Positional call, so name the last flag: the echo is the user's speech bubble (alignRight).
1187
882
  this.print(frame(fullBody), undefined, undefined, true, true, true);
1188
883
  return;
1189
884
  }
1190
- // Reserve the entire wrapped disclosure before choosing preview rows. On a narrow terminal
1191
- // the marker itself may need more than six rows; in that case the marker wins and the preview
1192
- // shrinks to zero rather than hiding the actionable "Ctrl+O to expand" text.
1193
885
  let previewRows = Math.max(0, PROMPT_COLLAPSED_BODY_ROWS - 1);
1194
886
  let disclosure = [];
1195
887
  for (let pass = 0; pass < 3; pass++) {
@@ -1211,15 +903,6 @@ export class TerminalUI extends EventEmitter {
1211
903
  this.transcript.append(entry);
1212
904
  this.scheduleRender();
1213
905
  }
1214
- /**
1215
- * Stream one reasoning delta into the live preview line.
1216
- *
1217
- * The preview always shows the tail of what has arrived, so each call only has to grow
1218
- * the bounded buffer; rendering stays on the working clock's repaint cadence, with a
1219
- * small throttle so a token firehose cannot trigger a full-frame render per network
1220
- * chunk.
1221
- * @param delta - the reasoning fragment that just arrived; empty fragments are ignored.
1222
- */
1223
906
  appendThinking(delta) {
1224
907
  if (this.closed || !delta)
1225
908
  return;
@@ -1235,14 +918,6 @@ export class TerminalUI extends EventEmitter {
1235
918
  this.thinkingFlush.unref?.();
1236
919
  }
1237
920
  }
1238
- /**
1239
- * Wipe the on-screen conversation so the display reads as a freshly started session.
1240
- *
1241
- * Only the transcript entries, the scroll position and the live reasoning preview are dropped:
1242
- * the welcome card is rebuilt as the scrollback prefix on the next render, so the frame returns
1243
- * to its startup shape without re-emitting a banner or a terminal clear escape. The composer's
1244
- * prompt-recall history is deliberately kept — it is input history, not chat output.
1245
- */
1246
921
  clearConversation() {
1247
922
  if (this.closed)
1248
923
  return;
@@ -1252,17 +927,12 @@ export class TerminalUI extends EventEmitter {
1252
927
  this.collapsedPromptIds.clear();
1253
928
  this.promptBoxIds.clear();
1254
929
  this.expandedPromptVisible = false;
1255
- // A cleared conversation abandons its pending attachments with it: they were queued for a
1256
- // task in this conversation, and silently attaching them to the next one would submit files
1257
- // the user never re-chose.
1258
930
  this.attachments = [];
1259
- // The scroll offset is clamped against the transcript, so a stale offset would draw an empty
1260
- // or misplaced window over the cleared list instead of the live tail.
1261
931
  this.scroll = 0;
1262
932
  this.clearThinking();
933
+ this.subagents.clear();
1263
934
  this.scheduleRender();
1264
935
  }
1265
- /** Retract the preview: the stream ended, was retried, or the whole run finished. */
1266
936
  clearThinking() {
1267
937
  if (this.thinkingFlush) {
1268
938
  clearTimeout(this.thinkingFlush);
@@ -1276,11 +946,6 @@ export class TerminalUI extends EventEmitter {
1276
946
  this.scheduleRender();
1277
947
  }
1278
948
  setStatus(partial) {
1279
- // The CLI reloads and re-validates the selected graph before every run, handing setStatus
1280
- // a fresh object for an unchanged selection. Display bookkeeping treats any new graph
1281
- // object as a change (its node identities repopulate from the run's own events anyway),
1282
- // while the speed readout identifies the graph by id and revision: a reload of the same
1283
- // graph keeps its average, a genuinely different or re-edited graph starts over.
1284
949
  const graphIdentity = (graph) => graph === undefined ? undefined : `${graph.id}@${graph.revision}`;
1285
950
  const modelChanged = (partial.provider !== undefined && partial.provider !== this.status.provider)
1286
951
  || (partial.model !== undefined && partial.model !== this.status.model)
@@ -1293,26 +958,17 @@ export class TerminalUI extends EventEmitter {
1293
958
  this.dashboardGraphOffset = 0;
1294
959
  }
1295
960
  if (modelChanged || graphChanged) {
1296
- // The nodes now decode under a different model or inference configuration, so every
1297
- // accumulated average describes something the footer no longer shows.
1298
961
  this.speedMeters.clear();
1299
962
  this.speedInvocations.clear();
1300
963
  this.activeSpeedNode = undefined;
1301
964
  this.activeSpeedCopy = undefined;
1302
965
  this.activeSpeedKey = undefined;
1303
966
  }
1304
- // A trail of node ids means nothing in another graph: the panel's zoom would focus an id
1305
- // that does not exist there and count visits against the new graph's total, so a changed
1306
- // selection starts it over - including the position a stopped run ended on, which is a node
1307
- // id from that same graph. Reloading the same graph (same id and revision) keeps both.
1308
967
  if (graphChanged) {
1309
968
  this.visitedNodes.clear();
1310
969
  this.stoppedNode = undefined;
1311
970
  }
1312
971
  this.status = { ...this.status, ...partial, ...(partial.activity !== undefined && partial.backgroundActivity === undefined ? { backgroundActivity: false } : {}) };
1313
- // A run ending returns the footer to idle but does not retire the speed readout: each
1314
- // node's cumulative average keeps describing the node that just ran, and it is the
1315
- // baseline the next run of that node continues from.
1316
972
  if (partial.activity === 'Ready') {
1317
973
  this.activeNodes.clear();
1318
974
  this.toolClock.stop();
@@ -1322,71 +978,32 @@ export class TerminalUI extends EventEmitter {
1322
978
  this.updateWorkingClock();
1323
979
  this.scheduleRender();
1324
980
  }
1325
- /**
1326
- * Feed the footer's token-speed readout with one finished model request.
1327
- *
1328
- * Providers report a request's tokens only when it completes. A streamed request carries its
1329
- * measured decode window, which is the time the tokens are credited with; otherwise the
1330
- * number is measured over the window opened by the call's `agent.iteration.started` event
1331
- * rather than credited to the instant it arrived, which would leave the readout no duration
1332
- * to divide by. The completion also replaces the live estimate {@link noteStreamedOutput}
1333
- * kept for the same request. `invocationId` - the id the executor stamps on both the start
1334
- * event and the usage delta - selects that window and, through the marker that opened it,
1335
- * the node whose average the measurement belongs to, so a completion from a concurrent request cannot
1336
- * borrow another request's window or another node's average. The measurement folds into
1337
- * that node's cumulative average, which only a changed selection or a changed model
1338
- * resolution for the node resets. Deltas that carry no tokens (the adapter's per-attempt
1339
- * request counting, retries included) are not completions and are passed through to the
1340
- * meter, which ignores them for window pairing. A final delta without tokens - a provider
1341
- * that omits usage - still closes its request's window but leaves the average untouched:
1342
- * it describes the requests that did report.
1343
- * @param tokens - output tokens the provider reported for that single request.
1344
- * @param invocationId - request identity from the executor, when one is known.
1345
- * @param final - true when the delta closes its request, per the runtime's origin flag.
1346
- * @param decodeMs - the adapter's measured decode window for the request, when it has one.
1347
- */
1348
981
  noteGeneratedTokens(tokens, invocationId, final, decodeMs) {
1349
982
  const key = this.speedRoute(invocationId);
1350
- // Attempt bookkeeping (zero tokens, not final) keeps its routing entry, so the completion
1351
- // that follows the retries still finds its meter; a completion consumes the entry.
1352
983
  if (invocationId !== undefined && (tokens > 0 || final))
1353
984
  this.speedInvocations.delete(invocationId);
1354
985
  this.ensureSpeedMeter(key).meter.report(tokens, invocationId, final, decodeMs);
1355
986
  this.scheduleRender();
1356
987
  }
1357
- /**
1358
- * Feed the footer's token-speed readout with a fragment a request is still streaming.
1359
- *
1360
- * A thinking model can stream for minutes before its usage arrives, and a readout that moved
1361
- * only on completions sat on the previous number the whole time. The fragment is estimated
1362
- * into the same meter the completion will report to, and repaints only when the number on
1363
- * screen changes - a stream from a node the footer does not follow costs nothing.
1364
- * @param text - the streamed reasoning or answer fragment.
1365
- * @param invocationId - request identity from the executor, when one is known.
1366
- */
1367
988
  noteStreamedOutput(text, invocationId) {
1368
989
  const before = this.displayRate();
1369
990
  this.ensureSpeedMeter(this.speedRoute(invocationId)).meter.stream(text, invocationId);
1370
991
  if (this.displayRate() !== before)
1371
992
  this.scheduleRender();
1372
993
  }
1373
- /** Drop a request's live estimate: the attempt failed, is about to be retried, or was aborted. */
1374
994
  noteStreamEnded(invocationId) {
1375
995
  const before = this.displayRate();
1376
996
  this.speedMeters.get(this.speedRoute(invocationId))?.meter.endStream(invocationId);
1377
997
  if (this.displayRate() !== before)
1378
998
  this.scheduleRender();
1379
999
  }
1380
- /** The meter a request's measurements belong to: the one its start marker named, else the followed one. */
1381
1000
  speedRoute(invocationId) {
1382
1001
  const routed = invocationId !== undefined ? this.speedInvocations.get(invocationId) : undefined;
1383
1002
  return routed ?? this.activeSpeedKey ?? 'engineer';
1384
1003
  }
1385
- /** The meter key for a node's requests: parallel copies each keep their own meter. */
1386
1004
  speedKey(nodeId, copy) {
1387
1005
  return copy === undefined ? nodeId : `${nodeId}#copy${copy}`;
1388
1006
  }
1389
- /** The meter's speed entry, created on first sight so no measurement is ever dropped. */
1390
1007
  ensureSpeedMeter(key) {
1391
1008
  let entry = this.speedMeters.get(key);
1392
1009
  if (!entry) {
@@ -1395,14 +1012,6 @@ export class TerminalUI extends EventEmitter {
1395
1012
  }
1396
1013
  return entry;
1397
1014
  }
1398
- /**
1399
- * Stamp a meter with the resolution its generating identity announced.
1400
- *
1401
- * A resolution different from the one the meter already measured under rebuilds the meter:
1402
- * its average described the previous model or reasoning effort, which is exactly the
1403
- * whole-agent-fallback case. Learning the identity for a meter that had none (the session
1404
- * event merely arrives before the meter was stamped) never discards measurements.
1405
- */
1406
1015
  stampSpeedMeter(key, provider, model, reasoningEffort) {
1407
1016
  const entry = this.ensureSpeedMeter(key);
1408
1017
  const changed = (provider !== undefined && entry.provider !== undefined && provider !== entry.provider)
@@ -1419,34 +1028,11 @@ export class TerminalUI extends EventEmitter {
1419
1028
  entry.reasoningEffort = reasoningEffort;
1420
1029
  }
1421
1030
  }
1422
- /**
1423
- * The footer's token speed: the cumulative average of the generating identity the readout
1424
- * currently follows, unchanged between completions.
1425
- *
1426
- * Exposed for callers and tests that need the exact number the readout is based on. The
1427
- * footer draws {@link displayRate}, which adds the model-identity check.
1428
- */
1429
1031
  tokenSpeed() { return this.activeSpeedKey === undefined ? 0 : this.speedMeters.get(this.activeSpeedKey)?.meter.rate() ?? 0; }
1430
- /**
1431
- * The node whose resolution the model row and the speed readout describe.
1432
- *
1433
- * This is the identity the readout follows - the most recent node or parallel copy to open
1434
- * a model call - so the row names the same node whose average is drawn, not whichever node
1435
- * happened to start first. Without a followed identity it falls back to the first active
1436
- * node, and with no active node at all the session's own selection answers.
1437
- */
1438
1032
  displayNode() {
1439
1033
  return (this.activeSpeedNode !== undefined ? this.activeNodes.get(this.activeSpeedNode) : undefined)
1440
1034
  ?? [...this.activeNodes.values()][0];
1441
1035
  }
1442
- /**
1443
- * The speed the footer shows: the followed identity's cumulative average, but only while
1444
- * the model row names the resolution the average was measured under.
1445
- *
1446
- * After a run ends the row reverts to the session's own selection, so an average measured
1447
- * on a node with a provider, model or effort override would otherwise sit beside a
1448
- * different resolution's name; the segment disappears instead of misdescribing it.
1449
- */
1450
1036
  displayRate() {
1451
1037
  const entry = this.activeSpeedKey === undefined ? undefined : this.speedMeters.get(this.activeSpeedKey);
1452
1038
  if (!entry)
@@ -1455,8 +1041,6 @@ export class TerminalUI extends EventEmitter {
1455
1041
  const perCopy = this.activeSpeedCopy !== undefined ? node?.copiesResolved?.get(this.activeSpeedCopy) : undefined;
1456
1042
  const provider = perCopy?.provider ?? node?.provider ?? this.status.provider;
1457
1043
  const model = perCopy?.model ?? node?.model ?? this.status.model;
1458
- // The followed copy's own effort comes first: comparing the meter's reading against a
1459
- // sibling's effort suppressed a rate that was measured on this copy's own resolution.
1460
1044
  const effort = perCopy?.resolved?.reasoningEffort ?? node?.resolved?.reasoningEffort ?? this.status.reasoningEffort;
1461
1045
  if ((entry.provider !== undefined && entry.provider !== provider)
1462
1046
  || (entry.model !== undefined && entry.model !== model)
@@ -1464,22 +1048,10 @@ export class TerminalUI extends EventEmitter {
1464
1048
  return 0;
1465
1049
  return entry.meter.rate();
1466
1050
  }
1467
- /**
1468
- * Let the composer accept steering input for the duration of a run.
1469
- *
1470
- * Called with `true` when an interactive run starts and `false` when it ends, so the
1471
- * normal question flow owns the composer outside a run.
1472
- * @param enabled - whether submitted text should be queued as a steer.
1473
- * @returns when disabling, any queued steers that can no longer be injected. The
1474
- * executor's last poll happens before finalization, so a steer submitted in that
1475
- * window is visibly accepted but has nowhere to go; returning it lets the caller say
1476
- * so instead of dropping it silently.
1477
- */
1478
1051
  setSteering(enabled) {
1479
1052
  if (this.steering === enabled)
1480
1053
  return [];
1481
1054
  this.steering = enabled;
1482
- // A parked draft belongs to the run that parked it.
1483
1055
  if (!enabled) {
1484
1056
  this.steerDraft = undefined;
1485
1057
  this.steerCursor = 0;
@@ -1487,49 +1059,23 @@ export class TerminalUI extends EventEmitter {
1487
1059
  this.scheduleRender();
1488
1060
  if (enabled)
1489
1061
  return [];
1490
- // A steer that reached the executor's finalization window has nowhere to go: its text is
1491
- // returned for the caller to report, and its chips return to the queue so they can ride the
1492
- // next task. The queue itself survives too — a paste is draft material like typed text.
1493
1062
  const undelivered = this.takeSteeringTurns();
1494
1063
  for (const turn of undelivered)
1495
1064
  for (const pending of turn.attachments)
1496
1065
  this.addAttachment(pending);
1497
1066
  return undelivered.map(turn => turn.text);
1498
1067
  }
1499
- /** The surface that currently owns the composer, if any. */
1500
1068
  composerOwner() {
1501
1069
  return this.pending ?? (this.steering ? STEERING_OWNER : undefined);
1502
1070
  }
1503
- /**
1504
- * Whether a captured composer owner is still the owner.
1505
- *
1506
- * Deferred input (a paste, or an Enter held back by the input-burst window) is only
1507
- * delivered when the surface that armed it still owns the composer. Steering is an
1508
- * owner too, so a pasted steer must not be discarded just because no question is
1509
- * pending.
1510
- * @param token - the owner captured when the input arrived.
1511
- * @returns whether that owner may still accept the deferred input.
1512
- */
1513
1071
  ownsComposer(token) {
1514
- // Object identity against a module-private sentinel, compared by reference and never by
1515
- // value. A static analyser flags `===` near the word "token" as a secret comparison; there
1516
- // is no secret here -- `STEERING_OWNER` is this module's own marker object and `token` is
1517
- // never a string, so no constant-time byte comparison applies or would mean anything.
1518
1072
  if (token === STEERING_OWNER)
1519
1073
  return this.steering && !this.pending;
1520
1074
  return token !== undefined && token === this.pending;
1521
1075
  }
1522
- /**
1523
- * Take every queued steer message, without blocking.
1524
- *
1525
- * The hardened executor polls this at turn boundaries; returning immediately with an
1526
- * empty array is what lets a run continue when the user has typed nothing.
1527
- * @returns the queued messages, oldest first.
1528
- */
1529
1076
  takeSteering() {
1530
1077
  return this.takeSteeringTurns().map(turn => turn.text);
1531
1078
  }
1532
- /** The queued steers with their attachments, oldest first; each turn is one injected user message. */
1533
1079
  takeSteeringTurns() {
1534
1080
  const queued = this.steered;
1535
1081
  this.steered = [];
@@ -1537,20 +1083,34 @@ export class TerminalUI extends EventEmitter {
1537
1083
  }
1538
1084
  setTodos(todos) { this.todos = todos.map(todo => ({ ...todo, text: oneLine(todo.text) })); this.todoOffset = Math.min(this.todoOffset, Math.max(0, todos.length - 1)); if (!todos.length)
1539
1085
  this.expandedTodos = false; this.scheduleRender(); }
1086
+ agentLines(width, maxRows) {
1087
+ const groups = this.subagents.groups();
1088
+ if (!groups.length || maxRows < 1)
1089
+ return [];
1090
+ const now = this.tokenClock ? this.tokenClock() : Date.now();
1091
+ const all = this.subagents.list();
1092
+ if (this.scroll > 0 || maxRows < 2) {
1093
+ const working = all.filter(entry => entry.status === 'running').length;
1094
+ return [paint(' ' + clip(`Agents ${all.length - working}/${all.length} done${working ? ` · ${working} running` : ''}`, width), GRAY)];
1095
+ }
1096
+ return subagentTreeRows(groups, Math.max(8, Math.min(AGENT_FALLBACK_MAX_COLUMNS, width - 2)), Math.min(AGENT_FALLBACK_MAX_ROWS, maxRows), now)
1097
+ .map(line => ' ' + line.segments.map(segment => paint(segment.text, segment.color ?? GRAY)).join(''));
1098
+ }
1099
+ goalLines(width, maxRows) {
1100
+ const goal = this.status.goal;
1101
+ if (!goal || maxRows < 1 || width < 12)
1102
+ return [];
1103
+ return [clip(`${goal.status === 'met' ? '✓' : '◎'} ${goalStatusLabel(goal)}: ${oneLine(goal.text)}`, width)];
1104
+ }
1540
1105
  todoLines(maxRows) {
1541
1106
  if (!this.todos.length || maxRows < 1)
1542
1107
  return [];
1543
1108
  const done = this.todos.filter(todo => todo.status === 'completed').length;
1544
- // While scrolled back the todo block stays pinned but collapses to one line, so it
1545
- // never competes with the transcript the user is reading. Scrolling to the live tail
1546
- // restores the full list without changing the expand/collapse state.
1547
1109
  if (this.scroll > 0 && !this.expandedTodos) {
1548
1110
  const active = this.todos.find(todo => todo.status === 'in_progress');
1549
1111
  const label = `${done}/${this.todos.length} done${active ? ` · ${active.text}` : ''}`;
1550
1112
  return [`Todo ${label} · ctrl+t to expand`];
1551
1113
  }
1552
- // The expanded form needs a header, at least one item and a summary; the collapsed form
1553
- // above needs only one row, so this guard sits after it rather than hiding both.
1554
1114
  if (maxRows < 3)
1555
1115
  return [];
1556
1116
  const count = Math.min(this.todos.length, this.expandedTodos ? maxRows - 2 : Math.min(5, maxRows - 2));
@@ -1561,17 +1121,6 @@ export class TerminalUI extends EventEmitter {
1561
1121
  const summary = this.expandedTodos && hidden ? `${this.todoOffset + 1}-${this.todoOffset + count}/${this.todos.length} · Page Up/Down · ` : hidden ? `… +${hidden} more ` : '';
1562
1122
  return ['Todo', ...visible.map(todo => ` ${todo.status === 'completed' ? '✓' : todo.status === 'in_progress' ? '●' : '○'} ${todo.text}`), `${summary}(${done} done) · ctrl+t to ${this.expandedTodos ? 'collapse' : 'expand'}`];
1563
1123
  }
1564
- /**
1565
- * Rows for the live reasoning preview, standing in for the plain working line.
1566
- *
1567
- * Collapsed it keeps the latest reasoning on one row and pins elapsed time plus the
1568
- * expand control on the row directly beneath it, so a growing reasoning tail cannot push
1569
- * the control off to the right. Expanded, the default for every new stream, it opens a
1570
- * fixed {@link THINKING_ROWS}-row window on the tail, padded at the top with the marker on
1571
- * the first reasoning row, with the same control row beneath it. `maxRows`
1572
- * is the room the terminal offers once the transcript keeps at least its last row; a
1573
- * one-row budget still shows the reasoning row.
1574
- */
1575
1124
  thinkingLines(width, seconds, maxRows) {
1576
1125
  if (!this.thinkingActive || maxRows < 1)
1577
1126
  return [];
@@ -1588,7 +1137,6 @@ export class TerminalUI extends EventEmitter {
1588
1137
  const first = traceCount - wrapped.length;
1589
1138
  return [...rows.map((row, index) => clip(`${index === first ? '◌ ' : ' '}${row}`, inner)), clip(`◌ ${stamp} · ctrl+y`, inner)];
1590
1139
  }
1591
- /** The last nonempty line of the retained reasoning, flattened for one row. */
1592
1140
  thinkingTail() {
1593
1141
  const rows = this.thinking.split('\n');
1594
1142
  for (let index = rows.length - 1; index >= 0; index--)
@@ -1654,6 +1202,8 @@ export class TerminalUI extends EventEmitter {
1654
1202
  this.output.write('\x1b[?1002l\x1b[?1006l\x1b[?1007h\x1b[?2004l\x1b[?25h\x1b[0m\x1b[?1049l');
1655
1203
  }
1656
1204
  }
1205
+ this.releaseWarnings?.();
1206
+ this.releaseWarnings = undefined;
1657
1207
  this.emit('close');
1658
1208
  }
1659
1209
  finishQuestion() {
@@ -1669,7 +1219,6 @@ export class TerminalUI extends EventEmitter {
1669
1219
  this.pasteQuestion = undefined;
1670
1220
  this.completion = undefined;
1671
1221
  this.dismissedCompletion = undefined;
1672
- // Put back a steer the question interrupted, so the user resumes where they left off.
1673
1222
  if (this.steering && this.steerDraft !== undefined) {
1674
1223
  this.value = this.restoredDraft(this.steerDraft);
1675
1224
  this.cursor = Math.min(this.steerCursor, this.value.length);
@@ -1691,20 +1240,6 @@ export class TerminalUI extends EventEmitter {
1691
1240
  this.consumeRaw();
1692
1241
  this.consumeIncoming();
1693
1242
  };
1694
- /**
1695
- * Frame legacy X10 mouse reports on the raw byte stream before UTF-8 decoding.
1696
- *
1697
- * A terminal with mouse tracking but without the SGR encoding of mode 1006 answers capture
1698
- * with ESC[M plus three raw payload bytes (button, then coordinates, each offset by
1699
- * 32). Those bytes are framed here rather than in the decoded string because decoding
1700
- * buffers an incomplete trailing sequence and collapses a complete pair into one
1701
- * character, so a string-domain match could only see a report late, consuming the
1702
- * keystroke that follows it. A report split across reads holds the buffer for the
1703
- * input burst, the same grace a lone Escape gets; a burst that elapses with an
1704
- * incomplete prefix hands the bytes to the key parser as if they were typed. Inside a
1705
- * bracketed paste the bytes are text, so once the decoded stream opens a paste the
1706
- * remainder is handed over untouched.
1707
- */
1708
1243
  consumeRaw() {
1709
1244
  while (this.rawIncoming.length) {
1710
1245
  const at = this.rawIncoming.indexOf(LEGACY_MOUSE);
@@ -1717,8 +1252,6 @@ export class TerminalUI extends EventEmitter {
1717
1252
  if (at < 0)
1718
1253
  break;
1719
1254
  if (this.pasting) {
1720
- // Only the paste body is text. Bytes after its terminator are framed again, so a
1721
- // report that arrives in the same read as the end of a paste is still a report.
1722
1255
  const closes = this.rawIncoming.indexOf(PASTE_END);
1723
1256
  if (closes < 0) {
1724
1257
  this.feedRaw(this.rawIncoming);
@@ -1737,11 +1270,8 @@ export class TerminalUI extends EventEmitter {
1737
1270
  }
1738
1271
  const button = this.rawIncoming[3] - 32, column = this.rawIncoming[4] - 32, row = this.rawIncoming[5] - 32;
1739
1272
  this.rawIncoming = this.rawIncoming.subarray(6);
1740
- // The legacy encoding has no release flag: a release is reported as button 3.
1741
1273
  this.mouse(button, (button & 3) !== 3 || (button & 64) !== 0, column, row);
1742
1274
  }
1743
- // Nothing report-shaped is pending: decode everything except a suffix that could
1744
- // still grow into a report prefix, which waits for the next chunk or the burst.
1745
1275
  const hold = legacyMousePrefixLength(this.rawIncoming);
1746
1276
  if (this.rawIncoming.length > hold) {
1747
1277
  const head = this.rawIncoming.subarray(0, this.rawIncoming.length - hold);
@@ -1756,11 +1286,6 @@ export class TerminalUI extends EventEmitter {
1756
1286
  armRawTimer() {
1757
1287
  if (this.rawTimer || this.closed)
1758
1288
  return;
1759
- // The burst has already done the lone-Escape disambiguation, so a flush that leaves
1760
- // exactly an ESC resolves it as the Escape key. The surface that received the held
1761
- // bytes is captured the way escapeTimer captures its own: if a load finished and
1762
- // opened a modal during the window, the bytes die with the surface they belonged to
1763
- // instead of closing or typing into the one that replaced it.
1764
1289
  const modal = this.modal, question = this.pending;
1765
1290
  this.rawTimer = setTimeout(() => {
1766
1291
  this.rawTimer = undefined;
@@ -1779,7 +1304,6 @@ export class TerminalUI extends EventEmitter {
1779
1304
  this.consumeIncoming();
1780
1305
  }, INPUT_BURST_MS);
1781
1306
  }
1782
- /** Drain the decoded stream: paste markers, SGR mouse reports and ordinary keys. */
1783
1307
  consumeIncoming() {
1784
1308
  const start = '\x1b[200~', end = '\x1b[201~';
1785
1309
  while (this.incoming) {
@@ -1840,13 +1364,6 @@ export class TerminalUI extends EventEmitter {
1840
1364
  break;
1841
1365
  }
1842
1366
  }
1843
- /**
1844
- * The effective disclosure state of one prompt box.
1845
- *
1846
- * An explicit per-prompt toggle wins over the Ctrl+O default, and Ctrl+O clears those
1847
- * toggles when it is pressed (see onKey), so the keyboard always remains a way out of
1848
- * either state.
1849
- */
1850
1367
  promptExpanded(id) {
1851
1368
  if (this.expandedPromptIds.has(id))
1852
1369
  return true;
@@ -1854,19 +1371,6 @@ export class TerminalUI extends EventEmitter {
1854
1371
  return false;
1855
1372
  return this.expandedTranscript;
1856
1373
  }
1857
- /**
1858
- * Act on one mouse report: the wheel scrolls, and a left drag selects text on the screen.
1859
- *
1860
- * The selection lives in screen cells over the frame as drawn. Releasing the button copies
1861
- * it; the highlight stays until the next key, click or wheel tick so the reader can see what
1862
- * was taken. A press and release on one cell selects nothing, and a second press on the same
1863
- * cell within the double-click window takes the word under it. Other buttons are swallowed,
1864
- * so no click reaches the composer as text.
1865
- * @param button - the report's button code, modifiers and motion bit included.
1866
- * @param pressed - false for a release.
1867
- * @param column - 1-based screen column.
1868
- * @param row - 1-based screen row.
1869
- */
1870
1374
  mouse(button, pressed, column, row) {
1871
1375
  const base = button & ~28;
1872
1376
  if (base === 64 || base === 65) {
@@ -1881,7 +1385,6 @@ export class TerminalUI extends EventEmitter {
1881
1385
  }
1882
1386
  const which = base & 3, motion = (base & 32) !== 0;
1883
1387
  if (motion) {
1884
- // A drag is not the first half of a double-click, even when it ends where it began.
1885
1388
  if (which === 0 && this.selection?.dragging) {
1886
1389
  this.selection.head = { row, column };
1887
1390
  this.lastPress = undefined;
@@ -1893,7 +1396,6 @@ export class TerminalUI extends EventEmitter {
1893
1396
  const now = Date.now(), last = this.lastPress;
1894
1397
  const double = last !== undefined && last.row === row && last.column === column && now - last.at <= DOUBLE_CLICK_MS;
1895
1398
  this.lastPress = double ? undefined : { row, column, at: now };
1896
- // A drag that starts in the chat column stays there, so the side panel is not copied with it.
1897
1399
  const chat = this.chatColumns(), limit = column <= chat ? chat : undefined;
1898
1400
  const word = double ? wordAt(this.frame, { row, column }) : undefined;
1899
1401
  this.selection = word ? { ...word, limit, dragging: false } : { anchor: { row, column }, head: { row, column }, limit, dragging: true };
@@ -1906,8 +1408,6 @@ export class TerminalUI extends EventEmitter {
1906
1408
  const selection = this.selection;
1907
1409
  if (!selection?.dragging)
1908
1410
  return;
1909
- // The release carries its own position: a fast drag can end past the last motion
1910
- // report, or send no motion report at all.
1911
1411
  selection.head = { row, column };
1912
1412
  selection.dragging = false;
1913
1413
  if (emptySelection(selection))
@@ -1917,7 +1417,6 @@ export class TerminalUI extends EventEmitter {
1917
1417
  this.scheduleRender();
1918
1418
  }
1919
1419
  }
1920
- /** Copy the screen selection; over SSH only the terminal's clipboard is the reader's own. */
1921
1420
  copyScreenSelection() {
1922
1421
  if (!this.selection)
1923
1422
  return;
@@ -1925,17 +1424,12 @@ export class TerminalUI extends EventEmitter {
1925
1424
  if (text.trim())
1926
1425
  this.copyText(text, { terminalOnly: Boolean(process.env.SSH_CONNECTION || process.env.SSH_CLIENT || process.env.SSH_TTY) });
1927
1426
  }
1928
- /** Lay the selection highlight over a composed frame. */
1929
1427
  withSelection(lines) {
1930
1428
  const selection = this.selection;
1931
1429
  if (!selection || emptySelection(selection))
1932
1430
  return lines;
1933
1431
  return lines.map((line, index) => { const span = selectedSpan(selection, index + 1); return span ? highlightRow(line, span[0], span[1]) : line; });
1934
1432
  }
1935
- /**
1936
- * Scroll the transcript (or the active screen). Positive `direction` scrolls up (toward
1937
- * older output), which is what a wheel-up report and an Up key during a run both mean.
1938
- */
1939
1433
  scrollBy(direction) {
1940
1434
  if (this.modal) {
1941
1435
  if (this.modal.kind === 'text')
@@ -1996,9 +1490,6 @@ export class TerminalUI extends EventEmitter {
1996
1490
  this.armPlainInput();
1997
1491
  return;
1998
1492
  }
1999
- // Steering shares the plain-input path so a pasted steer is handled like pasted text,
2000
- // but the deferred Enter must fire even with no pending question, so the ownership
2001
- // token carries whichever surface currently owns the composer.
2002
1493
  const owner = this.composerOwner();
2003
1494
  if (/^[\r\n]$|^\r\n$/.test(text)) {
2004
1495
  this.pendingBreak = text;
@@ -2028,19 +1519,9 @@ export class TerminalUI extends EventEmitter {
2028
1519
  return; if (this.pending?.choices && text.startsWith('/'))
2029
1520
  this.commandInput = true; const selected = this.selectionRange(); if (selected)
2030
1521
  this.deleteSelection(selected); const before = this.value.slice(0, this.cursor).join(''), after = this.value.slice(this.cursor).join(''); const insertion = clean(text).slice(0, Math.max(0, MAX_INPUT - before.length - after.length)); this.value = composerGraphemes(before + insertion + after); this.cursor = composerGraphemes(before + insertion).length; this.chipTypedSkill(); this.completion = undefined; this.dismissedCompletion = undefined; this.scroll = 0; this.scheduleRender(); }
2031
- /** Whether the surface that owns the composer accepts task input — the only place attachments mean anything. */
2032
1522
  conversationComposer() {
2033
- // Steering owns the conversation only while no question holds the composer: an approval or
2034
- // clarification owns it the moment it appears, and a queued attachment would then ride a
2035
- // later model turn while the visible question receives an empty Enter. This mirrors the
2036
- // `steering && !pending` owner rule in ownsComposer's STEERING_OWNER branch.
2037
1523
  return (this.steering && !this.pending) || this.pending?.conversationPrompt === true;
2038
1524
  }
2039
- /**
2040
- * Land a completed bracketed paste. Terminal drag-and-drop arrives as one or more existing
2041
- * filesystem paths, which become file references; a paste past the inline threshold becomes a
2042
- * spooled text attachment instead of flooding the composer; everything else inlines as before.
2043
- */
2044
1525
  landPaste(text) {
2045
1526
  const cleaned = clean(text);
2046
1527
  if (this.conversationComposer()) {
@@ -2057,11 +1538,6 @@ export class TerminalUI extends EventEmitter {
2057
1538
  }
2058
1539
  this.insert(cleaned);
2059
1540
  }
2060
- /**
2061
- * Queue one attachment as an inline token at the composer cursor; false means the per-turn cap
2062
- * refused it. Outside the conversation composer the token waits, and `adoptTokens` appends it
2063
- * to the draft once that composer is armed again.
2064
- */
2065
1541
  addAttachment(pending) {
2066
1542
  if (this.attachments.length >= MAX_ATTACHMENTS) {
2067
1543
  this.print(`Attachment limit reached (${MAX_ATTACHMENTS}). Submit, or press Ctrl+X to remove the last one.`);
@@ -2072,12 +1548,8 @@ export class TerminalUI extends EventEmitter {
2072
1548
  pending = { ...pending, name: `pasted-${seq}.txt` };
2073
1549
  if (pending.kind === 'image' && !pending.name)
2074
1550
  pending = { ...pending, name: `clipboard-${seq}.png` };
2075
- // One code point per attachment for the session: a marker parked in a history or steer draft
2076
- // after its attachment was dropped must never come back as a reference to a newer one.
2077
1551
  const marker = String.fromCodePoint(TOKEN_BASE + seq % 0xFFFFE);
2078
1552
  this.attachments.push({ marker, seq, pending });
2079
- // The token replaces a selection, as a small paste does; a space follows it unless one
2080
- // already does, so typing on reads as a new word.
2081
1553
  if (this.conversationComposer()) {
2082
1554
  const selected = this.selectionRange();
2083
1555
  if (selected)
@@ -2091,14 +1563,12 @@ export class TerminalUI extends EventEmitter {
2091
1563
  this.scheduleRender();
2092
1564
  return true;
2093
1565
  }
2094
- /** The skills the `/` popup lists after the built-in commands; a skill whose command a built-in owns is left out. */
2095
1566
  setSkillCommands(skills) {
2096
1567
  this.skillCommands = skills.filter(skill => /^\/\S+$/.test(skill.command) && !commands.includes(skill.command)).map(skill => ({ command: skill.command, description: oneLine(skill.description) }));
2097
1568
  this.completion = undefined;
2098
1569
  this.scheduleRender();
2099
1570
  }
2100
1571
  skillCommand(command) { return this.skillCommands.some(skill => skill.command === command); }
2101
- /** Replace the draft's leading `command` (and anything typed after it) with the skill chip and a space. */
2102
1572
  insertSkillChip(command, rest = ' ') {
2103
1573
  this.skillChip = command;
2104
1574
  this.value = [SKILL_TOKEN, ...composerGraphemes(rest.startsWith(' ') ? rest : ' ' + rest)];
@@ -2107,10 +1577,6 @@ export class TerminalUI extends EventEmitter {
2107
1577
  this.dismissedCompletion = undefined;
2108
1578
  this.selectionAnchor = undefined;
2109
1579
  }
2110
- /**
2111
- * Turn a leading, fully typed skill command into the chip once a space follows it, so a command
2112
- * typed out in full reads the same as one picked from the popup.
2113
- */
2114
1580
  chipTypedSkill() {
2115
1581
  if (this.value[0] === SKILL_TOKEN)
2116
1582
  return;
@@ -2123,10 +1589,6 @@ export class TerminalUI extends EventEmitter {
2123
1589
  this.value.splice(0, length, SKILL_TOKEN);
2124
1590
  this.cursor = Math.max(1, this.cursor - length + 1);
2125
1591
  }
2126
- /**
2127
- * Backspace and Delete. Beside the skill chip they remove the chip and the space that follows it in
2128
- * one keystroke, so a picked skill comes out as it went in.
2129
- */
2130
1592
  backspace() {
2131
1593
  if (this.cursor === 2 && this.value[0] === SKILL_TOKEN && this.value[1] === ' ') {
2132
1594
  this.removeDraft(0, 2);
@@ -2143,9 +1605,7 @@ export class TerminalUI extends EventEmitter {
2143
1605
  }
2144
1606
  this.removeDraft(this.cursor, 1);
2145
1607
  }
2146
- /** Take every queued attachment in draft order, without blocking — the CLI drains this when a task is submitted. */
2147
1608
  takeAttachments() { const queued = this.attachments.map(entry => entry.pending); this.attachments = []; this.scheduleRender(); return queued; }
2148
- /** The bold label a token draws as in the composer. */
2149
1609
  tokenLabel({ seq, pending }) {
2150
1610
  if (pending.kind === 'text') {
2151
1611
  const lines = pending.content.split('\n').length;
@@ -2157,7 +1617,6 @@ export class TerminalUI extends EventEmitter {
2157
1617
  const folder = /[\\/]$/.test(label);
2158
1618
  return `[${folder ? 'Folder' : 'File'} #${seq} · ${label.replace(/[\\/]+$/, '').split(/[\\/]/).pop() || label}${folder ? '/' : ''}]`;
2159
1619
  }
2160
- /** The draft as display elements: each token replaced by its label, clipped to the composer. */
2161
1620
  visibleDraft(width) {
2162
1621
  if (this.pending?.secret)
2163
1622
  return this.value.map(() => '*');
@@ -2166,12 +1625,6 @@ export class TerminalUI extends EventEmitter {
2166
1625
  labels.set(SKILL_TOKEN, clip(this.skillChip, Math.max(1, width)));
2167
1626
  return this.value.map(part => labels.get(part) ?? (isToken(part) ? '' : part));
2168
1627
  }
2169
- /**
2170
- * The draft as submitted text. Tokens become `[name]` references the model can match against
2171
- * the attachment block, and the queue is put in the order the tokens appear. A draft that is
2172
- * only tokens submits empty, so the CLI keeps its attachment-only task text, and a slash
2173
- * command submits without them, so the command runs and the attachments stay queued.
2174
- */
2175
1628
  submittedDraft() {
2176
1629
  const order = new Map(this.value.map((part, index) => [part, index]));
2177
1630
  this.attachments.sort((left, right) => (order.get(left.marker) ?? Infinity) - (order.get(right.marker) ?? Infinity));
@@ -2184,13 +1637,7 @@ export class TerminalUI extends EventEmitter {
2184
1637
  const names = new Map(this.attachments.map(({ marker, pending }) => [marker, `[${pending.kind === 'file' ? pending.path : pending.name}]`]));
2185
1638
  return draft.map(part => isToken(part) ? names.get(part) ?? '' : part).join('');
2186
1639
  }
2187
- /**
2188
- * The draft as it is parked (history browsing, a question interrupting steering): the skill chip is
2189
- * written out as its command, so `restoredDraft` can turn it back into a chip — the token alone would
2190
- * not survive the trip, and the draft would lose the skill it names.
2191
- */
2192
1640
  parkedDraft() { return this.value.map(part => part === SKILL_TOKEN ? this.skillChip ?? '' : part).join(''); }
2193
- /** A parked draft brought back into the composer, keeping only tokens whose attachment is still queued. */
2194
1641
  restoredDraft(text) {
2195
1642
  const live = new Set(this.attachments.map(entry => entry.marker));
2196
1643
  const parts = composerGraphemes(text).filter(part => !isToken(part) || live.has(part));
@@ -2200,7 +1647,6 @@ export class TerminalUI extends EventEmitter {
2200
1647
  this.skillChip = match[1];
2201
1648
  return [SKILL_TOKEN, ...parts.slice(graphemes(match[1]).length)];
2202
1649
  }
2203
- /** Remove draft elements, dropping the attachment behind every token they held. */
2204
1650
  removeDraft(start, count) {
2205
1651
  const removed = new Set(this.value.splice(start, count).filter(isToken));
2206
1652
  if (removed.has(SKILL_TOKEN))
@@ -2208,11 +1654,6 @@ export class TerminalUI extends EventEmitter {
2208
1654
  if (removed.size)
2209
1655
  this.attachments = this.attachments.filter(entry => !removed.has(entry.marker));
2210
1656
  }
2211
- /**
2212
- * Put every queued token that is missing from the armed conversation draft back at its end. A
2213
- * submitted prompt clears the composer before the CLI drains the queue, and `/attach` queues a
2214
- * file between prompts, so a token can be queued while no draft holds it.
2215
- */
2216
1657
  adoptTokens() {
2217
1658
  if (!this.conversationComposer() || this.historyIndex !== this.history.length)
2218
1659
  return;
@@ -2224,9 +1665,7 @@ export class TerminalUI extends EventEmitter {
2224
1665
  if (atEnd)
2225
1666
  this.cursor = this.value.length;
2226
1667
  }
2227
- /** Whether attachments are queued, without draining them (the CLI decides whether a submission carries them). */
2228
1668
  hasQueuedAttachments() { return this.attachments.length > 0; }
2229
- /** Read the system clipboard for an image and attach it (Ctrl+V; terminals cannot paste images as text). */
2230
1669
  pasteClipboardImage() {
2231
1670
  if (!this.conversationComposer())
2232
1671
  return;
@@ -2234,9 +1673,6 @@ export class TerminalUI extends EventEmitter {
2234
1673
  this.print('Clipboard image paste is unavailable here.');
2235
1674
  return;
2236
1675
  }
2237
- // The probe is asynchronous (a shell-out on Windows): bind the result to the composer that
2238
- // initiated it — and to its generation, so a steer submitted while the probe ran cannot be
2239
- // overtaken by an image the user pasted for a draft that no longer exists.
2240
1676
  const owner = this.composerOwner();
2241
1677
  const generation = this.clipboardProbe;
2242
1678
  void this.clipboardImageProbe().then(buffer => {
@@ -2255,6 +1691,12 @@ export class TerminalUI extends EventEmitter {
2255
1691
  }
2256
1692
  clearDraft() { this.clipboardProbe += 1; this.value = []; this.cursor = 0; this.historyIndex = this.history.length; this.draft = ''; this.commandInput = false; this.completion = undefined; this.dismissedCompletion = undefined; this.attachments = []; this.scroll = 0; this.scheduleRender(); }
2257
1693
  onKey = (text, key) => {
1694
+ if (this.selection && key.ctrl && key.name === 'c' && !emptySelection(this.selection)) {
1695
+ this.copyScreenSelection();
1696
+ this.selection = undefined;
1697
+ this.scheduleRender();
1698
+ return;
1699
+ }
2258
1700
  if (this.selection) {
2259
1701
  this.selection = undefined;
2260
1702
  this.scheduleRender();
@@ -2273,8 +1715,6 @@ export class TerminalUI extends EventEmitter {
2273
1715
  this.scheduleRender();
2274
1716
  return;
2275
1717
  }
2276
- // Expanding from the collapsed summary must not throw the reader back to the live tail:
2277
- // the summary advertises ctrl+t precisely while scrolled back, so the position is kept.
2278
1718
  if (key.ctrl && key.name === 't' && !this.modal) {
2279
1719
  this.expandedTodos = !this.expandedTodos;
2280
1720
  this.todoOffset = 0;
@@ -2282,9 +1722,6 @@ export class TerminalUI extends EventEmitter {
2282
1722
  return;
2283
1723
  }
2284
1724
  if (key.ctrl && key.name === 'o' && !this.modal && this.dashboard) {
2285
- // Leaving the dashboard always lands on the expanded transcript, and no prompt box is on
2286
- // screen to invert: inverting stored boxes the reader cannot see would silently change
2287
- // rows behind their back, so every box simply follows the expanded flag.
2288
1725
  this.dashboard = false;
2289
1726
  this.expandedTranscript = true;
2290
1727
  this.expandedPromptIds.clear();
@@ -2294,11 +1731,6 @@ export class TerminalUI extends EventEmitter {
2294
1731
  return;
2295
1732
  }
2296
1733
  if (key.ctrl && key.name === 'o' && !this.modal) {
2297
- // Ctrl+O inverts exactly what is on screen: the details flag flips, and every prompt box
2298
- // flips relative to the state the reader could see, so one press performs the action each
2299
- // row advertises ("Ctrl+O to expand" / "Ctrl+O to collapse"). A box
2300
- // whose state contradicts the flipped flag keeps an explicit override, because no single
2301
- // global value can express per-box inversion; boxes created later follow the flag.
2302
1734
  const expandedBefore = new Set([...this.promptBoxIds].filter(id => this.expandedPromptIds.has(id)
2303
1735
  || (this.expandedTranscript && !this.collapsedPromptIds.has(id))));
2304
1736
  this.expandedTranscript = this.dashboard || !this.expandedTranscript;
@@ -2315,7 +1747,6 @@ export class TerminalUI extends EventEmitter {
2315
1747
  this.scheduleRender();
2316
1748
  return;
2317
1749
  }
2318
- // The reasoning preview collapses and reopens from the keyboard; no click reaches the app.
2319
1750
  if (key.ctrl && key.name === 'y' && !this.modal) {
2320
1751
  if (this.thinkingActive) {
2321
1752
  this.thinkingExpanded = !this.thinkingExpanded;
@@ -2323,11 +1754,6 @@ export class TerminalUI extends EventEmitter {
2323
1754
  }
2324
1755
  return;
2325
1756
  }
2326
- // Composer attachments: Ctrl+X removes the last queued chip, Ctrl+V reads the system
2327
- // clipboard for an image (a terminal's own paste cannot deliver one). Both are no-ops
2328
- // without queued attachments / a clipboard probe, so they never shadow other intents.
2329
- // Over a composer selection Ctrl+C copies and Ctrl+X cuts, ahead of their other meanings
2330
- // (clearing the draft, interrupting, removing a chip). A secret prompt never copies.
2331
1757
  if (key.ctrl && (key.name === 'c' || key.name === 'x') && !this.modal && !this.pending?.secret && this.selectionRange()) {
2332
1758
  this.copySelection(key.name === 'x');
2333
1759
  return;
@@ -2352,13 +1778,6 @@ export class TerminalUI extends EventEmitter {
2352
1778
  this.pasteClipboardImage();
2353
1779
  return;
2354
1780
  }
2355
- // Ctrl+C clears a non-empty draft before it interrupts anything: the draft is the
2356
- // user's unfinished work, and one stray press should not pause a run or exit the
2357
- // session and take the draft with it. An empty composer escalates as before. Only a
2358
- // modal screen truly hides the composer — the dashboard keeps it drawn and editable,
2359
- // so a draft there clears like any other. Ctrl+C inside a paste payload is unreachable
2360
- // here: while a bracketed paste is in flight the bytes accumulate in the paste buffer
2361
- // and are stripped by clean() when the paste lands.
2362
1781
  if (key.ctrl && key.name === 'c') {
2363
1782
  if (!this.modal && (this.value.length || this.hasQueuedAttachments())) {
2364
1783
  this.clearDraft();
@@ -2395,12 +1814,6 @@ export class TerminalUI extends EventEmitter {
2395
1814
  this.scheduleRender();
2396
1815
  return;
2397
1816
  }
2398
- // Enter runs what the popup is highlighting: the popup promises that the selected row is
2399
- // the command that runs, and a prefix such as `/prov` is not itself a command, so sending
2400
- // it verbatim only ever produced an unknown-command notice. A plain Enter (Alt+Enter keeps
2401
- // inserting a newline) substitutes the visible selection for the draft and then falls
2402
- // through to the ordinary submit path below, so a single press is enough and the
2403
- // substituted text is submitted, echoed and recorded exactly as if it had been typed.
2404
1817
  if ((key.name === 'return' || key.name === 'enter') && !key.meta && !key.shift) {
2405
1818
  const selected = this.selectedCompletion();
2406
1819
  if (selected && this.skillCommand(selected)) {
@@ -2447,17 +1860,10 @@ export class TerminalUI extends EventEmitter {
2447
1860
  this.scheduleRender();
2448
1861
  return;
2449
1862
  }
2450
- // While no prompt is pending — a run streaming output — there is no history to
2451
- // navigate, so Up/Down scroll the transcript, alongside Page Up/Down and the wheel.
2452
- // Steering keeps the composer editable, so a draft rebinds the arrows to cursor movement
2453
- // inside it.
2454
1863
  if ((key.name === 'up' || key.name === 'down') && !this.pending && (!this.steering || !this.value.length)) {
2455
1864
  this.scrollBy(key.name === 'up' ? 1 : -1);
2456
1865
  return;
2457
1866
  }
2458
- // Steering owns the composer for the duration of a run: submitted text is queued for
2459
- // the executor instead of resolving a question, and a real question (approval,
2460
- // clarification) still takes precedence because it sets `pending`.
2461
1867
  if (this.steering && !this.pending && !this.modal) {
2462
1868
  if ((key.name === 'return' || key.name === 'enter') && (key.meta || key.shift)) {
2463
1869
  this.insert('\n');
@@ -2465,9 +1871,6 @@ export class TerminalUI extends EventEmitter {
2465
1871
  }
2466
1872
  if (key.name === 'return' || key.name === 'enter') {
2467
1873
  const value = this.submittedDraft().trim();
2468
- // An attachment-only steer submits too: the tokens are the message, and the CLI names
2469
- // them with the same stand-in text an attachment-only task gets. Enter with neither
2470
- // text nor tokens stays a no-op.
2471
1874
  if (value || this.hasQueuedAttachments()) {
2472
1875
  const drainAttachments = () => {
2473
1876
  const queuedAttachments = this.takeAttachments();
@@ -2480,21 +1883,12 @@ export class TerminalUI extends EventEmitter {
2480
1883
  this.history.push(value);
2481
1884
  this.history = this.history.slice(-100);
2482
1885
  }
2483
- // Steering is the composer for the live run, so a slash command typed here would
2484
- // otherwise be delivered to the model as an instruction. Session commands that cannot
2485
- // run mid-run say so immediately rather than queueing text the run would treat as a
2486
- // prompt; the live subset, exits, and paused runs fall through to the run input
2487
- // handler, which owns them.
2488
1886
  const command = submittedCommand(value);
2489
1887
  const hinted = command && !liveRunCommands.includes(command) && this.status.activity !== 'Paused' ? command : undefined;
2490
1888
  if (hinted)
2491
1889
  this.print(workingCommandHint(hinted));
2492
1890
  else {
2493
1891
  this.printPrompt(value);
2494
- // Attachments leave the queue only when the text actually becomes a steer. A live
2495
- // command (`/status`, `/attach`, …) is consumed by the run input handler, and a
2496
- // paused run turns the text into a resume direction: both keep the queue for the
2497
- // next submission, so running a command never discards queued files.
2498
1892
  if (!this.runInputHandler?.(value))
2499
1893
  this.steered.push({ text: value, attachments: drainAttachments() });
2500
1894
  }
@@ -2502,7 +1896,6 @@ export class TerminalUI extends EventEmitter {
2502
1896
  else {
2503
1897
  this.steered.push({ text: '', attachments: drainAttachments() });
2504
1898
  }
2505
- // The submission ends this draft: a clipboard probe still running belongs to it.
2506
1899
  this.clipboardProbe += 1;
2507
1900
  this.value = [];
2508
1901
  this.cursor = 0;
@@ -2556,8 +1949,6 @@ export class TerminalUI extends EventEmitter {
2556
1949
  this.value = [];
2557
1950
  this.cursor = 0;
2558
1951
  this.commandInput = false;
2559
- // Clarification cancellation belongs to the question, not the live-run command
2560
- // router. Never settle an approval or resume a paused run with this command.
2561
1952
  if (command.toLowerCase() === '/cancel') {
2562
1953
  if (this.pending.choices?.some(choice => choice.id === 'cancel')) {
2563
1954
  this.resolveQuestion('cancel');
@@ -2644,6 +2035,12 @@ export class TerminalUI extends EventEmitter {
2644
2035
  this.finishModal(item.id.startsWith(':') ? item.id : modal.editPrefix + item.id);
2645
2036
  return;
2646
2037
  }
2038
+ if (modal.kind === 'select' && ((key.name === 'right' && modal.expandPrefix !== undefined) || (key.name === 'left' && modal.collapsePrefix !== undefined))) {
2039
+ const item = modal.items[modal.selected];
2040
+ if (item && !item.separator)
2041
+ this.finishModal((key.name === 'right' ? modal.expandPrefix : modal.collapsePrefix) + item.id);
2042
+ return;
2043
+ }
2647
2044
  if (key.name === 'escape') {
2648
2045
  this.finishModal();
2649
2046
  return;
@@ -2678,9 +2075,6 @@ export class TerminalUI extends EventEmitter {
2678
2075
  if (this.moveRow(direction))
2679
2076
  return;
2680
2077
  const historyAt = this.pending?.history ? Math.max(0, Math.min(this.history.length, this.historyIndex + direction)) : this.historyIndex;
2681
- // The wheel never reaches this method: the mouse is captured, so it arrives as a wheel
2682
- // report (`mouse`) and never as arrow bytes. Up/Down are therefore purely the keyboard:
2683
- // cursor movement above, history recall here.
2684
2078
  if (this.pending?.history) {
2685
2079
  if (this.historyIndex === this.history.length)
2686
2080
  this.draft = this.parkedDraft();
@@ -2689,9 +2083,7 @@ export class TerminalUI extends EventEmitter {
2689
2083
  this.cursor = this.value.length;
2690
2084
  }
2691
2085
  }
2692
- /** Move the caret one wrapped row up or down inside the draft; false on the first/last row. */
2693
2086
  moveRow(direction) {
2694
- // Lay out the draft as it is drawn: a token is one element but spans its whole label.
2695
2087
  const columns = Math.max(1, this.chatColumns() - 4);
2696
2088
  const layout = editor(this.visibleDraft(columns), columns);
2697
2089
  const current = layout.positions[this.cursor];
@@ -2703,7 +2095,6 @@ export class TerminalUI extends EventEmitter {
2703
2095
  this.cursor = candidates[0]?.index ?? this.cursor;
2704
2096
  return true;
2705
2097
  }
2706
- /** The composer's selected grapheme range, or undefined when nothing is selected. */
2707
2098
  selectionRange() {
2708
2099
  const anchor = this.selectionAnchor;
2709
2100
  if (anchor === undefined || this.selectionValue !== this.value || anchor === this.cursor || anchor > this.value.length)
@@ -2717,13 +2108,6 @@ export class TerminalUI extends EventEmitter {
2717
2108
  this.completion = undefined;
2718
2109
  this.dismissedCompletion = undefined;
2719
2110
  }
2720
- /**
2721
- * Selection keys for the prompt and steering editors. Shift with an arrow, Home or End
2722
- * extends the selection from where it started (Shift+Up/Down past the first or last row runs
2723
- * to that end of the draft, never into history). Over a selection a plain Left/Right
2724
- * collapses it to that edge and Backspace/Delete remove it; typed or pasted text replaces it
2725
- * in `insert`. Any other key drops it. True when the key was consumed.
2726
- */
2727
2111
  selectionKey(key, text) {
2728
2112
  if (key.shift && !key.ctrl && !key.meta && ['left', 'right', 'home', 'end', 'up', 'down'].includes(key.name ?? '')) {
2729
2113
  if (this.selectionAnchor === undefined || this.selectionValue !== this.value) {
@@ -2768,18 +2152,6 @@ export class TerminalUI extends EventEmitter {
2768
2152
  this.selectionAnchor = undefined;
2769
2153
  return false;
2770
2154
  }
2771
- /**
2772
- * Copy the composer selection to the clipboard; a cut also removes it from the draft.
2773
- *
2774
- * The system writer is preferred; without one, or when it fails, an OSC 52 sequence asks
2775
- * the terminal to set the clipboard instead.
2776
- */
2777
- /**
2778
- * Put text on the clipboard of whoever is looking at this terminal.
2779
- *
2780
- * `terminalOnly` skips the system writer for an OSC 52 sequence alone: over SSH the system
2781
- * clipboard belongs to the remote host, while the terminal's is the one on the user's own machine.
2782
- */
2783
2155
  copyText(text, options = {}) {
2784
2156
  const osc52 = () => { if (this.started && !this.closed)
2785
2157
  this.output.write(`\x1b]52;c;${Buffer.from(text, 'utf8').toString('base64')}\x07`); };
@@ -2792,7 +2164,6 @@ export class TerminalUI extends EventEmitter {
2792
2164
  const range = this.selectionRange();
2793
2165
  if (!range)
2794
2166
  return;
2795
- // A token copies as what it stands for: the pasted text itself, a file's path, an image's name.
2796
2167
  const tokens = new Map(this.attachments.map(({ marker, pending }) => [marker, pending.kind === 'text' ? pending.content : pending.kind === 'file' ? pending.path : `[${pending.name}]`]));
2797
2168
  if (this.skillChip)
2798
2169
  tokens.set(SKILL_TOKEN, this.skillChip);
@@ -2815,30 +2186,13 @@ export class TerminalUI extends EventEmitter {
2815
2186
  this.awaitArgument(selected);
2816
2187
  return;
2817
2188
  } this.value = graphemes(selected); this.cursor = this.value.length; const options = completionOptions(selected, this.skillCommands.map(skill => skill.command)); this.completion = { query: selected, options, index: options.indexOf(selected) }; }
2818
- /** Put `command ` in the composer and open its argument list, without submitting anything. */
2819
2189
  awaitArgument(command) { this.value = graphemes(`${command} `); this.cursor = this.value.length; this.completion = undefined; this.dismissedCompletion = undefined; }
2820
- /**
2821
- * The command Enter must not run yet: the draft is only the name of a command that needs an
2822
- * argument, so it is completed to `command ` and the argument list opens. Applies wherever the
2823
- * popup does — the conversation prompt and the live-run composer — and never to a question,
2824
- * a secret, or a modal.
2825
- */
2826
2190
  argumentPending() {
2827
2191
  if (this.pending?.secret || (!this.pending?.conversationPrompt && !this.runInputHandler) || this.modal)
2828
2192
  return undefined;
2829
2193
  const draft = this.value.join('').trim();
2830
2194
  return argumentRequired.has(draft) ? draft : undefined;
2831
2195
  }
2832
- /**
2833
- * The popup entry Enter should run, or undefined when there is nothing runnable.
2834
- *
2835
- * Re-derived from the composer text on every call rather than read from the cached
2836
- * completion: that cache is shared with the renderer, and a resize or an edit outside the
2837
- * popup's own key handling can leave it stale, which would let Enter run a row that is no
2838
- * longer highlighted or no longer drawn. `commandMatches(true)` applies the same visibility
2839
- * gate the renderer uses, so a candidate that is off-screen on a short terminal reports
2840
- * nothing, and an entry identical to the draft is not a completion at all.
2841
- */
2842
2196
  selectedCompletion() {
2843
2197
  const completion = this.commandMatches(true);
2844
2198
  const selected = completion?.options[completion.index];
@@ -2861,24 +2215,6 @@ export class TerminalUI extends EventEmitter {
2861
2215
  scheduleRender() { if (!this.started || this.closed || this.scheduled)
2862
2216
  return; this.scheduled = true; queueMicrotask(() => { this.scheduled = false; if (!this.closed)
2863
2217
  this.render(); }); }
2864
- /**
2865
- * Paint a frame, rewriting only the rows whose content actually changed.
2866
- *
2867
- * The app never takes the mouse (`start`), so the terminal keeps drag-to-select and the
2868
- * clipboard in every state. What defeated those selections was output churn: a run repaints eight times a second for the working animation alone, and an
2869
- * emulator abandons the cells under a drag as soon as the app rewrites them. Diffing
2870
- * against what is already drawn means an unchanged screen writes nothing at all, and every
2871
- * *contiguous run* of changed rows gets its own write: when two separated rows change (the
2872
- * animated working row and the footer counters after a request completes, say) the
2873
- * unchanged rows between them are left alone, so a selection over the transcript, the
2874
- * composer or the model line survives a footer update. The composed picture is identical
2875
- * either way - the row diff is a delivery detail, never a change in what is drawn.
2876
- * @param lines - the frame's rows, top to bottom, exactly as they should read.
2877
- * @param cursor - optional caret sequence; re-emitted after any painted row, because painting
2878
- * hides the caret and only this sequence brings it back. A frame that paints nothing and
2879
- * leaves the caret where it was still writes zero bytes, so the caret can ride along with
2880
- * the frame without breaking the settled-frame contract.
2881
- */
2882
2218
  writeFrame(composed, cursor = '') {
2883
2219
  this.frame = composed;
2884
2220
  const lines = this.withSelection(composed);
@@ -2888,14 +2224,10 @@ export class TerminalUI extends EventEmitter {
2888
2224
  const unchanged = (index) => (previous?.[index] ?? '') === (lines[index] ?? '');
2889
2225
  let painted = false;
2890
2226
  if (!previous) {
2891
- // The first frame has nothing trustworthy to compare against, so it draws every row and
2892
- // clears the rest of the screen, byte for byte what an undiffed frame writes.
2893
2227
  this.output.write('\x1b[?25l\x1b[H' + lines.map(line => '\x1b[2K' + line).join('\r\n') + '\x1b[J');
2894
2228
  painted = true;
2895
2229
  }
2896
2230
  else {
2897
- // One write per contiguous run of changed rows, never one write spanning the unchanged
2898
- // rows that separate two runs: rewriting those cells is what breaks a drag selection.
2899
2231
  const spans = [];
2900
2232
  for (let index = 0; index < rows; index++) {
2901
2233
  if (unchanged(index))
@@ -2907,8 +2239,6 @@ export class TerminalUI extends EventEmitter {
2907
2239
  index = end;
2908
2240
  }
2909
2241
  if (spans.length) {
2910
- // A frame shorter than the one on screen is the only way content can linger underneath,
2911
- // so that is the one case that still needs an erase-below.
2912
2242
  const tail = lines.length < previous.length ? `\x1b[${lines.length + 1};1H\x1b[J` : '';
2913
2243
  this.output.write('\x1b[?25l' + spans.join('') + tail);
2914
2244
  painted = true;
@@ -2924,24 +2254,21 @@ export class TerminalUI extends EventEmitter {
2924
2254
  else
2925
2255
  this.drawnCursor = '';
2926
2256
  }
2927
- /** A quiet startup identity, never a full-width alert-colored diagnostics panel. */
2928
2257
  welcome(width, viewportHeight) {
2929
2258
  const status = this.status;
2930
- const available = Math.max(1, width - 4); // the transcript adds two columns of inset
2259
+ const available = Math.max(1, width - 4);
2931
2260
  const graph = status.graph;
2932
2261
  const selected = status.graphSelection ?? (graph?.id === 'software-engineer' ? 'default' : graph?.id);
2933
2262
  const graphName = selected === 'default' ? 'Default · Andorra Agent' : oneLine(graph?.name ?? 'Not selected');
2934
2263
  const nodes = graph ? Object.keys(graph.nodes).length : 0;
2935
2264
  const nodeCount = graph && selected !== 'default' ? ` · ${nodes} ${nodes === 1 ? 'node' : 'nodes'}` : '';
2936
2265
  const activity = oneLine(status.activity || 'Ready');
2937
- // Compact terminals and setup screens use a legible single-line label.
2938
2266
  const showArt = this.appName === 'ANDORRA CODE'
2939
2267
  && viewportHeight >= 10
2940
2268
  && ANDORRA_WORDMARK.every(row => stringWidth(row) <= available);
2941
2269
  const brand = showArt
2942
2270
  ? [...ANDORRA_WORDMARK, `CODE · v${this.version}`]
2943
2271
  : [`${this.appName} · v${this.version}`];
2944
- // A short terminal must not scroll the fallback label out of its own welcome.
2945
2272
  if (viewportHeight < 9)
2946
2273
  return [
2947
2274
  clip(brand.at(-1), available),
@@ -2959,22 +2286,10 @@ export class TerminalUI extends EventEmitter {
2959
2286
  '',
2960
2287
  ];
2961
2288
  }
2962
- /**
2963
- * The selection screen to dock above the composer while a typed field is being answered.
2964
- *
2965
- * A plain question that follows a selection screen is a field belonging to that screen, so
2966
- * the card is drawn where the home card would otherwise be. Run-time questions (approvals,
2967
- * clarifications) keep their own surface, and the card is windowed around the highlighted
2968
- * entry so a long list cannot eat the composer's rows on a short terminal.
2969
- * @param rows - the transcript rows the render pass left for this card.
2970
- * @returns the card's lines, or undefined when the home card belongs there instead.
2971
- */
2972
2289
  selectionCard(rows) {
2973
2290
  const selection = this.lastSelection;
2974
2291
  if (!selection || !this.pending || this.pending.choices || this.pending.conversationPrompt)
2975
2292
  return undefined;
2976
- // A run's own questions (approval, clarification) are not fields of a selection screen,
2977
- // so the docked card stays with the idle configuration flow it belongs to.
2978
2293
  if (this.status.activity && this.status.activity !== 'Ready')
2979
2294
  return undefined;
2980
2295
  const width = Math.max(8, this.chatColumns() - 4);
@@ -3013,7 +2328,7 @@ export class TerminalUI extends EventEmitter {
3013
2328
  const selected = index === modal.selected;
3014
2329
  if (selected)
3015
2330
  selectedStart = content.length;
3016
- content.push({ text: `${selected ? '›' : ' '} ${oneLine(item.label)}${item.id === modal.selectedId ? ' ✓' : ''}`, selected, bold: item.bold });
2331
+ content.push({ text: `${selected ? '›' : ' '} ${oneLine(item.label)}${item.id === (modal.checkedId ?? modal.selectedId) ? ' ✓' : ''}`, selected, bold: item.bold });
3017
2332
  if (item.description)
3018
2333
  for (const line of wrap(clean(item.description), Math.max(1, innerWidth - 2)))
3019
2334
  content.push({ text: ` ${line}`, selected, dim: true });
@@ -3066,14 +2381,6 @@ export class TerminalUI extends EventEmitter {
3066
2381
  rows.push(paint(pad(yolo, labelWidth), this.status.yolo ? ATTENTION : GRAY) + paint(clip(this.activeModel().label, footerWidth - labelWidth)));
3067
2382
  this.writeFrame(rows);
3068
2383
  }
3069
- /**
3070
- * Wrap transcript text into drawn rows.
3071
- * @param alignRight - pad each stored row that fits the transcript allowance onto its right margin,
3072
- * which is what makes a user submission read as a speech bubble. The decision is made on the
3073
- * stored row rather than on the fragments: wrapping a row that does not fit leaves short tails
3074
- * (the last cells of a split border) that would otherwise be pushed into the margin, smearing
3075
- * the frame across the screen, so no fragment of an over-wide row is padded.
3076
- */
3077
2384
  wrapTranscript(text, width, alignRight = false) {
3078
2385
  return text.split('\n').flatMap(line => {
3079
2386
  const diff = /^\s*[+-]\s+\d+\s*\|/.test(line), box = /^[╭╰│]/.test(line);
@@ -3081,8 +2388,6 @@ export class TerminalUI extends EventEmitter {
3081
2388
  const color = isBrand ? WHITE : box ? GRAY : !diff && line.includes(this.appName) ? accentPaint() : transcriptColor(line);
3082
2389
  const allowance = Math.max(1, width - 4);
3083
2390
  const aligned = alignRight && stringWidth(line) <= allowance;
3084
- // A wrapped list item or indented line continues under its own text, not at the margin:
3085
- // a list whose second rows start in column one reads as loose paragraphs.
3086
2391
  const lead = diff || box || isBrand || aligned ? undefined : /^\s*(?:(?:[•◦└]|\d{1,3}[.)])\s+)?/u.exec(line)?.[0];
3087
2392
  const hang = lead ? stringWidth(lead) : 0;
3088
2393
  const rows = lead && hang > 0 && hang <= allowance / 2 && stringWidth(line) > allowance
@@ -3093,17 +2398,11 @@ export class TerminalUI extends EventEmitter {
3093
2398
  }
3094
2399
  transcriptRows(entry, width) {
3095
2400
  const disclosure = entry.promptDisclosure;
3096
- // Ctrl+O expands the whole transcript, collapsed prompt boxes included: the app never
3097
- // takes the mouse, so the keyboard is the way to the stored rows. An explicit per-prompt
3098
- // toggle wins.
3099
2401
  const promptExpanded = disclosure ? this.promptExpanded(disclosure.id) : false;
3100
2402
  const text = disclosure
3101
2403
  ? promptExpanded && entry.detail ? entry.detail : entry.text
3102
2404
  : this.expandedTranscript && entry.detail ? entry.detail : entry.text + (entry.detail ? ' (Ctrl+O to expand)' : '');
3103
2405
  if (!entry.toolCall) {
3104
- // A collapsed tool result holds each output row to one screen line; Ctrl+O shows the rows
3105
- // whole. The last row is the `… N lines total (Ctrl+O to expand)` marker, which still wraps
3106
- // so a narrow pane never hides the key that reveals the rest.
3107
2406
  const shown = entry.clipRows && text !== entry.detail
3108
2407
  ? text.split('\n').map((row, index, rows) => index < rows.length - 1 ? clip(row, Math.max(1, width - 4)) : row).join('\n')
3109
2408
  : text;
@@ -3131,16 +2430,12 @@ export class TerminalUI extends EventEmitter {
3131
2430
  if (!this.started || this.closed)
3132
2431
  return;
3133
2432
  this.todoPageSize = 0;
3134
- const working = Boolean(this.status.activity && this.status.activity !== 'Ready' && this.status.activity !== 'Paused' && !this.status.backgroundActivity && !this.pending && !this.modal); /* A run folds the Graph/branch row into the other two, so the composer and footer take five rows instead of seven. */
2433
+ const working = Boolean(this.status.activity && this.status.activity !== 'Ready' && this.status.activity !== 'Paused' && !this.status.backgroundActivity && !this.pending && !this.modal);
3135
2434
  const compactFooter = working || this.runActive;
3136
2435
  const footerRows = compactFooter ? 2 : 3;
3137
2436
  const fixedRows = 4 + footerRows;
3138
2437
  this.updateWorkingClock();
3139
2438
  const columns = Math.max(1, this.output.columns || 80), height = Math.max(1, this.output.rows || 24);
3140
- // The token speed needs no refresh of its own: its reading is captured when a request
3141
- // finishes and held static between calls, so the frame already on screen stays correct
3142
- // across a paused run or an approval prompt, and `noteGeneratedTokens` schedules the one
3143
- // render that reveals a new reading. Only the animations need the ticker.
3144
2439
  const ticking = working || (this.dashboard && this.dashboardMetrics.snapshot().running);
3145
2440
  if (ticking && !this.workingTimer) {
3146
2441
  this.workingTimer = setInterval(() => this.scheduleRender(), 120);
@@ -3150,11 +2445,7 @@ export class TerminalUI extends EventEmitter {
3150
2445
  clearInterval(this.workingTimer);
3151
2446
  this.workingTimer = undefined;
3152
2447
  }
3153
- // A running background terminal ages on screen, but its age changes once a second: the panel
3154
- // gets its own one-second clock rather than riding the animation timer's eight frames a second
3155
- // for a string that is not changing. Only a visible panel arms it, and only while a displayed
3156
- // session runs.
3157
- const ages = this.panelColumns(columns, height) > 0 && (this.status.terminals?.some(session => session.running) ?? false);
2448
+ const ages = ((this.status.terminals?.some(session => session.running) ?? false) || this.subagents.running()) && (this.panelColumns(columns, height) > 0 || this.subagents.running());
3158
2449
  if (ages && !this.panelTimer) {
3159
2450
  this.panelTimer = setInterval(() => this.scheduleRender(), 1_000);
3160
2451
  this.panelTimer.unref?.();
@@ -3164,23 +2455,12 @@ export class TerminalUI extends EventEmitter {
3164
2455
  this.panelTimer = undefined;
3165
2456
  }
3166
2457
  if (this.modal) {
3167
- // A modal screen takes the frame, so the panel is hidden for as long as it is open - and a
3168
- // render that returns here never reaches the visibility bookkeeping below. Recording it here
3169
- // is what lets the render after the modal closes announce the panel's return, so its data is
3170
- // read again instead of showing what was true before the screen opened.
3171
2458
  this.panelWasHidden = true;
3172
2459
  this.expandedPromptVisible = false;
3173
2460
  this.renderModal(columns, height);
3174
2461
  return;
3175
2462
  }
3176
- // The panel is composed alongside the chat column rather than reflowing it: everything
3177
- // below keeps its own arithmetic at the reduced chat width, and the frame carries both
3178
- // columns once the rows are built (composePanel). One more column is the gutter that
3179
- // keeps the chat column's own frame - the composer's border, the header's right edge -
3180
- // from touching the divider.
3181
2463
  const panelColumns = this.panelColumns(columns, height);
3182
- // A resize or a closed screen can bring the panel back: tell the embedder so a summary it
3183
- // skipped while nothing could show it is read now instead of at the next run boundary.
3184
2464
  if (panelColumns > 0 && this.panelWasHidden) {
3185
2465
  this.panelWasHidden = false;
3186
2466
  this.emit('panel');
@@ -3207,24 +2487,21 @@ export class TerminalUI extends EventEmitter {
3207
2487
  const firstInput = Math.max(0, Math.min((choices ? choiceIndex : cursor.row) - inputRows + 1, (choices?.length ?? layout.lines.length) - inputRows));
3208
2488
  const completion = this.commandMatches();
3209
2489
  const popupRows = completion ? commandPopupRows(width, height, inputRows, completion.options.length) : 0;
3210
- const popupHeight = popupRows ? popupRows + 2 : 0; // The composer's own todo block stands down while the panel is drawn: the panel's Plan and
3211
- // Progress sections carry the same list, and one plan should not be reported twice on the
3212
- // same screen. The panel is the copy that survives a wide terminal.
3213
- const todoLines = this.dashboard || panelColumns ? [] : this.todoLines(Math.max(0, height - inputRows - fixedRows - 3 - popupHeight));
2490
+ const popupHeight = popupRows ? popupRows + 2 : 0;
2491
+ const goalLines = this.goalLines(width - 2, height - inputRows - fixedRows - 3 - popupHeight);
2492
+ const todoLines = [...goalLines, ...(this.dashboard || panelColumns ? [] : this.todoLines(Math.max(0, height - inputRows - fixedRows - 3 - popupHeight - goalLines.length)))];
2493
+ const agentLines = this.dashboard || panelColumns ? [] : this.agentLines(width - 2, Math.max(0, height - inputRows - fixedRows - 3 - popupHeight - todoLines.length));
3214
2494
  const elapsed = this.workingElapsed + (this.workingSince === undefined ? 0 : Date.now() - this.workingSince);
3215
2495
  const seconds = Math.floor(elapsed / 1000);
3216
- const thinkingLines = this.dashboard ? [] : this.thinkingLines(width, seconds, this.thinkingActive ? Math.max(1, Math.min(THINKING_ROWS + 1, height - inputRows - fixedRows - 1 - popupHeight - todoLines.length)) : 0);
3217
- const transcriptHeight = height - inputRows - fixedRows - popupHeight - todoLines.length - thinkingLines.length;
2496
+ const thinkingLines = this.dashboard ? [] : this.thinkingLines(width, seconds, this.thinkingActive ? Math.max(1, Math.min(THINKING_ROWS + 1, height - inputRows - fixedRows - 1 - popupHeight - todoLines.length - agentLines.length)) : 0);
2497
+ const transcriptHeight = height - inputRows - fixedRows - popupHeight - todoLines.length - agentLines.length - thinkingLines.length;
3218
2498
  const prefix = [...(this.selectionCard(transcriptHeight) ?? this.welcome(width, transcriptHeight)), ...(this.transcript.diagnostics.omitted ? ['Some transcript entries are unavailable because session storage failed.'] : [])].flatMap(text => this.wrapTranscript(text, width));
3219
2499
  const page = this.transcript.window({ prefix, height: transcriptHeight, scroll: this.scroll,
3220
2500
  key: `${width}:${this.expandedTranscript}`, render: entry => this.transcriptRows(entry, width),
3221
2501
  revision: entry => entry.timing ? formatDuration(this.toolClock.elapsed(entry.timing)) ?? ''
3222
- // The effective state, not just the explicit set: a box expanded by Ctrl+O and then
3223
- // collapsed by hand must invalidate the cached row count, or the window would slice
3224
- // against the taller expanded rendering and drop the box entirely.
3225
2502
  : entry.promptDisclosure ? (this.promptExpanded(entry.promptDisclosure.id) ? 'expanded' : 'collapsed') : '' });
3226
2503
  this.scroll = page.scroll;
3227
- const visible = this.dashboard ? dashboardRows({ metrics: this.dashboardMetrics.snapshot(), selectedModel: this.dashboardModel, provider: this.status.provider, model: this.status.model, graph: this.status.graph, providerModels: this.status.providerModels, activeNodes: [...this.activeNodes.keys()], nodeModels: this.nodeModels, todos: this.todos, todoOffset: this.todoOffset, onTodoOffset: offset => { this.todoOffset = offset; }, graphOffset: this.dashboardGraphOffset, notices: this.dashboardNotices, question: this.pending && !this.pending.conversationPrompt ? this.pending.dashboardQuestion ?? this.pending.choiceTitle ?? this.pending.title ?? this.pending.label : undefined }, Math.max(2, width - 4), transcriptHeight).map(line => ({ text: panelRowText(line), color: DIM, segments: line.segments })) : page.rows;
2504
+ const visible = this.dashboard ? dashboardRows({ metrics: this.dashboardMetrics.snapshot(), selectedModel: this.dashboardModel, provider: this.status.provider, model: this.status.model, graph: this.status.graph, providerModels: this.status.providerModels, modelNames: this.status.modelNames, activeNodes: [...this.activeNodes.keys()], nodeModels: this.nodeModels, todos: this.todos, todoOffset: this.todoOffset, onTodoOffset: offset => { this.todoOffset = offset; }, graphOffset: this.dashboardGraphOffset, notices: this.dashboardNotices, question: this.pending && !this.pending.conversationPrompt ? this.pending.dashboardQuestion ?? this.pending.choiceTitle ?? this.pending.title ?? this.pending.label : undefined }, Math.max(2, width - 4), transcriptHeight).map(line => ({ text: panelRowText(line), color: DIM, segments: line.segments })) : page.rows;
3228
2505
  while (visible.length < transcriptHeight)
3229
2506
  visible.push({ text: '', color: DIM });
3230
2507
  if (!this.dashboard && this.scroll && visible.length)
@@ -3243,7 +2520,7 @@ export class TerminalUI extends EventEmitter {
3243
2520
  const workingLabel = clip(workingText, Math.max(0, width - 6));
3244
2521
  const wave = Math.floor(elapsed / 120) % 11;
3245
2522
  const topBorder = working && workingLabel ? paint('╭ ', GRAY) + [...workingLabel].map((character, index) => paint(character, index < 7 && Math.abs(index - wave) <= 1 ? 255 : GRAY)).join('') + paint(' ' + '─'.repeat(Math.max(0, width - 4 - stringWidth(workingLabel))) + '╮', GRAY) : paint('╭' + borderLabel + '─'.repeat(Math.max(0, width - 2 - stringWidth(borderLabel))) + '╮', GRAY);
3246
- const lines = [header, paint(clip(` ${status.account ? `Account: ${oneLine(status.account.label)} | ` : ''}${oneLine(this.workspace)}`, width), FAINT), ...visible.map(line => line.segments ? ' ' + line.segments.map(segment => paint(segment.text, segment.color ?? GRAY)).join('') : paint(' ' + clip(line.text, width - 2), line.color)), ...thinkingLines.map(line => paint(' ' + pad(line, width - 4), GRAY)), ...todoLines.map(line => paint(' ' + clip(line, width - 2), GRAY))];
2523
+ const lines = [header, paint(clip(` ${status.account ? `Account: ${oneLine(status.account.label)} | ` : ''}${oneLine(this.workspace)}`, width), FAINT), ...visible.map(line => line.segments ? ' ' + line.segments.map(segment => paint(segment.text, segment.color ?? GRAY)).join('') : paint(' ' + clip(line.text, width - 2), line.color)), ...thinkingLines.map(line => paint(' ' + pad(line, width - 4), GRAY)), ...agentLines, ...todoLines.map(line => paint(' ' + clip(line, width - 2), GRAY))];
3247
2524
  if (completion && popupRows) {
3248
2525
  const cardWidth = width - 4;
3249
2526
  const popupTitle = clip(' Commands · ↑↓ move · Enter runs · Tab completes ', cardWidth - 2);
@@ -3280,7 +2557,13 @@ export class TerminalUI extends EventEmitter {
3280
2557
  const branchWidth = Math.min(Math.floor(width / 3), stringWidth(branch) + 3);
3281
2558
  const jev = oneLine(status.account?.jevQuota ?? 'Jev unavailable').replace(/^Jev(?= )/, status.jevEnabled === false ? 'Jev [Disabled] ·' : status.jevEnabled === true ? 'Jev [Enabled] ·' : 'Jev');
3282
2559
  const jevWidth = Math.min(stringWidth(jev), width - 1);
3283
- lines.push(paint(pad(model, Math.max(0, width - jevWidth - 2)) + (width - jevWidth > 1 ? ' ' : '') + clip(jev, jevWidth), GRAY));
2560
+ const andorraUsage = this.andorraSegment();
2561
+ const andorraText = andorraUsage?.forms.find(text => stringWidth(model) + 1 + stringWidth(text) + 3 + jevWidth <= width - 1);
2562
+ const andorraWidth = andorraText !== undefined ? stringWidth(andorraText) + 3 : 0;
2563
+ if (andorraUsage && andorraText !== undefined)
2564
+ lines.push(paint(pad(model, width - jevWidth - andorraWidth - 2) + ' ', GRAY) + paint(andorraText, andorraUsage.color) + paint(` · ${jev}`, GRAY));
2565
+ else
2566
+ lines.push(paint(pad(model, Math.max(0, width - jevWidth - 2)) + (width - jevWidth > 1 ? ' ' : '') + clip(jev, jevWidth), GRAY));
3284
2567
  const graph = oneLine(`Graph: ${(status.graphSelection ?? (status.graph?.id === 'software-engineer' ? 'default' : status.graph?.id)) === 'default' ? 'Default' : status.graph?.name ?? 'Not selected'}${status.codeIntel ? ` · CodeGraph: ${status.codeIntel}` : ''}`);
3285
2568
  if (!compactFooter)
3286
2569
  lines.push(paint(pad(graph, width - branchWidth) + clip(`⎇ ${branch}`, branchWidth), GRAY));
@@ -3289,14 +2572,6 @@ export class TerminalUI extends EventEmitter {
3289
2572
  const activeWindow = active.contextWindow;
3290
2573
  const context = activeWindow && Number.isFinite(activeWindow) && activeWindow > 0 ? ` · context: ${Math.floor((count(status.contextUsed) / activeWindow) * 100)}% (${compactTokens.format(count(status.contextUsed))}/${compactTokens.format(activeWindow)})` : '';
3291
2574
  const rate = this.displayRate();
3292
- // The reading is the cumulative average decoding speed of the node currently shown:
3293
- // totals only grow, so it holds unchanged between calls, across a pause, and after the
3294
- // run ends - and it is drawn only while the model row names the model the average was
3295
- // measured under. A session that has not finished one measured request reads 0 and the
3296
- // row stays byte for byte the footer it was before this segment existed. The usage row
3297
- // has one fixed allowance, and a permanent zero would spend it on a number that carries
3298
- // no information - and it is what pushes the context percentage out of the row on an
3299
- // 80-column terminal.
3300
2575
  const measured = rate > 0 ? ` · ${compactTokens.format(rate)} tok/s` : '';
3301
2576
  const counts = `${count(status.requests)} req · ${count(status.inputTokens)} in · ${count(status.outputTokens)} out`;
3302
2577
  const usage = `${counts}${measured}${context}`;
@@ -3304,12 +2579,6 @@ export class TerminalUI extends EventEmitter {
3304
2579
  const approval = compactFooter ? `${graph} · ${permission}` : `Permissions: ${permission}`;
3305
2580
  const footerWidth = width - 1;
3306
2581
  const branchLead = compactFooter ? `⎇ ${branch} · ` : '';
3307
- // Under width pressure the optional tail is dropped first - the context segment, as
3308
- // documented. But the cumulative counts are unbounded and can spend the whole allowance
3309
- // before the speed segment even starts, clipping it mid-word (`1K to`). While a speed is
3310
- // being shown, the counts switch to the compact whole-number form the context segment
3311
- // already uses so the complete `N tok/s` segment keeps its room; without a speed the
3312
- // row behaves exactly as it did before this segment existed.
3313
2582
  const wholeTokens = Intl.NumberFormat('en', { notation: 'compact', maximumFractionDigits: 0 });
3314
2583
  const compactCounts = `${wholeTokens.format(count(status.requests))} req · ${wholeTokens.format(count(status.inputTokens))} in · ${wholeTokens.format(count(status.outputTokens))} out`;
3315
2584
  const usageCap = Math.floor(footerWidth * 0.6);
@@ -3327,8 +2596,6 @@ export class TerminalUI extends EventEmitter {
3327
2596
  }
3328
2597
  else
3329
2598
  usageWidth = Math.min(stringWidth(usage), usageCap);
3330
- // On the compact row the graph name outranks the usage readout: it lost its own row, and the
3331
- // counts are also in the side panel and the dashboard.
3332
2599
  if (compactFooter) {
3333
2600
  usageWidth = Math.max(0, Math.min(usageWidth, footerWidth - stringWidth(`${graph} · `)));
3334
2601
  if (stringWidth(usageText) > usageWidth && branchLead && usageText.startsWith(branchLead))
@@ -3339,13 +2606,7 @@ export class TerminalUI extends EventEmitter {
3339
2606
  const restWidth = approvalWidth - stringWidth(leadText);
3340
2607
  const usagePart = branchLead && usageText.startsWith(branchLead) ? paint(branchLead, GRAY) + paint(usageText.slice(branchLead.length), WHITE) : paint(clip(usageText, usageWidth), WHITE);
3341
2608
  lines.push((leadText ? paint(leadText, GRAY) : '') + paint(clip(pad(compactFooter ? permission : approval, restWidth), restWidth), status.yolo ? ATTENTION : GRAY) + usagePart);
3342
- // The caret travels through the same diff as the rows: writing it straight to the output
3343
- // would put an absolute cursor move and a show-cursor sequence on the wire every 120 ms
3344
- // for the whole of an interactive run (cli.ts keeps steering on), and terminals that clear
3345
- // or move a selection on cursor traffic would lose a drag over an otherwise untouched
3346
- // frame. As a frame input it is suppressed whenever nothing was painted and the caret has
3347
- // not moved, and re-emitted whenever a row repaint hid it.
3348
- const caret = (this.pending || this.steering) && !choices ? `\x1b[${transcriptHeight + todoLines.length + popupHeight + thinkingLines.length + 4 + cursor.row - firstInput};${3 + cursor.column}H\x1b[?25h` : '';
2609
+ const caret = (this.pending || this.steering) && !choices ? `\x1b[${transcriptHeight + todoLines.length + agentLines.length + popupHeight + thinkingLines.length + 4 + cursor.row - firstInput};${3 + cursor.column}H\x1b[?25h` : '';
3349
2610
  this.writeFrame(this.composePanel(lines, this.panelRows(panelColumns, height), panelColumns, width), caret);
3350
2611
  }
3351
2612
  }