@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
@@ -1,4 +1,3 @@
1
- /* The Graph Manager button, its first-graph tip and the side chat panel. The decisions live in manager-state.js; this file draws them and talks to the graph server's /api/manager routes. */
2
1
  'use strict';
3
2
  globalThis.AndorraManager = (() => {
4
3
  const logic = globalThis.AndorraManagerState;
@@ -6,11 +5,10 @@ globalThis.AndorraManager = (() => {
6
5
  const byId = id => document.getElementById(id);
7
6
  const button = byId('graph-manager'), tip = byId('manager-tip'), panel = byId('manager-panel');
8
7
  if (!logic || !button || !tip || !panel) return undefined;
9
- const providerSelect = byId('manager-provider'), modelSelect = byId('manager-model');
8
+ const modelsSlot = byId('manager-models');
10
9
  const notices = byId('manager-notices'), log = byId('manager-transcript'), input = byId('manager-input');
11
10
  const sendButton = byId('manager-send'), stopButton = byId('manager-stop'), runLabel = byId('manager-run-state');
12
11
 
13
- /** Reading the storage property can itself throw (a sandboxed frame, blocked site data); the helpers treat a missing store as empty. */
14
12
  function storage() {
15
13
  try { return window.localStorage; } catch { return undefined; }
16
14
  }
@@ -20,34 +18,42 @@ globalThis.AndorraManager = (() => {
20
18
 
21
19
  let open = false;
22
20
  let transcript = [];
23
- /** The engine's run state, read from `state` events and each snapshot; the transcript does not keep it. */
24
21
  let runState = 'idle';
25
22
  let source = null, retryTimer = null, retryMs = 1000, connected = false;
26
- /** The canvas of the latest message the chat took, as JSON; what the agent's save is compared against. */
23
+ let streamGraphId = null;
27
24
  let sentCanvas = null;
28
- /** The graph the conversation is about, once it has a message. */
29
25
  let chatGraphId = null;
30
- /** Messages posted and not yet echoed by the stream, oldest first: { text, canvas, graphId }. */
31
26
  let posted = [];
32
- /** What `sentCanvas` and `chatGraphId` were before the latest echoed message, until that message can no longer be refused. */
33
27
  let beforeLastMessage = null;
34
- /** A message sent into a working run changed the canvas: the agent's next save may predate it, so it is offered. */
35
28
  let unsureCanvas = false;
29
+ let mergeCanvas = null;
30
+ const agentEdges = new Map();
31
+ let latestUserSeen = null;
32
+ const agentNodes = new Map();
33
+ let agentFields = {};
34
+ function rebase(canvas) {
35
+ mergeCanvas = canvas;
36
+ agentNodes.clear(); agentEdges.clear(); agentFields = {};
37
+ }
38
+ let mergeBeforeMessage = null;
39
+ function mergeState() {
40
+ return { mergeCanvas, nodes: new Map(agentNodes), edges: new Map(agentEdges), fields: { ...agentFields } };
41
+ }
42
+ function restoreMerge(saved) {
43
+ mergeCanvas = saved.mergeCanvas;
44
+ agentNodes.clear(); for (const [key, value] of saved.nodes) agentNodes.set(key, value);
45
+ agentEdges.clear(); for (const [key, value] of saved.edges) agentEdges.set(key, value);
46
+ agentFields = { ...saved.fields };
47
+ }
48
+ let deferredEdits = [];
36
49
  let shownGraphId = null;
37
50
  let choice;
38
51
  let providersSeen = '';
39
- /** A revision the agent saved that was not loaded because the canvas holds other edits. */
40
52
  let offeredRevision = null;
41
- /** A graph the agent created beside the bundled preset, which it cannot change: { id, label }. Opened only on click. */
42
53
  let createdOffer = null;
43
- /** The graph the user moved to while a conversation about another one is open. */
44
- let switchOffer = null;
45
54
  let localError = '';
46
- /** What this panel answered each approval with, to label the closed card. */
47
55
  const decisions = new Map();
48
- /** Cards whose answer is on its way; their controls stay disabled until the stream settles them. */
49
56
  const answering = new Set();
50
- /** What each drawn block showed: `{ block, pending, element }`. */
51
57
  let rendered = [];
52
58
 
53
59
  const node = (tag, text, className) => {
@@ -62,12 +68,9 @@ globalThis.AndorraManager = (() => {
62
68
  return item;
63
69
  };
64
70
 
65
- // ------------------------------------------------------------------ Button and tip
66
-
67
71
  function hideTip() { tip.hidden = true; }
68
72
  function dismissTip() { logic.dismissTip(storage()); hideTip(); }
69
73
 
70
- /** Follows the editor's heading: the button exists only beside an open graph, and a different graph is noticed here whichever way it arrived. */
71
74
  function heading() {
72
75
  const graph = state.graph;
73
76
  button.hidden = button.parentElement.hidden = !graph;
@@ -75,21 +78,29 @@ globalThis.AndorraManager = (() => {
75
78
  if (graph.id !== shownGraphId) {
76
79
  shownGraphId = graph.id;
77
80
  hideTip();
78
- offeredRevision = null;
79
- createdOffer = null;
80
- switchOffer = chatGraphId && chatGraphId !== graph.id && transcript.length ? graph.id : null;
81
- renderNotices();
81
+ switchConversation(graph.id);
82
82
  }
83
83
  if (open) fillModels();
84
84
  }
85
85
 
86
+ function switchConversation(graphId) {
87
+ disconnect();
88
+ streamGraphId = graphId;
89
+ chatGraphId = graphId;
90
+ transcript = []; runState = 'idle';
91
+ posted = []; sentCanvas = null; beforeLastMessage = null; unsureCanvas = false;
92
+ offeredRevision = null; createdOffer = null; localError = '';
93
+ decisions.clear(); answering.clear(); openRows.clear();
94
+ rebase(null); latestUserSeen = null; mergeBeforeMessage = null; deferredEdits = [];
95
+ rendered = [];
96
+ if (open) { connect(); render(); }
97
+ }
98
+
86
99
  function graphOpened(reason) {
87
100
  heading();
88
101
  if (!open && state.graph && logic.shouldShowTip(storage(), reason)) tip.hidden = false;
89
102
  }
90
103
 
91
- // ------------------------------------------------------------------ Panel
92
-
93
104
  function setOpen(next) {
94
105
  if (open === next) return;
95
106
  open = next;
@@ -105,7 +116,6 @@ globalThis.AndorraManager = (() => {
105
116
  } else {
106
117
  disconnect();
107
118
  }
108
- // The canvas changed width, so its controls and minimap take their places again.
109
119
  window.dispatchEvent(new Event('resize'));
110
120
  }
111
121
 
@@ -113,52 +123,41 @@ globalThis.AndorraManager = (() => {
113
123
  document.documentElement.style.setProperty('--manager-panel', `${Math.max(MIN_WIDTH, Math.min(MAX_WIDTH, Math.round(width)))}px`);
114
124
  }
115
125
 
116
- // ------------------------------------------------------------------ Model
117
-
118
126
  const modelsOf = provider => [...new Set([provider.model, ...(provider.models || [])].filter(Boolean))];
119
127
  const providerOf = id => state.providers.find(entry => entry.id === id);
120
128
 
121
- function option(value, label) { const item = node('option', label); item.value = value; return item; }
129
+ const entryOf = provider => ({ id: provider.id, label: titleFor(provider), type: provider.type, baseUrl: provider.baseUrl });
130
+ const picker = typeof modelPickerButton === 'function' ? modelPickerButton({
131
+ ariaLabel: 'Graph Manager model',
132
+ current: () => {
133
+ const provider = choice && providerOf(choice.provider);
134
+ return { model: choice?.model || 'No model available', provider: provider ? titleFor(provider) : '', entry: provider ? entryOf(provider) : undefined };
135
+ },
136
+ groups: () => state.providers.map(provider => ({ provider: entryOf(provider), models: modelsOf(provider).map(model => ({ model, note: '' })) })),
137
+ selected: () => choice,
138
+ pick: next => {
139
+ if (!providerOf(next.provider) || !next.model) return;
140
+ choice = { provider: next.provider, model: next.model };
141
+ logic.rememberModel(storage(), choice);
142
+ picker.redraw();
143
+ },
144
+ }) : null;
145
+ if (picker) { picker.id = 'manager-model-picker'; modelsSlot?.append(picker); }
122
146
 
123
- /** Fills both selects from the editor's provider registry, keeping the choice while it is still offered. */
124
147
  function fillModels() {
125
148
  const signature = JSON.stringify(state.providers);
126
149
  if (signature === providersSeen && choice) return;
127
150
  providersSeen = signature;
128
151
  const kept = choice && modelsOf(providerOf(choice.provider) || {}).includes(choice.model);
129
152
  if (!kept) choice = logic.initialModel(storage(), state.graph, state.providers);
130
- providerSelect.replaceChildren(...state.providers.map(provider => option(provider.id, titleFor(provider))));
131
- providerSelect.disabled = modelSelect.disabled = !choice;
132
- if (choice) providerSelect.value = choice.provider;
133
- fillModelOptions();
153
+ if (picker) { picker.disabled = !choice; picker.redraw(); globalThis.AndorraModelPicker?.refresh?.(picker); }
134
154
  renderNotices();
135
155
  }
136
- function fillModelOptions() {
137
- modelSelect.replaceChildren(...(choice ? modelsOf(providerOf(choice.provider) || {}) : []).map(model => option(model, model)));
138
- if (choice) modelSelect.value = choice.model;
139
- for (const select of [providerSelect, modelSelect]) globalThis.AndorraControls?.refreshSelect?.(select);
140
- }
141
- providerSelect.onchange = () => {
142
- const provider = providerOf(providerSelect.value);
143
- const model = provider && modelsOf(provider)[0];
144
- if (!model) return;
145
- choice = { provider: provider.id, model };
146
- logic.rememberModel(storage(), choice);
147
- fillModelOptions();
148
- };
149
- modelSelect.onchange = () => {
150
- if (!choice || !modelSelect.value) return;
151
- choice = { provider: choice.provider, model: modelSelect.value };
152
- logic.rememberModel(storage(), choice);
153
- };
154
-
155
- // ------------------------------------------------------------------ Stream
156
156
 
157
157
  function connect() {
158
- if (source || !open || !token || typeof EventSource !== 'function') return;
158
+ if (source || !open || !token || !streamGraphId || typeof EventSource !== 'function') return;
159
159
  clearTimeout(retryTimer);
160
- // EventSource cannot send an Authorization header, so the stream takes the session token in its query.
161
- const stream = source = new EventSource(`/api/manager/stream?token=${encodeURIComponent(token)}`);
160
+ const stream = source = new EventSource(`/api/manager/stream?token=${encodeURIComponent(token)}&graph=${encodeURIComponent(streamGraphId)}`);
162
161
  stream.onopen = () => { if (source !== stream) return; connected = true; retryMs = 1000; renderRunState(); };
163
162
  stream.onmessage = message => {
164
163
  if (source !== stream) return;
@@ -169,8 +168,6 @@ globalThis.AndorraManager = (() => {
169
168
  stream.onerror = () => {
170
169
  if (source !== stream) return;
171
170
  connected = false; renderRunState();
172
- // The browser retries a dropped stream on its own and the server opens each one with a
173
- // snapshot. A stream it has given up on (the server refused it) is reopened here, more slowly.
174
171
  if (stream.readyState !== 2) return;
175
172
  stream.close(); source = null;
176
173
  retryTimer = setTimeout(connect, retryMs);
@@ -189,85 +186,68 @@ globalThis.AndorraManager = (() => {
189
186
  if (event.type === 'snapshot') {
190
187
  runState = typeof event.state === 'string' ? event.state : 'idle';
191
188
  answering.clear();
192
- // What happened while this panel was not listening is unknown: another window may have sent
193
- // since, from another canvas. The baseline survives only as the canvas of this panel's own
194
- // message, when that message is the conversation's latest and started its run.
195
189
  const latest = transcript.filter(entry => entry.type === 'user').pop();
196
190
  const own = latest && posted.find(entry => entry.text === latest.text && entry.whileIdle);
197
191
  sentCanvas = own ? own.canvas : null;
192
+ if (!latest) rebase(null);
193
+ else if (latest.text !== latestUserSeen) rebase(own ? own.canvas : null);
194
+ latestUserSeen = latest ? latest.text : null;
198
195
  if (own) chatGraphId = own.graphId;
199
196
  posted = []; beforeLastMessage = null; unsureCanvas = false;
200
- if (!transcript.length) { chatGraphId = null; switchOffer = null; createdOffer = null; decisions.clear(); }
201
- // A conversation found already under way (a reload, another window) is taken to be about the open graph.
202
- else if (!chatGraphId) chatGraphId = state.graph?.id ?? null;
203
- // A graph deleted while this panel was not listening leaves the list all the same, and
204
- // nothing of it is offered: its latest revision is the deletion.
197
+ if (!transcript.length) { createdOffer = null; decisions.clear(); }
205
198
  const deleted = logic.deletedGraphs(transcript);
206
199
  if (state.graphs.some(entry => deleted.has(entry.id))) { state.graphs = state.graphs.filter(entry => !deleted.has(entry.id)); renderList(); }
207
200
  if (deleted.has(state.graph?.id)) offeredRevision = null;
208
201
  if (createdOffer && deleted.has(createdOffer.id)) createdOffer = null;
209
- // A save that happened while this panel was not listening is offered, never applied: nothing
210
- // here knows which canvas it was made from.
211
202
  const missed = transcript.filter(entry => entry.type === 'graph.saved' && entry.graphId === state.graph?.id).pop();
212
203
  if (missed && !deleted.has(missed.graphId) && missed.revision > (state.graph.revision || 0)) offeredRevision = missed.revision;
213
- // Likewise a graph created while nobody was listening: its latest save is the one offered.
214
204
  const created = transcript.map(entry => logic.createdGraph(state.graph?.id, entry)).filter(Boolean).pop();
215
205
  if (created && !deleted.has(created.id)) createdOffer = created;
216
206
  } else if (event.type === 'user') {
207
+ latestUserSeen = event.text;
217
208
  accepted(event.text);
218
209
  } else if (event.type === 'error') {
219
- refused();
210
+ if (!event.warning) refused();
220
211
  } else if (event.type === 'state') {
221
212
  runState = event.state;
222
- // The run is over: its message was read or no longer matters, and no save follows without a new one.
223
- if (runState === 'idle') { beforeLastMessage = null; unsureCanvas = false; }
213
+ if (runState === 'idle') { beforeLastMessage = null; unsureCanvas = false; mergeBeforeMessage = null; }
224
214
  } else if (event.type === 'resolved') {
225
215
  answering.delete(event.id);
226
216
  } else if (event.type === 'graph.saved') {
227
217
  void graphSaved(event);
228
218
  } else if (event.type === 'graph.deleted') {
229
219
  graphDeleted(event);
220
+ } else if (event.type === 'graph.edit') {
221
+ liveEdit(event);
222
+ return;
230
223
  }
231
224
  render();
232
225
  }
233
226
 
234
- /**
235
- * The chat echoed a message. Only now does its canvas count as sent: a request the server refused
236
- * is never echoed. The echo comes before delivery to the engine, so what it replaces is kept until
237
- * the message can no longer be refused.
238
- */
239
227
  function accepted(text) {
240
228
  const index = posted.findIndex(entry => entry.text === text);
241
229
  if (index < 0) {
242
- // Another window's message (or one of this panel's whose echo arrived after a reconnect): the
243
- // agent now works from a canvas this panel never saw, so nothing here is known to be what it
244
- // has. A save that follows is offered, never loaded over what is on this canvas.
245
230
  sentCanvas = null; beforeLastMessage = null;
231
+ rebase(null);
246
232
  return;
247
233
  }
248
234
  const [message] = posted.splice(index, 1);
249
235
  if (runState !== 'idle') {
250
- // Nothing on the stream says whether a working run read this message before its next save.
251
236
  if (message.canvas !== sentCanvas) unsureCanvas = true;
252
237
  chatGraphId = message.graphId;
253
238
  return;
254
239
  }
255
240
  beforeLastMessage = { sentCanvas, chatGraphId };
241
+ mergeBeforeMessage = mergeState();
242
+ rebase(message.canvas);
256
243
  sentCanvas = message.canvas; chatGraphId = message.graphId;
257
244
  }
258
- /** The chat reported an error: a message still open to refusal is taken as refused, which only ever makes a save an offer. */
259
245
  function refused() {
260
246
  if (beforeLastMessage) ({ sentCanvas, chatGraphId } = beforeLastMessage);
261
- beforeLastMessage = null; unsureCanvas = false;
247
+ if (mergeBeforeMessage) restoreMerge(mergeBeforeMessage);
248
+ beforeLastMessage = null; unsureCanvas = false; mergeBeforeMessage = null;
262
249
  }
263
250
 
264
- /**
265
- * The editor's fields put their text into the graph only when they are left, so while one is
266
- * focused the canvas can equal the one sent and still hold words the user is typing. A load redraws
267
- * the inspector over them. A focused text field anywhere outside this panel therefore counts as an
268
- * edit: the save is offered, and the half-typed text is neither lost nor committed for the user.
269
- * Selects and checkboxes commit at once and hold nothing back.
270
- */
271
251
  function typingInEditor() {
272
252
  const active = document.activeElement;
273
253
  if (!active || active === document.body || panel.contains(active)) return false;
@@ -275,15 +255,10 @@ globalThis.AndorraManager = (() => {
275
255
  return active.tagName === 'INPUT' && !['checkbox', 'radio', 'button', 'submit', 'reset', 'range', 'color', 'file', 'image'].includes(active.type);
276
256
  }
277
257
 
278
- /**
279
- * The agent saved a graph. Only the open one concerns the canvas: its new revision opens at once
280
- * when that discards nothing, and is otherwise offered, so no edit is ever replaced unasked.
281
- */
282
258
  async function graphSaved(event) {
283
259
  const graph = state.graph;
284
260
  const created = logic.createdGraph(graph?.id, event);
285
261
  if (created) {
286
- // The preset cannot be saved, so the agent's work is a new graph. It joins the list and is offered.
287
262
  const known = state.graphs.find(entry => entry.id === created.id);
288
263
  if (known) known.revision = event.revision; else state.graphs.push({ id: created.id, name: created.label, revision: event.revision });
289
264
  renderList();
@@ -298,25 +273,136 @@ globalThis.AndorraManager = (() => {
298
273
  const mayLoad = () => !unsureCanvas && !typingInEditor() && !logic.deletedGraphs(transcript).has(graph.id)
299
274
  && logic.applyDecision({ sentCanvas, currentCanvas: JSON.stringify(state.graph), untouched: state.untouched ?? null }) === 'load';
300
275
  if (mayLoad()) {
301
- // The revision takes a request to arrive, and the canvas is the user's all that while. It is
302
- // fetched first and applied only if the canvas is still the one the decision was made on;
303
- // nothing awaits between that check and the replacement.
304
276
  const canvas = JSON.stringify(state.graph);
305
277
  const fetched = await api(`/api/graphs/${encodeURIComponent(graph.id)}`).catch(() => undefined);
306
- // The user moved to another graph meanwhile: this save has nothing to replace or offer there.
307
278
  if (state.graph?.id !== graph.id) return;
308
- // A later save of the same run already put this revision, or a newer one, on the canvas.
309
279
  if ((state.graph.revision || 0) >= event.revision) return;
310
280
  if (fetched && JSON.stringify(state.graph) === canvas && mayLoad() && await loadRevision(graph.id, fetched)) return;
311
281
  }
312
282
  offeredRevision = event.revision;
313
283
  renderNotices();
314
284
  }
315
- /**
316
- * The agent deleted a graph, which publishes a revision marked as deleted. It leaves the list. When
317
- * it is the open graph that revision is never loaded or offered: the canvas stays as it is, still
318
- * the user's to copy or keep, and the status line says what happened.
319
- */
285
+ function sharedNode(id) {
286
+ if (agentNodes.has(id)) return JSON.parse(agentNodes.get(id));
287
+ try { return mergeCanvas ? JSON.parse(mergeCanvas).nodes?.[id] : undefined; } catch { return undefined; }
288
+ }
289
+ function sharedEdge(id) {
290
+ if (agentEdges.has(id)) return JSON.parse(agentEdges.get(id));
291
+ try { return mergeCanvas ? (JSON.parse(mergeCanvas).edges || []).find(edge => edge && edge.id === id) : undefined; } catch { return undefined; }
292
+ }
293
+ function sharedFields(keys) {
294
+ let sent = {};
295
+ try { sent = mergeCanvas ? JSON.parse(mergeCanvas) : {}; } catch { }
296
+ return Object.fromEntries(keys.map(key => [key, Object.hasOwn(agentFields, key) ? JSON.parse(agentFields[key]) : sent[key]]));
297
+ }
298
+
299
+ function liveEdit(event) {
300
+ if (!state.graph || event.graphId !== state.graph.id || !logic.soundEdit(event.edit)) return;
301
+ if (typingInEditor()) {
302
+ deferredEdits.push(event);
303
+ status('Graph Manager changed the draft; it shows when you leave this field.');
304
+ return;
305
+ }
306
+ applyLive(event);
307
+ }
308
+ function flushDeferred() {
309
+ if (!deferredEdits.length || typingInEditor()) return;
310
+ for (const event of deferredEdits.splice(0)) applyLive(event);
311
+ }
312
+ document.addEventListener('focusout', () => { setTimeout(flushDeferred, 0); });
313
+
314
+ function applyLive(event) {
315
+ const graph = state.graph;
316
+ if (!graph || event.graphId !== graph.id) return;
317
+ let edit = event.edit, kept = [];
318
+ if (edit.kind === 'node' && !graph.nodes?.[edit.node.id] && sharedNode(edit.node.id)) {
319
+ edit = null;
320
+ kept = ['node'];
321
+ } else if (edit.kind === 'edge' && !(graph.edges || []).some(item => item && item.id === edit.edge.id) && sharedEdge(edit.edge.id)) {
322
+ edit = null;
323
+ kept = ['edge'];
324
+ } else if (edit.kind === 'node' && graph.nodes?.[edit.node.id]) {
325
+ const base = sharedNode(edit.node.id);
326
+ if (!base) {
327
+ edit = null;
328
+ kept = ['node'];
329
+ } else {
330
+ const result = logic.mergeFields(base, graph.nodes[edit.node.id], edit.node);
331
+ kept = result.kept;
332
+ edit = { kind: 'node', node: { ...result.merged, id: edit.node.id } };
333
+ }
334
+ } else if (edit.kind === 'edge' && (graph.edges || []).some(item => item && item.id === edit.edge.id)) {
335
+ const base = sharedEdge(edit.edge.id);
336
+ if (!base) {
337
+ edit = null;
338
+ kept = ['edge'];
339
+ } else {
340
+ const result = logic.mergeFields(base, graph.edges.find(item => item && item.id === edit.edge.id), edit.edge);
341
+ kept = result.kept;
342
+ edit = { kind: 'edge', edge: { ...result.merged, id: edit.edge.id } };
343
+ }
344
+ } else if (edit.kind === 'node.remove' && graph.nodes?.[edit.nodeId]) {
345
+ const id = edit.nodeId;
346
+ const base = sharedNode(id);
347
+ const sameEdge = item => { const shared = sharedEdge(item.id); return !!shared && JSON.stringify(shared) === JSON.stringify(item); };
348
+ if (!base || JSON.stringify(base) !== JSON.stringify(graph.nodes[id])
349
+ || (graph.edges || []).some(item => item && (item.source === id || item.target === id) && !sameEdge(item))) {
350
+ edit = null;
351
+ kept = ['node'];
352
+ }
353
+ } else if (edit.kind === 'edge.remove' && (graph.edges || []).some(item => item && item.id === edit.edgeId)) {
354
+ const base = sharedEdge(edit.edgeId);
355
+ if (!base || JSON.stringify(base) !== JSON.stringify(graph.edges.find(item => item && item.id === edit.edgeId))) {
356
+ edit = null;
357
+ kept = ['edge'];
358
+ }
359
+ } else if (edit.kind === 'graph') {
360
+ const keys = Object.keys(edit.patch);
361
+ const current = Object.fromEntries(keys.map(key => [key, graph[key]]));
362
+ const result = logic.mergeFields(sharedFields(keys), current, edit.patch, keys);
363
+ kept = result.kept;
364
+ const patch = Object.fromEntries(keys.filter(key => result.merged[key] !== undefined).map(key => [key, result.merged[key]]));
365
+ edit = Object.keys(patch).length ? { kind: 'graph', patch } : null;
366
+ }
367
+ if (event.edit.kind === 'node') agentNodes.set(event.edit.node.id, JSON.stringify(event.edit.node));
368
+ if (event.edit.kind === 'node.remove') {
369
+ const id = event.edit.nodeId;
370
+ const current = new Map();
371
+ try { for (const item of (mergeCanvas ? JSON.parse(mergeCanvas).edges || [] : [])) if (item && typeof item.id === 'string') current.set(item.id, item); } catch { }
372
+ for (const [edgeId, json] of agentEdges) { const item = JSON.parse(json); if (item) current.set(edgeId, item); else current.delete(edgeId); }
373
+ for (const [edgeId, item] of current) if (item.source === id || item.target === id) agentEdges.set(edgeId, 'null');
374
+ agentNodes.set(id, 'null');
375
+ }
376
+ if (event.edit.kind === 'edge') agentEdges.set(event.edit.edge.id, JSON.stringify(event.edit.edge));
377
+ if (event.edit.kind === 'edge.remove') agentEdges.set(event.edit.edgeId, 'null');
378
+ if (event.edit.kind === 'graph') for (const [key, value] of Object.entries(event.edit.patch)) agentFields[key] = JSON.stringify(value);
379
+ if (!edit) {
380
+ if (kept.length) { sentCanvas = null; status('Graph Manager changed the draft; your own edits were kept. Approve its save, then load it to see its changes.'); }
381
+ return;
382
+ }
383
+ const trial = JSON.parse(JSON.stringify(graph));
384
+ if (!logic.applyEdit(trial, edit) || JSON.stringify(trial) === JSON.stringify(graph)) return;
385
+ const followed = JSON.stringify(graph) === sentCanvas && !kept.length;
386
+ try {
387
+ mutate(() => {
388
+ logic.applyEdit(state.graph, edit);
389
+ if (edit.kind === 'node.remove') {
390
+ state.selectedIds = state.selectedIds.filter(id => id !== edit.nodeId);
391
+ if (state.selected === edit.nodeId) state.selected = null;
392
+ }
393
+ if (edit.kind === 'edge.remove' && state.selectedEdge === edit.edgeId) state.selectedEdge = null;
394
+ }, true);
395
+ } catch {
396
+ if (state.undo.length) {
397
+ state.graph = state.undo.pop();
398
+ try { refreshDirty(); globalThis.render(); } catch { }
399
+ }
400
+ status('Graph Manager made a change the editor cannot show; it was left out.', true);
401
+ return;
402
+ }
403
+ if (followed) sentCanvas = JSON.stringify(state.graph);
404
+ status(kept.length ? 'Graph Manager changed the draft; your own edits were kept. Approve its save to keep its changes.' : 'Graph Manager changed the draft. Approve its save to keep it.');
405
+ }
320
406
  function graphDeleted(event) {
321
407
  if (state.graphs.some(entry => entry.id === event.graphId)) {
322
408
  state.graphs = state.graphs.filter(entry => entry.id !== event.graphId);
@@ -327,23 +413,18 @@ globalThis.AndorraManager = (() => {
327
413
  offeredRevision = null;
328
414
  status('Graph Manager deleted this graph.');
329
415
  }
330
- /** Opens the graph the agent created. Unsaved edits on the canvas are asked about first, as for any other graph. */
331
416
  async function openCreated(offer) {
332
- const before = chatGraphId;
333
- // The conversation is about the graph it created from here on, so opening it offers no new chat.
334
- if (transcript.length) chatGraphId = offer.id;
335
- if (!await openGraph(offer.id) || state.graph?.id !== offer.id) { chatGraphId = before; renderNotices(); return; }
336
- // The canvas is the agent's own save: a further save in the same run replaces it freely.
417
+ if (!await openGraph(offer.id) || state.graph?.id !== offer.id) { renderNotices(); return; }
337
418
  sentCanvas = JSON.stringify(state.graph);
419
+ rebase(sentCanvas);
338
420
  beforeLastMessage = null; unsureCanvas = false;
339
421
  createdOffer = null;
340
422
  renderNotices();
341
423
  }
342
- /** Replaces the canvas with the graph's latest revision: `fetched` when the caller already holds it, else requested now. */
343
424
  async function loadRevision(id, fetched) {
344
425
  if (!await openGraph(id, { discard: true, ...(fetched ? { fetched } : {}) }) || state.graph?.id !== id) return false;
345
- // The canvas is now the agent's own save: a further save in the same run replaces it as freely.
346
426
  sentCanvas = JSON.stringify(state.graph);
427
+ rebase(sentCanvas);
347
428
  beforeLastMessage = null; unsureCanvas = false;
348
429
  offeredRevision = null;
349
430
  status(`Graph Manager saved version ${state.graph.revision}`);
@@ -351,8 +432,6 @@ globalThis.AndorraManager = (() => {
351
432
  return true;
352
433
  }
353
434
 
354
- // ------------------------------------------------------------------ Requests
355
-
356
435
  async function post(path, body) {
357
436
  try { await api(path, body || {}); localError = ''; return true; }
358
437
  catch (error) { localError = error?.message || String(error); return false; }
@@ -364,13 +443,9 @@ globalThis.AndorraManager = (() => {
364
443
  if (!text || !state.graph) return;
365
444
  if (!choice) { localError = 'Add a model provider to use Graph Manager.'; renderNotices(); return; }
366
445
  const revision = Number.isInteger(state.graph.revision) ? state.graph.revision : 0;
367
- // The canvas is recorded with the message and becomes the comparison baseline only when the
368
- // stream echoes that message; a refused request puts the words back and leaves the baseline alone.
369
446
  const message = { text, canvas: JSON.stringify(state.graph), graphId: state.graph.id };
370
- // A message sent while idle starts its own run; a snapshot may stand in for its echo.
371
447
  message.whileIdle = runState === 'idle';
372
448
  posted.push(message);
373
- switchOffer = null;
374
449
  input.value = '';
375
450
  const sent = await post('/api/manager/message', { provider: choice.provider, model: choice.model, text, graph: JSON.parse(message.canvas), saved: revision > 0, revision });
376
451
  if (sent) return;
@@ -389,17 +464,12 @@ globalThis.AndorraManager = (() => {
389
464
  }
390
465
 
391
466
  async function newChat() {
392
- switchOffer = null;
393
- await post('/api/manager/reset');
467
+ await post('/api/manager/reset', { graphId: streamGraphId });
394
468
  }
395
469
 
396
- // ------------------------------------------------------------------ Drawing
397
-
398
- /** Rows the reader opened or closed, by key, so a redraw keeps each one as they left it. */
399
470
  const openRows = new Map();
400
471
  const span = (text, className) => node('span', text, className);
401
472
  const lastLine = text => String(text || '').trimEnd().split('\n').pop().trim();
402
- /** A live figure: the seconds since `startedAt`, kept current by the ticker below. */
403
473
  function since(startedAt) {
404
474
  const item = span(logic.seconds(Date.now() - startedAt), 'manager-row-duration');
405
475
  item.dataset.since = String(startedAt);
@@ -411,10 +481,6 @@ globalThis.AndorraManager = (() => {
411
481
  return label ? [item, span(label, 'sr-only')] : [item];
412
482
  }
413
483
 
414
- /**
415
- * One fold the way the app draws it: a flat line that opens to its body. A row with no body is the
416
- * line alone, with no control to press.
417
- */
418
484
  function fold(key, className, status, head, body, defaultOpen) {
419
485
  const wrap = node('div', undefined, `manager-fold ${className}`);
420
486
  if (status) wrap.dataset.status = status;
@@ -444,12 +510,10 @@ globalThis.AndorraManager = (() => {
444
510
  wrap.append(button, panelBody);
445
511
  return wrap;
446
512
  }
447
- /** An open live thought shows its newest words, as the app's does. */
448
513
  function followThought(scope) {
449
514
  for (const text of scope.querySelectorAll('.manager-fold[data-status="thinking"] .manager-activity-text')) text.scrollTop = text.scrollHeight;
450
515
  }
451
516
 
452
- /** One model call's reasoning: `Thinking` with its newest words while it streams, `Thought for 4s` once it settles. */
453
517
  function thoughtRow(entry) {
454
518
  const live = entry.status === 'thinking';
455
519
  const preview = live ? lastLine(entry.text) : '';
@@ -465,7 +529,6 @@ globalThis.AndorraManager = (() => {
465
529
  }
466
530
 
467
531
  const TOOL_GLYPHS = { running: ['◐', 'Running: '], failed: ['✕', 'Failed: '], stopped: ['○', 'Stopped: '] };
468
- /** One tool call: what it did and to what, its figure once it settles, and why it failed when it did. */
469
532
  function toolRow(entry) {
470
533
  const status = entry.status || 'done';
471
534
  const mark = TOOL_GLYPHS[status];
@@ -487,17 +550,48 @@ globalThis.AndorraManager = (() => {
487
550
  }
488
551
  const workRow = entry => entry.type === 'thought' ? thoughtRow(entry) : toolRow(entry);
489
552
 
490
- /**
491
- * A stretch of thinking and calls between messages. While it runs every row shows; once it
492
- * settles it condenses to the one line the app's turn shows (`Thought for 8s, made 4 edits`), with
493
- * its wall time at the edge, and opens back to the same rows.
494
- */
495
- function workBlock(block) {
496
- if (!block.settled) {
497
- const live = node('div', undefined, 'manager-work-live');
498
- live.append(...block.entries.map(workRow));
499
- return live;
553
+ function patchThought(old, entry) {
554
+ if (old.entry.type !== 'thought' || entry.type !== 'thought' || old.entry.status !== 'thinking' || entry.status !== 'thinking'
555
+ || old.entry.startedAt !== entry.startedAt || old.entry.truncated !== entry.truncated) return false;
556
+ const head = old.element.querySelector(':scope > .manager-fold-head');
557
+ const body = old.element.querySelector('.manager-activity-text');
558
+ if (!head || !body) return false;
559
+ const preview = lastLine(entry.text);
560
+ let tail = head.querySelector('.manager-preview-tail');
561
+ if (preview && !tail) {
562
+ tail = span(undefined, 'manager-activity-preview manager-preview-tail');
563
+ tail.append(span(preview));
564
+ head.insertBefore(tail, head.querySelector('[data-since]'));
565
+ } else if (tail) {
566
+ if (preview) tail.firstChild.textContent = preview; else tail.remove();
500
567
  }
568
+ const following = body.scrollHeight - body.scrollTop - body.clientHeight < 24;
569
+ body.textContent = entry.text || 'Still thinking; nothing has streamed yet.';
570
+ if (following) body.scrollTop = body.scrollHeight;
571
+ return true;
572
+ }
573
+
574
+ function liveBlock(block, before) {
575
+ const container = before?.element ?? node('div', undefined, 'manager-work-live');
576
+ const rows = new Map();
577
+ let previous = null;
578
+ for (const entry of block.entries) {
579
+ const old = before?.rows?.get(entry.id);
580
+ let element;
581
+ if (old && (old.entry === entry || patchThought(old, entry))) element = old.element;
582
+ else {
583
+ element = workRow(entry);
584
+ if (old) old.element.replaceWith(element);
585
+ }
586
+ if (element.parentNode !== container) { if (previous) previous.after(element); else container.prepend(element); }
587
+ rows.set(entry.id, { entry, element });
588
+ previous = element;
589
+ }
590
+ for (const [id, old] of before?.rows ?? []) if (!rows.has(id)) old.element.remove();
591
+ return { element: container, rows };
592
+ }
593
+
594
+ function workBlock(block) {
501
595
  const failed = block.entries.filter(entry => entry.type === 'tool' && entry.status === 'failed').length;
502
596
  const label = logic.workLabel(block.entries);
503
597
  const duration = logic.workDuration(block.entries);
@@ -507,7 +601,6 @@ globalThis.AndorraManager = (() => {
507
601
  return fold(block.key, 'manager-work', failed ? 'failed' : 'done', head, block.entries.map(workRow));
508
602
  }
509
603
 
510
- /** Engine and model text is set as text or built as Markdown nodes, never parsed as markup. */
511
604
  function row(entry) {
512
605
  if (entry.type === 'user') {
513
606
  const item = node('div', undefined, 'manager-row manager-user');
@@ -522,7 +615,6 @@ globalThis.AndorraManager = (() => {
522
615
  if (entry.type === 'thought' || entry.type === 'tool') return workRow(entry);
523
616
  if (entry.type === 'error') { const item = node('div', entry.message, 'manager-row manager-error'); item.setAttribute('role', 'alert'); return item; }
524
617
  if (entry.type === 'graph.saved') {
525
- // A save of another graph than the conversation's own names it.
526
618
  const other = entry.graphId !== chatGraphId && entry.graphId !== state.graph?.id;
527
619
  return node('div', other ? `Saved ${entry.name || entry.graphId}, version ${entry.revision}` : `Saved version ${entry.revision}`, 'manager-row manager-saved');
528
620
  }
@@ -541,7 +633,6 @@ globalThis.AndorraManager = (() => {
541
633
  item.append(node('strong', title), node('p', text));
542
634
  return item;
543
635
  }
544
- /** A settled card keeps its text and loses its controls. */
545
636
  function closed(item, entry, fallback) {
546
637
  item.classList.add('answered');
547
638
  item.append(node('span', decisions.get(entry.id) || fallback, 'manager-card-result'));
@@ -557,14 +648,14 @@ globalThis.AndorraManager = (() => {
557
648
  const item = card(entry, 'Graph Manager asks to', entry.text);
558
649
  if (entry.answered) return closed(item, entry, 'Answered');
559
650
  return actions(item, entry, [
560
- control('Approve', () => settle(entry, '/api/manager/approve', { id: entry.id, approved: true }, 'Approved'), 'btn-small primary'),
561
- control('Deny', () => settle(entry, '/api/manager/approve', { id: entry.id, approved: false }, 'Denied')),
651
+ control('Approve', () => settle(entry, '/api/manager/approve', { graphId: streamGraphId, id: entry.id, approved: true }, 'Approved'), 'btn-small primary'),
652
+ control('Deny', () => settle(entry, '/api/manager/approve', { graphId: streamGraphId, id: entry.id, approved: false }, 'Denied')),
562
653
  ]);
563
654
  }
564
655
  function questionCard(entry) {
565
656
  const item = card(entry, 'Graph Manager asks', entry.question);
566
657
  if (entry.answered) return closed(item, entry, 'Answered');
567
- const answer = value => settle(entry, '/api/manager/answer', { id: entry.id, value }, `Answered: ${value}`);
658
+ const answer = value => settle(entry, '/api/manager/answer', { graphId: streamGraphId, id: entry.id, value }, `Answered: ${value}`);
568
659
  if (Array.isArray(entry.choices) && entry.choices.length) {
569
660
  return actions(item, entry, entry.choices.map(value => control(String(value), () => answer(String(value)))));
570
661
  }
@@ -575,7 +666,6 @@ globalThis.AndorraManager = (() => {
575
666
  return actions(item, entry, [field, control('Answer', submit, 'btn-small primary')]);
576
667
  }
577
668
 
578
- /** Two blocks draw the same while every entry they show is the same object and nothing they depend on moved. */
579
669
  function sameBlock(before, block, pending) {
580
670
  if (!before || before.block.kind !== block.kind || before.pending !== pending) return false;
581
671
  if (block.kind === 'entry') return before.block.entry === block.entry;
@@ -583,12 +673,11 @@ globalThis.AndorraManager = (() => {
583
673
  && before.block.entries.length === block.entries.length && before.block.entries.every((entry, at) => entry === block.entries[at]);
584
674
  }
585
675
 
586
- /** Redraws only the blocks whose entries or pending state changed, so a half-typed answer survives the next event. */
587
676
  function renderTranscript() {
588
677
  const atEnd = log.scrollHeight - log.scrollTop - log.clientHeight < 40;
589
678
  const next = [];
590
679
  if (!transcript.length) {
591
- log.replaceChildren(node('p', 'Ask Graph Manager to build or change this graph. It sees the canvas as it is now, unsaved edits included, and asks before it saves anything.', 'help manager-empty'));
680
+ log.replaceChildren(node('p', 'Ask Graph Manager to build or change this graph. It sees the canvas as it is now, unsaved edits included. Its changes appear on the canvas as it makes them, and nothing is saved until you approve.', 'help manager-empty'));
592
681
  rendered = [];
593
682
  return;
594
683
  }
@@ -596,18 +685,24 @@ globalThis.AndorraManager = (() => {
596
685
  logic.blocks(transcript, runState !== 'idle').forEach((block, index) => {
597
686
  const before = rendered[index], pending = block.kind === 'entry' && answering.has(block.entry.id);
598
687
  if (sameBlock(before, block, pending)) { next.push(before); return; }
599
- const element = block.kind === 'work' ? workBlock(block) : row(block.entry);
688
+ const live = block.kind === 'work' && !block.settled;
689
+ if (live && before?.block.kind === 'work' && !before.block.settled && before.block.key === block.key && before.rows) {
690
+ const { rows } = liveBlock(block, before);
691
+ next.push({ block, pending, element: before.element, rows });
692
+ return;
693
+ }
694
+ const drawn = live ? liveBlock(block) : { element: block.kind === 'work' ? workBlock(block) : row(block.entry) };
695
+ const element = drawn.element;
600
696
  if (before?.element && element) before.element.replaceWith(element);
601
697
  else { before?.element?.remove(); if (element) log.append(element); }
602
698
  if (element) followThought(element);
603
- next.push({ block, pending, element });
699
+ next.push({ block, pending, element, ...(drawn.rows ? { rows: drawn.rows } : {}) });
604
700
  });
605
701
  for (const stale of rendered.slice(next.length)) stale.element?.remove();
606
702
  rendered = next;
607
703
  if (atEnd) log.scrollTop = log.scrollHeight;
608
704
  }
609
705
 
610
- /** Live figures count up between events; the ticker runs only while one is on screen. */
611
706
  let ticker = null;
612
707
  function tick() {
613
708
  const live = log.querySelectorAll('[data-since]');
@@ -629,12 +724,6 @@ globalThis.AndorraManager = (() => {
629
724
  function renderNotices() {
630
725
  const bars = [];
631
726
  if (!state.providers.length) bars.push(notice('manager-warning', 'Add a model provider to use Graph Manager.', []));
632
- if (switchOffer && state.graph?.id === switchOffer) {
633
- bars.push(notice('manager-switch', `Start a new chat about ${state.graph.name || 'this graph'}?`, [
634
- control('New chat', () => { void newChat(); }, 'btn-small primary'),
635
- control('Keep this chat', () => { switchOffer = null; renderNotices(); }),
636
- ]));
637
- }
638
727
  if (offeredRevision !== null && state.graph) {
639
728
  const id = state.graph.id;
640
729
  bars.push(notice('manager-load', `Graph Manager saved version ${offeredRevision}. Load it?`, [
@@ -662,14 +751,12 @@ globalThis.AndorraManager = (() => {
662
751
  }
663
752
  function render() { renderTranscript(); renderNotices(); renderRunState(); startTicker(); }
664
753
 
665
- // ------------------------------------------------------------------ Wiring
666
-
667
754
  button.onclick = () => setOpen(!open);
668
755
  byId('manager-tip-close').onclick = dismissTip;
669
756
  byId('manager-close').onclick = () => { setOpen(false); button.focus(); };
670
757
  byId('manager-new-chat').onclick = () => { void newChat(); };
671
758
  sendButton.onclick = () => { void send(); };
672
- stopButton.onclick = () => { void post('/api/manager/cancel'); };
759
+ stopButton.onclick = () => { void post('/api/manager/cancel', { graphId: streamGraphId }); };
673
760
  input.onkeydown = event => {
674
761
  if (event.key !== 'Enter' || event.shiftKey || event.isComposing) return;
675
762
  event.preventDefault();
@@ -689,11 +776,9 @@ globalThis.AndorraManager = (() => {
689
776
  setWidth(panel.getBoundingClientRect().width + (event.key === 'ArrowLeft' ? 20 : -20));
690
777
  };
691
778
  }
692
- // A page kept for Back/Forward comes back without its stream.
693
779
  window.addEventListener('pagehide', disconnect);
694
780
  window.addEventListener('pageshow', () => { if (open) connect(); });
695
781
 
696
- // The graph can be open before this script runs; app.js keeps how it arrived.
697
782
  if (state.graph) graphOpened(state.openReason || 'open'); else heading();
698
783
 
699
784
  return { graphOpened, heading };