synabun 2.2.2 → 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 (276) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +1 -1
  3. package/docs/whatsapp.md +52 -20
  4. package/lib/mcp-build.js +519 -0
  5. package/lib/mcp-dist.js +10 -4
  6. package/lib/server-supervisor.js +7 -1
  7. package/lib/virustotal.mjs +4 -2
  8. package/mcp-server/dist/http.d.ts +38 -0
  9. package/mcp-server/dist/http.d.ts.map +1 -1
  10. package/mcp-server/dist/http.js +75 -7
  11. package/mcp-server/dist/http.js.map +1 -1
  12. package/mcp-server/dist/services/browser-route-flow.d.ts +3 -2
  13. package/mcp-server/dist/services/browser-route-flow.d.ts.map +1 -1
  14. package/mcp-server/dist/services/browser-route-flow.js +4 -3
  15. package/mcp-server/dist/services/browser-route-flow.js.map +1 -1
  16. package/mcp-server/dist/services/embedding-service.d.ts.map +1 -1
  17. package/mcp-server/dist/services/embedding-service.js +2 -1
  18. package/mcp-server/dist/services/embedding-service.js.map +1 -1
  19. package/mcp-server/dist/services/neural-interface.d.ts +21 -0
  20. package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
  21. package/mcp-server/dist/services/neural-interface.js +76 -4
  22. package/mcp-server/dist/services/neural-interface.js.map +1 -1
  23. package/mcp-server/dist/services/tool-catalog.js +2 -2
  24. package/mcp-server/dist/services/tool-catalog.js.map +1 -1
  25. package/mcp-server/dist/tools/agents.d.ts +3 -2
  26. package/mcp-server/dist/tools/agents.d.ts.map +1 -1
  27. package/mcp-server/dist/tools/agents.js +6 -4
  28. package/mcp-server/dist/tools/agents.js.map +1 -1
  29. package/mcp-server/dist/tools/browser-advanced.d.ts +3 -1
  30. package/mcp-server/dist/tools/browser-advanced.d.ts.map +1 -1
  31. package/mcp-server/dist/tools/browser-advanced.js +30 -8
  32. package/mcp-server/dist/tools/browser-advanced.js.map +1 -1
  33. package/mcp-server/dist/tools/browser-navigate.d.ts +3 -3
  34. package/mcp-server/dist/tools/browser-navigate.d.ts.map +1 -1
  35. package/mcp-server/dist/tools/browser-navigate.js +19 -16
  36. package/mcp-server/dist/tools/browser-navigate.js.map +1 -1
  37. package/mcp-server/dist/tools/browser-observe.d.ts +2 -1
  38. package/mcp-server/dist/tools/browser-observe.d.ts.map +1 -1
  39. package/mcp-server/dist/tools/browser-observe.js +61 -20
  40. package/mcp-server/dist/tools/browser-observe.js.map +1 -1
  41. package/mcp-server/dist/tools/morelogin.d.ts +13 -3
  42. package/mcp-server/dist/tools/morelogin.d.ts.map +1 -1
  43. package/mcp-server/dist/tools/morelogin.js +81 -20
  44. package/mcp-server/dist/tools/morelogin.js.map +1 -1
  45. package/mcp-server/dist/tools/youtube/upload.d.ts.map +1 -1
  46. package/mcp-server/dist/tools/youtube/upload.js +225 -88
  47. package/mcp-server/dist/tools/youtube/upload.js.map +1 -1
  48. package/mcp-server/package-lock.json +2 -2
  49. package/mcp-server/package.json +1 -1
  50. package/mcp-server/src/http.ts +79 -7
  51. package/mcp-server/src/services/browser-route-flow.ts +4 -3
  52. package/mcp-server/src/services/embedding-service.ts +2 -1
  53. package/mcp-server/src/services/neural-interface.ts +77 -4
  54. package/mcp-server/src/services/tool-catalog.ts +2 -2
  55. package/mcp-server/src/tools/agents.ts +8 -4
  56. package/mcp-server/src/tools/browser-advanced.ts +29 -8
  57. package/mcp-server/src/tools/browser-navigate.ts +19 -16
  58. package/mcp-server/src/tools/browser-observe.ts +62 -20
  59. package/mcp-server/src/tools/morelogin.ts +81 -20
  60. package/mcp-server/src/tools/youtube/upload.ts +218 -99
  61. package/neural-interface/i18n/en.json +631 -123
  62. package/neural-interface/i18n/pt-BR.json +518 -10
  63. package/neural-interface/lib/assistant-api.js +26 -0
  64. package/neural-interface/lib/assistant-brains/claude.js +5 -0
  65. package/neural-interface/lib/assistant-catalog.js +114 -1
  66. package/neural-interface/lib/assistant-dispatch.js +71 -1
  67. package/neural-interface/lib/assistant-persona.js +14 -7
  68. package/neural-interface/lib/assistant-router.js +6 -4
  69. package/neural-interface/lib/assistant-runtime.js +3 -0
  70. package/neural-interface/lib/assistant-task-prompt.js +5 -0
  71. package/neural-interface/lib/automation-approval.js +249 -0
  72. package/neural-interface/lib/automation-browser-owner-access.js +82 -0
  73. package/neural-interface/lib/backup-service.js +16 -1
  74. package/neural-interface/lib/browser-background-tab.js +72 -3
  75. package/neural-interface/lib/browser-extraction.js +106 -45
  76. package/neural-interface/lib/browser-profile-choices.js +143 -0
  77. package/neural-interface/lib/browser-profiles.js +142 -0
  78. package/neural-interface/lib/browser-tab-recovery.js +153 -0
  79. package/neural-interface/lib/browser-tool-policy.js +2 -0
  80. package/neural-interface/lib/chromium-on-device-model.js +67 -0
  81. package/neural-interface/lib/claude-agent-bridge.js +7 -4
  82. package/neural-interface/lib/claude-model-catalog.js +12 -0
  83. package/neural-interface/lib/effort-levels.js +28 -2
  84. package/neural-interface/lib/local-profile-proxy.js +362 -0
  85. package/neural-interface/lib/local-profiles.js +929 -0
  86. package/neural-interface/lib/loop-logger.js +25 -4
  87. package/neural-interface/lib/maritaca/api.js +179 -0
  88. package/neural-interface/lib/maritaca/attachments.js +44 -0
  89. package/neural-interface/lib/maritaca/client.js +362 -0
  90. package/neural-interface/lib/maritaca/key-store.js +122 -0
  91. package/neural-interface/lib/maritaca/models.js +181 -0
  92. package/neural-interface/lib/maritaca/modes.js +39 -0
  93. package/neural-interface/lib/maritaca/opencode-proxy.js +236 -0
  94. package/neural-interface/lib/maritaca/opencode-stream.js +345 -0
  95. package/neural-interface/lib/maritaca/opencode.js +218 -0
  96. package/neural-interface/lib/maritaca/panel-bridge.js +273 -0
  97. package/neural-interface/lib/maritaca/sessions.js +198 -0
  98. package/neural-interface/lib/morelogin-agent-profiles.js +149 -0
  99. package/neural-interface/lib/morelogin.js +278 -14
  100. package/neural-interface/lib/native-loop-providers.js +3 -1
  101. package/neural-interface/lib/owner-authority.js +30 -12
  102. package/neural-interface/lib/page-session.js +43 -17
  103. package/neural-interface/lib/request-gate.js +2 -0
  104. package/neural-interface/lib/system-activity.js +1 -1
  105. package/neural-interface/lib/terminal-tokens.js +82 -5
  106. package/neural-interface/package-lock.json +3 -2
  107. package/neural-interface/package.json +2 -1
  108. package/neural-interface/public/assets/mascot/README.md +11 -0
  109. package/neural-interface/public/assets/mascot/ask.gif +0 -0
  110. package/neural-interface/public/assets/mascot/ask.png +0 -0
  111. package/neural-interface/public/assets/mascot/blocked.gif +0 -0
  112. package/neural-interface/public/assets/mascot/blocked.png +0 -0
  113. package/neural-interface/public/assets/mascot/budget.gif +0 -0
  114. package/neural-interface/public/assets/mascot/budget.png +0 -0
  115. package/neural-interface/public/assets/mascot/computer.gif +0 -0
  116. package/neural-interface/public/assets/mascot/computer.png +0 -0
  117. package/neural-interface/public/assets/mascot/edit.gif +0 -0
  118. package/neural-interface/public/assets/mascot/edit.png +0 -0
  119. package/neural-interface/public/assets/mascot/error.gif +0 -0
  120. package/neural-interface/public/assets/mascot/error.png +0 -0
  121. package/neural-interface/public/assets/mascot/hover-attention.gif +0 -0
  122. package/neural-interface/public/assets/mascot/hover-attention.png +0 -0
  123. package/neural-interface/public/assets/mascot/idle-hero.gif +0 -0
  124. package/neural-interface/public/assets/mascot/idle-hero.png +0 -0
  125. package/neural-interface/public/assets/mascot/idle.gif +0 -0
  126. package/neural-interface/public/assets/mascot/idle.png +0 -0
  127. package/neural-interface/public/assets/mascot/manifest.json +254 -0
  128. package/neural-interface/public/assets/mascot/mcp.gif +0 -0
  129. package/neural-interface/public/assets/mascot/mcp.png +0 -0
  130. package/neural-interface/public/assets/mascot/memory.gif +0 -0
  131. package/neural-interface/public/assets/mascot/memory.png +0 -0
  132. package/neural-interface/public/assets/mascot/offline.gif +0 -0
  133. package/neural-interface/public/assets/mascot/offline.png +0 -0
  134. package/neural-interface/public/assets/mascot/pick.gif +0 -0
  135. package/neural-interface/public/assets/mascot/pick.png +0 -0
  136. package/neural-interface/public/assets/mascot/plan.gif +0 -0
  137. package/neural-interface/public/assets/mascot/plan.png +0 -0
  138. package/neural-interface/public/assets/mascot/present.gif +0 -0
  139. package/neural-interface/public/assets/mascot/present.png +0 -0
  140. package/neural-interface/public/assets/mascot/project.gif +0 -0
  141. package/neural-interface/public/assets/mascot/project.png +0 -0
  142. package/neural-interface/public/assets/mascot/read.gif +0 -0
  143. package/neural-interface/public/assets/mascot/read.png +0 -0
  144. package/neural-interface/public/assets/mascot/runs.gif +0 -0
  145. package/neural-interface/public/assets/mascot/runs.png +0 -0
  146. package/neural-interface/public/assets/mascot/scenes/automation.gif +0 -0
  147. package/neural-interface/public/assets/mascot/scenes/automation.png +0 -0
  148. package/neural-interface/public/assets/mascot/scenes/browser.gif +0 -0
  149. package/neural-interface/public/assets/mascot/scenes/browser.png +0 -0
  150. package/neural-interface/public/assets/mascot/scenes/code.gif +0 -0
  151. package/neural-interface/public/assets/mascot/scenes/code.png +0 -0
  152. package/neural-interface/public/assets/mascot/scenes/complex.gif +0 -0
  153. package/neural-interface/public/assets/mascot/scenes/complex.png +0 -0
  154. package/neural-interface/public/assets/mascot/scenes/computer.gif +0 -0
  155. package/neural-interface/public/assets/mascot/scenes/computer.png +0 -0
  156. package/neural-interface/public/assets/mascot/scenes/design.gif +0 -0
  157. package/neural-interface/public/assets/mascot/scenes/design.png +0 -0
  158. package/neural-interface/public/assets/mascot/scenes/edit.gif +0 -0
  159. package/neural-interface/public/assets/mascot/scenes/edit.png +0 -0
  160. package/neural-interface/public/assets/mascot/scenes/generic.gif +0 -0
  161. package/neural-interface/public/assets/mascot/scenes/generic.png +0 -0
  162. package/neural-interface/public/assets/mascot/scenes/image_gen.gif +0 -0
  163. package/neural-interface/public/assets/mascot/scenes/image_gen.png +0 -0
  164. package/neural-interface/public/assets/mascot/scenes/manifest.json +173 -0
  165. package/neural-interface/public/assets/mascot/scenes/memory.gif +0 -0
  166. package/neural-interface/public/assets/mascot/scenes/memory.png +0 -0
  167. package/neural-interface/public/assets/mascot/scenes/quick.gif +0 -0
  168. package/neural-interface/public/assets/mascot/scenes/quick.png +0 -0
  169. package/neural-interface/public/assets/mascot/scenes/read.gif +0 -0
  170. package/neural-interface/public/assets/mascot/scenes/read.png +0 -0
  171. package/neural-interface/public/assets/mascot/scenes/research.gif +0 -0
  172. package/neural-interface/public/assets/mascot/scenes/research.png +0 -0
  173. package/neural-interface/public/assets/mascot/scenes/review.gif +0 -0
  174. package/neural-interface/public/assets/mascot/scenes/review.png +0 -0
  175. package/neural-interface/public/assets/mascot/scenes/search.gif +0 -0
  176. package/neural-interface/public/assets/mascot/scenes/search.png +0 -0
  177. package/neural-interface/public/assets/mascot/scenes/shell.gif +0 -0
  178. package/neural-interface/public/assets/mascot/scenes/shell.png +0 -0
  179. package/neural-interface/public/assets/mascot/scenes/thinking.gif +0 -0
  180. package/neural-interface/public/assets/mascot/scenes/thinking.png +0 -0
  181. package/neural-interface/public/assets/mascot/scenes/video_gen.gif +0 -0
  182. package/neural-interface/public/assets/mascot/scenes/video_gen.png +0 -0
  183. package/neural-interface/public/assets/mascot/scenes/web.gif +0 -0
  184. package/neural-interface/public/assets/mascot/scenes/web.png +0 -0
  185. package/neural-interface/public/assets/mascot/search.gif +0 -0
  186. package/neural-interface/public/assets/mascot/search.png +0 -0
  187. package/neural-interface/public/assets/mascot/shell.gif +0 -0
  188. package/neural-interface/public/assets/mascot/shell.png +0 -0
  189. package/neural-interface/public/assets/mascot/skill.gif +0 -0
  190. package/neural-interface/public/assets/mascot/skill.png +0 -0
  191. package/neural-interface/public/assets/mascot/sleep.gif +0 -0
  192. package/neural-interface/public/assets/mascot/sleep.png +0 -0
  193. package/neural-interface/public/assets/mascot/subagent.gif +0 -0
  194. package/neural-interface/public/assets/mascot/subagent.png +0 -0
  195. package/neural-interface/public/assets/mascot/success.gif +0 -0
  196. package/neural-interface/public/assets/mascot/success.png +0 -0
  197. package/neural-interface/public/assets/mascot/think.gif +0 -0
  198. package/neural-interface/public/assets/mascot/think.png +0 -0
  199. package/neural-interface/public/assets/mascot/wait.gif +0 -0
  200. package/neural-interface/public/assets/mascot/wait.png +0 -0
  201. package/neural-interface/public/assets/mascot/watch.gif +0 -0
  202. package/neural-interface/public/assets/mascot/watch.png +0 -0
  203. package/neural-interface/public/assets/mascot/web.gif +0 -0
  204. package/neural-interface/public/assets/mascot/web.png +0 -0
  205. package/neural-interface/public/onboarding.html +14 -1
  206. package/neural-interface/public/shared/agent-runtime-options.js +49 -8
  207. package/neural-interface/public/shared/agy/agy-panel.js +2 -2
  208. package/neural-interface/public/shared/api.js +4 -4
  209. package/neural-interface/public/shared/assistant/asst-ask-styles.js +8 -8
  210. package/neural-interface/public/shared/assistant/asst-ask.js +1 -1
  211. package/neural-interface/public/shared/assistant/asst-brain-picker.js +99 -9
  212. package/neural-interface/public/shared/assistant/asst-control.js +1 -1
  213. package/neural-interface/public/shared/assistant/asst-limit-wait.js +4 -4
  214. package/neural-interface/public/shared/assistant/asst-panel.js +6 -2
  215. package/neural-interface/public/shared/assistant/asst-rack-styles.js +4 -4
  216. package/neural-interface/public/shared/assistant/asst-render.js +6 -6
  217. package/neural-interface/public/shared/assistant/asst-route-models.js +64 -4
  218. package/neural-interface/public/shared/assistant/asst-route.js +24 -7
  219. package/neural-interface/public/shared/assistant/asst-routes-editor.js +154 -39
  220. package/neural-interface/public/shared/assistant/asst-run-stage.js +3 -3
  221. package/neural-interface/public/shared/assistant/asst-scene-styles.js +8 -111
  222. package/neural-interface/public/shared/assistant/asst-scenes.js +46 -318
  223. package/neural-interface/public/shared/assistant/asst-sidepanel.js +2 -2
  224. package/neural-interface/public/shared/assistant/asst-state.js +72 -2
  225. package/neural-interface/public/shared/assistant/asst-styles.js +58 -14
  226. package/neural-interface/public/shared/automation-approval-view.js +75 -0
  227. package/neural-interface/public/shared/cdx/cdx-panel.js +2 -2
  228. package/neural-interface/public/shared/context-menu-model.js +2 -0
  229. package/neural-interface/public/shared/editor/editor-panel-logic.js +10 -0
  230. package/neural-interface/public/shared/editor/editor-panel.js +10 -2
  231. package/neural-interface/public/shared/html-shell.js +30 -22
  232. package/neural-interface/public/shared/morelogin-profile-choices.js +107 -0
  233. package/neural-interface/public/shared/morelogin-profile-field.js +186 -0
  234. package/neural-interface/public/shared/mtc/mtc-client.js +181 -0
  235. package/neural-interface/public/shared/mtc/mtc-compose.js +40 -0
  236. package/neural-interface/public/shared/mtc/mtc-copy.js +253 -0
  237. package/neural-interface/public/shared/mtc/mtc-logic.js +478 -0
  238. package/neural-interface/public/shared/mtc/mtc-panel.js +1354 -0
  239. package/neural-interface/public/shared/mtc/mtc-render.js +172 -0
  240. package/neural-interface/public/shared/mtc/mtc-styles.js +437 -0
  241. package/neural-interface/public/shared/ocp-v2/ocp-v2-panel.js +6 -2
  242. package/neural-interface/public/shared/provider-icons.js +3 -0
  243. package/neural-interface/public/shared/schedules-view.js +7 -0
  244. package/neural-interface/public/shared/server-back.js +50 -0
  245. package/neural-interface/public/shared/settings/settings-browser-owner-access.js +72 -0
  246. package/neural-interface/public/shared/settings/settings-data.js +1 -0
  247. package/neural-interface/public/shared/settings/settings-ia.js +3 -1
  248. package/neural-interface/public/shared/settings/settings-local-profiles.js +153 -0
  249. package/neural-interface/public/shared/settings/settings-maritaca-opencode.js +105 -0
  250. package/neural-interface/public/shared/sidepanel-session-status.js +16 -2
  251. package/neural-interface/public/shared/state.js +1 -1
  252. package/neural-interface/public/shared/styles.css +356 -157
  253. package/neural-interface/public/shared/synabun-mascot-assets.js +67 -0
  254. package/neural-interface/public/shared/synabun-mascot.js +136 -12
  255. package/neural-interface/public/shared/synabun-ticker.js +3 -0
  256. package/neural-interface/public/shared/topright-overflow-logic.js +1 -0
  257. package/neural-interface/public/shared/ui-automation-approval.js +188 -0
  258. package/neural-interface/public/shared/ui-automation-studio.js +130 -90
  259. package/neural-interface/public/shared/ui-claude-panel.js +50 -2
  260. package/neural-interface/public/shared/ui-maritaca-panel.js +15 -0
  261. package/neural-interface/public/shared/ui-navbar.js +17 -0
  262. package/neural-interface/public/shared/ui-panels.js +3 -1
  263. package/neural-interface/public/shared/ui-schedules-studio.js +118 -17
  264. package/neural-interface/public/shared/ui-scroll-follow.js +3 -0
  265. package/neural-interface/public/shared/ui-settings.js +590 -27
  266. package/neural-interface/public/shared/ui-sidepanel-session-entry.js +8 -2
  267. package/neural-interface/public/shared/ui-sidepanel-sessions.js +3 -3
  268. package/neural-interface/public/shared/ui-sidepanel-tray.js +24 -0
  269. package/neural-interface/public/shared/ui-sidepanel-windows.js +1 -1
  270. package/neural-interface/scripts/build-mascot-assets.mjs +30 -0
  271. package/neural-interface/server.js +1784 -195
  272. package/npm-shrinkwrap.json +5 -17
  273. package/package.json +5 -6
  274. package/postinstall.js +38 -39
  275. package/setup.js +33 -31
  276. package/skills/synabun/modules/changelog.md +14 -0
@@ -71,7 +71,7 @@ export function launchMoreLoginApp() {
71
71
  if (!installed) return { launched: false, path: null, error: 'MoreLogin is not installed' };
72
72
  try {
73
73
  const child = process.platform === 'darwin'
74
- ? spawn('open', [path], { detached: true, stdio: 'ignore' })
74
+ ? spawn('open', ['-g', path], { detached: true, stdio: 'ignore' }) // -g: launch without bringing it forward
75
75
  : spawn(path, [], { detached: true, stdio: 'ignore', windowsHide: false });
76
76
  child.unref();
77
77
  return { launched: true, path, error: null };
@@ -314,7 +314,21 @@ export async function probeMoreLoginApi(opts = {}) {
314
314
  * `running: false` result FAILS the session in createBrowserSession(); nothing
315
315
  * falls back to Chrome.
316
316
  */
317
- export async function ensureMoreLoginRunning(opts = {}) {
317
+ export function ensureMoreLoginRunning(opts = {}) {
318
+ // One start for everybody who asks at once: browser sessions of different profiles start side by side, and each
319
+ // would otherwise launch the app while it is not running yet. The first caller's wait is the one that counts.
320
+ const key = String(opts.port ?? getMoreLoginPort(opts.savedCfg));
321
+ let start = _appStarts.get(key);
322
+ if (!start) {
323
+ start = startMoreLoginAppIfNeeded(opts).finally(() => { if (_appStarts.get(key) === start) _appStarts.delete(key); });
324
+ _appStarts.set(key, start);
325
+ }
326
+ return start;
327
+ }
328
+
329
+ const _appStarts = new Map(); // local API port → the start under way
330
+
331
+ async function startMoreLoginAppIfNeeded(opts = {}) {
318
332
  const timeoutMs = opts.timeoutMs ?? 25000;
319
333
  const intervalMs = opts.intervalMs ?? 1000;
320
334
 
@@ -372,11 +386,221 @@ export async function profileStatus(envId, opts = {}) {
372
386
  }
373
387
  }
374
388
 
389
+ /** MoreLogin's `browserTypeId` (profile detail, create): 1 is its Chrome-based browser, 2 its Firefox-based one. */
390
+ const BROWSER_TYPE_KERNEL = { 1: 'chromium', 2: 'firefox' };
391
+
392
+ /**
393
+ * Which browser a profile runs, from whatever MoreLogin said about it: 'chromium', 'firefox' or null (not said).
394
+ * Read from the profile detail's `browserTypeId` (then its user agent), or from the `webdriver` path a start or a
395
+ * status answers with (`…/Core/chrome_64_154.0/webdriver_154`, `…/Core/firefox_64_148.1/webdriver_148`).
396
+ * SynaBun drives a profile over the Chrome DevTools protocol, which only the Chrome-based browser speaks: the
397
+ * Firefox one opens `--remote-debugging-port` too, but as Firefox's own remote agent (WebDriver BiDi), which
398
+ * answers 404 to `/json/version`.
399
+ */
400
+ export function profileKernel(data) {
401
+ if (!data || typeof data !== 'object') return null;
402
+ const byType = BROWSER_TYPE_KERNEL[Number(data.browserTypeId)];
403
+ if (byType) return byType;
404
+ const path = typeof data.webdriver === 'string' ? data.webdriver : '';
405
+ const core = /(?:^|[\\/])(firefox|chrome|chromium)[_-][^\\/]*[\\/]/i.exec(path);
406
+ if (core) return core[1].toLowerCase() === 'firefox' ? 'firefox' : 'chromium';
407
+ const ua = data.advancedSetting && typeof data.advancedSetting.ua === 'string' ? data.advancedSetting.ua : '';
408
+ if (/\bFirefox\/\d/.test(ua)) return 'firefox';
409
+ if (/\bChrome\/\d/.test(ua)) return 'chromium';
410
+ return null;
411
+ }
412
+
413
+ /** The error of a profile SynaBun cannot drive. `started` says whether this start may have opened its browser. */
414
+ export function notChromiumError(envId, { started = false, evidence = '' } = {}) {
415
+ const e = new Error(
416
+ `MoreLogin profile ${envId} runs MoreLogin's Firefox browser, which has no Chrome DevTools (CDP) endpoint${evidence ? ` (${evidence})` : ''}. `
417
+ + 'SynaBun drives a MoreLogin profile over CDP, so only a Chrome-type profile can be used: '
418
+ + 'pick a Chrome-type profile, or create one in MoreLogin (New profile → Browser: Chrome)'
419
+ + (started ? '. The profile\'s Firefox window was left open in MoreLogin' : ''),
420
+ );
421
+ e.code = 'MORELOGIN_NOT_CHROMIUM';
422
+ e.kernel = 'firefox';
423
+ e.started = !!started;
424
+ return e;
425
+ }
426
+
427
+ /** One profile's full record (`/api/env/detail`). Large: it carries the profile's whole cookie jar. */
428
+ export async function profileDetail(envId, opts = {}) {
429
+ return request('/api/env/detail', { envId: String(envId) }, { ...opts, idempotent: true });
430
+ }
431
+
432
+ // Profiles already seen to be Chrome-type. A profile's browser is chosen when it is created, and the detail call
433
+ // that says it is megabytes (the cookie jar), so a Chrome verdict is asked for once. A Firefox verdict is never
434
+ // kept: it is asked again each time, and a wrong Chrome one is caught by the start's own answer.
435
+ const _chromiumProfiles = new Set();
436
+ export function _resetMoreLoginKernelsForTests() { _chromiumProfiles.clear(); _listedKernels.clear(); _kernelLookups.clear(); }
437
+
438
+ function statusRow(st) {
439
+ return Array.isArray(st?.dataList) ? st.dataList[0] : (Array.isArray(st) ? st[0] : st);
440
+ }
441
+
442
+ /**
443
+ * Which browser a profile runs, asked without starting it: the status of a running profile says it (small), else
444
+ * the profile's detail. Best effort: null when MoreLogin does not say; never throws.
445
+ */
446
+ export async function profileKernelOf(envId, opts = {}) {
447
+ const id = String(envId);
448
+ if (_chromiumProfiles.has(id)) return 'chromium';
449
+ let kernel = null;
450
+ try { kernel = profileKernel(statusRow(await profileStatus(id, opts))); }
451
+ catch { /* unreachable: the start says so itself */ }
452
+ if (!kernel) {
453
+ try { kernel = profileKernel(await profileDetail(id, opts)); } catch { /* a MoreLogin without the call */ }
454
+ }
455
+ if (kernel === 'chromium') _chromiumProfiles.add(id);
456
+ return kernel;
457
+ }
458
+
459
+ // ── Which browser each listed profile runs (the profile pickers, and the routes that save a choice) ──
460
+ // MoreLogin's list call does not say a profile's browser; only the megabyte detail does. So the verdicts are kept
461
+ // per profile: a Chrome one for the life of the process (above), a Firefox one for ten minutes, "MoreLogin did not
462
+ // say" for half a minute (then asked again, never taken for an answer). One lookup per profile at a time, a few at
463
+ // once, and a list never waits for them longer than its budget: what is not known yet is `null` in that answer and
464
+ // arrives in a later one. null always means "not known", and a profile of unknown browser stays usable everywhere:
465
+ // the start of a run still refuses a Firefox one (startProfile, requireCdp).
466
+ const FIREFOX_VERDICT_MS = 10 * 60_000;
467
+ const UNKNOWN_VERDICT_MS = 30_000;
468
+ const MAX_LISTED_VERDICTS = 5000;
469
+ const _listedKernels = new Map(); // id → { kernel: 'firefox' | null, at }
470
+ const _kernelLookups = new Map(); // id → the lookup under way
471
+
472
+ /** The verdict already held for a profile: { known: true, kernel } or { known: false }. Never asks MoreLogin. */
473
+ export function heldProfileKernel(envId, now = Date.now()) {
474
+ const id = String(envId);
475
+ if (_chromiumProfiles.has(id)) return { known: true, kernel: 'chromium' };
476
+ const held = _listedKernels.get(id);
477
+ if (!held) return { known: false, kernel: null };
478
+ if (now - held.at > (held.kernel === 'firefox' ? FIREFOX_VERDICT_MS : UNKNOWN_VERDICT_MS)) {
479
+ _listedKernels.delete(id);
480
+ return { known: false, kernel: null };
481
+ }
482
+ return { known: true, kernel: held.kernel };
483
+ }
484
+
485
+ /** A profile's browser, from what is held or one shared lookup: 'chromium', 'firefox' or null. Never throws. */
486
+ export function lookupProfileKernel(envId, opts = {}) {
487
+ const id = String(envId);
488
+ const held = heldProfileKernel(id);
489
+ if (held.known) return Promise.resolve(held.kernel);
490
+ let lookup = _kernelLookups.get(id);
491
+ if (!lookup) {
492
+ lookup = (opts.kernelOf || profileKernelOf)(id, opts)
493
+ .then((kernel) => (kernel === 'chromium' || kernel === 'firefox' ? kernel : null), () => null)
494
+ .then((kernel) => {
495
+ if (kernel !== 'chromium') {
496
+ _listedKernels.delete(id); // newest last
497
+ _listedKernels.set(id, { kernel, at: Date.now() });
498
+ while (_listedKernels.size > MAX_LISTED_VERDICTS) _listedKernels.delete(_listedKernels.keys().next().value);
499
+ } else _chromiumProfiles.add(id);
500
+ return kernel;
501
+ })
502
+ .finally(() => { if (_kernelLookups.get(id) === lookup) _kernelLookups.delete(id); });
503
+ _kernelLookups.set(id, lookup);
504
+ }
505
+ return lookup;
506
+ }
507
+
375
508
  /**
376
- * Start (launch) a profile and return { debugPort, webdriver, raw }.
509
+ * The browsers of many profiles: { kernels: { id: 'chromium' | 'firefox' | null }, pending }.
510
+ * `concurrency` lookups at once (default 4); after `budgetMs` (default 2500) the answer is what is known by then,
511
+ * `pending` counts the profiles still being asked (their lookups go on and fill the cache for the next call).
512
+ * A lookup that fails is `null` for that profile and never the list's failure.
513
+ */
514
+ export async function profileKernels(envIds, opts = {}) {
515
+ const ids = [...new Set((envIds || []).map(String))];
516
+ const concurrency = Math.max(1, opts.concurrency || 4);
517
+ const budgetMs = opts.budgetMs ?? 2500;
518
+ const queue = ids.filter(id => !heldProfileKernel(id).known);
519
+ if (queue.length) {
520
+ let next = 0;
521
+ const worker = async () => {
522
+ while (next < queue.length) {
523
+ const id = queue[next++];
524
+ try { await lookupProfileKernel(id, opts); } catch { /* null for this one */ }
525
+ }
526
+ };
527
+ const all = Promise.all(Array.from({ length: Math.min(concurrency, queue.length) }, worker)).catch(() => {});
528
+ let timer = null;
529
+ await Promise.race([all, new Promise((done) => { timer = setTimeout(done, Math.max(0, budgetMs)); timer.unref?.(); })]);
530
+ clearTimeout(timer);
531
+ }
532
+ const kernels = {};
533
+ let pending = 0;
534
+ for (const id of ids) {
535
+ const held = heldProfileKernel(id);
536
+ kernels[id] = held.known ? held.kernel : null;
537
+ if (!held.known) pending++;
538
+ }
539
+ return { kernels, pending };
540
+ }
541
+
542
+ /** The error of a choice SynaBun refuses to save: a profile known to run MoreLogin's Firefox browser. */
543
+ export function notChromiumChoiceError(envId, name = null) {
544
+ const label = name ? `"${name}" (${envId})` : String(envId);
545
+ const e = new Error(
546
+ `MoreLogin profile ${label} is a Firefox-type profile. SynaBun drives a MoreLogin profile over the Chrome DevTools protocol, `
547
+ + 'so only a Chrome-type profile can be chosen: pick a Chrome-type profile, or create one in MoreLogin (New profile → Browser: Chrome).',
548
+ );
549
+ e.code = 'MORELOGIN_NOT_CHROMIUM';
550
+ e.status = 400;
551
+ e.kernel = 'firefox';
552
+ return e;
553
+ }
554
+
555
+ /**
556
+ * What answers on a started profile's debug port, asked when `/json/version` did not answer as DevTools does:
557
+ * { kind: 'devtools' | 'not-devtools' | 'closed', status, server }. `not-devtools` is an HTTP server that is not a
558
+ * DevTools endpoint (Firefox's remote agent says `Server: httpd.js` and 404); `closed` is nothing listening (yet).
559
+ * Never throws.
560
+ */
561
+ export async function describeDebugEndpoint(port, opts = {}) {
562
+ const fetchImpl = opts.fetch || fetch;
563
+ let res;
564
+ try {
565
+ res = await fetchImpl(`http://127.0.0.1:${port}/json/version`, { signal: AbortSignal.timeout(opts.timeout || 2000) });
566
+ } catch (err) {
567
+ return { kind: 'closed', status: null, server: null, error: String(err?.cause?.code || err?.code || err?.message || err) };
568
+ }
569
+ const server = res.headers?.get?.('server') || null;
570
+ let body = null;
571
+ try { body = await res.json(); } catch { try { await res.body?.cancel(); } catch { /* ignore */ } }
572
+ if (res.ok && body && typeof body === 'object' && (body.webSocketDebuggerUrl || body.Browser)) {
573
+ return { kind: 'devtools', status: res.status, server };
574
+ }
575
+ return { kind: 'not-devtools', status: res.status, server, firefox: /^httpd\.js/i.test(server || '') };
576
+ }
577
+
578
+ /** The error of a started profile whose debug port is some other HTTP server (see describeDebugEndpoint). */
579
+ export function notDevToolsError(envId, port, seen = {}) {
580
+ if (seen.firefox) {
581
+ return notChromiumError(envId, { started: true, evidence: `port ${port} answers as Firefox's remote agent, HTTP ${seen.status}` });
582
+ }
583
+ const e = new Error(
584
+ `MoreLogin started profile ${envId} and named debug port ${port}, but what listens there is not a Chrome DevTools endpoint `
585
+ + `(HTTP ${seen.status} for /json/version${seen.server ? `, server "${seen.server}"` : ''}). `
586
+ + 'SynaBun drives a MoreLogin profile over CDP: use a Chrome-type profile, or close this profile in MoreLogin and start the run again if it is one',
587
+ );
588
+ e.code = 'MORELOGIN_NOT_DEVTOOLS';
589
+ return e;
590
+ }
591
+
592
+ /**
593
+ * Start (launch) a profile and return { debugPort, webdriver, kernel, raw }.
377
594
  * Recovers the debugPort via status when the env is already running.
595
+ *
596
+ * `opts.requireCdp` (a start SynaBun will drive, never the Settings Start button): a Firefox-type profile is
597
+ * refused with MORELOGIN_NOT_CHROMIUM before it is started when MoreLogin says what it is up front, and right
598
+ * after the start when only the start's answer says it. It is never closed here: it may be the user's own window.
378
599
  */
379
600
  export async function startProfile(envId, opts = {}) {
601
+ if (opts.requireCdp && await profileKernelOf(envId, opts) === 'firefox') {
602
+ throw notChromiumError(envId, { evidence: 'MoreLogin lists it as a Firefox profile' });
603
+ }
380
604
  let data = null;
381
605
  try {
382
606
  data = await request('/api/env/start', { envId: String(envId), ...(opts.startArgs || {}) }, opts);
@@ -390,12 +614,17 @@ export async function startProfile(envId, opts = {}) {
390
614
  // Already-running or no port echoed — recover from status. A `status` object
391
615
  // may be keyed directly or under a list.
392
616
  const st = await profileStatus(envId, opts);
393
- const stData = Array.isArray(st?.dataList) ? st.dataList[0] : (Array.isArray(st) ? st[0] : st);
617
+ const stData = statusRow(st);
394
618
  port = extractDebugPort(stData);
395
619
  webdriver = webdriver || (stData && stData.webdriver);
396
620
  }
621
+ const kernel = profileKernel({ webdriver });
622
+ if (opts.requireCdp && kernel === 'firefox') {
623
+ throw notChromiumError(envId, { started: true, evidence: `its browser is ${webdriver}` });
624
+ }
397
625
  if (!port) throw new Error(`MoreLogin started env ${envId} but returned no debugPort`);
398
- return { debugPort: port, webdriver: webdriver || null, raw: data };
626
+ if (kernel === 'chromium') _chromiumProfiles.add(String(envId));
627
+ return { debugPort: port, webdriver: webdriver || null, kernel, raw: data };
399
628
  }
400
629
 
401
630
  /**
@@ -428,18 +657,53 @@ export async function stopProfile(envId, opts = {}) {
428
657
  return request('/api/env/close', { envId: String(envId) }, opts);
429
658
  }
430
659
 
431
- /** Create a quick profile. Shape varies by version; pass `opts.body` to override. */
432
- export async function createProfile(opts = {}) {
433
- const body = {
660
+ /** MoreLogin's operating-system id for a profile made on this host (Local API quick create: 1 Windows, 2 macOS,
661
+ * 3 Android, 4 iOS). macOS on a Mac, Windows everywhere else (MoreLogin has no Linux fingerprint). */
662
+ export function hostOperatorSystemId(platform = process.platform) {
663
+ return platform === 'darwin' ? 2 : 1;
664
+ }
665
+
666
+ /** The body of `/api/env/create/quick`, per guide.morelogin.com (Browser → Local API → Profiles, checked 2026-11-11):
667
+ * `browserTypeId`, `operatorSystemId` and `quantity` are required; there is no name field. Chrome type (1) is the
668
+ * only kind SynaBun can drive. `opts.operatorSystemId`, then `opts.body`, override. */
669
+ export function quickCreateBody(opts = {}) {
670
+ return {
434
671
  quantity: 1,
435
- browserTypeId: opts.browserTypeId || 1,
436
- ...(opts.name ? { name: opts.name } : {}),
672
+ browserTypeId: 1,
673
+ operatorSystemId: opts.operatorSystemId || hostOperatorSystemId(opts.platform),
437
674
  ...(opts.body || {}),
438
675
  };
439
- const data = await request('/api/env/create/quick', body, opts);
440
- // Returns { envIds:[...] } or { id } depending on version.
441
- const ids = data && (data.envIds || (data.id != null ? [data.id] : []));
442
- return { ids: (ids || []).map(String), raw: data };
676
+ }
677
+
678
+ const CREATE_PREFIX = 'MoreLogin API /api/env/create/quick';
679
+ /** A refusal of quick create, in words a toast can show: "MoreLogin refused the new profile: <reason>". */
680
+ function refusedNewProfile(err) {
681
+ if (!err || (err.code !== 'MORELOGIN_API' && err.code !== 'MORELOGIN_HTTP')) return err;
682
+ let reason = String(err.message || '');
683
+ if (reason.startsWith(CREATE_PREFIX)) reason = reason.slice(CREATE_PREFIX.length).replace(/^\s*(?::|→)\s*/, '');
684
+ const e = new Error(`MoreLogin refused the new profile: ${reason}`);
685
+ e.code = err.code;
686
+ if (err.apiCode !== undefined) e.apiCode = err.apiCode;
687
+ if (err.status !== undefined) e.status = err.status;
688
+ e.reason = reason;
689
+ return e;
690
+ }
691
+
692
+ /** Create one quick profile. Quick create takes no name, so a name is set right after through `/api/env/update`
693
+ * (`envId` + `envName`); the profile exists even when that rename fails (`nameError`). */
694
+ export async function createProfile(opts = {}) {
695
+ let data;
696
+ try { data = await request('/api/env/create/quick', quickCreateBody(opts), opts); }
697
+ catch (err) { throw refusedNewProfile(err); }
698
+ // Documented answer: `data` is an array of id strings. Older clients answered { envIds } or { id }.
699
+ const ids = Array.isArray(data) ? data
700
+ : (data && (data.envIds || (data.id != null ? [data.id] : []))) || [];
701
+ const out = { ids: ids.map(String), raw: data };
702
+ if (opts.name && out.ids.length) {
703
+ try { await request('/api/env/update', { envId: out.ids[0], envName: String(opts.name) }, opts); }
704
+ catch (err) { out.nameError = err.message; }
705
+ }
706
+ return out;
443
707
  }
444
708
 
445
709
  /** Return the first profile, creating a default "SynaBun" profile if none exist. */
@@ -8,7 +8,7 @@ import { config as memoryConfig, detectProject as memoryProject } from '../../mc
8
8
  import { Codex } from '@openai/codex-sdk';
9
9
  import { CodexWorkerAppServer } from './codex-worker-app-server.js';
10
10
  import { query as claudeQuery } from '@anthropic-ai/claude-agent-sdk';
11
- import { CLAUDE_EFFORT_LEVELS } from './claude-model-catalog.js';
11
+ import { CLAUDE_EFFORT_LEVELS, CLAUDE_EFFORT_OFF } from './claude-model-catalog.js';
12
12
  import { CLAUDE_NOT_INSTALLED, resolveClaudeSdkExecutable } from './claude-executable.js';
13
13
  import { BACKGROUND_HOLD_DEFAULTS, createBackgroundTasks, createTurnHold, resultDeclaresDone } from './claude-background-hold.js';
14
14
  import { extractOpenCodeText } from './session-title-generator.js';
@@ -905,6 +905,8 @@ export async function createClaudeNativeLoopAdapter(options = {}) {
905
905
  }
906
906
  if (model) queryOptions.model = model;
907
907
  if (effort && CLAUDE_EFFORT_LEVELS.includes(effort)) queryOptions.effort = effort;
908
+ // Off (the route card's, agent_dispatch effort "none"): no thinking at all, over the user's effortLevel setting.
909
+ else if (effort === CLAUDE_EFFORT_OFF) queryOptions.thinking = { type: 'disabled' };
908
910
  // Read-only: with the guard enforced the shell stays, limited to read-only commands by the hook, and only the
909
911
  // built-in writers are off the list; otherwise (warn, off) today's list, Bash included.
910
912
  if (capability === 'read-only' && !held) queryOptions.disallowedTools = guard?.enforced ? [...CLAUDE_READ_ONLY_WRITE_TOOLS] : [...CLAUDE_READ_ONLY_DISALLOWED_TOOLS];
@@ -33,8 +33,8 @@
33
33
  // credential that survived the peer check — and stays on its route's rules (the MCP git tool, desktop, loop and
34
34
  // browser tools; the brain; the Assistant's route gate, asked with the session's pin by the OpenCode plugin and the
35
35
  // Codex hook, which checks the session's own token), as do the few routes agents call without a pin
36
- // (AGENT_OPEN_PREFIXES: the server's stop and restart the CLI asks, the MCP server's tab release, and the loops and
37
- // schedules the /synabun skill creates with curl).
36
+ // (AGENT_OPEN_PREFIXES: the server's stop and restart the CLI asks, the MCP server's tab release, the loops and
37
+ // schedules the /synabun skill creates with curl, and OpenCode's requests for a Sabiá model through SynaBun).
38
38
  //
39
39
  // Never refused by this module: the owner's own browser and the SynaBun app (the peer lookup allows them), this
40
40
  // server itself, a request from outside (the tunnel, the invite proxy: the guest rules decide those, and the
@@ -69,8 +69,11 @@ export const FEATURE_OPEN_PREFIXES = Object.freeze([
69
69
  ]);
70
70
  /** Paths under an open prefix that are not open: the code editor's copies of unsaved buffers (file content). */
71
71
  export const NEVER_OPEN_PREFIXES = Object.freeze(['/api/ui-blobs/editor-backups']);
72
- /** Routes agents call without a pin: an agent's tree may call them as it did (the other peers are still refused). */
73
- export const AGENT_OPEN_PREFIXES = Object.freeze(['/api/server/', '/api/browser/release', '/api/loop', '/api/schedules', '/api/schedule-groups']);
72
+ /** Routes agents call without a pin: an agent's tree may call them as it did (the other peers are still refused).
73
+ * `/api/maritaca/opencode/v1/chat/completions` is OpenCode's own request for a Sabiá model (lib/maritaca/opencode-proxy.js,
74
+ * the base URL of the provider block SynaBun writes): OpenCode's serve is an agent's tree and sends no pin, and the
75
+ * route itself takes only a caller that presents the saved Maritaca key. That one path only, nothing else of /api/maritaca. */
76
+ export const AGENT_OPEN_PREFIXES = Object.freeze(['/api/server/', '/api/browser/release', '/api/loop', '/api/schedules', '/api/schedule-groups', '/api/maritaca/opencode/v1/chat/completions']);
74
77
  /** The peers whose own calls (pinned, or on an agent-open route) keep their route's rules: an AI agent's process tree,
75
78
  * and SynaBun's own MCP server over HTTP (lib/peer-identity.js isSynabunMcpServer), as the stdio one in an agent's tree. */
76
79
  export const AGENT_CALL_KINDS = Object.freeze(['agent', 'synabun-mcp']);
@@ -90,7 +93,7 @@ export const OWNER_READ_PREFIXES = Object.freeze([...ADMIN_ONLY_PREFIXES.filter(
90
93
  */
91
94
  export const DEGRADED_OPEN_PATHS = Object.freeze(['/api/server/restart', '/api/server/shutdown']);
92
95
  /** The owner's sockets: a terminal, the agent panels, the Assistant, the browser panel. */
93
- export const OWNER_SOCKET_PREFIXES = Object.freeze(['/ws/terminal/', '/ws/claude-skin', '/ws/codex-skin', '/ws/opencode-v2', '/ws/antigravity', '/ws/assistant/', '/ws/browser/']);
96
+ export const OWNER_SOCKET_PREFIXES = Object.freeze(['/ws/terminal/', '/ws/claude-skin', '/ws/codex-skin', '/ws/opencode-v2', '/ws/antigravity', '/ws/maritaca', '/ws/assistant/', '/ws/browser/']);
94
97
  /** Sockets that stay open for the app's pages to draw, read-only for a peer the owner's powers are refused to. */
95
98
  export const READ_ONLY_SOCKET_PATHS = Object.freeze(['/ws/sync']);
96
99
 
@@ -216,20 +219,25 @@ export function socketScope(pathname) {
216
219
  /**
217
220
  * The decision for one request whose peer verdict is on it (or not: then only the marker counts, unless `required`).
218
221
  * @param {object} req
219
- * @param {{ agentOpen?: boolean, degradedOpen?: boolean, required?: boolean, fromWorkerBrowser?: (req) => boolean }} o
222
+ * @param {{ agentOpen?: boolean, degradedOpen?: boolean, required?: boolean, fromWorkerBrowser?: (req) => boolean, automationBrowserAllowed?: boolean }} o
220
223
  * `required`: the lookup runs on this server (macOS, not off), so a covered request without a verdict was never
221
- * identified and is taken as a failed lookup; `degradedOpen`: a failed lookup leaves this one to the rules from before
224
+ * identified and is taken as a failed lookup; `degradedOpen`: a failed lookup leaves this one to the rules from before;
225
+ * `automationBrowserAllowed`: the owner's setting is on, so the automation browser (marker or peer) is not refused
222
226
  * @returns {{ status: 403|503, code: string, error: string, hint?: string, peer?: object, retryable?: boolean, reason?: string } | null}
223
227
  * `hint: 'proxy'` (with the relay's kind, pid and name) when the peer carries requests for others: `error` then says
224
228
  * what to do, in the request's language; status 503 with code PEER_UNAVAILABLE when the peer could not be identified
225
229
  */
226
- export function ownerRefusal(req, { agentOpen = false, degradedOpen = false, required = false, fromWorkerBrowser = () => false } = {}) {
230
+ export function ownerRefusal(req, { agentOpen = false, degradedOpen = false, required = false, fromWorkerBrowser = () => false, automationBrowserAllowed = false } = {}) {
231
+ // The owner's setting "Let the automation browser act as owner" (lib/automation-browser-owner-access.js): while
232
+ // on, that browser's marker and its peer kind are not refusals. Nothing else is granted by it.
233
+ const granted = automationBrowserAllowed === true;
227
234
  let marked = false;
228
235
  try { marked = !!fromWorkerBrowser(req); } catch { marked = false; }
229
- if (marked) return { status: 403, code: 'WORKER_BROWSER', error: 'SynaBun\'s automation browser cannot act as the owner: it reads SynaBun\'s pages, clicks and screenshots; the owner\'s own settings, files and actions are the owner\'s, from the owner\'s browser or the app.' };
236
+ if (marked && !granted) return { status: 403, code: 'WORKER_BROWSER', error: 'SynaBun\'s automation browser cannot act as the owner: it reads SynaBun\'s pages, clicks and screenshots; the owner\'s own settings, files and actions are the owner\'s, from the owner\'s browser or the app.' };
230
237
  const verdict = req?.[PEER_VERDICT];
231
238
  const auth = verdict == null && required ? peerAuthority(failedPeerVerdict('the request was not identified')) : peerAuthority(verdict);
232
239
  if (auth.decision === 'before' || auth.decision === 'allowed') return null;
240
+ if (granted && auth.decision === 'refused' && auth.kind === 'automation-browser') return null;
233
241
  if (auth.decision === 'unavailable') {
234
242
  if (degradedOpen) return null; // the server's restart and stop: the rules from before (DEGRADED_OPEN_PATHS)
235
243
  return { status: 503, code: PEER_UNAVAILABLE, error: peerUnavailableText(req, auth), retryable: auth.retryable, reason: auth.reason };
@@ -250,9 +258,19 @@ export function ownerRefusal(req, { agentOpen = false, degradedOpen = false, req
250
258
  * middleware runs for them). `supported` (macOS, not off): a covered request without a verdict, or a socket whose
251
259
  * lookup threw, is a failed lookup (503), never the rules from before.
252
260
  * @param {(line: string) => void} [o.log]
261
+ * @param {() => boolean} [o.automationBrowserAllowed] the owner's setting (lib/automation-browser-owner-access.js);
262
+ * left out, the page session's `automationBrowserGranted()` is asked, so both read the one value
253
263
  */
254
- export function createOwnerAuthority({ pageSession = () => null, isRemote = () => false, peer = null, log = () => {} } = {}) {
264
+ export function createOwnerAuthority({ pageSession = () => null, isRemote = () => false, peer = null, log = () => {}, automationBrowserAllowed = null } = {}) {
255
265
  const fromWorkerBrowser = (req) => { const s = pageSession(); return typeof s?.fromWorkerBrowser === 'function' ? s.fromWorkerBrowser(req) : false; };
266
+ /** The owner's setting, read at request time: given here, else the page session's own reading; never on a failure. */
267
+ const granted = () => {
268
+ try {
269
+ if (typeof automationBrowserAllowed === 'function') return automationBrowserAllowed() === true;
270
+ const s = pageSession();
271
+ return typeof s?.automationBrowserGranted === 'function' && s.automationBrowserGranted() === true;
272
+ } catch { return false; }
273
+ };
256
274
  const remote = (req) => { try { return isRemote(req) === true; } catch { return false; } };
257
275
  /** The lookup runs here (macOS, not off): no verdict is no proof. */
258
276
  const required = peer?.supported === true;
@@ -278,7 +296,7 @@ export function createOwnerAuthority({ pageSession = () => null, isRemote = () =
278
296
  let scope;
279
297
  try { scope = restScope(req); } catch { scope = { gated: true, agentOpen: false, degradedOpen: false }; }
280
298
  if (!scope.gated || remote(req)) return next();
281
- const refused = ownerRefusal(req, { agentOpen: scope.agentOpen, degradedOpen: scope.degradedOpen, required, fromWorkerBrowser });
299
+ const refused = ownerRefusal(req, { agentOpen: scope.agentOpen, degradedOpen: scope.degradedOpen, required, fromWorkerBrowser, automationBrowserAllowed: granted() });
282
300
  if (!refused) return next();
283
301
  note(`${refused.code}:${req[PEER_VERDICT]?.pid || (refused.code === PEER_UNAVAILABLE ? refused.reason : 'marker')}:${String(req.path).slice(0, 80)}`, `[owner-authority] ${refused.code === PEER_UNAVAILABLE ? 'unavailable (503)' : 'refused'} ${req.method} ${String(req.path).slice(0, 120)}: ${refused.hint === 'proxy' ? `${req[PEER_VERDICT]?.refuse?.why}: pid ${refused.peer?.pid} (${refused.peer?.name})` : refused.code === PEER_UNAVAILABLE ? `the caller could not be identified (${refused.reason})` : refused.error}`);
284
302
  if (refused.code === PEER_UNAVAILABLE) return sendPeerUnavailable(res, req, refused);
@@ -301,7 +319,7 @@ export function createOwnerAuthority({ pageSession = () => null, isRemote = () =
301
319
  if (required) req[PEER_VERDICT] = failedPeerVerdict(`the lookup failed (${error?.message || error})`);
302
320
  }
303
321
  }
304
- const refused = ownerRefusal(req, { agentOpen: false, required, fromWorkerBrowser });
322
+ const refused = ownerRefusal(req, { agentOpen: false, required, fromWorkerBrowser, automationBrowserAllowed: granted() });
305
323
  if (!refused) return { refuse: false, readOnly: false };
306
324
  note(`ws:${refused.code}:${req[PEER_VERDICT]?.pid || 'marker'}:${pathname}`, `[owner-authority] ${scope.owner ? (refused.code === PEER_UNAVAILABLE ? 'unavailable (503)' : 'refused') : 'read-only'} socket ${pathname}: ${refused.code === PEER_UNAVAILABLE ? `the caller could not be identified (${refused.reason})` : refused.error}`);
307
325
  return scope.owner ? { refuse: true, readOnly: false, ...refused } : { refuse: false, readOnly: true, ...refused };
@@ -164,12 +164,21 @@ self.addEventListener('activate', (event) => { event.waitUntil(self.registration
164
164
  * request (req[PEER_VERDICT], read through peerAuthority) decides; `supported` (macOS, not off) makes a missing
165
165
  * verdict on a request that hands out or carries the secret a failed lookup. A stand-in without verdicts may answer
166
166
  * `refusal(req)` (a sentence: refused).
167
+ * @param {() => boolean} [o.automationBrowserAllowed] the owner's setting (lib/automation-browser-owner-access.js
168
+ * `enabled`): while true, the automation browser (its marker or its peer) is handed the secret and verifies as the
169
+ * owner; the service worker rule and every other refusal stay.
167
170
  */
168
- export function createPageSession({ secret = null, cookieName = null, port = null, secure = false, isGuest = null, peer = null, networkRule = setBrowserNetworkRule } = {}) {
171
+ export function createPageSession({ secret = null, cookieName = null, port = null, secure = false, isGuest = null, peer = null, networkRule = setBrowserNetworkRule, automationBrowserAllowed = null } = {}) {
169
172
  const value = typeof secret === 'string' && secret.length >= 32 ? secret : randomBytes(32).toString('hex');
170
173
  const expected = Buffer.from(value);
171
174
  const name = typeof cookieName === 'string' && cookieName ? cookieName : pageSecretCookieName(port);
172
175
  const guest = (req) => { try { return typeof isGuest === 'function' && isGuest(req) === true; } catch { return true; } };
176
+ /**
177
+ * The owner's setting "Let the automation browser act as owner" (lib/automation-browser-owner-access.js), read on
178
+ * every request: while on, the automation browser (its marker, or its peer process) is handed the secret and
179
+ * verifies as the owner. Off, missing or failing: the rules above, exactly. Never a grant for any other refusal.
180
+ */
181
+ const allowed = () => { try { return typeof automationBrowserAllowed === 'function' && automationBrowserAllowed() === true; } catch { return false; } };
173
182
  /** The lookup runs on this server (macOS, not off): where the secret is at stake, no verdict is no proof. */
174
183
  const peerRequired = () => { try { return peer?.supported === true; } catch { return true; } };
175
184
  /**
@@ -177,20 +186,24 @@ export function createPageSession({ secret = null, cookieName = null, port = nul
177
186
  * `secretAtStake`: the request is handed the secret or carries it, so on a server whose lookup runs a missing verdict
178
187
  * is a failed lookup. Never throws: on a server whose lookup runs a failure here is a failed lookup too.
179
188
  */
180
- function peerDecision(req, { secretAtStake = false } = {}) {
189
+ function peerDecision(req, { secretAtStake = false, grant = true } = {}) {
181
190
  if (!peer) return { decision: 'before' };
191
+ let auth;
182
192
  try {
183
193
  const verdict = req?.[PEER_VERDICT];
184
- if (verdict != null) return peerAuthority(verdict);
185
- if (typeof peer.refusal === 'function') {
186
- const why = peer.refusal(req);
187
- if (why) return { decision: 'refused', code: 'PEER_REFUSED', why: String(why), pid: null };
188
- }
189
- return secretAtStake && peerRequired() ? peerAuthority(failedPeerVerdict('the request was not identified')) : { decision: 'before' };
194
+ if (verdict != null) auth = peerAuthority(verdict);
195
+ else if (typeof peer.refusal === 'function' && peer.refusal(req)) auth = { decision: 'refused', code: 'PEER_REFUSED', why: String(peer.refusal(req)), pid: null };
196
+ else auth = secretAtStake && peerRequired() ? peerAuthority(failedPeerVerdict('the request was not identified')) : { decision: 'before' };
190
197
  } catch (error) {
191
- return peerRequired() ? peerAuthority(failedPeerVerdict(`the lookup failed (${error?.message || error})`)) : { decision: 'before' };
198
+ auth = peerRequired() ? peerAuthority(failedPeerVerdict(`the lookup failed (${error?.message || error})`)) : { decision: 'before' };
192
199
  }
200
+ // The one grant: the automation browser, by its process, while the owner's setting is on (never a peer refused
201
+ // for any other reason, never a failed lookup). `grant: false` asks the rules without it (the service worker).
202
+ if (grant && auth.decision === 'refused' && auth.kind === 'automation-browser' && allowed()) return { decision: 'allowed', granted: 'automation-browser' };
203
+ return auth;
193
204
  }
205
+ /** The automation browser's marker counts unless the owner's setting lets that browser act as the owner. */
206
+ const markerHolds = (req, { grant = true } = {}) => hasWorkerMarker(req) && !(grant && allowed());
194
207
  const refusedText = (auth) => (auth.gone || auth.pid == null ? auth.why : `${auth.why}: pid ${auth.pid} (${auth.name})`);
195
208
  /** Why the peer lookup refuses this request the secret (a sentence), or null (never asked, not looked up here, or
196
209
  * allowed). A failed lookup on macOS is a refusal too. */
@@ -206,9 +219,9 @@ export function createPageSession({ secret = null, cookieName = null, port = nul
206
219
  return auth.decision === 'unavailable' ? auth : null;
207
220
  };
208
221
  /** A request that may neither be handed the secret nor use it: a marker of the automation browser, or its peer. */
209
- const heldBack = (req) => {
210
- if (hasWorkerMarker(req)) return true;
211
- const decision = peerDecision(req, { secretAtStake: true }).decision;
222
+ const heldBack = (req, { grant = true } = {}) => {
223
+ if (markerHolds(req, { grant })) return true;
224
+ const decision = peerDecision(req, { secretAtStake: true, grant }).decision;
212
225
  return decision === 'refused' || decision === 'unavailable';
213
226
  };
214
227
 
@@ -243,10 +256,22 @@ export function createPageSession({ secret = null, cookieName = null, port = nul
243
256
  if (!carriesSecret(req)) return false;
244
257
  return !heldBack(req);
245
258
  }
246
- /** Whether a request comes from a tab of SynaBun's automation browser (the marker cookie or the host-proof header). */
259
+ /** Whether a request comes from a tab of SynaBun's automation browser (the marker cookie or the host-proof header),
260
+ * whatever the owner's setting says (the owner gate asks the setting itself). */
247
261
  function fromWorkerBrowser(req) {
248
262
  return hasWorkerMarker(req);
249
263
  }
264
+ /**
265
+ * Whether a request is the automation browser's by any sign: its marker, or a peer verdict that names a browser
266
+ * started for automation. Never changed by the owner's setting: this is what refuses that browser the change of
267
+ * the setting itself (PUT /api/assistant/automation-browser-owner-access), on or off.
268
+ */
269
+ function isAutomationBrowser(req) {
270
+ if (hasWorkerMarker(req)) return true;
271
+ try { return peerAuthority(req?.[PEER_VERDICT]).kind === 'automation-browser'; } catch { return false; }
272
+ }
273
+ /** Whether the owner's setting lets the automation browser act as the owner right now. */
274
+ function automationBrowserGranted() { return allowed(); }
250
275
  /**
251
276
  * Mark a Playwright browser context as SynaBun's automation browser. Two markers, both HttpOnly / network-level so
252
277
  * no page script reads or drops them, and never throws:
@@ -309,7 +334,7 @@ export function createPageSession({ secret = null, cookieName = null, port = nul
309
334
  function refresh(req, res) {
310
335
  res.setHeader('Cache-Control', 'no-store');
311
336
  if (guest(req)) return res.status(403).json({ ok: false, code: 'GUEST_FORBIDDEN', error: 'Available to the owner only.' });
312
- if (hasWorkerMarker(req)) return res.status(403).json({ ok: false, code: 'WORKER_BROWSER', error: 'SynaBun\'s automation browser does not hold the owner\'s page secret.' });
337
+ if (markerHolds(req)) return res.status(403).json({ ok: false, code: 'WORKER_BROWSER', error: 'SynaBun\'s automation browser does not hold the owner\'s page secret.' });
313
338
  const auth = peerDecision(req, { secretAtStake: true });
314
339
  if (auth.decision === 'unavailable') return sendUnavailable(res, req, auth);
315
340
  if (auth.decision === 'refused') return res.status(403).json({ ok: false, code: 'PEER_REFUSED', error: `SynaBun hands its page secret to the owner's own browser only; this request comes from ${refusedText(auth)}.` });
@@ -319,15 +344,16 @@ export function createPageSession({ secret = null, cookieName = null, port = nul
319
344
  /**
320
345
  * Express middleware for GET /sw.js: a browser that may not hold the secret (the automation browser's marker, a
321
346
  * refused peer, or on macOS one that could not be identified) gets SERVICE_WORKER_NOOP, so no service worker answers
322
- * its requests out of the server's sight; everyone else falls through to the real public/sw.js.
347
+ * its requests out of the server's sight; everyone else falls through to the real public/sw.js. The owner's setting
348
+ * that lets the automation browser act as the owner does not reach here: that browser still gets no service worker.
323
349
  */
324
350
  function serviceWorker(req, res, next) {
325
- if ((req.method === 'GET' || req.method === 'HEAD') && req.path === SERVICE_WORKER_PATH && heldBack(req)) {
351
+ if ((req.method === 'GET' || req.method === 'HEAD') && req.path === SERVICE_WORKER_PATH && heldBack(req, { grant: false })) {
326
352
  res.setHeader('Cache-Control', 'no-store');
327
353
  res.setHeader('Content-Type', 'text/javascript; charset=utf-8');
328
354
  return res.end(req.method === 'HEAD' ? undefined : SERVICE_WORKER_NOOP);
329
355
  }
330
356
  next();
331
357
  }
332
- return { cookieName: name, cookie, attach, carriesSecret, verify, require, pages, refresh, serviceWorker, fromWorkerBrowser, peerRefusal, peerUnavailable, sendUnavailable, markWorkerBrowserContext };
358
+ return { cookieName: name, cookie, attach, carriesSecret, verify, require, pages, refresh, serviceWorker, fromWorkerBrowser, isAutomationBrowser, automationBrowserGranted, peerRefusal, peerUnavailable, sendUnavailable, markWorkerBrowserContext };
333
359
  }
@@ -99,6 +99,8 @@ export const ADMIN_ONLY_PREFIXES = Object.freeze([
99
99
  // Antigravity's own conversations and models: each uncached answer starts the owner's `agy` (its side panel
100
100
  // socket is refused to guests too).
101
101
  '/api/antigravity',
102
+ // Maritaca's key, defaults and conversations (its side panel socket is refused to guests too).
103
+ '/api/maritaca',
102
104
  '/api/sidepanel',
103
105
  '/api/sidepanel-runs',
104
106
  '/api/loop',
@@ -14,7 +14,7 @@
14
14
 
15
15
  /** The kinds an answer may name, in the order the interface lists them. */
16
16
  export const ACTIVITY_KINDS = Object.freeze([
17
- 'assistant', 'claude-panel', 'codex-panel', 'opencode-panel', 'antigravity-panel', 'claude-cli', 'loop', 'schedule', 'backup', 'maintenance', 'unknown',
17
+ 'assistant', 'claude-panel', 'codex-panel', 'opencode-panel', 'antigravity-panel', 'maritaca-panel', 'claude-cli', 'loop', 'schedule', 'backup', 'maintenance', 'unknown',
18
18
  ]);
19
19
 
20
20
  /** A Claude Code session that took a prompt this recently may still be working on it. */