synabun 2.2.1 → 2.3.0

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 (365) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/README.md +1 -1
  3. package/docs/whatsapp.md +52 -20
  4. package/hooks/claude-code/pre-websearch.mjs +4 -1
  5. package/hooks/claude-code/prompt-submit.mjs +7 -0
  6. package/lib/mcp-build.js +519 -0
  7. package/lib/mcp-dist.js +10 -4
  8. package/lib/release-scan.mjs +23 -10
  9. package/lib/server-supervisor.js +7 -1
  10. package/lib/virustotal.mjs +146 -40
  11. package/mcp-server/dist/http.d.ts +57 -0
  12. package/mcp-server/dist/http.d.ts.map +1 -1
  13. package/mcp-server/dist/http.js +128 -18
  14. package/mcp-server/dist/http.js.map +1 -1
  15. package/mcp-server/dist/index.d.ts.map +1 -1
  16. package/mcp-server/dist/index.js +14 -9
  17. package/mcp-server/dist/index.js.map +1 -1
  18. package/mcp-server/dist/services/browser-route-flow.d.ts +119 -0
  19. package/mcp-server/dist/services/browser-route-flow.d.ts.map +1 -0
  20. package/mcp-server/dist/services/browser-route-flow.js +340 -0
  21. package/mcp-server/dist/services/browser-route-flow.js.map +1 -0
  22. package/mcp-server/dist/services/desktop-client.js +2 -2
  23. package/mcp-server/dist/services/desktop-client.js.map +1 -1
  24. package/mcp-server/dist/services/embedding-service.d.ts.map +1 -1
  25. package/mcp-server/dist/services/embedding-service.js +2 -1
  26. package/mcp-server/dist/services/embedding-service.js.map +1 -1
  27. package/mcp-server/dist/services/identity.d.ts +66 -3
  28. package/mcp-server/dist/services/identity.d.ts.map +1 -1
  29. package/mcp-server/dist/services/identity.js +61 -4
  30. package/mcp-server/dist/services/identity.js.map +1 -1
  31. package/mcp-server/dist/services/neural-interface.d.ts +133 -1
  32. package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
  33. package/mcp-server/dist/services/neural-interface.js +630 -64
  34. package/mcp-server/dist/services/neural-interface.js.map +1 -1
  35. package/mcp-server/dist/services/tool-catalog.js +2 -2
  36. package/mcp-server/dist/services/tool-catalog.js.map +1 -1
  37. package/mcp-server/dist/tools/agents.d.ts +3 -2
  38. package/mcp-server/dist/tools/agents.d.ts.map +1 -1
  39. package/mcp-server/dist/tools/agents.js +6 -4
  40. package/mcp-server/dist/tools/agents.js.map +1 -1
  41. package/mcp-server/dist/tools/bluesky.d.ts +20 -7
  42. package/mcp-server/dist/tools/bluesky.d.ts.map +1 -1
  43. package/mcp-server/dist/tools/bluesky.js +147 -45
  44. package/mcp-server/dist/tools/bluesky.js.map +1 -1
  45. package/mcp-server/dist/tools/browser-advanced.d.ts +13 -2
  46. package/mcp-server/dist/tools/browser-advanced.d.ts.map +1 -1
  47. package/mcp-server/dist/tools/browser-advanced.js +153 -18
  48. package/mcp-server/dist/tools/browser-advanced.js.map +1 -1
  49. package/mcp-server/dist/tools/browser-cheatsheet.d.ts +2 -0
  50. package/mcp-server/dist/tools/browser-cheatsheet.d.ts.map +1 -1
  51. package/mcp-server/dist/tools/browser-cheatsheet.js +3 -0
  52. package/mcp-server/dist/tools/browser-cheatsheet.js.map +1 -1
  53. package/mcp-server/dist/tools/browser-navigate.d.ts +3 -3
  54. package/mcp-server/dist/tools/browser-navigate.d.ts.map +1 -1
  55. package/mcp-server/dist/tools/browser-navigate.js +19 -16
  56. package/mcp-server/dist/tools/browser-navigate.js.map +1 -1
  57. package/mcp-server/dist/tools/browser-observe.d.ts +2 -1
  58. package/mcp-server/dist/tools/browser-observe.d.ts.map +1 -1
  59. package/mcp-server/dist/tools/browser-observe.js +61 -20
  60. package/mcp-server/dist/tools/browser-observe.js.map +1 -1
  61. package/mcp-server/dist/tools/morelogin.d.ts +13 -3
  62. package/mcp-server/dist/tools/morelogin.d.ts.map +1 -1
  63. package/mcp-server/dist/tools/morelogin.js +82 -19
  64. package/mcp-server/dist/tools/morelogin.js.map +1 -1
  65. package/mcp-server/dist/tools/skill-tools.d.ts +4 -4
  66. package/mcp-server/dist/tools/youtube/helpers.d.ts +1 -0
  67. package/mcp-server/dist/tools/youtube/helpers.d.ts.map +1 -1
  68. package/mcp-server/dist/tools/youtube/helpers.js +1 -1
  69. package/mcp-server/dist/tools/youtube/helpers.js.map +1 -1
  70. package/mcp-server/dist/tools/youtube/upload.d.ts.map +1 -1
  71. package/mcp-server/dist/tools/youtube/upload.js +225 -88
  72. package/mcp-server/dist/tools/youtube/upload.js.map +1 -1
  73. package/mcp-server/package-lock.json +2 -2
  74. package/mcp-server/package.json +1 -1
  75. package/mcp-server/src/http.ts +135 -17
  76. package/mcp-server/src/index.ts +15 -9
  77. package/mcp-server/src/services/browser-route-flow.ts +403 -0
  78. package/mcp-server/src/services/desktop-client.ts +2 -2
  79. package/mcp-server/src/services/embedding-service.ts +2 -1
  80. package/mcp-server/src/services/identity.ts +80 -4
  81. package/mcp-server/src/services/neural-interface.ts +648 -73
  82. package/mcp-server/src/services/tool-catalog.ts +2 -2
  83. package/mcp-server/src/tools/agents.ts +8 -4
  84. package/mcp-server/src/tools/bluesky.ts +164 -51
  85. package/mcp-server/src/tools/browser-advanced.ts +142 -17
  86. package/mcp-server/src/tools/browser-cheatsheet.ts +3 -0
  87. package/mcp-server/src/tools/browser-navigate.ts +19 -16
  88. package/mcp-server/src/tools/browser-observe.ts +62 -20
  89. package/mcp-server/src/tools/morelogin.ts +82 -19
  90. package/mcp-server/src/tools/youtube/helpers.ts +2 -2
  91. package/mcp-server/src/tools/youtube/upload.ts +218 -99
  92. package/neural-interface/i18n/en.json +655 -123
  93. package/neural-interface/i18n/pt-BR.json +542 -10
  94. package/neural-interface/lib/assistant-api.js +90 -23
  95. package/neural-interface/lib/assistant-brains/claude.js +5 -0
  96. package/neural-interface/lib/assistant-catalog.js +134 -3
  97. package/neural-interface/lib/assistant-dispatch.js +97 -1
  98. package/neural-interface/lib/assistant-persona.js +15 -7
  99. package/neural-interface/lib/assistant-router.js +6 -4
  100. package/neural-interface/lib/assistant-runtime.js +18 -1
  101. package/neural-interface/lib/assistant-task-prompt.js +5 -0
  102. package/neural-interface/lib/assistant-tools.js +10 -1
  103. package/neural-interface/lib/automation-approval.js +249 -0
  104. package/neural-interface/lib/automation-browser-owner-access.js +82 -0
  105. package/neural-interface/lib/backup-service.js +16 -1
  106. package/neural-interface/lib/browser-automation-routes.js +84 -0
  107. package/neural-interface/lib/browser-background-tab.js +72 -3
  108. package/neural-interface/lib/browser-execution.js +16 -3
  109. package/neural-interface/lib/browser-extraction.js +106 -45
  110. package/neural-interface/lib/browser-owner.js +48 -0
  111. package/neural-interface/lib/browser-profile-choices.js +143 -0
  112. package/neural-interface/lib/browser-profiles.js +142 -0
  113. package/neural-interface/lib/browser-session-close.js +84 -0
  114. package/neural-interface/lib/browser-start-handoff.js +202 -0
  115. package/neural-interface/lib/browser-tab-recovery.js +153 -0
  116. package/neural-interface/lib/browser-tool-policy.js +23 -4
  117. package/neural-interface/lib/browser-wedge-retire.js +64 -0
  118. package/neural-interface/lib/chromium-on-device-model.js +67 -0
  119. package/neural-interface/lib/claude-agent-bridge.js +43 -5
  120. package/neural-interface/lib/claude-background-hold.js +239 -0
  121. package/neural-interface/lib/claude-model-catalog.js +12 -0
  122. package/neural-interface/lib/effort-levels.js +28 -2
  123. package/neural-interface/lib/exec-loop-command.js +8 -0
  124. package/neural-interface/lib/http-guards.js +11 -6
  125. package/neural-interface/lib/local-profile-proxy.js +362 -0
  126. package/neural-interface/lib/local-profiles.js +929 -0
  127. package/neural-interface/lib/loop-logger.js +31 -5
  128. package/neural-interface/lib/maritaca/api.js +179 -0
  129. package/neural-interface/lib/maritaca/attachments.js +44 -0
  130. package/neural-interface/lib/maritaca/client.js +362 -0
  131. package/neural-interface/lib/maritaca/key-store.js +122 -0
  132. package/neural-interface/lib/maritaca/models.js +181 -0
  133. package/neural-interface/lib/maritaca/modes.js +39 -0
  134. package/neural-interface/lib/maritaca/opencode-proxy.js +236 -0
  135. package/neural-interface/lib/maritaca/opencode-stream.js +345 -0
  136. package/neural-interface/lib/maritaca/opencode.js +218 -0
  137. package/neural-interface/lib/maritaca/panel-bridge.js +273 -0
  138. package/neural-interface/lib/maritaca/sessions.js +198 -0
  139. package/neural-interface/lib/mcp-external-servers.js +37 -10
  140. package/neural-interface/lib/morelogin-agent-profiles.js +149 -0
  141. package/neural-interface/lib/morelogin.js +278 -14
  142. package/neural-interface/lib/native-loop-providers.js +124 -11
  143. package/neural-interface/lib/native-loop-runtime.js +112 -11
  144. package/neural-interface/lib/owner-authority.js +137 -43
  145. package/neural-interface/lib/page-session.js +111 -27
  146. package/neural-interface/lib/peer-identity.js +263 -43
  147. package/neural-interface/lib/provider-panel-api-key-auth.js +7 -2
  148. package/neural-interface/lib/pty-host/core.js +36 -0
  149. package/neural-interface/lib/pty-host/protocol.js +2 -0
  150. package/neural-interface/lib/request-gate.js +2 -0
  151. package/neural-interface/lib/skills/api-v2.js +13 -2
  152. package/neural-interface/lib/skills/creation-api.js +3 -1
  153. package/neural-interface/lib/skills/evals-api.js +5 -1
  154. package/neural-interface/lib/social-write-pacing.js +151 -0
  155. package/neural-interface/lib/system-activity.js +1 -1
  156. package/neural-interface/lib/terminal-token-redaction.js +293 -0
  157. package/neural-interface/lib/terminal-tokens.js +436 -0
  158. package/neural-interface/lib/worker-mcp-channel.js +45 -10
  159. package/neural-interface/package-lock.json +3 -2
  160. package/neural-interface/package.json +2 -1
  161. package/neural-interface/public/assets/mascot/README.md +11 -0
  162. package/neural-interface/public/assets/mascot/ask.gif +0 -0
  163. package/neural-interface/public/assets/mascot/ask.png +0 -0
  164. package/neural-interface/public/assets/mascot/blocked.gif +0 -0
  165. package/neural-interface/public/assets/mascot/blocked.png +0 -0
  166. package/neural-interface/public/assets/mascot/budget.gif +0 -0
  167. package/neural-interface/public/assets/mascot/budget.png +0 -0
  168. package/neural-interface/public/assets/mascot/computer.gif +0 -0
  169. package/neural-interface/public/assets/mascot/computer.png +0 -0
  170. package/neural-interface/public/assets/mascot/edit.gif +0 -0
  171. package/neural-interface/public/assets/mascot/edit.png +0 -0
  172. package/neural-interface/public/assets/mascot/error.gif +0 -0
  173. package/neural-interface/public/assets/mascot/error.png +0 -0
  174. package/neural-interface/public/assets/mascot/hover-attention.gif +0 -0
  175. package/neural-interface/public/assets/mascot/hover-attention.png +0 -0
  176. package/neural-interface/public/assets/mascot/idle-hero.gif +0 -0
  177. package/neural-interface/public/assets/mascot/idle-hero.png +0 -0
  178. package/neural-interface/public/assets/mascot/idle.gif +0 -0
  179. package/neural-interface/public/assets/mascot/idle.png +0 -0
  180. package/neural-interface/public/assets/mascot/manifest.json +254 -0
  181. package/neural-interface/public/assets/mascot/mcp.gif +0 -0
  182. package/neural-interface/public/assets/mascot/mcp.png +0 -0
  183. package/neural-interface/public/assets/mascot/memory.gif +0 -0
  184. package/neural-interface/public/assets/mascot/memory.png +0 -0
  185. package/neural-interface/public/assets/mascot/offline.gif +0 -0
  186. package/neural-interface/public/assets/mascot/offline.png +0 -0
  187. package/neural-interface/public/assets/mascot/pick.gif +0 -0
  188. package/neural-interface/public/assets/mascot/pick.png +0 -0
  189. package/neural-interface/public/assets/mascot/plan.gif +0 -0
  190. package/neural-interface/public/assets/mascot/plan.png +0 -0
  191. package/neural-interface/public/assets/mascot/present.gif +0 -0
  192. package/neural-interface/public/assets/mascot/present.png +0 -0
  193. package/neural-interface/public/assets/mascot/project.gif +0 -0
  194. package/neural-interface/public/assets/mascot/project.png +0 -0
  195. package/neural-interface/public/assets/mascot/read.gif +0 -0
  196. package/neural-interface/public/assets/mascot/read.png +0 -0
  197. package/neural-interface/public/assets/mascot/runs.gif +0 -0
  198. package/neural-interface/public/assets/mascot/runs.png +0 -0
  199. package/neural-interface/public/assets/mascot/scenes/automation.gif +0 -0
  200. package/neural-interface/public/assets/mascot/scenes/automation.png +0 -0
  201. package/neural-interface/public/assets/mascot/scenes/browser.gif +0 -0
  202. package/neural-interface/public/assets/mascot/scenes/browser.png +0 -0
  203. package/neural-interface/public/assets/mascot/scenes/code.gif +0 -0
  204. package/neural-interface/public/assets/mascot/scenes/code.png +0 -0
  205. package/neural-interface/public/assets/mascot/scenes/complex.gif +0 -0
  206. package/neural-interface/public/assets/mascot/scenes/complex.png +0 -0
  207. package/neural-interface/public/assets/mascot/scenes/computer.gif +0 -0
  208. package/neural-interface/public/assets/mascot/scenes/computer.png +0 -0
  209. package/neural-interface/public/assets/mascot/scenes/design.gif +0 -0
  210. package/neural-interface/public/assets/mascot/scenes/design.png +0 -0
  211. package/neural-interface/public/assets/mascot/scenes/edit.gif +0 -0
  212. package/neural-interface/public/assets/mascot/scenes/edit.png +0 -0
  213. package/neural-interface/public/assets/mascot/scenes/generic.gif +0 -0
  214. package/neural-interface/public/assets/mascot/scenes/generic.png +0 -0
  215. package/neural-interface/public/assets/mascot/scenes/image_gen.gif +0 -0
  216. package/neural-interface/public/assets/mascot/scenes/image_gen.png +0 -0
  217. package/neural-interface/public/assets/mascot/scenes/manifest.json +173 -0
  218. package/neural-interface/public/assets/mascot/scenes/memory.gif +0 -0
  219. package/neural-interface/public/assets/mascot/scenes/memory.png +0 -0
  220. package/neural-interface/public/assets/mascot/scenes/quick.gif +0 -0
  221. package/neural-interface/public/assets/mascot/scenes/quick.png +0 -0
  222. package/neural-interface/public/assets/mascot/scenes/read.gif +0 -0
  223. package/neural-interface/public/assets/mascot/scenes/read.png +0 -0
  224. package/neural-interface/public/assets/mascot/scenes/research.gif +0 -0
  225. package/neural-interface/public/assets/mascot/scenes/research.png +0 -0
  226. package/neural-interface/public/assets/mascot/scenes/review.gif +0 -0
  227. package/neural-interface/public/assets/mascot/scenes/review.png +0 -0
  228. package/neural-interface/public/assets/mascot/scenes/search.gif +0 -0
  229. package/neural-interface/public/assets/mascot/scenes/search.png +0 -0
  230. package/neural-interface/public/assets/mascot/scenes/shell.gif +0 -0
  231. package/neural-interface/public/assets/mascot/scenes/shell.png +0 -0
  232. package/neural-interface/public/assets/mascot/scenes/thinking.gif +0 -0
  233. package/neural-interface/public/assets/mascot/scenes/thinking.png +0 -0
  234. package/neural-interface/public/assets/mascot/scenes/video_gen.gif +0 -0
  235. package/neural-interface/public/assets/mascot/scenes/video_gen.png +0 -0
  236. package/neural-interface/public/assets/mascot/scenes/web.gif +0 -0
  237. package/neural-interface/public/assets/mascot/scenes/web.png +0 -0
  238. package/neural-interface/public/assets/mascot/search.gif +0 -0
  239. package/neural-interface/public/assets/mascot/search.png +0 -0
  240. package/neural-interface/public/assets/mascot/shell.gif +0 -0
  241. package/neural-interface/public/assets/mascot/shell.png +0 -0
  242. package/neural-interface/public/assets/mascot/skill.gif +0 -0
  243. package/neural-interface/public/assets/mascot/skill.png +0 -0
  244. package/neural-interface/public/assets/mascot/sleep.gif +0 -0
  245. package/neural-interface/public/assets/mascot/sleep.png +0 -0
  246. package/neural-interface/public/assets/mascot/subagent.gif +0 -0
  247. package/neural-interface/public/assets/mascot/subagent.png +0 -0
  248. package/neural-interface/public/assets/mascot/success.gif +0 -0
  249. package/neural-interface/public/assets/mascot/success.png +0 -0
  250. package/neural-interface/public/assets/mascot/think.gif +0 -0
  251. package/neural-interface/public/assets/mascot/think.png +0 -0
  252. package/neural-interface/public/assets/mascot/wait.gif +0 -0
  253. package/neural-interface/public/assets/mascot/wait.png +0 -0
  254. package/neural-interface/public/assets/mascot/watch.gif +0 -0
  255. package/neural-interface/public/assets/mascot/watch.png +0 -0
  256. package/neural-interface/public/assets/mascot/web.gif +0 -0
  257. package/neural-interface/public/assets/mascot/web.png +0 -0
  258. package/neural-interface/public/onboarding.html +14 -1
  259. package/neural-interface/public/shared/agent-runtime-options.js +49 -8
  260. package/neural-interface/public/shared/agy/agy-panel.js +2 -2
  261. package/neural-interface/public/shared/agy/agy-render.js +41 -1
  262. package/neural-interface/public/shared/agy/agy-styles.js +5 -0
  263. package/neural-interface/public/shared/api.js +5 -4
  264. package/neural-interface/public/shared/assistant/asst-ask-styles.js +8 -8
  265. package/neural-interface/public/shared/assistant/asst-ask.js +1 -1
  266. package/neural-interface/public/shared/assistant/asst-brain-picker.js +99 -9
  267. package/neural-interface/public/shared/assistant/asst-computer.js +47 -2
  268. package/neural-interface/public/shared/assistant/asst-control.js +1 -1
  269. package/neural-interface/public/shared/assistant/asst-limit-wait.js +7 -5
  270. package/neural-interface/public/shared/assistant/asst-panel.js +13 -5
  271. package/neural-interface/public/shared/assistant/asst-rack-styles.js +4 -4
  272. package/neural-interface/public/shared/assistant/asst-render.js +16 -10
  273. package/neural-interface/public/shared/assistant/asst-route-models.js +64 -4
  274. package/neural-interface/public/shared/assistant/asst-route.js +24 -7
  275. package/neural-interface/public/shared/assistant/asst-routes-editor.js +154 -39
  276. package/neural-interface/public/shared/assistant/asst-run-stage.js +3 -3
  277. package/neural-interface/public/shared/assistant/asst-scene-styles.js +8 -111
  278. package/neural-interface/public/shared/assistant/asst-scenes.js +46 -318
  279. package/neural-interface/public/shared/assistant/asst-sidepanel.js +2 -2
  280. package/neural-interface/public/shared/assistant/asst-state.js +72 -2
  281. package/neural-interface/public/shared/assistant/asst-styles.js +60 -15
  282. package/neural-interface/public/shared/automation-approval-view.js +75 -0
  283. package/neural-interface/public/shared/cdx/cdx-panel.js +2 -2
  284. package/neural-interface/public/shared/cdx/cdx-render.js +73 -7
  285. package/neural-interface/public/shared/cdx/cdx-tabs.js +3 -3
  286. package/neural-interface/public/shared/context-menu-model.js +2 -0
  287. package/neural-interface/public/shared/cp/cp-agents.js +8 -0
  288. package/neural-interface/public/shared/cp/cp-permissions.js +6 -2
  289. package/neural-interface/public/shared/cp/cp-rehydrate.js +25 -1
  290. package/neural-interface/public/shared/cp/cp-tasks-model.js +33 -0
  291. package/neural-interface/public/shared/editor/editor-panel-logic.js +10 -0
  292. package/neural-interface/public/shared/editor/editor-panel.js +10 -2
  293. package/neural-interface/public/shared/html-shell.js +30 -22
  294. package/neural-interface/public/shared/judgments-log-origins.js +29 -0
  295. package/neural-interface/public/shared/morelogin-profile-choices.js +107 -0
  296. package/neural-interface/public/shared/morelogin-profile-field.js +186 -0
  297. package/neural-interface/public/shared/mtc/mtc-client.js +181 -0
  298. package/neural-interface/public/shared/mtc/mtc-compose.js +40 -0
  299. package/neural-interface/public/shared/mtc/mtc-copy.js +253 -0
  300. package/neural-interface/public/shared/mtc/mtc-logic.js +478 -0
  301. package/neural-interface/public/shared/mtc/mtc-panel.js +1354 -0
  302. package/neural-interface/public/shared/mtc/mtc-render.js +172 -0
  303. package/neural-interface/public/shared/mtc/mtc-styles.js +437 -0
  304. package/neural-interface/public/shared/ocp-v2/ocp-v2-automation-ownership.js +23 -0
  305. package/neural-interface/public/shared/ocp-v2/ocp-v2-events.js +13 -0
  306. package/neural-interface/public/shared/ocp-v2/ocp-v2-icons.js +3 -1
  307. package/neural-interface/public/shared/ocp-v2/ocp-v2-panel.js +10 -4
  308. package/neural-interface/public/shared/ocp-v2/ocp-v2-render.js +6 -86
  309. package/neural-interface/public/shared/ocp-v2/ocp-v2-ws.js +5 -2
  310. package/neural-interface/public/shared/owner-access.js +134 -0
  311. package/neural-interface/public/shared/owner-authority-view.js +92 -0
  312. package/neural-interface/public/shared/page-session.js +143 -14
  313. package/neural-interface/public/shared/poll-backoff.js +59 -0
  314. package/neural-interface/public/shared/provider-icons.js +3 -0
  315. package/neural-interface/public/shared/schedules-view.js +7 -0
  316. package/neural-interface/public/shared/server-back.js +50 -0
  317. package/neural-interface/public/shared/settings/settings-browser-owner-access.js +72 -0
  318. package/neural-interface/public/shared/settings/settings-data.js +7 -1
  319. package/neural-interface/public/shared/settings/settings-ia.js +3 -1
  320. package/neural-interface/public/shared/settings/settings-kit.js +11 -3
  321. package/neural-interface/public/shared/settings/settings-local-profiles.js +153 -0
  322. package/neural-interface/public/shared/settings/settings-maritaca-opencode.js +105 -0
  323. package/neural-interface/public/shared/settings/settings-shell.js +7 -0
  324. package/neural-interface/public/shared/shown-children.js +72 -0
  325. package/neural-interface/public/shared/sidepanel-session-status.js +16 -2
  326. package/neural-interface/public/shared/state.js +1 -1
  327. package/neural-interface/public/shared/static-bg-state.js +22 -0
  328. package/neural-interface/public/shared/styles.css +457 -164
  329. package/neural-interface/public/shared/synabun-mascot-assets.js +67 -0
  330. package/neural-interface/public/shared/synabun-mascot.js +136 -12
  331. package/neural-interface/public/shared/synabun-ticker.js +3 -0
  332. package/neural-interface/public/shared/synabun-tools.js +173 -0
  333. package/neural-interface/public/shared/tool-heartbeat.js +43 -0
  334. package/neural-interface/public/shared/tool-list-picker.js +3 -1
  335. package/neural-interface/public/shared/tool-list-view.js +23 -4
  336. package/neural-interface/public/shared/topright-overflow-logic.js +1 -0
  337. package/neural-interface/public/shared/ui-automation-approval.js +188 -0
  338. package/neural-interface/public/shared/ui-automation-studio.js +138 -91
  339. package/neural-interface/public/shared/ui-claude-panel.js +209 -31
  340. package/neural-interface/public/shared/ui-judgments.js +37 -10
  341. package/neural-interface/public/shared/ui-maritaca-panel.js +15 -0
  342. package/neural-interface/public/shared/ui-navbar.js +23 -0
  343. package/neural-interface/public/shared/ui-owner-access.js +191 -0
  344. package/neural-interface/public/shared/ui-owner-authority.js +162 -0
  345. package/neural-interface/public/shared/ui-panels.js +3 -1
  346. package/neural-interface/public/shared/ui-schedules-studio.js +118 -17
  347. package/neural-interface/public/shared/ui-scroll-follow.js +3 -0
  348. package/neural-interface/public/shared/ui-sessions.js +45 -16
  349. package/neural-interface/public/shared/ui-settings.js +676 -42
  350. package/neural-interface/public/shared/ui-sidepanel-session-entry.js +8 -2
  351. package/neural-interface/public/shared/ui-sidepanel-sessions.js +3 -3
  352. package/neural-interface/public/shared/ui-sidepanel-tray.js +24 -0
  353. package/neural-interface/public/shared/ui-sidepanel-windows.js +1 -1
  354. package/neural-interface/public/shared/ui-terminal.js +15 -7
  355. package/neural-interface/public/shared/ui-tutorial-preview.js +4 -0
  356. package/neural-interface/public/shared/ui-update.js +3 -0
  357. package/neural-interface/public/shared/ui-whiteboard.js +4 -0
  358. package/neural-interface/public/shared/window-keys.js +38 -0
  359. package/neural-interface/scripts/build-mascot-assets.mjs +30 -0
  360. package/neural-interface/server.js +2903 -359
  361. package/npm-shrinkwrap.json +5 -17
  362. package/package.json +5 -6
  363. package/postinstall.js +38 -39
  364. package/setup.js +33 -31
  365. package/skills/synabun/modules/changelog.md +14 -0
@@ -35,6 +35,7 @@ import {
35
35
  import {
36
36
  revertToMessage, restoreReverted, retryFromMessage, forkSession,
37
37
  } from './ocp-v2-session-actions.js';
38
+ import { synabunToolKey, synabunToolLabel, synabunToolSummary } from '../synabun-tools.js';
38
39
 
39
40
  const _expandedReasoningIds = new Set();
40
41
  const _activeRenderers = new Set();
@@ -748,62 +749,14 @@ function extractQuestionsFromToolInput(input) {
748
749
  // ── SynaBun MCP tool branding ────────────────────────────────────────────────
749
750
  const SYNABUN_LOGO_HTML = '<img src="logoHD.png" alt="" style="width:14px;height:14px;object-fit:contain;">';
750
751
 
751
- const SYNABUN_LABELS = {
752
- recall: 'Recall', remember: 'Remember', reflect: 'Reflect',
753
- forget: 'Forget', restore: 'Restore', memories: 'Memories', sync: 'Sync',
754
- category: 'Category', loop: 'Loop', git: 'Git', tictactoe: 'TicTacToe',
755
- image_staged: 'Images', profile: 'Profile',
756
- browser_navigate: 'Browser · Navigate', browser_screenshot: 'Browser · Screenshot', browser_console: 'Browser · Console',
757
- browser_snapshot: 'Browser · Snapshot', browser_content: 'Browser · Content',
758
- browser_click: 'Browser · Click', browser_type: 'Browser · Type',
759
- browser_fill: 'Browser · Fill', browser_hover: 'Browser · Hover',
760
- browser_select: 'Browser · Select', browser_press: 'Browser · Press',
761
- browser_scroll: 'Browser · Scroll', browser_wait: 'Browser · Wait',
762
- browser_go_back: 'Browser · Back', browser_go_forward: 'Browser · Forward',
763
- browser_reload: 'Browser · Reload', browser_evaluate: 'Browser · Evaluate',
764
- browser_upload: 'Browser · Upload', browser_session: 'Browser · Session',
765
- browser_cheatsheet: 'Browser · Cheatsheet',
766
- browser_extract_tweets: 'Extract · Tweets', browser_extract_fb_posts: 'Extract · Facebook',
767
- browser_fb_composer_state: 'Facebook · Composer', browser_extract_fb_groups: 'Extract · FB Groups',
768
- browser_extract_ig_feed: 'Extract · Instagram', browser_extract_ig_post: 'Extract · IG Post',
769
- browser_extract_ig_reels: 'Extract · IG Reels', browser_extract_ig_profile: 'Extract · IG Profile',
770
- browser_extract_ig_search: 'Extract · IG Search',
771
- browser_extract_tiktok_videos: 'Extract · TikTok', browser_extract_tiktok_search: 'Extract · TikTok Search',
772
- browser_extract_tiktok_studio: 'Extract · TikTok Studio', browser_extract_tiktok_profile: 'Extract · TikTok Profile',
773
- browser_extract_li_feed: 'Extract · LinkedIn', browser_extract_li_profile: 'Extract · LI Profile',
774
- browser_extract_li_post: 'Extract · LI Post', browser_extract_li_notifications: 'Extract · LI Notifications',
775
- browser_extract_li_messages: 'Extract · LI Messages', browser_extract_li_search_people: 'Extract · LI People',
776
- browser_extract_li_network: 'Extract · LI Network', browser_extract_li_jobs: 'Extract · LI Jobs',
777
- browser_extract_wa_chats: 'Extract · WhatsApp', browser_extract_wa_messages: 'Extract · WA Messages',
778
- bluesky_session: 'BlueSky · Session', bluesky_timeline: 'BlueSky · Timeline',
779
- bluesky_author_feed: 'BlueSky · Author Feed', bluesky_thread: 'BlueSky · Thread',
780
- bluesky_profile: 'BlueSky · Profile', bluesky_search_posts: 'BlueSky · Search Posts',
781
- bluesky_search_actors: 'BlueSky · Search Users', bluesky_notifications: 'BlueSky · Notifications',
782
- bluesky_graph: 'BlueSky · Graph', bluesky_likes: 'BlueSky · Likes', bluesky_feed: 'BlueSky · Feed',
783
- bluesky_post: 'BlueSky · Post', bluesky_action: 'BlueSky · Action',
784
- bluesky_resolve: 'BlueSky · Resolve', bluesky_dm: 'BlueSky · DM',
785
- whiteboard_read: 'Whiteboard · Read', whiteboard_add: 'Whiteboard · Add',
786
- whiteboard_update: 'Whiteboard · Update', whiteboard_remove: 'Whiteboard · Remove',
787
- whiteboard_screenshot: 'Whiteboard · Screenshot',
788
- card_list: 'Cards · List', card_open: 'Cards · Open', card_close: 'Cards · Close',
789
- card_update: 'Cards · Update', card_screenshot: 'Cards · Screenshot',
790
- discord_guild: 'Discord · Guild', discord_channel: 'Discord · Channel',
791
- discord_role: 'Discord · Role', discord_message: 'Discord · Message',
792
- discord_member: 'Discord · Member', discord_onboarding: 'Discord · Onboarding',
793
- discord_webhook: 'Discord · Webhook', discord_thread: 'Discord · Thread',
794
- };
795
-
752
+ // Which call is SynaBun's, its name and its one-line summary: synabun-tools.js, the same
753
+ // for every panel (`SynaBun_x` here, `mcp__SynaBun__x` from the others, any letter case).
796
754
  function isSynaBunTool(name) {
797
- return typeof name === 'string' && (name.startsWith('mcp__SynaBun__') || name.startsWith('SynaBun_'));
798
- }
799
-
800
- function synabunToolKey(name) {
801
- return (name || '').replace(/^mcp__SynaBun__/, '').replace(/^SynaBun_/, '');
755
+ return typeof name === 'string' && synabunToolKey(name) != null;
802
756
  }
803
757
 
804
758
  function synabunDisplayName(name) {
805
- const key = synabunToolKey(name);
806
- return SYNABUN_LABELS[key] || (key.charAt(0).toUpperCase() + key.slice(1).replace(/_/g, ' '));
759
+ return synabunToolLabel(synabunToolKey(name) || '');
807
760
  }
808
761
 
809
762
  function _truncate(s, n = 90) {
@@ -813,40 +766,7 @@ function _truncate(s, n = 90) {
813
766
 
814
767
  function synabunSummaryText(name, input) {
815
768
  if (!input || typeof input !== 'object') return '';
816
- const key = synabunToolKey(name);
817
- const t = (s) => _truncate(s, 90);
818
- switch (key) {
819
- case 'recall': return t(input.query);
820
- case 'remember': return t(input.content);
821
- case 'reflect': return t(input.content || input.memory_id);
822
- case 'forget':
823
- case 'restore': return t(input.memory_id);
824
- case 'memories': return t(input.action);
825
- case 'category': return t(`${input.action || ''}${input.name ? ' · ' + input.name : ''}`);
826
- case 'sync': return '';
827
- case 'git': return t(input.action);
828
- case 'loop': return t(`${input.action || ''}${input.prompt ? ' · ' + input.prompt : ''}`);
829
- case 'browser_navigate': return t(input.url);
830
- case 'browser_click':
831
- case 'browser_hover': return t(input.selector || input.label);
832
- case 'browser_type':
833
- case 'browser_fill': return t(input.text || input.value || input.selector);
834
- case 'browser_select': return t(input.value || input.selector);
835
- case 'browser_press': return t(input.key);
836
- case 'browser_scroll': return t(input.direction || input.selector);
837
- case 'browser_evaluate': return t(input.script);
838
- case 'browser_session': return t(input.action);
839
- case 'image_staged': return t(input.action);
840
- case 'discord_message': return t(input.content || input.action);
841
- case 'discord_channel':
842
- case 'discord_member':
843
- case 'discord_role': return t(input.action || input.name);
844
- case 'whiteboard_add':
845
- case 'whiteboard_update': return t(input.content || input.title);
846
- case 'card_open':
847
- case 'card_update': return t(input.title || input.id);
848
- default: return '';
849
- }
769
+ return synabunToolSummary(synabunToolKey(name) || '', input);
850
770
  }
851
771
 
852
772
  // Persist expand/collapse state across re-renders (render() rebuilds DOM).
@@ -12,8 +12,8 @@ import { createOutcomeNotifications } from './ocp-v2-outcome-notifications.js';
12
12
  import { getDefaultStore } from './ocp-v2-state.js';
13
13
  import { notify as uiNotify, NOTIF_TYPE } from '../ui-notifications.js';
14
14
  import { nativeLoopWindowId } from '../ui-native-window-id.js';
15
- import { registerAutomationSession } from './ocp-v2-automation-ownership.js';
16
- import { applyEvent, resolveEventTargets } from './ocp-v2-events.js';
15
+ import { registerAutomationSession, automationRunAnswersAsks } from './ocp-v2-automation-ownership.js';
16
+ import { applyEvent, resolveEventTargets, askNotifies } from './ocp-v2-events.js';
17
17
  import { createCapabilities, gatedRequest } from './ocp-v2-caps.js';
18
18
  import { shouldAutoAccept, autoAcceptRequest, autoAcceptInherited } from './ocp-v2-approvals.js';
19
19
  import { verifyDescendant, descendantState, knownDescendant, createReconnectNotifier, requestOwner } from './ocp-v2-rehydrate.js';
@@ -535,6 +535,9 @@ const EVENT_HOOKS = {
535
535
  onAsk(store, id, kind, ev) {
536
536
  if (!id || _notifiedPermissionIds.has(id)) return;
537
537
  _notifiedPermissionIds.add(id);
538
+ // A live automation answers its own session's permission asks by itself (a protected worker's
539
+ // OpenCode asks for every shell call): the card shows while the reply is out, nothing is announced.
540
+ if (!askNotifies(kind, ev, { runAnswers: automationRunAnswersAsks })) return;
538
541
  // Auto-accept is the user's standing answer for this session: reply and
539
542
  // stay quiet. A refused reply leaves the card up for them.
540
543
  if (kind === 'permission' && shouldAutoAccept(autoAcceptEnabledFor(store), ev)) {
@@ -0,0 +1,134 @@
1
+ // ═══════════════════════════════════════════
2
+ // SynaBun Neural Interface — a page without the owner's access: what it is and what it says
3
+ // ═══════════════════════════════════════════
4
+ //
5
+ // SynaBun's automation browser (the one its browser tools drive) may open SynaBun's own page, by design: it reads it,
6
+ // clicks it and takes screenshots. It never gets the owner's page secret (GET /api/page-session answers 403
7
+ // WORKER_BROWSER), so every owner route refuses it (403 WORKER_BROWSER, PAGE_SECRET_REQUIRED, OWNER_ROUTE). That
8
+ // refusal is right and stays. What this module is for is the page's side of it: a refused read is not an empty list,
9
+ // a default value or an "Off" state, and the page says so in one way everywhere (ui-owner-access.js draws it: one
10
+ // banner, and a "No access" state in the panels whose data was refused, their Save and actions disabled).
11
+ //
12
+ // page-session.js (the page's fetch, wrapped once) tells every final refusal (`synabun:owner-access-refused`); the
13
+ // panels that read through their own paths ask `refusalOfError` / `refusalOfResponse` about what they got.
14
+ //
15
+ // No DOM: `node --test` loads this file (tests/owner-access.test.mjs). OWNER_ACCESS_COPY is the English of every
16
+ // sentence; `ownerAccess.*` in i18n/en.json must equal it and i18n/pt-BR.json must have the same keys.
17
+
18
+ import { OWNER_ACCESS_CODES } from './page-session.js';
19
+
20
+ export { OWNER_ACCESS_CODES };
21
+
22
+ export const OWNER_ACCESS_COPY = Object.freeze({
23
+ label: 'No owner access',
24
+ title: 'This page doesn\'t have owner access.',
25
+ bodyAutomation: 'It was opened from SynaBun\'s automation browser, which can read SynaBun\'s pages but not your settings, files or actions. Open SynaBun in your own browser or the desktop app.',
26
+ bodyOwner: 'SynaBun refused this page your settings and actions. Reload the page; if it persists, open SynaBun in your own browser or the desktop app.',
27
+ reload: 'Reload',
28
+ dismiss: 'Dismiss',
29
+ panelTitle: 'No access',
30
+ panelBody: 'This page doesn\'t have owner access, so this can\'t be shown or changed here. Open SynaBun in your own browser or the desktop app.',
31
+ navStatus: 'No access',
32
+ actionDisabled: 'Needs owner access',
33
+ });
34
+
35
+ /** Why a page has no owner access: SynaBun's automation browser, or a refusal the page could not cure. */
36
+ export const OWNER_ACCESS_REASONS = Object.freeze(['automation', 'owner']);
37
+
38
+ /** The English of a key with its {values} filled; an unknown key is itself. */
39
+ export function ownerAccessText(key, params = {}) {
40
+ const template = OWNER_ACCESS_COPY[key];
41
+ if (typeof template !== 'string') return key;
42
+ return template.replace(/\{(\w+)\}/g, (whole, name) => (params[name] != null ? String(params[name]) : whole));
43
+ }
44
+
45
+ const reasonOf = (code) => (code === 'WORKER_BROWSER' ? 'automation' : 'owner');
46
+
47
+ /** A refusal from an answer's status and body: { code, reason } when it is a final owner refusal, else null. */
48
+ export function readOwnerAccessRefusal(status, body) {
49
+ if (Number(status) !== 403 || !body || typeof body !== 'object') return null;
50
+ const code = typeof body.code === 'string' ? body.code : null;
51
+ if (!code || !OWNER_ACCESS_CODES.includes(code)) return null;
52
+ return { code, reason: reasonOf(code) };
53
+ }
54
+
55
+ /**
56
+ * The refusal an error (or a read result) stands for: api.js / asst-api.js errors carry `status` and `code` (and
57
+ * `body`), a pane's own reading `{ ok: false, status, code }` too. null for anything else (a network error, a 500…).
58
+ */
59
+ export function refusalOfError(err) {
60
+ if (!err || typeof err !== 'object') return null;
61
+ const status = Number(err.status ?? err.statusCode);
62
+ const code = typeof err.code === 'string' ? err.code : (typeof err.body?.code === 'string' ? err.body.code : null);
63
+ return readOwnerAccessRefusal(status, { code });
64
+ }
65
+
66
+ /** The refusal a fetch Response stands for (its body read from a clone: the response is untouched). */
67
+ export async function refusalOfResponse(res) {
68
+ if (!res || Number(res.status) !== 403 || typeof res.clone !== 'function') return null;
69
+ try { return readOwnerAccessRefusal(res.status, await res.clone().json()); } catch { return null; }
70
+ }
71
+
72
+ /**
73
+ * What the page knows about its own access: null (nothing refused, or restored since) or { code, reason, url, at }.
74
+ * Once SynaBun's automation browser is named (WORKER_BROWSER) the reason stays `automation` whatever comes after: that
75
+ * is the one that explains the rest. `subscribe(fn)` is told every change (fn(current)); returns the unsubscribe.
76
+ */
77
+ export function createOwnerAccessState({ now = () => Date.now() } = {}) {
78
+ let current = null;
79
+ const listeners = new Set();
80
+ const tell = () => { for (const fn of [...listeners]) { try { fn(current); } catch { /* a listener's own error */ } } };
81
+ return {
82
+ current: () => current,
83
+ /** A refusal was seen (an event's detail or a refusal): true when what the page knows changed. */
84
+ note(detail) {
85
+ const code = typeof detail?.code === 'string' ? detail.code : null;
86
+ if (!code || !OWNER_ACCESS_CODES.includes(code)) return false;
87
+ const reason = current?.reason === 'automation' ? 'automation' : reasonOf(code);
88
+ if (current && current.reason === reason) return false;
89
+ current = { code, reason, url: typeof detail.url === 'string' ? detail.url : '', at: now() };
90
+ tell();
91
+ return true;
92
+ },
93
+ /** The page got this boot's page secret: it is the owner's again. */
94
+ clear() {
95
+ if (!current) return false;
96
+ current = null;
97
+ tell();
98
+ return true;
99
+ },
100
+ subscribe(fn) {
101
+ if (typeof fn !== 'function') return () => {};
102
+ listeners.add(fn);
103
+ return () => listeners.delete(fn);
104
+ },
105
+ };
106
+ }
107
+
108
+ /** A translator over OWNER_ACCESS_COPY: a key the page's translator does not know is English. */
109
+ export function ownerAccessSayer(t) {
110
+ return (key, params) => {
111
+ if (typeof t !== 'function') return ownerAccessText(key, params);
112
+ try {
113
+ const text = t(key, params);
114
+ return typeof text === 'string' && text && text !== key && !text.endsWith(`.${key}`) ? text : ownerAccessText(key, params);
115
+ } catch { return ownerAccessText(key, params); }
116
+ };
117
+ }
118
+
119
+ /**
120
+ * What the banner shows for what the page knows, or null (nothing refused).
121
+ * → { key, label, title, body, actions: [{ id: 'reload'|'dismiss', label }] }. `key` is what a dismissal is
122
+ * remembered by: the same reason stays dismissed.
123
+ */
124
+ export function ownerAccessNoticeView(refusal, { t = null } = {}) {
125
+ if (!refusal || !OWNER_ACCESS_REASONS.includes(refusal.reason)) return null;
126
+ const say = ownerAccessSayer(t);
127
+ return {
128
+ key: `owner-access:${refusal.reason}`,
129
+ label: say('label'),
130
+ title: say('title'),
131
+ body: say(refusal.reason === 'automation' ? 'bodyAutomation' : 'bodyOwner'),
132
+ actions: [{ id: 'reload', label: say('reload') }, { id: 'dismiss', label: say('dismiss') }],
133
+ };
134
+ }
@@ -0,0 +1,92 @@
1
+ // ═══════════════════════════════════════════
2
+ // SynaBun Neural Interface — the banner of a degraded owner authority: what it says
3
+ // ═══════════════════════════════════════════
4
+ //
5
+ // On macOS the server tells the owner's own page from every other local program by the process at the other end of
6
+ // the connection (lib/peer-identity.js). When it cannot look that process up (netstat or ps missing, denied because
7
+ // the server was started inside a sandbox, slow past its cap), it proves nothing about who is asking and pauses the
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
12
+ // server, listens and draws them. `unsupported` (Windows, Linux) and `off` (SYNABUN_PEER_IDENTITY=off) show nothing:
13
+ // there the rules from before apply and nothing is paused.
14
+ //
15
+ // No imports and no DOM: `node --test` loads this file as it is (tests/owner-authority-notice.test.mjs).
16
+ // OWNER_AUTHORITY_NOTICE_COPY is the English of every sentence; `ownerAuthorityNotice.*` in i18n/en.json must equal
17
+ // it and i18n/pt-BR.json must have the same keys.
18
+
19
+ export const OWNER_AUTHORITY_NOTICE_COPY = Object.freeze({
20
+ label: 'Owner actions paused',
21
+ title: 'SynaBun can\'t verify which program is calling it, so the owner\'s actions are paused.',
22
+ body: 'Settings, files, terminals, the agent panels and dispatching are refused until the check works again. Pages and memories still load.',
23
+ reason: 'Reason: {reason}',
24
+ hint: 'If this persists, start SynaBun outside any sandbox, or add SYNABUN_PEER_IDENTITY=off to ~/.synabun/.env and restart SynaBun (this turns the check off).',
25
+ reload: 'Reload to retry',
26
+ dismiss: 'Dismiss',
27
+ });
28
+
29
+ /** The states GET /api/health can name (lib/peer-identity.js authorityState). */
30
+ export const OWNER_AUTHORITY_STATES = Object.freeze(['ok', 'degraded', 'unsupported', 'off']);
31
+ /** The longest reason the banner shows (the server's reasons are short; a longer one is cut). */
32
+ export const REASON_MAX = 200;
33
+
34
+ /** A sentence of OWNER_AUTHORITY_NOTICE_COPY in English with its {values} filled; an unknown key is itself. */
35
+ export function ownerAuthorityText(key, params = {}) {
36
+ const template = OWNER_AUTHORITY_NOTICE_COPY[key];
37
+ if (typeof template !== 'string') return key;
38
+ return template.replace(/\{(\w+)\}/g, (whole, name) => (params[name] != null ? String(params[name]) : whole));
39
+ }
40
+
41
+ const cleanReason = (value) => {
42
+ const text = typeof value === 'string' ? value.replace(/\s+/g, ' ').trim() : '';
43
+ return text.length > REASON_MAX ? `${text.slice(0, REASON_MAX - 1)}…` : text;
44
+ };
45
+
46
+ /**
47
+ * The owner authority a GET /api/health answer reports, or null (an older server says nothing, a body that is not
48
+ * one): { state, reason, retryable, since }.
49
+ */
50
+ export function readOwnerAuthority(health) {
51
+ const raw = health && typeof health === 'object' ? health.ownerAuthority : null;
52
+ if (!raw || typeof raw !== 'object' || !OWNER_AUTHORITY_STATES.includes(raw.state)) return null;
53
+ return {
54
+ state: raw.state,
55
+ reason: cleanReason(raw.reason) || null,
56
+ retryable: raw.retryable === true,
57
+ since: typeof raw.since === 'string' ? raw.since : null,
58
+ };
59
+ }
60
+
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
+ /**
67
+ * What the banner shows for a state, or null when it shows nothing (ok, unsupported, off, nothing known).
68
+ * `t(key, params)` is the page's translator for `ownerAuthorityNotice.*` (English by default).
69
+ * → { key, label, title, body, reason, hint, actions: [{ id: 'reload'|'dismiss', label }] }. `key` is what a
70
+ * dismissal is remembered by: the same outage stays dismissed, a new reason shows again.
71
+ */
72
+ export function ownerAuthorityNoticeView(authority, { t = ownerAuthorityText } = {}) {
73
+ if (!authority || authority.state !== 'degraded') return null;
74
+ // (a translator that does not know a key answers the key itself, short or as its whole path: English then)
75
+ const say = (key, params) => {
76
+ try {
77
+ const text = t(key, params);
78
+ return typeof text === 'string' && text && text !== key && !text.endsWith(`.${key}`) ? text : ownerAuthorityText(key, params);
79
+ } catch { return ownerAuthorityText(key, params); }
80
+ };
81
+ const reason = cleanReason(authority.reason);
82
+ return {
83
+ key: `degraded:${reason || 'unknown'}`,
84
+ label: say('label'),
85
+ title: say('title'),
86
+ body: say('body'),
87
+ reason: reason ? say('reason', { reason }) : '',
88
+ // A failure that may pass by itself (a timeout) is what a reload cures; one that does not needs the way out.
89
+ hint: authority.retryable ? '' : say('hint'),
90
+ actions: [{ id: 'reload', label: say('reload') }, { id: 'dismiss', label: say('dismiss') }],
91
+ };
92
+ }
@@ -10,17 +10,51 @@
10
10
  // page's fetch once: when a same-origin write is refused with one of those two codes, it asks GET /api/page-session
11
11
  // (which sets this boot's cookie), then sends the very same request once more and hands back that answer. No
12
12
  // reload, no toast (the toast fires on the error jsonFetch throws, and it throws only on the final answer), no lost
13
- // action. Anything else (a read, another 403, a refusal the refresh did not cure, a body that cannot be sent
14
- // twice) is handed back as it came, so nothing changes for a request this is not about.
13
+ // action. A read is recovered the same way when it is refused 403 PAGE_SECRET_REQUIRED: since 2026-11-04 the browser
14
+ // routes (/api/browser/*) ask every request of the page for this boot's secret, reads included, so the browser panel
15
+ // and the browser settings keep working across a restart. Anything else (a read refused UI_ONLY, another 403, a refusal
16
+ // the refresh did not cure, a body that cannot be sent twice) is handed back as it came, so nothing changes for a
17
+ // request this is not about. refreshPageSession() asks for this boot's cookie by itself (one request at a time): the
18
+ // browser panel calls it before it opens its socket again, because a WebSocket refused for a stale cookie never says why.
15
19
  //
16
20
  // No imports and nothing done at load under Node: tests load it with node --test and a fake fetch. In a browser it
17
21
  // installs itself on window.fetch when the page loads it (index.html, index2d.html and sidepanel-session.html load
18
22
  // it as their first module script, before any module that writes), and once only.
23
+ //
24
+ // 503 PEER_UNAVAILABLE is something else: the server could not tell which program sent the request (macOS, its
25
+ // lookup of the calling process failed: lib/peer-identity.js), so it hands out no page secret and refuses the owner's
26
+ // actions until a lookup works again. Nothing here cures that, so nothing is retried: the answer goes back as it came,
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
29
+ // again for a few seconds: a burst of refused writes costs the server one lookup, not one each.
30
+ //
31
+ // A refusal nothing here cures (403 WORKER_BROWSER, OWNER_ROUTE, or PAGE_SECRET_REQUIRED the refresh did not cure) is
32
+ // the page not having the owner's access at all: SynaBun's automation browser opened it, by design. The answer still
33
+ // goes back as it came; the page is told (`synabun:owner-access-refused` on the window, which ui-owner-access.js turns
34
+ // into one banner and each panel into "No access" instead of an empty list or default values). A refresh that gets
35
+ // this boot's secret is told too (`synabun:owner-access-restored`).
19
36
 
20
37
  /** The route that hands an open tab this boot's cookie (lib/page-session.js PAGE_SECRET_REFRESH_PATH). */
21
38
  export const PAGE_SECRET_REFRESH_PATH = '/api/page-session';
22
39
  /** The refusals that mean "the page secret is missing or stale", and nothing else. */
23
40
  export const PAGE_SECRET_CODES = Object.freeze(['UI_ONLY', 'PAGE_SECRET_REQUIRED']);
41
+ /** The answer that means "the server could not identify the caller" (lib/owner-authority.js PEER_UNAVAILABLE). */
42
+ export const PEER_UNAVAILABLE_CODE = 'PEER_UNAVAILABLE';
43
+ /** The window event a 503 PEER_UNAVAILABLE becomes (detail: { reason, retryable, error, url, method }). */
44
+ export const PEER_UNAVAILABLE_EVENT = 'synabun:peer-unavailable';
45
+ /** How long a refresh that met 503 PEER_UNAVAILABLE is not asked again. */
46
+ export const REFRESH_COOLDOWN_MS = 5000;
47
+ /**
48
+ * The final refusals that mean "this page does not have the owner's access" (after any recovery here was tried):
49
+ * WORKER_BROWSER (SynaBun's automation browser: never the owner), PAGE_SECRET_REQUIRED (no secret, and the refresh
50
+ * did not cure it), OWNER_ROUTE (a route the owner's page only reaches). Told once per answer to `onRefused`, which
51
+ * the window turns into OWNER_ACCESS_REFUSED_EVENT (ui-owner-access.js: the banner and the panels' "No access").
52
+ */
53
+ export const OWNER_ACCESS_CODES = Object.freeze(['WORKER_BROWSER', 'PAGE_SECRET_REQUIRED', 'OWNER_ROUTE']);
54
+ /** The window event a final owner refusal becomes (detail: { code, url, method, status }). */
55
+ export const OWNER_ACCESS_REFUSED_EVENT = 'synabun:owner-access-refused';
56
+ /** The window event a refresh that got this boot's page secret becomes (detail: {}): the page is the owner's again. */
57
+ export const OWNER_ACCESS_RESTORED_EVENT = 'synabun:owner-access-restored';
24
58
  const SAFE_METHODS = new Set(['GET', 'HEAD', 'OPTIONS']);
25
59
 
26
60
  /** Whether an answer is the server refusing a write for want of this boot's page secret. */
@@ -28,6 +62,16 @@ export function isPageSecretRefusal(status, body) {
28
62
  return Number(status) === 403 && !!body && typeof body === 'object' && PAGE_SECRET_CODES.includes(body.code);
29
63
  }
30
64
 
65
+ /** Whether an answer is a final refusal of the owner's access (403 with one of OWNER_ACCESS_CODES). */
66
+ export function isOwnerAccessRefusal(status, body) {
67
+ return Number(status) === 403 && !!body && typeof body === 'object' && OWNER_ACCESS_CODES.includes(body.code);
68
+ }
69
+
70
+ /** Whether an answer is the server saying it could not identify the caller (never retried here). */
71
+ export function isPeerUnavailable(status, body) {
72
+ return Number(status) === 503 && !!body && typeof body === 'object' && body.code === PEER_UNAVAILABLE_CODE;
73
+ }
74
+
31
75
  /**
32
76
  * What a request is, for the retry: its method, whether it is same-origin, and the arguments that send it again,
33
77
  * or null when it is not a write, goes elsewhere, or cannot be sent twice (a streamed body).
@@ -45,52 +89,137 @@ export function replayPlan(input, init, origin = null) {
45
89
  return { method, url, args: init === undefined ? [again] : [again, init] };
46
90
  }
47
91
 
92
+ /** The same for a read (GET / HEAD of this origin): sent again only when it was refused for the page secret. */
93
+ export function readReplayPlan(input, init, origin = null) {
94
+ const isRequest = typeof Request !== 'undefined' && input instanceof Request;
95
+ const method = String(init?.method || (isRequest ? input.method : '') || 'GET').toUpperCase();
96
+ if (method !== 'GET' && method !== 'HEAD') return null;
97
+ const url = isRequest ? input.url : (input instanceof URL ? input.href : String(input ?? ''));
98
+ if (!sameOrigin(url, origin)) return null;
99
+ const again = isRequest ? input.clone() : input;
100
+ return { method, url, read: true, args: init === undefined ? [again] : [again, init] };
101
+ }
102
+
48
103
  function sameOrigin(url, origin) {
49
104
  if (!/^[a-z][a-z0-9+.-]*:/i.test(url) && !url.startsWith('//')) return true; // a path of this page
50
105
  if (!origin) return false;
51
106
  try { return new URL(url).origin === new URL(origin).origin; } catch { return false; }
52
107
  }
53
108
 
109
+ /** A request's URL and method as given to fetch (for the event's detail). */
110
+ function describeRequest(input, init) {
111
+ const isRequest = typeof Request !== 'undefined' && input instanceof Request;
112
+ const method = String(init?.method || (isRequest ? input.method : '') || 'GET').toUpperCase();
113
+ const url = isRequest ? input.url : (input instanceof URL ? input.href : String(input ?? ''));
114
+ return { method, url };
115
+ }
116
+
54
117
  /**
55
118
  * A fetch over `fetchImpl` that recovers the page secret once: the refresh is one request at a time (writes refused
56
119
  * together share it), the refused request is sent again only when the refresh answered, and the second answer is
57
- * final whatever it says.
120
+ * final whatever it says. A 503 PEER_UNAVAILABLE (a write's, a read's, or the refresh's) is never retried: it is handed
121
+ * back as it came and told to `onUnavailable` ({ reason, retryable, error, url, method }); after the refresh met one,
122
+ * refused writes are handed back without a refresh for `cooldownMs`.
58
123
  */
59
- export function createPageSessionFetch(fetchImpl, { refreshPath = PAGE_SECRET_REFRESH_PATH, origin = null, onRecover = null } = {}) {
124
+ export function createPageSessionFetch(fetchImpl, { refreshPath = PAGE_SECRET_REFRESH_PATH, origin = null, onRecover = null, onUnavailable = null, onRefused = null, onRestored = null, cooldownMs = REFRESH_COOLDOWN_MS, now = () => Date.now() } = {}) {
60
125
  if (typeof fetchImpl !== 'function') throw new TypeError('createPageSessionFetch needs a fetch');
61
126
  let refreshing = null;
127
+ let quietUntil = 0;
128
+ const tell = (body, request) => {
129
+ try { onUnavailable?.({ reason: typeof body?.reason === 'string' ? body.reason : '', retryable: body?.retryable === true, error: typeof body?.error === 'string' ? body.error : '', url: request.url, method: request.method }); } catch { /* a listener's own error */ }
130
+ };
131
+ const tellRefused = (body, request, status = 403) => {
132
+ try { onRefused?.({ code: body.code, url: request.url, method: request.method, status }); } catch { /* a listener's own error */ }
133
+ };
134
+ /** Read a 403 answer's body and tell it when it is a final owner refusal (the answer itself is untouched). */
135
+ async function noteRefused(res, request) {
136
+ if (!onRefused || !res || res.status !== 403 || typeof res.clone !== 'function') return res;
137
+ let body = null;
138
+ try { body = await res.clone().json(); } catch { return res; }
139
+ if (isOwnerAccessRefusal(res.status, body)) tellRefused(body, request);
140
+ return res;
141
+ }
142
+ /** Read a 503 answer's body and tell it when it is PEER_UNAVAILABLE (the answer itself is untouched). */
143
+ async function noteUnavailable(res, request) {
144
+ if (!res || res.status !== 503 || typeof res.clone !== 'function') return false;
145
+ let body = null;
146
+ try { body = await res.clone().json(); } catch { return false; }
147
+ if (!isPeerUnavailable(res.status, body)) return false;
148
+ tell(body, request);
149
+ return true;
150
+ }
62
151
  function refreshCookie() {
152
+ if (now() < quietUntil) return Promise.resolve(false);
63
153
  if (!refreshing) {
64
154
  refreshing = (async () => {
65
155
  try {
66
156
  const res = await fetchImpl(refreshPath, { method: 'GET', credentials: 'same-origin', cache: 'no-store', headers: { Accept: 'application/json' } });
67
- return !!res && res.ok === true;
157
+ if (await noteUnavailable(res, { url: refreshPath, method: 'GET' })) { quietUntil = now() + Math.max(0, Number(cooldownMs) || 0); return false; }
158
+ if (res && res.ok === true) { try { onRestored?.(); } catch { /* a listener's own error */ } return true; }
159
+ // The server refusing this page the secret itself (403 WORKER_BROWSER: the automation browser) is told too.
160
+ await noteRefused(res, { url: refreshPath, method: 'GET' });
161
+ return false;
68
162
  } catch { return false; } finally { refreshing = null; }
69
163
  })();
70
164
  }
71
165
  return refreshing;
72
166
  }
73
- return async function pageSessionFetch(input, init) {
74
- const plan = replayPlan(input, init, origin);
167
+ async function pageSessionFetch(input, init) {
168
+ const plan = replayPlan(input, init, origin) || readReplayPlan(input, init, origin);
169
+ const request = describeRequest(input, init);
75
170
  const res = await fetchImpl(input, init);
76
- if (!plan || !res || res.status !== 403 || typeof res.clone !== 'function') return res;
171
+ if (res && res.status === 503) { await noteUnavailable(res, request); return res; }
172
+ if (!plan || !res || res.status !== 403 || typeof res.clone !== 'function') return noteRefused(res, request);
77
173
  let body = null;
78
174
  try { body = await res.clone().json(); } catch { return res; }
79
- if (!isPageSecretRefusal(res.status, body)) return res;
80
- if (!(await refreshCookie())) return res;
175
+ if (!isPageSecretRefusal(res.status, body)) { if (isOwnerAccessRefusal(res.status, body)) tellRefused(body, request); return res; }
176
+ // A read is the page secret's business only when it says so (the browser routes): UI_ONLY on a read is handed back.
177
+ if (plan.read && body.code !== 'PAGE_SECRET_REQUIRED') return res;
178
+ if (!(await refreshCookie())) { if (isOwnerAccessRefusal(res.status, body)) tellRefused(body, request); return res; }
81
179
  try { onRecover?.({ method: plan.method, url: plan.url, code: body.code }); } catch { /* a listener's own error */ }
82
- return fetchImpl(...plan.args);
83
- };
180
+ const again = await fetchImpl(...plan.args);
181
+ if (again && again.status === 503) await noteUnavailable(again, { url: plan.url, method: plan.method });
182
+ return noteRefused(again, { url: plan.url, method: plan.method });
183
+ }
184
+ // The refresh by itself (one at a time, the same cooldown): true when the server handed this boot's cookie.
185
+ pageSessionFetch.refreshPageSession = () => refreshCookie();
186
+ return pageSessionFetch;
84
187
  }
85
188
 
86
- /** Wrap `target.fetch` (the window's) once; returns true when it did, false when it already had or there is none. */
189
+ /** Wrap `target.fetch` (the window's) once; returns true when it did, false when it already had or there is none.
190
+ * A 503 PEER_UNAVAILABLE is dispatched on `target` as PEER_UNAVAILABLE_EVENT, a final owner refusal as
191
+ * OWNER_ACCESS_REFUSED_EVENT and a refresh that got the secret as OWNER_ACCESS_RESTORED_EVENT (when it can dispatch). */
87
192
  export function installPageSessionRecovery(target = globalThis) {
88
193
  if (!target || typeof target.fetch !== 'function' || target.__synabunPageSession) return false;
89
194
  const original = target.fetch.bind(target);
90
195
  const origin = target.location && typeof target.location.origin === 'string' ? target.location.origin : null;
91
- target.fetch = createPageSessionFetch(original, { origin });
196
+ const dispatch = (name, detail) => {
197
+ if (typeof target.dispatchEvent !== 'function' || typeof CustomEvent === 'undefined') return;
198
+ target.dispatchEvent(new CustomEvent(name, { detail }));
199
+ };
200
+ const onUnavailable = (detail) => dispatch(PEER_UNAVAILABLE_EVENT, detail);
201
+ // The last refusal is kept on the window too, for a module that listens only after it was told.
202
+ const onRefused = (detail) => { try { target.__synabunOwnerAccessRefused = detail; } catch { /* a frozen target */ } dispatch(OWNER_ACCESS_REFUSED_EVENT, detail); };
203
+ const onRestored = () => { try { delete target.__synabunOwnerAccessRefused; } catch { /* a frozen target */ } dispatch(OWNER_ACCESS_RESTORED_EVENT, {}); };
204
+ target.fetch = createPageSessionFetch(original, { origin, onUnavailable, onRefused, onRestored });
92
205
  try { Object.defineProperty(target, '__synabunPageSession', { value: true, configurable: true }); } catch { target.__synabunPageSession = true; }
93
206
  return true;
94
207
  }
95
208
 
209
+ /**
210
+ * Ask for this boot's page secret now (GET /api/page-session through the installed recovery: one request at a time,
211
+ * none during a cooldown after a 503). Resolves true when the server handed it, false otherwise; never rejects. For a
212
+ * socket the browser opens by itself (the browser panel's /ws/browser/:id), whose refusal for a stale cookie the page
213
+ * cannot read.
214
+ */
215
+ export async function refreshPageSession(target = globalThis) {
216
+ try {
217
+ const refresh = target?.fetch?.refreshPageSession;
218
+ if (typeof refresh === 'function') return (await refresh()) === true;
219
+ if (typeof target?.fetch !== 'function') return false;
220
+ const res = await target.fetch(PAGE_SECRET_REFRESH_PATH, { method: 'GET', credentials: 'same-origin', cache: 'no-store', headers: { Accept: 'application/json' } });
221
+ return !!res && res.ok === true;
222
+ } catch { return false; }
223
+ }
224
+
96
225
  if (typeof window !== 'undefined' && typeof document !== 'undefined') installPageSessionRecovery(window);