@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,14 +6,8 @@ import { acquireSaveLock, archiveUnpublishedSnapshot, removeLockedFolder, SaveLo
6
6
  import { validateMappingConstants, validateMappings, validateSchema, validateValue, schemaAt, nodeOutputSchema } from './handoffs.js';
7
7
  import { CANONICAL_CODING_TOOLS, canonicalToolName, canonicalizeToolList, toolNameMatches } from './tool-names.js';
8
8
  import { DEFAULT_AGENT_GRAPH } from './default-graph.js';
9
- export const GRAPH_TOOLS = [...CANONICAL_CODING_TOOLS, 'NativeExec', 'AsyncProcess', 'PowerShellFast', 'ShellMetrics', 'read_file', 'list_files', 'search_files', 'write_file', 'edit_file', 'read', 'write', 'edit', 'find', 'grep', 'ls', 'powershell', 'bash', 'shell', 'git_read', 'read_artifact', 'write_artifact', 'repo_explore', 'memory_search', 'set_timer', 'pull_request', 'graphs', 'qa.terminal', 'qa.browser', 'qa.browser_session', 'browser.solve_captcha', 'web_search', 'read_skill_resource', 'browser.panel', 'browser.incognito'];
10
- /** QA tool names are an explicit allowlist; gating keys off membership, never a name prefix. */
9
+ export const GRAPH_TOOLS = [...CANONICAL_CODING_TOOLS, 'NativeExec', 'AsyncProcess', 'PowerShellFast', 'ShellMetrics', 'read_file', 'list_files', 'search_files', 'write_file', 'edit_file', 'read', 'write', 'edit', 'find', 'grep', 'ls', 'powershell', 'bash', 'shell', 'git_read', 'read_artifact', 'write_artifact', 'repo_explore', 'memory_search', 'set_timer', 'pull_request', 'graphs', 'qa.terminal', 'qa.browser', 'qa.browser_session', 'browser.solve_captcha', 'web_search', 'read_skill_resource', 'browser.panel', 'browser.incognito', 'browser.extensions'];
11
10
  export const QA_TOOL_NAMES = ['qa.terminal', 'qa.browser'];
12
- /**
13
- * The QA check pipeline, removed: these tools ran lint, tests and a merge gate that the agent's
14
- * own shell commands already cover, at about two extra requests per run. A saved graph may still
15
- * list them in a node's tools; they are dropped on load instead of failing the graph.
16
- */
17
11
  export const RETIRED_GRAPH_TOOLS = new Set(['qa.inspect_project', 'qa.status', 'qa.fast', 'qa.deep', 'qa.test', 'qa.security']);
18
12
  export const isQaToolName = (name) => QA_TOOL_NAMES.includes(name);
19
13
  export const LEGACY_DEFAULT_HARNESS = {
@@ -26,14 +20,13 @@ export const LEGACY_DEFAULT_HARNESS = {
26
20
  done: { id: 'done', name: 'Done', type: 'end', position: { x: 440, y: 120 } },
27
21
  }, edges: [{ source: 'engineer', target: 'done' }],
28
22
  };
29
- /** The intake role is configuration for the shared executor, not a separate runtime. */
30
23
  export function createOrchestratorNode(id = 'orchestrator') {
31
24
  const list = { type: 'array', items: { type: 'string' } };
32
25
  return {
33
26
  id, name: 'Orchestrator', type: 'agent', agentRole: 'orchestrator', executor: 'react-basic',
34
27
  instruction: 'Understand the requested work before delegating implementation. Inspect relevant repository files, components, interfaces, architecture and testing patterns with the available read tools. Ground codebase findings in inspected paths and distinguish evidence from unknowns. Ask the user to clarify requirements, acceptance criteria, design preferences and important tradeoffs before handing work onward; do not infer approval from silence. Summarize the confirmed requirements, design considerations and codebase findings, then produce a concrete task instruction for the next Agent. Research subagents are optional and bounded; use only those that help resolve specific questions. Do not implement or modify the workspace during intake.',
35
28
  capabilities: { filesystem: 'read', shell: 'disabled', git: 'read', github: 'none', browser: 'playwright', deployment: 'none' },
36
- tools: ['read_file', 'list_files', 'search_files', 'git_read', 'read_artifact', 'write_artifact', 'repo_explore', 'read_skill_resource', 'qa.browser_session', 'browser.panel', 'browser.incognito'],
29
+ tools: ['read_file', 'list_files', 'search_files', 'git_read', 'read_artifact', 'write_artifact', 'repo_explore', 'read_skill_resource', 'qa.browser_session', 'browser.panel', 'browser.incognito', 'browser.extensions'],
37
30
  completion: { mode: 'single', outcome: 'completed' },
38
31
  contextPolicy: { history: true },
39
32
  inputs: { originalTask: '$run.input.task' },
@@ -48,16 +41,6 @@ export const ORCHESTRATOR_HANDOFF = {
48
41
  originalTask: '$run.input.task', taskInstruction: '$source.output.taskInstruction', requirements: '$source.output.requirements',
49
42
  acceptanceCriteria: '$source.output.acceptanceCriteria', designConsiderations: '$source.output.designConsiderations', codebaseFindings: '$source.output.codebaseFindings',
50
43
  };
51
- /**
52
- * Revision 2 of the bundled harness, frozen exactly as it was published.
53
- *
54
- * A published revision is a promise about behavior, so each one is stored as its own snapshot
55
- * rather than rebuilt from the current builders. Were revision 2 derived from
56
- * {@link createOrchestratorNode} or from the current harness body, editing either would silently
57
- * rewrite history and `loadGraph('default', 2)` would stop describing the graph revision 2 always
58
- * described; the revision-1 graph above is frozen the same way. Do not tidy this into a builder,
59
- * and publish a new revision rather than editing it.
60
- */
61
44
  export const DEFAULT_HARNESS_REVISION_2 = {
62
45
  schemaVersion: 3, id: "default", name: "Software Engineer", revision: 2, entry: "orchestrator",
63
46
  nodes: {
@@ -67,20 +50,10 @@ export const DEFAULT_HARNESS_REVISION_2 = {
67
50
  },
68
51
  edges: [{ "id": "orchestrator-engineer", "source": "orchestrator", "target": "engineer", "outcome": "completed", "inputMapping": { "originalTask": "$run.input.task", "taskInstruction": "$source.output.taskInstruction", "requirements": "$source.output.requirements", "acceptanceCriteria": "$source.output.acceptanceCriteria", "designConsiderations": "$source.output.designConsiderations", "codebaseFindings": "$source.output.codebaseFindings" } }, { "id": "engineer-done", "source": "engineer", "target": "done", "outcome": "completed" }],
69
52
  };
70
- /**
71
- * Frozen revision 3 adds one retry for the Orchestrator to the revision-2 snapshot.
72
- *
73
- * Intake is read-only and runs many turns, so one transient provider failure must not discard it,
74
- * and the retry keeps the user's confirmed clarifications. The Engineer writes to the workspace,
75
- * where re-running a finished attempt could repeat side effects, so it stays single-shot; a graph
76
- * that wants retries there opts in per node.
77
- */
78
53
  export const DEFAULT_HARNESS_REVISION_3 = { ...structuredClone(DEFAULT_HARNESS_REVISION_2), revision: 3 };
79
54
  DEFAULT_HARNESS_REVISION_3.nodes.orchestrator.retry = { maxAttempts: 2 };
80
- /** Frozen revision 4 adds skill resources to the published revision-3 snapshot. */
81
55
  export const DEFAULT_HARNESS_REVISION_4 = { ...structuredClone(DEFAULT_HARNESS_REVISION_3), revision: 4 };
82
56
  DEFAULT_HARNESS_REVISION_4.nodes.orchestrator.tools.push('read_skill_resource');
83
- /** Frozen revision 5 enables the integrated browser for all default agents. */
84
57
  export const DEFAULT_HARNESS_REVISION_5 = {
85
58
  schemaVersion: 3, id: 'default', name: 'Software Engineer', revision: 5, entry: 'orchestrator',
86
59
  nodes: {
@@ -89,47 +62,14 @@ export const DEFAULT_HARNESS_REVISION_5 = {
89
62
  done: { id: 'done', name: 'Done', type: 'end', position: { x: 780, y: 120 } },
90
63
  }, edges: [{ id: 'orchestrator-engineer', source: 'orchestrator', target: 'engineer', outcome: 'completed', inputMapping: structuredClone(ORCHESTRATOR_HANDOFF) }, { id: 'engineer-done', source: 'engineer', target: 'done', outcome: 'completed' }],
91
64
  };
92
- /**
93
- * Revision 6 renames the bundled execution agent to Andorra Agent and widens its role to general
94
- * tasks alongside coding. The agent still receives the confirmed task instruction through the same
95
- * intake handoff, and topology, capabilities and tooling are exactly revision 5's, so the change is
96
- * presentation and instruction only.
97
- *
98
- * Revision 6 is frozen and is no longer the latest `default`: it is the body of the paid Andorra
99
- * preset (`getAndorraHarness`), the Orchestrator -> Andorra Agent -> Done workflow. The graph a
100
- * Default run executes is {@link DEFAULT_GRAPH}.
101
- */
102
65
  export const DEFAULT_HARNESS = { ...structuredClone(DEFAULT_HARNESS_REVISION_5), name: 'Andorra Agent', revision: 6 };
103
66
  DEFAULT_HARNESS.nodes.engineer.name = 'Andorra Agent';
104
67
  DEFAULT_HARNESS.nodes.engineer.instruction = 'Carry out the confirmed task instruction completely, whether it is a coding task or a general one: implement code and verify changes with appropriate tools, and answer general research, writing and analysis directly. Use the supplied requirements, acceptance criteria, design considerations and repository findings to guide the work. Verify the result and report remaining issues.';
105
- /**
106
- * Revision 7, the latest `default`: one Andorra Agent and no Orchestrator intake.
107
- *
108
- * Selecting Default runs a single agent that cannot delegate (`SOFTWARE_ENGINEER_HARNESS`, built from
109
- * the same {@link DEFAULT_AGENT_GRAPH} as this revision), while revision 6 put an Orchestrator in front of it. Graph
110
- * Studio and the graph tools read `default` from here, so they showed a workflow that Default never
111
- * ran. This revision describes what Default runs; revision 6 remains loadable as history and as the
112
- * Andorra preset. It is schema version 3 so the editor's migration leaves it as one agent rather than
113
- * adding an Orchestrator in front of it.
114
- */
115
68
  export const DEFAULT_GRAPH = {
116
69
  schemaVersion: 3, id: 'default', name: DEFAULT_AGENT_GRAPH.name, revision: 7, entry: DEFAULT_AGENT_GRAPH.entry,
117
70
  nodes: structuredClone(DEFAULT_AGENT_GRAPH.nodes), edges: structuredClone(DEFAULT_AGENT_GRAPH.edges),
118
71
  };
119
- /** The id of the bundled Graph Manager graph. Reserved: no saved, synced or deleted graph may use it. */
120
72
  export const GRAPH_MANAGER_GRAPH_ID = 'andorra-graph-manager';
121
- /**
122
- * The graph Graph Studio's Graph Manager chat runs: one top-level agent and no Orchestrator intake.
123
- *
124
- * It is built in rather than saved so every installation has it and no account can edit it, and it
125
- * is hidden from graph lists because it is not a workflow a user selects for a task. The agent
126
- * sets neither `capabilities` nor `tools`, exactly as the default graph's execution agent: the
127
- * defaults allow the shell, which is what grants the `graphs` tool, and filesystem reads, which
128
- * grant `read_skill_resource`. A delegated subagent never receives `graphs`, so the work stays on
129
- * this node. Its instruction has the agent ask in its reply, with the user's next message as the
130
- * answer, and the node keeps session history so that message sees the question; as a top-level
131
- * agent it is also offered `ask_user` wherever a person can answer.
132
- */
133
73
  export const GRAPH_MANAGER_HARNESS = {
134
74
  schemaVersion: 3, id: GRAPH_MANAGER_GRAPH_ID, name: 'Graph Manager', revision: 1, entry: 'manager',
135
75
  nodes: {
@@ -137,30 +77,13 @@ export const GRAPH_MANAGER_HARNESS = {
137
77
  done: { id: 'done', name: 'Done', type: 'end', position: { x: 440, y: 120 } },
138
78
  }, edges: [{ id: 'manager-done', source: 'manager', target: 'done', outcome: 'completed' }],
139
79
  };
140
- /**
141
- * The configured MCP servers a run of this graph connects at its start.
142
- *
143
- * Graph Manager works only through the `graphs` tool and its bundled skill, and its chat runs
144
- * under Ask for approval, where every server raises a connection prompt before the first reply:
145
- * its run connects none. Every other graph connects what the user configured.
146
- */
147
80
  export function graphMcpServers(graphId, servers) {
148
81
  return graphId === GRAPH_MANAGER_GRAPH_ID ? {} : servers;
149
82
  }
150
- /** The refusal every path that would write, delete or tombstone the reserved id answers with. */
151
83
  export const reservedGraphId = (id) => new Error(`Graph id ${id} is reserved for a built-in graph`);
152
- /** Upgrade only in-memory copies. Stored snapshots remain unchanged. */
153
- /**
154
- * `addOrchestrator: false` upgrades a legacy graph without an Orchestrator to the current schema as it
155
- * stands, rather than placing an Orchestrator in front of its entry: a free account's graph may not
156
- * carry one, and inserting it would leave an eligible graph unsavable.
157
- */
158
84
  export function migrateGraphForEditor(input, options = {}) {
159
85
  const graph = validateGraphInternal(input);
160
86
  for (const node of Object.values(graph.nodes)) {
161
- // Assign only when a list exists: writing back undefined would add a `tools: undefined`
162
- // own property, and the editor's round-trip checks compare the copy against loaded
163
- // snapshots that never carried the key.
164
87
  if (node.tools)
165
88
  node.tools = canonicalizeToolList(node.tools);
166
89
  if (node.subagents?.roles)
@@ -207,9 +130,6 @@ export function migrateGraphForEditor(input, options = {}) {
207
130
  for (let i = 2; Object.hasOwn(graph.nodes, id); i++)
208
131
  id = `orchestrator-${i}`;
209
132
  const orchestrator = createOrchestratorNode(id);
210
- // The promoted intake is built after the canonicalization loop above, and the builder
211
- // must keep the frozen legacy spellings for the published revisions. Rewrite this copy
212
- // so the editor graph is canonical end to end, and re-migrating it is a no-op.
213
133
  if (orchestrator.tools)
214
134
  orchestrator.tools = canonicalizeToolList(orchestrator.tools);
215
135
  if (orchestrator.subagents?.roles)
@@ -238,11 +158,6 @@ export function migrateGraphForEditor(input, options = {}) {
238
158
  return validateGraph(graph);
239
159
  }
240
160
  const validId = (value) => typeof value === 'string' && /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,79}$/.test(value) && !['constructor', 'prototype', '__proto__'].includes(value);
241
- /**
242
- * Outcome names are author-facing phrases rather than identifiers ("FAILED TESTING"), yet
243
- * they still travel through loop exits, edge routing and criteria keys, so single inner
244
- * spaces are the only addition over the identifier rules and both ends stay alphanumeric.
245
- */
246
161
  const validOutcomeName = (value) => typeof value === 'string'
247
162
  && /^[a-zA-Z0-9][a-zA-Z0-9_ -]{0,79}$/.test(value) && !value.endsWith(' ') && !value.includes(' ')
248
163
  && !['constructor', 'prototype', '__proto__'].includes(value);
@@ -257,31 +172,20 @@ export function intakeCapabilities(node) {
257
172
  return { filesystem: policy.filesystem === 'none' ? 'none' : 'read', shell: 'disabled',
258
173
  git: policy.git === 'none' ? 'none' : 'read', github: 'none', browser: policy.browser, deployment: 'none' };
259
174
  }
260
- /** The second completion outcome of a delegating Orchestrator: subagents did the work and it landed. */
261
175
  export const DELIVERED_OUTCOME = 'delivered';
262
176
  export function isWritingRole(role) {
263
177
  return role.capabilities?.filesystem === 'read-write' || role.capabilities?.git === 'write';
264
178
  }
265
- /** An Orchestrator delegates implementation when spawning is on and at least one role may write. */
266
179
  export function delegatesWriting(node) {
267
180
  return node.type === 'agent' && node.agentRole === 'orchestrator' && node.subagents?.enabled === true && node.maxSubagents !== 0
268
181
  && (node.subagents.roles ?? []).some(isWritingRole);
269
182
  }
270
- /**
271
- * The shell setting alone decides whether a node runs commands. Filesystem and Git settings govern
272
- * their own structured tools (Write/Edit, git writes) and do not take the shell away: a reviewer set
273
- * to read files but allowed a shell needs `gh pr diff`, and withholding the shell silently left it
274
- * with instructions it could not follow (run 8a245b0f). Commands still go through the run's approval
275
- * rules. Ordinary delegated children never run commands; only a delegated-worktree child does.
276
- */
277
183
  const canRunCommands = (policy, child) => child !== true && policy.shell === 'allowed';
278
184
  export function permitsBuiltInTool(node, name, child = false) {
279
185
  if (node.tools !== undefined && !node.tools.some(configured => toolNameMatches(configured, name)))
280
186
  return false;
281
187
  const policy = effectiveCapabilities(node);
282
188
  const canonical = canonicalToolName(name);
283
- // The solve tool only acts on this agent's own qa.browser_session pages, so it follows the same policy;
284
- // web_search reaches the internet the way the browser does, so the browser policy governs it too.
285
189
  if (name === 'qa.browser_session' || name === 'browser.solve_captcha' || name === 'web_search')
286
190
  return policy.browser === 'playwright';
287
191
  if (['Read', 'Glob', 'Grep', 'repo_explore', 'read_skill_resource'].includes(canonical))
@@ -292,8 +196,6 @@ export function permitsBuiltInTool(node, name, child = false) {
292
196
  return canRunCommands(policy, child);
293
197
  if (name === 'ShellMetrics')
294
198
  return policy.filesystem !== 'none';
295
- // Every QA tool is part of the command-execution surface: even the read-only
296
- // pair only makes sense for nodes that can run the QA pipeline itself.
297
199
  if (isQaToolName(name))
298
200
  return canRunCommands(policy, child);
299
201
  if (name === 'git_read')
@@ -308,6 +210,16 @@ export function capabilitySubset(child, parent) {
308
210
  return levels.indexOf(child[key]) <= levels.indexOf(parent[key]);
309
211
  });
310
212
  }
213
+ /** An Action takes this outcome when its command ran to the end and exited non-zero. */
214
+ export const ACTION_FAILED_OUTCOME = 'failed';
215
+ /** Outcomes a node can take that a graph may route but does not have to. */
216
+ export function optionalOutcomes(node) {
217
+ return node.type === 'action' ? [ACTION_FAILED_OUTCOME] : [];
218
+ }
219
+ /** Every outcome a node can leave through in this graph: the required ones, and each optional one that has an edge. */
220
+ function routedOutcomes(node, edges) {
221
+ return [...nodeOutcomes(node), ...optionalOutcomes(node).filter(outcome => edges.some(edge => edge.source === node.id && edge.outcome === outcome))];
222
+ }
311
223
  export function nodeOutcomes(node) {
312
224
  if (node.type === 'end')
313
225
  return [];
@@ -336,9 +248,7 @@ function guaranteedGraphInvocations(graph) {
336
248
  for (const node of nodes) {
337
249
  if (node.id === boundary)
338
250
  continue;
339
- // An unrouted delivered port is not a path the run can take, so it does not weaken what the
340
- // completed route guarantees; once routed it is a real alternative like any other outcome.
341
- const alternatives = nodeOutcomes(node).filter(outcome => outcome !== DELIVERED_OUTCOME || !delegatesWriting(node) || routes(node.id, outcome).length > 0).map(outcome => {
251
+ const alternatives = routedOutcomes(node, graph.edges).filter(outcome => outcome !== DELIVERED_OUTCOME || !delegatesWriting(node) || routes(node.id, outcome).length > 0).map(outcome => {
342
252
  const reached = new Set();
343
253
  for (const edge of routes(node.id, outcome))
344
254
  for (const id of guaranteed.get(edge.target))
@@ -380,24 +290,9 @@ export function minimumGraphToolCalls(graph) {
380
290
  }
381
291
  return [...calls.values()].reduce((total, count) => total + count, 0);
382
292
  }
383
- /**
384
- * Whether a configured tool-call ceiling is at least what the graph needs.
385
- *
386
- * An absent ceiling means unlimited, so it always satisfies the minimum. Comparing
387
- * against the old numeric default instead would read an unset limit as "no budget"
388
- * and reject a graph that is in fact unbounded.
389
- * @param configured - the graph's explicit ceiling, or undefined when unlimited.
390
- * @param minimum - the fewest tool calls the graph provably needs.
391
- * @returns whether the graph can afford its guaranteed tool calls.
392
- */
393
293
  function meetsMinimumToolCalls(configured, minimum) {
394
294
  return configured === undefined || configured >= minimum;
395
295
  }
396
- /**
397
- * Raise a graph's explicit tool-call ceiling to the minimum its guaranteed
398
- * invocations need. An unlimited graph needs no ceiling, so this is a no-op then.
399
- * @param graph - graph being migrated in place.
400
- */
401
296
  function raiseGraphToolCallsToMinimum(graph) {
402
297
  const configured = graph.limits?.maxToolCalls;
403
298
  if (configured === undefined)
@@ -410,41 +305,15 @@ function bounds(value, label, max = 1_000_000_000, min = 1) {
410
305
  if (value !== undefined && (!Number.isSafeInteger(value) || value < min || value > max))
411
306
  fail(`${label} must be an integer between ${min} and ${max}`);
412
307
  }
413
- /**
414
- * Erase the explicit `0` spelling of an unlimited deadline-shaped bound.
415
- *
416
- * Internally an absent key is the only spelling of unlimited, so the alias is resolved at the
417
- * one boundary where graph JSON enters rather than making every consumer handle two
418
- * encodings. A zero tool-call ceiling is untouched: there it genuinely means "no calls".
419
- * @param holder - the object owning the limit.
420
- * @param key - the limit key to normalize.
421
- */
422
308
  function normalizeUnlimited(holder, key) {
423
309
  const limits = holder;
424
310
  if (limits[key] === 0)
425
311
  delete limits[key];
426
312
  }
427
- /**
428
- * The visit ceiling a graph enforces on each node, or `Infinity` when it enforces none.
429
- *
430
- * Node visits are unlimited unless a graph says otherwise: the setting's default is `0`, and a
431
- * `0` is normalized away, so an absent limit is the single internal spelling of "no ceiling".
432
- * @param graph - the graph whose limits apply.
433
- * @returns the maximum visits per node, or Infinity when visits are unbounded.
434
- */
435
313
  export function maxNodeVisitsOf(graph) {
436
314
  const limit = graph.limits?.maxNodeVisits;
437
315
  return limit === undefined || limit === 0 ? Infinity : limit;
438
316
  }
439
- /**
440
- * Whether a graph's run is bounded well enough for a return connection to terminate.
441
- *
442
- * A cycle repeats the same agents until something stops it. Visits are unlimited by default, so
443
- * a cycle needs a ceiling of its own: a finite visit count, or the run's wall clock, which
444
- * advances whatever the agents do.
445
- * @param graph - the validated graph.
446
- * @returns whether the graph bounds how long its cycles may run.
447
- */
448
317
  function hasRunCeiling(graph) {
449
318
  return graph.limits?.maxNodeVisits !== undefined || graph.limits?.wallTimeMs !== undefined;
450
319
  }
@@ -496,13 +365,6 @@ function toolsValid(value, label) {
496
365
  fail(`${label}: tools must be unique supported tool names`);
497
366
  }
498
367
  export function validateGraph(value, options = {}) { return validateGraphInternal(value, options); }
499
- /**
500
- * The agent nodes a run can reach after this node, nearest first, without the node itself.
501
- *
502
- * Every outgoing edge counts whatever its outcome, so the list is what may run after the node,
503
- * not what will: a node told what later nodes exist leaves their work to them rather than doing
504
- * it early. A node a loop leads back to is still excluded, because it is this node.
505
- */
506
368
  export function laterAgentNodes(graph, nodeId) {
507
369
  const seen = new Set([nodeId]);
508
370
  const later = [];
@@ -520,35 +382,14 @@ export function laterAgentNodes(graph, nodeId) {
520
382
  }
521
383
  return later;
522
384
  }
523
- /**
524
- * Whether a node's name says it tests the change: "QA Tester", "Test runner", "Verifier".
525
- *
526
- * Graphs declare no testing role, so the name is the evidence a graph author gives; a name that
527
- * does not say so is treated as not testing, which leaves the node's predecessors told to verify
528
- * their own work as before.
529
- */
530
385
  export function isTestingNode(node) {
531
386
  return /\b(?:qa|tests?|tester|testing|verif(?:y|ier|ication))\b/i.test(node.name ?? '');
532
387
  }
533
- /**
534
- * The testing node this node's work is sure to pass through: every outcome the node can complete
535
- * with routes, along every path, through a testing node before the run can end. Absent when any
536
- * route can finish untested — a delegating Orchestrator's `delivered` edge straight to Done, an
537
- * outcome no edge handles (this node's or any node's on the way), or a branch that reaches an end
538
- * first — because a node told to leave
539
- * the running app to a tester must not be one whose work can ship without that tester.
540
- *
541
- * A path that leads back to the node itself is not an escape: the node runs again and its own
542
- * routes are the ones being checked.
543
- */
544
388
  export function testerOnEveryRoute(graph, nodeId) {
545
389
  const node = graph.nodes[nodeId];
546
390
  if (node === undefined)
547
391
  return undefined;
548
- // The targets of each outcome a node declares, the way the runner routes them: an edge with no
549
- // outcome is the `completed` route. A declared outcome with no edge is an empty route, which ends
550
- // the run there (a graph saved with `requireRoutes: false` may leave one unconnected).
551
- const routes = (id, of) => nodeOutcomes(of).map(outcome => (graph.edges ?? []).filter(edge => edge.source === id && (edge.outcome ?? 'completed') === outcome).map(edge => edge.target));
392
+ const routes = (id, of) => routedOutcomes({ ...of, id }, graph.edges ?? []).map(outcome => (graph.edges ?? []).filter(edge => edge.source === id && (edge.outcome ?? 'completed') === outcome).map(edge => edge.target));
552
393
  const seen = new Set([nodeId]);
553
394
  const stack = [];
554
395
  for (const targets of routes(nodeId, node)) {
@@ -569,7 +410,6 @@ export function testerOnEveryRoute(graph, nodeId) {
569
410
  tester ??= next.name;
570
411
  continue;
571
412
  }
572
- // Every outcome of a node on the way counts, not only the ones the graph happened to connect.
573
413
  const nextRoutes = routes(id, next);
574
414
  if (nextRoutes.length === 0 || nextRoutes.some(targets => targets.length === 0))
575
415
  return undefined;
@@ -578,16 +418,6 @@ export function testerOnEveryRoute(graph, nodeId) {
578
418
  }
579
419
  return tester;
580
420
  }
581
- /**
582
- * Whether a run of this graph can execute the session's own provider/model pair.
583
- *
584
- * An agent node that omits its provider resolves against the live session pair, so the run's own
585
- * adapter is reachable and its metadata has to be resolved. When every agent node names its own
586
- * provider, every model call resolves against that node's provider instead — this is the same
587
- * predicate the desktop's model-pinning read applies when it hides the session model controls —
588
- * and a run of the graph cannot consult the session pair at all. A graph with no agent node leaves
589
- * it unused as well.
590
- */
591
421
  export function graphLeavesNodesToSession(graph) {
592
422
  const agents = Object.values(graph?.nodes ?? {}).filter(node => node.type === 'agent');
593
423
  return agents.length === 0 || agents.some(node => node.provider === undefined);
@@ -617,8 +447,6 @@ function validateGraphInternal(value, options = {}) {
617
447
  if (graph.metadata !== undefined) {
618
448
  if (!record(graph.metadata))
619
449
  fail('graph metadata must be an object');
620
- // Studio layout data has a dedicated versioned key; metadata.groups was
621
- // previously unrestricted extension data and must not be reinterpreted.
622
450
  const groups = graph.metadata.studioLayoutGroupsV1;
623
451
  if (groups !== undefined) {
624
452
  if (!Array.isArray(groups) || groups.length > 50)
@@ -639,10 +467,6 @@ function validateGraphInternal(value, options = {}) {
639
467
  }
640
468
  }
641
469
  }
642
- // A zero tool-call ceiling is valid: it permits a node to complete without tools while
643
- // refusing any call. The runtime accepts it, so the validator must too, or a graph the
644
- // editor offers to save cannot be saved. A zero wall time, iteration or node-visit ceiling
645
- // is a different thing — the explicit spelling of unlimited — and is normalized away below.
646
470
  if (graph.limits !== undefined) {
647
471
  if (!record(graph.limits))
648
472
  fail('limits must be an object');
@@ -766,9 +590,6 @@ function validateGraphInternal(value, options = {}) {
766
590
  fail(`${label}: node limits are supported only on Agent nodes; remove them and use graph limits (or loop.maxIterations for a Loop)`);
767
591
  if (node.agentRole === 'orchestrator')
768
592
  validateOrchestratorContracts(node, label);
769
- // `maxTokens` is accepted but ignored: graphs saved before the cumulative token
770
- // ceiling was removed still carry it, and rejecting an unknown key would make those
771
- // graphs fail to load instead of simply dropping a setting that no longer applies.
772
593
  if (node.limits !== undefined) {
773
594
  if (!record(node.limits))
774
595
  fail(`${label}: limits must be an object`);
@@ -877,8 +698,6 @@ function validateGraphInternal(value, options = {}) {
877
698
  const s = node.subagents;
878
699
  if (!record(s) || typeof s.enabled !== 'boolean')
879
700
  fail(`${label}: subagents.enabled must be boolean`);
880
- // The two subagent token budgets are accepted but ignored for the same reason as
881
- // node maxTokens: previously saved graphs must keep loading.
882
701
  for (const key of Object.keys(s)) {
883
702
  if (key === 'maxTokensPerSubagent' || key === 'maxCombinedTokens')
884
703
  continue;
@@ -924,22 +743,15 @@ function validateGraphInternal(value, options = {}) {
924
743
  fail(`${label}: task-only context cannot supply required inputs for role ${r.id}; select selected context or make the role inputs optional`);
925
744
  if (r.capabilities)
926
745
  capabilities(r.capabilities, `${label} role ${r.id}`);
927
- // A writing role on an Orchestrator is a delegated one: delegatesWriting(node) && isWritingRole(r),
928
- // spelled out per role so that roles not yet shape-checked by this loop are never inspected.
929
746
  const delegated = node.agentRole === 'orchestrator' && spawningEnabled && isWritingRole(r);
930
747
  if (delegated && (s.workspace ?? 'shared-read-only') !== 'worktree')
931
748
  fail(`${label}: writing roles on an Orchestrator require separate worktrees; set subagents.workspace to "worktree" (Separate Git worktree)`);
932
- if (delegated && node.completion?.mode === 'outcomes')
933
- fail(`${label}: Orchestrator delegation needs a single completion outcome; remove declared outcomes or the writing roles`);
934
- if (delegated && node.completion?.mode === 'single' && node.completion.outcome === DELIVERED_OUTCOME)
749
+ if (delegated && (node.completion?.mode === 'outcomes' ? node.completion.outcomes.includes(DELIVERED_OUTCOME) : node.completion?.outcome === DELIVERED_OUTCOME))
935
750
  fail(`${label}: the outcome name ${DELIVERED_OUTCOME} is reserved for Orchestrator delegation; rename the completion outcome`);
936
- // Two ceilings: the Orchestrator itself and its read-only roles stay under the intake ceiling;
937
- // a delegated writing role is measured against the node's configured capabilities.
938
751
  const parent = node.agentRole === 'orchestrator' && spawningEnabled && !delegated ? intakeCapabilities(node) : effectiveCapabilities(node);
939
752
  const child = r.capabilities ?? { ...parent, ...((s.workspace ?? 'shared-read-only') === 'shared-read-only' ? { filesystem: parent.filesystem === 'none' ? 'none' : 'read', git: parent.git === 'none' ? 'none' : 'read', shell: 'disabled' } : {}) };
940
753
  if (!capabilitySubset(child, parent))
941
754
  fail(`${label}: role ${r.id} capability exceeds parent${node.agentRole === 'orchestrator' && !delegated ? ' intake read-only ceiling; reduce child permissions' : '; reduce child permissions or explicitly grant them to the parent'}`);
942
- // The delegation ceiling is the node's capabilities alone: the Orchestrator's own tool list is its intake kit.
943
755
  if (r.tools?.some(t => !permitsBuiltInTool(delegated ? { capabilities: parent } : { ...node, capabilities: parent }, t)))
944
756
  fail(`${label}: role ${r.id} tools exceed effective parent capabilities; reduce its tools or explicitly grant parent permissions`);
945
757
  if (r.tools?.some(t => !permitsBuiltInTool({ capabilities: child }, t, delegated ? 'delegated-worktree' : true)))
@@ -970,7 +782,7 @@ function validateGraphInternal(value, options = {}) {
970
782
  if (!validId(edge.id) || ids.has(edge.id))
971
783
  fail('duplicate/invalid edge id; assign a unique safe identifier');
972
784
  ids.add(edge.id);
973
- if (!nodeOutcomes(graph.nodes[edge.source]).includes(edge.outcome))
785
+ if (!nodeOutcomes(graph.nodes[edge.source]).includes(edge.outcome) && !optionalOutcomes(graph.nodes[edge.source]).includes(edge.outcome))
974
786
  fail(`edge ${edge.id}: nonexistent outcome ${edge.outcome}; select a declared output port`);
975
787
  if (edge.toInput !== undefined && !validId(edge.toInput))
976
788
  fail(`edge ${edge.id}: invalid target input name`);
@@ -1041,14 +853,11 @@ function validateGraphInternal(value, options = {}) {
1041
853
  entriesRequired = Math.max(entriesRequired, graph.nodes[outerId].loop.maxIterations);
1042
854
  }
1043
855
  const minimumVisits = node.loop.maxIterations + entriesRequired;
1044
- // An unlimited visit budget can always reach the done outcome, so the check is about a
1045
- // finite cap that is too small to get there.
1046
856
  if (maxNodeVisitsOf(graph) < minimumVisits)
1047
857
  fail(`Loop ${id}: set graph limits.maxNodeVisits to at least ${minimumVisits} so the body cycle and enclosing reentries can return for the done outcome`);
1048
858
  }
1049
859
  if (node.type === 'condition' && (node.condition.source === id || canReach(graph.entry, id, node.condition.source)))
1050
860
  fail(`Condition ${id}: source ${node.condition.source} must execute on every path before this condition; route through the source first`);
1051
- // A delegating Orchestrator's delivered port is optional: unrouted, the graph behaves like intake.
1052
861
  for (const outcome of nodeOutcomes(node))
1053
862
  if (!(node.completion?.mode === 'outcomes' && node.completion.requireRoutes === false) && !(outcome === DELIVERED_OUTCOME && delegatesWriting(node)) && !(outgoing.get(id) ?? []).some(e => e.outcome === outcome))
1054
863
  fail(`node ${id}: required outcome ${outcome} has no route; connect its output port`);
@@ -1056,8 +865,6 @@ function validateGraphInternal(value, options = {}) {
1056
865
  const edges = (incoming.get(id) ?? []).filter(edge => !edge.bootstrap);
1057
866
  if (!edges.length)
1058
867
  fail(`Join ${id} needs an incoming branch`);
1059
- // Like bootstrap entry, direct entry skips the first barrier. Each cyclic
1060
- // return then advances its own generation, so multiple returns cannot join.
1061
868
  if (graph.schemaVersion === 3 && graph.entry === id && edges.length > 1)
1062
869
  fail(`Join ${id}: direct-start Join all supports only one ordinary cyclic incoming branch; use Join any or a single return branch`);
1063
870
  if (graph.schemaVersion === 3 && edges.some(edge => canReach(graph.entry, edge.source, id)) && edges.some(edge => canReach(id, edge.source)))
@@ -1075,7 +882,7 @@ function validateGraphInternal(value, options = {}) {
1075
882
  fail(`Join ${id}: returning Loop ${loopId} advances generations independently of a sibling branch; use Join any or move the Loop before the shared fan-out`);
1076
883
  }
1077
884
  for (const [ancestorId, ancestor] of entries) {
1078
- if (nodeOutcomes(ancestor).length < 2)
885
+ if (routedOutcomes(ancestor, graph.edges).length < 2)
1079
886
  continue;
1080
887
  const reaches = (start, target, seen = new Set()) => { if (start === target)
1081
888
  return true; if (start === id || start === ancestorId || seen.has(start))
@@ -1106,14 +913,9 @@ function validateGraphInternal(value, options = {}) {
1106
913
  if (!['read', 'find', 'grep', 'ls', 'read_file', 'list_files', 'search_files', 'repo_explore'].some(tool => permitsBuiltInTool(orchestrators[0][1], tool)))
1107
914
  fail('Orchestrator requires a usable research path; enable a filesystem read tool and filesystem read access');
1108
915
  const intake = orchestrators[0][1];
1109
- // An unlimited iteration ceiling has no upper bound at all, so it satisfies the minimum
1110
- // trivially. Only an explicit ceiling that is too small can fail this check; treating an
1111
- // absent bound as `3` would have made the check pass for the wrong reason.
1112
916
  const intakeIterations = [intake.maxIterations, intake.limits?.maxIterations].filter((value) => typeof value === 'number' && value > 0);
1113
917
  if (intakeIterations.length && Math.min(...intakeIterations) < 3)
1114
918
  fail('Orchestrator requires at least three model iterations; raise maxIterations or limits.maxIterations for research, clarification and completion, or leave them unset for no ceiling; todo-only turns have a separate budget');
1115
- // An absent ceiling is unlimited, which satisfies the Orchestrator minimum; only
1116
- // an explicit ceiling that is too small fails.
1117
919
  if (!meetsMinimumToolCalls(intake.limits?.maxToolCalls, 2))
1118
920
  fail('Orchestrator requires at least two tool calls; increase node limits.maxToolCalls for research and ask_user');
1119
921
  if (!meetsMinimumToolCalls(graph.limits?.maxToolCalls, 2))
@@ -1134,25 +936,16 @@ function validateGraphInternal(value, options = {}) {
1134
936
  export class GraphConflictError extends Error {
1135
937
  constructor(message = 'This graph changed in another editor. Reload it before saving.') { super(message); this.name = 'GraphConflictError'; }
1136
938
  }
1137
- /**
1138
- * A soft-deleted graph: its latest revision carries `metadata.deletedAt`.
1139
- *
1140
- * Deleting publishes that revision rather than removing files, because cloud sync restores every graph
1141
- * an account holds and would bring removed files back. Every earlier revision stays stored.
1142
- */
1143
939
  export function isDeletedGraph(graph) {
1144
940
  return typeof graph.metadata?.deletedAt === 'string' && graph.metadata.deletedAt.length > 0;
1145
941
  }
1146
- /** What a listing shows. Quota is computed from the full list, so deleted graphs still count there. */
1147
942
  export function withoutDeletedGraphs(graphs) {
1148
943
  return graphs.filter(graph => !isDeletedGraph(graph));
1149
944
  }
1150
- /** A new run named a deleted graph. Resuming a session that already ran it is still allowed. */
1151
945
  export class GraphDeletedError extends Error {
1152
946
  code = 'GRAPH_DELETED';
1153
947
  constructor(name) { super(`Graph ${name} was deleted. Restore it before running it.`); this.name = 'GraphDeletedError'; }
1154
948
  }
1155
- /** Whether the folder holds a published graph: a save's latest pointer or any numbered revision. */
1156
949
  async function publishedRevision(folder) {
1157
950
  try {
1158
951
  await readFile(join(folder, 'latest.json'), 'utf8');
@@ -1172,13 +965,6 @@ async function publishedRevision(folder) {
1172
965
  return error.code !== 'ENOENT';
1173
966
  }
1174
967
  }
1175
- /**
1176
- * Publish an immutable cloud revision only when the local revision is absent or identical.
1177
- *
1178
- * `skip` and `floorOf` are consulted under the folder's save lock immediately before any write:
1179
- * a graph deleted on this machine must not be written back, and asking while holding the lock
1180
- * makes those verdicts final against a delete or revival that is still running.
1181
- */
1182
968
  export async function restoreGraphRevision(input, directory, skip, floorOf) {
1183
969
  const graph = validateGraphInternal(input);
1184
970
  if (graph.id === 'default' || graph.revision < 1)
@@ -1191,16 +977,10 @@ export async function restoreGraphRevision(input, directory, skip, floorOf) {
1191
977
  const temp = join(folder, `latest-${randomUUID()}.tmp`);
1192
978
  try {
1193
979
  if (skip && await skip(graph)) {
1194
- // The tombstone is the authority: what this restore finds here is either residue from a
1195
- // restore that raced the delete — removed under the lock — or a graph a save re-created
1196
- // after the delete and before the tombstone revival cleared it. Erasing that re-creation
1197
- // would lose a save that already succeeded, so only an unpublished folder is removed.
1198
980
  if (!await publishedRevision(folder))
1199
981
  await removeLockedFolder(folder);
1200
982
  return { graph, restored: false };
1201
983
  }
1202
- // The latest pointer is read before any write: the floor verdict below needs it, and a
1203
- // damaged pointer must refuse the restore before the folder receives new content.
1204
984
  let current = 0;
1205
985
  try {
1206
986
  const raw = await readFile(join(folder, 'latest.json'), 'utf8');
@@ -1217,27 +997,10 @@ export async function restoreGraphRevision(input, directory, skip, floorOf) {
1217
997
  }
1218
998
  if (!Number.isSafeInteger(current) || current < 0)
1219
999
  throw new GraphConflictError('Invalid latest revision');
1220
- // A re-created id starts a new lineage. While a deletion floor is recorded for the id, cloud
1221
- // revisions above the replacement's head never advance its latest pointer: the floor the
1222
- // deleting machine recorded can sit behind the cloud (another device synced newer revisions
1223
- // it never pulled), so a revision above the floor is not proof of new-lineage history.
1224
- // New-lineage snapshots are unaffected — they were restored locally before their upload, so
1225
- // their revisions never exceed the head. A device with no local graph at all still adopts
1226
- // revisions above the floor: only what the deleting machine had already seen is known to
1227
- // belong to the deleted lineage. Everything else stays in the immutable snapshot cache,
1228
- // which would otherwise make the replacement open as the old graph again.
1229
1000
  const floor = floorOf ? await floorOf(graph) : undefined;
1230
1001
  if (floor !== undefined && current < graph.revision && (current >= 1 || graph.revision <= floor)) {
1231
- // A live replacement can still take a later revision of its own lineage: storage pins
1232
- // metadata.createdAt per lineage (a save takes it from the stored head, never from the
1233
- // submitted graph), every save of the lineage preserves it, and a foreign lineage cannot
1234
- // produce it. A snapshot above the head that carries the replacement's creation time is a
1235
- // later edit of the replacement — another device that adopted it and saved — so it advances
1236
- // the pointer like any save. Anything else belongs to the deleted lineage the floor keeps
1237
- // out: the replacement is young, or the revision predates it, or no replacement lives here.
1238
1002
  let replacementCreatedAt;
1239
1003
  if (current >= 1) {
1240
- // An unreadable head cannot vouch for any lineage, so the verdict stays refusal.
1241
1004
  try {
1242
1005
  replacementCreatedAt = JSON.parse(await readFile(join(folder, `${current}.json`), 'utf8'))?.metadata?.createdAt;
1243
1006
  }
@@ -1290,7 +1053,6 @@ export async function loadGraph(id, revision, directory = configDirectory()) {
1290
1053
  throw new Error('Default graph revision does not exist');
1291
1054
  return structuredClone(revision === 1 ? LEGACY_DEFAULT_HARNESS : revision === 2 ? DEFAULT_HARNESS_REVISION_2 : revision === 3 ? DEFAULT_HARNESS_REVISION_3 : revision === 4 ? DEFAULT_HARNESS_REVISION_4 : revision === 5 ? DEFAULT_HARNESS_REVISION_5 : revision === 6 ? DEFAULT_HARNESS : DEFAULT_GRAPH);
1292
1055
  }
1293
- // Built in like `default`: answered before storage is read, so a folder of the same name is never loaded.
1294
1056
  if (id === GRAPH_MANAGER_GRAPH_ID) {
1295
1057
  if (revision !== undefined && revision !== GRAPH_MANAGER_HARNESS.revision)
1296
1058
  throw new Error('Graph Manager graph revision does not exist');
@@ -1305,6 +1067,16 @@ export async function loadGraph(id, revision, directory = configDirectory()) {
1305
1067
  throw new Error('Stored graph identity does not match its revision');
1306
1068
  return graph;
1307
1069
  }
1070
+ const GRAPH_ORDER_FILE = 'order.json';
1071
+ const readGraphOrder = async (directory) => {
1072
+ try {
1073
+ const stored = JSON.parse(await readFile(join(directory, 'graphs', GRAPH_ORDER_FILE), 'utf8'));
1074
+ return Array.isArray(stored) ? stored.filter(item => typeof item === 'string' && validId(item)) : [];
1075
+ }
1076
+ catch {
1077
+ return [];
1078
+ }
1079
+ };
1308
1080
  export async function listGraphs(directory = configDirectory(), onLoadError) {
1309
1081
  let entries;
1310
1082
  try {
@@ -1315,17 +1087,54 @@ export async function listGraphs(directory = configDirectory(), onLoadError) {
1315
1087
  return [structuredClone(DEFAULT_GRAPH)];
1316
1088
  throw error;
1317
1089
  }
1318
- const graphs = [structuredClone(DEFAULT_GRAPH)];
1090
+ const loaded = new Map();
1319
1091
  for (const entry of entries.filter(item => item.isDirectory() && validId(item.name) && item.name !== 'default' && item.name !== GRAPH_MANAGER_GRAPH_ID).sort((a, b) => a.name.localeCompare(b.name))) {
1320
1092
  try {
1321
- graphs.push(await loadGraph(entry.name, undefined, directory));
1093
+ loaded.set(entry.name, await loadGraph(entry.name, undefined, directory));
1322
1094
  }
1323
1095
  catch (error) {
1324
1096
  onLoadError?.(entry.name, error);
1325
1097
  }
1326
1098
  }
1099
+ const graphs = [structuredClone(DEFAULT_GRAPH)];
1100
+ const ordered = new Set();
1101
+ for (const id of await readGraphOrder(directory)) {
1102
+ const graph = loaded.get(id);
1103
+ if (!graph)
1104
+ continue;
1105
+ graphs.push(graph);
1106
+ ordered.add(id);
1107
+ }
1108
+ for (const id of [...loaded.keys()].filter(id => !ordered.has(id)).sort((a, b) => a.localeCompare(b)))
1109
+ graphs.push(loaded.get(id));
1327
1110
  return graphs;
1328
1111
  }
1112
+ export async function saveGraphOrder(order, directory = configDirectory()) {
1113
+ if (!Array.isArray(order))
1114
+ throw new Error('Graph order must be an array of graph ids');
1115
+ const ids = [];
1116
+ for (const id of order) {
1117
+ if (!validId(id))
1118
+ throw new Error('Graph order must be an array of graph ids');
1119
+ if (id === 'default')
1120
+ throw new Error('The bundled default graph is always first; do not include it in the order');
1121
+ if (id === GRAPH_MANAGER_GRAPH_ID)
1122
+ throw reservedGraphId(id);
1123
+ if (!ids.includes(id))
1124
+ ids.push(id);
1125
+ }
1126
+ const folder = join(directory, 'graphs');
1127
+ await mkdir(folder, { recursive: true });
1128
+ const temporary = join(folder, `order-${randomUUID()}.tmp`);
1129
+ try {
1130
+ await writeFile(temporary, JSON.stringify(ids) + '\n', { flag: 'wx', mode: 0o600 });
1131
+ await rename(temporary, join(folder, GRAPH_ORDER_FILE));
1132
+ }
1133
+ finally {
1134
+ await unlink(temporary).catch(() => { });
1135
+ }
1136
+ return ids;
1137
+ }
1329
1138
  export async function saveGraph(input, expectedRevision, directory = configDirectory()) {
1330
1139
  const graph = validateGraph(input);
1331
1140
  if (graph.id === 'default')
@@ -1361,8 +1170,6 @@ export async function saveGraph(input, expectedRevision, directory = configDirec
1361
1170
  if ((current?.revision ?? null) !== expectedRevision)
1362
1171
  throw new GraphConflictError();
1363
1172
  graph.revision = (expectedRevision ?? 0) + 1;
1364
- // The creation time comes from storage, not the submitted graph: it decides which graph a free
1365
- // account keeps, so a save cannot move it.
1366
1173
  const now = new Date().toISOString();
1367
1174
  const createdAt = current ? current.metadata?.createdAt : now;
1368
1175
  graph.metadata = { ...graph.metadata, updatedAt: now };
@@ -1386,16 +1193,6 @@ export async function saveGraph(input, expectedRevision, directory = configDirec
1386
1193
  await releaseLock();
1387
1194
  }
1388
1195
  }
1389
- /**
1390
- * Remove a saved graph and its whole revision history.
1391
- *
1392
- * The save lock serializes against a save or cloud restore of the same graph, so a delete cannot
1393
- * race one into leaving a half-written folder behind. The folder leaves the live path in one
1394
- * rename while the lock is held, so a save that lands during the removal writes into a fresh
1395
- * folder and survives it. Deleting the bundled `default` is refused: it has no storage to remove,
1396
- * and a hidden preset would only return on the next launch. The built-in Graph Manager graph is
1397
- * refused for the same reason, by name.
1398
- */
1399
1196
  export async function deleteGraph(id, directory = configDirectory(), options = {}) {
1400
1197
  if (!validId(id) || id === 'default')
1401
1198
  throw new Error('Invalid graph id');