@andorra-labs/code 0.1.11 → 0.1.13

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 (614) hide show
  1. package/README.md +8 -2
  2. package/THIRD_PARTY_NOTICES.md +15 -0
  3. package/dist/src/account-presentation.d.ts +1 -37
  4. package/dist/src/account-presentation.js +2 -42
  5. package/dist/src/activity.d.ts +0 -25
  6. package/dist/src/activity.js +1 -23
  7. package/dist/src/agent-definitions.d.ts +0 -26
  8. package/dist/src/agent-definitions.js +0 -43
  9. package/dist/src/agent-execution.d.ts +0 -2
  10. package/dist/src/agent-execution.js +59 -414
  11. package/dist/src/agent-mcp-catalog.d.ts +0 -8
  12. package/dist/src/agent-mcp-catalog.js +0 -2
  13. package/dist/src/agent-mcp.d.ts +0 -56
  14. package/dist/src/agent-mcp.js +14 -153
  15. package/dist/src/agent-modifiers.d.ts +0 -1
  16. package/dist/src/agent-modifiers.js +25 -68
  17. package/dist/src/analytics.d.ts +0 -66
  18. package/dist/src/analytics.js +0 -45
  19. package/dist/src/anthropic-console-auth.d.ts +0 -24
  20. package/dist/src/anthropic-console-auth.js +0 -37
  21. package/dist/src/anthropic-credentials.d.ts +0 -25
  22. package/dist/src/anthropic-credentials.js +0 -28
  23. package/dist/src/app-server/protocol.d.ts +19 -244
  24. package/dist/src/app-server/protocol.js +1 -132
  25. package/dist/src/app-server/reasoning.d.ts +0 -31
  26. package/dist/src/app-server/reasoning.js +0 -54
  27. package/dist/src/app-server/terminal.d.ts +0 -36
  28. package/dist/src/app-server/terminal.js +3 -39
  29. package/dist/src/app-server/workspace.d.ts +0 -167
  30. package/dist/src/app-server/workspace.js +4 -406
  31. package/dist/src/app-server.d.ts +33 -918
  32. package/dist/src/app-server.js +608 -2984
  33. package/dist/src/artifacts.d.ts +0 -10
  34. package/dist/src/artifacts.js +1 -11
  35. package/dist/src/attachments.d.ts +4 -98
  36. package/dist/src/attachments.js +10 -130
  37. package/dist/src/auth/AuthManager.d.ts +0 -93
  38. package/dist/src/auth/AuthManager.js +3 -165
  39. package/dist/src/auth/callback-page.d.ts +0 -1
  40. package/dist/src/auth/callback-page.js +0 -4
  41. package/dist/src/auth/callback.d.ts +0 -25
  42. package/dist/src/auth/callback.js +1 -29
  43. package/dist/src/auth/deployment.d.ts +0 -16
  44. package/dist/src/auth/deployment.js +0 -16
  45. package/dist/src/auth/index.d.ts +0 -11
  46. package/dist/src/auth/index.js +0 -11
  47. package/dist/src/auth/lock.d.ts +0 -1
  48. package/dist/src/auth/lock.js +0 -1
  49. package/dist/src/auth/store.d.ts +7 -108
  50. package/dist/src/auth/store.js +21 -129
  51. package/dist/src/auth/types.d.ts +0 -8
  52. package/dist/src/auth-commands.d.ts +0 -5
  53. package/dist/src/auth-commands.js +0 -1
  54. package/dist/src/automation-runner.d.ts +0 -9
  55. package/dist/src/automation-runner.js +0 -11
  56. package/dist/src/automation-service.d.ts +0 -10
  57. package/dist/src/automation-service.js +3 -17
  58. package/dist/src/automation-tool.js +0 -5
  59. package/dist/src/automation-worker-shutdown.d.ts +0 -1
  60. package/dist/src/automation-worker-shutdown.js +0 -3
  61. package/dist/src/automations.d.ts +23 -2
  62. package/dist/src/automations.js +91 -12
  63. package/dist/src/background-tasks.d.ts +0 -23
  64. package/dist/src/background-tasks.js +0 -11
  65. package/dist/src/boot-trace.d.ts +0 -13
  66. package/dist/src/boot-trace.js +1 -14
  67. package/dist/src/browser-activity.js +0 -2
  68. package/dist/src/browser-bridge.d.ts +0 -2
  69. package/dist/src/browser-bridge.js +0 -27
  70. package/dist/src/browser-captcha-tool.d.ts +0 -13
  71. package/dist/src/browser-captcha-tool.js +3 -35
  72. package/dist/src/browser-extensions-tool.d.ts +24 -0
  73. package/dist/src/browser-extensions-tool.js +137 -0
  74. package/dist/src/browser-extensions.d.ts +127 -0
  75. package/dist/src/browser-extensions.js +729 -0
  76. package/dist/src/browser-observation.d.ts +0 -15
  77. package/dist/src/browser-observation.js +1 -22
  78. package/dist/src/browser-panel-tool.d.ts +10 -25
  79. package/dist/src/browser-panel-tool.js +64 -60
  80. package/dist/src/browser-runner.d.ts +0 -1
  81. package/dist/src/browser-runner.js +7 -46
  82. package/dist/src/browser-server.d.ts +0 -6
  83. package/dist/src/browser-server.js +6 -229
  84. package/dist/src/browser-session.d.ts +0 -25
  85. package/dist/src/browser-session.js +1 -71
  86. package/dist/src/browser-stealth.d.ts +0 -12
  87. package/dist/src/browser-stealth.js +0 -36
  88. package/dist/src/browser-ui/app.js +7 -174
  89. package/dist/src/browser-ui/style.css +0 -68
  90. package/dist/src/browser-ui/tokens.css +11 -93
  91. package/dist/src/browser-view.d.ts +52 -290
  92. package/dist/src/browser-view.js +354 -567
  93. package/dist/src/capabilities.d.ts +0 -8
  94. package/dist/src/capabilities.js +0 -29
  95. package/dist/src/capsolver.d.ts +0 -13
  96. package/dist/src/capsolver.js +0 -15
  97. package/dist/src/clarification-ui.d.ts +0 -7
  98. package/dist/src/clarification-ui.js +0 -8
  99. package/dist/src/claude-executable.d.ts +0 -1
  100. package/dist/src/claude-executable.js +1 -2
  101. package/dist/src/claude-provider.d.ts +6 -19
  102. package/dist/src/claude-provider.js +166 -61
  103. package/dist/src/cli-executable.d.ts +0 -16
  104. package/dist/src/cli-executable.js +0 -7
  105. package/dist/src/cli-process.d.ts +0 -26
  106. package/dist/src/cli-process.js +0 -18
  107. package/dist/src/cli-sign-in.d.ts +0 -20
  108. package/dist/src/cli-sign-in.js +1 -17
  109. package/dist/src/cli.d.ts +3 -56
  110. package/dist/src/cli.js +193 -702
  111. package/dist/src/code-intelligence/CodeIntelligenceManager.d.ts +4 -59
  112. package/dist/src/code-intelligence/CodeIntelligenceManager.js +27 -100
  113. package/dist/src/code-intelligence/ContextLedger.d.ts +0 -4
  114. package/dist/src/code-intelligence/ContextLedger.js +0 -10
  115. package/dist/src/code-intelligence/ContextRouter.d.ts +0 -6
  116. package/dist/src/code-intelligence/ContextRouter.js +0 -8
  117. package/dist/src/code-intelligence/codegraph/CodeGraphProjectSession.d.ts +0 -2
  118. package/dist/src/code-intelligence/codegraph/CodeGraphProjectSession.js +5 -12
  119. package/dist/src/code-intelligence/codegraph/CodeGraphProvider.d.ts +0 -6
  120. package/dist/src/code-intelligence/codegraph/CodeGraphProvider.js +0 -6
  121. package/dist/src/code-intelligence/codegraph/CodeGraphSyncBarrier.d.ts +0 -5
  122. package/dist/src/code-intelligence/codegraph/CodeGraphSyncBarrier.js +1 -17
  123. package/dist/src/code-intelligence/codegraph/repoExploreTool.d.ts +0 -5
  124. package/dist/src/code-intelligence/codegraph/repoExploreTool.js +0 -5
  125. package/dist/src/code-intelligence/repository.d.ts +0 -9
  126. package/dist/src/code-intelligence/repository.js +1 -11
  127. package/dist/src/code-intelligence/types.d.ts +0 -8
  128. package/dist/src/codex-auth.d.ts +0 -44
  129. package/dist/src/codex-auth.js +0 -45
  130. package/dist/src/codex-browser-auth.d.ts +0 -13
  131. package/dist/src/codex-browser-auth.js +3 -20
  132. package/dist/src/codex-errors.js +0 -2
  133. package/dist/src/codex-executable.d.ts +0 -2
  134. package/dist/src/codex-executable.js +1 -7
  135. package/dist/src/codex-provider.d.ts +0 -13
  136. package/dist/src/codex-provider.js +1 -26
  137. package/dist/src/codex-rpc.d.ts +0 -10
  138. package/dist/src/codex-rpc.js +0 -12
  139. package/dist/src/coding-tools.d.ts +6 -27
  140. package/dist/src/coding-tools.js +193 -205
  141. package/dist/src/command-metrics.d.ts +0 -4
  142. package/dist/src/command-output-tap.d.ts +0 -11
  143. package/dist/src/command-output-tap.js +0 -3
  144. package/dist/src/command-screens.d.ts +24 -0
  145. package/dist/src/command-screens.js +132 -100
  146. package/dist/src/commands.d.ts +6 -63
  147. package/dist/src/commands.js +20 -100
  148. package/dist/src/completion-gates.d.ts +0 -47
  149. package/dist/src/completion-gates.js +0 -14
  150. package/dist/src/completion.d.ts +2 -58
  151. package/dist/src/completion.js +90 -186
  152. package/dist/src/config.d.ts +12 -116
  153. package/dist/src/config.js +41 -171
  154. package/dist/src/context-budget.d.ts +0 -22
  155. package/dist/src/context-budget.js +0 -44
  156. package/dist/src/context-compaction.d.ts +29 -6
  157. package/dist/src/context-compaction.js +94 -25
  158. package/dist/src/context-selection.d.ts +0 -24
  159. package/dist/src/context-selection.js +0 -34
  160. package/dist/src/dashboard-view.d.ts +0 -2
  161. package/dist/src/dashboard-view.js +0 -35
  162. package/dist/src/dashboard.d.ts +0 -2
  163. package/dist/src/dashboard.js +0 -9
  164. package/dist/src/deadline.d.ts +0 -45
  165. package/dist/src/deadline.js +0 -54
  166. package/dist/src/decision/ContinuationAdapter.d.ts +0 -5
  167. package/dist/src/decision/ContinuationAdapter.js +0 -5
  168. package/dist/src/decision/DecisionEngine.d.ts +0 -4
  169. package/dist/src/decision/DecisionManager.d.ts +0 -1
  170. package/dist/src/decision/DecisionManager.js +2 -7
  171. package/dist/src/decision/DecisionPolicy.d.ts +0 -1
  172. package/dist/src/decision/DecisionPolicy.js +0 -1
  173. package/dist/src/decision/FactContinuations.d.ts +11 -43
  174. package/dist/src/decision/FactContinuations.js +126 -95
  175. package/dist/src/decision/FactServiceGate.d.ts +0 -1
  176. package/dist/src/decision/FactServiceGate.js +0 -4
  177. package/dist/src/decision/PreparedSteps.d.ts +0 -15
  178. package/dist/src/decision/PreparedSteps.js +1 -11
  179. package/dist/src/decision/applyToolMenu.d.ts +0 -1
  180. package/dist/src/decision/applyToolMenu.js +1 -5
  181. package/dist/src/decision/checks.d.ts +15 -28
  182. package/dist/src/decision/checks.js +118 -49
  183. package/dist/src/decision/facts.d.ts +0 -16
  184. package/dist/src/decision/facts.js +0 -30
  185. package/dist/src/decision/guidancePolicy.js +0 -1
  186. package/dist/src/decision/hostedPolicy.d.ts +0 -6
  187. package/dist/src/decision/hostedPolicy.js +0 -7
  188. package/dist/src/decision/hostedSkills.d.ts +0 -19
  189. package/dist/src/decision/hostedSkills.js +0 -19
  190. package/dist/src/decision/optimizationPolicy.d.ts +0 -3
  191. package/dist/src/decision/optimizationPolicy.js +1 -4
  192. package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +0 -7
  193. package/dist/src/decision/providers/AndorraDecisionProvider.js +4 -27
  194. package/dist/src/decision/providers/HttpDecisionProvider.d.ts +0 -2
  195. package/dist/src/decision/providers/HttpDecisionProvider.js +0 -6
  196. package/dist/src/decision/routeTools.d.ts +0 -8
  197. package/dist/src/decision/routeTools.js +1 -8
  198. package/dist/src/decision/toolFamilies.d.ts +0 -1
  199. package/dist/src/decision/toolFamilies.js +0 -1
  200. package/dist/src/decision/toolMenu.d.ts +0 -3
  201. package/dist/src/decision/toolMenu.js +0 -4
  202. package/dist/src/decision/types.d.ts +0 -6
  203. package/dist/src/default-graph.d.ts +0 -9
  204. package/dist/src/default-graph.js +0 -9
  205. package/dist/src/delegation-changes.d.ts +0 -56
  206. package/dist/src/delegation-changes.js +15 -124
  207. package/dist/src/diff-preview.d.ts +1 -1
  208. package/dist/src/diff-preview.js +4 -12
  209. package/dist/src/duration.d.ts +0 -50
  210. package/dist/src/duration.js +0 -50
  211. package/dist/src/efficiency.d.ts +0 -39
  212. package/dist/src/efficiency.js +0 -16
  213. package/dist/src/engine/protocol.d.ts +0 -2
  214. package/dist/src/engine/protocol.js +0 -2
  215. package/dist/src/engine-streams.d.ts +13 -0
  216. package/dist/src/engine-streams.js +16 -0
  217. package/dist/src/extensions.d.ts +3 -2
  218. package/dist/src/extensions.js +76 -37
  219. package/dist/src/favicons.d.ts +0 -26
  220. package/dist/src/favicons.js +0 -34
  221. package/dist/src/file-diff.d.ts +2 -58
  222. package/dist/src/file-diff.js +0 -32
  223. package/dist/src/file-read-key.d.ts +1 -0
  224. package/dist/src/file-read-key.js +5 -0
  225. package/dist/src/file-read-state.d.ts +0 -1
  226. package/dist/src/file-read-state.js +0 -4
  227. package/dist/src/firefox-cookies.d.ts +0 -34
  228. package/dist/src/firefox-cookies.js +1 -55
  229. package/dist/src/git-identity-audit.d.ts +27 -0
  230. package/dist/src/git-identity-audit.js +286 -0
  231. package/dist/src/git-identity-guard.d.ts +4 -0
  232. package/dist/src/git-identity-guard.js +998 -0
  233. package/dist/src/git-identity-hold.d.ts +12 -0
  234. package/dist/src/git-identity-hold.js +81 -0
  235. package/dist/src/git-summary.d.ts +0 -58
  236. package/dist/src/git-summary.js +2 -212
  237. package/dist/src/goal-completion-verification.d.ts +2 -2
  238. package/dist/src/goal-completion-verification.js +3 -6
  239. package/dist/src/graph-account.d.ts +0 -21
  240. package/dist/src/graph-account.js +0 -17
  241. package/dist/src/graph-editor-session.d.ts +0 -1
  242. package/dist/src/graph-editor-session.js +1 -3
  243. package/dist/src/graph-health.d.ts +7 -49
  244. package/dist/src/graph-health.js +35 -46
  245. package/dist/src/graph-manager-chat.d.ts +27 -128
  246. package/dist/src/graph-manager-chat.js +36 -166
  247. package/dist/src/graph-provider-portability.d.ts +1 -21
  248. package/dist/src/graph-provider-portability.js +6 -45
  249. package/dist/src/graph-quota.d.ts +0 -33
  250. package/dist/src/graph-quota.js +1 -44
  251. package/dist/src/graph-runner.d.ts +0 -1
  252. package/dist/src/graph-runner.js +47 -387
  253. package/dist/src/graph-selection.d.ts +0 -14
  254. package/dist/src/graph-selection.js +0 -14
  255. package/dist/src/graph-server.d.ts +3 -11
  256. package/dist/src/graph-server.js +70 -111
  257. package/dist/src/graph-studio-features.d.ts +0 -5
  258. package/dist/src/graph-studio-features.js +2 -42
  259. package/dist/src/graph-sync.d.ts +0 -78
  260. package/dist/src/graph-sync.js +5 -201
  261. package/dist/src/graph-tool.d.ts +0 -18
  262. package/dist/src/graph-tool.js +0 -27
  263. package/dist/src/graph-ui/app.js +229 -498
  264. package/dist/src/graph-ui/compat.js +0 -7
  265. package/dist/src/graph-ui/controls.css +47 -43
  266. package/dist/src/graph-ui/controls.js +0 -88
  267. package/dist/src/graph-ui/drafts.js +0 -12
  268. package/dist/src/graph-ui/edge-router.js +0 -62
  269. package/dist/src/graph-ui/embed.js +0 -59
  270. package/dist/src/graph-ui/icons.js +2 -7
  271. package/dist/src/graph-ui/index.html +2 -2
  272. package/dist/src/graph-ui/library.css +0 -5
  273. package/dist/src/graph-ui/manager-markdown.js +0 -11
  274. package/dist/src/graph-ui/manager-state.js +110 -49
  275. package/dist/src/graph-ui/manager.css +2 -20
  276. package/dist/src/graph-ui/manager.js +251 -166
  277. package/dist/src/graph-ui/model-picker.js +250 -0
  278. package/dist/src/graph-ui/provider-glyphs/alibaba-cloud.png +0 -0
  279. package/dist/src/graph-ui/provider-glyphs/anthropic.png +0 -0
  280. package/dist/src/graph-ui/provider-glyphs/aws-bedrock.png +0 -0
  281. package/dist/src/graph-ui/provider-glyphs/claude.png +0 -0
  282. package/dist/src/graph-ui/provider-glyphs/deepseek.png +0 -0
  283. package/dist/src/graph-ui/provider-glyphs/fireworks.png +0 -0
  284. package/dist/src/graph-ui/provider-glyphs/kimi.png +0 -0
  285. package/dist/src/graph-ui/provider-glyphs/minimax.png +0 -0
  286. package/dist/src/graph-ui/provider-glyphs/openai.png +0 -0
  287. package/dist/src/graph-ui/provider-glyphs/opencode.png +0 -0
  288. package/dist/src/graph-ui/provider-glyphs/openrouter.png +0 -0
  289. package/dist/src/graph-ui/provider-glyphs/xai.png +0 -0
  290. package/dist/src/graph-ui/provider-glyphs/xiaomi-mimo.png +0 -0
  291. package/dist/src/graph-ui/provider-glyphs/zai.png +0 -0
  292. package/dist/src/graph-ui/sidebar.js +2 -3
  293. package/dist/src/graph-ui/skill-picker.js +373 -39
  294. package/dist/src/graph-ui/studio-canvas.js +3 -38
  295. package/dist/src/graph-ui/studio.css +0 -18
  296. package/dist/src/graph-ui/studio.js +3 -71
  297. package/dist/src/graph-ui/style.css +11 -134
  298. package/dist/src/graph-ui/theme.js +1 -26
  299. package/dist/src/graph-ui/tokens.css +15 -114
  300. package/dist/src/graphs.d.ts +7 -156
  301. package/dist/src/graphs.js +72 -273
  302. package/dist/src/grep-regex-worker.js +0 -2
  303. package/dist/src/grep-regex.d.ts +1 -5
  304. package/dist/src/grep-regex.js +6 -8
  305. package/dist/src/grok-provider.d.ts +0 -17
  306. package/dist/src/grok-provider.js +1 -26
  307. package/dist/src/handoffs.d.ts +0 -11
  308. package/dist/src/handoffs.js +0 -13
  309. package/dist/src/hardened-runtime.d.ts +0 -10
  310. package/dist/src/hardened-runtime.js +8 -46
  311. package/dist/src/harness-home.d.ts +21 -0
  312. package/dist/src/harness-home.js +87 -0
  313. package/dist/src/host-process-guard.d.ts +0 -50
  314. package/dist/src/host-process-guard.js +0 -641
  315. package/dist/src/limits.d.ts +0 -64
  316. package/dist/src/limits.js +0 -62
  317. package/dist/src/managed-sign-in.d.ts +0 -12
  318. package/dist/src/managed-sign-in.js +0 -16
  319. package/dist/src/markdown.d.ts +0 -28
  320. package/dist/src/markdown.js +1 -175
  321. package/dist/src/mcp.d.ts +21 -82
  322. package/dist/src/mcp.js +228 -237
  323. package/dist/src/membership-errors.d.ts +0 -14
  324. package/dist/src/membership-errors.js +0 -13
  325. package/dist/src/membership.d.ts +2 -60
  326. package/dist/src/membership.js +0 -85
  327. package/dist/src/memory/LocalToolMemory.d.ts +0 -1
  328. package/dist/src/memory/LocalToolMemory.js +2 -7
  329. package/dist/src/memory/MemoryDistiller.js +0 -15
  330. package/dist/src/memory/MemoryManager.d.ts +0 -3
  331. package/dist/src/memory/MemoryManager.js +6 -18
  332. package/dist/src/memory/MemoryPolicy.d.ts +0 -2
  333. package/dist/src/memory/MemoryPolicy.js +0 -2
  334. package/dist/src/memory/MemoryProvider.d.ts +0 -6
  335. package/dist/src/memory/MemoryRetriever.js +0 -7
  336. package/dist/src/memory/PermissionMemoryProvider.d.ts +0 -1
  337. package/dist/src/memory/PermissionMemoryProvider.js +0 -1
  338. package/dist/src/memory/ProjectMemory.d.ts +42 -0
  339. package/dist/src/memory/ProjectMemory.js +285 -0
  340. package/dist/src/memory/ToolFailureLessons.d.ts +0 -3
  341. package/dist/src/memory/ToolFailureLessons.js +0 -6
  342. package/dist/src/memory/index.d.ts +1 -0
  343. package/dist/src/memory/index.js +1 -0
  344. package/dist/src/memory/providers/NoOpMemoryProvider.d.ts +0 -1
  345. package/dist/src/memory/providers/NoOpMemoryProvider.js +0 -1
  346. package/dist/src/memory/redaction.d.ts +0 -5
  347. package/dist/src/memory/redaction.js +0 -11
  348. package/dist/src/memory/repository.d.ts +0 -6
  349. package/dist/src/memory/repository.js +2 -12
  350. package/dist/src/memory/types.d.ts +0 -1
  351. package/dist/src/model-health-cache.d.ts +0 -38
  352. package/dist/src/model-health-cache.js +1 -49
  353. package/dist/src/model-metadata.d.ts +0 -18
  354. package/dist/src/model-metadata.js +2 -42
  355. package/dist/src/model-override.d.ts +0 -36
  356. package/dist/src/model-override.js +0 -43
  357. package/dist/src/model-tiers.d.ts +0 -13
  358. package/dist/src/model-tiers.js +0 -23
  359. package/dist/src/opencode-catalog.d.ts +0 -2
  360. package/dist/src/opencode-catalog.js +0 -11
  361. package/dist/src/opencode-cli-provider.d.ts +0 -35
  362. package/dist/src/opencode-cli-provider.js +1 -44
  363. package/dist/src/opencode-provider.d.ts +0 -2
  364. package/dist/src/opencode-provider.js +6 -22
  365. package/dist/src/package-name.d.ts +1 -0
  366. package/dist/src/package-name.js +1 -0
  367. package/dist/src/paged-transcript.d.ts +0 -11
  368. package/dist/src/paged-transcript.js +2 -20
  369. package/dist/src/palette.d.ts +0 -63
  370. package/dist/src/palette.js +0 -63
  371. package/dist/src/permissions.d.ts +0 -15
  372. package/dist/src/permissions.js +0 -17
  373. package/dist/src/powershell-pool.d.ts +0 -9
  374. package/dist/src/powershell-pool.js +3 -26
  375. package/dist/src/process-warnings.d.ts +4 -0
  376. package/dist/src/process-warnings.js +103 -0
  377. package/dist/src/profile.d.ts +0 -43
  378. package/dist/src/profile.js +0 -43
  379. package/dist/src/project-reservation.d.ts +11 -0
  380. package/dist/src/project-reservation.js +143 -0
  381. package/dist/src/provider-connection.d.ts +0 -18
  382. package/dist/src/provider-connection.js +0 -39
  383. package/dist/src/provider-engine.d.ts +0 -21
  384. package/dist/src/provider-engine.js +3 -98
  385. package/dist/src/provider-import.d.ts +0 -49
  386. package/dist/src/provider-import.js +0 -60
  387. package/dist/src/provider-keys.d.ts +1 -36
  388. package/dist/src/provider-keys.js +5 -48
  389. package/dist/src/provider-settings.d.ts +0 -2
  390. package/dist/src/provider-settings.js +0 -32
  391. package/dist/src/providers.d.ts +0 -217
  392. package/dist/src/providers.js +0 -315
  393. package/dist/src/pull-requests.d.ts +0 -173
  394. package/dist/src/pull-requests.js +5 -195
  395. package/dist/src/qa/browser/PlaywrightRunner.d.ts +0 -7
  396. package/dist/src/qa/browser/PlaywrightRunner.js +2 -16
  397. package/dist/src/qa/command-policy.d.ts +0 -23
  398. package/dist/src/qa/command-policy.js +0 -30
  399. package/dist/src/qa/guidance.d.ts +0 -21
  400. package/dist/src/qa/guidance.js +0 -20
  401. package/dist/src/qa/profile/ProjectInspector.d.ts +0 -4
  402. package/dist/src/qa/profile/ProjectInspector.js +0 -6
  403. package/dist/src/qa/profile/QaConfigLoader.d.ts +0 -7
  404. package/dist/src/qa/profile/QaConfigLoader.js +0 -6
  405. package/dist/src/qa/profile/QaProfile.d.ts +0 -7
  406. package/dist/src/qa/profile/QaProfile.js +0 -7
  407. package/dist/src/qa/profile/yaml.d.ts +0 -9
  408. package/dist/src/qa/profile/yaml.js +0 -13
  409. package/dist/src/qa/qa-authorize.d.ts +0 -19
  410. package/dist/src/qa/qa-authorize.js +4 -11
  411. package/dist/src/qa/runtime/ProcessManager.d.ts +0 -31
  412. package/dist/src/qa/runtime/ProcessManager.js +4 -41
  413. package/dist/src/qa/runtime/PtyManager.d.ts +0 -4
  414. package/dist/src/qa/runtime/PtyManager.js +2 -7
  415. package/dist/src/qa/runtime/changes.d.ts +0 -11
  416. package/dist/src/qa/runtime/changes.js +1 -3
  417. package/dist/src/qa/tools.d.ts +0 -10
  418. package/dist/src/qa/tools.js +0 -12
  419. package/dist/src/qa/types.d.ts +0 -13
  420. package/dist/src/react-runtime.d.ts +2 -21
  421. package/dist/src/react-runtime.js +106 -418
  422. package/dist/src/read-document-doc.d.ts +0 -6
  423. package/dist/src/read-document-doc.js +0 -55
  424. package/dist/src/read-document-docx.d.ts +0 -16
  425. package/dist/src/read-document-docx.js +2 -69
  426. package/dist/src/read-document-text.d.ts +0 -17
  427. package/dist/src/read-document-text.js +0 -22
  428. package/dist/src/read-document-tool.d.ts +0 -31
  429. package/dist/src/read-document-tool.js +0 -30
  430. package/dist/src/read-document.d.ts +0 -49
  431. package/dist/src/read-document.js +1 -67
  432. package/dist/src/read-image.d.ts +0 -32
  433. package/dist/src/read-image.js +0 -33
  434. package/dist/src/remote/cert.d.ts +1 -19
  435. package/dist/src/remote/cert.js +2 -51
  436. package/dist/src/remote/client.d.ts +0 -70
  437. package/dist/src/remote/client.js +2 -117
  438. package/dist/src/remote/command.js +0 -17
  439. package/dist/src/remote/engine-pool.d.ts +0 -152
  440. package/dist/src/remote/engine-pool.js +17 -335
  441. package/dist/src/remote/errors.d.ts +0 -15
  442. package/dist/src/remote/errors.js +0 -7
  443. package/dist/src/remote/network.d.ts +0 -26
  444. package/dist/src/remote/network.js +1 -34
  445. package/dist/src/remote/pairing.d.ts +16 -51
  446. package/dist/src/remote/pairing.js +50 -57
  447. package/dist/src/remote/pem.d.ts +2 -0
  448. package/dist/src/remote/pem.js +7 -0
  449. package/dist/src/remote/roots.d.ts +0 -20
  450. package/dist/src/remote/roots.js +0 -8
  451. package/dist/src/remote/serve.d.ts +0 -47
  452. package/dist/src/remote/serve.js +0 -30
  453. package/dist/src/remote/server.d.ts +0 -14
  454. package/dist/src/remote/server.js +1 -79
  455. package/dist/src/remote/types.d.ts +1 -32
  456. package/dist/src/remote/types.js +0 -10
  457. package/dist/src/run-control.d.ts +0 -7
  458. package/dist/src/run-control.js +0 -7
  459. package/dist/src/run-progress.d.ts +0 -170
  460. package/dist/src/run-progress.js +0 -285
  461. package/dist/src/run-records.d.ts +0 -443
  462. package/dist/src/run-records.js +44 -678
  463. package/dist/src/run-temp.d.ts +12 -0
  464. package/dist/src/run-temp.js +50 -0
  465. package/dist/src/runtime.d.ts +11 -227
  466. package/dist/src/runtime.js +0 -127
  467. package/dist/src/sandbox-child.js +0 -1
  468. package/dist/src/save-lock.d.ts +0 -12
  469. package/dist/src/save-lock.js +0 -28
  470. package/dist/src/screen-selection.d.ts +0 -23
  471. package/dist/src/screen-selection.js +0 -22
  472. package/dist/src/secret-redaction.d.ts +0 -12
  473. package/dist/src/secret-redaction.js +0 -45
  474. package/dist/src/session-changes.d.ts +4 -80
  475. package/dist/src/session-changes.js +25 -130
  476. package/dist/src/session-goal.d.ts +129 -0
  477. package/dist/src/session-goal.js +230 -0
  478. package/dist/src/session-monitor.d.ts +1 -10
  479. package/dist/src/session-monitor.js +2 -39
  480. package/dist/src/session-reaper.d.ts +0 -15
  481. package/dist/src/session-reaper.js +0 -14
  482. package/dist/src/session-skills.d.ts +15 -44
  483. package/dist/src/session-skills.js +75 -60
  484. package/dist/src/session-summary.d.ts +0 -26
  485. package/dist/src/session-summary.js +0 -32
  486. package/dist/src/session-title.d.ts +0 -1
  487. package/dist/src/session-title.js +0 -2
  488. package/dist/src/sessions.d.ts +2 -120
  489. package/dist/src/sessions.js +9 -178
  490. package/dist/src/shell.d.ts +3 -20
  491. package/dist/src/shell.js +8 -72
  492. package/dist/src/side-panel.d.ts +5 -99
  493. package/dist/src/side-panel.js +76 -133
  494. package/dist/src/sign-in-detection.d.ts +43 -0
  495. package/dist/src/sign-in-detection.js +154 -0
  496. package/dist/src/sign-in-offer.d.ts +17 -0
  497. package/dist/src/sign-in-offer.js +103 -0
  498. package/dist/src/skill-commands.d.ts +0 -1
  499. package/dist/src/skill-commands.js +1 -4
  500. package/dist/src/skills/bundled/control-browser/SKILL.md +1 -1
  501. package/dist/src/skills/bundled/graph-manager/SKILL.md +22 -4
  502. package/dist/src/skills/bundled/provenance.json +2 -2
  503. package/dist/src/skills/invocable-skills.d.ts +0 -18
  504. package/dist/src/skills/invocable-skills.js +0 -17
  505. package/dist/src/skills/project-skills.d.ts +0 -1
  506. package/dist/src/skills/project-skills.js +0 -3
  507. package/dist/src/skills/prompt-skills.js +0 -14
  508. package/dist/src/skills/runtime-skills.d.ts +1 -8
  509. package/dist/src/skills/runtime-skills.js +8 -32
  510. package/dist/src/stall-recovery.d.ts +0 -25
  511. package/dist/src/stall-recovery.js +0 -38
  512. package/dist/src/stray-files.d.ts +5 -0
  513. package/dist/src/stray-files.js +65 -0
  514. package/dist/src/structured-step.d.ts +0 -22
  515. package/dist/src/structured-step.js +0 -22
  516. package/dist/src/subagent-run.d.ts +0 -163
  517. package/dist/src/subagent-run.js +10 -374
  518. package/dist/src/subagent-tree.d.ts +32 -0
  519. package/dist/src/subagent-tree.js +128 -0
  520. package/dist/src/telemetry/aggregate.d.ts +0 -37
  521. package/dist/src/telemetry/aggregate.js +0 -40
  522. package/dist/src/telemetry/capture-core.d.ts +0 -87
  523. package/dist/src/telemetry/capture-core.js +0 -67
  524. package/dist/src/telemetry/capture.d.ts +0 -1
  525. package/dist/src/telemetry/capture.js +0 -3
  526. package/dist/src/telemetry/classify.d.ts +0 -58
  527. package/dist/src/telemetry/classify.js +0 -60
  528. package/dist/src/telemetry/decision-capture.d.ts +0 -1
  529. package/dist/src/telemetry/emitter.d.ts +0 -30
  530. package/dist/src/telemetry/emitter.js +1 -62
  531. package/dist/src/telemetry/gate.d.ts +0 -29
  532. package/dist/src/telemetry/gate.js +0 -22
  533. package/dist/src/telemetry/identity.d.ts +0 -13
  534. package/dist/src/telemetry/identity.js +0 -29
  535. package/dist/src/telemetry/outbox.d.ts +0 -64
  536. package/dist/src/telemetry/outbox.js +1 -108
  537. package/dist/src/telemetry/schema.d.ts +1 -49
  538. package/dist/src/telemetry/schema.js +1 -82
  539. package/dist/src/telemetry/state.d.ts +0 -53
  540. package/dist/src/telemetry/state.js +0 -64
  541. package/dist/src/telemetry/surface.d.ts +0 -31
  542. package/dist/src/telemetry/surface.js +1 -39
  543. package/dist/src/telemetry/uploader.d.ts +0 -11
  544. package/dist/src/telemetry/uploader.js +0 -46
  545. package/dist/src/telemetry/uploads.d.ts +0 -11
  546. package/dist/src/telemetry/uploads.js +0 -11
  547. package/dist/src/telemetry/version.d.ts +0 -4
  548. package/dist/src/telemetry/version.js +0 -14
  549. package/dist/src/telemetry/workspace.d.ts +0 -7
  550. package/dist/src/telemetry/workspace.js +1 -22
  551. package/dist/src/terminal-ui.d.ts +15 -524
  552. package/dist/src/terminal-ui.js +80 -876
  553. package/dist/src/test-edit-guard.d.ts +74 -0
  554. package/dist/src/test-edit-guard.js +269 -0
  555. package/dist/src/text.d.ts +0 -1
  556. package/dist/src/text.js +0 -1
  557. package/dist/src/time-limit.d.ts +0 -36
  558. package/dist/src/time-limit.js +0 -37
  559. package/dist/src/timers.d.ts +0 -161
  560. package/dist/src/timers.js +0 -126
  561. package/dist/src/todos.d.ts +0 -1
  562. package/dist/src/todos.js +0 -3
  563. package/dist/src/token-rate.d.ts +0 -94
  564. package/dist/src/token-rate.js +0 -154
  565. package/dist/src/tool-activity.d.ts +0 -6
  566. package/dist/src/tool-activity.js +1 -8
  567. package/dist/src/tool-availability.d.ts +0 -13
  568. package/dist/src/tool-availability.js +1 -14
  569. package/dist/src/tool-call-clock.d.ts +1 -4
  570. package/dist/src/tool-call-clock.js +0 -13
  571. package/dist/src/tool-catalog.d.ts +0 -11
  572. package/dist/src/tool-catalog.js +0 -23
  573. package/dist/src/tool-dependencies.d.ts +0 -5
  574. package/dist/src/tool-dependencies.js +0 -4
  575. package/dist/src/tool-diff-stats.d.ts +0 -23
  576. package/dist/src/tool-diff-stats.js +0 -49
  577. package/dist/src/tool-errors.d.ts +9 -7
  578. package/dist/src/tool-errors.js +13 -6
  579. package/dist/src/tool-failure-tracker.d.ts +3 -11
  580. package/dist/src/tool-failure-tracker.js +19 -27
  581. package/dist/src/tool-names.d.ts +0 -16
  582. package/dist/src/tool-names.js +0 -12
  583. package/dist/src/tool-profile.d.ts +6 -0
  584. package/dist/src/tool-profile.js +23 -0
  585. package/dist/src/tool-result-filter.d.ts +0 -19
  586. package/dist/src/tool-result-filter.js +1 -66
  587. package/dist/src/tool-schema-compatibility.d.ts +1 -2
  588. package/dist/src/tool-schema-compatibility.js +2 -7
  589. package/dist/src/tools.d.ts +0 -4
  590. package/dist/src/tools.js +11 -114
  591. package/dist/src/trajectory.d.ts +0 -13
  592. package/dist/src/trajectory.js +23 -79
  593. package/dist/src/transcript.d.ts +1 -37
  594. package/dist/src/transcript.js +11 -61
  595. package/dist/src/types.d.ts +2 -167
  596. package/dist/src/untracked-file-removal.d.ts +3 -0
  597. package/dist/src/untracked-file-removal.js +105 -0
  598. package/dist/src/update-check.d.ts +0 -14
  599. package/dist/src/update-check.js +2 -16
  600. package/dist/src/update.d.ts +4 -29
  601. package/dist/src/update.js +20 -98
  602. package/dist/src/usage-analytics.d.ts +17 -17
  603. package/dist/src/usage-analytics.js +168 -209
  604. package/dist/src/web-search.d.ts +0 -23
  605. package/dist/src/web-search.js +1 -27
  606. package/dist/src/widgets.d.ts +0 -25
  607. package/dist/src/widgets.js +0 -24
  608. package/dist/src/workspace-facts.d.ts +0 -12
  609. package/dist/src/workspace-facts.js +1 -18
  610. package/dist/src/workspace-git-metadata.d.ts +4 -5
  611. package/dist/src/workspace-git-metadata.js +37 -9
  612. package/dist/src/workspace-instructions.d.ts +3 -15
  613. package/dist/src/workspace-instructions.js +7 -20
  614. package/package.json +2 -2
@@ -11,12 +11,12 @@ import { createRunTelemetry, recordModelUse } from './telemetry/capture.js';
11
11
  import { checkGraphModelHealth } from './graph-health.js';
12
12
  import { validateGraph } from './graphs.js';
13
13
  import { runGraph } from './runtime.js';
14
- import { createTools } from './tools.js';
15
- import { loadWorkspaceInstructions } from './workspace-instructions.js';
16
- import { extensionSnapshot } from './extensions.js';
14
+ import { loadWorkspaceInstructions, systemPromptOverrideFor } from './workspace-instructions.js';
15
+ import { effectiveExtensionConfig, extensionSnapshot } from './extensions.js';
17
16
  import { resolveModelContext } from './model-metadata.js';
18
17
  import { MemoryManager } from './memory/MemoryManager.js';
19
18
  import { LocalToolMemory } from './memory/LocalToolMemory.js';
19
+ import { ProjectMemory } from './memory/ProjectMemory.js';
20
20
  import { ArtifactStore } from './artifacts.js';
21
21
  import { CodeIntelligenceManager } from './code-intelligence/CodeIntelligenceManager.js';
22
22
  import { DecisionManager } from './decision/DecisionManager.js';
@@ -24,46 +24,12 @@ import { permissionMode } from './permissions.js';
24
24
  import { TodoStore } from './todos.js';
25
25
  import { claimProcessWorkspace, clearOpenRunClaim, createCheckpointFailureTracker, createRunJournalWriter, releaseProcessWorkspace, removeOpenRunRecord, removeRunCheckpoint, repairSessionMarkers, RUNNING_TURN_SUMMARY, runRecordPath, summaryForStoppedRecord, writeOpenRunRecord, writeRunCheckpoint, writeStudioRunSummary } from './run-records.js';
26
26
  import { SessionStore, projectIdentity, sessionName } from './sessions.js';
27
- /**
28
- * External subagent mode: the only graph an external host (Claude CLI, Codex CLI) may run.
29
- *
30
- * The restriction is structural — the id is a constant here, never a parameter on any surface —
31
- * and the id is `default`, which `loadAccessibleGraph` resolves to the bundled single-agent
32
- * Andorra Agent harness: no Orchestrator intake, no per-node provider pins, no account
33
- * membership. That is what makes a one-shot external run headless-safe and lets the caller's
34
- * provider/model choice reach every request the run makes.
35
- */
36
27
  export const SUBAGENT_GRAPH_ID = 'default';
37
- /**
38
- * The longest task a subagent run accepts.
39
- *
40
- * The bound is the engine's own, and it is enforced here rather than in each entry point: a task
41
- * this long is not a task a host meant to ask for, and it is persisted and turned into model
42
- * context before anything else looks at it. Every surface that starts a run goes through this
43
- * check, so the CLI and the MCP tools refuse the same task the same way.
44
- */
45
28
  export const MAX_SUBAGENT_TASK_CHARS = 100_000;
46
- /**
47
- * The longest model identifier a subagent run accepts.
48
- *
49
- * It is the bound the configuration holds a saved model id to, and a per-call model is held to
50
- * the same one: the value is written into the open run record and carried through the preflight
51
- * and the model resolution, so an unbounded one would fill the installation's storage and the
52
- * provider's request with what is only ever a caller's typo.
53
- */
54
29
  export const MAX_SUBAGENT_MODEL_CHARS = 500;
55
- /** A task the caller may not ask for: too long for the run to carry. */
56
30
  export class SubagentInvalidArgumentError extends Error {
57
31
  constructor(message) { super(message); this.name = 'SubagentInvalidArgumentError'; }
58
32
  }
59
- /**
60
- * The permission a caller asked for.
61
- *
62
- * The two supported modes are the whole vocabulary. A value outside them is the caller's
63
- * mistake, and answering it with `full-access` would grant the filesystem and shell mutations the
64
- * caller was trying to withhold — so it is refused instead of rounded up. An absent permission
65
- * keeps the default, which is what the CLI and the MCP wrappers mean by not naming one.
66
- */
67
33
  export function resolveSubagentPermissions(requested) {
68
34
  if (requested === undefined)
69
35
  return 'full-access';
@@ -71,14 +37,6 @@ export function resolveSubagentPermissions(requested) {
71
37
  return requested;
72
38
  throw new SubagentInvalidArgumentError(`The permission must be "read-only" or "full-access"; "${String(requested)}" is not a permission.`);
73
39
  }
74
- /**
75
- * The provider snapshot a run's own model is invoked with.
76
- *
77
- * The saved reasoning effort and context window belong to the provider's *configured* model, so a
78
- * run on a different one does not carry them: an adapter that honours them would send a
79
- * reasoning setting the model does not take, or compact against the wrong limit. The window the
80
- * provider lists for the selected model is applied instead, when it lists one.
81
- */
82
40
  function providerForModel(provider, model) {
83
41
  const selected = { ...provider, model };
84
42
  if (model !== provider.model) {
@@ -90,35 +48,15 @@ function providerForModel(provider, model) {
90
48
  selected.contextWindow = savedWindow;
91
49
  return selected;
92
50
  }
93
- /** Fold one account of spend into another. */
94
51
  function foldUsage(target, delta) {
95
52
  target.requests += delta.requests ?? 0;
96
53
  target.inputTokens += delta.inputTokens ?? 0;
97
54
  target.outputTokens += delta.outputTokens ?? 0;
98
- // Presence, not magnitude: a counter the provider reported as zero is a measurement, and a
99
- // session that is reloaded shows it as one. Only an unreported counter stays absent.
100
55
  if (delta.cacheRead !== undefined)
101
56
  target.cacheRead = (target.cacheRead ?? 0) + delta.cacheRead;
102
57
  if (delta.cacheWrite !== undefined)
103
58
  target.cacheWrite = (target.cacheWrite ?? 0) + delta.cacheWrite;
104
59
  }
105
- /**
106
- * The workspaces this process is running a subagent in.
107
- *
108
- * The reservation is process-wide rather than a runner's own: an embedded host can build several
109
- * backends — or a runner of its own — in one process, and each of them held a slot of its own,
110
- * so two full-access runs could work the same workspace at once. The unit the slot reserves is
111
- * the workspace, because that is what two overlapping runs would both write to.
112
- */
113
- /**
114
- * The workspace a run works in, resolved to a real directory.
115
- *
116
- * Both public wrappers canonicalize the path before they call the runner, and the runner is
117
- * exported for embedded use: a relative, empty or file-valued path would create the open record
118
- * and the session — and spend the health probe — before the tools failed. A relative alias would
119
- * also give one workspace two project identities, and a later resume would resolve the stored
120
- * path against whatever working directory it happened to run in.
121
- */
122
60
  export async function canonicalWorkspace(requested) {
123
61
  let resolved;
124
62
  try {
@@ -145,21 +83,6 @@ export class SubagentRunInProgressError extends Error {
145
83
  export function listSubagentProviders(config) {
146
84
  return config.providers.map(provider => ({ id: provider.id, type: provider.type, models: providerModels(provider) }));
147
85
  }
148
- /**
149
- * Resolve the provider/model a subagent run uses: the caller's explicit pick wins, the saved
150
- * `externalSubagent` setting is next, and anything else is the self-describing PROVIDER_NOT_SET
151
- * error the calling agent is expected to take back to its user.
152
- *
153
- * A per-call model is accepted on the same terms as the CLI's `--model` (any nonempty id), while
154
- * the saved setting is held to the stricter config validation: a persisted pair names a provider
155
- * that must still exist and, when the provider carries an explicit model list, a model on it.
156
- */
157
- /**
158
- * The caller named a provider or a model the installation does not have.
159
- *
160
- * It is a selection failure rather than a backend failure, so a host can tell that its own
161
- * choice was wrong and correct the identifier without a second diagnostic path.
162
- */
163
86
  export class SubagentSelectionError extends Error {
164
87
  }
165
88
  export function resolveSubagentProvider(config, call = {}) {
@@ -172,9 +95,6 @@ export function resolveSubagentProvider(config, call = {}) {
172
95
  if (typeof call.model !== 'string' || !call.model.trim()) {
173
96
  throw new SubagentSelectionError('A provider was supplied without a model. Retry with both provider and model.');
174
97
  }
175
- // The bound a configured model id is held to. A per-call model is persisted in the open run
176
- // record and carried through the preflight and the model resolution, so it is held to the
177
- // same length before any of that happens.
178
98
  if (call.model.trim().length > MAX_SUBAGENT_MODEL_CHARS) {
179
99
  throw new SubagentInvalidArgumentError(`The model must be at most ${MAX_SUBAGENT_MODEL_CHARS} characters.`);
180
100
  }
@@ -189,38 +109,12 @@ export function resolveSubagentProvider(config, call = {}) {
189
109
  throw new SubagentProviderNotSetError(listSubagentProviders(config));
190
110
  }
191
111
  const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));
192
- /**
193
- * The health failure a subagent caller is given.
194
- *
195
- * A subagent always runs the built-in Andorra Agent graph, whose node has no editable model
196
- * selection, so the ordinary remedy — edit the graph's model selections — cannot be followed. The
197
- * caller has to pick another provider and model, or repair that provider's credentials.
198
- */
199
112
  function subagentHealthFailure(health) {
200
113
  return ['The provider/model this subagent run would use is not usable:',
201
114
  ...health.failures.map(failure => `- ${failure.provider}/${failure.model}: ${failure.reason}`),
202
115
  'A subagent run always uses the built-in Andorra Agent graph, whose model is the one you picked, so there is no graph to edit: retry with another provider and model, or repair that provider credentials.',
203
116
  ].join('\n');
204
117
  }
205
- /**
206
- * One subagent run at a time per process, mirroring the engine's own one-run rule: the MCP server
207
- * is a single process, so a second start while one run is live is refused rather than queued.
208
- *
209
- * The reservation is the process's rather than this runner's, because an embedded host can build
210
- * several backends in one process: two of them would otherwise each hold a slot of their own and
211
- * work the same workspace at once. What the slot reserves is the workspace, because that is what
212
- * two overlapping runs would both write to.
213
- *
214
- * Records follow the installation's own lifecycle — an open run record before any preflight, run
215
- * events appended to `runs/<id>.jsonl`, a session record and a terminal run record on finalize —
216
- * so a crashed subagent run is classified by the same startup recovery as any other attempt and
217
- * stays visible in the Runs view instead of vanishing with its host.
218
- */
219
- /**
220
- * The decision service an external subagent run uses: the one this installation configured, never a
221
- * hosted default, and only for a signed-in account. The account is asked only when the answer could
222
- * matter, so a run with decisions off stays free of an account request.
223
- */
224
118
  export async function subagentDecisionConfig(config, membership) {
225
119
  const decisions = config.decisions;
226
120
  if (config.jevEnabled === false || !decisions || decisions.provider === 'none' || decisions.mode === 'off')
@@ -230,22 +124,11 @@ export async function subagentDecisionConfig(config, membership) {
230
124
  export class SubagentRunner {
231
125
  defaults;
232
126
  active;
233
- /** Set when the runner was shut down: a start that begins after it must not launch a run. */
234
127
  closed = false;
235
- /** A start that is preparing its run holds the slot before it is assigned. */
236
128
  starting = false;
237
- /** The workspace this runner holds the process-wide reservation for, when it holds one. */
238
129
  reservedWorkspace;
239
- /** A cancellation that arrived while the run was still starting. */
240
130
  pendingCancel = false;
241
- /** The start that is preparing a run, so a shutdown can wait for it instead of racing it. */
242
131
  startPromise;
243
- /**
244
- * This runner's identity in the process-wide workspace reservation.
245
- *
246
- * The reservation is the process's, so two runners over one workspace cannot both hold it, and
247
- * only the holder gives it back.
248
- */
249
132
  reservationId = randomUUID();
250
133
  constructor(defaults = {}) {
251
134
  this.defaults = defaults;
@@ -253,39 +136,22 @@ export class SubagentRunner {
253
136
  async start(options) {
254
137
  if (!options.task.trim())
255
138
  throw new Error('The subagent task must not be empty.');
256
- // The bound is checked before anything is written: an oversized task must not leave a record,
257
- // a claim or a session behind, whichever surface asked for it.
258
139
  if (options.task.length > MAX_SUBAGENT_TASK_CHARS) {
259
140
  throw new SubagentInvalidArgumentError(`The task must be at most ${MAX_SUBAGENT_TASK_CHARS} characters.`);
260
141
  }
261
- // The permission is read before anything is written too: a caller that meant to withhold the
262
- // mutations must not be given them by a value this runner could not read.
263
142
  const permissions = resolveSubagentPermissions(options.permissions);
264
- // The connection that owned this runner closed while the start was still preparing. A run that
265
- // begins now would outlive the connection that asked for it, with nothing left to cancel it.
266
143
  if (this.closed)
267
144
  throw new Error('The connection to Andorra closed before the run started.');
268
- // The slot is taken before the first await: two overlapping starts would otherwise both
269
- // pass the check, and the later assignment would hide the first run from every reader.
270
145
  if (this.starting || (this.active !== undefined && !this.active.outcome))
271
146
  throw new SubagentRunInProgressError();
272
147
  this.starting = true;
273
- // The run takes the reservation over from the start: a start that failed leaves nothing
274
- // behind, and a start that reached its run hands the reservation to it.
275
148
  let handedOver = false;
276
149
  const pending = this.begin(options, permissions).then(reply => { handedOver = true; return reply; });
277
- // The start is tracked while it prepares, so a shutdown can wait for it: a start that has
278
- // not reached its run yet has nothing to abort, and it would otherwise go on to launch a
279
- // full-access run after the connection that asked for it has closed.
280
150
  this.startPromise = pending;
281
151
  try {
282
152
  return await pending;
283
153
  }
284
154
  finally {
285
- // The reservation is the slot until the run itself holds it, and it is released when the
286
- // start failed, so the next caller is not refused for a run that never began. A
287
- // cancellation that belonged to that start goes with it: it was never a cancellation of
288
- // the next run.
289
155
  this.starting = false;
290
156
  this.pendingCancel = false;
291
157
  if (this.startPromise === pending)
@@ -294,26 +160,15 @@ export class SubagentRunner {
294
160
  this.releaseWorkspace();
295
161
  }
296
162
  }
297
- /** The run itself, once the slot is held. */
298
163
  async begin(options, permissions) {
299
164
  const directory = options.directory ?? this.defaults.directory ?? configDirectory();
300
- // The workspace is resolved before anything is written: the records name the directory the
301
- // run really works in, and a path that is not one would be recorded before the tools failed.
302
165
  const workspace = await canonicalWorkspace(options.workspace);
303
166
  const config = await (this.defaults.loadConfig ?? loadConfig)(directory);
304
167
  const { provider, model } = resolveSubagentProvider(config, options);
305
- // The process-wide reservation: another engine in this process — a second backend of an
306
- // embedded host, or the app server over the same project — is already working in this
307
- // workspace, and two full-access runs would write to the same files at once. It is taken
308
- // here, once the workspace is known, and the check and the claim are one step, so two starts
309
- // cannot both pass it.
310
168
  if (!claimProcessWorkspace(workspace, this.reservationId))
311
169
  throw new SubagentRunInProgressError();
312
170
  this.reservedWorkspace = workspace;
313
171
  const telemetryRunId = randomUUID();
314
- // Resolved once, before the record is written: the start, the finish and the drains must all
315
- // ask the gate for the account that owns this run, or a shared installation answers with
316
- // whichever account most recently confirmed a plan.
317
172
  const accountSubject = await currentGraphSubject().catch(() => undefined);
318
173
  const runId = randomUUID();
319
174
  const run = {
@@ -326,37 +181,20 @@ export class SubagentRunner {
326
181
  probeUsage: { requests: 0, inputTokens: 0, outputTokens: 0 }, probeModels: new Map(),
327
182
  providerType: provider.type, baseUrl: provider.baseUrl,
328
183
  };
329
- // The claim lands before any preflight: a crash between here and finalize leaves exactly the
330
- // record recovery knows how to classify.
331
184
  const openRecord = {
332
185
  id: run.runId, status: 'running', sessionId: run.sessionId, startedAt: run.startedAt, pid: process.pid,
333
186
  graphSelection: SUBAGENT_GRAPH_ID, graph: { id: SUBAGENT_GRAPH_ID }, provider: provider.id, model,
334
- // The account this attempt was started under travels with the record: recovery on a shared
335
- // installation would otherwise gate the finish with whichever cached account is newest.
336
187
  ...(accountSubject === undefined ? {} : { accountSubject }),
337
- // A CLI or app-server recovery may find this record in the shared home; the finish it
338
- // reports must still be labeled with the subagent surface that produced the start.
339
188
  surface: 'subagent',
340
- // `startSent` stays false until the start is queued below; a crash in between owes the
341
- // missing start as well as the finish, and recovery reads this flag to decide that.
342
189
  telemetry: { runId: telemetryRunId, nodes: 1, subagents: false, jevEnabled: config.jevEnabled !== false, decisionRouting: config.decisions?.mode ?? 'off', startSent: false },
343
- // The marker travels with the open record as well as the terminal one: a crash before
344
- // the finalization rewrites this record as interrupted, and it must still say that the
345
- // attempt was a subagent run.
346
190
  subagent: true,
347
- // The permission the host bound this attempt to. A read-only subagent that is later
348
- // resumed must not come back as a full-access run: the workspace's own setting is not
349
- // the host's instruction, and the host is the one that prohibited the mutations.
350
191
  permissions: run.permissions,
351
192
  };
352
193
  try {
353
194
  await writeOpenRunRecord(directory, openRecord);
354
195
  }
355
196
  catch (error) {
356
- // A partial claim would be classified as an interrupted attempt that never ran.
357
197
  await removeOpenRunRecord(directory, run.runId).catch(() => { });
358
- // The filesystem code travels with the message: a storage failure is told to the host as a
359
- // storage problem, and a plain error would answer as a general backend one.
360
198
  const code = error && typeof error === 'object' && 'code' in error ? error.code : undefined;
361
199
  throw Object.assign(new Error(`Could not write the subagent run record: ${error instanceof Error ? error.message : String(error)}`), typeof code === 'string' ? { code } : {}, error instanceof Error ? { cause: error } : {});
362
200
  }
@@ -365,34 +203,22 @@ export class SubagentRunner {
365
203
  jevEnabled: run.jevEnabled, decisionRouting: run.decisionRouting,
366
204
  }, workspace);
367
205
  run.telemetryStart = reportRunStarted({ home: directory, config, surface: 'subagent', ...(run.accountSubject === undefined ? {} : { subject: run.accountSubject }) }, run.telemetryHandle).catch(() => { });
368
- // Stamp the queue result into the record before the work starts: after this point a crash is
369
- // recovered from a start that exists, and recovery must not synthesize a second one.
370
206
  await run.telemetryStart;
371
207
  await writeOpenRunRecord(directory, {
372
208
  ...openRecord,
373
209
  telemetry: { ...openRecord.telemetry, startSent: run.telemetryHandle.started !== false },
374
210
  }).catch(() => { });
375
- // The session exists before the work does: a crash between here and the finalization
376
- // leaves a session with a running turn, which is what the recovery repairs.
377
211
  try {
378
212
  await this.saveSession(run, { summary: RUNNING_TURN_SUMMARY, tests: [], status: 'running' });
379
213
  }
380
214
  catch (error) {
381
- // The claim and the record both name a process that never ran, and nothing else would clear
382
- // either: a record left behind is an attempt the Runs view lists, and its live pid tells the
383
- // recovery that another process owns it.
384
215
  await removeOpenRunRecord(directory, run.runId).catch(() => { });
385
- // The start already left; the run is accepted but ended before executing, so it owes the
386
- // finish that joins it rather than leaving an unmatched start on the spool.
387
216
  await run.telemetryStart;
388
- // Same account and dimensions as the start: a shared installation must not let a newer
389
- // account's cached plan decide whether this run's finish is queued.
390
217
  await reportRunFinished({ home: directory, config, surface: 'subagent', ...(run.accountSubject === undefined ? {} : { subject: run.accountSubject }) }, run.telemetryHandle ?? createRunHandle(run.telemetryRunId, run.startedAt, { graphId: SUBAGENT_GRAPH_ID, nodes: 1, subagents: false, permissionMode: run.permissions,
391
218
  jevEnabled: run.jevEnabled, decisionRouting: run.decisionRouting }), { status: 'infrastructure_error', reason: 'The subagent session record could not be saved.' }).catch(() => { });
392
219
  throw error;
393
220
  }
394
221
  this.active = run;
395
- // A cancellation that arrived while the run was starting applies to it now.
396
222
  if (this.pendingCancel) {
397
223
  this.pendingCancel = false;
398
224
  run.controller.abort(new Error('Cancelled by the calling agent'));
@@ -412,7 +238,6 @@ export class SubagentRunner {
412
238
  ...(run.outcome?.reason !== undefined ? { reason: run.outcome.reason } : {}),
413
239
  };
414
240
  }
415
- /** Wait up to `waitMs` for the run; a finished run stays answerable until the next start. */
416
241
  async result(waitMs = 0) {
417
242
  const run = this.active;
418
243
  if (!run)
@@ -431,32 +256,14 @@ export class SubagentRunner {
431
256
  run.controller.abort(new Error('Cancelled by the calling agent'));
432
257
  return true;
433
258
  }
434
- // A cancellation that arrives while a start is preparing belongs to that start: it has no run
435
- // to abort yet, and it would otherwise go on to spend tokens. A run that has already finished
436
- // is not the one being cancelled either — the replacement that is preparing is, and a
437
- // cancellation dropped here would leave it to go on with billable, full-access work after the
438
- // caller asked it to stop.
439
259
  if ((!run || run.outcome !== undefined) && this.starting) {
440
260
  this.pendingCancel = true;
441
261
  return true;
442
262
  }
443
263
  return false;
444
264
  }
445
- /**
446
- * End the run this process owns and wait for it to finish.
447
- *
448
- * The run finalizes itself: it writes the session and the terminal record, and clears the
449
- * open-run claim. A caller that closes while the run works waits for that, so the records it
450
- * leaves behind are the ones of a finished attempt rather than of a half-written one.
451
- */
452
265
  async shutdown() {
453
- // A start that has not reached the runner yet must not begin: the connection that asked for it
454
- // is gone, and nothing would ever cancel the run it launches.
455
266
  this.closed = true;
456
- // A start that is still preparing has no run to abort yet, and it would otherwise launch a
457
- // run after the connection that asked for it is gone. The start is awaited here, marked
458
- // cancelled while it waits, and the run it produces is cancelled and awaited in turn, so no
459
- // provider request or tool call outlives the controlling connection.
460
267
  if (this.startPromise) {
461
268
  this.pendingCancel = true;
462
269
  await this.startPromise.catch(() => { });
@@ -465,17 +272,9 @@ export class SubagentRunner {
465
272
  if (!run)
466
273
  return;
467
274
  this.cancel();
468
- // A run that already finished still owns what it spawned: a QA terminal it left behind keeps
469
- // the process alive behind that child, and closing the connection does not close it.
470
275
  this.release(run);
471
276
  await run.finished.catch(() => { });
472
277
  }
473
- /**
474
- * Wait for the run, up to `waitMs`.
475
- *
476
- * The timer is cleared when the run wins, so a run that finished early does not keep the
477
- * process alive for the rest of the wait, and repeated waits do not pile timers up.
478
- */
479
278
  async awaitOutcome(run, waitMs) {
480
279
  let timer;
481
280
  const timeout = new Promise(resolve => {
@@ -490,16 +289,6 @@ export class SubagentRunner {
490
289
  clearTimeout(timer);
491
290
  }
492
291
  }
493
- /**
494
- * Record one runtime event, and hand back the journal write that carries it.
495
- *
496
- * The returned promise is what makes the event durable before the run moves on: the runtime
497
- * awaits the callback it was given, so a caller that awaits this waits for the append — and for
498
- * every append queued before it — to land. Without that the runtime would advance past a
499
- * mutating tool call whose event was still queued, and a kill in that window would leave a
500
- * journal that omits the completed call: a resume of that attempt would replay to a position
501
- * before the call and repeat its effects.
502
- */
503
292
  observe(run, event) {
504
293
  const data = event.data;
505
294
  const node = typeof data.nodeId === 'string' ? data.nodeId : typeof data.node === 'string' ? data.node : undefined;
@@ -508,20 +297,9 @@ export class SubagentRunner {
508
297
  run.events.splice(0, run.events.length - 200);
509
298
  if (event.type === 'graph.node.started' && typeof data.nodeId === 'string')
510
299
  run.currentNode = data.nodeId;
511
- // The journal keeps the order the events happened in, and the runtime awaits the callback for
512
- // exactly that reason: the writer chains its appends rather than launching them side by side,
513
- // because the filesystem does not finish them in the order they were started. The run keeps
514
- // going when an append fails (a storage hiccup must not kill the work): the writer holds the
515
- // event and writes it once the file accepts appends again.
516
300
  run.journal = run.journalWriter.append(event);
517
301
  return run.journal;
518
302
  }
519
- /**
520
- * Record what the run could not set up, and publish it.
521
- *
522
- * The notice is a fact about the attempt, not a log line: the run continues without the
523
- * capability, and the caller can only see that from the run's own observable path.
524
- */
525
303
  notice(run, message) {
526
304
  run.notices.push(message);
527
305
  if (run.notices.length > 50)
@@ -534,33 +312,22 @@ export class SubagentRunner {
534
312
  let failure;
535
313
  let mcp;
536
314
  let codeIntel;
537
- /** The repository's learned command guidance, when the installation keeps it. */
538
315
  let commandMemory;
539
- /** The checkpoint writes, chained so the newest conversation is the file's content. */
316
+ let projectMemory;
540
317
  let checkpointWrites = Promise.resolve();
541
318
  try {
542
319
  const graph = validateGraph(await (options.loadGraph ?? loadAccessibleGraph)(SUBAGENT_GRAPH_ID, signal), { providers: config.providers, defaultProvider: config.provider, spawnAvailable: true });
543
- // The preflight must probe the model the run will call: the node pins no model, so it
544
- // runs on this run provider and model, not on the installation default.
545
320
  const healthConfig = {
546
321
  ...config,
547
322
  provider: run.providerId,
548
323
  providers: config.providers.map(item => {
549
324
  if (item.id !== run.providerId)
550
325
  return item;
551
- // The selected model is not the provider's configured one, so the default model's saved
552
- // reasoning and window belong to that model and not to this one: a model that refuses the
553
- // default model's reasoning parameter would fail the probe for a reason the run does not
554
- // have.
555
326
  return providerForModel(item, run.model);
556
327
  }),
557
328
  };
558
329
  const health = await checkGraphModelHealth(graph, healthConfig, signal, {
559
330
  ...(options.adapterFactory ? { createAdapter: options.adapterFactory } : options.healthDependencies),
560
- // The probes are model calls this run pays for, and they happen outside `runGraph`: the
561
- // result carries the graph's own calls only, so a run whose totals left the probes out
562
- // would report less than it spent — and a probe that reached the provider and failed
563
- // would be recorded as having cost nothing at all.
564
331
  onUsage: (delta, reference) => {
565
332
  foldUsage(run.probeUsage, delta);
566
333
  options.healthDependencies?.onUsage?.(delta, reference);
@@ -579,14 +346,10 @@ export class SubagentRunner {
579
346
  throw new Error(subagentHealthFailure(health));
580
347
  }
581
348
  const runProvider = config.providers.find(item => item.id === run.providerId);
582
- // An embedded adapter keeps the run offline; the default path resolves model metadata the
583
- // same way the CLI does, so context-window and effort handling match an ordinary session.
584
349
  const resolvedProvider = options.adapterFactory ? { ...runProvider, model: run.model } : await resolveModelContext(runProvider, run.model, signal);
585
350
  const adapterFor = options.adapterFactory ?? createAdapter;
586
- const snapshot = await extensionSnapshot(config, signal, run.directory);
587
- const instructions = `${await loadWorkspaceInstructions(run.workspace, signal, config.systemPromptOverride)}${snapshot.instructions}`;
588
- // The harness needs no hosted membership, and asking for it only adds the delay of a token
589
- // refresh and a membership request before a run that is entirely local.
351
+ const snapshot = await extensionSnapshot(effectiveExtensionConfig(config, run.workspace), signal, run.directory);
352
+ const instructions = `${await loadWorkspaceInstructions(run.workspace, signal, systemPromptOverrideFor(graph, config.systemPromptOverride))}${snapshot.instructions}`;
590
353
  const context = {
591
354
  workspace: run.workspace, signal,
592
355
  yolo: run.permissions === 'full-access', permissions: run.permissions, approvalMode: 'headless',
@@ -594,29 +357,18 @@ export class SubagentRunner {
594
357
  };
595
358
  if (Object.keys(snapshot.servers).length) {
596
359
  const { connectMcpServers } = await import('./mcp.js');
597
- // A server that could not connect, or a catalog that was refused, is told to the
598
- // caller: the run continues without those tools, and the host has to know that its
599
- // task is running with less than it configured.
600
360
  mcp = await connectMcpServers(snapshot.servers, context, message => this.notice(run, message), signal);
601
361
  }
602
- // The run's memory and its decision policy come from the configuration of the home it
603
- // runs in: the runner falls back to the process-wide installation otherwise, and the run
604
- // would read and write another installation's memory.
605
362
  const memory = await MemoryManager.create({
606
363
  config: resolveMemoryConfig(config, process.env, detail => { void this.observe(run, { type: 'memory.error', time: new Date().toISOString(), data: { runId: run.runId, operation: 'Graphiti', detail } }); }), workspace: run.workspace,
607
364
  onEvent: event => this.observe(run, event), getPermissions: () => permissionMode(context),
608
365
  });
609
366
  codeIntel = await this.codeIntelligence(run, config, signal);
610
- // The artifacts belong to the home the run works in: the process-wide installation would
611
- // hold files the run's own records cannot find.
612
367
  const artifactStore = new ArtifactStore(run.runId, run.directory);
613
- // The repository's learned command guidance is the installation's setting, and a subagent
614
- // run honours it like any other run.
615
368
  if (config.commandMemory !== false)
616
369
  commandMemory = await LocalToolMemory.open({ workspace: run.workspace, directory: run.directory });
617
- // The checkpoints land one at a time, newest last: the runner calls back synchronously from
618
- // several nodes, and an unserialized write could leave an older conversation as the file's
619
- // final content.
370
+ if (config.projectMemory !== false)
371
+ projectMemory = await ProjectMemory.open({ home: run.directory, workspace: run.workspace });
620
372
  const persistCheckpoint = (nodeId, messages, state, meta) => {
621
373
  checkpointWrites = checkpointWrites
622
374
  .then(() => writeRunCheckpoint(run.directory, run.runId, {
@@ -625,21 +377,13 @@ export class SubagentRunner {
625
377
  ...(meta?.provider === undefined ? {} : { provider: meta.provider }),
626
378
  ...(meta?.model === undefined ? {} : { model: meta.model }),
627
379
  }))
628
- // The run keeps going — durability is a convenience, never the run's outcome. But a
629
- // checkpoint that could not be written is the conversation a resume re-enters the node
630
- // with, so the node stays marked until one of its later writes lands; a resume of an
631
- // attempt that stopped while it was marked warns that the node may repeat work.
632
380
  .then(() => run.checkpoints.succeeded({ nodeId, generation: meta?.generation }), error => run.checkpoints.failed({ nodeId, generation: meta?.generation }, error));
633
- // The write is handed back so the runtime can await it: the checkpoint is the conversation
634
- // a resume re-enters the node with, and a run that advanced past a mutating tool call
635
- // while its checkpoint was still queued could be killed with that conversation unwritten.
636
381
  return checkpointWrites;
637
382
  };
383
+ const { createTools } = await import('./tools.js');
638
384
  const graphOptions = {
639
385
  task: run.task, runId: run.runId, provider: run.providerId, model: run.model,
640
386
  adapter: adapterFor(resolvedProvider),
641
- // The model context window the registry resolved, so the run compacts against the
642
- // provider limit rather than the generic one.
643
387
  ...(resolvedProvider.contextWindow === undefined ? {} : { contextWindow: resolvedProvider.contextWindow }),
644
388
  tools: [...createTools(), ...snapshot.tools, ...(mcp?.tools ?? [])],
645
389
  instructions, limits: resolveConfiguredLimits(config), todoStore: new TodoStore(),
@@ -647,15 +391,8 @@ export class SubagentRunner {
647
391
  const provider = config.providers.find(item => item.id === id);
648
392
  if (!provider)
649
393
  throw new Error(`Unknown provider: ${id}. Use /providers to add or edit providers.`);
650
- // A node that names no model takes the run's own model when it runs on the run's own
651
- // provider: the host chose that pair, and the provider's configured default is a model
652
- // nobody asked for. The preflight and the reported result already use it, so the request
653
- // has to bill the same one.
654
394
  const wanted = model ?? (id === run.providerId ? run.model : provider.model);
655
395
  if (options.adapterFactory) {
656
- // The same normalization the preflight and the ordinary path apply: the saved
657
- // reasoning effort and context window belong to the provider's configured model, so an
658
- // embedded adapter is not handed the default model's settings for another one.
659
396
  return Promise.resolve({ model: wanted, adapter: options.adapterFactory(providerForModel(provider, wanted)), providerType: provider.type, baseUrl: provider.baseUrl });
660
397
  }
661
398
  return resolveModelContext(provider, wanted, modelSignal)
@@ -665,22 +402,17 @@ export class SubagentRunner {
665
402
  const provider = config.providers.find(item => item.id === id);
666
403
  if (!provider)
667
404
  throw new Error(`Unknown provider: ${id}. Use /providers to add or edit providers.`);
668
- // The node pins no model, so it runs on the model this run selected: a provider's
669
- // own default is a model the host never asked for.
670
405
  const selected = providerForModel(provider, run.model);
671
406
  return { model: run.model, adapter: adapterFor(selected), contextWindow: selected.contextWindow, providerType: selected.type, baseUrl: selected.baseUrl };
672
407
  },
673
408
  context,
674
409
  artifactStore,
675
410
  ...(commandMemory ? { commandMemory } : {}),
411
+ ...(projectMemory ? { projectMemory } : {}),
676
412
  memory,
677
413
  decisionManager: new DecisionManager({ config: await subagentDecisionConfig(config, () => (options.membership ?? getMembership)(signal)), onEvent: event => this.observe(run, event) }),
678
414
  decisionNodeOptIn: true,
679
- // The code intelligence of the installation this run works in, so the run has the same
680
- // repository coverage an ordinary Andorra Agent run has.
681
415
  ...(codeIntel ? { codeIntel } : {}),
682
- // The checkpoints a resume reads: without them a replay re-enters the node from its
683
- // opening task and repeats the writes and shell calls that already ran.
684
416
  onNodeCheckpoint: persistCheckpoint,
685
417
  onEvent: event => this.observe(run, event),
686
418
  };
@@ -690,18 +422,13 @@ export class SubagentRunner {
690
422
  failure = error;
691
423
  }
692
424
  finally {
693
- // The work is over: from here the run only writes its records, and a cancellation would be
694
- // reported as accepted while the run publishes what it did.
695
425
  run.executed = true;
696
- // The checkpoints are drained before the attempt is published: a resume that reads a
697
- // half-written checkpoint would replay the node from its opening task.
698
426
  await checkpointWrites.catch(() => { });
699
427
  await mcp?.close().catch(() => { });
700
428
  await codeIntel?.dispose().catch(() => { });
701
429
  await this.finalize(run, result, failure);
702
430
  }
703
431
  }
704
- /** The session record for a run: the turn it is running, or the one it finished. */
705
432
  async saveSession(run, completion, usage = { requests: 0, inputTokens: 0, outputTokens: 0 }, updatedAt = new Date().toISOString()) {
706
433
  await new SessionStore(run.directory).save({
707
434
  version: 1, id: run.sessionId, name: sessionName(run.task), workspace: run.workspace, updatedAt,
@@ -711,23 +438,16 @@ export class SubagentRunner {
711
438
  async finalize(run, result, failure) {
712
439
  const status = result?.status ?? (run.controller.signal.aborted ? 'cancelled' : 'infrastructure_error');
713
440
  const reason = result?.reason ?? (failure !== undefined ? (failure instanceof Error ? failure.message : String(failure)) : undefined);
714
- // The start's own dimensions and account are repeated: the configuration may have changed
715
- // while the run was in flight, and a joined pair that reported different JEV/routing settings
716
- // would attribute the run to settings it never used.
717
441
  const telemetrySurface = { home: run.directory, surface: 'subagent', ...(run.accountSubject === undefined ? {} : { subject: run.accountSubject }) };
718
442
  const telemetryHandle = run.telemetryHandle ?? createRunHandle(run.telemetryRunId, run.startedAt, {
719
443
  graphId: SUBAGENT_GRAPH_ID, nodes: 1, subagents: false, permissionMode: run.permissions,
720
444
  jevEnabled: run.jevEnabled, decisionRouting: run.decisionRouting,
721
445
  }, run.workspace);
722
446
  let telemetryFinished = false;
723
- // The finish is returned so the caller can wait for it: a drain that starts before the finish
724
- // is queued exits with the event still on the spool.
725
447
  const settleTelemetry = (settled, why) => {
726
448
  if (telemetryFinished)
727
449
  return Promise.resolve();
728
450
  telemetryFinished = true;
729
- // The finish waits for the start: a short run can otherwise drain before the start is queued.
730
- // The health probes precede the graph, so their tuples join the capture the finish reports.
731
451
  const finishedTelemetry = result?.telemetry ?? createRunTelemetry();
732
452
  for (const probe of run.probeModels.values()) {
733
453
  recordModelUse(finishedTelemetry, { providerType: run.providerType, baseUrl: run.baseUrl, model: probe.model, role: 'other', usage: probe.usage });
@@ -742,62 +462,31 @@ export class SubagentRunner {
742
462
  };
743
463
  const endedAt = new Date().toISOString();
744
464
  const usage = result?.usage ?? { requests: 0, inputTokens: 0, outputTokens: 0 };
745
- // The preflight ran outside `runGraph`, so its spend is folded in here: the result carries
746
- // the graph's own calls only, and the record and the session report what the attempt cost.
747
465
  foldUsage(usage, run.probeUsage);
748
- // The record holds the run's own result, so the Runs view reports its graph, its
749
- // completion, its tool calls and its todos, and the subagent identity is laid over it.
750
466
  const record = {
751
467
  ...(result ?? {}),
752
468
  id: run.runId, status, ...(reason !== undefined ? { reason } : {}), graphSelection: SUBAGENT_GRAPH_ID,
753
469
  subagent: true, usage, sessionId: run.sessionId, startedAt: run.startedAt, endedAt,
754
470
  provider: run.providerId, model: run.model,
755
- // The permission the host bound the attempt to, so a later resume of it inherits the
756
- // restriction rather than the workspace's own current setting.
757
471
  permissions: run.permissions,
758
472
  };
759
- // The journal is drained before the record that says the run finished: a record that reports a
760
- // completed run while its last events are still being written is a record whose journal tail
761
- // may never land.
762
- // Settling also retries whatever the file refused earlier, so space freed since then lets the
763
- // journal finish whole.
764
473
  await run.journal.catch(() => { });
765
474
  const journalIntact = await run.journalWriter.settle();
766
- // The record carries the flag the resume reads when the marker file could not be written: a
767
- // resume of an attempt whose journal has a hole warns that a step may repeat.
768
475
  if (!journalIntact)
769
476
  record.journalIntegrity = 'failed';
770
- // The same flag for a node whose newest checkpoint could not be written: a resume re-enters
771
- // that node from an older conversation, and warns that it may repeat work.
772
477
  if (!run.checkpoints.intact) {
773
478
  record.checkpointIntegrity = 'failed';
774
479
  record.checkpointFailures = run.checkpoints.failures;
775
480
  }
776
- // The terminal record is written before the session is finalized. A crash between the two
777
- // leaves a session whose turn is still marked running, which the startup recovery repairs
778
- // from the record; the other order would leave a session that reports the completion while
779
- // the recovery still rewrites the still-open record as interrupted, and a completed turn is
780
- // not one the recovery reconciles.
781
481
  try {
782
482
  await writeFile(runRecordPath(run.directory, run.runId, 'json'), JSON.stringify(record, null, 2) + '\n', { mode: 0o600 });
783
483
  }
784
484
  catch (error) {
785
485
  process.stderr.write(`Could not record the stopped subagent run: ${error instanceof Error ? error.message : String(error)}\n`);
786
- // The terminal record did not land, and the attempt is still open: the record says the run
787
- // is live and the claim holds the session against it. A long-lived server would keep the
788
- // attempt in the Runs view and the session locked until the process exited, so the record is
789
- // terminalized here, and the claim released once that record landed: the attempt failed,
790
- // and it says so.
791
486
  const detail = error instanceof Error ? error.message : String(error);
792
487
  const terminalized = await writeFile(runRecordPath(run.directory, run.runId, 'json'), JSON.stringify({
793
488
  ...record, status: 'infrastructure_error', reason: `The run record could not be written: ${detail}`, endedAt,
794
489
  }, null, 2) + '\n', { mode: 0o600 }).then(() => true, () => false);
795
- // The sidecar carries the same projection the ordinary finalizer writes: it is newer than the
796
- // record, and Graph Studio prefers it, so a sidecar without the graph and the tool calls
797
- // would report a null for both.
798
- // The sidecar is published only when the terminal record landed: it is newer than the
799
- // record, and a sidecar that says the attempt is terminal while the record still says the
800
- // run is live would make Graph Studio report an attempt that is not.
801
490
  if (terminalized) {
802
491
  await writeStudioRunSummary(run.directory, {
803
492
  id: run.runId, status: 'infrastructure_error', startedAt: run.startedAt, graphSelection: SUBAGENT_GRAPH_ID,
@@ -805,25 +494,14 @@ export class SubagentRunner {
805
494
  ...(typeof result?.toolCalls === 'number' ? { toolCalls: result.toolCalls } : {}),
806
495
  }).catch(() => { });
807
496
  }
808
- // The session is landed before the claim is given back. The claim is what holds the session
809
- // against a mutation, and a rename, archive or delete accepted in that window would be
810
- // overwritten by the save below — or, if that save fails, left behind with the session
811
- // still marked running. A save that fails is repaired from the record, the way the normal
812
- // path repairs it.
813
497
  try {
814
498
  await this.saveSession(run, { summary: `The run finished, but its record could not be written: ${detail}`, tests: [], status: 'infrastructure_error' }, usage, endedAt);
815
499
  }
816
500
  catch {
817
501
  await repairSessionMarkers(run.directory, run.sessionId).catch(() => { });
818
502
  }
819
- // The claim is released only when the terminal record landed. A record that still says the
820
- // run is live, with no claim to say so, is a history that contradicts itself — and when
821
- // even that write fails, the claim stays and the recovery classifies the attempt once
822
- // this process is gone, which is the answer that is true rather than one that reads well.
823
503
  if (terminalized)
824
504
  await clearOpenRunClaim(run.directory, run.runId).catch(() => { });
825
- // The reservation is given back before the outcome is published: a caller that reads the
826
- // outcome must be able to start the next run in the same workspace.
827
505
  this.releaseWorkspace();
828
506
  this.release(run);
829
507
  await settleTelemetry('infrastructure_error', `The run record could not be written: ${detail}`);
@@ -831,15 +509,9 @@ export class SubagentRunner {
831
509
  run.outcome = { status: 'infrastructure_error', reason: `The run record could not be written: ${detail}` };
832
510
  return;
833
511
  }
834
- // A finished run has nothing to resume, so its durable conversation goes with it: a checkpoint
835
- // file holds the node's whole message history — tool outputs included — and repeated subagent
836
- // runs would accumulate all of it under `runs/` for ever. The ordinary CLI and app-server
837
- // finalizers delete it for the same reason. A stopped attempt keeps its checkpoint: that one
838
- // is what a resume re-enters the node with.
839
512
  if (status === 'succeeded')
840
513
  await removeRunCheckpoint(run.directory, run.runId).catch(() => { });
841
514
  try {
842
- // A stopped run's completion says how it stopped: an absent status is read as a success.
843
515
  const completion = result?.completion ?? {
844
516
  summary: summaryForStoppedRecord(record),
845
517
  tests: [],
@@ -848,54 +520,24 @@ export class SubagentRunner {
848
520
  await this.saveSession(run, completion, usage, endedAt);
849
521
  }
850
522
  catch (error) {
851
- // The record says how the attempt ended and the session's turn is still marked running. The
852
- // repair belongs to the session now, not to the next start: a long-lived server would leave
853
- // the turn unfinished until it was restarted.
854
523
  await repairSessionMarkers(run.directory, run.sessionId).catch(() => { });
855
524
  process.stderr.write(`Could not save the subagent session: ${error instanceof Error ? error.message : String(error)}\n`);
856
525
  }
857
- // The studio sidecar carries the same projection the ordinary run finalizers write, so Graph
858
- // Studio reports the run's graph and its tool calls rather than a null for both.
859
526
  await writeStudioRunSummary(run.directory, {
860
527
  id: run.runId, status, startedAt: run.startedAt, graphSelection: SUBAGENT_GRAPH_ID,
861
528
  ...(result?.graph ? { graph: result.graph } : {}),
862
529
  ...(typeof result?.toolCalls === 'number' ? { toolCalls: result.toolCalls } : {}),
863
530
  }).catch(() => { });
864
531
  await clearOpenRunClaim(run.directory, run.runId).catch(() => { });
865
- // The reservation is given back before the outcome is published: a caller that reads the
866
- // outcome must be able to start the next run in the same workspace.
867
532
  this.releaseWorkspace();
868
- // The run is over, and what it owns is tied to its signal: a QA terminal it spawned and did
869
- // not kill keeps the process alive behind that child, so the CLI would print its result and
870
- // never exit. Releasing the signal closes them, and the outcome is already decided.
871
533
  this.release(run);
872
534
  await settleTelemetry(status, reason);
873
535
  await drainTelemetry(telemetrySurface).catch(() => { });
874
536
  run.outcome = { status, ...(result !== undefined ? { result } : {}), ...(reason !== undefined ? { reason } : {}) };
875
537
  }
876
- /**
877
- * The signal the run's own resources are tied to.
878
- *
879
- * A run releases it when it ends: a QA terminal it spawned and did not kill stays open behind
880
- * its child, and the process would not exit. The signal is what closes it, so this is how a
881
- * caller sees that the run has let go of what it owned.
882
- */
883
538
  runSignal() {
884
539
  return this.active?.controller.signal;
885
540
  }
886
- /**
887
- * Release what the run owns.
888
- *
889
- * The run's signal is what its QA terminals and other run-scoped resources are tied to, and a
890
- * finished run never releases it on its own: only a cancellation aborts it. A run that succeeded
891
- * with a terminal still open would keep the process alive behind that child.
892
- */
893
- /**
894
- * The code intelligence the run works with.
895
- *
896
- * The manager takes its own read-only branch and its own disabled branch, so it is always
897
- * created; what matters is that both guards reach it rather than indexing by default.
898
- */
899
541
  async codeIntelligence(run, config, signal) {
900
542
  if (signal.aborted)
901
543
  return undefined;
@@ -909,12 +551,6 @@ export class SubagentRunner {
909
551
  return;
910
552
  run.controller.abort(new Error('The subagent run has finished.'));
911
553
  }
912
- /**
913
- * Give the process-wide reservation back.
914
- *
915
- * Only the holder gives it back: a runner whose start failed releases nothing that another
916
- * runner has taken since.
917
- */
918
554
  releaseWorkspace() {
919
555
  const workspace = this.reservedWorkspace;
920
556
  if (workspace === undefined)