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
@@ -265,8 +265,9 @@ function prependNotices(result: unknown, notices: RouteNotice[]): unknown {
265
265
  // ── Fields a browser tool does not take ─────────────────────────
266
266
 
267
267
  /**
268
- * Which browser or profile SynaBun drives is the owner's choice (Settings → Browser), never an automation's. A tool
269
- * argument naming one is refused, not silently dropped: before 2026-11-05 zod stripped unknown keys, so
268
+ * Which browser SynaBun drives is the owner's choice (Settings → Browser), and a session picks a MoreLogin profile for
269
+ * itself only through the `morelogin` tool's "use" action (or browser_session create's own moreloginProfile), never
270
+ * through an argument of a page tool. A tool argument naming one is refused, not silently dropped: before 2026-11-05 zod stripped unknown keys, so
270
271
  * `browser_navigate({ profile: "other" })` ran in the default browser and the model believed it had switched profile.
271
272
  * Mirrors OWNER_ONLY_BROWSER_FIELDS in neural-interface/lib/browser-automation-routes.js (the server refuses the same
272
273
  * names on a session create; neural-interface/tests/browser-automation-routes.test.mjs keeps the two lists equal).
@@ -286,7 +287,7 @@ export class OwnerOnlyFieldsError extends Error {
286
287
  readonly fields: string[];
287
288
  constructor(tool: string, fields: string[]) {
288
289
  const names = fields.map(f => `"${f}"`).join(', ');
289
- super(`OWNER_ONLY_FIELDS: ${tool} does not take ${names}. Which browser, MoreLogin profile or browser settings SynaBun uses is the owner's choice (Settings → Browser); browser tools always use the default browser. Leave ${fields.length === 1 ? 'it' : 'them'} out and call ${tool} again. Nothing ran.`);
290
+ super(`OWNER_ONLY_FIELDS: ${tool} does not take ${names}. A browser tool works in the browser of the session that calls it and takes no such argument; the browser settings are the owner's (Settings → Browser). To work in another MoreLogin profile, call morelogin with action "use" (envId or name) first: your browser tools then drive that profile (only a profile the owner allowed agents to choose). Leave ${fields.length === 1 ? 'it' : 'them'} out and call ${tool} again. Nothing ran.`);
290
291
  this.name = 'OwnerOnlyFieldsError';
291
292
  this.fields = fields;
292
293
  }
@@ -52,7 +52,8 @@ function pump() {
52
52
  const interactive = queue.findIndex(t => !t.background);
53
53
  active = queue.splice(interactive < 0 ? 0 : interactive, 1)[0];
54
54
  worker.ref(); worker.channel?.ref();
55
- timer = setTimeout(() => fail(new Error('Local embedding deadline exceeded')), 30_000);
55
+ // Explicit installation may download the model; ordinary offline requests stay bounded.
56
+ timer = setTimeout(() => fail(new Error('Local embedding deadline exceeded')), active.op === 'install' ? 300_000 : 30_000);
56
57
  worker.send({ id: active.id, op: active.op, text: active.text },error=>{if(error)fail(error);});
57
58
  }
58
59
 
@@ -508,6 +508,12 @@ async function acquireInteractive(id: CallerIdentity, url?: string): Promise<Rou
508
508
  function adoptCreatedSession(id: CallerIdentity, created: NiResponse, tabId?: string): { sessionId: string; tabId?: string } {
509
509
  const sessionId = created.sessionId as string;
510
510
  id.state.affinitySessionId = sessionId;
511
+ // A tab of its own in a shared browser (a caller with a MoreLogin profile of its own): released when it leaves.
512
+ if (created.shared === true && typeof created.tabId === 'string') {
513
+ id.state.interactiveSessionId = sessionId;
514
+ id.state.interactiveTabId = created.tabId;
515
+ tabId = tabId || created.tabId;
516
+ }
511
517
  if (id.state.lostRoute) {
512
518
  announceReplacement(id, { sessionId, tabId: tabId || (typeof created.tabId === 'string' ? created.tabId : null) });
513
519
  }
@@ -791,12 +797,18 @@ async function resolveSessionUncached(
791
797
  namedListing = listed;
792
798
  const named = ((listed.sessions || []) as BrowserSessionInfo[]).find(s => s.id === sessionId);
793
799
  if (named && !servesDefault(named)) {
794
- if (!wantsDefaultBrowser) {
795
- return { error: `Browser session ${sessionId} is not the default browser (${describeSession(named)}; the default is ${describeDefault(listed)}), so SynaBun's browser tools do not act on it. Leave sessionId out: browser_navigate opens the page in the default browser.` };
800
+ // Ids of the browser this caller left when it chose another MoreLogin profile (useSessionProfile): the call
801
+ // goes to its own tab in the profile it works in now, and its answer names that tab.
802
+ const replaced = tabId ? id.state.replacedTabs.get(tabId) : undefined;
803
+ const left = id.state.lostRoute?.sessionId === sessionId || !!replaced;
804
+ if (!wantsDefaultBrowser && !left) {
805
+ const own = listed.yourProfile ? 'this session\'s browser' : 'the default browser';
806
+ return { error: `Browser session ${sessionId} is not ${own} (${describeSession(named)}; ${listed.yourProfile ? 'this session works in' : 'the default is'} ${describeDefault(listed)}), so SynaBun's browser tools do not act on it. Leave sessionId out: browser_navigate opens the page in ${own}.${named.profileMode === 'morelogin' ? ' To work in another MoreLogin profile, call morelogin with action "use" first.' : ''}` };
796
807
  }
797
808
  console.error(`[MCP] not using session ${sessionId} (${describeSession(named)}) — resolving ${describeDefault(listed)}`);
798
809
  sessionId = undefined;
799
- tabId = undefined;
810
+ // A tab that was replaced keeps its name: the call goes to its replacement (below).
811
+ if (!replaced) tabId = undefined;
800
812
  }
801
813
  }
802
814
 
@@ -890,6 +902,16 @@ async function resolveSessionUncached(
890
902
  const active = listed.find(s => s.id === pinnedSession);
891
903
  // A run's pinned browser must be the default one. Hard-fail rather than work
892
904
  // in the wrong browser.
905
+ if (active && !servesDefault(active) && check.profileChosen === true) {
906
+ // The run chose another MoreLogin profile for itself (morelogin "use"): its launch tab is in the browser it
907
+ // left. It gets a tab of its own in the profile it works in now, and the server records that as its route.
908
+ const recovered = await recoverRunBrowser(id, { sessionId: pinnedSession, tabId: resolvedTabId });
909
+ if (isBrowserStarting(recovered)) return { error: String(recovered.error), starting: true };
910
+ if (!recovered.error && recovered.sessionId) {
911
+ return { sessionId: recovered.sessionId as string, tabId: (recovered.tabId as string) || undefined };
912
+ }
913
+ return { error: `No browser tab in ${describeDefault(check)}, the profile this run chose: ${recovered.error || 'no tab returned'}\nThe run was not moved to another profile or browser. Pick a profile that can start (morelogin "use"), or go back with morelogin "use" and envId "default".` };
914
+ }
893
915
  if (active && !servesDefault(active)) {
894
916
  return { error: `Pinned browser session ${pinnedSession} is not the default browser (${describeSession(active)}; the default is ${describeDefault(check)}), so this run will not use it. Start the run again so it acquires the default browser.` };
895
917
  }
@@ -1171,6 +1193,8 @@ export interface BrowserRouteStatus {
1171
1193
  movedFromPin: boolean;
1172
1194
  /** The tab it moved from, when known. */
1173
1195
  movedFrom?: { sessionId: string; tabId: string | null } | null;
1196
+ /** The MoreLogin profile this caller works in when it is not the default (its launch's, or its own choice). */
1197
+ profile?: { envId: string; name: string | null } | null;
1174
1198
  }
1175
1199
 
1176
1200
  /**
@@ -1234,7 +1258,10 @@ export async function browserRouteStatus(): Promise<BrowserRouteStatus> {
1234
1258
  const fromHere = !!here && !!moved && moved.to.sessionId === here.sessionId && (!moved.to.tabId || moved.to.tabId === here.tabId);
1235
1259
  const movedFromPin = fromPin || fromHere;
1236
1260
  const movedFrom = fromHere ? moved!.from : fromPin ? { sessionId: pinnedSession!, tabId: pinnedTab } : null;
1237
- return { sessions, current, replacedTabs, lost: id.state.lostRoute, movedFromPin, movedFrom };
1261
+ const yourProfile = listing.yourProfile as { envId?: unknown; name?: unknown } | undefined;
1262
+ const profile = yourProfile && typeof yourProfile.envId === 'string'
1263
+ ? { envId: yourProfile.envId, name: typeof yourProfile.name === 'string' ? yourProfile.name : null } : null;
1264
+ return { sessions, current, replacedTabs, lost: id.state.lostRoute, movedFromPin, movedFrom, profile };
1238
1265
  }
1239
1266
 
1240
1267
  /**
@@ -1276,6 +1303,10 @@ export async function createSession(url?: string): Promise<NiResponse> {
1276
1303
  else if (created.error || typeof created.sessionId !== 'string') return created;
1277
1304
  else {
1278
1305
  id.state.affinitySessionId = created.sessionId as string;
1306
+ if (created.shared === true && typeof created.tabId === 'string') {
1307
+ id.state.interactiveSessionId = created.sessionId as string;
1308
+ id.state.interactiveTabId = created.tabId;
1309
+ }
1279
1310
  resolvedRoutes.delete(id);
1280
1311
  // A start handed over from an earlier create may not be at this URL yet.
1281
1312
  opened = !created.handedOver;
@@ -1887,6 +1918,46 @@ export async function moreloginStop(envId: string): Promise<NiResponse> {
1887
1918
  return request('POST', '/api/morelogin/stop', { envId }, LONG_TIMEOUT);
1888
1919
  }
1889
1920
 
1921
+ /**
1922
+ * This caller works in a MoreLogin profile of its own from now on (POST /api/morelogin/use): `envId`, `name` or
1923
+ * `profile` (either) of a profile MoreLogin lists, or `default: true` for the default of Settings → Browser. Only this
1924
+ * caller moves: the default AI browser and every other session stay where they are. The server releases what the
1925
+ * caller owned in the browser it leaves; here every route this process knew is forgotten, so its next browser call
1926
+ * resolves again and gets a tab of its own in the new profile (started then). The route it left is kept as its lost
1927
+ * route: a call that still names those ids goes to the new tab and says so.
1928
+ */
1929
+ export async function useSessionProfile(ref: { envId?: string; name?: string; profile?: string; default?: boolean }): Promise<NiResponse> {
1930
+ const id = getIdentity();
1931
+ const pins = effectivePins(id);
1932
+ if (!pins.browserSessionId && !pins.browserTabId) await resolveFromAncestors(id);
1933
+ const result = await request('POST', '/api/morelogin/use', { ...ref }, LONG_TIMEOUT);
1934
+ // A Neural Interface from before per-session profiles has no such route and answers it as the owner's.
1935
+ if (result.code === 'OWNER_ROUTE') {
1936
+ return { ...result, error: 'This SynaBun server is older than per-session MoreLogin profiles (it was started before the update): it needs a restart before a session can pick a profile of its own.' };
1937
+ }
1938
+ if (result.error || result.ok !== true || result.changed !== true) return result;
1939
+ const left = knownRoute(id) || (id.state.interactiveSessionId
1940
+ ? { sessionId: id.state.interactiveSessionId, tabId: id.state.interactiveTabId }
1941
+ : null);
1942
+ id.state.interactiveSessionId = null;
1943
+ id.state.interactiveTabId = null;
1944
+ id.state.affinitySessionId = null;
1945
+ id.state.recoveredSessionId = null;
1946
+ id.state.recoveredTabId = null;
1947
+ id.state.servedRoute = null;
1948
+ id.state.routeMoved = null;
1949
+ id.state.replacedTabs.clear();
1950
+ // Only a route the server released is a lost one (a profile that is the default too keeps its tab). The server
1951
+ // names the tab it closed; this process may have known its route by the session alone (a tab-less route).
1952
+ const released = (Array.isArray(result.released) ? result.released : []) as Array<{ sessionId?: unknown; tabId?: unknown }>;
1953
+ const gone = released.find(r => r && r.sessionId === left?.sessionId) || released[0];
1954
+ id.state.lostRoute = gone && typeof gone.sessionId === 'string'
1955
+ ? { sessionId: gone.sessionId, tabId: typeof gone.tabId === 'string' ? gone.tabId : left?.sessionId === gone.sessionId ? left.tabId : null }
1956
+ : null;
1957
+ resolvedRoutes.delete(id);
1958
+ return result;
1959
+ }
1960
+
1890
1961
  export async function moreloginUseDefault(envId: string | null): Promise<NiResponse> {
1891
1962
  return request('POST', '/api/morelogin/use-default', envId ? { envId } : { clear: true });
1892
1963
  }
@@ -1933,6 +2004,8 @@ export type AssistantDispatchBody = {
1933
2004
  maxMinutes?: number;
1934
2005
  budgetUsd?: number;
1935
2006
  usesBrowser?: boolean;
2007
+ /** The MoreLogin profile (id or name) of the worker's browser tab; none = the default browser. */
2008
+ moreloginProfile?: string;
1936
2009
  focus?: boolean;
1937
2010
  title?: string;
1938
2011
  context?: string;
@@ -196,8 +196,8 @@ const DEFINITIONS: readonly ToolGroupDefinition[] = [
196
196
  {
197
197
  id: 'morelogin', label: 'MoreLogin', section: 'browser', browser: false, gate: null,
198
198
  purpose: 'Manage MoreLogin anti-detect browser profiles and pick the browser the browser tools drive',
199
- instructions: '- MoreLogin (anti-detect browser): morelogin (action: status/list/create/start/stop/use_default). Set a profile as the default AI browser with use_default — afterwards all browser_* tools drive that MoreLogin profile. Needs the MoreLogin desktop app running.',
200
- deferredGuidance: '- MoreLogin: profile management; use_default selects the browser for browser_* tools. Requires the desktop app.',
199
+ instructions: '- MoreLogin (anti-detect browser): morelogin (action: status/list/create/start/stop/use/use_default). To work in a profile other than the default, call action "use" with its envId or name: your own browser_* tools then drive that profile in a tab of your own, while other sessions keep theirs (several profiles can be driven at once). Only a profile the owner allowed agents to choose can be used ("list" says which; none until the owner switches one on in Settings → Connected tools → MoreLogin): when "use" or "start" is refused for that, tell the user and stop. use_default is always refused: the default profile is the owner\'s choice in Settings → Browser. Needs the MoreLogin desktop app running.',
200
+ deferredGuidance: '- MoreLogin: profile management; action "use" picks the profile your own browser_* tools drive, among the profiles the owner allowed agents to choose (other sessions unaffected). Requires the desktop app.',
201
201
  tools: ['morelogin'],
202
202
  },
203
203
  {
@@ -55,7 +55,7 @@ export const agentRouteSchema = {
55
55
  kind: z.enum(['direct', 'dispatch']).describe('"direct" = do it here on your own model (or another model of your own provider); "dispatch" = hand it to a worker.'),
56
56
  provider: z.enum(PROVIDERS).optional().describe('Worker provider for "dispatch" (ignored for "direct").'),
57
57
  model: z.string().max(200).optional().describe('Model id from the routing sheet / agent_catalog. Omit for the provider default (or a remembered route).'),
58
- effort: z.string().max(40).optional().describe('Reasoning effort for that model, per agent_catalog (e.g. low…max/ultra; OpenCode uses the model\'s variant names). Unsupported values are corrected to the nearest level the model runs.'),
58
+ effort: z.string().max(40).optional().describe('Reasoning effort for that model, per agent_catalog (e.g. low…max/ultra; OpenCode uses the model\'s variant names). "none" turns thinking off: kept on Claude Code models that think and on Codex / OpenCode models that list none. Unsupported values are corrected to the nearest level the model runs (never to none).'),
59
59
  account_id: z.string().max(64).optional().describe('Claude Code or Codex account id, or "auto" to choose the signed-in subscription with most usage left. API-key accounts are excluded from Auto. A limited pinned/default account falls back within the provider; corrections explain the selection. Another account runs on a worker when the proposal was direct.'),
60
60
  reason: z.string().max(240).optional().describe('Why this model (one short clause, shown on the card).'),
61
61
  })).min(1).max(3).describe('1-3 candidate routes, best first. The first is your pick.'),
@@ -117,7 +117,7 @@ export const agentDispatchSchema = {
117
117
  'Provider model id from agent_catalog (Claude id or alias, a Codex model, or OpenCode "providerID/modelID"). "auto" or omitted = the approved route, a remembered route, or the provider default. Unknown ids are rejected with MODEL_UNKNOWN and suggestions.'
118
118
  ),
119
119
  effort: z.string().max(40).optional().describe(
120
- 'Reasoning effort for the chosen model, per agent_catalog (e.g. low…max/ultra; OpenCode uses the model\'s variant names). Unsupported values are corrected to the nearest level the model runs. Omit for the default.'
120
+ 'Reasoning effort for the chosen model, per agent_catalog (e.g. low…max/ultra; OpenCode uses the model\'s variant names). "none" turns thinking off: kept on Claude Code models that think and on Codex / OpenCode models that list none. Unsupported values are corrected to the nearest level the model runs (never to none). Omit for the default.'
121
121
  ),
122
122
  tools: z.array(z.string().min(1).max(72)).max(32).optional().describe(
123
123
  'SynaBun group ids plus mcp:<exact server name> or mcp:* from agent_catalog.tools.servers. Omitted = core with no external servers; [] = always-on only. Unnamed external servers are off on Codex, OpenCode, Claude and Antigravity. Browser use adds browser; design adds browser, styleguide and image. OpenCode loads the list strictly; Claude Code and Codex keep every SynaBun tool on demand and group choices set focus only; external-server selection is strict.'
@@ -140,6 +140,9 @@ export const agentDispatchSchema = {
140
140
  uses_browser: z.boolean().optional().describe(
141
141
  'true when the worker drives the SynaBun browser: it gets a loop browser tab and the browser enforcement block; page content is treated as untrusted data. Design runs default to true; false keeps one off the browser (no tab, no automatic browser group).'
142
142
  ),
143
+ morelogin_profile: z.string().max(200).optional().describe(
144
+ 'With uses_browser: the MoreLogin profile (its id or its name, as the morelogin tool\'s "list" shows it) the worker\'s browser tab opens in, for this run only. Omit it for the default profile of Settings → Browser. Workers on different profiles run side by side; two on the same profile share its browser, each in its own tab. Only a profile the owner allowed agents to choose (the morelogin tool\'s "list" and "status" say which; none until the owner switches one on in SynaBun\'s Settings → Connected tools → MoreLogin): any other is refused with MORELOGIN_PROFILE_NOT_ALLOWED and nothing starts; tell the user which profile to switch on and where, and never dispatch into another profile instead. Only a Chrome-type profile; one that is unknown, Firefox-type or cannot start fails the dispatch by name (never another profile or browser). Use it when the user names a profile or an account for the task: never change the default AI browser for one run.'
145
+ ),
143
146
  focus: z.boolean().optional().describe(
144
147
  'true to bring the worker\'s sidepanel tab to the front on attach. Default false: runs attach without stealing focus.'
145
148
  ),
@@ -234,7 +237,7 @@ export const agentUsageSchema = {
234
237
  // ── Descriptions (routing instructions) ──
235
238
 
236
239
  export const agentCatalogDescription =
237
- 'Discover what you can route to: providers (claude-code, codex, opencode, antigravity) with models (tier, price per 1M tokens, vision, context, efforts), accounts with subscription usage remaining (or usage unknown; API keys are n/a), registered projects (cwd candidates), SynaBun tool groups and each host\'s effect, rails/limits and active runs. Without arguments it returns a compact routing view (OpenCode sampled); pass provider and/or search to list more models. Call it when the routing sheet in your instructions lacks a model, or after a MODEL_UNKNOWN rejection. Returns JSON.';
240
+ 'Discover what you can route to: providers (claude-code, codex, opencode, antigravity) with models (tier, price per 1M tokens, vision, context, efforts), plus `chat` (chat-only providers such as maritaca: a side panel the user talks to, prices in BRL, never a dispatch target), accounts with subscription usage remaining (or usage unknown; API keys are n/a), registered projects (cwd candidates), SynaBun tool groups and each host\'s effect, rails/limits and active runs. Without arguments it returns a compact routing view (OpenCode sampled); pass provider and/or search to list more models. Call it when the routing sheet in your instructions lacks a model, or after a MODEL_UNKNOWN rejection. Returns JSON.';
238
241
 
239
242
  export const agentRouteDescription =
240
243
  'Route an actionable task BEFORE starting it (you are the planner). Give task_class, a one-line summary, your honest confidence (0-1) and 1-3 proposals (direct = here on your model; dispatch = a worker provider/model). proposals.account_id accepts an account id or "auto" (most subscription usage left); limited pinned/default accounts fall back within the provider. The returned target.account includes usage and corrections explain the choice. The server applies the session\'s route mode (always ask / ask when unsure / never ask): it approves at once, or shows the user a route card and waits briefly. On a route card the user can always pick here or a worker, whatever you proposed: follow the returned target.kind and next, never your proposal. Follow the returned status and next: approved+dispatch → agent_dispatch with route_id; approved+direct → do it yourself (a route the user kept here is never dispatched: agent_dispatch refuses it with ROUTE_IS_DIRECT); continuation → end your turn (SynaBun continues on the chosen model); pending → end your turn, the choice arrives as a [SynaBun Mailbox] route_decided event; declined → do not start (reason no_capable_model: no model can make the image or video, or see for design; tell the user which Model routes row needs one); clarifying → end your turn, the user has not answered your agent_clarify questions yet (independent:true for a task that does not depend on them). image_gen / video_gen always route to a worker whose model generates the medium, design to a worker whose model can see. With a session budget, a provider whose share is used up cannot take the task: SynaBun first divides the unspent budget again, then moves the task to the next capable provider with money left (your next proposal, the same tier on another provider, then a free model) and says so in corrections (reason budget_share, "budget: codex share used up -> claude-code/sonnet"); the saved routes yield to this. When no provider can pay it declines with reason budget_exhausted and names the dry providers (dry). The result carries budget: each provider\'s share, spent and left. Never use it for conversation or bookkeeping. Returns JSON.';
@@ -246,7 +249,7 @@ export const agentListDescription =
246
249
  'List dispatched worker runs with status, state, provider/model, title, elapsed time, work time left (workLeftMs), cost and resumes (how often a server restart cut the run off and it was resumed). Use it before dispatching more work, to recover run ids, or after a mailbox event. Filter with active_only, assistant_session_id (your own session) or workflow_id. Returns JSON.';
247
250
 
248
251
  export const agentDispatchDescription =
249
- 'Dispatch a task to a worker agent (Claude Code, Codex or OpenCode). Route it first with agent_route and pass the approved route_id (the server applies that provider/model/effort); without one, the dispatch may be held until the user picks a model (awaitingRoute:true — do not dispatch it again; if the user picks "here" instead, the run never starts and a route_decided mailbox event asks you to do the task yourself). A route_id the user decided to keep here is refused (ROUTE_IS_DIRECT): do that task yourself. After agent_clarify, pass its brief_id: the worker gets the user\'s own words and answers; while its questions are open a dependent dispatch is refused (CLARIFICATION_PENDING). The run attaches as a live automation tab in the matching sidepanel without stealing focus. Write a self-contained task that ends with a ## Result block, pass the absolute cwd and your assistant_session_id. Defaults: permission_policy "auto", capability "full", 45 minutes of work time (max_minutes, at least 20), no per-run dollar ceiling (with a budget the run draws from its provider\'s share; a provider whose share is used up and cannot get more is refused with BUDGET_SHARE_EXHAUSTED: route again). Use "ask" only for sensitive scopes (Codex cannot ask: use "restricted"). uses_computer:true for desktop work (one at a time, vision model). An image_gen / video_gen run makes the asset with its model\'s own generation tool; SynaBun collects the files into the run\'s result (media: path + url); with no model that generates the medium an un-routed dispatch is refused (NO_CAPABLE_MODEL), and a route_id approved for other work is refused for image_gen / video_gen / design (and the other way round: ROUTE_CLASS_MISMATCH; route the task again with its own class). A design run gets SynaBun\'s design rules and the project\'s style guide, defaults to capability "workspace", uses_browser true, browser, styleguide and image groups, and 60 minutes of work time (explicit values win), runs only on a model confirmed to see (MODEL_CANNOT_SEE otherwise), and its screenshots land in the result\'s media. Group fan-outs with workflow_id, chain with parent_run_id, retry safely with idempotency_key. Over-limit dispatches are queued (queued:true, position). After dispatching, block with agent_wait rather than polling. Returns JSON.';
252
+ 'Dispatch a task to a worker agent (Claude Code, Codex or OpenCode). Route it first with agent_route and pass the approved route_id (the server applies that provider/model/effort); without one, the dispatch may be held until the user picks a model (awaitingRoute:true — do not dispatch it again; if the user picks "here" instead, the run never starts and a route_decided mailbox event asks you to do the task yourself). A route_id the user decided to keep here is refused (ROUTE_IS_DIRECT): do that task yourself. After agent_clarify, pass its brief_id: the worker gets the user\'s own words and answers; while its questions are open a dependent dispatch is refused (CLARIFICATION_PENDING). The run attaches as a live automation tab in the matching sidepanel without stealing focus. Write a self-contained task that ends with a ## Result block, pass the absolute cwd and your assistant_session_id. Defaults: permission_policy "auto", capability "full", 45 minutes of work time (max_minutes, at least 20), no per-run dollar ceiling (with a budget the run draws from its provider\'s share; a provider whose share is used up and cannot get more is refused with BUDGET_SHARE_EXHAUSTED: route again). Use "ask" only for sensitive scopes (Codex cannot ask: use "restricted"). uses_computer:true for desktop work (one at a time, vision model). uses_browser:true with morelogin_profile (a profile id or name) opens the worker\'s browser tab in that MoreLogin profile for this run only, next to runs in the default or other profiles (only a profile the owner allowed agents to choose; MORELOGIN_PROFILE_NOT_ALLOWED otherwise: tell the user to switch it on in Settings). An image_gen / video_gen run makes the asset with its model\'s own generation tool; SynaBun collects the files into the run\'s result (media: path + url); with no model that generates the medium an un-routed dispatch is refused (NO_CAPABLE_MODEL), and a route_id approved for other work is refused for image_gen / video_gen / design (and the other way round: ROUTE_CLASS_MISMATCH; route the task again with its own class). A design run gets SynaBun\'s design rules and the project\'s style guide, defaults to capability "workspace", uses_browser true, browser, styleguide and image groups, and 60 minutes of work time (explicit values win), runs only on a model confirmed to see (MODEL_CANNOT_SEE otherwise), and its screenshots land in the result\'s media. Group fan-outs with workflow_id, chain with parent_run_id, retry safely with idempotency_key. Over-limit dispatches are queued (queued:true, position). After dispatching, block with agent_wait rather than polling. Returns JSON.';
250
253
 
251
254
  export const agentStatusDescription =
252
255
  'Get one run\'s current descriptor: status (queued, starting, running, completed, failed, stopped, interrupted), state (the detail: also idle, awaiting_permission, and suspended / resuming while a SynaBun server restart cuts a Claude Code worker off and the next start resumes it as the same run, its Claude session and its tab; resumes counts that, at most 3; a run that could not be resumed ends interrupted, with why in notes), turnState (running, idle, awaiting_permission), provider/model/account, elapsed time (elapsedMs, wall clock), work time used and left of max_minutes (workMs, workLeftMs), cost, the last parsed result summary and any pending permission or question requests. Cheap; use it between agent_wait calls or before agent_send / agent_stop. Returns JSON.';
@@ -369,6 +372,7 @@ export function handleAgentDispatch(args: AgentDispatchArgs): Promise<ToolResult
369
372
  maxMinutes: args.max_minutes,
370
373
  budgetUsd: args.budget_usd,
371
374
  usesBrowser: args.uses_browser,
375
+ moreloginProfile: args.morelogin_profile,
372
376
  focus: args.focus,
373
377
  title: args.title,
374
378
  context: args.context,
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod/v3';
2
2
  import * as ni from '../services/neural-interface.js';
3
3
  import { text } from './response.js';
4
+ import { useAnswer } from './morelogin.js';
4
5
 
5
6
  const tabIdField = z.string().optional().describe('Target a specific tab within the session. Auto-resolved from environment if omitted.');
6
7
 
@@ -91,17 +92,22 @@ export const browserSessionSchema = {
91
92
  url: z.string().optional().describe('Starting URL for "create" action (default: about:blank).'),
92
93
  sessionId: z.string().optional().describe('Session ID for "close" action. Required for close when multiple sessions exist (or pass your tabId).'),
93
94
  tabId: z.string().optional().describe('Your tab id, as the other browser tools take it. "status" / "list": says whether it is still your current tab (a lost tab names the tab that replaced it). "close": closes only this tab of yours; a tab that is not yours is refused and nothing is closed. Ignored by "create", which always opens a new tab of your own.'),
95
+ moreloginProfile: z.string().optional().describe('"create" only: the MoreLogin profile (its id or its name, as the morelogin tool\'s "list" shows it) to work in from now on. The new tab opens in that profile and your later browser calls stay there; the default browser and other sessions are not touched. "default" goes back to the default profile. The same as calling morelogin with action "use" first, with the same rule: only a profile the owner allowed agents to choose (morelogin "list" says which); a refusal for a profile not on that list means tell the user to switch it on in SynaBun\'s Settings, never another profile. Omit it to stay in the profile you work in.'),
94
96
  };
95
97
 
96
98
  export const browserSessionDescription =
97
- 'Manage browser sessions — list open sessions and your tabs in them, see which tab you work in ("status"), create a new one, or close one (pass your tabId to close only that tab of yours). Use "status" to find your current tab id. When a browser tool\'s answer starts with "Your tab … was lost; a replacement tab … is open", continue in that tab (no create). Use "create" when your browser session or tab was lost (closed, disconnected, "Session not found", "Tab … not found"): it opens a new tab of your own in the SynaBun browser, starting the browser when it is not running, and in a loop or a dispatched run your next browser calls go to it. Only if create fails too, stop and report it; never switch to another browser. Closing a session other automations still use closes only your own tab in it; the session stays open for them.';
99
+ 'Manage browser sessions — list open sessions and your tabs in them, see which tab you work in ("status"), create a new one, or close one (pass your tabId to close only that tab of yours). Use "status" to find your current tab id. When a browser tool\'s answer starts with "Your tab … was lost; a replacement tab … is open", continue in that tab (no create). Use "create" when your browser session or tab was lost (closed, disconnected, "Session not found", "Tab … not found"): it opens a new tab of your own in the SynaBun browser, starting the browser when it is not running, and in a loop or a dispatched run your next browser calls go to it. Only if create fails too, stop and report it; never switch to another browser. To work in a MoreLogin profile other than the default (a second account, while other automations use the default one), pass moreloginProfile to "create" or call morelogin with action "use": your browser tools then drive that profile in a tab of your own and nobody else is moved (only a profile the owner allowed agents to choose; when it is refused as not on the owner\'s list, tell the user to switch it on in SynaBun\'s Settings and stop). Closing a session other automations still use closes only your own tab in it; the session stays open for them.';
98
100
 
99
101
  export async function handleBrowserSession(args: {
100
102
  action: string;
101
103
  url?: string;
102
104
  sessionId?: string;
103
105
  tabId?: string;
106
+ moreloginProfile?: string;
104
107
  }) {
108
+ if (args.moreloginProfile && args.action !== 'create') {
109
+ return text('moreloginProfile goes with action "create" (or call morelogin with action "use"). Nothing ran.');
110
+ }
105
111
  if (args.action === 'list' || args.action === 'status') {
106
112
  const status = await ni.browserRouteStatus();
107
113
  if (status.error) return text(`${args.action === 'list' ? 'List' : 'Status'} failed: ${status.error}`);
@@ -111,14 +117,21 @@ export async function handleBrowserSession(args: {
111
117
  }
112
118
 
113
119
  if (args.action === 'create') {
120
+ let profileLine: string | null = null;
121
+ if (args.moreloginProfile) {
122
+ const wanted = args.moreloginProfile.trim();
123
+ const chosen = await ni.useSessionProfile(wanted.toLowerCase() === 'default' ? { default: true } : { profile: wanted });
124
+ if (chosen.error) return text(`Create failed: the MoreLogin profile "${wanted}" could not be chosen: ${chosen.error}\nNothing changed: you still work where you did. Never fall back to another profile or browser by yourself.`);
125
+ profileLine = useAnswer(chosen).split('\n')[0];
126
+ }
114
127
  const result = await ni.createSession(args.url);
115
128
  // A cold browser start still running: nothing failed, and the next create returns that same start.
116
- if (ni.isBrowserStarting(result)) return text(String(result.error || 'The browser is still starting. Call browser_session with action "create" again in a moment.'));
117
- if (result.error) return text(`Create failed: ${result.error}\nThe SynaBun browser could not open a new session: stop and report this. Never switch to another browser or tool.`);
129
+ if (ni.isBrowserStarting(result)) return text([profileLine, String(result.error || 'The browser is still starting. Call browser_session with action "create" again in a moment.')].filter(Boolean).join('\n'));
130
+ if (result.error) return text(`${profileLine ? `${profileLine}\n` : ''}Create failed: ${result.error}\nThe SynaBun browser could not open a new session: stop and report this. Never switch to another browser or tool.`);
118
131
  const sessionId = String(result.sessionId);
119
132
  const tabId = typeof result.tabId === 'string' ? result.tabId : null;
120
133
  const ids = `sessionId "${sessionId}"${tabId ? ` and tabId "${tabId}"` : ''}`;
121
- const lines = [`Created session ${sessionId}${tabId ? `, tab ${tabId}` : ''} at ${typeof result.url === 'string' ? result.url : args.url || 'about:blank'}.`];
134
+ const lines = [...(profileLine ? [profileLine] : []), `Created session ${sessionId}${tabId ? `, tab ${tabId}` : ''} at ${typeof result.url === 'string' ? result.url : args.url || 'about:blank'}.`];
122
135
  lines.push(result.repinned === true
123
136
  ? `This run's browser now works there: your next browser calls go to it with or without ids (pass ${ids} if you pass ids; never the old ones).`
124
137
  : `Continue there: pass ${ids} to your next browser calls.`);
@@ -190,7 +203,7 @@ export function formatSessionList(status: ni.BrowserRouteStatus): string {
190
203
  if (status.sessions.length === 0) return 'No browser sessions open. browser_navigate opens one by itself.';
191
204
  const lines = [`${status.sessions.length} session(s); only your own tabs are listed:`];
192
205
  for (const session of status.sessions) {
193
- lines.push(` ${session.id}${session.servesDefault ? '' : ` — not the default browser (${session.profile}); SynaBun's browser tools do not use it`}`);
206
+ lines.push(` ${session.id}${session.servesDefault ? '' : ` — not ${status.profile ? 'the profile you work in' : 'the default browser'} (${session.profile}); SynaBun's browser tools do not use it`}`);
194
207
  for (const tab of session.tabs) {
195
208
  const isCurrent = status.current?.open && status.current.sessionId === session.id && status.current.tabId === tab.id;
196
209
  lines.push(` tab ${tab.id} — ${tab.url || 'about:blank'}${quoteTitle(tab.title)}${isCurrent ? ' ← your current tab' : ''}`);
@@ -200,9 +213,15 @@ export function formatSessionList(status: ni.BrowserRouteStatus): string {
200
213
  }
201
214
  if (status.current && !status.current.open) lines.push(lostTabLine(status.current));
202
215
  else if (!status.current) lines.push('You have no tab of your own yet: browser_navigate opens one.');
216
+ if (status.profile) lines.push(profileLineOf(status.profile));
203
217
  return lines.join('\n');
204
218
  }
205
219
 
220
+ /** The profile a caller works in when it is not the default. */
221
+ function profileLineOf(profile: NonNullable<ni.BrowserRouteStatus['profile']>): string {
222
+ return `Profile: you work in MoreLogin profile ${profile.name ? `"${profile.name}" (env ${profile.envId})` : `env ${profile.envId}`}, not the default one (morelogin "use" changes it; envId "default" goes back).`;
223
+ }
224
+
206
225
  function lostTabLine(current: NonNullable<ni.BrowserRouteStatus['current']>): string {
207
226
  return `Your tab ${current.tabId || '(none)'} of session ${current.sessionId} is gone. Your next browser call opens a new tab of your own, and its answer starts with that tab's id: continue there. Call browser_session create only if a browser call fails because the tab is gone and announces no replacement.`;
208
227
  }
@@ -210,11 +229,12 @@ function lostTabLine(current: NonNullable<ni.BrowserRouteStatus['current']>): st
210
229
  /** browser_session status: the route the caller's next browser call uses, its page, and what replaced what. */
211
230
  export function formatRouteStatus(status: ni.BrowserRouteStatus): string {
212
231
  const current = status.current;
232
+ const withProfile = (line: string) => (status.profile ? `${line}\n${profileLineOf(status.profile)}` : line);
213
233
  if (!current) {
214
- if (status.lost) return `Your tab ${status.lost.tabId || '(none)'} of session ${status.lost.sessionId} is gone and no tab replaced it yet. Your next browser call opens a new tab of your own, and its answer starts with that tab's id.`;
215
- return 'You have no browser tab yet: browser_navigate opens one (no browser_session create needed).';
234
+ if (status.lost) return withProfile(`Your tab ${status.lost.tabId || '(none)'} of session ${status.lost.sessionId} is gone and no tab replaced it yet. Your next browser call opens a new tab of your own, and its answer starts with that tab's id.`);
235
+ return withProfile('You have no browser tab yet: browser_navigate opens one (no browser_session create needed).');
216
236
  }
217
- if (!current.open) return lostTabLine(current);
237
+ if (!current.open) return withProfile(lostTabLine(current));
218
238
  const lines = [
219
239
  `Current session: ${current.sessionId}`,
220
240
  `Current tab: ${current.tabId}`,
@@ -232,5 +252,6 @@ export function formatRouteStatus(status: ni.BrowserRouteStatus): string {
232
252
  if (status.lost && !(status.lost.sessionId === current.sessionId && status.lost.tabId === current.tabId)) {
233
253
  lines.push(`Your tab ${status.lost.tabId || '(none)'} of session ${status.lost.sessionId} went away; your next browser call may open a new tab and will say so.`);
234
254
  }
255
+ if (status.profile) lines.push(profileLineOf(status.profile));
235
256
  return lines.join('\n');
236
257
  }
@@ -2,8 +2,6 @@ import { z } from 'zod/v3';
2
2
  import * as ni from '../services/neural-interface.js';
3
3
  import { text } from './response.js';
4
4
  import { formatInlineSnapshot, formatAiSnapshotBody } from './browser-observe.js';
5
- import { autosnapshotEnabled } from './browser-interact.js';
6
- import * as assist from '../services/browser-assist.js';
7
5
 
8
6
  const tabIdField = z.string().optional().describe('Target a specific tab within the session. Auto-resolved from environment if omitted.');
9
7
 
@@ -25,6 +23,15 @@ function formatBrowserLocation(result: Record<string, unknown>, action: string):
25
23
 
26
24
  const NAVIGATE_SNAPSHOT_MAX_CHARS = 12000;
27
25
 
26
+ const SLOW_LOAD_FALLBACK_NOTICE = 'the document committed but is still loading; wait a moment, then read it with browser_snapshot. Do not navigate to it again.';
27
+
28
+ /** A navigate the server answered `slowLoad: true`: the URL and the server's notice, nothing else. */
29
+ export function formatSlowLoad(result: Record<string, unknown>, requestedUrl: string): string {
30
+ const url = typeof result.url === 'string' && result.url ? result.url : requestedUrl;
31
+ const notice = typeof result.notice === 'string' && result.notice.trim() ? result.notice.trim() : SLOW_LOAD_FALLBACK_NOTICE;
32
+ return `Slow page: ${url}\nnote: ${notice}`;
33
+ }
34
+
28
35
  // One-line per-platform steering appended to navigate responses: points the model at
29
36
  // the cheap extraction path instead of full snapshots on feed-heavy sites.
30
37
  const PLATFORM_HINTS: Array<{ re: RegExp; hint: string }> = [
@@ -51,21 +58,18 @@ function platformHint(url: unknown): string {
51
58
 
52
59
  export const browserNavigateSchema = {
53
60
  url: z.string().describe('The URL to navigate to.'),
54
- snapshot: z.enum(['full', 'diff', 'none']).optional().describe('Inline AI snapshot of the new page (default "full", with [ref=eN] refs for actions). "none" = terse response.'),
55
- intent: z.string().max(300).optional().describe('What you expect this page to let you do or show (e.g. "read my open invoices"). Adds a "goal satisfied" estimate to the page assessment. Advisory only.'),
61
+ snapshot: z.enum(['full', 'diff', 'none']).optional().describe('Inline AI snapshot of the new page. Default "none": a terse answer as soon as the page loads. "full" waits for the document to parse and returns [ref=eN] refs; otherwise call browser_snapshot when you need the page structure.'),
56
62
  returnSnapshot: returnSnapshotField,
57
63
  sessionId: z.string().optional().describe('Browser session ID. If omitted, auto-selects the only open session or creates a new one.'),
58
64
  tabId: tabIdField,
59
65
  };
60
66
 
61
67
  export const browserNavigateDescription =
62
- 'Navigate the browser to a URL (auto-creates a session if needed). By default the response includes an AI snapshot of the new page with [ref=eN] element refs — act on them directly with browser_click/fill/type, no separate snapshot call needed. ' +
63
- 'A "Jev assessment:" line may follow (usable, loading, authentication_required, verification_required, consent_blocker, error, empty): it is advice about the page, never an action. On a sign-in or verification wall, stop and hand over to a human.';
68
+ 'Navigate the browser to a URL (auto-creates a session if needed). Returns as soon as the page commits (url, title, loadState "commit" or "domcontentloaded"); no snapshot by default. Call browser_snapshot for the page structure and [ref=eN] refs, or pass snapshot:"full" to get them inline (that waits for the document to parse).';
64
69
 
65
70
  export async function handleBrowserNavigate(args: {
66
71
  url: string;
67
72
  snapshot?: 'full' | 'diff' | 'none';
68
- intent?: string;
69
73
  returnSnapshot?: { mode?: 'full' | 'interactive' | 'landmarks'; selector?: string; viewport?: boolean; maxChars?: number; format?: 'text' | 'json' };
70
74
  sessionId?: string;
71
75
  tabId?: string;
@@ -80,20 +84,19 @@ export async function handleBrowserNavigate(args: {
80
84
  selector: args.returnSnapshot.selector,
81
85
  viewport: args.returnSnapshot.viewport,
82
86
  } : undefined;
83
- // New page → full AI snapshot by default (diff vs the previous page is meaningless).
84
- const snapshot = args.snapshot ?? (rs || !autosnapshotEnabled() ? undefined : 'full');
85
- // The page-state context comes back in this same round trip; the judgment itself runs here, never in the Neural Interface.
86
- const assess = assist.assistAvailable('browser-page-state');
87
- const result = await ni.navigate(resolved.sessionId, args.url, resolved.tabId, rs, snapshot, undefined, { semanticContext: assess });
87
+ // No snapshot unless asked (2026-11-08 benchmark: the default full snapshot cost seconds per navigate).
88
+ const snapshot = args.snapshot === 'full' || args.snapshot === 'diff' ? args.snapshot : undefined;
89
+ const result = await ni.navigate(resolved.sessionId, args.url, resolved.tabId, rs, snapshot, undefined);
88
90
  if (result.error) return text(`Navigation failed: ${result.error}`);
91
+ // The document committed but did not finish loading in the server's budget (x.com's cold first
92
+ // load): there is no title, snapshot or page context yet, so none is printed as "(empty page)".
93
+ if (result.slowLoad === true) return text(formatSlowLoad(result, args.url));
89
94
 
90
95
  let msg = formatBrowserLocation(result, 'Navigated');
96
+ if (result.loadState === 'commit') msg += ' (still parsing)';
91
97
  if (typeof result.notice === 'string') msg += `\nnote: ${result.notice}`;
92
98
  msg += platformHint(result.url);
93
- // Advice about the page that loaded. Bounded by the surface timeout, and empty when Jev is off,
94
- // rate-limited, unsure, or the page is an unremarkable "usable" in compact mode.
95
- if (assess) msg += await assist.assessNavigation(result, args.intent);
96
- if (snapshot && snapshot !== 'none') {
99
+ if (snapshot) {
97
100
  msg += `\n\n--- Snapshot ---\n${formatAiSnapshotBody(result, NAVIGATE_SNAPSHOT_MAX_CHARS)}`;
98
101
  } else if (args.returnSnapshot) {
99
102
  const snap = formatInlineSnapshot(result, {
@@ -489,6 +489,8 @@ interface PagedOpts extends PagedArgs {
489
489
 
490
490
  interface PagedResult {
491
491
  items: Array<Record<string, unknown>>;
492
+ /** The distinct `type` of the returned items, read before `fields` projected them (null: no string type). */
493
+ types?: Array<string | null>;
492
494
  raw: number;
493
495
  scrollsUsed: number;
494
496
  truncated: boolean;
@@ -571,6 +573,7 @@ async function runPagedExtractor(
571
573
 
572
574
  const all = [...collected.values()];
573
575
  const items: Array<Record<string, unknown>> = [];
576
+ const types = new Set<string | null>();
574
577
  let chars = 2;
575
578
  let budgetReason: string | undefined;
576
579
  for (const item of all) {
@@ -579,9 +582,21 @@ async function runPagedExtractor(
579
582
  const size = JSON.stringify(value).length + (items.length ? 1 : 0);
580
583
  if (opts.maxChars !== undefined && chars + size > opts.maxChars) { budgetReason = 'max_chars'; break; }
581
584
  items.push(value); chars += size;
585
+ types.add(typeof item.type === 'string' ? item.type : null);
582
586
  }
583
587
  if (items.length === 0 && budgetReason === 'max_chars') return { error: 'maxChars is too small for the first complete item. Increase maxChars or select fewer fields.' };
584
- return { items, raw, scrollsUsed, truncated: items.length < all.length, partial: !!failureReason, stopReason: budgetReason || stopReason, failureReason, budgetReason };
588
+ return { items, types: [...types], raw, scrollsUsed, truncated: items.length < all.length, partial: !!failureReason, stopReason: budgetReason || stopReason, failureReason, budgetReason };
589
+ }
590
+
591
+ /**
592
+ * Whether every returned item is of `type`, decided on the items before `fields` projected them
593
+ * (`types`, from the server or the local loop). A server from before `types` answers from the
594
+ * projected items, where a projection without `type` reads as untyped.
595
+ */
596
+ function extractedTypesAre(res: PagedResult, type: string): boolean {
597
+ if (res.items.length === 0) return false;
598
+ if (Array.isArray(res.types)) return res.types.length > 0 && res.types.every(t => t === type);
599
+ return res.items.every(item => item.type === type);
585
600
  }
586
601
 
587
602
  /**
@@ -614,23 +629,49 @@ const SCROLLABLE_ANCESTOR = (innerSelector: string) =>
614
629
 
615
630
  // ── browser_extract_tweets ──
616
631
 
617
- const TWEET_EXTRACTOR_SCRIPT = `
618
- Array.from(document.querySelectorAll('[data-testid="tweet"]')).map(el => {
619
- const userNameEl = el.querySelector('[data-testid="User-Name"]');
620
- const lines = userNameEl ? userNameEl.innerText.split('\\n').filter(Boolean) : [];
621
- const statusLink = el.querySelector('a[href*="/status/"]');
622
- return {
623
- author: lines[0] || null,
624
- handle: lines.find(l => l.startsWith('@')) || null,
625
- text: el.querySelector('[data-testid="tweetText"]')?.innerText || null,
626
- time: el.querySelector('time')?.getAttribute('datetime') || null,
627
- url: statusLink ? statusLink.href : null,
628
- replies: el.querySelector('[data-testid="reply"] span[data-testid="app-text-transition-container"]')?.innerText || null,
629
- reposts: el.querySelector('[data-testid="retweet"] span[data-testid="app-text-transition-container"]')?.innerText || null,
630
- likes: el.querySelector('[data-testid="like"] span[data-testid="app-text-transition-container"]')?.innerText || null,
631
- views: el.querySelector('a[href*="/analytics"] span')?.innerText || null,
632
- };
633
- })
632
+ // One expression, DOM queries only (no eval, innerHTML or script insertion): the server embeds
633
+ // it in the page functions of the paged extraction, which x.com's CSP ('script-src' without
634
+ // 'unsafe-eval') must not be able to refuse. Exported for the fixture test
635
+ // (neural-interface/tests/x-extractor.browser.mjs) that runs it against X-shaped pages.
636
+ export const TWEET_EXTRACTOR_SCRIPT = `
637
+ (() => {
638
+ const tweets = Array.from(document.querySelectorAll('[data-testid="tweet"]')).map(el => {
639
+ const userNameEl = el.querySelector('[data-testid="User-Name"]');
640
+ const lines = userNameEl ? userNameEl.innerText.split('\\n').filter(Boolean) : [];
641
+ const statusLink = el.querySelector('a[href*="/status/"]');
642
+ return {
643
+ author: lines[0] || null,
644
+ handle: lines.find(l => l.startsWith('@')) || null,
645
+ text: el.querySelector('[data-testid="tweetText"]')?.innerText || null,
646
+ time: el.querySelector('time')?.getAttribute('datetime') || null,
647
+ url: statusLink ? statusLink.href : null,
648
+ replies: el.querySelector('[data-testid="reply"] span[data-testid="app-text-transition-container"]')?.innerText || null,
649
+ reposts: el.querySelector('[data-testid="retweet"] span[data-testid="app-text-transition-container"]')?.innerText || null,
650
+ likes: el.querySelector('[data-testid="like"] span[data-testid="app-text-transition-container"]')?.innerText || null,
651
+ views: el.querySelector('a[href*="/analytics"] span')?.innerText || null,
652
+ };
653
+ });
654
+ // Explore's tabs (trending, for-you, news, ...) list trends, not posts: say what is there.
655
+ if (tweets.length || !/^\\/(explore|i\\/trends)(\\/|$)/.test(location.pathname)) return tweets;
656
+ const rowText = row => (row?.innerText || '').split('\\n').map(s => s.trim()).filter(s => s && s !== '·');
657
+ // The page's own column only: the sidebar's "What's happening" trends are never the answer.
658
+ const column = document.querySelector('[data-testid="primaryColumn"]');
659
+ return Array.from(column ? column.querySelectorAll('[data-testid="trend"]') : []).map((el, i) => {
660
+ // A cell is rows: context (rank · category), name, an optional post count; the caret button is not one.
661
+ const rows = Array.from(el.firstElementChild?.children || []).filter(row => !row.querySelector('button'));
662
+ const context = rowText(rows[0]);
663
+ const rank = /^\\d+$/.test(context[0] || '') ? Number(context[0]) : null;
664
+ const name = rowText(rows[1]).join(' ') || null;
665
+ return {
666
+ type: 'trend',
667
+ rank: rank ?? i + 1,
668
+ category: (rank === null ? context : context.slice(1)).join(' ') || null,
669
+ text: name,
670
+ posts: rowText(rows[2]).join(' ') || null,
671
+ url: name ? 'https://x.com/search?q=' + encodeURIComponent(name) + '&src=typed_query&f=live' : null,
672
+ };
673
+ });
674
+ })()
634
675
  `.trim();
635
676
 
636
677
  export const browserExtractTweetsSchema = {
@@ -640,7 +681,8 @@ export const browserExtractTweetsSchema = {
640
681
  };
641
682
 
642
683
  export const browserExtractTweetsDescription =
643
- 'Extract visible tweets as structured JSON (author, handle, text, time, url, replies, reposts, likes, views). Pass scrolls/minItems to auto-scroll, extract, and dedupe in ONE call (e.g. scrolls:3 minItems:30). Much faster than browser_snapshot for data harvesting. Navigate to x.com/search?q=%23hashtag&f=live first for latest-first hashtag results.';
684
+ 'Extract visible tweets as structured JSON (author, handle, text, time, url, replies, reposts, likes, views). Pass scrolls/minItems to auto-scroll, extract, and dedupe in ONE call (e.g. scrolls:3 minItems:30). Much faster than browser_snapshot for data harvesting. Navigate to x.com/search?q=%23hashtag&f=live first for latest-first hashtag results. ' +
685
+ 'An Explore tab (x.com/explore/tabs/trending, for-you, news) lists trends, not posts: there it returns the trends instead, {type:"trend", rank, category, text, posts, url} with url a latest-first search for the trend.';
644
686
 
645
687
  export async function handleBrowserExtractTweets(args: PagedArgs & { sessionId?: string; tabId?: string }) {
646
688
  const resolved = await ni.resolveSession(args.sessionId, undefined, args.tabId);
@@ -652,7 +694,7 @@ export async function handleBrowserExtractTweets(args: PagedArgs & { sessionId?:
652
694
  if ('error' in res) return text(`Extract failed: ${res.error}`);
653
695
  if (res.items.length === 0) return emptyExtraction(resolved, 'browser_extract_tweets', 'an X/Twitter timeline, profile or search results page', 'No tweets found. Try browser_scroll (or pass scrolls:2) then retry.');
654
696
 
655
- return text(formatExtraction('tweet', res));
697
+ return text(formatExtraction(extractedTypesAre(res, 'trend') ? 'trend' : 'tweet', res));
656
698
  }
657
699
 
658
700
  // ── browser_x_compose_state ──