@andorra-labs/code 0.1.11 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (614) hide show
  1. package/README.md +8 -2
  2. package/THIRD_PARTY_NOTICES.md +15 -0
  3. package/dist/src/account-presentation.d.ts +1 -37
  4. package/dist/src/account-presentation.js +2 -42
  5. package/dist/src/activity.d.ts +0 -25
  6. package/dist/src/activity.js +1 -23
  7. package/dist/src/agent-definitions.d.ts +0 -26
  8. package/dist/src/agent-definitions.js +0 -43
  9. package/dist/src/agent-execution.d.ts +0 -2
  10. package/dist/src/agent-execution.js +59 -414
  11. package/dist/src/agent-mcp-catalog.d.ts +0 -8
  12. package/dist/src/agent-mcp-catalog.js +0 -2
  13. package/dist/src/agent-mcp.d.ts +0 -56
  14. package/dist/src/agent-mcp.js +14 -153
  15. package/dist/src/agent-modifiers.d.ts +0 -1
  16. package/dist/src/agent-modifiers.js +25 -68
  17. package/dist/src/analytics.d.ts +0 -66
  18. package/dist/src/analytics.js +0 -45
  19. package/dist/src/anthropic-console-auth.d.ts +0 -24
  20. package/dist/src/anthropic-console-auth.js +0 -37
  21. package/dist/src/anthropic-credentials.d.ts +0 -25
  22. package/dist/src/anthropic-credentials.js +0 -28
  23. package/dist/src/app-server/protocol.d.ts +19 -244
  24. package/dist/src/app-server/protocol.js +1 -132
  25. package/dist/src/app-server/reasoning.d.ts +0 -31
  26. package/dist/src/app-server/reasoning.js +0 -54
  27. package/dist/src/app-server/terminal.d.ts +0 -36
  28. package/dist/src/app-server/terminal.js +3 -39
  29. package/dist/src/app-server/workspace.d.ts +0 -167
  30. package/dist/src/app-server/workspace.js +4 -406
  31. package/dist/src/app-server.d.ts +33 -918
  32. package/dist/src/app-server.js +608 -2984
  33. package/dist/src/artifacts.d.ts +0 -10
  34. package/dist/src/artifacts.js +1 -11
  35. package/dist/src/attachments.d.ts +4 -98
  36. package/dist/src/attachments.js +10 -130
  37. package/dist/src/auth/AuthManager.d.ts +0 -93
  38. package/dist/src/auth/AuthManager.js +3 -165
  39. package/dist/src/auth/callback-page.d.ts +0 -1
  40. package/dist/src/auth/callback-page.js +0 -4
  41. package/dist/src/auth/callback.d.ts +0 -25
  42. package/dist/src/auth/callback.js +1 -29
  43. package/dist/src/auth/deployment.d.ts +0 -16
  44. package/dist/src/auth/deployment.js +0 -16
  45. package/dist/src/auth/index.d.ts +0 -11
  46. package/dist/src/auth/index.js +0 -11
  47. package/dist/src/auth/lock.d.ts +0 -1
  48. package/dist/src/auth/lock.js +0 -1
  49. package/dist/src/auth/store.d.ts +7 -108
  50. package/dist/src/auth/store.js +21 -129
  51. package/dist/src/auth/types.d.ts +0 -8
  52. package/dist/src/auth-commands.d.ts +0 -5
  53. package/dist/src/auth-commands.js +0 -1
  54. package/dist/src/automation-runner.d.ts +0 -9
  55. package/dist/src/automation-runner.js +0 -11
  56. package/dist/src/automation-service.d.ts +0 -10
  57. package/dist/src/automation-service.js +3 -17
  58. package/dist/src/automation-tool.js +0 -5
  59. package/dist/src/automation-worker-shutdown.d.ts +0 -1
  60. package/dist/src/automation-worker-shutdown.js +0 -3
  61. package/dist/src/automations.d.ts +23 -2
  62. package/dist/src/automations.js +91 -12
  63. package/dist/src/background-tasks.d.ts +0 -23
  64. package/dist/src/background-tasks.js +0 -11
  65. package/dist/src/boot-trace.d.ts +0 -13
  66. package/dist/src/boot-trace.js +1 -14
  67. package/dist/src/browser-activity.js +0 -2
  68. package/dist/src/browser-bridge.d.ts +0 -2
  69. package/dist/src/browser-bridge.js +0 -27
  70. package/dist/src/browser-captcha-tool.d.ts +0 -13
  71. package/dist/src/browser-captcha-tool.js +3 -35
  72. package/dist/src/browser-extensions-tool.d.ts +24 -0
  73. package/dist/src/browser-extensions-tool.js +137 -0
  74. package/dist/src/browser-extensions.d.ts +127 -0
  75. package/dist/src/browser-extensions.js +729 -0
  76. package/dist/src/browser-observation.d.ts +0 -15
  77. package/dist/src/browser-observation.js +1 -22
  78. package/dist/src/browser-panel-tool.d.ts +10 -25
  79. package/dist/src/browser-panel-tool.js +64 -60
  80. package/dist/src/browser-runner.d.ts +0 -1
  81. package/dist/src/browser-runner.js +7 -46
  82. package/dist/src/browser-server.d.ts +0 -6
  83. package/dist/src/browser-server.js +6 -229
  84. package/dist/src/browser-session.d.ts +0 -25
  85. package/dist/src/browser-session.js +1 -71
  86. package/dist/src/browser-stealth.d.ts +0 -12
  87. package/dist/src/browser-stealth.js +0 -36
  88. package/dist/src/browser-ui/app.js +7 -174
  89. package/dist/src/browser-ui/style.css +0 -68
  90. package/dist/src/browser-ui/tokens.css +11 -93
  91. package/dist/src/browser-view.d.ts +52 -290
  92. package/dist/src/browser-view.js +354 -567
  93. package/dist/src/capabilities.d.ts +0 -8
  94. package/dist/src/capabilities.js +0 -29
  95. package/dist/src/capsolver.d.ts +0 -13
  96. package/dist/src/capsolver.js +0 -15
  97. package/dist/src/clarification-ui.d.ts +0 -7
  98. package/dist/src/clarification-ui.js +0 -8
  99. package/dist/src/claude-executable.d.ts +0 -1
  100. package/dist/src/claude-executable.js +1 -2
  101. package/dist/src/claude-provider.d.ts +6 -19
  102. package/dist/src/claude-provider.js +166 -61
  103. package/dist/src/cli-executable.d.ts +0 -16
  104. package/dist/src/cli-executable.js +0 -7
  105. package/dist/src/cli-process.d.ts +0 -26
  106. package/dist/src/cli-process.js +0 -18
  107. package/dist/src/cli-sign-in.d.ts +0 -20
  108. package/dist/src/cli-sign-in.js +1 -17
  109. package/dist/src/cli.d.ts +3 -56
  110. package/dist/src/cli.js +193 -702
  111. package/dist/src/code-intelligence/CodeIntelligenceManager.d.ts +4 -59
  112. package/dist/src/code-intelligence/CodeIntelligenceManager.js +27 -100
  113. package/dist/src/code-intelligence/ContextLedger.d.ts +0 -4
  114. package/dist/src/code-intelligence/ContextLedger.js +0 -10
  115. package/dist/src/code-intelligence/ContextRouter.d.ts +0 -6
  116. package/dist/src/code-intelligence/ContextRouter.js +0 -8
  117. package/dist/src/code-intelligence/codegraph/CodeGraphProjectSession.d.ts +0 -2
  118. package/dist/src/code-intelligence/codegraph/CodeGraphProjectSession.js +5 -12
  119. package/dist/src/code-intelligence/codegraph/CodeGraphProvider.d.ts +0 -6
  120. package/dist/src/code-intelligence/codegraph/CodeGraphProvider.js +0 -6
  121. package/dist/src/code-intelligence/codegraph/CodeGraphSyncBarrier.d.ts +0 -5
  122. package/dist/src/code-intelligence/codegraph/CodeGraphSyncBarrier.js +1 -17
  123. package/dist/src/code-intelligence/codegraph/repoExploreTool.d.ts +0 -5
  124. package/dist/src/code-intelligence/codegraph/repoExploreTool.js +0 -5
  125. package/dist/src/code-intelligence/repository.d.ts +0 -9
  126. package/dist/src/code-intelligence/repository.js +1 -11
  127. package/dist/src/code-intelligence/types.d.ts +0 -8
  128. package/dist/src/codex-auth.d.ts +0 -44
  129. package/dist/src/codex-auth.js +0 -45
  130. package/dist/src/codex-browser-auth.d.ts +0 -13
  131. package/dist/src/codex-browser-auth.js +3 -20
  132. package/dist/src/codex-errors.js +0 -2
  133. package/dist/src/codex-executable.d.ts +0 -2
  134. package/dist/src/codex-executable.js +1 -7
  135. package/dist/src/codex-provider.d.ts +0 -13
  136. package/dist/src/codex-provider.js +1 -26
  137. package/dist/src/codex-rpc.d.ts +0 -10
  138. package/dist/src/codex-rpc.js +0 -12
  139. package/dist/src/coding-tools.d.ts +6 -27
  140. package/dist/src/coding-tools.js +193 -205
  141. package/dist/src/command-metrics.d.ts +0 -4
  142. package/dist/src/command-output-tap.d.ts +0 -11
  143. package/dist/src/command-output-tap.js +0 -3
  144. package/dist/src/command-screens.d.ts +24 -0
  145. package/dist/src/command-screens.js +132 -100
  146. package/dist/src/commands.d.ts +6 -63
  147. package/dist/src/commands.js +20 -100
  148. package/dist/src/completion-gates.d.ts +0 -47
  149. package/dist/src/completion-gates.js +0 -14
  150. package/dist/src/completion.d.ts +2 -58
  151. package/dist/src/completion.js +90 -186
  152. package/dist/src/config.d.ts +12 -116
  153. package/dist/src/config.js +41 -171
  154. package/dist/src/context-budget.d.ts +0 -22
  155. package/dist/src/context-budget.js +0 -44
  156. package/dist/src/context-compaction.d.ts +29 -6
  157. package/dist/src/context-compaction.js +94 -25
  158. package/dist/src/context-selection.d.ts +0 -24
  159. package/dist/src/context-selection.js +0 -34
  160. package/dist/src/dashboard-view.d.ts +0 -2
  161. package/dist/src/dashboard-view.js +0 -35
  162. package/dist/src/dashboard.d.ts +0 -2
  163. package/dist/src/dashboard.js +0 -9
  164. package/dist/src/deadline.d.ts +0 -45
  165. package/dist/src/deadline.js +0 -54
  166. package/dist/src/decision/ContinuationAdapter.d.ts +0 -5
  167. package/dist/src/decision/ContinuationAdapter.js +0 -5
  168. package/dist/src/decision/DecisionEngine.d.ts +0 -4
  169. package/dist/src/decision/DecisionManager.d.ts +0 -1
  170. package/dist/src/decision/DecisionManager.js +2 -7
  171. package/dist/src/decision/DecisionPolicy.d.ts +0 -1
  172. package/dist/src/decision/DecisionPolicy.js +0 -1
  173. package/dist/src/decision/FactContinuations.d.ts +11 -43
  174. package/dist/src/decision/FactContinuations.js +126 -95
  175. package/dist/src/decision/FactServiceGate.d.ts +0 -1
  176. package/dist/src/decision/FactServiceGate.js +0 -4
  177. package/dist/src/decision/PreparedSteps.d.ts +0 -15
  178. package/dist/src/decision/PreparedSteps.js +1 -11
  179. package/dist/src/decision/applyToolMenu.d.ts +0 -1
  180. package/dist/src/decision/applyToolMenu.js +1 -5
  181. package/dist/src/decision/checks.d.ts +15 -28
  182. package/dist/src/decision/checks.js +118 -49
  183. package/dist/src/decision/facts.d.ts +0 -16
  184. package/dist/src/decision/facts.js +0 -30
  185. package/dist/src/decision/guidancePolicy.js +0 -1
  186. package/dist/src/decision/hostedPolicy.d.ts +0 -6
  187. package/dist/src/decision/hostedPolicy.js +0 -7
  188. package/dist/src/decision/hostedSkills.d.ts +0 -19
  189. package/dist/src/decision/hostedSkills.js +0 -19
  190. package/dist/src/decision/optimizationPolicy.d.ts +0 -3
  191. package/dist/src/decision/optimizationPolicy.js +1 -4
  192. package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +0 -7
  193. package/dist/src/decision/providers/AndorraDecisionProvider.js +4 -27
  194. package/dist/src/decision/providers/HttpDecisionProvider.d.ts +0 -2
  195. package/dist/src/decision/providers/HttpDecisionProvider.js +0 -6
  196. package/dist/src/decision/routeTools.d.ts +0 -8
  197. package/dist/src/decision/routeTools.js +1 -8
  198. package/dist/src/decision/toolFamilies.d.ts +0 -1
  199. package/dist/src/decision/toolFamilies.js +0 -1
  200. package/dist/src/decision/toolMenu.d.ts +0 -3
  201. package/dist/src/decision/toolMenu.js +0 -4
  202. package/dist/src/decision/types.d.ts +0 -6
  203. package/dist/src/default-graph.d.ts +0 -9
  204. package/dist/src/default-graph.js +0 -9
  205. package/dist/src/delegation-changes.d.ts +0 -56
  206. package/dist/src/delegation-changes.js +15 -124
  207. package/dist/src/diff-preview.d.ts +1 -1
  208. package/dist/src/diff-preview.js +4 -12
  209. package/dist/src/duration.d.ts +0 -50
  210. package/dist/src/duration.js +0 -50
  211. package/dist/src/efficiency.d.ts +0 -39
  212. package/dist/src/efficiency.js +0 -16
  213. package/dist/src/engine/protocol.d.ts +0 -2
  214. package/dist/src/engine/protocol.js +0 -2
  215. package/dist/src/engine-streams.d.ts +13 -0
  216. package/dist/src/engine-streams.js +16 -0
  217. package/dist/src/extensions.d.ts +3 -2
  218. package/dist/src/extensions.js +76 -37
  219. package/dist/src/favicons.d.ts +0 -26
  220. package/dist/src/favicons.js +0 -34
  221. package/dist/src/file-diff.d.ts +2 -58
  222. package/dist/src/file-diff.js +0 -32
  223. package/dist/src/file-read-key.d.ts +1 -0
  224. package/dist/src/file-read-key.js +5 -0
  225. package/dist/src/file-read-state.d.ts +0 -1
  226. package/dist/src/file-read-state.js +0 -4
  227. package/dist/src/firefox-cookies.d.ts +0 -34
  228. package/dist/src/firefox-cookies.js +1 -55
  229. package/dist/src/git-identity-audit.d.ts +27 -0
  230. package/dist/src/git-identity-audit.js +286 -0
  231. package/dist/src/git-identity-guard.d.ts +4 -0
  232. package/dist/src/git-identity-guard.js +998 -0
  233. package/dist/src/git-identity-hold.d.ts +12 -0
  234. package/dist/src/git-identity-hold.js +81 -0
  235. package/dist/src/git-summary.d.ts +0 -58
  236. package/dist/src/git-summary.js +2 -212
  237. package/dist/src/goal-completion-verification.d.ts +2 -2
  238. package/dist/src/goal-completion-verification.js +3 -6
  239. package/dist/src/graph-account.d.ts +0 -21
  240. package/dist/src/graph-account.js +0 -17
  241. package/dist/src/graph-editor-session.d.ts +0 -1
  242. package/dist/src/graph-editor-session.js +1 -3
  243. package/dist/src/graph-health.d.ts +7 -49
  244. package/dist/src/graph-health.js +35 -46
  245. package/dist/src/graph-manager-chat.d.ts +27 -128
  246. package/dist/src/graph-manager-chat.js +36 -166
  247. package/dist/src/graph-provider-portability.d.ts +1 -21
  248. package/dist/src/graph-provider-portability.js +6 -45
  249. package/dist/src/graph-quota.d.ts +0 -33
  250. package/dist/src/graph-quota.js +1 -44
  251. package/dist/src/graph-runner.d.ts +0 -1
  252. package/dist/src/graph-runner.js +47 -387
  253. package/dist/src/graph-selection.d.ts +0 -14
  254. package/dist/src/graph-selection.js +0 -14
  255. package/dist/src/graph-server.d.ts +3 -11
  256. package/dist/src/graph-server.js +70 -111
  257. package/dist/src/graph-studio-features.d.ts +0 -5
  258. package/dist/src/graph-studio-features.js +2 -42
  259. package/dist/src/graph-sync.d.ts +0 -78
  260. package/dist/src/graph-sync.js +5 -201
  261. package/dist/src/graph-tool.d.ts +0 -18
  262. package/dist/src/graph-tool.js +0 -27
  263. package/dist/src/graph-ui/app.js +229 -498
  264. package/dist/src/graph-ui/compat.js +0 -7
  265. package/dist/src/graph-ui/controls.css +47 -43
  266. package/dist/src/graph-ui/controls.js +0 -88
  267. package/dist/src/graph-ui/drafts.js +0 -12
  268. package/dist/src/graph-ui/edge-router.js +0 -62
  269. package/dist/src/graph-ui/embed.js +0 -59
  270. package/dist/src/graph-ui/icons.js +2 -7
  271. package/dist/src/graph-ui/index.html +2 -2
  272. package/dist/src/graph-ui/library.css +0 -5
  273. package/dist/src/graph-ui/manager-markdown.js +0 -11
  274. package/dist/src/graph-ui/manager-state.js +110 -49
  275. package/dist/src/graph-ui/manager.css +2 -20
  276. package/dist/src/graph-ui/manager.js +251 -166
  277. package/dist/src/graph-ui/model-picker.js +250 -0
  278. package/dist/src/graph-ui/provider-glyphs/alibaba-cloud.png +0 -0
  279. package/dist/src/graph-ui/provider-glyphs/anthropic.png +0 -0
  280. package/dist/src/graph-ui/provider-glyphs/aws-bedrock.png +0 -0
  281. package/dist/src/graph-ui/provider-glyphs/claude.png +0 -0
  282. package/dist/src/graph-ui/provider-glyphs/deepseek.png +0 -0
  283. package/dist/src/graph-ui/provider-glyphs/fireworks.png +0 -0
  284. package/dist/src/graph-ui/provider-glyphs/kimi.png +0 -0
  285. package/dist/src/graph-ui/provider-glyphs/minimax.png +0 -0
  286. package/dist/src/graph-ui/provider-glyphs/openai.png +0 -0
  287. package/dist/src/graph-ui/provider-glyphs/opencode.png +0 -0
  288. package/dist/src/graph-ui/provider-glyphs/openrouter.png +0 -0
  289. package/dist/src/graph-ui/provider-glyphs/xai.png +0 -0
  290. package/dist/src/graph-ui/provider-glyphs/xiaomi-mimo.png +0 -0
  291. package/dist/src/graph-ui/provider-glyphs/zai.png +0 -0
  292. package/dist/src/graph-ui/sidebar.js +2 -3
  293. package/dist/src/graph-ui/skill-picker.js +373 -39
  294. package/dist/src/graph-ui/studio-canvas.js +3 -38
  295. package/dist/src/graph-ui/studio.css +0 -18
  296. package/dist/src/graph-ui/studio.js +3 -71
  297. package/dist/src/graph-ui/style.css +11 -134
  298. package/dist/src/graph-ui/theme.js +1 -26
  299. package/dist/src/graph-ui/tokens.css +15 -114
  300. package/dist/src/graphs.d.ts +7 -156
  301. package/dist/src/graphs.js +72 -273
  302. package/dist/src/grep-regex-worker.js +0 -2
  303. package/dist/src/grep-regex.d.ts +1 -5
  304. package/dist/src/grep-regex.js +6 -8
  305. package/dist/src/grok-provider.d.ts +0 -17
  306. package/dist/src/grok-provider.js +1 -26
  307. package/dist/src/handoffs.d.ts +0 -11
  308. package/dist/src/handoffs.js +0 -13
  309. package/dist/src/hardened-runtime.d.ts +0 -10
  310. package/dist/src/hardened-runtime.js +8 -46
  311. package/dist/src/harness-home.d.ts +21 -0
  312. package/dist/src/harness-home.js +87 -0
  313. package/dist/src/host-process-guard.d.ts +0 -50
  314. package/dist/src/host-process-guard.js +0 -641
  315. package/dist/src/limits.d.ts +0 -64
  316. package/dist/src/limits.js +0 -62
  317. package/dist/src/managed-sign-in.d.ts +0 -12
  318. package/dist/src/managed-sign-in.js +0 -16
  319. package/dist/src/markdown.d.ts +0 -28
  320. package/dist/src/markdown.js +1 -175
  321. package/dist/src/mcp.d.ts +21 -82
  322. package/dist/src/mcp.js +228 -237
  323. package/dist/src/membership-errors.d.ts +0 -14
  324. package/dist/src/membership-errors.js +0 -13
  325. package/dist/src/membership.d.ts +2 -60
  326. package/dist/src/membership.js +0 -85
  327. package/dist/src/memory/LocalToolMemory.d.ts +0 -1
  328. package/dist/src/memory/LocalToolMemory.js +2 -7
  329. package/dist/src/memory/MemoryDistiller.js +0 -15
  330. package/dist/src/memory/MemoryManager.d.ts +0 -3
  331. package/dist/src/memory/MemoryManager.js +6 -18
  332. package/dist/src/memory/MemoryPolicy.d.ts +0 -2
  333. package/dist/src/memory/MemoryPolicy.js +0 -2
  334. package/dist/src/memory/MemoryProvider.d.ts +0 -6
  335. package/dist/src/memory/MemoryRetriever.js +0 -7
  336. package/dist/src/memory/PermissionMemoryProvider.d.ts +0 -1
  337. package/dist/src/memory/PermissionMemoryProvider.js +0 -1
  338. package/dist/src/memory/ProjectMemory.d.ts +42 -0
  339. package/dist/src/memory/ProjectMemory.js +285 -0
  340. package/dist/src/memory/ToolFailureLessons.d.ts +0 -3
  341. package/dist/src/memory/ToolFailureLessons.js +0 -6
  342. package/dist/src/memory/index.d.ts +1 -0
  343. package/dist/src/memory/index.js +1 -0
  344. package/dist/src/memory/providers/NoOpMemoryProvider.d.ts +0 -1
  345. package/dist/src/memory/providers/NoOpMemoryProvider.js +0 -1
  346. package/dist/src/memory/redaction.d.ts +0 -5
  347. package/dist/src/memory/redaction.js +0 -11
  348. package/dist/src/memory/repository.d.ts +0 -6
  349. package/dist/src/memory/repository.js +2 -12
  350. package/dist/src/memory/types.d.ts +0 -1
  351. package/dist/src/model-health-cache.d.ts +0 -38
  352. package/dist/src/model-health-cache.js +1 -49
  353. package/dist/src/model-metadata.d.ts +0 -18
  354. package/dist/src/model-metadata.js +2 -42
  355. package/dist/src/model-override.d.ts +0 -36
  356. package/dist/src/model-override.js +0 -43
  357. package/dist/src/model-tiers.d.ts +0 -13
  358. package/dist/src/model-tiers.js +0 -23
  359. package/dist/src/opencode-catalog.d.ts +0 -2
  360. package/dist/src/opencode-catalog.js +0 -11
  361. package/dist/src/opencode-cli-provider.d.ts +0 -35
  362. package/dist/src/opencode-cli-provider.js +1 -44
  363. package/dist/src/opencode-provider.d.ts +0 -2
  364. package/dist/src/opencode-provider.js +6 -22
  365. package/dist/src/package-name.d.ts +1 -0
  366. package/dist/src/package-name.js +1 -0
  367. package/dist/src/paged-transcript.d.ts +0 -11
  368. package/dist/src/paged-transcript.js +2 -20
  369. package/dist/src/palette.d.ts +0 -63
  370. package/dist/src/palette.js +0 -63
  371. package/dist/src/permissions.d.ts +0 -15
  372. package/dist/src/permissions.js +0 -17
  373. package/dist/src/powershell-pool.d.ts +0 -9
  374. package/dist/src/powershell-pool.js +3 -26
  375. package/dist/src/process-warnings.d.ts +4 -0
  376. package/dist/src/process-warnings.js +103 -0
  377. package/dist/src/profile.d.ts +0 -43
  378. package/dist/src/profile.js +0 -43
  379. package/dist/src/project-reservation.d.ts +11 -0
  380. package/dist/src/project-reservation.js +143 -0
  381. package/dist/src/provider-connection.d.ts +0 -18
  382. package/dist/src/provider-connection.js +0 -39
  383. package/dist/src/provider-engine.d.ts +0 -21
  384. package/dist/src/provider-engine.js +3 -98
  385. package/dist/src/provider-import.d.ts +0 -49
  386. package/dist/src/provider-import.js +0 -60
  387. package/dist/src/provider-keys.d.ts +1 -36
  388. package/dist/src/provider-keys.js +5 -48
  389. package/dist/src/provider-settings.d.ts +0 -2
  390. package/dist/src/provider-settings.js +0 -32
  391. package/dist/src/providers.d.ts +0 -217
  392. package/dist/src/providers.js +0 -315
  393. package/dist/src/pull-requests.d.ts +0 -173
  394. package/dist/src/pull-requests.js +5 -195
  395. package/dist/src/qa/browser/PlaywrightRunner.d.ts +0 -7
  396. package/dist/src/qa/browser/PlaywrightRunner.js +2 -16
  397. package/dist/src/qa/command-policy.d.ts +0 -23
  398. package/dist/src/qa/command-policy.js +0 -30
  399. package/dist/src/qa/guidance.d.ts +0 -21
  400. package/dist/src/qa/guidance.js +0 -20
  401. package/dist/src/qa/profile/ProjectInspector.d.ts +0 -4
  402. package/dist/src/qa/profile/ProjectInspector.js +0 -6
  403. package/dist/src/qa/profile/QaConfigLoader.d.ts +0 -7
  404. package/dist/src/qa/profile/QaConfigLoader.js +0 -6
  405. package/dist/src/qa/profile/QaProfile.d.ts +0 -7
  406. package/dist/src/qa/profile/QaProfile.js +0 -7
  407. package/dist/src/qa/profile/yaml.d.ts +0 -9
  408. package/dist/src/qa/profile/yaml.js +0 -13
  409. package/dist/src/qa/qa-authorize.d.ts +0 -19
  410. package/dist/src/qa/qa-authorize.js +4 -11
  411. package/dist/src/qa/runtime/ProcessManager.d.ts +0 -31
  412. package/dist/src/qa/runtime/ProcessManager.js +4 -41
  413. package/dist/src/qa/runtime/PtyManager.d.ts +0 -4
  414. package/dist/src/qa/runtime/PtyManager.js +2 -7
  415. package/dist/src/qa/runtime/changes.d.ts +0 -11
  416. package/dist/src/qa/runtime/changes.js +1 -3
  417. package/dist/src/qa/tools.d.ts +0 -10
  418. package/dist/src/qa/tools.js +0 -12
  419. package/dist/src/qa/types.d.ts +0 -13
  420. package/dist/src/react-runtime.d.ts +2 -21
  421. package/dist/src/react-runtime.js +106 -418
  422. package/dist/src/read-document-doc.d.ts +0 -6
  423. package/dist/src/read-document-doc.js +0 -55
  424. package/dist/src/read-document-docx.d.ts +0 -16
  425. package/dist/src/read-document-docx.js +2 -69
  426. package/dist/src/read-document-text.d.ts +0 -17
  427. package/dist/src/read-document-text.js +0 -22
  428. package/dist/src/read-document-tool.d.ts +0 -31
  429. package/dist/src/read-document-tool.js +0 -30
  430. package/dist/src/read-document.d.ts +0 -49
  431. package/dist/src/read-document.js +1 -67
  432. package/dist/src/read-image.d.ts +0 -32
  433. package/dist/src/read-image.js +0 -33
  434. package/dist/src/remote/cert.d.ts +1 -19
  435. package/dist/src/remote/cert.js +2 -51
  436. package/dist/src/remote/client.d.ts +0 -70
  437. package/dist/src/remote/client.js +2 -117
  438. package/dist/src/remote/command.js +0 -17
  439. package/dist/src/remote/engine-pool.d.ts +0 -152
  440. package/dist/src/remote/engine-pool.js +17 -335
  441. package/dist/src/remote/errors.d.ts +0 -15
  442. package/dist/src/remote/errors.js +0 -7
  443. package/dist/src/remote/network.d.ts +0 -26
  444. package/dist/src/remote/network.js +1 -34
  445. package/dist/src/remote/pairing.d.ts +16 -51
  446. package/dist/src/remote/pairing.js +50 -57
  447. package/dist/src/remote/pem.d.ts +2 -0
  448. package/dist/src/remote/pem.js +7 -0
  449. package/dist/src/remote/roots.d.ts +0 -20
  450. package/dist/src/remote/roots.js +0 -8
  451. package/dist/src/remote/serve.d.ts +0 -47
  452. package/dist/src/remote/serve.js +0 -30
  453. package/dist/src/remote/server.d.ts +0 -14
  454. package/dist/src/remote/server.js +1 -79
  455. package/dist/src/remote/types.d.ts +1 -32
  456. package/dist/src/remote/types.js +0 -10
  457. package/dist/src/run-control.d.ts +0 -7
  458. package/dist/src/run-control.js +0 -7
  459. package/dist/src/run-progress.d.ts +0 -170
  460. package/dist/src/run-progress.js +0 -285
  461. package/dist/src/run-records.d.ts +0 -443
  462. package/dist/src/run-records.js +44 -678
  463. package/dist/src/run-temp.d.ts +12 -0
  464. package/dist/src/run-temp.js +50 -0
  465. package/dist/src/runtime.d.ts +11 -227
  466. package/dist/src/runtime.js +0 -127
  467. package/dist/src/sandbox-child.js +0 -1
  468. package/dist/src/save-lock.d.ts +0 -12
  469. package/dist/src/save-lock.js +0 -28
  470. package/dist/src/screen-selection.d.ts +0 -23
  471. package/dist/src/screen-selection.js +0 -22
  472. package/dist/src/secret-redaction.d.ts +0 -12
  473. package/dist/src/secret-redaction.js +0 -45
  474. package/dist/src/session-changes.d.ts +4 -80
  475. package/dist/src/session-changes.js +25 -130
  476. package/dist/src/session-goal.d.ts +129 -0
  477. package/dist/src/session-goal.js +230 -0
  478. package/dist/src/session-monitor.d.ts +1 -10
  479. package/dist/src/session-monitor.js +2 -39
  480. package/dist/src/session-reaper.d.ts +0 -15
  481. package/dist/src/session-reaper.js +0 -14
  482. package/dist/src/session-skills.d.ts +15 -44
  483. package/dist/src/session-skills.js +75 -60
  484. package/dist/src/session-summary.d.ts +0 -26
  485. package/dist/src/session-summary.js +0 -32
  486. package/dist/src/session-title.d.ts +0 -1
  487. package/dist/src/session-title.js +0 -2
  488. package/dist/src/sessions.d.ts +2 -120
  489. package/dist/src/sessions.js +9 -178
  490. package/dist/src/shell.d.ts +3 -20
  491. package/dist/src/shell.js +8 -72
  492. package/dist/src/side-panel.d.ts +5 -99
  493. package/dist/src/side-panel.js +76 -133
  494. package/dist/src/sign-in-detection.d.ts +43 -0
  495. package/dist/src/sign-in-detection.js +154 -0
  496. package/dist/src/sign-in-offer.d.ts +17 -0
  497. package/dist/src/sign-in-offer.js +103 -0
  498. package/dist/src/skill-commands.d.ts +0 -1
  499. package/dist/src/skill-commands.js +1 -4
  500. package/dist/src/skills/bundled/control-browser/SKILL.md +1 -1
  501. package/dist/src/skills/bundled/graph-manager/SKILL.md +22 -4
  502. package/dist/src/skills/bundled/provenance.json +2 -2
  503. package/dist/src/skills/invocable-skills.d.ts +0 -18
  504. package/dist/src/skills/invocable-skills.js +0 -17
  505. package/dist/src/skills/project-skills.d.ts +0 -1
  506. package/dist/src/skills/project-skills.js +0 -3
  507. package/dist/src/skills/prompt-skills.js +0 -14
  508. package/dist/src/skills/runtime-skills.d.ts +1 -8
  509. package/dist/src/skills/runtime-skills.js +8 -32
  510. package/dist/src/stall-recovery.d.ts +0 -25
  511. package/dist/src/stall-recovery.js +0 -38
  512. package/dist/src/stray-files.d.ts +5 -0
  513. package/dist/src/stray-files.js +65 -0
  514. package/dist/src/structured-step.d.ts +0 -22
  515. package/dist/src/structured-step.js +0 -22
  516. package/dist/src/subagent-run.d.ts +0 -163
  517. package/dist/src/subagent-run.js +10 -374
  518. package/dist/src/subagent-tree.d.ts +32 -0
  519. package/dist/src/subagent-tree.js +128 -0
  520. package/dist/src/telemetry/aggregate.d.ts +0 -37
  521. package/dist/src/telemetry/aggregate.js +0 -40
  522. package/dist/src/telemetry/capture-core.d.ts +0 -87
  523. package/dist/src/telemetry/capture-core.js +0 -67
  524. package/dist/src/telemetry/capture.d.ts +0 -1
  525. package/dist/src/telemetry/capture.js +0 -3
  526. package/dist/src/telemetry/classify.d.ts +0 -58
  527. package/dist/src/telemetry/classify.js +0 -60
  528. package/dist/src/telemetry/decision-capture.d.ts +0 -1
  529. package/dist/src/telemetry/emitter.d.ts +0 -30
  530. package/dist/src/telemetry/emitter.js +1 -62
  531. package/dist/src/telemetry/gate.d.ts +0 -29
  532. package/dist/src/telemetry/gate.js +0 -22
  533. package/dist/src/telemetry/identity.d.ts +0 -13
  534. package/dist/src/telemetry/identity.js +0 -29
  535. package/dist/src/telemetry/outbox.d.ts +0 -64
  536. package/dist/src/telemetry/outbox.js +1 -108
  537. package/dist/src/telemetry/schema.d.ts +1 -49
  538. package/dist/src/telemetry/schema.js +1 -82
  539. package/dist/src/telemetry/state.d.ts +0 -53
  540. package/dist/src/telemetry/state.js +0 -64
  541. package/dist/src/telemetry/surface.d.ts +0 -31
  542. package/dist/src/telemetry/surface.js +1 -39
  543. package/dist/src/telemetry/uploader.d.ts +0 -11
  544. package/dist/src/telemetry/uploader.js +0 -46
  545. package/dist/src/telemetry/uploads.d.ts +0 -11
  546. package/dist/src/telemetry/uploads.js +0 -11
  547. package/dist/src/telemetry/version.d.ts +0 -4
  548. package/dist/src/telemetry/version.js +0 -14
  549. package/dist/src/telemetry/workspace.d.ts +0 -7
  550. package/dist/src/telemetry/workspace.js +1 -22
  551. package/dist/src/terminal-ui.d.ts +15 -524
  552. package/dist/src/terminal-ui.js +80 -876
  553. package/dist/src/test-edit-guard.d.ts +74 -0
  554. package/dist/src/test-edit-guard.js +269 -0
  555. package/dist/src/text.d.ts +0 -1
  556. package/dist/src/text.js +0 -1
  557. package/dist/src/time-limit.d.ts +0 -36
  558. package/dist/src/time-limit.js +0 -37
  559. package/dist/src/timers.d.ts +0 -161
  560. package/dist/src/timers.js +0 -126
  561. package/dist/src/todos.d.ts +0 -1
  562. package/dist/src/todos.js +0 -3
  563. package/dist/src/token-rate.d.ts +0 -94
  564. package/dist/src/token-rate.js +0 -154
  565. package/dist/src/tool-activity.d.ts +0 -6
  566. package/dist/src/tool-activity.js +1 -8
  567. package/dist/src/tool-availability.d.ts +0 -13
  568. package/dist/src/tool-availability.js +1 -14
  569. package/dist/src/tool-call-clock.d.ts +1 -4
  570. package/dist/src/tool-call-clock.js +0 -13
  571. package/dist/src/tool-catalog.d.ts +0 -11
  572. package/dist/src/tool-catalog.js +0 -23
  573. package/dist/src/tool-dependencies.d.ts +0 -5
  574. package/dist/src/tool-dependencies.js +0 -4
  575. package/dist/src/tool-diff-stats.d.ts +0 -23
  576. package/dist/src/tool-diff-stats.js +0 -49
  577. package/dist/src/tool-errors.d.ts +9 -7
  578. package/dist/src/tool-errors.js +13 -6
  579. package/dist/src/tool-failure-tracker.d.ts +3 -11
  580. package/dist/src/tool-failure-tracker.js +19 -27
  581. package/dist/src/tool-names.d.ts +0 -16
  582. package/dist/src/tool-names.js +0 -12
  583. package/dist/src/tool-profile.d.ts +6 -0
  584. package/dist/src/tool-profile.js +23 -0
  585. package/dist/src/tool-result-filter.d.ts +0 -19
  586. package/dist/src/tool-result-filter.js +1 -66
  587. package/dist/src/tool-schema-compatibility.d.ts +1 -2
  588. package/dist/src/tool-schema-compatibility.js +2 -7
  589. package/dist/src/tools.d.ts +0 -4
  590. package/dist/src/tools.js +11 -114
  591. package/dist/src/trajectory.d.ts +0 -13
  592. package/dist/src/trajectory.js +23 -79
  593. package/dist/src/transcript.d.ts +1 -37
  594. package/dist/src/transcript.js +11 -61
  595. package/dist/src/types.d.ts +2 -167
  596. package/dist/src/untracked-file-removal.d.ts +3 -0
  597. package/dist/src/untracked-file-removal.js +105 -0
  598. package/dist/src/update-check.d.ts +0 -14
  599. package/dist/src/update-check.js +2 -16
  600. package/dist/src/update.d.ts +4 -29
  601. package/dist/src/update.js +20 -98
  602. package/dist/src/usage-analytics.d.ts +17 -17
  603. package/dist/src/usage-analytics.js +168 -209
  604. package/dist/src/web-search.d.ts +0 -23
  605. package/dist/src/web-search.js +1 -27
  606. package/dist/src/widgets.d.ts +0 -25
  607. package/dist/src/widgets.js +0 -24
  608. package/dist/src/workspace-facts.d.ts +0 -12
  609. package/dist/src/workspace-facts.js +1 -18
  610. package/dist/src/workspace-git-metadata.d.ts +4 -5
  611. package/dist/src/workspace-git-metadata.js +37 -9
  612. package/dist/src/workspace-instructions.d.ts +3 -15
  613. package/dist/src/workspace-instructions.js +7 -20
  614. package/package.json +2 -2
@@ -4,147 +4,59 @@ import { loadConfig } from '../config.js';
4
4
  import { reconcileInterruptedRuns } from '../run-records.js';
5
5
  import { configuredSurface, reportInterruptedRuns } from '../telemetry/surface.js';
6
6
  import { authorizedRoots } from './roots.js';
7
- /**
8
- * The engine relay: the host side of full-owner remote access.
9
- *
10
- * A paired window is a full client of this machine's engine surface, so someone has to stand between
11
- * the pairing listener and the engine pool the product describes (ADR 0017): a browsing engine that
12
- * answers sessions, run records, workspace reads and terminals, plus one child engine per concurrent
13
- * task. That coordinator is this module, and it lives in the process that owns the listener — the
14
- * desktop's primary engine, or a standalone `andorra remote serve`. It spawns its own children with
15
- * the same `app-server --stdio` wire every other client speaks, so a headless host and a desktop host
16
- * serve the identical surface.
17
- *
18
- * Nothing here decides authority: the endpoints in `server.ts` admit a request only for a full-grant
19
- * device over TLS, and this module assumes that check has run. Revocation is still enforced live — a
20
- * poller re-reads the device table and cuts a revoked device's event stream and terminals, because a
21
- * long-lived stream is exactly the resource a per-request authentication check cannot see.
22
- *
23
- * Client-lifetime resources are namespaced per connection: terminal ids are prefixed with the
24
- * connection that opened them, their output is delivered only to that connection, and a closeAll from
25
- * one connection sweeps only its own shells. Run ownership is host-wide (the runs belong to this
26
- * machine), so run and prompt routing is by runId and engine id across all children.
27
- */
28
- /** The engine a paired client addresses for everything that is not one task's run. */
29
7
  export const REMOTE_PRIMARY_ENGINE = 'remote-primary';
30
- /**
31
- * The capability that says this relay understands a capability requirement.
32
- *
33
- * It lives here, with the implementation that honours it, and not in the app-server's shared
34
- * capability list: the server loads that list lazily, so a build whose files were replaced under
35
- * a running relay would advertise a capability the relay in memory does not have — and a client
36
- * that trusted it would send a requirement the old relay forwards to a child that ignores it.
37
- */
38
8
  export const RELAY_CAPABILITY_REQUIREMENT = 'remote.engine.relay.capability';
39
9
  const TASK_PREFIX = 'remote-task-';
40
- /** How many task engines the relay will run at once, besides the browsing engine. */
41
10
  const MAX_RELAY_ENGINES = 9;
42
- /** How many of a child's newest stderr lines are kept, for the message when it dies. */
43
11
  const CHILD_STDERR_LINES = 50;
44
- /** A child that never completes its handshake is not an engine; the start fails after this. */
45
12
  const CHILD_READY_TIMEOUT_MS = 60_000;
46
- /** How long a graceful child stop may take before the kill backstop fires. */
47
13
  const CHILD_STOP_GRACE_MS = 20_000;
48
- /**
49
- * The wall-clock a relayed request gives the child, over what the viewer asked for.
50
- *
51
- * The viewer's own client times out at exactly the deadline it sent; this slack is what keeps the
52
- * relay from racing that timer, so the failure the desktop reports is its own timeout with its own
53
- * pending-entry cleanup, not a second, earlier one from under the link.
54
- */
55
14
  const CHILD_DEADLINE_SLACK_MS = 5_000;
56
15
  const MAX_CHILD_DEADLINE_MS = 300_000;
57
- /**
58
- * The ceiling for methods whose own work is allowed to be slow. The browser installer is bounded by
59
- * its own twenty-minute timer and the viewer grants it 21 minutes; the short ceiling would cut that
60
- * budget off under the link and fail a call the peer was still completing.
61
- */
62
16
  const LONG_DEADLINE_METHODS = new Set(['browser.runtime.install']);
63
17
  const MAX_LONG_CHILD_DEADLINE_MS = 1_260_000;
64
- /** How often a live connection's device is re-checked against the configuration. */
65
18
  const REVOCATION_POLL_MS = 5_000;
66
- /**
67
- * How long a connection may exist with no event stream before the relay retires it.
68
- *
69
- * `remote.engine.connect` answers before its SSE GET lands, and a viewer can unload in between: a
70
- * connection created only by requests would otherwise keep its terminals and never be swept, since
71
- * the response-close callback that ends it exists only on the stream. The same TTL now also bounds
72
- * a retryable stream loss: the shells survive the seconds a reconnect takes, and only an abandoned
73
- * connection reaches the poller's sweep.
74
- */
75
19
  const SINKLESS_CONNECTION_TTL_MS = 30_000;
76
- /**
77
- * How long a run's completion is kept for a reconnecting viewer.
78
- *
79
- * A run that finished while its viewer's stream was down is not active any more — replaying its
80
- * start would show it working forever — so the completion itself is what the replacement stream
81
- * receives, for as long as a viewer that saw the start could still be reconnecting.
82
- */
83
20
  const FINISHED_RUN_TTL_MS = 5 * 60_000;
84
- /** How many recent completions are kept, per the TTL above. */
85
21
  const FINISHED_RUNS_REMEMBERED = 8;
86
- /**
87
- * What a relayed response may weigh. The viewer's transport caps at 2 MiB by default; the methods a
88
- * local window displays in megabytes — a journal tail, a diff — get the larger bound the product
89
- * contract asks for, and anything past its bound is an error the window can name.
90
- */
91
22
  const MAX_RESPONSE_BYTES = 2 * 1024 * 1024;
92
23
  const MAX_LARGE_RESPONSE_BYTES = 12 * 1024 * 1024;
93
24
  const LARGE_RESPONSE_METHODS = new Set(['runs.get', 'workspace.diff', 'workspace.git', 'sessions.trajectory', 'browser.view.selection', 'attachments.read', 'sessions.changes.list', 'sessions.changes.get']);
94
- /** Methods a paired client may ask the browsing engine (and only the browsing engine). */
95
25
  const PRIMARY_METHODS = new Set([
96
26
  'sessions.list', 'sessions.get', 'sessions.create', 'sessions.rename', 'sessions.setArchived', 'sessions.delete',
97
27
  'sessions.trajectory',
98
- // The skill a slash invocation left active on that machine's session: the Plan card shows it and
99
- // pauses, resumes or removes it there, since the session's later runs start there too.
100
28
  'sessions.skill.get', 'sessions.skill.update',
101
- // The files that machine's agent changed in the session, and Keep / Undo of them: the files and the
102
- // stored originals are on that machine, and every engine sharing its home can read and change the record.
103
29
  'sessions.changes.list', 'sessions.changes.get', 'sessions.changes.keep', 'sessions.changes.undo',
104
30
  'runs.list', 'runs.get', 'timers.list',
105
31
  'workspace.tree', 'workspace.read', 'workspace.git', 'workspace.branches', 'workspace.checkout', 'workspace.diff',
106
32
  'graphs.list', 'graphs.get', 'graphs.select',
107
- // The attachment chips of a browsed session name files spooled on the machine that owns the
108
- // session, so the preview asks that machine's engine for the bytes.
109
33
  'attachments.read',
110
- 'config.get', 'projects.list', 'projects.add', 'projects.remove',
111
- // Composer suggestions read the paired machine's installed skills; management stays local.
112
- 'extensions.list',
113
- // The session browser panel lives on the machine that owns the session, so a
114
- // paired window's pane asks that machine's browsing engine for both the
115
- // runtime and the pages. Without these entries a full-grant link refuses
116
- // every panel call as unknown-method.
34
+ 'config.get', 'projects.list', 'projects.add', 'projects.remove', 'projects.relink',
35
+ 'extensions.list', 'project.extensions',
117
36
  'browser.runtime.status', 'browser.runtime.install',
118
37
  'browser.view.status', 'browser.view.open', 'browser.view.navigate', 'browser.view.go', 'browser.view.activate',
119
38
  'browser.view.closeTab', 'browser.view.stream', 'browser.view.input', 'browser.view.selection',
120
39
  'browser.view.release', 'browser.view.cursor',
121
- // A paired window's import reads the Firefox of the machine that owns the browser.
122
40
  'browser.cookies.sources', 'browser.cookies.import',
123
- // The agent's panel tool on a task engine relays through the viewer: the
124
- // operation runs on the browsing engine, and a run cancellation travels back
125
- // so a stopped call cannot act on the shared browser afterwards.
41
+ 'browser.extensions.list', 'browser.extensions.sources', 'browser.extensions.prepare', 'browser.extensions.commit',
42
+ 'browser.extensions.discard', 'browser.extensions.remove', 'browser.extensions.setEnabled', 'browser.extensions.reload',
43
+ 'browser.extensions.restart',
126
44
  'browser.panel.op', 'browser.panel.cancel',
127
45
  ]);
128
- /** Methods that start a run, on an engine of the pool's choosing. */
129
46
  const RUN_START_METHODS = new Set(['run.start', 'run.resume']);
130
- /** Methods that answer for one run, addressed to the child that owns it. */
131
47
  const RUN_TARGET_METHODS = new Set(['run.setModel', 'run.setPermissions', 'run.cancel', 'run.steer', 'run.approve', 'run.answer', 'browser.panel.result']);
132
- /** Methods handled by the namespacing layer rather than forwarded verbatim. */
133
48
  const TERMINAL_METHODS = new Set(['terminal.open', 'terminal.write', 'terminal.resize', 'terminal.close', 'terminal.closeAll']);
134
49
  const ALLOWED_METHODS = new Set([...PRIMARY_METHODS, ...RUN_START_METHODS, ...RUN_TARGET_METHODS, ...TERMINAL_METHODS]);
135
- /** A session-mutating call goes to the engine whose run owns the session's record. */
136
50
  const SESSION_MUTATION_METHODS = new Set(['sessions.rename', 'sessions.setArchived', 'sessions.delete']);
137
- /** Calls whose effect must land inside the caller's own deadline, not past it. */
138
51
  const MUTATING_METHODS = new Set([
139
52
  ...RUN_START_METHODS, ...RUN_TARGET_METHODS, ...SESSION_MUTATION_METHODS, 'sessions.skill.update', 'sessions.changes.keep', 'sessions.changes.undo',
140
- 'terminal.open', 'terminal.write', 'terminal.close', 'terminal.closeAll', 'workspace.checkout', 'projects.add', 'projects.remove',
141
- // Panel calls act on the peer's browser immediately; an install outlives the
142
- // relay's default child deadline, so it keeps the caller's own budget.
53
+ 'terminal.open', 'terminal.write', 'terminal.close', 'terminal.closeAll', 'workspace.checkout', 'projects.add', 'projects.remove', 'projects.relink',
143
54
  'browser.runtime.install', 'browser.view.open', 'browser.view.navigate', 'browser.view.go', 'browser.view.activate',
144
55
  'browser.view.closeTab', 'browser.view.stream', 'browser.view.input', 'browser.cookies.import',
145
56
  'browser.panel.op', 'browser.panel.cancel',
57
+ 'browser.extensions.commit', 'browser.extensions.discard', 'browser.extensions.remove', 'browser.extensions.setEnabled',
58
+ 'browser.extensions.reload', 'browser.extensions.restart',
146
59
  ]);
147
- /** A child's failure, with the wire code it answered with — `engine-busy` decides pool selection. */
148
60
  class ChildError extends Error {
149
61
  code;
150
62
  constructor(code, message) {
@@ -152,11 +64,6 @@ class ChildError extends Error {
152
64
  this.code = code;
153
65
  }
154
66
  }
155
- /**
156
- * The only refusal type the relay raises on its own. A code from the engine's vocabulary survives
157
- * the trip (the desktop branches on `engine-busy`, `nothing-to-continue`); an unrecognized peer
158
- * string is never rethrown as a code.
159
- */
160
67
  class RelayRefusal extends Error {
161
68
  code;
162
69
  constructor(code, message) {
@@ -172,7 +79,6 @@ function relayError(error) {
172
79
  }
173
80
  return { code: 'remote', message: error instanceof Error ? error.message : String(error) };
174
81
  }
175
- /** One spawned `app-server`, speaking the newline JSON wire. */
176
82
  class ChildEngine {
177
83
  id;
178
84
  onEvent;
@@ -184,11 +90,8 @@ class ChildEngine {
184
90
  resolveReady;
185
91
  rejectReady;
186
92
  stopped = false;
187
- /** Whether a run owns this child; learned from its own run lifecycle events. */
188
93
  busy = false;
189
- /** The capabilities the child advertised in its handshake. */
190
94
  advertised = [];
191
- /** The child's newest stderr lines: an engine that dies should say what it last said. */
192
95
  stderrTail = [];
193
96
  constructor(id, command, home, onEvent, onExit) {
194
97
  this.id = id;
@@ -197,7 +100,6 @@ class ChildEngine {
197
100
  this.child = spawn(command[0], command.slice(1), {
198
101
  windowsHide: true,
199
102
  stdio: ['pipe', 'pipe', 'pipe'],
200
- // The relayed child cannot see the window that drives it, so it is told which surface it is.
201
103
  env: { ...process.env, ANDORRACODE_HOME: home, ANDORRA_SURFACE: 'remote' },
202
104
  });
203
105
  this.ready = new Promise((resolve, reject) => {
@@ -210,8 +112,6 @@ class ChildEngine {
210
112
  const last = this.stderrTail[this.stderrTail.length - 1];
211
113
  this.fail(new Error(`Engine ${id} exited.${last !== undefined ? ` Last output: ${last.slice(0, 300)}` : ''}`));
212
114
  });
213
- // A child's stderr must be drained even though nothing forwards it yet: an unread pipe fills,
214
- // and a task that writes enough diagnostics would then block on its own logging and hang.
215
115
  if (this.child.stderr) {
216
116
  createInterface({ input: this.child.stderr }).on('line', line => {
217
117
  if (!line.trim())
@@ -227,9 +127,6 @@ class ChildEngine {
227
127
  this.fail(new Error(`Engine ${id} started without a usable pipe.`));
228
128
  return;
229
129
  }
230
- // A write that fails asynchronously — EPIPE after the child died between the liveness check and
231
- // the write — is emitted as an 'error' event on stdin, not thrown; unhandled it would terminate
232
- // the whole relay process instead of failing this engine.
233
130
  stdin.on('error', error => this.fail(new Error(`Engine ${id} lost its input: ${error.message}`)));
234
131
  createInterface({ input: stdout }).on('line', line => {
235
132
  if (!line.trim())
@@ -243,8 +140,6 @@ class ChildEngine {
243
140
  }
244
141
  if (typeof parsed.event === 'string') {
245
142
  if (parsed.event === 'ready') {
246
- // The handshake is what says what this child can do, and the pool routes by it: a child
247
- // that predates a feature answers the request and silently ignores the parameter.
248
143
  const capabilities = parsed.data?.capabilities;
249
144
  this.advertised = Array.isArray(capabilities) ? capabilities.filter((entry) => typeof entry === 'string') : [];
250
145
  this.resolveReady?.();
@@ -280,7 +175,6 @@ class ChildEngine {
280
175
  this.child.kill();
281
176
  this.onExit(this.id);
282
177
  }
283
- /** Whether this child advertised a capability in its handshake. */
284
178
  supports(capability) {
285
179
  return this.advertised.includes(capability);
286
180
  }
@@ -298,8 +192,6 @@ class ChildEngine {
298
192
  this.pending.set(id, { resolve, reject, timer });
299
193
  try {
300
194
  stdin.write(`${JSON.stringify({ id, method, params })}\n`, error => {
301
- // The same failure surfacing on the write's own callback: the request cannot be answered,
302
- // so it is rejected now rather than left to its deadline.
303
195
  if (!error)
304
196
  return;
305
197
  const entry = this.pending.get(id);
@@ -317,7 +209,6 @@ class ChildEngine {
317
209
  }
318
210
  });
319
211
  }
320
- /** Close stdin (the engine's graceful shutdown signal) with a kill backstop. */
321
212
  stop() {
322
213
  if (this.stopped)
323
214
  return Promise.resolve();
@@ -338,7 +229,6 @@ class ChildEngine {
338
229
  });
339
230
  }
340
231
  }
341
- /** How this process spawns another engine of its own CLI. */
342
232
  export function relayEngineCommand() {
343
233
  const override = process.env.ANDORRA_REMOTE_ENGINE_COMMAND;
344
234
  if (override) {
@@ -347,11 +237,9 @@ export function relayEngineCommand() {
347
237
  if (Array.isArray(parsed) && parsed.length)
348
238
  return parsed.map(String);
349
239
  }
350
- catch { /* A single path is the plain spelling of the override. */ }
240
+ catch { }
351
241
  return [override];
352
242
  }
353
- // This process is the CLI (`node …/cli.js app-server|remote …`), so its own entry is the engine
354
- // entry: the relay's children are the same `app-server --stdio` wire the desktop's shell spawns.
355
243
  const entry = process.argv[1];
356
244
  if (!entry)
357
245
  throw new RelayRefusal('remote', 'The engine relay cannot locate its own CLI entry.');
@@ -361,7 +249,6 @@ const REMOTE_PROJECT_PREFIX = 'rw:';
361
249
  function isRemoteProjectSpelling(value) {
362
250
  return value.startsWith(REMOTE_PROJECT_PREFIX);
363
251
  }
364
- /** The root id part of an `rw:` spelling: everything after the viewer workspace segment. */
365
252
  function rootPartOf(value) {
366
253
  const rest = value.slice(REMOTE_PROJECT_PREFIX.length);
367
254
  const colon = rest.indexOf(':');
@@ -369,45 +256,25 @@ function rootPartOf(value) {
369
256
  return undefined;
370
257
  return rest.slice(colon + 1);
371
258
  }
372
- /**
373
- * The coordinator. One instance per listener, created by the server alongside it.
374
- */
375
259
  export class RemoteEngineRelay {
376
260
  directory;
377
261
  children = new Map();
378
- /**
379
- * The children this relay is stopping, so no start takes one that is on its way out.
380
- *
381
- * It belongs to the relay: two relays in one process allocate the same child ids, and one
382
- * relay's reservation would hide another's idle child.
383
- */
384
262
  retiringChildren = new Set();
385
263
  taskSeq = 0;
386
264
  connections = new Map();
387
- /** Real (child-side) terminal id → the connection that opened it. */
388
265
  terminalOwner = new Map();
389
- /** Session id → the connections whose panels are watching it (a stream they share). */
390
266
  browserViewers = new Map();
391
- /** runId / sessionId → the child that owns it, learned from run lifecycle events. */
392
267
  runEngine = new Map();
393
268
  sessionEngine = new Map();
394
- /** The `run.started` payload of each live run, keyed by its child — replayed to new connections. */
395
269
  activeRuns = new Map();
396
- /** The completions that landed with no stream attached, kept briefly for the reconnect replay. */
397
270
  finishedRuns = new Map();
398
- /** Translations by viewer workspace id, each cached briefly (a rebuild realpath-walks the roots). */
399
271
  translations = new Map();
400
272
  revocationTimer;
401
- /** Event delivery is queued: a stream's frames must land in the order the children emitted them. */
402
273
  delivery = Promise.resolve();
403
274
  closed = false;
404
275
  constructor(directory) {
405
276
  this.directory = directory;
406
277
  }
407
- /**
408
- * One relayed request. Throws nothing: every failure is the answer's `error`, because the caller is
409
- * an HTTP handler whose status code cannot say what went wrong inside the engine pool.
410
- */
411
278
  async request(deviceId, body) {
412
279
  try {
413
280
  const { method, params } = this.validate(body);
@@ -442,10 +309,6 @@ export class RemoteEngineRelay {
442
309
  const asked = typeof body.deadlineMs === 'number' && body.deadlineMs > 0 ? body.deadlineMs : 120_000;
443
310
  const ceiling = LONG_DEADLINE_METHODS.has(body.method) ? MAX_LONG_CHILD_DEADLINE_MS : MAX_CHILD_DEADLINE_MS;
444
311
  const bounded = Math.min(Math.max(asked, 5_000), ceiling);
445
- // A mutation runs inside the caller's own budget: the viewer's client fails the call at the
446
- // deadline it sent, and a start, prompt answer, session change, or shell open that committed
447
- // after that would surprise a user who already retried or moved on. Reads keep the small slack
448
- // that lets the engine decide its own timeout rather than racing the viewer's.
449
312
  if (MUTATING_METHODS.has(body.method))
450
313
  return bounded;
451
314
  return bounded + CHILD_DEADLINE_SLACK_MS;
@@ -459,8 +322,6 @@ export class RemoteEngineRelay {
459
322
  return this.startRequest(body, method, params, deadline);
460
323
  if (RUN_TARGET_METHODS.has(method))
461
324
  return this.runTargetRequest(body, method, params, deadline);
462
- // A run owns its session's record while it executes, so a mutation belongs to the engine running
463
- // it — the same refusal-and-perform rule a local window's routing follows.
464
325
  if (SESSION_MUTATION_METHODS.has(method) && typeof params.id === 'string') {
465
326
  const owner = this.sessionEngine.get(params.id);
466
327
  if (owner)
@@ -470,9 +331,6 @@ export class RemoteEngineRelay {
470
331
  if (target !== REMOTE_PRIMARY_ENGINE && !this.children.has(target)) {
471
332
  throw new RelayRefusal('not-found', `No engine ${target} is serving this machine's remote surface.`);
472
333
  }
473
- // A session's panel stream is one switch on the hosting engine, so several paired viewers
474
- // watching the same session share it: it is turned off only when the last of them leaves, and
475
- // the other viewers' panes keep receiving frames until then.
476
334
  if (method === 'browser.view.stream' && typeof params.sessionId === 'string') {
477
335
  const sessionId = params.sessionId;
478
336
  if (params.enabled === false) {
@@ -492,50 +350,25 @@ export class RemoteEngineRelay {
492
350
  }
493
351
  const engine = await this.engine(target);
494
352
  const answer = await engine.request(method, await this.translateParams(body.viewerWorkspaceId, params), deadline);
495
- // The session listing echoes each requested spelling back; the viewer files its groups by its
496
- // own, so the echo is restored here rather than left in this machine's terms.
497
353
  if (method === 'sessions.list' && Array.isArray(params.workspaces)) {
498
354
  return this.restoreRequestedEcho(answer, params.workspaces, body.viewerWorkspaceId);
499
355
  }
500
- // A trajectory page names the log it is showing, and that name is a path on this machine: the
501
- // viewer's own home is not this one, and it cannot use the name anyway. It is left out rather
502
- // than sent, so the host's layout is not handed to a paired client.
503
356
  if (method === 'sessions.trajectory' && answer !== null && typeof answer === 'object' && !Array.isArray(answer)) {
504
357
  const { path: _hostPath, ...page } = answer;
505
358
  return page;
506
359
  }
507
360
  return answer;
508
361
  }
509
- /**
510
- * run.start / run.resume: pick a free task engine, spawning one when every child is busy.
511
- *
512
- * The browsing engine never takes a run (ADR 0017), the busy refusal is the engine's own, and the
513
- * answer names the engine that took the run so the viewer can address its prompts directly.
514
- */
515
362
  async startRequest(body, method, params, deadline) {
516
- // The capability the answering child must advertise, asked for by the viewer: the browsing
517
- // engine's handshake says what the machine can do, not what every task engine on it can, and a
518
- // child that predates a feature answers the request and ignores the parameter. The requirement
519
- // travels with the request so the pool picks a child that honours it — and it is stripped here,
520
- // because it is the pool's own routing rule and not the engine's parameter.
521
363
  const { requireCapability, ...rest } = params;
522
364
  const required = typeof requireCapability === 'string' && requireCapability.length > 0 ? requireCapability : undefined;
523
365
  const translated = await this.translateParams(body.viewerWorkspaceId, rest);
524
- // A resume may address the engine that owns the session's scheduled wake (the desktop learned
525
- // the id from the wake's own events): routing it by pool selection could wake the session in a
526
- // second process while the first still holds the timer, and the two would overwrite each
527
- // other's persisted turns. The addressed engine decides; its own busy refusal is the answer.
528
366
  if (body.engine !== '' && body.engine !== REMOTE_PRIMARY_ENGINE) {
529
367
  const addressed = this.children.get(body.engine);
530
368
  if (addressed !== undefined) {
531
- // A child this relay is stopping is on its way out: a request addressed to it would be
532
- // accepted and then lose the engine under it.
533
369
  if (this.retiringChildren.has(addressed.id)) {
534
370
  throw new RelayRefusal('busy', 'That engine is being stopped; try again.');
535
371
  }
536
- // The addressed engine owns the session's wake, so it is the one that has to answer. A child
537
- // that cannot honour the requirement is refused rather than rerouted: another engine would
538
- // wake the session in a second process.
539
372
  if (required !== undefined && !addressed.supports(required)) {
540
373
  throw new RelayRefusal('invalid-params', `The engine that would answer does not support ${required}.`);
541
374
  }
@@ -543,22 +376,15 @@ export class RemoteEngineRelay {
543
376
  return { ...result, engine: addressed.id };
544
377
  }
545
378
  }
546
- // A child that does not advertise the capability is not asked at all: it would answer and
547
- // ignore the parameter, which is exactly the silence the requirement exists to prevent. An idle
548
- // one is retired rather than merely skipped: the pool's cap counts every child, and a pool full
549
- // of children that cannot answer would refuse the run as busy while nothing was running.
550
379
  const incompatible = [];
551
380
  for (const [id, engine] of [...this.children]) {
552
381
  if (id === REMOTE_PRIMARY_ENGINE)
553
382
  continue;
554
383
  if (required !== undefined && !engine.supports(required)) {
555
- // A child another request is already retiring is not a candidate: two scans would pick the
556
- // same one, and only one slot would be freed.
557
384
  if (!engine.busy && !this.retiringChildren.has(id))
558
385
  incompatible.push(engine);
559
386
  continue;
560
387
  }
561
- // A child this relay is stopping is on its way out: a start must not take it.
562
388
  if (this.retiringChildren.has(id))
563
389
  continue;
564
390
  try {
@@ -571,22 +397,13 @@ export class RemoteEngineRelay {
571
397
  throw error;
572
398
  }
573
399
  }
574
- // A child that finished its run but still owns a self-wake timer is not idle in the sense that
575
- // matters: stopping it would destroy the pending wake, which is the session's own work. The
576
- // scan looks for a child that can be stopped — one may hold a wake while the next cannot.
577
400
  for (const child of incompatible) {
578
- // Reserved before the first check, and only if another request has not claimed this child
579
- // already: two claims would retire one child and free one slot, and the second request
580
- // would be refused as busy while another incompatible idle child remained.
581
401
  if (this.retiringChildren.has(child.id))
582
402
  continue;
583
403
  this.retiringChildren.add(child.id);
584
404
  try {
585
405
  if (await this.childHoldsWake(child))
586
406
  continue;
587
- // The child's own answer is the authority on whether it is free: the busy flag is set when
588
- // a run starts, which is after the child has accepted the request, so a child that is still
589
- // preparing one looks idle here and must not be stopped under it.
590
407
  if (!await this.childIsIdle(child))
591
408
  continue;
592
409
  await this.retireChild(child.id);
@@ -598,8 +415,6 @@ export class RemoteEngineRelay {
598
415
  }
599
416
  const spawned = await this.spawnChild(`${TASK_PREFIX}${++this.taskSeq}`);
600
417
  try {
601
- // A fresh child comes from the machine's current install, so it advertises what the browsing
602
- // engine advertised; a machine whose install cannot honour the requirement says so instead.
603
418
  if (required !== undefined && !spawned.supports(required)) {
604
419
  throw new RelayRefusal('invalid-params', `This machine's engine does not support ${required}.`);
605
420
  }
@@ -607,20 +422,11 @@ export class RemoteEngineRelay {
607
422
  return { ...result, engine: spawned.id };
608
423
  }
609
424
  catch (error) {
610
- // A child that took no run is an idle process the pool does not need; retiring it keeps a
611
- // refused start from spending a slot. A child whose run began keeps the slot — its events are
612
- // still owed to the streams.
613
425
  if (!spawned.busy && !this.engineOwnsRun(spawned.id))
614
426
  await this.retireChild(spawned.id);
615
427
  throw error;
616
428
  }
617
429
  }
618
- /**
619
- * run.cancel / run.approve / run.answer: a prompt belongs to the child that raised it.
620
- *
621
- * The viewer addresses these by the engine id it learned from `run.started`, which is authoritative
622
- * here as well; a cancel names its run id, and the ownership map answers that on its own.
623
- */
624
430
  async runTargetRequest(body, method, params, deadline) {
625
431
  let owner;
626
432
  if (typeof params.runId === 'string')
@@ -635,11 +441,6 @@ export class RemoteEngineRelay {
635
441
  }
636
442
  return (await this.engine(owner)).request(method, params, deadline);
637
443
  }
638
- /**
639
- * Terminal calls: ids are prefixed with the connection, output goes only to that connection, and a
640
- * closeAll sweeps only the shells that connection opened. The browsing engine hosts the PTYs — a
641
- * shell outlives any one task and belongs to no run.
642
- */
643
444
  async terminalRequest(connection, method, params, deadline) {
644
445
  const primary = await this.engine(REMOTE_PRIMARY_ENGINE);
645
446
  const real = (prefixed) => {
@@ -659,8 +460,6 @@ export class RemoteEngineRelay {
659
460
  const id = real(params.id);
660
461
  if (id === undefined)
661
462
  throw new RelayRefusal('not-found', 'That terminal was not opened on this connection.');
662
- // `cwd` on these calls is the VIEWER's routing hint (which machine owns the shell); the
663
- // engine's own write/resize/close take no folder, so it is not forwarded.
664
463
  const { cwd: _routing, ...forwarded } = params;
665
464
  const answer = await primary.request(method, { ...forwarded, id }, deadline);
666
465
  if (method === 'terminal.close') {
@@ -669,8 +468,6 @@ export class RemoteEngineRelay {
669
468
  }
670
469
  return answer;
671
470
  }
672
- // terminal.closeAll: only the shells this connection opened — the desktop's own closeAll from a
673
- // reattach is the one call that cannot name ids, and here it stays scoped to the issuer.
674
471
  const opened = [...connection.terminals.entries()];
675
472
  connection.terminals.clear();
676
473
  for (const [, id] of opened)
@@ -681,19 +478,15 @@ export class RemoteEngineRelay {
681
478
  await primary.request('terminal.close', { id }, 5_000);
682
479
  closed += 1;
683
480
  }
684
- catch { /* A dead shell is closed. */ }
481
+ catch { }
685
482
  }
686
483
  return { closed };
687
484
  }
688
- /**
689
- * Translate the viewer's project spellings inside request params. Only the fields that NAME a
690
- * workspace folder carry one, so the walk is over those fields, not the whole payload — a task
691
- * prompt may legitimately contain the literal text "rw:".
692
- */
693
485
  async translateParams(viewerWorkspaceId, params) {
694
486
  const workspaces = Array.isArray(params.workspaces) ? params.workspaces : undefined;
695
487
  const needs = (typeof params.workspace === 'string' && isRemoteProjectSpelling(params.workspace))
696
488
  || (typeof params.cwd === 'string' && isRemoteProjectSpelling(params.cwd))
489
+ || (typeof params.path === 'string' && isRemoteProjectSpelling(params.path))
697
490
  || (workspaces !== undefined && workspaces.some(value => typeof value === 'string' && isRemoteProjectSpelling(value)));
698
491
  if (!needs)
699
492
  return params;
@@ -703,10 +496,9 @@ export class RemoteEngineRelay {
703
496
  next.workspace = translation.toHost(next.workspace);
704
497
  if (typeof next.cwd === 'string' && isRemoteProjectSpelling(next.cwd))
705
498
  next.cwd = translation.toHost(next.cwd);
499
+ if (typeof next.path === 'string' && isRemoteProjectSpelling(next.path))
500
+ next.path = translation.toHost(next.path);
706
501
  if (workspaces !== undefined) {
707
- // A listing tolerates one untranslatable spelling: a hashed pick (a folder chosen inside a
708
- // root) has no host path, but refusing the WHOLE listing for it would blank every registered
709
- // row beside it. It passes through verbatim; the host answers that group empty.
710
502
  next.workspaces = workspaces.map(value => {
711
503
  if (typeof value !== 'string' || !isRemoteProjectSpelling(value))
712
504
  return value;
@@ -720,7 +512,6 @@ export class RemoteEngineRelay {
720
512
  }
721
513
  return next;
722
514
  }
723
- /** Put each listing group back under the spelling the viewer asked with. */
724
515
  async restoreRequestedEcho(answer, original, viewerWorkspaceId) {
725
516
  const groups = answer?.groups;
726
517
  if (!Array.isArray(groups))
@@ -735,7 +526,6 @@ export class RemoteEngineRelay {
735
526
  });
736
527
  return answer;
737
528
  }
738
- /** The connection record, created on first sight. */
739
529
  connection(deviceId, connectionId, viewerWorkspaceId) {
740
530
  let found = this.connections.get(connectionId);
741
531
  if (!found) {
@@ -748,18 +538,12 @@ export class RemoteEngineRelay {
748
538
  found.viewerWorkspaceId = viewerWorkspaceId;
749
539
  return found;
750
540
  }
751
- /**
752
- * End one connection outright: its streams are closed (not merely starved), its terminals swept.
753
- *
754
- * Revocation and shutdown both go through here, so a connection never survives either — the
755
- * viewer observes the stream end and the host keeps no orphaned shells or half-dead sockets.
756
- */
757
541
  sever(connection) {
758
542
  for (const cut of [...connection.cuts]) {
759
543
  try {
760
544
  cut();
761
545
  }
762
- catch { /* The response is already gone. */ }
546
+ catch { }
763
547
  }
764
548
  connection.sinks.clear();
765
549
  connection.cuts.clear();
@@ -768,9 +552,6 @@ export class RemoteEngineRelay {
768
552
  void this.engine(REMOTE_PRIMARY_ENGINE).then(primary => primary.request('terminal.close', { id: real }, 5_000)).catch(() => undefined);
769
553
  }
770
554
  connection.terminals.clear();
771
- // Turning the stream off hands the browser back to the idle reaper, which
772
- // closes it a while later; the viewer that owned it is gone either way — but
773
- // only when no other connection is still watching that session's panel.
774
555
  for (const sessionId of connection.browserStreams) {
775
556
  const viewers = this.browserViewers.get(sessionId);
776
557
  viewers?.delete(connection.id);
@@ -784,41 +565,20 @@ export class RemoteEngineRelay {
784
565
  connection.browserStreams.clear();
785
566
  this.connections.delete(connection.id);
786
567
  }
787
- /**
788
- * Register one connection's event stream. The returned stop function ends delivery; the server
789
- * calls it when the HTTP response closes, and it sweeps that connection's terminals with it — a
790
- * window that is gone cannot name its shells any more, and the host's slots are not a graveyard.
791
- */
792
568
  events(deviceId, connectionId, viewerWorkspaceId, sink, cut) {
793
569
  const connection = this.connection(deviceId, connectionId, viewerWorkspaceId);
794
570
  connection.sinks.add(sink);
795
571
  connection.cuts.add(cut);
796
572
  connection.sinklessSince = 0;
797
- // A window that reconnects while work is still live has never seen what happened since its last
798
- // stream ended: the active run's `run.started`, the completions that landed in the gap, and the
799
- // timers an idle engine still holds. These are delivered TO THIS SINK alone — the other, healthy
800
- // viewers already saw them, and replaying start frames at them would reset live tracking.
801
573
  this.replayTo(connection, viewerWorkspaceId, sink);
802
574
  return () => {
803
575
  connection.sinks.delete(sink);
804
576
  connection.cuts.delete(cut);
805
577
  if (connection.sinks.size > 0)
806
578
  return;
807
- // A stream that closed may be a retryable one (a network blip, backpressure): its viewer
808
- // reconnects with the same connection id within seconds. The shells stay — they are the
809
- // connection's until either an explicit stream returns (sinklessSince resets) or the poller's
810
- // abandonment TTL ends the connection for good.
811
579
  connection.sinklessSince = Date.now();
812
580
  };
813
581
  }
814
- /**
815
- * Deliver the reconnect snapshot to one stream, in emission order with everything else.
816
- *
817
- * Active runs first (the replacement client must register them), then the completions that landed
818
- * while no stream was attached (so a run that finished in a reconnect gap is not shown as working
819
- * forever), then each idle engine's outstanding timers (so a scheduled wake is adopted by the new
820
- * client rather than firing unseen).
821
- */
822
582
  replayTo(connection, viewerWorkspaceId, sink) {
823
583
  void (async () => {
824
584
  const now = Date.now();
@@ -853,7 +613,6 @@ export class RemoteEngineRelay {
853
613
  }
854
614
  })().catch(() => undefined);
855
615
  }
856
- /** One queued frame for one sink: the reconnect replay shares the queue, not the broadcast. */
857
616
  enqueueTo(sink, translation, engineId, event, data) {
858
617
  this.delivery = this.delivery.then(() => {
859
618
  if (this.closed)
@@ -861,15 +620,9 @@ export class RemoteEngineRelay {
861
620
  try {
862
621
  sink({ engine: engineId, event, data: translation.rewrite(data) });
863
622
  }
864
- catch { /* The stream's own handler closes it. */ }
623
+ catch { }
865
624
  }).catch(() => undefined);
866
625
  }
867
- /**
868
- * One child event, in emission order.
869
- *
870
- * The queue is the ordering guarantee a stream needs — `run.started` must reach the viewer before
871
- * the run's first events whatever the translation cache is doing between them.
872
- */
873
626
  enqueue(engineId, event, data) {
874
627
  this.delivery = this.delivery.then(() => this.deliverEvent(engineId, event, data)).catch(() => undefined);
875
628
  }
@@ -887,7 +640,6 @@ export class RemoteEngineRelay {
887
640
  this.runEngine.set(runId, engineId);
888
641
  if (typeof data.sessionId === 'string')
889
642
  this.sessionEngine.set(data.sessionId, engineId);
890
- // A task engine runs one task at a time: this frame is the run a reconnecting window adopts.
891
643
  if (engineId !== REMOTE_PRIMARY_ENGINE)
892
644
  this.activeRuns.set(engineId, data);
893
645
  }
@@ -901,8 +653,6 @@ export class RemoteEngineRelay {
901
653
  child.busy = false;
902
654
  if (engineId !== REMOTE_PRIMARY_ENGINE) {
903
655
  this.activeRuns.delete(engineId);
904
- // A viewer whose stream is down saw the start but will miss this: the completion is kept
905
- // for the reconnect replay, so the run does not stay on screen as working forever.
906
656
  this.finishedRuns.set(engineId, { event, data, at: Date.now() });
907
657
  if (this.finishedRuns.size > FINISHED_RUNS_REMEMBERED) {
908
658
  const oldest = this.finishedRuns.keys().next().value;
@@ -912,8 +662,6 @@ export class RemoteEngineRelay {
912
662
  }
913
663
  }
914
664
  if ((event === 'terminal.data' || event === 'terminal.exit') && typeof data.id === 'string') {
915
- // Terminal output belongs to the connection that opened the shell; every other stream — and
916
- // every other device — never sees it.
917
665
  const ownerId = this.terminalOwner.get(data.id);
918
666
  if (ownerId === undefined)
919
667
  return;
@@ -926,7 +674,7 @@ export class RemoteEngineRelay {
926
674
  try {
927
675
  sink(frame);
928
676
  }
929
- catch { /* The stream's own handler closes it. */ }
677
+ catch { }
930
678
  }
931
679
  return;
932
680
  }
@@ -939,18 +687,10 @@ export class RemoteEngineRelay {
939
687
  try {
940
688
  sink(frame);
941
689
  }
942
- catch { /* The stream's own handler closes it. */ }
690
+ catch { }
943
691
  }
944
692
  }
945
693
  }
946
- /**
947
- * One event's data for one viewer, with its project paths translated.
948
- *
949
- * A panel operation's arguments are the browser's own input, not paths: a `fill` value that
950
- * happens to equal a shared root is a form value the page must receive verbatim, and rewriting it
951
- * into the viewer's project id would type that id into the page instead. Only the routing fields
952
- * around them are translated.
953
- */
954
694
  rewriteEventData(translation, event, data) {
955
695
  if (event !== 'browser.panel.request' || data.arguments === undefined)
956
696
  return translation.rewrite(data);
@@ -958,14 +698,8 @@ export class RemoteEngineRelay {
958
698
  return { ...translation.rewrite(rest), arguments: verbatim };
959
699
  }
960
700
  onChildExit(engineId) {
961
- // A child that dies mid-run leaves the persisted session claiming the run is still live (the
962
- // reconciliation a healthy engine performs at startup never runs for it): mark it interrupted
963
- // here, so listings and reloads do not show a working task that no process is driving.
964
701
  const interrupted = this.activeRuns.get(engineId);
965
702
  if (interrupted !== undefined && typeof interrupted.runId === 'string') {
966
- // The child queued a start for this run, so the reconciliation owes the matching finish;
967
- // dropping the returned records would leave that start unmatched, because a replacement
968
- // app-server skips records no longer marked running.
969
703
  void reconcileInterruptedRuns(this.directory, new Set([interrupted.runId]), { includePending: true })
970
704
  .then(recovered => reportInterruptedRuns({ home: this.directory, surface: configuredSurface('remote') }, recovered.interrupted))
971
705
  .catch(() => undefined);
@@ -978,8 +712,6 @@ export class RemoteEngineRelay {
978
712
  for (const [sessionId, owner] of [...this.sessionEngine])
979
713
  if (owner === engineId)
980
714
  this.sessionEngine.delete(sessionId);
981
- // The viewer learns the engine is gone as an event, so its remote client for it can be retired
982
- // the way a dead process's client is.
983
715
  this.enqueue(engineId, 'engine.exited', { engine: engineId });
984
716
  }
985
717
  engineOwnsRun(engineId) {
@@ -1002,9 +734,6 @@ export class RemoteEngineRelay {
1002
734
  return existing;
1003
735
  if (this.closed)
1004
736
  throw new RelayRefusal('remote', 'The remote engine relay is shutting down.');
1005
- // The cap counts task engines, and the browsing engine is exempt from it — its slot is the one
1006
- // the cap exists to protect, so nine busy tasks never leave the primary surface (sessions,
1007
- // workspace reads, terminals) unspawnable.
1008
737
  if (id !== REMOTE_PRIMARY_ENGINE) {
1009
738
  const taskEngines = [...this.children.keys()].filter(childId => childId !== REMOTE_PRIMARY_ENGINE).length;
1010
739
  if (taskEngines >= MAX_RELAY_ENGINES) {
@@ -1023,18 +752,6 @@ export class RemoteEngineRelay {
1023
752
  }
1024
753
  return created;
1025
754
  }
1026
- /**
1027
- * Whether a child still owns a scheduled wake.
1028
- *
1029
- * A child that cannot answer is treated as holding one: stopping it could destroy a wake that
1030
- * is still owed, and a refused start is a visible failure while a lost wake is not.
1031
- */
1032
- /**
1033
- * Whether a child is free of a run.
1034
- *
1035
- * A child that cannot answer is not known to be free, and stopping one that is preparing a run
1036
- * would abort the task it accepted.
1037
- */
1038
755
  async childIsIdle(child) {
1039
756
  try {
1040
757
  const info = await child.request('host.info', {}, 5_000);
@@ -1060,14 +777,6 @@ export class RemoteEngineRelay {
1060
777
  this.children.delete(id);
1061
778
  await child.stop().catch(() => undefined);
1062
779
  }
1063
- /**
1064
- * The bidirectional project-spelling translation for one viewer.
1065
- *
1066
- * Cached briefly per viewer workspace id: building it realpath-walks every authorized root, and a
1067
- * sessions listing or an event burst would otherwise pay that per call. The cache never outlives a
1068
- * pairing change by long — five seconds — so a newly registered project is executable almost
1069
- * immediately.
1070
- */
1071
780
  async translation(viewerWorkspaceId) {
1072
781
  const cached = this.translations.get(viewerWorkspaceId);
1073
782
  const now = Date.now();
@@ -1090,8 +799,6 @@ export class RemoteEngineRelay {
1090
799
  const mapped = toHostMap.get(value);
1091
800
  if (mapped !== undefined)
1092
801
  return mapped;
1093
- // A folder picked inside a root was hashed with a relative path only the viewer knows, so no
1094
- // host-side table can reverse it. Refusing with the fix is the answer that can be acted on.
1095
802
  throw new RelayRefusal('not-found', 'That folder was picked inside a shared root. Register the folder itself on this machine (Add on the rail, or a project on this host) to run tasks in it.');
1096
803
  },
1097
804
  toViewer: value => toViewerMap.get(value) ?? value,
@@ -1100,12 +807,6 @@ export class RemoteEngineRelay {
1100
807
  this.translations.set(viewerWorkspaceId, { at: now, translation });
1101
808
  return translation;
1102
809
  }
1103
- /**
1104
- * Cut every live stream and terminal of devices that no longer hold full authority.
1105
- *
1106
- * Per-request authentication already refuses a revoked device's next call; this poller is for the
1107
- * resource a request never re-checks — the open event stream, and the shells its connection owns.
1108
- */
1109
810
  startRevocationPoll() {
1110
811
  if (this.revocationTimer !== undefined)
1111
812
  return;
@@ -1115,9 +816,6 @@ export class RemoteEngineRelay {
1115
816
  const valid = new Set((config.remote?.hosting?.devices ?? []).filter(device => device.grant === 'full').map(device => device.id));
1116
817
  for (const [, connection] of [...this.connections]) {
1117
818
  if (valid.has(connection.deviceId)) {
1118
- // A connection made by requests whose stream never arrived (the viewer unloaded between
1119
- // `remote.engine.connect` and its SSE GET) has no response-close callback to end it:
1120
- // the poller retires it, sweeping the terminals it opened.
1121
819
  if (connection.sinks.size === 0 && connection.sinklessSince !== 0 && Date.now() - connection.sinklessSince > SINKLESS_CONNECTION_TTL_MS) {
1122
820
  this.sever(connection);
1123
821
  }
@@ -1130,7 +828,6 @@ export class RemoteEngineRelay {
1130
828
  this.revocationTimer = setInterval(sweep, REVOCATION_POLL_MS);
1131
829
  this.revocationTimer.unref?.();
1132
830
  }
1133
- /** Stop the pool: every child gets the graceful close, and no stream outlives the listener. */
1134
831
  async close() {
1135
832
  if (this.closed)
1136
833
  return;
@@ -1144,15 +841,7 @@ export class RemoteEngineRelay {
1144
841
  await Promise.all(children.map(child => child.stop().catch(() => undefined)));
1145
842
  }
1146
843
  }
1147
- /**
1148
- * Fields whose value is a file's own text wherever it appears: a completed call's `fileDiff` on
1149
- * `node.tool.completed`, which reaches a viewer live inside `run.event` and again in the journal a
1150
- * `runs.get` or a trajectory read returns. A diff line that reads exactly like a host project folder is
1151
- * still a line of the file, and rewriting it would show the viewer a change the file never had. Only the
1152
- * routing fields around such a value are translated.
1153
- */
1154
844
  const VERBATIM_FIELDS = new Set(['fileDiff']);
1155
- /** Rewrite every known host path inside an arbitrary payload, structurally, leaving file text alone. */
1156
845
  function rewritePaths(value, paths) {
1157
846
  if (typeof value === 'string')
1158
847
  return paths.get(value) ?? value;
@@ -1166,12 +855,5 @@ function rewritePaths(value, paths) {
1166
855
  }
1167
856
  return value;
1168
857
  }
1169
- /**
1170
- * Answers that are the page's own data, not file-system answers. A selection that happens to read
1171
- * exactly like one of the host's shared-root paths is the user's text — rewriting it would put an
1172
- * `rw:` project identifier on the viewer's clipboard and, for a cut, delete the original from the
1173
- * page with only the identifier surviving. A pending change's diff is the same: the file's own text,
1174
- * whose paths are workspace-relative, and a line that reads like a host path is still a line.
1175
- */
1176
858
  const OPAQUE_RESPONSE_METHODS = new Set(['browser.view.selection', 'browser.view.cursor', 'sessions.changes.list', 'sessions.changes.get']);
1177
859
  export { REMOTE_PROJECT_PREFIX, isRemoteProjectSpelling, rootPartOf };