@andorra-labs/code 0.1.12 → 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 (592) hide show
  1. package/dist/src/account-presentation.d.ts +1 -37
  2. package/dist/src/account-presentation.js +2 -42
  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 +49 -416
  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 +9 -153
  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/anthropic-console-auth.d.ts +0 -24
  18. package/dist/src/anthropic-console-auth.js +0 -37
  19. package/dist/src/anthropic-credentials.d.ts +0 -25
  20. package/dist/src/anthropic-credentials.js +0 -28
  21. package/dist/src/app-server/protocol.d.ts +13 -245
  22. package/dist/src/app-server/protocol.js +1 -132
  23. package/dist/src/app-server/reasoning.d.ts +0 -31
  24. package/dist/src/app-server/reasoning.js +0 -54
  25. package/dist/src/app-server/terminal.d.ts +0 -36
  26. package/dist/src/app-server/terminal.js +3 -39
  27. package/dist/src/app-server/workspace.d.ts +0 -167
  28. package/dist/src/app-server/workspace.js +4 -406
  29. package/dist/src/app-server.d.ts +27 -927
  30. package/dist/src/app-server.js +537 -2992
  31. package/dist/src/artifacts.d.ts +0 -10
  32. package/dist/src/artifacts.js +1 -11
  33. package/dist/src/attachments.d.ts +4 -98
  34. package/dist/src/attachments.js +10 -130
  35. package/dist/src/auth/AuthManager.d.ts +0 -93
  36. package/dist/src/auth/AuthManager.js +3 -165
  37. package/dist/src/auth/callback-page.d.ts +0 -1
  38. package/dist/src/auth/callback-page.js +0 -4
  39. package/dist/src/auth/callback.d.ts +0 -25
  40. package/dist/src/auth/callback.js +1 -29
  41. package/dist/src/auth/deployment.d.ts +0 -16
  42. package/dist/src/auth/deployment.js +0 -16
  43. package/dist/src/auth/index.d.ts +0 -11
  44. package/dist/src/auth/index.js +0 -11
  45. package/dist/src/auth/lock.d.ts +0 -1
  46. package/dist/src/auth/lock.js +0 -1
  47. package/dist/src/auth/store.d.ts +7 -108
  48. package/dist/src/auth/store.js +21 -129
  49. package/dist/src/auth/types.d.ts +0 -8
  50. package/dist/src/auth-commands.d.ts +0 -5
  51. package/dist/src/auth-commands.js +0 -1
  52. package/dist/src/automation-runner.d.ts +0 -9
  53. package/dist/src/automation-runner.js +0 -11
  54. package/dist/src/automation-service.d.ts +0 -10
  55. package/dist/src/automation-service.js +3 -17
  56. package/dist/src/automation-tool.js +0 -5
  57. package/dist/src/automation-worker-shutdown.d.ts +0 -1
  58. package/dist/src/automation-worker-shutdown.js +0 -3
  59. package/dist/src/automations.d.ts +23 -2
  60. package/dist/src/automations.js +91 -12
  61. package/dist/src/background-tasks.d.ts +0 -23
  62. package/dist/src/background-tasks.js +0 -11
  63. package/dist/src/boot-trace.d.ts +0 -13
  64. package/dist/src/boot-trace.js +1 -14
  65. package/dist/src/browser-activity.js +0 -2
  66. package/dist/src/browser-bridge.d.ts +0 -2
  67. package/dist/src/browser-bridge.js +0 -27
  68. package/dist/src/browser-captcha-tool.d.ts +0 -13
  69. package/dist/src/browser-captcha-tool.js +3 -35
  70. package/dist/src/browser-extensions-tool.d.ts +24 -0
  71. package/dist/src/browser-extensions-tool.js +137 -0
  72. package/dist/src/browser-extensions.d.ts +127 -0
  73. package/dist/src/browser-extensions.js +729 -0
  74. package/dist/src/browser-observation.d.ts +0 -15
  75. package/dist/src/browser-observation.js +1 -22
  76. package/dist/src/browser-panel-tool.d.ts +1 -37
  77. package/dist/src/browser-panel-tool.js +3 -73
  78. package/dist/src/browser-runner.d.ts +0 -1
  79. package/dist/src/browser-runner.js +4 -45
  80. package/dist/src/browser-server.d.ts +0 -6
  81. package/dist/src/browser-server.js +6 -229
  82. package/dist/src/browser-session.d.ts +0 -25
  83. package/dist/src/browser-session.js +1 -71
  84. package/dist/src/browser-stealth.d.ts +0 -12
  85. package/dist/src/browser-stealth.js +0 -36
  86. package/dist/src/browser-ui/app.js +7 -174
  87. package/dist/src/browser-ui/style.css +0 -68
  88. package/dist/src/browser-ui/tokens.css +11 -93
  89. package/dist/src/browser-view.d.ts +47 -301
  90. package/dist/src/browser-view.js +333 -582
  91. package/dist/src/capabilities.d.ts +0 -8
  92. package/dist/src/capabilities.js +0 -29
  93. package/dist/src/capsolver.d.ts +0 -13
  94. package/dist/src/capsolver.js +0 -15
  95. package/dist/src/clarification-ui.d.ts +0 -7
  96. package/dist/src/clarification-ui.js +0 -8
  97. package/dist/src/claude-executable.d.ts +0 -1
  98. package/dist/src/claude-executable.js +1 -2
  99. package/dist/src/claude-provider.d.ts +6 -19
  100. package/dist/src/claude-provider.js +155 -63
  101. package/dist/src/cli-executable.d.ts +0 -16
  102. package/dist/src/cli-executable.js +0 -7
  103. package/dist/src/cli-process.d.ts +0 -26
  104. package/dist/src/cli-process.js +0 -18
  105. package/dist/src/cli-sign-in.d.ts +0 -20
  106. package/dist/src/cli-sign-in.js +1 -17
  107. package/dist/src/cli.d.ts +1 -55
  108. package/dist/src/cli.js +80 -721
  109. package/dist/src/code-intelligence/CodeIntelligenceManager.d.ts +4 -59
  110. package/dist/src/code-intelligence/CodeIntelligenceManager.js +26 -99
  111. package/dist/src/code-intelligence/ContextLedger.d.ts +0 -4
  112. package/dist/src/code-intelligence/ContextLedger.js +0 -10
  113. package/dist/src/code-intelligence/ContextRouter.d.ts +0 -6
  114. package/dist/src/code-intelligence/ContextRouter.js +0 -8
  115. package/dist/src/code-intelligence/codegraph/CodeGraphProjectSession.d.ts +0 -2
  116. package/dist/src/code-intelligence/codegraph/CodeGraphProjectSession.js +5 -12
  117. package/dist/src/code-intelligence/codegraph/CodeGraphProvider.d.ts +0 -6
  118. package/dist/src/code-intelligence/codegraph/CodeGraphProvider.js +0 -6
  119. package/dist/src/code-intelligence/codegraph/CodeGraphSyncBarrier.d.ts +0 -5
  120. package/dist/src/code-intelligence/codegraph/CodeGraphSyncBarrier.js +1 -17
  121. package/dist/src/code-intelligence/codegraph/repoExploreTool.d.ts +0 -5
  122. package/dist/src/code-intelligence/codegraph/repoExploreTool.js +0 -5
  123. package/dist/src/code-intelligence/repository.d.ts +0 -9
  124. package/dist/src/code-intelligence/repository.js +1 -11
  125. package/dist/src/code-intelligence/types.d.ts +0 -8
  126. package/dist/src/codex-auth.d.ts +0 -44
  127. package/dist/src/codex-auth.js +0 -45
  128. package/dist/src/codex-browser-auth.d.ts +0 -13
  129. package/dist/src/codex-browser-auth.js +3 -20
  130. package/dist/src/codex-errors.js +0 -2
  131. package/dist/src/codex-executable.d.ts +0 -2
  132. package/dist/src/codex-executable.js +1 -7
  133. package/dist/src/codex-provider.d.ts +0 -13
  134. package/dist/src/codex-provider.js +0 -28
  135. package/dist/src/codex-rpc.d.ts +0 -10
  136. package/dist/src/codex-rpc.js +0 -12
  137. package/dist/src/coding-tools.d.ts +4 -26
  138. package/dist/src/coding-tools.js +161 -181
  139. package/dist/src/command-metrics.d.ts +0 -4
  140. package/dist/src/command-output-tap.d.ts +0 -11
  141. package/dist/src/command-output-tap.js +0 -3
  142. package/dist/src/command-screens.d.ts +24 -0
  143. package/dist/src/command-screens.js +132 -100
  144. package/dist/src/commands.d.ts +6 -63
  145. package/dist/src/commands.js +20 -100
  146. package/dist/src/completion-gates.d.ts +0 -47
  147. package/dist/src/completion-gates.js +0 -14
  148. package/dist/src/completion.d.ts +0 -98
  149. package/dist/src/completion.js +2 -239
  150. package/dist/src/config.d.ts +11 -116
  151. package/dist/src/config.js +39 -171
  152. package/dist/src/context-budget.d.ts +0 -22
  153. package/dist/src/context-budget.js +0 -44
  154. package/dist/src/context-compaction.d.ts +29 -6
  155. package/dist/src/context-compaction.js +94 -25
  156. package/dist/src/context-selection.d.ts +0 -24
  157. package/dist/src/context-selection.js +0 -34
  158. package/dist/src/dashboard-view.d.ts +0 -2
  159. package/dist/src/dashboard-view.js +0 -35
  160. package/dist/src/dashboard.d.ts +0 -2
  161. package/dist/src/dashboard.js +0 -9
  162. package/dist/src/deadline.d.ts +0 -45
  163. package/dist/src/deadline.js +0 -54
  164. package/dist/src/decision/ContinuationAdapter.d.ts +0 -5
  165. package/dist/src/decision/ContinuationAdapter.js +0 -5
  166. package/dist/src/decision/DecisionEngine.d.ts +0 -4
  167. package/dist/src/decision/DecisionManager.d.ts +0 -1
  168. package/dist/src/decision/DecisionManager.js +2 -7
  169. package/dist/src/decision/DecisionPolicy.d.ts +0 -1
  170. package/dist/src/decision/DecisionPolicy.js +0 -1
  171. package/dist/src/decision/FactContinuations.d.ts +11 -43
  172. package/dist/src/decision/FactContinuations.js +126 -95
  173. package/dist/src/decision/FactServiceGate.d.ts +0 -1
  174. package/dist/src/decision/FactServiceGate.js +0 -4
  175. package/dist/src/decision/PreparedSteps.d.ts +0 -15
  176. package/dist/src/decision/PreparedSteps.js +0 -10
  177. package/dist/src/decision/applyToolMenu.d.ts +0 -1
  178. package/dist/src/decision/applyToolMenu.js +1 -5
  179. package/dist/src/decision/checks.d.ts +15 -28
  180. package/dist/src/decision/checks.js +118 -49
  181. package/dist/src/decision/facts.d.ts +0 -16
  182. package/dist/src/decision/facts.js +0 -30
  183. package/dist/src/decision/guidancePolicy.js +0 -1
  184. package/dist/src/decision/hostedPolicy.d.ts +0 -6
  185. package/dist/src/decision/hostedPolicy.js +0 -7
  186. package/dist/src/decision/hostedSkills.d.ts +0 -19
  187. package/dist/src/decision/hostedSkills.js +0 -19
  188. package/dist/src/decision/optimizationPolicy.d.ts +0 -3
  189. package/dist/src/decision/optimizationPolicy.js +1 -4
  190. package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +0 -7
  191. package/dist/src/decision/providers/AndorraDecisionProvider.js +4 -27
  192. package/dist/src/decision/providers/HttpDecisionProvider.d.ts +0 -2
  193. package/dist/src/decision/providers/HttpDecisionProvider.js +0 -6
  194. package/dist/src/decision/routeTools.d.ts +0 -8
  195. package/dist/src/decision/routeTools.js +1 -8
  196. package/dist/src/decision/toolFamilies.d.ts +0 -1
  197. package/dist/src/decision/toolFamilies.js +0 -1
  198. package/dist/src/decision/toolMenu.d.ts +0 -3
  199. package/dist/src/decision/toolMenu.js +0 -4
  200. package/dist/src/decision/types.d.ts +0 -6
  201. package/dist/src/default-graph.d.ts +0 -9
  202. package/dist/src/default-graph.js +0 -9
  203. package/dist/src/delegation-changes.d.ts +0 -56
  204. package/dist/src/delegation-changes.js +4 -130
  205. package/dist/src/diff-preview.d.ts +0 -1
  206. package/dist/src/diff-preview.js +0 -17
  207. package/dist/src/duration.d.ts +0 -50
  208. package/dist/src/duration.js +0 -50
  209. package/dist/src/efficiency.d.ts +0 -39
  210. package/dist/src/efficiency.js +0 -16
  211. package/dist/src/engine/protocol.d.ts +0 -2
  212. package/dist/src/engine/protocol.js +0 -2
  213. package/dist/src/engine-streams.d.ts +0 -9
  214. package/dist/src/extensions.d.ts +3 -2
  215. package/dist/src/extensions.js +63 -35
  216. package/dist/src/favicons.d.ts +0 -26
  217. package/dist/src/favicons.js +0 -34
  218. package/dist/src/file-diff.d.ts +2 -58
  219. package/dist/src/file-diff.js +0 -32
  220. package/dist/src/file-read-key.d.ts +0 -7
  221. package/dist/src/file-read-key.js +0 -7
  222. package/dist/src/file-read-state.d.ts +0 -1
  223. package/dist/src/file-read-state.js +0 -4
  224. package/dist/src/firefox-cookies.d.ts +0 -34
  225. package/dist/src/firefox-cookies.js +1 -55
  226. package/dist/src/git-identity-audit.d.ts +27 -0
  227. package/dist/src/git-identity-audit.js +286 -0
  228. package/dist/src/git-identity-guard.d.ts +4 -0
  229. package/dist/src/git-identity-guard.js +998 -0
  230. package/dist/src/git-identity-hold.d.ts +12 -0
  231. package/dist/src/git-identity-hold.js +81 -0
  232. package/dist/src/git-summary.d.ts +0 -58
  233. package/dist/src/git-summary.js +2 -212
  234. package/dist/src/goal-completion-verification.d.ts +2 -2
  235. package/dist/src/goal-completion-verification.js +3 -6
  236. package/dist/src/graph-account.d.ts +0 -21
  237. package/dist/src/graph-account.js +0 -17
  238. package/dist/src/graph-editor-session.d.ts +0 -1
  239. package/dist/src/graph-editor-session.js +0 -3
  240. package/dist/src/graph-health.d.ts +0 -63
  241. package/dist/src/graph-health.js +0 -57
  242. package/dist/src/graph-manager-chat.d.ts +5 -155
  243. package/dist/src/graph-manager-chat.js +2 -177
  244. package/dist/src/graph-provider-portability.d.ts +1 -21
  245. package/dist/src/graph-provider-portability.js +6 -45
  246. package/dist/src/graph-quota.d.ts +0 -33
  247. package/dist/src/graph-quota.js +1 -44
  248. package/dist/src/graph-runner.d.ts +0 -1
  249. package/dist/src/graph-runner.js +31 -391
  250. package/dist/src/graph-selection.d.ts +0 -14
  251. package/dist/src/graph-selection.js +0 -14
  252. package/dist/src/graph-server.d.ts +2 -10
  253. package/dist/src/graph-server.js +39 -101
  254. package/dist/src/graph-studio-features.d.ts +0 -5
  255. package/dist/src/graph-studio-features.js +2 -42
  256. package/dist/src/graph-sync.d.ts +0 -78
  257. package/dist/src/graph-sync.js +5 -201
  258. package/dist/src/graph-tool.d.ts +0 -18
  259. package/dist/src/graph-tool.js +0 -27
  260. package/dist/src/graph-ui/app.js +152 -491
  261. package/dist/src/graph-ui/compat.js +0 -7
  262. package/dist/src/graph-ui/controls.css +0 -48
  263. package/dist/src/graph-ui/controls.js +0 -88
  264. package/dist/src/graph-ui/drafts.js +0 -12
  265. package/dist/src/graph-ui/edge-router.js +0 -62
  266. package/dist/src/graph-ui/embed.js +0 -59
  267. package/dist/src/graph-ui/icons.js +0 -8
  268. package/dist/src/graph-ui/library.css +0 -5
  269. package/dist/src/graph-ui/manager-markdown.js +0 -11
  270. package/dist/src/graph-ui/manager-state.js +1 -78
  271. package/dist/src/graph-ui/manager.css +0 -18
  272. package/dist/src/graph-ui/manager.js +3 -180
  273. package/dist/src/graph-ui/model-picker.js +0 -29
  274. package/dist/src/graph-ui/sidebar.js +2 -3
  275. package/dist/src/graph-ui/skill-picker.js +373 -39
  276. package/dist/src/graph-ui/studio-canvas.js +3 -38
  277. package/dist/src/graph-ui/studio.css +0 -18
  278. package/dist/src/graph-ui/studio.js +3 -71
  279. package/dist/src/graph-ui/style.css +11 -134
  280. package/dist/src/graph-ui/theme.js +1 -26
  281. package/dist/src/graph-ui/tokens.css +15 -114
  282. package/dist/src/graphs.d.ts +6 -157
  283. package/dist/src/graphs.js +65 -266
  284. package/dist/src/grep-regex-worker.js +0 -2
  285. package/dist/src/grep-regex.d.ts +1 -5
  286. package/dist/src/grep-regex.js +6 -8
  287. package/dist/src/grok-provider.d.ts +0 -17
  288. package/dist/src/grok-provider.js +1 -26
  289. package/dist/src/handoffs.d.ts +0 -11
  290. package/dist/src/handoffs.js +0 -13
  291. package/dist/src/hardened-runtime.d.ts +0 -10
  292. package/dist/src/hardened-runtime.js +8 -46
  293. package/dist/src/harness-home.d.ts +21 -0
  294. package/dist/src/harness-home.js +87 -0
  295. package/dist/src/host-process-guard.d.ts +0 -50
  296. package/dist/src/host-process-guard.js +0 -641
  297. package/dist/src/limits.d.ts +0 -64
  298. package/dist/src/limits.js +0 -62
  299. package/dist/src/managed-sign-in.d.ts +0 -12
  300. package/dist/src/managed-sign-in.js +0 -16
  301. package/dist/src/markdown.d.ts +0 -28
  302. package/dist/src/markdown.js +1 -175
  303. package/dist/src/mcp.d.ts +0 -99
  304. package/dist/src/mcp.js +4 -170
  305. package/dist/src/membership-errors.d.ts +0 -14
  306. package/dist/src/membership-errors.js +0 -13
  307. package/dist/src/membership.d.ts +2 -60
  308. package/dist/src/membership.js +0 -85
  309. package/dist/src/memory/LocalToolMemory.d.ts +0 -1
  310. package/dist/src/memory/LocalToolMemory.js +2 -7
  311. package/dist/src/memory/MemoryDistiller.js +0 -15
  312. package/dist/src/memory/MemoryManager.d.ts +0 -3
  313. package/dist/src/memory/MemoryManager.js +6 -18
  314. package/dist/src/memory/MemoryPolicy.d.ts +0 -2
  315. package/dist/src/memory/MemoryPolicy.js +0 -2
  316. package/dist/src/memory/MemoryProvider.d.ts +0 -6
  317. package/dist/src/memory/MemoryRetriever.js +0 -7
  318. package/dist/src/memory/PermissionMemoryProvider.d.ts +0 -1
  319. package/dist/src/memory/PermissionMemoryProvider.js +0 -1
  320. package/dist/src/memory/ProjectMemory.d.ts +5 -40
  321. package/dist/src/memory/ProjectMemory.js +22 -47
  322. package/dist/src/memory/ToolFailureLessons.d.ts +0 -3
  323. package/dist/src/memory/ToolFailureLessons.js +0 -6
  324. package/dist/src/memory/providers/NoOpMemoryProvider.d.ts +0 -1
  325. package/dist/src/memory/providers/NoOpMemoryProvider.js +0 -1
  326. package/dist/src/memory/redaction.d.ts +0 -5
  327. package/dist/src/memory/redaction.js +0 -11
  328. package/dist/src/memory/repository.d.ts +0 -6
  329. package/dist/src/memory/repository.js +2 -12
  330. package/dist/src/memory/types.d.ts +0 -1
  331. package/dist/src/model-health-cache.d.ts +0 -38
  332. package/dist/src/model-health-cache.js +1 -49
  333. package/dist/src/model-metadata.d.ts +0 -18
  334. package/dist/src/model-metadata.js +2 -42
  335. package/dist/src/model-override.d.ts +0 -36
  336. package/dist/src/model-override.js +0 -43
  337. package/dist/src/model-tiers.d.ts +0 -13
  338. package/dist/src/model-tiers.js +0 -23
  339. package/dist/src/opencode-catalog.d.ts +0 -2
  340. package/dist/src/opencode-catalog.js +0 -11
  341. package/dist/src/opencode-cli-provider.d.ts +0 -35
  342. package/dist/src/opencode-cli-provider.js +1 -44
  343. package/dist/src/opencode-provider.d.ts +0 -2
  344. package/dist/src/opencode-provider.js +1 -16
  345. package/dist/src/package-name.d.ts +0 -2
  346. package/dist/src/package-name.js +0 -2
  347. package/dist/src/paged-transcript.d.ts +0 -11
  348. package/dist/src/paged-transcript.js +2 -20
  349. package/dist/src/palette.d.ts +0 -63
  350. package/dist/src/palette.js +0 -63
  351. package/dist/src/permissions.d.ts +0 -15
  352. package/dist/src/permissions.js +0 -17
  353. package/dist/src/powershell-pool.d.ts +0 -9
  354. package/dist/src/powershell-pool.js +3 -26
  355. package/dist/src/process-warnings.d.ts +4 -0
  356. package/dist/src/process-warnings.js +103 -0
  357. package/dist/src/profile.d.ts +0 -43
  358. package/dist/src/profile.js +0 -43
  359. package/dist/src/project-reservation.d.ts +11 -0
  360. package/dist/src/project-reservation.js +143 -0
  361. package/dist/src/provider-connection.d.ts +0 -18
  362. package/dist/src/provider-connection.js +0 -39
  363. package/dist/src/provider-engine.d.ts +0 -21
  364. package/dist/src/provider-engine.js +1 -96
  365. package/dist/src/provider-import.d.ts +0 -49
  366. package/dist/src/provider-import.js +0 -60
  367. package/dist/src/provider-keys.d.ts +1 -36
  368. package/dist/src/provider-keys.js +5 -48
  369. package/dist/src/provider-settings.d.ts +0 -2
  370. package/dist/src/provider-settings.js +0 -32
  371. package/dist/src/providers.d.ts +0 -217
  372. package/dist/src/providers.js +0 -315
  373. package/dist/src/pull-requests.d.ts +0 -173
  374. package/dist/src/pull-requests.js +5 -195
  375. package/dist/src/qa/browser/PlaywrightRunner.d.ts +0 -7
  376. package/dist/src/qa/browser/PlaywrightRunner.js +2 -16
  377. package/dist/src/qa/command-policy.d.ts +0 -23
  378. package/dist/src/qa/command-policy.js +0 -30
  379. package/dist/src/qa/guidance.d.ts +0 -21
  380. package/dist/src/qa/guidance.js +0 -20
  381. package/dist/src/qa/profile/ProjectInspector.d.ts +0 -4
  382. package/dist/src/qa/profile/ProjectInspector.js +0 -6
  383. package/dist/src/qa/profile/QaConfigLoader.d.ts +0 -7
  384. package/dist/src/qa/profile/QaConfigLoader.js +0 -6
  385. package/dist/src/qa/profile/QaProfile.d.ts +0 -7
  386. package/dist/src/qa/profile/QaProfile.js +0 -7
  387. package/dist/src/qa/profile/yaml.d.ts +0 -9
  388. package/dist/src/qa/profile/yaml.js +0 -13
  389. package/dist/src/qa/qa-authorize.d.ts +0 -19
  390. package/dist/src/qa/qa-authorize.js +4 -11
  391. package/dist/src/qa/runtime/ProcessManager.d.ts +0 -31
  392. package/dist/src/qa/runtime/ProcessManager.js +4 -41
  393. package/dist/src/qa/runtime/PtyManager.d.ts +0 -4
  394. package/dist/src/qa/runtime/PtyManager.js +1 -7
  395. package/dist/src/qa/runtime/changes.d.ts +0 -11
  396. package/dist/src/qa/runtime/changes.js +1 -3
  397. package/dist/src/qa/tools.d.ts +0 -10
  398. package/dist/src/qa/tools.js +0 -12
  399. package/dist/src/qa/types.d.ts +0 -13
  400. package/dist/src/react-runtime.d.ts +2 -21
  401. package/dist/src/react-runtime.js +95 -415
  402. package/dist/src/read-document-doc.d.ts +0 -6
  403. package/dist/src/read-document-doc.js +0 -55
  404. package/dist/src/read-document-docx.d.ts +0 -16
  405. package/dist/src/read-document-docx.js +2 -69
  406. package/dist/src/read-document-text.d.ts +0 -17
  407. package/dist/src/read-document-text.js +0 -22
  408. package/dist/src/read-document-tool.d.ts +0 -31
  409. package/dist/src/read-document-tool.js +0 -30
  410. package/dist/src/read-document.d.ts +0 -49
  411. package/dist/src/read-document.js +1 -67
  412. package/dist/src/read-image.d.ts +0 -32
  413. package/dist/src/read-image.js +0 -33
  414. package/dist/src/remote/cert.d.ts +0 -18
  415. package/dist/src/remote/cert.js +0 -44
  416. package/dist/src/remote/client.d.ts +0 -70
  417. package/dist/src/remote/client.js +1 -116
  418. package/dist/src/remote/command.js +0 -17
  419. package/dist/src/remote/engine-pool.d.ts +0 -152
  420. package/dist/src/remote/engine-pool.js +17 -335
  421. package/dist/src/remote/errors.d.ts +0 -15
  422. package/dist/src/remote/errors.js +0 -7
  423. package/dist/src/remote/network.d.ts +0 -26
  424. package/dist/src/remote/network.js +1 -34
  425. package/dist/src/remote/pairing.d.ts +16 -51
  426. package/dist/src/remote/pairing.js +50 -57
  427. package/dist/src/remote/pem.d.ts +0 -4
  428. package/dist/src/remote/pem.js +0 -4
  429. package/dist/src/remote/roots.d.ts +0 -20
  430. package/dist/src/remote/roots.js +0 -8
  431. package/dist/src/remote/serve.d.ts +0 -47
  432. package/dist/src/remote/serve.js +0 -30
  433. package/dist/src/remote/server.d.ts +0 -14
  434. package/dist/src/remote/server.js +1 -79
  435. package/dist/src/remote/types.d.ts +1 -32
  436. package/dist/src/remote/types.js +0 -10
  437. package/dist/src/run-control.d.ts +0 -7
  438. package/dist/src/run-control.js +0 -7
  439. package/dist/src/run-progress.d.ts +0 -170
  440. package/dist/src/run-progress.js +0 -285
  441. package/dist/src/run-records.d.ts +0 -443
  442. package/dist/src/run-records.js +14 -687
  443. package/dist/src/run-temp.d.ts +12 -0
  444. package/dist/src/run-temp.js +50 -0
  445. package/dist/src/runtime.d.ts +10 -228
  446. package/dist/src/runtime.js +0 -127
  447. package/dist/src/sandbox-child.js +0 -1
  448. package/dist/src/save-lock.d.ts +0 -12
  449. package/dist/src/save-lock.js +0 -28
  450. package/dist/src/screen-selection.d.ts +0 -23
  451. package/dist/src/screen-selection.js +0 -22
  452. package/dist/src/secret-redaction.d.ts +0 -12
  453. package/dist/src/secret-redaction.js +0 -45
  454. package/dist/src/session-changes.d.ts +4 -80
  455. package/dist/src/session-changes.js +25 -130
  456. package/dist/src/session-goal.d.ts +129 -0
  457. package/dist/src/session-goal.js +230 -0
  458. package/dist/src/session-monitor.d.ts +1 -10
  459. package/dist/src/session-monitor.js +2 -39
  460. package/dist/src/session-reaper.d.ts +0 -15
  461. package/dist/src/session-reaper.js +0 -14
  462. package/dist/src/session-skills.d.ts +15 -44
  463. package/dist/src/session-skills.js +75 -60
  464. package/dist/src/session-summary.d.ts +0 -26
  465. package/dist/src/session-summary.js +0 -32
  466. package/dist/src/session-title.d.ts +0 -1
  467. package/dist/src/session-title.js +0 -2
  468. package/dist/src/sessions.d.ts +2 -122
  469. package/dist/src/sessions.js +7 -178
  470. package/dist/src/shell.d.ts +3 -20
  471. package/dist/src/shell.js +8 -72
  472. package/dist/src/side-panel.d.ts +5 -99
  473. package/dist/src/side-panel.js +76 -133
  474. package/dist/src/sign-in-detection.d.ts +0 -39
  475. package/dist/src/sign-in-detection.js +0 -43
  476. package/dist/src/sign-in-offer.d.ts +1 -19
  477. package/dist/src/sign-in-offer.js +0 -13
  478. package/dist/src/skill-commands.d.ts +0 -1
  479. package/dist/src/skill-commands.js +1 -4
  480. package/dist/src/skills/bundled/control-browser/SKILL.md +1 -1
  481. package/dist/src/skills/bundled/provenance.json +1 -1
  482. package/dist/src/skills/invocable-skills.d.ts +0 -18
  483. package/dist/src/skills/invocable-skills.js +0 -17
  484. package/dist/src/skills/project-skills.d.ts +0 -1
  485. package/dist/src/skills/project-skills.js +0 -3
  486. package/dist/src/skills/prompt-skills.js +0 -14
  487. package/dist/src/skills/runtime-skills.d.ts +0 -13
  488. package/dist/src/skills/runtime-skills.js +0 -37
  489. package/dist/src/stall-recovery.d.ts +0 -25
  490. package/dist/src/stall-recovery.js +0 -38
  491. package/dist/src/stray-files.d.ts +0 -9
  492. package/dist/src/stray-files.js +0 -16
  493. package/dist/src/structured-step.d.ts +0 -22
  494. package/dist/src/structured-step.js +0 -22
  495. package/dist/src/subagent-run.d.ts +0 -163
  496. package/dist/src/subagent-run.js +4 -373
  497. package/dist/src/subagent-tree.d.ts +32 -0
  498. package/dist/src/subagent-tree.js +128 -0
  499. package/dist/src/telemetry/aggregate.d.ts +0 -37
  500. package/dist/src/telemetry/aggregate.js +0 -40
  501. package/dist/src/telemetry/capture-core.d.ts +0 -87
  502. package/dist/src/telemetry/capture-core.js +0 -67
  503. package/dist/src/telemetry/capture.d.ts +0 -1
  504. package/dist/src/telemetry/capture.js +0 -3
  505. package/dist/src/telemetry/classify.d.ts +0 -58
  506. package/dist/src/telemetry/classify.js +0 -60
  507. package/dist/src/telemetry/decision-capture.d.ts +0 -1
  508. package/dist/src/telemetry/emitter.d.ts +0 -30
  509. package/dist/src/telemetry/emitter.js +1 -62
  510. package/dist/src/telemetry/gate.d.ts +0 -29
  511. package/dist/src/telemetry/gate.js +0 -22
  512. package/dist/src/telemetry/identity.d.ts +0 -13
  513. package/dist/src/telemetry/identity.js +0 -29
  514. package/dist/src/telemetry/outbox.d.ts +0 -64
  515. package/dist/src/telemetry/outbox.js +1 -108
  516. package/dist/src/telemetry/schema.d.ts +1 -49
  517. package/dist/src/telemetry/schema.js +1 -82
  518. package/dist/src/telemetry/state.d.ts +0 -53
  519. package/dist/src/telemetry/state.js +0 -64
  520. package/dist/src/telemetry/surface.d.ts +0 -31
  521. package/dist/src/telemetry/surface.js +1 -39
  522. package/dist/src/telemetry/uploader.d.ts +0 -11
  523. package/dist/src/telemetry/uploader.js +0 -46
  524. package/dist/src/telemetry/uploads.d.ts +0 -11
  525. package/dist/src/telemetry/uploads.js +0 -11
  526. package/dist/src/telemetry/version.d.ts +0 -4
  527. package/dist/src/telemetry/version.js +0 -14
  528. package/dist/src/telemetry/workspace.d.ts +0 -7
  529. package/dist/src/telemetry/workspace.js +1 -22
  530. package/dist/src/terminal-ui.d.ts +14 -523
  531. package/dist/src/terminal-ui.js +74 -876
  532. package/dist/src/test-edit-guard.d.ts +74 -0
  533. package/dist/src/test-edit-guard.js +269 -0
  534. package/dist/src/text.d.ts +0 -1
  535. package/dist/src/text.js +0 -1
  536. package/dist/src/time-limit.d.ts +0 -36
  537. package/dist/src/time-limit.js +0 -37
  538. package/dist/src/timers.d.ts +0 -161
  539. package/dist/src/timers.js +0 -126
  540. package/dist/src/todos.d.ts +0 -1
  541. package/dist/src/todos.js +0 -3
  542. package/dist/src/token-rate.d.ts +0 -94
  543. package/dist/src/token-rate.js +0 -154
  544. package/dist/src/tool-activity.d.ts +0 -6
  545. package/dist/src/tool-activity.js +0 -7
  546. package/dist/src/tool-availability.d.ts +0 -13
  547. package/dist/src/tool-availability.js +1 -14
  548. package/dist/src/tool-call-clock.d.ts +1 -4
  549. package/dist/src/tool-call-clock.js +0 -13
  550. package/dist/src/tool-catalog.d.ts +0 -11
  551. package/dist/src/tool-catalog.js +0 -23
  552. package/dist/src/tool-dependencies.d.ts +0 -5
  553. package/dist/src/tool-dependencies.js +0 -4
  554. package/dist/src/tool-diff-stats.d.ts +0 -23
  555. package/dist/src/tool-diff-stats.js +0 -49
  556. package/dist/src/tool-errors.d.ts +9 -7
  557. package/dist/src/tool-errors.js +13 -6
  558. package/dist/src/tool-failure-tracker.d.ts +3 -11
  559. package/dist/src/tool-failure-tracker.js +19 -27
  560. package/dist/src/tool-names.d.ts +0 -16
  561. package/dist/src/tool-names.js +0 -12
  562. package/dist/src/tool-profile.d.ts +6 -0
  563. package/dist/src/tool-profile.js +23 -0
  564. package/dist/src/tool-result-filter.d.ts +0 -19
  565. package/dist/src/tool-result-filter.js +1 -66
  566. package/dist/src/tool-schema-compatibility.d.ts +0 -6
  567. package/dist/src/tool-schema-compatibility.js +0 -9
  568. package/dist/src/tools.d.ts +0 -4
  569. package/dist/src/tools.js +11 -114
  570. package/dist/src/trajectory.d.ts +0 -13
  571. package/dist/src/trajectory.js +23 -79
  572. package/dist/src/transcript.d.ts +0 -41
  573. package/dist/src/transcript.js +2 -60
  574. package/dist/src/types.d.ts +1 -168
  575. package/dist/src/untracked-file-removal.js +0 -20
  576. package/dist/src/update-check.d.ts +0 -14
  577. package/dist/src/update-check.js +1 -15
  578. package/dist/src/update.d.ts +0 -35
  579. package/dist/src/update.js +0 -100
  580. package/dist/src/usage-analytics.d.ts +17 -17
  581. package/dist/src/usage-analytics.js +168 -209
  582. package/dist/src/web-search.d.ts +0 -23
  583. package/dist/src/web-search.js +1 -27
  584. package/dist/src/widgets.d.ts +0 -25
  585. package/dist/src/widgets.js +0 -24
  586. package/dist/src/workspace-facts.d.ts +0 -12
  587. package/dist/src/workspace-facts.js +1 -18
  588. package/dist/src/workspace-git-metadata.d.ts +0 -16
  589. package/dist/src/workspace-git-metadata.js +0 -21
  590. package/dist/src/workspace-instructions.d.ts +3 -15
  591. package/dist/src/workspace-instructions.js +6 -19
  592. package/package.json +2 -2
@@ -16,25 +16,8 @@ import { configuredSurface, reportSessionStarted } from './telemetry/surface.js'
16
16
  import { currentGraphSubject } from './graph-selection.js';
17
17
  import { createSessionTrajectory } from './trajectory.js';
18
18
  import { boundBrowserActivity } from './browser-activity.js';
19
- /**
20
- * A required save found this session's mutation lock held by another writer, so its round did not happen.
21
- *
22
- * The message is what the surface shows; the type is what lets the one caller that owes a completed turn
23
- * retry it, instead of treating contention and a broken filesystem as the same answer.
24
- */
25
19
  export class SessionSaveContendedError extends Error {
26
20
  }
27
- /**
28
- * The rail's filing and name pin, applied to a copy of the record before it is written.
29
- *
30
- * Both copies this save writes have to say the same thing about those fields. Hydrate decides what a
31
- * run that died mid-prompt was doing by comparing the primary's digest against the archive's, and a
32
- * primary carrying `archived` while its archive does not makes those digests differ for as long as
33
- * the filing stands — the exact difference `independentlyUpdated` reads as "another writer moved on",
34
- * which restores a session whose engine was killed as idle and drops the recoverable prompt. Same rule
35
- * as the CLI's save, shared through `carryRailOwnedFields`; the one exemption is the acceptance save,
36
- * which clears the flag in both copies because work the user just started belongs on the working rail.
37
- */
38
21
  function withRailFields(target, predecessor, carryFiling) {
39
22
  carryRailOwnedFields(target, predecessor);
40
23
  if (!carryFiling) {
@@ -43,16 +26,6 @@ function withRailFields(target, predecessor, carryFiling) {
43
26
  }
44
27
  return target;
45
28
  }
46
- /**
47
- * The status a browser-written turn must carry into the saved record.
48
- *
49
- * A turn's status is read off its completion, and a completion with no status IS a normal completion —
50
- * that is the engine's contract, and it is what lets a finished task still read as finished after a
51
- * reload. The browser surface ends a turn from a result that can say `cancelled`, `exhausted`,
52
- * `needs_clarification` or `infrastructure_error`, and from catches that know only that the attempt did
53
- * not finish. Saving those turns status-less would hand the rail a green completed mark for work that
54
- * failed or was interrupted, so every terminal write here stamps what actually happened.
55
- */
56
29
  function terminalCompletion(completion, status) {
57
30
  return completion.status === undefined ? { ...completion, status } : completion;
58
31
  }
@@ -82,8 +55,6 @@ export async function startBrowserServer(options = {}) {
82
55
  await refreshSecrets();
83
56
  const publicState = (state) => {
84
57
  boundBrowserActivity(state.events);
85
- // Keep routing UUIDs and validated timestamp/status metadata canonical;
86
- // redacting them would break discovery or control of the public projection.
87
58
  return { ...sanitizer.sanitize(state), id: state.id, parentId: state.parentId, updatedAt: state.updatedAt, status: state.status };
88
59
  };
89
60
  const bridges = new Map();
@@ -109,8 +80,6 @@ export async function startBrowserServer(options = {}) {
109
80
  throw new Error('Application is shutting down');
110
81
  if (bridges.has(state.id))
111
82
  return;
112
- // A freshly generated id cannot already be held by another descriptor;
113
- // an unrelated bridge outage must not block creating a new session.
114
83
  if (!fresh)
115
84
  await assertBrowserSessionUnowned(directory, state.id);
116
85
  const folder = join(directory, 'browser-owners');
@@ -124,9 +93,6 @@ export async function startBrowserServer(options = {}) {
124
93
  const bridge = bridges.get(state.id);
125
94
  bridges.delete(state.id);
126
95
  owned.delete(state.id);
127
- // The lost-ownership guard fences future writes, but submitted OS
128
- // replacements cannot be cancelled. Keep discovery fail-closed until
129
- // those settle, just as normal shutdown does, while closing the listener.
130
96
  void bridge?.close(writes.replacements.size ? writes.settled() : undefined).catch(() => { });
131
97
  } });
132
98
  }
@@ -189,8 +155,6 @@ export async function startBrowserServer(options = {}) {
189
155
  if (!/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}\.json$/i.test(name) || primaryIds.has(name.slice(0, -5)))
190
156
  continue;
191
157
  try {
192
- // Recover an archive-only first CLI save, but never replace an existing
193
- // primary (including a damaged one) with potentially stale context.
194
158
  if (await readSnapshot(join(directory, 'sessions', name)) !== undefined)
195
159
  continue;
196
160
  const saved = JSON.parse(await readFile(join(folder, name), 'utf8'));
@@ -198,7 +162,7 @@ export async function startBrowserServer(options = {}) {
198
162
  continue;
199
163
  records.push(savedSessionFields(saved));
200
164
  }
201
- catch { /* One damaged archive must not hide other retained sessions. */ }
165
+ catch { }
202
166
  }
203
167
  return records;
204
168
  };
@@ -209,7 +173,7 @@ export async function startBrowserServer(options = {}) {
209
173
  if (Number.isInteger(saved.maxAgeDays) && saved.maxAgeDays >= 0 && saved.maxAgeDays <= 36500)
210
174
  settings = { maxAgeDays: saved.maxAgeDays, theme: ['system', 'light', 'dark'].includes(saved.theme) ? saved.theme : 'system' };
211
175
  }
212
- catch { /* retain defaults or last valid setting */ }
176
+ catch { }
213
177
  };
214
178
  await refreshSettings();
215
179
  const saves = new Map();
@@ -223,15 +187,11 @@ export async function startBrowserServer(options = {}) {
223
187
  const checkpoints = new Map();
224
188
  const assertOwnership = (id) => { if (lostOwnership.has(id))
225
189
  throw new Error('Session ownership was lost. Reopen this application before retrying.'); };
226
- // `carryFiling` is false only for the save that accepts a prompt: that one deliberately files
227
- // the session onto the working rail. Every other save carries the record's own filing instead.
228
190
  const save = (state, required = false, carryFiling = true) => {
229
191
  clearTimeout(checkpoints.get(state.id));
230
192
  checkpoints.delete(state.id);
231
193
  if (lostOwnership.has(state.id))
232
194
  return required ? Promise.reject(new Error('Session ownership was lost. Reopen this application before retrying.')) : Promise.resolve();
233
- // Public path redaction must not change where a retained session executes.
234
- // Activity/history remain sanitized in both durable records.
235
195
  const snapshot = { ...publicState({ ...state, pending: undefined, live: undefined }), workspace: state.workspace, updatedAt: state.updatedAt };
236
196
  const content = JSON.stringify(snapshot);
237
197
  const generation = saveGenerations.get(state.id) ?? 0;
@@ -249,20 +209,6 @@ export async function startBrowserServer(options = {}) {
249
209
  throw new Error('Session save was invalidated');
250
210
  });
251
211
  assertCanWrite();
252
- // The primary record's filing and name pin are the rail's changes, not this surface's
253
- // state: the desktop renames or archives through its own process, while this cached state
254
- // can predate that write. Take the same per-session mutation lock every rail rename,
255
- // archive, and delete takes, and read the record under it, so a change that landed while
256
- // this save queued is carried forward instead of overwritten: while the rail says the user
257
- // chose the name, that name and its pin survive this save (auto-titling is for unnamed
258
- // sessions only); while this session is not live, the record's own filing decides — a task
259
- // filed away on the desktop during an idle window of this surface stays filed away, and one
260
- // let back out does not silently return. A filing made while this surface's own run is live
261
- // is carried too: the desktop's guard answers from open-run claims, which a browser task does
262
- // not write, so filing a running browser session is a legitimate change from there — and a
263
- // cached state that predates it must not undo it. The exempt save is the acceptance save
264
- // below, which passes `carryFiling = false` because work the user started belongs on the
265
- // working rail.
266
212
  let releaseRailLock;
267
213
  try {
268
214
  releaseRailLock = await acquireSessionMutationLock(directory, state.id);
@@ -271,22 +217,18 @@ export async function startBrowserServer(options = {}) {
271
217
  if (error instanceof SessionMutationLockHeldError) {
272
218
  if (required)
273
219
  throw new SessionSaveContendedError('That session is being changed in another window. Wait a moment, then try again.');
274
- return; // A best-effort checkpoint skipping one round is safe; a stale overwrite is not.
220
+ return;
275
221
  }
276
222
  throw error;
277
223
  }
278
224
  try {
279
225
  assertCanWrite();
280
- // Record the exact predecessor, not a timestamp: primary-only CLI resets
281
- // must win even when they share the archive's millisecond timestamp.
282
226
  const previous = await readSnapshot(join(directory, 'sessions', `${state.id}.json`));
283
227
  const predecessor = previous === undefined ? undefined : JSON.parse(previous);
284
228
  const cached = JSON.parse(content);
285
229
  const archive = withRailFields({ ...cached, previousPrimaryDigest: predecessor === undefined ? undefined : primaryDigest(predecessor) }, predecessor, carryFiling);
286
230
  await writeSessionSnapshot(join(folder, `${state.id}.json`), JSON.stringify(archive), assertCanWrite);
287
231
  assertCanWrite();
288
- // Both copies from one rule, so the two records a crash leaves behind agree on what the rail
289
- // decided and hydrate reads one answer rather than a contradiction between them.
290
232
  await store.save(withRailFields(savedSessionFields(cached), predecessor, carryFiling), assertCanWrite);
291
233
  assertCanWrite();
292
234
  if (saves.get(state.id) === pending)
@@ -296,8 +238,6 @@ export async function startBrowserServer(options = {}) {
296
238
  await releaseRailLock?.().catch(() => { });
297
239
  }
298
240
  }).catch(error => {
299
- // Invalidate before exposing a rejected required write to successors in
300
- // the queue: their snapshots may still contain this rejected prompt.
301
241
  if (required && generation === (saveGenerations.get(state.id) ?? 0))
302
242
  invalidateSaves(state.id);
303
243
  throw error;
@@ -307,18 +247,6 @@ export async function startBrowserServer(options = {}) {
307
247
  saves.delete(state.id); }).catch(() => { });
308
248
  return pending;
309
249
  };
310
- /**
311
- * Persist the state a finished run left behind.
312
- *
313
- * A completed turn is not a checkpoint. The best-effort save skips its round while another writer holds
314
- * this session's mutation lock, and a promise that resolves having written nothing tells finalization
315
- * nothing: the run reports done while the durable record still says the prompt is running, and an exit
316
- * before the next save loses the turn the user just watched finish. So this asks for the required save,
317
- * which reports the contention instead of swallowing it, and gives the other writer's release a bounded
318
- * chance. A write that fails for any other reason still rejects, because the finalizer's reporting of it
319
- * — the notice on the session and the error it logs — is the answer the user gets today and must keep
320
- * getting. Only contention is sat on, and only briefly.
321
- */
322
250
  const persistCompleted = (completed) => {
323
251
  const settle = async (budgetMs) => {
324
252
  const deadline = Date.now() + budgetMs;
@@ -329,14 +257,10 @@ export async function startBrowserServer(options = {}) {
329
257
  return true;
330
258
  }
331
259
  catch (error) {
332
- // A newer save owns this state now, so that path owes the durability, not this one. Losing
333
- // ownership means the tab is gone, and retrying a save the close drain will not want is noise.
334
260
  if (error instanceof Error && error.message === 'Session save was invalidated')
335
261
  return false;
336
262
  if (lostOwnership.has(completed.id))
337
263
  return false;
338
- // A write that really failed has nothing to wait out. It gets the single immediate retry the
339
- // finalizer has always made, and then rejects so the finalizer can report it.
340
264
  if (!(error instanceof SessionSaveContendedError)) {
341
265
  if (retried)
342
266
  throw error;
@@ -349,17 +273,9 @@ export async function startBrowserServer(options = {}) {
349
273
  }
350
274
  }
351
275
  };
352
- // Two seconds of patience covers the case that actually happens — a peer finishing its own write —
353
- // and lands the turn before the run reports out. Past that the retry goes detached: a finished run
354
- // must not look hung because persistence is contended, and a turn that never lands stays dirty for
355
- // the close-time drain, which is the point the old skip failed.
356
- // The detached pass has no listener left to tell: the run is already reported done. The state stays
357
- // dirty, so the close-time drain is what answers for it if this never lands.
358
276
  return settle(2_000).then(landed => { if (!landed)
359
277
  void settle(60_000).catch(() => { }); });
360
278
  };
361
- // Append-only trajectory recording remains on the event path. Coalesce the
362
- // expensive full archive checkpoints, then flush all state at run completion.
363
279
  const checkpoint = (state) => {
364
280
  if (checkpoints.has(state.id) || lostOwnership.has(state.id))
365
281
  return;
@@ -367,24 +283,6 @@ export async function startBrowserServer(options = {}) {
367
283
  void save(state).catch(error => console.error('Browser history checkpoint failed:', sanitizer.sanitize(error instanceof Error ? error.message : String(error))));
368
284
  }, 1000));
369
285
  };
370
- /**
371
- * Rename, file away, or delete a saved session: the desktop rail's own changes, made from this surface.
372
- *
373
- * The rules are the app server's (`renameSession`, `setSessionArchived`, `deleteSession`): the primary
374
- * record is changed under the per-session mutation lock, and a session with a run in flight anywhere is
375
- * refused, because that run saves the record it captured and would undo the change — or, for a delete,
376
- * recreate the session. A session another process holds live (a terminal, another browser workspace) is
377
- * refused too: that owner's state would keep showing, and re-saving, what it had. This surface's own
378
- * idle state is updated alongside the record, because hydrate answers from it; its later saves carry
379
- * the name pin and the filing forward from the record (`withRailFields`).
380
- *
381
- * Two fences hold for the whole change. In this process, `managing` keeps a prompt from being accepted
382
- * until the change is done (`execute` checks it in the same step that marks the session running), so a
383
- * delete cannot be followed by an acceptance save that recreates the session. Across processes, a
384
- * session this application does not own has its ownership lease taken for the duration — the lease
385
- * another browser workspace must hold to prompt it — and a live owner that cannot be reached refuses
386
- * the change rather than being taken for absent.
387
- */
388
286
  const managing = new Set();
389
287
  const manageSession = async (id, change, body, live) => {
390
288
  const name = change === 'rename' && typeof body.name === 'string' ? body.name.trim() : '';
@@ -431,8 +329,6 @@ export async function startBrowserServer(options = {}) {
431
329
  if (await sessionHasOpenRun(directory, id))
432
330
  throw new Error(`That session is running in another window. Cancel the run or wait for it to finish, then ${verb} it.`);
433
331
  if (change === 'delete') {
434
- // A queued checkpoint would write the record back after the removal. Invalidated, it settles without
435
- // writing; it is awaited before the lock is taken, because the save itself takes that lock.
436
332
  invalidateSaves(id);
437
333
  await saves.get(id)?.catch(() => { });
438
334
  }
@@ -446,21 +342,15 @@ export async function startBrowserServer(options = {}) {
446
342
  throw error;
447
343
  }
448
344
  try {
449
- // A prompt accepted while the lock was being taken owns the session now, and so does a desktop or
450
- // terminal run that published its claim while this request waited: preparing a run holds this same
451
- // lock until its claim is written, so the answer read here is the one that counts.
452
345
  assertIdle();
453
346
  if (await sessionHasOpenRun(directory, id))
454
347
  throw new Error(`That session is running in another window. Cancel the run or wait for it to finish, then ${verb} it.`);
455
348
  const primaryPath = join(directory, 'sessions', `${id}.json`);
456
349
  const raw = await readSnapshot(primaryPath);
457
- // A session whose first save reached only this surface's archive has no primary yet.
458
350
  const archiveOnly = raw === undefined ? (await listRecords()).find(record => record.id === id) : undefined;
459
351
  if (raw === undefined && archiveOnly === undefined)
460
352
  throw new Error('Session not found');
461
353
  if (change === 'delete') {
462
- // The record goes first, then this surface's copy: a failure in between leaves a session that is
463
- // still listed and can be deleted again, never an archive that resurrects a deleted record.
464
354
  await removeSessionSnapshot(primaryPath);
465
355
  await removeSessionSnapshot(join(folder, `${id}.json`));
466
356
  dirtyCompleted.delete(id);
@@ -490,25 +380,16 @@ export async function startBrowserServer(options = {}) {
490
380
  if (!validSavedSession(record) || record.id !== id)
491
381
  throw new Error('That session record is damaged. Delete it, or repair the file in your sessions folder.');
492
382
  const now = new Date().toISOString();
493
- // `renamed` pins the name against the automatic titling a first prompt applies; a rename is news,
494
- // so it moves the session up the list, while filing is organization and leaves the order alone.
495
383
  const apply = (target) => change === 'rename'
496
384
  ? { ...target, name, renamed: true, updatedAt: now }
497
385
  : { ...target, archived: body.archived };
498
- // This surface's copy is what hydrate recovers a crashed run from: the prompt that was running and
499
- // the turn it owes. Hydrate trusts it while it agrees with the record (or is the newer of the two),
500
- // and reads a record that changed alone as another writer moving on — idle, with that turn dropped.
501
- // So while the copy is current, the change goes into it first, naming the record it was made over,
502
- // and the record is then written from it: a crash between the two writes leaves the copy as the
503
- // newer one, and after both they agree again. A copy another writer already superseded stays as it
504
- // is, and only the record changes, as the desktop's rename does.
505
386
  let copy;
506
387
  try {
507
388
  const { previousPrimaryDigest, ...saved } = JSON.parse(await readFile(join(folder, `${id}.json`), 'utf8'));
508
389
  if (validBrowserSession(saved) && saved.id === id)
509
390
  copy = { ...saved, previousPrimaryDigest };
510
391
  }
511
- catch { /* No copy, or an unreadable one: the record alone is the session. */ }
392
+ catch { }
512
393
  const recordDigest = raw === undefined ? undefined : primaryDigest(record);
513
394
  const copyCurrent = copy !== undefined && (recordDigest === undefined || copy.previousPrimaryDigest === recordDigest || primaryDigest(copy) === recordDigest);
514
395
  let updated;
@@ -534,12 +415,6 @@ export async function startBrowserServer(options = {}) {
534
415
  await release().catch(() => { });
535
416
  }
536
417
  };
537
- /**
538
- * The trajectory logs a session has, newest first: the runtime events this surface records for its
539
- * runs; the engine's log under the session's id, where the desktop and this surface's runner record
540
- * model calls; and, for a session the terminal created or continued, the terminal's own log, which
541
- * the record names by `trajectoryId`.
542
- */
543
418
  const trajectoryLogs = async (id, live) => {
544
419
  const record = owned.get(id) ?? (await listRecords()).find(item => item.id === id) ?? live.find(endpoint => endpoint.state.id === id)?.state;
545
420
  if (!record)
@@ -572,20 +447,12 @@ export async function startBrowserServer(options = {}) {
572
447
  if (validBrowserSession(saved) && saved.id === session.id) {
573
448
  const digest = primaryDigest(session);
574
449
  const independentlyUpdated = previousPrimaryDigest !== undefined && previousPrimaryDigest !== digest && primaryDigest(saved) !== digest;
575
- // A matching predecessor proves the archive committed before the
576
- // primary write. Any independently updated primary stays authoritative.
577
450
  if (previousPrimaryDigest === digest)
578
451
  session = savedSessionFields(saved);
579
452
  const interrupted = ['running', 'awaiting-input', 'cancelling'].includes(saved.status);
580
- // A stale archive's running status must not outlive a newer primary:
581
- // a CLI that completed and exited stays idle, not disconnected.
582
453
  state = { ...saved, ...session, status: independentlyUpdated ? 'idle' : interrupted ? 'disconnected' : saved.status, pending: undefined, prompt: undefined, live: false };
583
454
  if (interrupted && saved.prompt && !independentlyUpdated) {
584
- // The status is what a recovered attempt reads as. A turn that carries only a summary is a turn that
585
- // finished, and the rail would put a green mark on work this very record says was cut off.
586
455
  const turn = { task: saved.prompt, completion: { summary: 'Run interrupted when its owner disconnected. Inspect partial workspace changes before retrying.', tests: [], status: 'interrupted' } };
587
- // CLI acceptance already saves a synthetic pending turn. Only the
588
- // trailing pending attempt counts: earlier identical tasks are valid.
589
456
  const hasPending = (history) => {
590
457
  const last = history.at(-1);
591
458
  return last !== undefined && last.task === saved.prompt && !last.runId && last.completion.tests.length === 0 &&
@@ -598,12 +465,10 @@ export async function startBrowserServer(options = {}) {
598
465
  }
599
466
  }
600
467
  }
601
- catch { /* historic CLI record */ }
468
+ catch { }
602
469
  return state;
603
470
  };
604
471
  const execute = async (state, text) => {
605
- // A completed result is already visible while its storage flush finishes.
606
- // Queue a continuation behind that flush without accepting late controls.
607
472
  const previousJob = running.get(state.id);
608
473
  if (previousJob && !state.live)
609
474
  await previousJob.done;
@@ -618,11 +483,6 @@ export async function startBrowserServer(options = {}) {
618
483
  if (managing.has(state.id))
619
484
  throw new Error('That session is being changed. Try again in a moment.');
620
485
  const before = structuredClone(state);
621
- // A name the user set by hand is pinned: titling from the first prompt is for unnamed sessions only.
622
- // The pin and the chosen name live on the primary record, and this state may have been hydrated
623
- // before they were written — a rail rename while this application held the session idle. The
624
- // record is therefore re-read here, where titling would otherwise overwrite the chosen name and
625
- // the required save below would drop the pin with it.
626
486
  let pinned;
627
487
  if (!state.history.length) {
628
488
  try {
@@ -631,10 +491,8 @@ export async function startBrowserServer(options = {}) {
631
491
  if (primary !== undefined && primary.id === state.id && primary.renamed === true && typeof primary.name === 'string')
632
492
  pinned = primary.name;
633
493
  }
634
- catch { /* An unreadable record cannot claim the name was chosen; this state's own pin still governs. */ }
494
+ catch { }
635
495
  }
636
- // Asked again after the read, in the same synchronous step that marks the session running below: a
637
- // rename, filing or delete that began meanwhile owns the session until it finishes.
638
496
  if (running.has(state.id))
639
497
  throw new Error('Session already running');
640
498
  if (managing.has(state.id))
@@ -647,11 +505,6 @@ export async function startBrowserServer(options = {}) {
647
505
  if (state.renamed !== true)
648
506
  state.name = sessionName(text);
649
507
  }
650
- // Work this surface starts comes onto the working rail, the same rule the app server applies
651
- // to a resume and to a due wake: live work never hides inside the archived subsection, whose
652
- // rows carry no running or pending mark. Clearing here is what makes that intent deliberate
653
- // rather than a by-product of whether this state was hydrated before or after the desktop
654
- // filed the record away.
655
508
  delete state.archived;
656
509
  delete state.autoArchived;
657
510
  const abort = new AbortController();
@@ -663,7 +516,6 @@ export async function startBrowserServer(options = {}) {
663
516
  state.live = true;
664
517
  owned.set(state.id, state);
665
518
  running.set(state.id, job);
666
- // A successful submission must already have a recoverable prompt on disk.
667
519
  let acceptanceSucceeded = false;
668
520
  const accepted = (async () => {
669
521
  const archivePath = join(folder, `${state.id}.json`);
@@ -672,8 +524,6 @@ export async function startBrowserServer(options = {}) {
672
524
  try {
673
525
  await saves.get(state.id);
674
526
  snapshots = await Promise.all([archivePath, primaryPath].map(async (path) => [path, await readSnapshot(path)]));
675
- // The one save that files the session onto the working rail: `execute` cleared the flag
676
- // above because the user started this work here.
677
527
  await save(state, true, false);
678
528
  assertOwnership(state.id);
679
529
  acceptanceSucceeded = true;
@@ -683,11 +533,7 @@ export async function startBrowserServer(options = {}) {
683
533
  for (const key of Object.keys(state))
684
534
  delete state[key];
685
535
  Object.assign(state, before);
686
- // Drain even already-submitted replacements before rollback. Guarded
687
- // queued snapshots cannot publish after the restored predecessor.
688
536
  await saves.get(state.id)?.catch(() => { });
689
- // Another owner may already have published newer history. A rejected
690
- // acceptance must never restore snapshots after losing its lease.
691
537
  if (lostOwnership.has(state.id)) {
692
538
  running.delete(state.id);
693
539
  throw error;
@@ -706,9 +552,6 @@ export async function startBrowserServer(options = {}) {
706
552
  catch (rollbackError) {
707
553
  if (lostOwnership.has(state.id))
708
554
  throw error;
709
- // Never leave the rejected prompt recoverable from a partial archive.
710
- // If even removal fails, report the durability uncertainty and refuse
711
- // further runs in this process instead of treating a retry as safe.
712
555
  failedRollbacks.add(state.id);
713
556
  let removed = true;
714
557
  await removeSessionSnapshot(archivePath, writes.guard(() => assertOwnership(state.id))).catch(() => { removed = false; });
@@ -771,23 +614,16 @@ export async function startBrowserServer(options = {}) {
771
614
  state.status = result.status;
772
615
  state.provider = result.provider;
773
616
  state.model = result.model;
774
- // A result that did not succeed must arrive carrying its status: the record's reader cannot tell a
775
- // status-less completion from a finished one, and this surface is the only witness to what happened.
776
617
  const terminalRecord = result.completion ?? { summary: result.status === 'cancelled' ? 'Cancelled. Inspect partial workspace changes before retrying.' : `Run ${result.status}: ${result.reason ?? ''}`, tests: [] };
777
618
  state.history.push({ task: text, runId: result.id, completion: result.status === 'succeeded' ? terminalRecord : terminalCompletion(terminalRecord, result.status) });
778
619
  for (const key of ['inputTokens', 'outputTokens', 'requests'])
779
620
  state.usage[key] += result.usage[key];
780
- // Sparse: providers that report no cache counts keep the persisted shape unchanged.
781
621
  const cacheRead = (state.usage.cacheRead ?? 0) + (result.usage.cacheRead ?? 0);
782
622
  if (cacheRead > 0)
783
623
  state.usage.cacheRead = cacheRead;
784
624
  const cacheWrite = (state.usage.cacheWrite ?? 0) + (result.usage.cacheWrite ?? 0);
785
625
  if (cacheWrite > 0)
786
626
  state.usage.cacheWrite = cacheWrite;
787
- // The run's final widget values are the session's newest, exactly as the CLI's and the
788
- // app-server's finalizers treat them: assigning the result's (possibly absent) set both
789
- // carries updates and clears values a previous graph left behind, so the record this
790
- // browser saves never shows stale sections beside this run's plan.
791
627
  state.widgets = result.widgets;
792
628
  }
793
629
  catch (error) {
@@ -804,8 +640,6 @@ export async function startBrowserServer(options = {}) {
804
640
  state.live = false;
805
641
  state.updatedAt = new Date().toISOString();
806
642
  dirtyCompleted.add(state.id);
807
- // Finalization failures must not rewrite the completed run as an
808
- // initialization failure or append a second turn for the same prompt.
809
643
  const finalized = await Promise.allSettled([persistCompleted(state), trajectory.flush()]);
810
644
  for (const outcome of finalized)
811
645
  if (outcome.status === 'rejected') {
@@ -829,11 +663,6 @@ export async function startBrowserServer(options = {}) {
829
663
  browserReply(res, 403, { error: 'Invalid origin' });
830
664
  return;
831
665
  }
832
- // `/tokens.css` is the desktop client's own token file, which build-assets.mjs copies into the
833
- // build beside this page, so the workspace and the desktop draw from one source. The page
834
- // renders the desktop's face too: the build ships one copy of the Geist files (the graph
835
- // editor's, under graph-ui/fonts), and they are served here from this origin, the only one the
836
- // page's CSP admits.
837
666
  const assets = { '/': ['index.html', 'text/html'], '/app.js': ['app.js', 'text/javascript'], '/style.css': ['style.css', 'text/css'], '/tokens.css': ['tokens.css', 'text/css'], '/icons/chevron-right.svg': ['icons/chevron-right.svg', 'image/svg+xml'], '/andorra-logo.png': ['andorra-logo.png', 'image/png'],
838
667
  '/fonts/geist-sans-latin-400-normal.woff2': ['../graph-ui/fonts/geist-sans-latin-400-normal.woff2', 'font/woff2'],
839
668
  '/fonts/geist-sans-latin-500-normal.woff2': ['../graph-ui/fonts/geist-sans-latin-500-normal.woff2', 'font/woff2'],
@@ -862,15 +691,6 @@ export async function startBrowserServer(options = {}) {
862
691
  merged.set(endpoint.state.id, endpoint.state);
863
692
  const cutoff = Date.now() - settings.maxAgeDays * 86400000;
864
693
  const sessions = [...merged.values()].filter(state => state.live || !settings.maxAgeDays || Date.parse(state.updatedAt) >= cutoff).sort((a, b) => Date.parse(b.updatedAt) - Date.parse(a.updatedAt));
865
- // The membership the sidebar prunes its saved arrangement against: every project identity
866
- // the server holds, with no history window applied. The session list above is cut down by
867
- // maxAgeDays, so it is not the truth about which projects exist — a project whose every
868
- // session is older than the window is gone from it while its project is still here, and
869
- // pruning against it would erase that project's place in the arrangement. The identity is
870
- // sanitized exactly like the projections it reconciles against: a legacy record without a
871
- // project id falls back to its workspace path, which may name a configured secret, and the
872
- // sidebar derives its own identity from the redacted projections — an unsanitized member
873
- // would leak the secret and read as a project the sessions do not describe.
874
694
  const projectIds = [];
875
695
  {
876
696
  const seen = new Set();
@@ -900,11 +720,6 @@ export async function startBrowserServer(options = {}) {
900
720
  browserReply(res, 404, { error: 'This session has no trajectory yet' });
901
721
  return;
902
722
  }
903
- // Record by record through the sanitizer, as every other answer here goes: a key added to the
904
- // configuration after a record was written is still kept out of what leaves this server. The
905
- // record is parsed first, because the sanitizer replaces a whole JSON text above its size limit
906
- // with a plain-text marker — which would turn the large records the panel sends people here for
907
- // into lines that are not JSON. A line that is not JSON (a torn tail) is redacted as text.
908
723
  const downloadLine = (line) => {
909
724
  let record;
910
725
  try {
@@ -918,10 +733,7 @@ export async function startBrowserServer(options = {}) {
918
733
  res.writeHead(200, { 'Content-Type': 'application/x-ndjson; charset=utf-8', 'Content-Disposition': `attachment; filename="${id}-${log.source}.jsonl"`, 'Cache-Control': 'no-store', 'X-Content-Type-Options': 'nosniff' });
919
734
  const input = createReadStream(log.path);
920
735
  const lines = createInterface({ input, crlfDelay: Infinity });
921
- // A client that goes away while the response is backed up never drains it, so the wait also ends
922
- // when the response closes, and the file is released either way.
923
736
  const closed = new Promise(done => res.once('close', done));
924
- // The headers are out, so a read that fails part way can only cut the download short.
925
737
  try {
926
738
  for await (const line of lines) {
927
739
  if (res.destroyed)
@@ -960,9 +772,6 @@ export async function startBrowserServer(options = {}) {
960
772
  if (body.theme !== undefined && !['system', 'light', 'dark'].includes(String(body.theme)))
961
773
  throw new Error('Theme must be system, light or dark');
962
774
  const candidate = { maxAgeDays: Number(body.maxAgeDays), theme: body.theme === undefined ? settings.theme : String(body.theme) };
963
- // Settings are global to the shared configuration directory: serialize
964
- // the replacement in process and across applications so a stalled write
965
- // cannot resume after a newer one was already acknowledged.
966
775
  await writes.run(async () => {
967
776
  const release = await lockfile.lock(join(directory, 'browser-settings.lock'), { realpath: false, stale: 10000, update: 2000, onCompromised: () => { } });
968
777
  try {
@@ -981,8 +790,6 @@ export async function startBrowserServer(options = {}) {
981
790
  if (body.projectSessionId !== undefined) {
982
791
  if (typeof body.projectSessionId !== 'string')
983
792
  throw new Error('Invalid project session');
984
- // Display paths may be redacted. Resolve the selected project from
985
- // canonical owned/persisted metadata, then an unsaved live CLI session.
986
793
  const source = owned.get(body.projectSessionId)
987
794
  ?? (await listRecords()).find(record => record.id === body.projectSessionId)
988
795
  ?? live.find(endpoint => endpoint.state.id === body.projectSessionId)?.state;
@@ -999,11 +806,6 @@ export async function startBrowserServer(options = {}) {
999
806
  await ensureOwner(state, true);
1000
807
  try {
1001
808
  await save(state, true);
1002
- // This handler is the browser surface's one conversation-creation point: the run path
1003
- // only ever reopens a session this stored, so without this the browser's sessions are
1004
- // missing from the conversation counts entirely.
1005
- // Awaited: the creation handler is not latency-critical, and a queued start that lands
1006
- // after the response would race a caller closing the engine on the same home.
1007
809
  await currentGraphSubject().catch(() => undefined).then(subject => reportSessionStarted({ home: directory, surface: configuredSurface('desktop'), workspace, ...(subject === undefined ? {} : { subject }) })).catch(() => { });
1008
810
  }
1009
811
  catch (error) {
@@ -1013,13 +815,8 @@ export async function startBrowserServer(options = {}) {
1013
815
  const ownerPath = join(directory, 'browser-owners', state.id);
1014
816
  const release = leases.get(ownerPath);
1015
817
  leases.delete(ownerPath);
1016
- // This fresh ID was never acknowledged; discard its partial archive.
1017
- // Submit deletion independently of bridge cleanup and retain the lease
1018
- // until both settle, even if close fails or shutdown starts meanwhile.
1019
818
  const removal = lostOwnership.has(state.id) ? Promise.resolve() : Promise.allSettled([
1020
819
  removeSessionSnapshot(join(folder, `${state.id}.json`), writes.guard(() => assertOwnership(state.id))),
1021
- // The required save can commit the primary and still reject after;
1022
- // this fresh id was never acknowledged, so discard that record too.
1023
820
  removeSessionSnapshot(join(directory, 'sessions', `${state.id}.json`), writes.guard(() => assertOwnership(state.id))),
1024
821
  ]).then(results => { const failure = results.find(result => result.status === 'rejected'); if (failure)
1025
822
  throw failure.reason; });
@@ -1051,8 +848,6 @@ export async function startBrowserServer(options = {}) {
1051
848
  const [, id, action] = match;
1052
849
  const endpoint = live.find(item => item.state.id === id);
1053
850
  if (endpoint) {
1054
- // Acceptance has no deadline: the owner may already be persisting it.
1055
- // Shutdown only disconnects transport; it cannot reject or undo a run.
1056
851
  if (closing) {
1057
852
  res.destroy();
1058
853
  return;
@@ -1065,9 +860,6 @@ export async function startBrowserServer(options = {}) {
1065
860
  browserReply(res, upstream.status, await upstream.json());
1066
861
  }
1067
862
  catch (error) {
1068
- // A dropped transport after submission leaves the outcome unknown:
1069
- // the owner may have durably accepted the prompt and be running it.
1070
- // Destroy instead of returning a definite retryable rejection.
1071
863
  if (forwarding.signal.aborted || action === 'prompt') {
1072
864
  res.destroy();
1073
865
  return;
@@ -1123,13 +915,8 @@ export async function startBrowserServer(options = {}) {
1123
915
  closing = true;
1124
916
  for (const forwarding of forwardedRequests)
1125
917
  forwarding.abort();
1126
- // A provisional bridge stuck in descriptor publication must lose its
1127
- // listener now; its acquisition promise is left to the stalled storage.
1128
918
  for (const cancellation of acquisitionSignals)
1129
919
  cancellation.abort();
1130
- // An acquisition already waiting on discovery, a lock or bridge setup must
1131
- // get a bounded grace period. Late arrivals observe closing and dispose of
1132
- // their own bridge and lease; unpublished leases stay with that cleanup.
1133
920
  let acquisitionTimer;
1134
921
  try {
1135
922
  await Promise.race([
@@ -1142,8 +929,6 @@ export async function startBrowserServer(options = {}) {
1142
929
  }
1143
930
  for (const job of running.values())
1144
931
  job.abort.abort();
1145
- // Providers/tools may ignore abort. Give cooperative runs time to persist
1146
- // their result, then fence late callbacks before releasing their ownership.
1147
932
  let drainTimer;
1148
933
  try {
1149
934
  await Promise.race([
@@ -1157,23 +942,17 @@ export async function startBrowserServer(options = {}) {
1157
942
  const interruptedSaves = [];
1158
943
  for (const [id, job] of running) {
1159
944
  job.detached = true;
1160
- // Keep the accepted prompt recoverable as an interrupted run. Save the
1161
- // latest observed events before fencing all later writes from this owner.
1162
945
  const state = owned.get(id);
1163
946
  if (state)
1164
947
  interruptedSaves.push(save(state));
1165
948
  clearTimeout(checkpoints.get(id));
1166
949
  checkpoints.delete(id);
1167
950
  }
1168
- // Completed jobs leave running even when both final writes fail. Retry
1169
- // their retained state while ownership and the bounded flush still apply.
1170
951
  for (const id of dirtyCompleted) {
1171
952
  const state = owned.get(id);
1172
953
  if (state && !running.has(id) && !failedRollbacks.has(id))
1173
954
  interruptedSaves.push(save(state));
1174
955
  }
1175
- // A checkpoint can itself be stuck in storage. Bound the entire flush,
1176
- // then fence queued saves and atomic replacements before releasing leases.
1177
956
  try {
1178
957
  await Promise.race([
1179
958
  Promise.allSettled([...saves.values(), ...interruptedSaves]),
@@ -1189,8 +968,6 @@ export async function startBrowserServer(options = {}) {
1189
968
  clearTimeout(checkpoints.get(id));
1190
969
  checkpoints.delete(id);
1191
970
  }
1192
- // Submitted OS replacements cannot be cancelled: retain discovery and
1193
- // lease heartbeats until they settle, but close every HTTP listener now.
1194
971
  const replacementDrain = writes.replacements.size ? writes.settled() : undefined;
1195
972
  const bridgeResults = await Promise.allSettled([...bridges.values()].map(bridge => bridge.close(replacementDrain)));
1196
973
  const releaseLeases = () => Promise.all([...leases.values()].map(release => release().catch(() => { })));