synabun 2.4.0 → 2.4.2

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 (319) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +1 -1
  3. package/browser-extension/content.js +73 -11
  4. package/browser-extension/engine.js +196 -15
  5. package/browser-extension/manifest.json +4 -2
  6. package/browser-extension/popup-strings.js +10 -4
  7. package/browser-extension/popup-view.js +1 -1
  8. package/browser-extension/popup.css +1 -0
  9. package/browser-extension/popup.html +4 -1
  10. package/browser-extension/popup.js +22 -10
  11. package/browser-extension/protocol.js +102 -11
  12. package/browser-extension/service-worker.js +20 -4
  13. package/browser-extension/tokens.css +1 -1
  14. package/docs/browser-extension-bridge.md +25 -5
  15. package/lib/data-home-files.js +47 -0
  16. package/lib/data-home-migration.js +34 -58
  17. package/lib/first-launch-protection.js +8 -2
  18. package/lib/update-snapshot.js +11 -4
  19. package/mcp-server/dist/http.d.ts.map +1 -1
  20. package/mcp-server/dist/http.js +25 -2
  21. package/mcp-server/dist/http.js.map +1 -1
  22. package/mcp-server/dist/index.d.ts.map +1 -1
  23. package/mcp-server/dist/index.js +62 -17
  24. package/mcp-server/dist/index.js.map +1 -1
  25. package/mcp-server/dist/services/browser-bench.d.ts +22 -22
  26. package/mcp-server/dist/services/memory-maintenance.d.ts +1 -0
  27. package/mcp-server/dist/services/memory-maintenance.d.ts.map +1 -1
  28. package/mcp-server/dist/services/memory-maintenance.js +34 -45
  29. package/mcp-server/dist/services/memory-maintenance.js.map +1 -1
  30. package/mcp-server/dist/services/memory-migration-copy.d.ts +144 -0
  31. package/mcp-server/dist/services/memory-migration-copy.d.ts.map +1 -0
  32. package/mcp-server/dist/services/memory-migration-copy.js +467 -0
  33. package/mcp-server/dist/services/memory-migration-copy.js.map +1 -0
  34. package/mcp-server/dist/services/memory-migration-worker.d.ts +2 -0
  35. package/mcp-server/dist/services/memory-migration-worker.d.ts.map +1 -0
  36. package/mcp-server/dist/services/memory-migration-worker.js +60 -0
  37. package/mcp-server/dist/services/memory-migration-worker.js.map +1 -0
  38. package/mcp-server/dist/services/memory-retrieval.d.ts +4 -0
  39. package/mcp-server/dist/services/memory-retrieval.d.ts.map +1 -1
  40. package/mcp-server/dist/services/memory-retrieval.js +188 -40
  41. package/mcp-server/dist/services/memory-retrieval.js.map +1 -1
  42. package/mcp-server/dist/services/memory-schema.d.ts +58 -2
  43. package/mcp-server/dist/services/memory-schema.d.ts.map +1 -1
  44. package/mcp-server/dist/services/memory-schema.js +190 -13
  45. package/mcp-server/dist/services/memory-schema.js.map +1 -1
  46. package/mcp-server/dist/services/memory-sessions.d.ts +19 -1
  47. package/mcp-server/dist/services/memory-sessions.d.ts.map +1 -1
  48. package/mcp-server/dist/services/memory-sessions.js +56 -20
  49. package/mcp-server/dist/services/memory-sessions.js.map +1 -1
  50. package/mcp-server/dist/services/memory-verification.d.ts.map +1 -1
  51. package/mcp-server/dist/services/memory-verification.js +8 -5
  52. package/mcp-server/dist/services/memory-verification.js.map +1 -1
  53. package/mcp-server/dist/services/neural-interface.d.ts +6 -0
  54. package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
  55. package/mcp-server/dist/services/neural-interface.js +19 -2
  56. package/mcp-server/dist/services/neural-interface.js.map +1 -1
  57. package/mcp-server/dist/services/retrieval-reader-worker.d.ts +2 -0
  58. package/mcp-server/dist/services/retrieval-reader-worker.d.ts.map +1 -0
  59. package/mcp-server/dist/services/retrieval-reader-worker.js +76 -0
  60. package/mcp-server/dist/services/retrieval-reader-worker.js.map +1 -0
  61. package/mcp-server/dist/services/retrieval-reader.d.ts +38 -0
  62. package/mcp-server/dist/services/retrieval-reader.d.ts.map +1 -0
  63. package/mcp-server/dist/services/retrieval-reader.js +145 -0
  64. package/mcp-server/dist/services/retrieval-reader.js.map +1 -0
  65. package/mcp-server/dist/services/sqlite-write.d.ts +14 -0
  66. package/mcp-server/dist/services/sqlite-write.d.ts.map +1 -0
  67. package/mcp-server/dist/services/sqlite-write.js +94 -0
  68. package/mcp-server/dist/services/sqlite-write.js.map +1 -0
  69. package/mcp-server/dist/services/sqlite.d.ts +39 -0
  70. package/mcp-server/dist/services/sqlite.d.ts.map +1 -1
  71. package/mcp-server/dist/services/sqlite.js +249 -8
  72. package/mcp-server/dist/services/sqlite.js.map +1 -1
  73. package/mcp-server/dist/services/tool-catalog.d.ts +1 -1
  74. package/mcp-server/dist/services/typesafe-config.d.ts +7 -1
  75. package/mcp-server/dist/services/typesafe-config.d.ts.map +1 -1
  76. package/mcp-server/dist/services/typesafe-config.js +32 -10
  77. package/mcp-server/dist/services/typesafe-config.js.map +1 -1
  78. package/mcp-server/dist/services/typesafe.d.ts.map +1 -1
  79. package/mcp-server/dist/services/typesafe.js +9 -7
  80. package/mcp-server/dist/services/typesafe.js.map +1 -1
  81. package/mcp-server/dist/services/vector-cache.d.ts +32 -0
  82. package/mcp-server/dist/services/vector-cache.d.ts.map +1 -1
  83. package/mcp-server/dist/services/vector-cache.js +161 -8
  84. package/mcp-server/dist/services/vector-cache.js.map +1 -1
  85. package/mcp-server/dist/tools/agent-definition.d.ts +2 -2
  86. package/mcp-server/dist/tools/agents.d.ts +13 -8
  87. package/mcp-server/dist/tools/agents.d.ts.map +1 -1
  88. package/mcp-server/dist/tools/agents.js +35 -15
  89. package/mcp-server/dist/tools/agents.js.map +1 -1
  90. package/mcp-server/dist/tools/browser-advanced.d.ts +1 -1
  91. package/mcp-server/dist/tools/browser-advanced.d.ts.map +1 -1
  92. package/mcp-server/dist/tools/browser-advanced.js +10 -3
  93. package/mcp-server/dist/tools/browser-advanced.js.map +1 -1
  94. package/mcp-server/dist/tools/browser-extension-setup.d.ts +5 -0
  95. package/mcp-server/dist/tools/browser-extension-setup.d.ts.map +1 -0
  96. package/mcp-server/dist/tools/browser-extension-setup.js +23 -0
  97. package/mcp-server/dist/tools/browser-extension-setup.js.map +1 -0
  98. package/mcp-server/dist/tools/browser-interact.d.ts.map +1 -1
  99. package/mcp-server/dist/tools/browser-interact.js +6 -1
  100. package/mcp-server/dist/tools/browser-interact.js.map +1 -1
  101. package/mcp-server/dist/tools/fb-groups.d.ts +2 -2
  102. package/mcp-server/dist/tools/skill-tools.d.ts +4 -4
  103. package/mcp-server/dist/tools/tool-groups.d.ts +1 -1
  104. package/mcp-server/package-lock.json +2 -2
  105. package/mcp-server/package.json +1 -1
  106. package/mcp-server/src/http.ts +20 -2
  107. package/mcp-server/src/index.ts +59 -17
  108. package/mcp-server/src/services/memory-maintenance.ts +31 -28
  109. package/mcp-server/src/services/memory-migration-copy.ts +419 -0
  110. package/mcp-server/src/services/memory-migration-worker.ts +55 -0
  111. package/mcp-server/src/services/memory-retrieval.ts +173 -32
  112. package/mcp-server/src/services/memory-schema.ts +194 -12
  113. package/mcp-server/src/services/memory-sessions.ts +54 -21
  114. package/mcp-server/src/services/memory-verification.ts +7 -4
  115. package/mcp-server/src/services/neural-interface.ts +23 -2
  116. package/mcp-server/src/services/retrieval-reader-worker.ts +67 -0
  117. package/mcp-server/src/services/retrieval-reader.ts +131 -0
  118. package/mcp-server/src/services/sqlite-write.ts +60 -0
  119. package/mcp-server/src/services/sqlite.ts +246 -8
  120. package/mcp-server/src/services/typesafe-config.ts +25 -6
  121. package/mcp-server/src/services/typesafe.ts +9 -7
  122. package/mcp-server/src/services/vector-cache.ts +154 -9
  123. package/mcp-server/src/tools/agents.ts +33 -14
  124. package/mcp-server/src/tools/browser-advanced.ts +10 -3
  125. package/mcp-server/src/tools/browser-extension-setup.ts +30 -0
  126. package/mcp-server/src/tools/browser-interact.ts +5 -1
  127. package/neural-interface/i18n/en.json +266 -2
  128. package/neural-interface/i18n/pt-BR.json +267 -3
  129. package/neural-interface/lib/agents/builtins.json +207 -0
  130. package/neural-interface/lib/agents/registry.js +60 -15
  131. package/neural-interface/lib/agents/resolve.js +69 -10
  132. package/neural-interface/lib/agents/split.js +32 -4
  133. package/neural-interface/lib/assistant-api.js +19 -8
  134. package/neural-interface/lib/assistant-brains/claude.js +2 -0
  135. package/neural-interface/lib/assistant-brains/opencode.js +60 -11
  136. package/neural-interface/lib/assistant-catalog.js +2 -2
  137. package/neural-interface/lib/assistant-config.js +0 -7
  138. package/neural-interface/lib/assistant-dispatch.js +384 -119
  139. package/neural-interface/lib/assistant-persona.js +17 -5
  140. package/neural-interface/lib/assistant-pricing.js +65 -14
  141. package/neural-interface/lib/assistant-router.js +181 -54
  142. package/neural-interface/lib/assistant-run-wait.js +45 -28
  143. package/neural-interface/lib/assistant-runtime.js +48 -34
  144. package/neural-interface/lib/backup-contents.js +158 -0
  145. package/neural-interface/lib/backup-crypto-io.js +330 -0
  146. package/neural-interface/lib/backup-crypto-worker.js +130 -0
  147. package/neural-interface/lib/backup-crypto.js +525 -0
  148. package/neural-interface/lib/backup-download.js +268 -0
  149. package/neural-interface/lib/backup-encryption.js +318 -0
  150. package/neural-interface/lib/backup-groups.js +287 -0
  151. package/neural-interface/lib/backup-restore-session.js +176 -0
  152. package/neural-interface/lib/backup-restore-stage.js +60 -0
  153. package/neural-interface/lib/backup-service.js +836 -322
  154. package/neural-interface/lib/backup-zip-reader.js +30 -18
  155. package/neural-interface/lib/backup-zip-writer.js +34 -10
  156. package/neural-interface/lib/browser-extension-adapter.js +109 -24
  157. package/neural-interface/lib/browser-extension-bridge.js +42 -8
  158. package/neural-interface/lib/claude-agent-bridge.js +1 -0
  159. package/neural-interface/lib/claude-session-cleanup.js +5 -1
  160. package/neural-interface/lib/cli-update-planner.js +105 -6
  161. package/neural-interface/lib/client-diagnostics.js +42 -0
  162. package/neural-interface/lib/confined-fs.js +7 -2
  163. package/neural-interface/lib/coordination/README.md +8 -2
  164. package/neural-interface/lib/coordination/contract.js +161 -0
  165. package/neural-interface/lib/coordination/database.js +999 -0
  166. package/neural-interface/lib/coordination/operations.js +436 -0
  167. package/neural-interface/lib/coordination/service.js +68 -537
  168. package/neural-interface/lib/coordination/storage-worker.js +101 -0
  169. package/neural-interface/lib/coordination/store.js +219 -1111
  170. package/neural-interface/lib/db.js +70 -32
  171. package/neural-interface/lib/health-count.js +37 -0
  172. package/neural-interface/lib/loop-stall.js +139 -0
  173. package/neural-interface/lib/maritaca/client.js +2 -2
  174. package/neural-interface/lib/maritaca/models.js +12 -17
  175. package/neural-interface/lib/maritaca/opencode.js +4 -2
  176. package/neural-interface/lib/memory-api.js +9 -1
  177. package/neural-interface/lib/memory-session-capture.js +42 -10
  178. package/neural-interface/lib/memory-store-gate.js +313 -0
  179. package/neural-interface/lib/memory-store-migrate.js +65 -0
  180. package/neural-interface/lib/memory-timers.js +7 -7
  181. package/neural-interface/lib/native-loop-providers.js +13 -16
  182. package/neural-interface/lib/native-loop-runtime.js +34 -14
  183. package/neural-interface/lib/opencode-build-preflight.js +30 -8
  184. package/neural-interface/lib/opencode-native-boundary.js +69 -8
  185. package/neural-interface/lib/opencode-provider-view.js +14 -3
  186. package/neural-interface/lib/opencode-v2-ws-requests.js +31 -1
  187. package/neural-interface/lib/opencode2-client.js +2 -1
  188. package/neural-interface/lib/peer-identity.js +13 -8
  189. package/neural-interface/lib/recall-impact.js +122 -0
  190. package/neural-interface/lib/scratch-evidence.js +420 -0
  191. package/neural-interface/lib/scratch-process-guard.js +139 -0
  192. package/neural-interface/lib/scratch-references.js +279 -0
  193. package/neural-interface/lib/scratch-retention-core.js +385 -0
  194. package/neural-interface/lib/scratch-retention-worker.js +37 -0
  195. package/neural-interface/lib/scratch-retention.js +151 -0
  196. package/neural-interface/lib/session-cache-builder.js +70 -44
  197. package/neural-interface/lib/session-cache-worker.js +157 -0
  198. package/neural-interface/lib/session-indexer.js +28 -21
  199. package/neural-interface/lib/session-search-index.js +85 -0
  200. package/neural-interface/lib/skills/creation.js +1 -1
  201. package/neural-interface/lib/sqlite-integrity-worker.js +3 -1
  202. package/neural-interface/lib/style-guide/store.js +43 -3
  203. package/neural-interface/lib/system-restore.js +50 -0
  204. package/neural-interface/lib/teams/api.js +15 -6
  205. package/neural-interface/lib/teams/claims.js +67 -31
  206. package/neural-interface/lib/teams/index.js +7 -7
  207. package/neural-interface/lib/teams/integration.js +40 -40
  208. package/neural-interface/lib/teams/landing.js +6 -6
  209. package/neural-interface/lib/teams/recovery.js +24 -23
  210. package/neural-interface/lib/teams/scheduler.js +196 -97
  211. package/neural-interface/lib/teams/schema.js +1 -1
  212. package/neural-interface/lib/teams/state.js +14 -14
  213. package/neural-interface/lib/teams/worktrees.js +27 -27
  214. package/neural-interface/lib/whatsapp/bridge.js +2 -1
  215. package/neural-interface/lib/worker-confinement.js +47 -2
  216. package/neural-interface/lib/worker-mcp-channel.js +2 -0
  217. package/neural-interface/lib/worker-resume.js +5 -0
  218. package/neural-interface/lib/worker-stop.js +86 -0
  219. package/neural-interface/package-lock.json +2 -2
  220. package/neural-interface/package.json +1 -1
  221. package/neural-interface/public/index.html +260 -0
  222. package/neural-interface/public/offline.html +4 -3
  223. package/neural-interface/public/onboarding.html +259 -34
  224. package/neural-interface/public/shared/agents/studio/ax-agent-view.js +2 -2
  225. package/neural-interface/public/shared/agents/studio/ax-editor-view.js +1 -1
  226. package/neural-interface/public/shared/agents/studio/ax-library.js +0 -6
  227. package/neural-interface/public/shared/agents/studio/ax-main.js +14 -7
  228. package/neural-interface/public/shared/agents/studio/ax-ui.js +2 -2
  229. package/neural-interface/public/shared/agy/agy-options.js +11 -0
  230. package/neural-interface/public/shared/agy/agy-panel.js +29 -10
  231. package/neural-interface/public/shared/agy/agy-styles.js +14 -12
  232. package/neural-interface/public/shared/agy/agy-tabs-logic.js +4 -1
  233. package/neural-interface/public/shared/api.js +3 -2
  234. package/neural-interface/public/shared/assistant/asst-api.js +3 -3
  235. package/neural-interface/public/shared/assistant/asst-brain-picker.js +13 -6
  236. package/neural-interface/public/shared/assistant/asst-control.js +2 -0
  237. package/neural-interface/public/shared/assistant/asst-motion-gate.js +78 -4
  238. package/neural-interface/public/shared/assistant/asst-panel.js +18 -2
  239. package/neural-interface/public/shared/assistant/asst-rack-styles.js +4 -0
  240. package/neural-interface/public/shared/assistant/asst-render.js +106 -38
  241. package/neural-interface/public/shared/assistant/asst-route.js +102 -21
  242. package/neural-interface/public/shared/assistant/asst-routes-editor.js +1 -1
  243. package/neural-interface/public/shared/assistant/asst-sidepanel.js +4 -2
  244. package/neural-interface/public/shared/assistant/asst-state.js +11 -0
  245. package/neural-interface/public/shared/assistant/asst-styles.js +10 -23
  246. package/neural-interface/public/shared/assistant/route-identity.js +2 -1
  247. package/neural-interface/public/shared/cc-dropdown.js +21 -15
  248. package/neural-interface/public/shared/cdx/cdx-render.js +9 -0
  249. package/neural-interface/public/shared/cdx/cdx-settings.js +3 -1
  250. package/neural-interface/public/shared/cdx/cdx-styles.js +6 -0
  251. package/neural-interface/public/shared/cdx/cdx-tabs.js +29 -9
  252. package/neural-interface/public/shared/client-diagnostics.js +94 -0
  253. package/neural-interface/public/shared/cp/cp-markdown.js +7 -2
  254. package/neural-interface/public/shared/cp/cp-styles.js +1 -1
  255. package/neural-interface/public/shared/effort-i18n.js +118 -0
  256. package/neural-interface/public/shared/html-shell.js +4 -51
  257. package/neural-interface/public/shared/loading-diagnostic-entry.js +64 -0
  258. package/neural-interface/public/shared/memory-store-wait.js +52 -0
  259. package/neural-interface/public/shared/morelogin-profile-field.js +1 -1
  260. package/neural-interface/public/shared/mtc/mtc-logic.js +2 -1
  261. package/neural-interface/public/shared/mtc/mtc-panel.js +8 -1
  262. package/neural-interface/public/shared/mtc/mtc-styles.js +13 -12
  263. package/neural-interface/public/shared/ocp-v2/ocp-v2-childpanel.js +7 -0
  264. package/neural-interface/public/shared/ocp-v2/ocp-v2-location-logic.js +109 -0
  265. package/neural-interface/public/shared/ocp-v2/ocp-v2-modelpicker.js +8 -1
  266. package/neural-interface/public/shared/ocp-v2/ocp-v2-panel.js +118 -6
  267. package/neural-interface/public/shared/ocp-v2/ocp-v2-render.js +27 -3
  268. package/neural-interface/public/shared/ocp-v2/ocp-v2-send.js +13 -0
  269. package/neural-interface/public/shared/ocp-v2/ocp-v2-session-actions.js +2 -1
  270. package/neural-interface/public/shared/ocp-v2/ocp-v2-styles.js +27 -93
  271. package/neural-interface/public/shared/ocp-v2/ocp-v2-variantpicker.js +17 -6
  272. package/neural-interface/public/shared/output-format.js +294 -0
  273. package/neural-interface/public/shared/owner-authority-view.js +4 -10
  274. package/neural-interface/public/shared/page-session.js +1 -1
  275. package/neural-interface/public/shared/provider-icons.js +6 -0
  276. package/neural-interface/public/shared/schedules-view.js +2 -1
  277. package/neural-interface/public/shared/server-presence.js +77 -0
  278. package/neural-interface/public/shared/settings/settings-ai-browser.js +5 -5
  279. package/neural-interface/public/shared/settings/settings-backup-contents.js +241 -0
  280. package/neural-interface/public/shared/settings/settings-backup-download.js +298 -0
  281. package/neural-interface/public/shared/settings/settings-backup-encryption-pane.js +335 -0
  282. package/neural-interface/public/shared/settings/settings-backup-encryption.js +545 -0
  283. package/neural-interface/public/shared/settings/settings-ia.js +1 -1
  284. package/neural-interface/public/shared/skills/studio/sx-geometry.js +12 -3
  285. package/neural-interface/public/shared/skills/studio/sx-main.js +14 -7
  286. package/neural-interface/public/shared/start-bridge.js +2 -2
  287. package/neural-interface/public/shared/studio-attention.js +6 -0
  288. package/neural-interface/public/shared/styles.css +354 -438
  289. package/neural-interface/public/shared/transcript-rows.js +28 -3
  290. package/neural-interface/public/shared/tray-auto-close.js +18 -5
  291. package/neural-interface/public/shared/ui-agents.js +1 -2
  292. package/neural-interface/public/shared/ui-automation-studio.js +168 -108
  293. package/neural-interface/public/shared/ui-claude-panel.js +42 -65
  294. package/neural-interface/public/shared/ui-loading.js +185 -25
  295. package/neural-interface/public/shared/ui-native-loop-router.js +59 -20
  296. package/neural-interface/public/shared/ui-navbar.js +2 -1
  297. package/neural-interface/public/shared/ui-output.js +533 -0
  298. package/neural-interface/public/shared/ui-owner-authority.js +48 -25
  299. package/neural-interface/public/shared/ui-schedules-studio.js +165 -128
  300. package/neural-interface/public/shared/ui-scroll-follow.js +97 -6
  301. package/neural-interface/public/shared/ui-sessions.js +2 -2
  302. package/neural-interface/public/shared/ui-settings-entry.js +18 -0
  303. package/neural-interface/public/shared/ui-settings.js +234 -67
  304. package/neural-interface/public/shared/ui-sidepanel-tray.js +3 -2
  305. package/neural-interface/public/shared/ui-sync.js +1 -0
  306. package/neural-interface/public/shared/ui-tooltip.js +16 -0
  307. package/neural-interface/public/shared/ui-tutorial.js +5 -6
  308. package/neural-interface/public/shared/ui-worker-end.js +27 -8
  309. package/neural-interface/public/shared/worker-end.js +9 -4
  310. package/neural-interface/public/sw.js +4 -3
  311. package/neural-interface/public/variant/2d/main.js +5 -0
  312. package/neural-interface/public/variant/3d/app.js +10 -0
  313. package/neural-interface/public/variant/3d/main.js +17 -4
  314. package/neural-interface/scripts/scratch-retention.mjs +20 -0
  315. package/neural-interface/server.js +507 -160
  316. package/npm-shrinkwrap.json +2 -2
  317. package/package.json +2 -1
  318. package/scripts/restore-data-home-from-backup.mjs +175 -8
  319. package/setup.js +18 -4
@@ -0,0 +1,294 @@
1
+ // ═══════════════════════════════════════════
2
+ // SynaBun Neural Interface — an agent's answer as a readable document: the decisions
3
+ // ═══════════════════════════════════════════
4
+ //
5
+ // The six side panels (Assistant, Claude Code, Codex, OpenCode, Antigravity, Maritaca) show an agent's Markdown
6
+ // through the same sanitiser and, since this module, as the same document: one type scale, one spacing rhythm,
7
+ // one table, one code block. This is the part that needs no page: the words, the markup added to a panel's
8
+ // SANITISED Markdown (so a stream, a re-render, a morph and a stored transcript all keep it, exactly like the
9
+ // Copy button of code-copy.js), and what a table copies. ui-output.js gives it the page: the stylesheet, the
10
+ // one click listener per document, the wider view of a table.
11
+ //
12
+ // What it adds, and nothing else:
13
+ // · a frame around every table (it wraps at words to fit the panel, and scrolls sideways inside the frame only
14
+ // when its columns cannot fit), with Copy and, for a table worth it, Expand; a numeric column is
15
+ // right-aligned and a column of sentences keeps a readable width;
16
+ // · a class on a task-list item (the sanitiser turns its checkbox into ☑ / ☐: no bullet beside the box);
17
+ // · the language of a fenced block on its <pre> (drawn as a label) and the lines of a diff as add / remove.
18
+ //
19
+ // Run it on the sanitiser's output, never before: the allowlist takes a model's own div, button and class out,
20
+ // so a reply cannot forge a frame or a button. It never adds a link, a handler or a style.
21
+ //
22
+ // No imports and no `document`: loaded by `node --test` as it is, and by the Markdown renderers.
23
+
24
+ /** The English of `output.*` in i18n/en.json (tests/output-format.test.mjs keeps them equal). */
25
+ export const OUTPUT_COPY = Object.freeze({
26
+ copy: 'Copy',
27
+ copied: 'Copied',
28
+ failed: 'Not copied',
29
+ copyTable: 'Copy table',
30
+ tableCopied: 'Table copied',
31
+ tableFailed: 'Could not copy the table.',
32
+ expand: 'Expand',
33
+ expandTable: 'Open the table in a wider view',
34
+ tableTitle: 'Table',
35
+ tableSize: '{rows} rows · {columns} columns',
36
+ close: 'Close',
37
+ });
38
+
39
+ export const TABLE_FRAME_CLASS = 'sb-table';
40
+ export const TABLE_SCROLL_CLASS = 'sb-table-scroll';
41
+ export const TABLE_TOOLS_CLASS = 'sb-table-tools';
42
+ export const TABLE_BUTTON_CLASS = 'sb-table-btn';
43
+ export const NUMERIC_CLASS = 'sb-num';
44
+ export const LONG_CLASS = 'sb-long';
45
+ /** A column with a cell of at least this many characters in at least LONG_CELL_WORDS words holds sentences. */
46
+ export const LONG_CELL_CHARS = 28;
47
+ export const LONG_CELL_WORDS = 4;
48
+ export const TASK_CLASS = 'sb-task';
49
+
50
+ /** How long "Copied" (and the failure) stays on a table's button: the code block's timing. */
51
+ export const OUTPUT_FEEDBACK_MS = Object.freeze({ copied: 1500, failed: 4000 });
52
+
53
+ let translate = null;
54
+
55
+ /** Where a sentence comes from in the active locale: `fn(key, params)`, or a falsy value for the English. */
56
+ export function setOutputTranslator(fn) { translate = typeof fn === 'function' ? fn : null; }
57
+
58
+ /** An `output.*` sentence in the active locale, else the English. */
59
+ export function outputText(key, params = {}) {
60
+ let text = '';
61
+ try { text = translate?.(key, params) || ''; } catch { text = ''; }
62
+ if (!text || typeof text !== 'string') text = OUTPUT_COPY[key] ?? key;
63
+ return text.replace(/\{(\w+)\}/g, (whole, name) => (params[name] != null ? String(params[name]) : whole));
64
+ }
65
+
66
+ const escAttr = (value) => String(value ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
67
+
68
+ // A number as a reader sees one: an optional sign or comparison, a currency, digits with their separators, and a
69
+ // short unit (%, ms, s, MB, k, ×). A date (2026-11-21) or a time (12:30) is not one: nothing is aligned by it.
70
+ const NUMERIC_RE = /^[+\-−–~≈<>≤≥]?\s?(?:US\$|R\$|[$€£¥])?\s?\d[\d.,\s_]*(?:\s?(?:%|×|[a-zA-Zµ°]{1,5}(?:\/[a-zA-Z]{1,4})?))?$/;
71
+ const BLANK_RE = /^(?:|[-–—]|n\/a|—)$/i;
72
+
73
+ /** True when a cell's text is a number (see above). */
74
+ export function isNumericText(text) { return NUMERIC_RE.test(String(text ?? '').trim()); }
75
+
76
+ /**
77
+ * Which columns of a table hold numbers: every filled cell of the body is one, and at least one is filled.
78
+ * @param {string[][]} bodyRows the body's cells as text
79
+ * @returns {boolean[]} one flag per column
80
+ */
81
+ export function numericColumns(bodyRows) {
82
+ const rows = Array.isArray(bodyRows) ? bodyRows : [];
83
+ const width = rows.reduce((max, row) => Math.max(max, row.length), 0);
84
+ const flags = [];
85
+ for (let col = 0; col < width; col += 1) {
86
+ let filled = 0;
87
+ let numeric = true;
88
+ for (const row of rows) {
89
+ const text = String(row[col] ?? '').trim();
90
+ if (BLANK_RE.test(text)) continue;
91
+ filled += 1;
92
+ if (!NUMERIC_RE.test(text)) { numeric = false; break; }
93
+ }
94
+ flags.push(numeric && filled > 0);
95
+ }
96
+ return flags;
97
+ }
98
+
99
+ const ENTITIES = { amp: '&', lt: '<', gt: '>', quot: '"', '#39': "'", nbsp: ' ' };
100
+ // The text of a serialised cell: its tags out, the few entities a serialiser writes read back.
101
+ const cellText = (html) => String(html).replace(/<[^>]*>/g, '').replace(/&(amp|lt|gt|quot|#39|nbsp);/g, (_, name) => ENTITIES[name]).trim();
102
+
103
+ const ROW_RE = /<tr>([\s\S]*?)<\/tr>/g;
104
+ const CELL_RE = /<(t[hd])((?:\s[^>]*)?)>([\s\S]*?)<\/t[hd]>/g;
105
+
106
+ /**
107
+ * Which columns of a table hold sentences: some cell (the header's too) is LONG_CELL_CHARS or longer and has
108
+ * LONG_CELL_WORDS words or more. A long path or identifier is one word: it wraps where it can, and is not one.
109
+ * @param {string[][]} rows every row's cells as text
110
+ * @returns {boolean[]} one flag per column
111
+ */
112
+ export function longColumns(rows) {
113
+ const flags = [];
114
+ for (const row of Array.isArray(rows) ? rows : []) {
115
+ row.forEach((cell, col) => {
116
+ const text = String(cell ?? '').trim();
117
+ if (text.length >= LONG_CELL_CHARS && text.split(/\s+/).length >= LONG_CELL_WORDS) flags[col] = true;
118
+ });
119
+ }
120
+ return Array.from(flags, Boolean);
121
+ }
122
+
123
+ // A sanitised table with `class="sb-num"` on the cells of its numeric columns and `class="sb-long"` on those of
124
+ // its columns of sentences. A numeric column the writer aligned (`---:` in Markdown: the sanitiser keeps
125
+ // `align`) is left as written, and so is a table that holds a table.
126
+ function markColumns(table) {
127
+ if (table.indexOf('<table', 1) !== -1) return table;
128
+ const bodyStart = table.indexOf('<tbody>');
129
+ const head = bodyStart === -1 ? '' : table.slice(0, bodyStart);
130
+ const body = bodyStart === -1 ? table : table.slice(bodyStart);
131
+ const rows = [];
132
+ for (const row of body.matchAll(ROW_RE)) {
133
+ const cells = [...row[1].matchAll(CELL_RE)];
134
+ if (cells.some((cell) => /\s(?:colspan|rowspan)=/i.test(cell[2]))) return table;
135
+ rows.push(cells.map((cell) => cellText(cell[3])));
136
+ }
137
+ const bodyRows = bodyStart === -1 ? rows.slice(1) : rows.slice();
138
+ if (!bodyRows.length) return table;
139
+ // The header's cells count for a column's width, wherever the header is.
140
+ if (bodyStart !== -1) for (const row of head.matchAll(ROW_RE)) rows.push([...row[1].matchAll(CELL_RE)].map((cell) => cellText(cell[3])));
141
+ const numeric = numericColumns(bodyRows);
142
+ const long = longColumns(rows);
143
+ if (!numeric.some(Boolean) && !long.some(Boolean)) return table;
144
+ const mark = (part) => part.replace(ROW_RE, (whole, inner) => {
145
+ let col = -1;
146
+ return `<tr>${inner.replace(CELL_RE, (cell, tag, attrs, content) => {
147
+ col += 1;
148
+ if (/\sclass=/i.test(attrs)) return cell;
149
+ const cls = numeric[col] && !/\salign=/i.test(attrs) ? NUMERIC_CLASS : long[col] && !numeric[col] ? LONG_CLASS : '';
150
+ return cls ? `<${tag}${attrs} class="${cls}">${content}</${tag}>` : cell;
151
+ })}</tr>`;
152
+ });
153
+ return mark(head) + mark(body);
154
+ }
155
+
156
+ /** How many body rows and columns a serialised table has. */
157
+ export function tableSize(table) {
158
+ const rows = [...String(table).matchAll(ROW_RE)];
159
+ const hasHead = /<thead>/i.test(table);
160
+ const columns = rows.length ? [...rows[0][1].matchAll(CELL_RE)].length : 0;
161
+ return { rows: Math.max(0, rows.length - (hasHead || rows.length > 1 ? 1 : 0)), columns };
162
+ }
163
+
164
+ function tableButton(action, label, name) {
165
+ return `<button type="button" class="${TABLE_BUTTON_CLASS}" data-sb-act="${action}" data-label="${escAttr(label)}" aria-label="${escAttr(name)}"></button>`;
166
+ }
167
+
168
+ /** The strip above a table: its size (drawn by CSS for a table that is worth it), Expand and Copy. */
169
+ export function tableToolsHtml({ rows = 0, columns = 0 } = {}) {
170
+ return `<div class="${TABLE_TOOLS_CLASS}" data-rows="${rows}" data-columns="${columns}" data-label="${escAttr(outputText('tableSize', { rows, columns }))}">`
171
+ + `${tableButton('expand', outputText('expand'), outputText('expandTable'))}${tableButton('copy', outputText('copy'), outputText('copyTable'))}</div>`;
172
+ }
173
+
174
+ const FRAME_OPEN = `<div class="${TABLE_SCROLL_CLASS}">`;
175
+
176
+ /** One sanitised `<table>…</table>` inside its frame. */
177
+ export function tableFrameHtml(table) {
178
+ const marked = markColumns(table);
179
+ return `<div class="${TABLE_FRAME_CLASS}">${tableToolsHtml(tableSize(marked))}${FRAME_OPEN}${marked}</div></div>`;
180
+ }
181
+
182
+ // Every outermost table of a serialised document through `fn`; one already inside a frame is left alone, so the
183
+ // result is the same however often this runs.
184
+ function mapTables(html, fn) {
185
+ const token = /<table>|<\/table>/gi;
186
+ let out = '';
187
+ let last = 0;
188
+ let depth = 0;
189
+ let start = -1;
190
+ for (let match = token.exec(html); match; match = token.exec(html)) {
191
+ if (match[0][1] !== '/') {
192
+ if (depth === 0) start = match.index;
193
+ depth += 1;
194
+ } else if (depth > 0) {
195
+ depth -= 1;
196
+ if (depth !== 0) continue;
197
+ const end = match.index + match[0].length;
198
+ const framed = html.slice(Math.max(0, start - FRAME_OPEN.length), start) === FRAME_OPEN;
199
+ out += html.slice(last, start) + (framed ? html.slice(start, end) : fn(html.slice(start, end)));
200
+ last = end;
201
+ }
202
+ }
203
+ return out + html.slice(last);
204
+ }
205
+
206
+ const TASK_RE = /<li>(\s*(?:<p>)?)(☑|☐) /g;
207
+ const LANG_RE = /<pre><code class="language-([\w+#.-]{1,40})">/g;
208
+ const DIFF_RE = /(<pre data-lang="diff"><code class="language-diff">)([\s\S]*?)(<\/code>)/g;
209
+
210
+ /** The kind of a diff's line as a class (`sb-diff-add`, `-del`, `-hunk`, `-file`), or '' for a line of context. */
211
+ export function diffLineClass(line) {
212
+ if (/^(?:\+\+\+ |--- |diff |index )/.test(line)) return 'sb-diff-file';
213
+ if (line.startsWith('@@')) return 'sb-diff-hunk';
214
+ if (line.startsWith('+')) return 'sb-diff-add';
215
+ if (line.startsWith('-')) return 'sb-diff-del';
216
+ return '';
217
+ }
218
+
219
+ // The lines of a diff block, each added, removed, hunk or file line in a span of its kind. The text is untouched
220
+ // (what the block copies is what was written); a block that already holds markup is left as it is.
221
+ export function markDiffLines(body) {
222
+ if (body.includes('<')) return body;
223
+ return body.split('\n').map((line) => {
224
+ const cls = diffLineClass(line);
225
+ return cls && line ? `<span class="${cls}">${line}</span>` : line;
226
+ }).join('\n');
227
+ }
228
+
229
+ /**
230
+ * Sanitised Markdown HTML as a readable document: tables in their frames, task items, code languages, diff lines.
231
+ * Idempotent. `diff: false` leaves a diff block's lines alone (a panel that highlights code itself).
232
+ */
233
+ export function withOutputFrames(html, { diff = true } = {}) {
234
+ let out = typeof html === 'string' ? html : '';
235
+ if (!out) return out;
236
+ if (/<table>/i.test(out)) out = mapTables(out, tableFrameHtml);
237
+ if (out.includes('☑') || out.includes('☐')) {
238
+ out = out.replace(TASK_RE, (whole, lead, box) => `<li class="${TASK_CLASS}${box === '☑' ? ` ${TASK_CLASS}-done` : ''}">${lead}<span class="${TASK_CLASS}-box">${box}</span> `);
239
+ }
240
+ if (out.includes('<pre><code class="language-')) out = out.replace(LANG_RE, '<pre data-lang="$1"><code class="language-$1">');
241
+ if (diff && out.includes('data-lang="diff"')) out = out.replace(DIFF_RE, (whole, open, body, close) => open + markDiffLines(body) + close);
242
+ return out;
243
+ }
244
+
245
+ const tagOf = (node) => String(node?.localName || node?.nodeName || '').toLowerCase();
246
+
247
+ function nodeText(node) {
248
+ let out = '';
249
+ const walk = (parent) => {
250
+ for (const child of parent.childNodes || []) {
251
+ if (child.nodeType === 3 || child.nodeType === 4) { out += child.data ?? child.nodeValue ?? ''; continue; }
252
+ if (child.nodeType !== 1) continue;
253
+ const tag = tagOf(child);
254
+ if (tag === 'button') continue;
255
+ if (tag === 'br') { out += ' '; continue; }
256
+ walk(child);
257
+ }
258
+ };
259
+ walk(node);
260
+ return out.replace(/\s+/g, ' ').trim();
261
+ }
262
+
263
+ /**
264
+ * A table element's cells as text, row by row (the header first). Works on any DOM, a test's included.
265
+ * @returns {string[][]}
266
+ */
267
+ export function tableMatrix(table) {
268
+ const rows = [];
269
+ const walk = (node) => {
270
+ for (const child of node?.childNodes || []) {
271
+ if (child.nodeType !== 1) continue;
272
+ const tag = tagOf(child);
273
+ if (tag === 'tr') rows.push([...child.childNodes].filter((cell) => cell.nodeType === 1 && /^t[hd]$/.test(tagOf(cell))).map(nodeText));
274
+ else if (tag === 'thead' || tag === 'tbody' || tag === 'tfoot') walk(child);
275
+ }
276
+ };
277
+ walk(table);
278
+ return rows;
279
+ }
280
+
281
+ /** A table as tab-separated text: what a spreadsheet, a chat and a terminal all read. */
282
+ export function matrixToTsv(matrix) {
283
+ return (matrix || []).map((row) => row.map((cell) => String(cell ?? '').replace(/[\t\r\n]+/g, ' ')).join('\t')).join('\n');
284
+ }
285
+
286
+ const escText = (value) => String(value ?? '').replace(/[&<>]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;' }[c]));
287
+
288
+ /** The same table as plain, unstyled HTML (text only): what a document or a mail pastes as a table. */
289
+ export function matrixToHtml(matrix) {
290
+ const rows = matrix || [];
291
+ if (!rows.length) return '';
292
+ const line = (row, tag) => `<tr>${row.map((cell) => `<${tag}>${escText(cell)}</${tag}>`).join('')}</tr>`;
293
+ return `<table><thead>${line(rows[0], 'th')}</thead><tbody>${rows.slice(1).map((row) => line(row, 'td')).join('')}</tbody></table>`;
294
+ }
@@ -6,9 +6,8 @@
6
6
  // the connection (lib/peer-identity.js). When it cannot look that process up (netstat or ps missing, denied because
7
7
  // the server was started inside a sandbox, slow past its cap), it proves nothing about who is asking and pauses the
8
8
  // owner's actions: no page secret, and the owner's writes, reads and sockets answer 503 PEER_UNAVAILABLE. GET
9
- // /api/health says so (`ownerAuthority: { state: 'degraded', reason, retryable, since }`), and so does every 503
10
- // PEER_UNAVAILABLE a request of the page gets (public/shared/page-session.js turns it into the
11
- // `synabun:peer-unavailable` event). This module decides the words of the banner; ui-owner-authority.js asks the
9
+ // /api/health says so (`ownerAuthority: { state: 'degraded', reason, retryable, since }`). A request refused with
10
+ // PEER_UNAVAILABLE prompts the page to check health. This module decides the words of the banner; ui-owner-authority.js asks the
12
11
  // server, listens and draws them. `unsupported` (Windows, Linux) and `off` (SYNABUN_PEER_IDENTITY=off) show nothing:
13
12
  // there the rules from before apply and nothing is paused.
14
13
  //
@@ -27,7 +26,7 @@ export const OWNER_AUTHORITY_NOTICE_COPY = Object.freeze({
27
26
  });
28
27
 
29
28
  /** The states GET /api/health can name (lib/peer-identity.js authorityState). */
30
- export const OWNER_AUTHORITY_STATES = Object.freeze(['ok', 'degraded', 'unsupported', 'off']);
29
+ export const OWNER_AUTHORITY_STATES = Object.freeze(['pending', 'ok', 'degraded', 'unsupported', 'off']);
31
30
  /** The longest reason the banner shows (the server's reasons are short; a longer one is cut). */
32
31
  export const REASON_MAX = 200;
33
32
 
@@ -58,13 +57,8 @@ export function readOwnerAuthority(health) {
58
57
  };
59
58
  }
60
59
 
61
- /** The state a 503 PEER_UNAVAILABLE answer stands for (the event's detail, or the answer's body). */
62
- export function unavailableAuthority(detail) {
63
- return { state: 'degraded', reason: cleanReason(detail?.reason) || null, retryable: detail?.retryable === true, since: null };
64
- }
65
-
66
60
  /**
67
- * What the banner shows for a state, or null when it shows nothing (ok, unsupported, off, nothing known).
61
+ * What the banner shows for a state, or null when it shows nothing (pending, ok, unsupported, off, nothing known).
68
62
  * `t(key, params)` is the page's translator for `ownerAuthorityNotice.*` (English by default).
69
63
  * → { key, label, title, body, reason, hint, actions: [{ id: 'reload'|'dismiss', label }] }. `key` is what a
70
64
  * dismissal is remembered by: the same outage stays dismissed, a new reason shows again.
@@ -25,7 +25,7 @@
25
25
  // lookup of the calling process failed: lib/peer-identity.js), so it hands out no page secret and refuses the owner's
26
26
  // actions until a lookup works again. Nothing here cures that, so nothing is retried: the answer goes back as it came,
27
27
  // and the page is told once per answer (the `synabun:peer-unavailable` event on the window, which
28
- // ui-owner-authority.js turns into its banner). A refresh that met it (GET /api/page-session answered 503) is not asked
28
+ // ui-owner-authority.js uses to recheck verifier health). A refresh that met it (GET /api/page-session answered 503) is not asked
29
29
  // again for a few seconds: a burst of refused writes costs the server one lookup, not one each.
30
30
  //
31
31
  // A refusal nothing here cures (403 WORKER_BROWSER, OWNER_ROUTE, or PAGE_SECRET_REQUIRED the refresh did not cure) is
@@ -33,3 +33,9 @@ export function getProviderMeta(providerId = 'claude-code') {
33
33
  }
34
34
 
35
35
  export { PROVIDER_META };
36
+
37
+ /** OpenCode stores a model as providerID/modelID or as its serialized string. */
38
+ export function isMaritacaModel(model) {
39
+ const provider = typeof model === 'string' ? model.split('/', 1)[0] : model?.providerID;
40
+ return typeof provider === 'string' && provider.toLowerCase() === 'maritaca';
41
+ }
@@ -1,3 +1,4 @@
1
+ import { isPersonalStop } from './worker-end.js';
1
2
  import { toolListView } from './tool-list-view.js';
2
3
  // SynaBun Neural Interface — what the Schedules window shows, without the page.
3
4
  // Which schedules a view lists and in which order, how a schedule's state reads, and the cron
@@ -230,7 +231,7 @@ export function lastRunState(schedule) {
230
231
  const head = (colon >= 0 ? text.slice(0, colon) : text).trim();
231
232
  const reason = colon >= 0 ? text.slice(colon + 1).trim() : '';
232
233
  if (head === 'error') return { kind: 'failed', label: scheduleWord('runFailed'), reason: reason || scheduleWord('runFailedReason') };
233
- if (head === 'stopped') return { kind: 'stopped', label: scheduleWord('runStopped'), reason: reason === 'user' ? scheduleWord('runStoppedByYou') : reason };
234
+ if (head === 'stopped') return { kind: 'stopped', label: scheduleWord('runStopped'), reason: reason === 'user' ? (isPersonalStop(schedule.lastStopProvenance) ? scheduleWord('runStoppedByYou') : '') : reason };
234
235
  if (head === 'interrupted') return { kind: 'interrupted', label: scheduleWord('runInterrupted'), reason };
235
236
  return { kind: 'other', label: head.charAt(0).toUpperCase() + head.slice(1), reason };
236
237
  }
@@ -0,0 +1,77 @@
1
+ // ═══════════════════════════════════════════
2
+ // SynaBun Neural Interface — is the server gone, or only slow
3
+ // What the page concludes from health probes that were not answered.
4
+ // DOM-free and dependency-free (unit-tested under Node).
5
+ //
6
+ // The page asks GET /api/health every 3 s and gives each request 3 s. It used
7
+ // to show "Server offline" after two requests in a row without an answer: six
8
+ // seconds. On 2026-11-21 a server that never stopped (same boot id before and
9
+ // after, its WebSockets still open) was shown as offline that way, twice,
10
+ // while it worked through slow database statements during and after a 9.4 GB
11
+ // backup. Not answering in time is not being gone, and the two look different
12
+ // from here:
13
+ //
14
+ // refused the request failed at once: nothing listens on the port (the
15
+ // process ended), or what answered is not the server. Asked once
16
+ // more right away; refused again is offline. A real stop is still
17
+ // reported within the time of two failed connections.
18
+ // timeout the connection was taken and no answer came in time: the
19
+ // process is there and busy (or the machine is). Nothing is shown
20
+ // until that has lasted `slowGraceMs` over at least `slowMisses`
21
+ // probes in a row; one answer in between starts the count again.
22
+ // A hung server is still reported, just not a slow one.
23
+ //
24
+ // A hidden tab never concludes "offline" from timeouts: browsers hold back a
25
+ // background tab's timers and requests, so a late answer there says nothing
26
+ // about the server. It looks again the moment it is shown (`shown()`).
27
+ // ═══════════════════════════════════════════
28
+
29
+ export const PRESENCE_LIMITS = {
30
+ slowGraceMs: 20000, // unanswered (but not refused) for this long before the offline screen
31
+ slowMisses: 3, // and at least this many probes in a row
32
+ };
33
+
34
+ /** How a failed probe ended: 'timeout' (given up on waiting) or 'refused' (nothing took it, or not the server's answer). */
35
+ export function probeFailureKind(error) {
36
+ const name = String(error?.name || '');
37
+ return name === 'TimeoutError' || name === 'AbortError' ? 'timeout' : 'refused';
38
+ }
39
+
40
+ /**
41
+ * The misses of one page, in a row.
42
+ * missed(kind, { hidden, confirmed }) → 'confirm' | 'offline' | 'wait'
43
+ * 'confirm' refused once: ask again right away, then call missed(kind, { confirmed: true })
44
+ * 'offline' show the offline screen
45
+ * 'wait' slow, or a hidden tab that cannot tell: show nothing, keep probing
46
+ * answered() → { recovered, misses, ms } an answer from the server ends the row
47
+ * snapshot() → { misses, ms, held } | null the row under way (held: 'slow' | 'hidden' | null)
48
+ */
49
+ export function createServerPresence({ limits = PRESENCE_LIMITS, now = () => Date.now() } = {}) {
50
+ const lim = { ...PRESENCE_LIMITS, ...limits };
51
+ let row = null; // { since, misses, held }
52
+
53
+ return {
54
+ missed(kind, { hidden = false, confirmed = false } = {}) {
55
+ if (!row) row = { since: now(), misses: 0, held: null };
56
+ row.misses += 1;
57
+ if (kind !== 'timeout') {
58
+ row.held = null;
59
+ return confirmed ? 'offline' : 'confirm';
60
+ }
61
+ if (hidden) { row.held = 'hidden'; return 'wait'; }
62
+ if (row.misses >= lim.slowMisses && now() - row.since >= lim.slowGraceMs) { row.held = null; return 'offline'; }
63
+ row.held = 'slow';
64
+ return 'wait';
65
+ },
66
+ answered() {
67
+ const had = row;
68
+ row = null;
69
+ return had ? { recovered: true, misses: had.misses, ms: Math.max(0, now() - had.since) } : { recovered: false, misses: 0, ms: 0 };
70
+ },
71
+ snapshot() {
72
+ return row ? { misses: row.misses, ms: Math.max(0, now() - row.since), held: row.held } : null;
73
+ },
74
+ /** The offline screen is up, or the page gave up watching: whatever comes next is a new row. */
75
+ reset() { row = null; },
76
+ };
77
+ }
@@ -11,10 +11,10 @@
11
11
  //
12
12
  // DOM-free and without imports: node --test and the page load the same file.
13
13
 
14
- /** The Connection modes of SynaBun's own local browser (the Browser tab's dropdown). */
15
- export const LOCAL_CONNECT_MODES = Object.freeze(['mirror', 'attach', 'extension']);
14
+ /** The modes offered in the Browser tab's Connection dropdown. */
15
+ export const LOCAL_CONNECT_OPTIONS = Object.freeze(['attach', 'extension']);
16
16
 
17
- /** The mode a MoreLogin switch-off goes back to (as POST /api/morelogin/use-default { clear: true } does). */
17
+ /** Deprecated in the menu. Still supported for saved configs and as the server's local default. */
18
18
  export const LOCAL_DEFAULT_MODE = 'mirror';
19
19
 
20
20
  const idOf = (value) => (value === undefined || value === null || value === '' ? null : String(value));
@@ -40,7 +40,7 @@ export function aiBrowserOfStatus(status) {
40
40
  /** The Connection dropdown's value for a loaded config: a local mode, never 'morelogin' (it has no such option). */
41
41
  export function localConnectModeOf(cfg) {
42
42
  const mode = cfg && typeof cfg === 'object' ? cfg.connectMode : null;
43
- return LOCAL_CONNECT_MODES.includes(mode) ? mode : LOCAL_DEFAULT_MODE;
43
+ return LOCAL_CONNECT_OPTIONS.includes(mode) ? mode : LOCAL_DEFAULT_MODE;
44
44
  }
45
45
 
46
46
  /**
@@ -54,7 +54,7 @@ export function browserSaveFields(formMode, current) {
54
54
  const now = current && typeof current === 'object' ? current : {};
55
55
  const envId = idOf(now.envId);
56
56
  if (now.moreLogin === true) return { connectMode: 'morelogin', moreloginEnvId: envId };
57
- return { connectMode: LOCAL_CONNECT_MODES.includes(formMode) ? formMode : LOCAL_DEFAULT_MODE, moreloginEnvId: envId };
57
+ return { connectMode: LOCAL_CONNECT_OPTIONS.includes(formMode) ? formMode : LOCAL_DEFAULT_MODE, moreloginEnvId: envId };
58
58
  }
59
59
 
60
60
  /**