synabun 2.3.1 → 2.4.1

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 (370) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +1 -1
  3. package/browser-extension/content.js +189 -0
  4. package/browser-extension/engine.js +508 -0
  5. package/browser-extension/icons/icon-128.png +0 -0
  6. package/browser-extension/icons/icon-16.png +0 -0
  7. package/browser-extension/icons/icon-32.png +0 -0
  8. package/browser-extension/icons/icon-48.png +0 -0
  9. package/browser-extension/icons/status-off-16.png +0 -0
  10. package/browser-extension/icons/status-off-32.png +0 -0
  11. package/browser-extension/icons/status-off-48.png +0 -0
  12. package/browser-extension/icons/status-on-16.png +0 -0
  13. package/browser-extension/icons/status-on-32.png +0 -0
  14. package/browser-extension/icons/status-on-48.png +0 -0
  15. package/browser-extension/manifest.json +56 -0
  16. package/browser-extension/popup-strings.js +250 -0
  17. package/browser-extension/popup-view.js +151 -0
  18. package/browser-extension/popup.css +166 -0
  19. package/browser-extension/popup.html +108 -0
  20. package/browser-extension/popup.js +359 -0
  21. package/browser-extension/protocol.js +232 -0
  22. package/browser-extension/service-worker.js +275 -0
  23. package/browser-extension/setup-content.js +36 -0
  24. package/browser-extension/tokens.css +326 -0
  25. package/docs/browser-extension-bridge.md +84 -0
  26. package/docs/whatsapp.md +1 -1
  27. package/lib/data-home-files.js +45 -0
  28. package/lib/data-home-migration.js +34 -58
  29. package/mcp-server/dist/http.d.ts +2 -0
  30. package/mcp-server/dist/http.d.ts.map +1 -1
  31. package/mcp-server/dist/http.js +9 -1
  32. package/mcp-server/dist/http.js.map +1 -1
  33. package/mcp-server/dist/index.d.ts +11 -0
  34. package/mcp-server/dist/index.d.ts.map +1 -1
  35. package/mcp-server/dist/index.js +38 -3
  36. package/mcp-server/dist/index.js.map +1 -1
  37. package/mcp-server/dist/services/browser-route-flow.d.ts +6 -2
  38. package/mcp-server/dist/services/browser-route-flow.d.ts.map +1 -1
  39. package/mcp-server/dist/services/browser-route-flow.js +10 -3
  40. package/mcp-server/dist/services/browser-route-flow.js.map +1 -1
  41. package/mcp-server/dist/services/codex-config-heal.d.ts.map +1 -1
  42. package/mcp-server/dist/services/codex-config-heal.js +7 -0
  43. package/mcp-server/dist/services/codex-config-heal.js.map +1 -1
  44. package/mcp-server/dist/services/neural-interface.d.ts +95 -3
  45. package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
  46. package/mcp-server/dist/services/neural-interface.js +168 -23
  47. package/mcp-server/dist/services/neural-interface.js.map +1 -1
  48. package/mcp-server/dist/services/team-context.d.ts +18 -0
  49. package/mcp-server/dist/services/team-context.d.ts.map +1 -0
  50. package/mcp-server/dist/services/team-context.js +29 -0
  51. package/mcp-server/dist/services/team-context.js.map +1 -0
  52. package/mcp-server/dist/services/tool-catalog.d.ts +5 -2
  53. package/mcp-server/dist/services/tool-catalog.d.ts.map +1 -1
  54. package/mcp-server/dist/services/tool-catalog.js +22 -6
  55. package/mcp-server/dist/services/tool-catalog.js.map +1 -1
  56. package/mcp-server/dist/services/tool-list.d.ts.map +1 -1
  57. package/mcp-server/dist/services/tool-list.js +4 -0
  58. package/mcp-server/dist/services/tool-list.js.map +1 -1
  59. package/mcp-server/dist/services/tool-runtime.d.ts +8 -1
  60. package/mcp-server/dist/services/tool-runtime.d.ts.map +1 -1
  61. package/mcp-server/dist/services/tool-runtime.js +18 -1
  62. package/mcp-server/dist/services/tool-runtime.js.map +1 -1
  63. package/mcp-server/dist/tools/agent-definition.d.ts +133 -0
  64. package/mcp-server/dist/tools/agent-definition.d.ts.map +1 -0
  65. package/mcp-server/dist/tools/agent-definition.js +483 -0
  66. package/mcp-server/dist/tools/agent-definition.js.map +1 -0
  67. package/mcp-server/dist/tools/agents.d.ts +92 -9
  68. package/mcp-server/dist/tools/agents.d.ts.map +1 -1
  69. package/mcp-server/dist/tools/agents.js +163 -20
  70. package/mcp-server/dist/tools/agents.js.map +1 -1
  71. package/mcp-server/dist/tools/browser-advanced.d.ts +8 -1
  72. package/mcp-server/dist/tools/browser-advanced.d.ts.map +1 -1
  73. package/mcp-server/dist/tools/browser-advanced.js +70 -6
  74. package/mcp-server/dist/tools/browser-advanced.js.map +1 -1
  75. package/mcp-server/dist/tools/git-tools.d.ts +4 -2
  76. package/mcp-server/dist/tools/git-tools.d.ts.map +1 -1
  77. package/mcp-server/dist/tools/git-tools.js +283 -2
  78. package/mcp-server/dist/tools/git-tools.js.map +1 -1
  79. package/mcp-server/dist/tools/morelogin.d.ts +8 -2
  80. package/mcp-server/dist/tools/morelogin.d.ts.map +1 -1
  81. package/mcp-server/dist/tools/morelogin.js +22 -5
  82. package/mcp-server/dist/tools/morelogin.js.map +1 -1
  83. package/mcp-server/dist/tools/team.d.ts +32 -0
  84. package/mcp-server/dist/tools/team.d.ts.map +1 -0
  85. package/mcp-server/dist/tools/team.js +87 -0
  86. package/mcp-server/dist/tools/team.js.map +1 -0
  87. package/mcp-server/package-lock.json +2 -2
  88. package/mcp-server/package.json +1 -1
  89. package/mcp-server/src/http.ts +9 -1
  90. package/mcp-server/src/index.ts +34 -4
  91. package/mcp-server/src/services/browser-route-flow.ts +12 -5
  92. package/mcp-server/src/services/codex-config-heal.ts +7 -0
  93. package/mcp-server/src/services/neural-interface.ts +191 -29
  94. package/mcp-server/src/services/team-context.ts +27 -0
  95. package/mcp-server/src/services/tool-catalog.ts +26 -8
  96. package/mcp-server/src/services/tool-list.ts +4 -0
  97. package/mcp-server/src/services/tool-runtime.ts +21 -2
  98. package/mcp-server/src/tools/agent-definition.ts +458 -0
  99. package/mcp-server/src/tools/agents.ts +177 -19
  100. package/mcp-server/src/tools/browser-advanced.ts +60 -6
  101. package/mcp-server/src/tools/git-tools.ts +249 -3
  102. package/mcp-server/src/tools/morelogin.ts +20 -5
  103. package/mcp-server/src/tools/team.ts +97 -0
  104. package/neural-interface/i18n/en.json +1119 -47
  105. package/neural-interface/i18n/pt-BR.json +1119 -47
  106. package/neural-interface/lib/account-usage.js +1 -1
  107. package/neural-interface/lib/agents/builtins.json +207 -0
  108. package/neural-interface/lib/agents/density.js +101 -0
  109. package/neural-interface/lib/agents/forge-host.js +223 -0
  110. package/neural-interface/lib/agents/native-export-targets.js +190 -0
  111. package/neural-interface/lib/agents/native-export.js +365 -0
  112. package/neural-interface/lib/agents/registry.js +885 -0
  113. package/neural-interface/lib/agents/resolve.js +603 -0
  114. package/neural-interface/lib/agents/schema.js +642 -0
  115. package/neural-interface/lib/agents/split.js +37 -0
  116. package/neural-interface/lib/agents-studio-api.js +591 -0
  117. package/neural-interface/lib/assistant-api.js +76 -7
  118. package/neural-interface/lib/assistant-brains/opencode.js +60 -11
  119. package/neural-interface/lib/assistant-catalog.js +2 -0
  120. package/neural-interface/lib/assistant-continuity.js +49 -0
  121. package/neural-interface/lib/assistant-dispatch.js +351 -121
  122. package/neural-interface/lib/assistant-persona.js +105 -8
  123. package/neural-interface/lib/assistant-route-gate.js +24 -9
  124. package/neural-interface/lib/assistant-router.js +432 -47
  125. package/neural-interface/lib/assistant-run-tail.js +151 -0
  126. package/neural-interface/lib/assistant-run-wait.js +183 -0
  127. package/neural-interface/lib/assistant-runtime.js +449 -94
  128. package/neural-interface/lib/assistant-task-prompt.js +11 -2
  129. package/neural-interface/lib/assistant-usage.js +3 -2
  130. package/neural-interface/lib/automation-approval.js +2 -2
  131. package/neural-interface/lib/backup-service.js +64 -105
  132. package/neural-interface/lib/browser-close-evidence.js +80 -0
  133. package/neural-interface/lib/browser-default.js +210 -0
  134. package/neural-interface/lib/browser-extension-adapter.js +264 -0
  135. package/neural-interface/lib/browser-extension-bridge.js +441 -0
  136. package/neural-interface/lib/browser-extension-folder.js +116 -0
  137. package/neural-interface/lib/browser-extension-setup.js +140 -0
  138. package/neural-interface/lib/browser-profile-choices.js +3 -3
  139. package/neural-interface/lib/browser-tool-policy.js +1 -1
  140. package/neural-interface/lib/claude-account-links.js +301 -0
  141. package/neural-interface/lib/claude-accounts.js +45 -20
  142. package/neural-interface/lib/claude-agent-bridge.js +142 -10
  143. package/neural-interface/lib/claude-model-catalog.js +6 -0
  144. package/neural-interface/lib/claude-panel-session.js +33 -0
  145. package/neural-interface/lib/codex-accounts.js +67 -24
  146. package/neural-interface/lib/coordination/README.md +384 -0
  147. package/neural-interface/lib/coordination/service.js +563 -0
  148. package/neural-interface/lib/coordination/store.js +1138 -0
  149. package/neural-interface/lib/db.js +22 -1
  150. package/neural-interface/lib/effort-levels.js +10 -1
  151. package/neural-interface/lib/memory-list-page.js +49 -0
  152. package/neural-interface/lib/memory-list-stamp.js +60 -0
  153. package/neural-interface/lib/morelogin-outside-close.js +186 -0
  154. package/neural-interface/lib/morelogin-profile-failures.js +206 -0
  155. package/neural-interface/lib/morelogin-start-cooldown.js +160 -0
  156. package/neural-interface/lib/morelogin.js +194 -8
  157. package/neural-interface/lib/native-loop-runtime.js +26 -7
  158. package/neural-interface/lib/opencode-build-preflight.js +28 -8
  159. package/neural-interface/lib/opencode-native-boundary.js +83 -13
  160. package/neural-interface/lib/opencode-serve-records.js +14 -9
  161. package/neural-interface/lib/page-session.js +1 -1
  162. package/neural-interface/lib/peer-identity.js +73 -29
  163. package/neural-interface/lib/process-identity.js +68 -7
  164. package/neural-interface/lib/request-gate.js +3 -0
  165. package/neural-interface/lib/screenshot-location.js +33 -0
  166. package/neural-interface/lib/session-cache-builder.js +41 -3
  167. package/neural-interface/lib/skills/creation.js +1 -1
  168. package/neural-interface/lib/skills/known-bridge-digests.json +40 -0
  169. package/neural-interface/lib/studio-attention.js +56 -0
  170. package/neural-interface/lib/teams/README.md +382 -0
  171. package/neural-interface/lib/teams/api.js +287 -0
  172. package/neural-interface/lib/teams/brief.js +185 -0
  173. package/neural-interface/lib/teams/claims.js +315 -0
  174. package/neural-interface/lib/teams/git.js +293 -0
  175. package/neural-interface/lib/teams/index.js +122 -0
  176. package/neural-interface/lib/teams/integration.js +580 -0
  177. package/neural-interface/lib/teams/landing.js +184 -0
  178. package/neural-interface/lib/teams/recovery.js +256 -0
  179. package/neural-interface/lib/teams/scheduler.js +1474 -0
  180. package/neural-interface/lib/teams/schema.js +559 -0
  181. package/neural-interface/lib/teams/state.js +181 -0
  182. package/neural-interface/lib/teams/test-runner.js +86 -0
  183. package/neural-interface/lib/teams/test-sandbox.js +99 -0
  184. package/neural-interface/lib/teams/worktrees.js +757 -0
  185. package/neural-interface/lib/tool-permission-choices.js +226 -0
  186. package/neural-interface/lib/whatsapp/cards.js +24 -10
  187. package/neural-interface/lib/worker-confinement.js +206 -6
  188. package/neural-interface/package-lock.json +2 -2
  189. package/neural-interface/package.json +1 -1
  190. package/neural-interface/public/extension-setup.html +107 -0
  191. package/neural-interface/public/index.html +103 -12
  192. package/neural-interface/public/offline.html +4 -3
  193. package/neural-interface/public/shared/agent-runtime-options.js +3 -1
  194. package/neural-interface/public/shared/agents/studio/ax-agent-view.js +614 -0
  195. package/neural-interface/public/shared/agents/studio/ax-api.js +198 -0
  196. package/neural-interface/public/shared/agents/studio/ax-create-view.js +221 -0
  197. package/neural-interface/public/shared/agents/studio/ax-diff.js +143 -0
  198. package/neural-interface/public/shared/agents/studio/ax-editor-view.js +392 -0
  199. package/neural-interface/public/shared/agents/studio/ax-export-view.js +94 -0
  200. package/neural-interface/public/shared/agents/studio/ax-form.js +191 -0
  201. package/neural-interface/public/shared/agents/studio/ax-icons.js +87 -0
  202. package/neural-interface/public/shared/agents/studio/ax-library-view.js +158 -0
  203. package/neural-interface/public/shared/agents/studio/ax-library.js +162 -0
  204. package/neural-interface/public/shared/agents/studio/ax-main.js +712 -0
  205. package/neural-interface/public/shared/agents/studio/ax-native-export.js +35 -0
  206. package/neural-interface/public/shared/agents/studio/ax-options.js +198 -0
  207. package/neural-interface/public/shared/agents/studio/ax-review-view.js +175 -0
  208. package/neural-interface/public/shared/agents/studio/ax-revisions-view.js +189 -0
  209. package/neural-interface/public/shared/agents/studio/ax-runs-view.js +202 -0
  210. package/neural-interface/public/shared/agents/studio/ax-runs.js +82 -0
  211. package/neural-interface/public/shared/agents/studio/ax-teams-view.js +256 -0
  212. package/neural-interface/public/shared/agents/studio/ax-teams.js +200 -0
  213. package/neural-interface/public/shared/agents/studio/ax-templates.js +50 -0
  214. package/neural-interface/public/shared/agents/studio/ax-ui.js +194 -0
  215. package/neural-interface/public/shared/agents/studio/ax-views.js +170 -0
  216. package/neural-interface/public/shared/agy/agy-panel.js +142 -28
  217. package/neural-interface/public/shared/agy/agy-styles.js +25 -5
  218. package/neural-interface/public/shared/api.js +2 -1
  219. package/neural-interface/public/shared/assistant/asst-account-menu.js +13 -13
  220. package/neural-interface/public/shared/assistant/asst-ask-styles.js +2 -3
  221. package/neural-interface/public/shared/assistant/asst-brain-picker.js +91 -9
  222. package/neural-interface/public/shared/assistant/asst-control.js +3 -0
  223. package/neural-interface/public/shared/assistant/asst-interaction-hold.js +99 -0
  224. package/neural-interface/public/shared/assistant/asst-limit-dismissals.js +111 -0
  225. package/neural-interface/public/shared/assistant/asst-limit-dock.js +37 -3
  226. package/neural-interface/public/shared/assistant/asst-limit-wait.js +30 -7
  227. package/neural-interface/public/shared/assistant/asst-panel.js +177 -30
  228. package/neural-interface/public/shared/assistant/asst-rack-styles.js +15 -8
  229. package/neural-interface/public/shared/assistant/asst-render.js +37 -6
  230. package/neural-interface/public/shared/assistant/asst-route.js +80 -12
  231. package/neural-interface/public/shared/assistant/asst-routes-editor.js +148 -70
  232. package/neural-interface/public/shared/assistant/asst-roving.js +17 -1
  233. package/neural-interface/public/shared/assistant/asst-scene-styles.js +7 -2
  234. package/neural-interface/public/shared/assistant/asst-scenes.js +12 -1
  235. package/neural-interface/public/shared/assistant/asst-sidepanel.js +12 -2
  236. package/neural-interface/public/shared/assistant/asst-state.js +66 -1
  237. package/neural-interface/public/shared/assistant/asst-styles.js +98 -44
  238. package/neural-interface/public/shared/assistant/route-identity.js +16 -0
  239. package/neural-interface/public/shared/cc-dropdown.js +21 -15
  240. package/neural-interface/public/shared/cdx/cdx-output.js +10 -0
  241. package/neural-interface/public/shared/cdx/cdx-panel.js +18 -16
  242. package/neural-interface/public/shared/cdx/cdx-plan.js +3 -2
  243. package/neural-interface/public/shared/cdx/cdx-render.js +122 -45
  244. package/neural-interface/public/shared/cdx/cdx-requests.js +4 -4
  245. package/neural-interface/public/shared/cdx/cdx-styles.js +8 -36
  246. package/neural-interface/public/shared/cdx/cdx-tabs.js +110 -42
  247. package/neural-interface/public/shared/claude-panel-lazy.js +12 -0
  248. package/neural-interface/public/shared/code-copy.js +120 -0
  249. package/neural-interface/public/shared/constants.js +7 -0
  250. package/neural-interface/public/shared/context-menu-model.js +1 -0
  251. package/neural-interface/public/shared/cp/cp-markdown.js +7 -2
  252. package/neural-interface/public/shared/cp/cp-session-model.js +86 -5
  253. package/neural-interface/public/shared/cp/cp-session-settings.js +58 -30
  254. package/neural-interface/public/shared/cp/cp-styles.js +9 -0
  255. package/neural-interface/public/shared/dom-change-flag.js +66 -0
  256. package/neural-interface/public/shared/dom-morph.js +124 -0
  257. package/neural-interface/public/shared/extension-setup/es-page.css +134 -0
  258. package/neural-interface/public/shared/extension-setup/es-page.js +120 -0
  259. package/neural-interface/public/shared/extension-setup/es-view.js +100 -0
  260. package/neural-interface/public/shared/html-shell.js +34 -4
  261. package/neural-interface/public/shared/i18n.js +14 -1
  262. package/neural-interface/public/shared/idle-queue.js +78 -0
  263. package/neural-interface/public/shared/iface-config.js +227 -0
  264. package/neural-interface/public/shared/lazy-module.js +108 -0
  265. package/neural-interface/public/shared/memory-list.js +117 -0
  266. package/neural-interface/public/shared/morelogin-profile-choices.js +1 -1
  267. package/neural-interface/public/shared/morelogin-profile-field.js +3 -3
  268. package/neural-interface/public/shared/mtc/mtc-panel.js +3 -1
  269. package/neural-interface/public/shared/mtc/mtc-styles.js +4 -1
  270. package/neural-interface/public/shared/ocp-v2/ocp-v2-manager.js +35 -15
  271. package/neural-interface/public/shared/ocp-v2/ocp-v2-panel.js +77 -23
  272. package/neural-interface/public/shared/ocp-v2/ocp-v2-projectbar.js +3 -6
  273. package/neural-interface/public/shared/ocp-v2/ocp-v2-render.js +24 -21
  274. package/neural-interface/public/shared/ocp-v2/ocp-v2-send-logic.js +16 -5
  275. package/neural-interface/public/shared/ocp-v2/ocp-v2-sessions-logic.js +16 -2
  276. package/neural-interface/public/shared/ocp-v2/ocp-v2-styles.js +27 -43
  277. package/neural-interface/public/shared/ocp-v2/ocp-v2-ws.js +73 -9
  278. package/neural-interface/public/shared/owner-authority-view.js +4 -10
  279. package/neural-interface/public/shared/page-session.js +1 -1
  280. package/neural-interface/public/shared/schedules-view.js +2 -2
  281. package/neural-interface/public/shared/session-project-items.js +11 -0
  282. package/neural-interface/public/shared/settings/settings-ai-browser.js +119 -0
  283. package/neural-interface/public/shared/settings/settings-browser-extension.js +446 -0
  284. package/neural-interface/public/shared/settings/settings-ia.js +4 -2
  285. package/neural-interface/public/shared/settings/settings-morelogin-cooldown.js +63 -0
  286. package/neural-interface/public/shared/settings/settings-tool-permissions.js +70 -0
  287. package/neural-interface/public/shared/sidepanel-lazy.js +40 -0
  288. package/neural-interface/public/shared/sidepanel-session-status.js +8 -14
  289. package/neural-interface/public/shared/sidepanel-shown.js +73 -0
  290. package/neural-interface/public/shared/start-bridge.js +2 -2
  291. package/neural-interface/public/shared/storage.js +6 -1
  292. package/neural-interface/public/shared/studio-attention.js +83 -0
  293. package/neural-interface/public/shared/styles.css +694 -50
  294. package/neural-interface/public/shared/term-browser-tabs.js +34 -0
  295. package/neural-interface/public/shared/transcript-rows.js +334 -0
  296. package/neural-interface/public/shared/tray-auto-close.js +106 -0
  297. package/neural-interface/public/shared/ui-agents.js +97 -0
  298. package/neural-interface/public/shared/ui-antigravity-panel.js +16 -14
  299. package/neural-interface/public/shared/ui-automation-studio.js +3 -3
  300. package/neural-interface/public/shared/ui-claude-panel.js +162 -95
  301. package/neural-interface/public/shared/ui-code-copy.js +256 -0
  302. package/neural-interface/public/shared/ui-codex-panel.js +14 -10
  303. package/neural-interface/public/shared/ui-context-menu.js +1 -1
  304. package/neural-interface/public/shared/ui-file-explorer.js +2 -3
  305. package/neural-interface/public/shared/ui-games.js +1 -1
  306. package/neural-interface/public/shared/ui-loading.js +83 -19
  307. package/neural-interface/public/shared/ui-maritaca-panel.js +12 -11
  308. package/neural-interface/public/shared/ui-menubar.js +23 -0
  309. package/neural-interface/public/shared/ui-native-loop-router.js +50 -21
  310. package/neural-interface/public/shared/ui-navbar.js +15 -9
  311. package/neural-interface/public/shared/ui-opencode-panel-v2.js +13 -11
  312. package/neural-interface/public/shared/ui-owner-authority.js +48 -25
  313. package/neural-interface/public/shared/ui-schedules-studio.js +3 -3
  314. package/neural-interface/public/shared/ui-scroll-follow.js +39 -0
  315. package/neural-interface/public/shared/ui-sessions.js +3 -3
  316. package/neural-interface/public/shared/ui-settings-entry.js +55 -0
  317. package/neural-interface/public/shared/ui-settings.js +363 -400
  318. package/neural-interface/public/shared/ui-sidepanel-layout.js +44 -25
  319. package/neural-interface/public/shared/ui-sidepanel-session-entry.js +22 -9
  320. package/neural-interface/public/shared/ui-sidepanel-sessions.js +10 -2
  321. package/neural-interface/public/shared/ui-sidepanel-tray.js +36 -41
  322. package/neural-interface/public/shared/ui-sidepanel-windows.js +14 -1
  323. package/neural-interface/public/shared/ui-styleguide.js +10 -2
  324. package/neural-interface/public/shared/ui-sync.js +6 -0
  325. package/neural-interface/public/shared/ui-terminal.js +13 -9
  326. package/neural-interface/public/shared/ui-tooltip.js +28 -7
  327. package/neural-interface/public/shared/ui-topright-overflow.js +26 -4
  328. package/neural-interface/public/shared/ui-tray-columns.js +375 -0
  329. package/neural-interface/public/shared/ui-whiteboard.js +51 -6
  330. package/neural-interface/public/shared/ui-worker-end.js +28 -1
  331. package/neural-interface/public/shared/ui-workspaces.js +13 -0
  332. package/neural-interface/public/shared/window-keys.js +71 -0
  333. package/neural-interface/public/sw.js +4 -3
  334. package/neural-interface/public/variant/2d/main.js +2 -0
  335. package/neural-interface/public/variant/3d/app.js +620 -0
  336. package/neural-interface/public/variant/3d/boot-reveal.js +47 -0
  337. package/neural-interface/public/variant/3d/main.js +30 -544
  338. package/neural-interface/public/variant/3d/map-controls.js +4 -2
  339. package/neural-interface/public/vendor/fonts/fonts.css +508 -0
  340. package/neural-interface/public/vendor/fonts/inter-OFL.txt +93 -0
  341. package/neural-interface/public/vendor/fonts/inter-cyrillic-ext.woff2 +0 -0
  342. package/neural-interface/public/vendor/fonts/inter-cyrillic.woff2 +0 -0
  343. package/neural-interface/public/vendor/fonts/inter-greek-ext.woff2 +0 -0
  344. package/neural-interface/public/vendor/fonts/inter-greek.woff2 +0 -0
  345. package/neural-interface/public/vendor/fonts/inter-latin-ext.woff2 +0 -0
  346. package/neural-interface/public/vendor/fonts/inter-latin.woff2 +0 -0
  347. package/neural-interface/public/vendor/fonts/inter-vietnamese.woff2 +0 -0
  348. package/neural-interface/public/vendor/fonts/jetbrains-mono-OFL.txt +93 -0
  349. package/neural-interface/public/vendor/fonts/jetbrains-mono-cyrillic-ext.woff2 +0 -0
  350. package/neural-interface/public/vendor/fonts/jetbrains-mono-cyrillic.woff2 +0 -0
  351. package/neural-interface/public/vendor/fonts/jetbrains-mono-greek.woff2 +0 -0
  352. package/neural-interface/public/vendor/fonts/jetbrains-mono-latin-ext.woff2 +0 -0
  353. package/neural-interface/public/vendor/fonts/jetbrains-mono-latin.woff2 +0 -0
  354. package/neural-interface/public/vendor/fonts/jetbrains-mono-vietnamese.woff2 +0 -0
  355. package/neural-interface/public/vendor/fonts/manifest.json +142 -0
  356. package/neural-interface/public/vendor/fonts/space-grotesk-OFL.txt +93 -0
  357. package/neural-interface/public/vendor/fonts/space-grotesk-latin-ext.woff2 +0 -0
  358. package/neural-interface/public/vendor/fonts/space-grotesk-latin.woff2 +0 -0
  359. package/neural-interface/public/vendor/fonts/space-grotesk-vietnamese.woff2 +0 -0
  360. package/neural-interface/scripts/boot-graph.mjs +270 -0
  361. package/neural-interface/scripts/vendor-fonts.mjs +124 -0
  362. package/neural-interface/server.js +1083 -164
  363. package/npm-shrinkwrap.json +2 -2
  364. package/package.json +4 -1
  365. package/skills/agent-forge/SKILL.md +182 -0
  366. package/skills/agent-forge/evals/evals.json +56 -0
  367. package/skills/agent-forge/references/definition-fields.md +61 -0
  368. package/skills/agent-forge/references/examples.md +105 -0
  369. package/skills/agent-forge/references/instructions.md +51 -0
  370. package/skills/agent-forge/references/review-and-export.md +84 -0
@@ -0,0 +1,119 @@
1
+ // The AI browser: the browser SynaBun's own web tasks run in. It is SynaBun's local browser (Settings → Browser), or a
2
+ // MoreLogin / SynaBun local profile chosen in Settings → Connected tools → MoreLogin → Default AI browser. The saved
3
+ // browser config holds it as it always has: `connectMode: 'morelogin'` + `moreloginEnvId` (lib routes unchanged:
4
+ // POST /api/morelogin/use-default writes it, PUT /api/browser/config carries it back whole).
5
+ //
6
+ // Who decides what:
7
+ // - the MoreLogin tab's card is the only place that turns a profile on or off as the AI browser (and its per-row
8
+ // "Use as default" button, which is the same request);
9
+ // - the Browser tab never turns it on or off and never changes or clears the profile: a save there carries back
10
+ // what the server holds at that moment (browserSaveFields), whatever its own Connection field shows.
11
+ //
12
+ // DOM-free and without imports: node --test and the page load the same file.
13
+
14
+ /** The modes offered in the Browser tab's Connection dropdown. */
15
+ export const LOCAL_CONNECT_OPTIONS = Object.freeze(['attach', 'extension']);
16
+
17
+ /** Deprecated in the menu. Still supported for saved configs and as the server's local default. */
18
+ export const LOCAL_DEFAULT_MODE = 'mirror';
19
+
20
+ const idOf = (value) => (value === undefined || value === null || value === '' ? null : String(value));
21
+
22
+ /**
23
+ * The AI browser a browser config (GET /api/browser/config `config`) or a use-default answer describes.
24
+ * @returns {{ moreLogin: boolean, envId: string|null }}
25
+ */
26
+ export function aiBrowserOf(cfg) {
27
+ const c = cfg && typeof cfg === 'object' ? cfg : {};
28
+ return { moreLogin: c.connectMode === 'morelogin', envId: idOf(c.moreloginEnvId) };
29
+ }
30
+
31
+ /**
32
+ * The AI browser GET /api/morelogin/status describes (`isDefault`, `defaultEnvId`).
33
+ * @returns {{ moreLogin: boolean, envId: string|null }}
34
+ */
35
+ export function aiBrowserOfStatus(status) {
36
+ const s = status && typeof status === 'object' ? status : {};
37
+ return { moreLogin: s.isDefault === true, envId: idOf(s.defaultEnvId) };
38
+ }
39
+
40
+ /** The Connection dropdown's value for a loaded config: a local mode, never 'morelogin' (it has no such option). */
41
+ export function localConnectModeOf(cfg) {
42
+ const mode = cfg && typeof cfg === 'object' ? cfg.connectMode : null;
43
+ return LOCAL_CONNECT_OPTIONS.includes(mode) ? mode : LOCAL_DEFAULT_MODE;
44
+ }
45
+
46
+ /**
47
+ * The connection fields of a Browser tab save. `formMode`: its Connection dropdown. `current`: the AI browser as the
48
+ * server holds it now (aiBrowserOf of a fresh read; the last one known when that read failed). A MoreLogin AI browser
49
+ * stays exactly as it is, profile included; otherwise the local mode is the form's and the remembered profile id is
50
+ * kept (never cleared from here).
51
+ * @returns {{ connectMode: string, moreloginEnvId: string|null }}
52
+ */
53
+ export function browserSaveFields(formMode, current) {
54
+ const now = current && typeof current === 'object' ? current : {};
55
+ const envId = idOf(now.envId);
56
+ if (now.moreLogin === true) return { connectMode: 'morelogin', moreloginEnvId: envId };
57
+ return { connectMode: LOCAL_CONNECT_OPTIONS.includes(formMode) ? formMode : LOCAL_DEFAULT_MODE, moreloginEnvId: envId };
58
+ }
59
+
60
+ /**
61
+ * What the card's on/off switch asks of POST /api/morelogin/use-default.
62
+ * `chosen`: the picker's profile id; `firefox`: that profile is known to be Firefox-type (cannot be driven).
63
+ * @returns {{ body: Object } | { refuse: 'pickFirst' | 'firefox' }}
64
+ */
65
+ export function switchRequest({ on, chosen, firefox = false } = {}) {
66
+ if (!on) return { body: { clear: true } };
67
+ const envId = idOf(chosen);
68
+ if (!envId) return { refuse: 'pickFirst' };
69
+ if (firefox) return { refuse: 'firefox' };
70
+ return { body: { envId } };
71
+ }
72
+
73
+ /**
74
+ * What a new choice in the card's picker asks: saved at once while the switch is on, only remembered while it is
75
+ * off (the switch then uses it). Nothing when it is already the AI browser, or cannot be one.
76
+ * @returns {{ body: Object } | null}
77
+ */
78
+ export function pickRequest({ on, chosen, current, firefox = false } = {}) {
79
+ const envId = idOf(chosen);
80
+ if (!on || !envId || firefox) return null;
81
+ const now = current && typeof current === 'object' ? current : {};
82
+ if (now.moreLogin === true && idOf(now.envId) === envId) return null;
83
+ return { body: { envId } };
84
+ }
85
+
86
+ /**
87
+ * The line that says what the AI browser is: one key of `settings.redesign.morelogin.aiBrowser.line.*` (the card) or
88
+ * `settings.redesign.browser.aiBrowser.*` (the Browser tab) and its params. `profile`: { name, kind } of the profile
89
+ * when it was listed (kind 'local' for SynaBun's own); its id stands in for a name the list did not give.
90
+ * @returns {{ key: 'off' | 'moreLogin' | 'local', params: { name?: string } }}
91
+ */
92
+ export function aiBrowserLine(state, profile = null) {
93
+ const s = state && typeof state === 'object' ? state : {};
94
+ if (s.moreLogin !== true) return { key: 'off', params: {} };
95
+ const name = (profile && profile.name != null && String(profile.name).trim()) || idOf(s.envId) || '?';
96
+ return { key: profile && profile.kind === 'local' ? 'local' : 'moreLogin', params: { name: String(name) } };
97
+ }
98
+
99
+ /** The listed profile with this id, or null. `envs`: rows of GET /api/browser/morelogin-envs or /api/morelogin/profiles. */
100
+ export function profileOf(envs, envId) {
101
+ const id = idOf(envId);
102
+ if (!id || !Array.isArray(envs)) return null;
103
+ const row = envs.find((e) => e && idOf(e.id) === id);
104
+ return row ? { name: row.name ?? null, kind: row.kind === 'local' ? 'local' : 'morelogin', browser: row.browser ?? null } : null;
105
+ }
106
+
107
+ /** The event the MoreLogin tab sends on the Settings overlay whenever it learns the AI browser (detail: aiBrowserDetail). */
108
+ export const AI_BROWSER_EVENT = 'stg-ai-browser';
109
+
110
+ /** The event's detail: the state and, when known, the profile's name and kind. */
111
+ export function aiBrowserDetail(state, profile = null) {
112
+ const s = state && typeof state === 'object' ? state : {};
113
+ return {
114
+ moreLogin: s.moreLogin === true,
115
+ envId: idOf(s.envId),
116
+ name: profile && profile.name != null ? String(profile.name) : null,
117
+ kind: profile && profile.kind === 'local' ? 'local' : (profile ? 'morelogin' : null),
118
+ };
119
+ }
@@ -0,0 +1,446 @@
1
+ // Settings → Browser → "Existing browser via extension". The approved redesign (docs/design/browser-extension:
2
+ // "Settings card"): a connection status that says what to do next, the agent access, the tabs agents hold grouped by
3
+ // agent with an immediate Take back, the one-button setup, and the rest behind two disclosures. Settings' own markup,
4
+ // tokens and 22 px controls; no native dropdown and no new palette.
5
+ //
6
+ // Layout: the card is one row of the Browser group (`.stg-field`, for the group's row spacing and hairline), but it
7
+ // never has a label, an input or a compact control as a DIRECT child: the Settings rule for a compact control
8
+ // (`.stg-field:has(> input[type="number"])`) would turn the whole card into a two-column grid and put every help
9
+ // paragraph into the same cell (styles.css, "Fields: label, control, one-line help"). Each part is a block of its own
10
+ // that reads top to bottom: status, agent access, tabs, setup, files and limits, connection details, the actions.
11
+ //
12
+ // The mode: "Full control" (the default) or "Only shared sites and tabs". It is the owner's: switched here (POST
13
+ // /api/browser/extension/mode, behind the owner route) or in the extension popup, and confirmed first either way.
14
+ // The dropdown is the app's .cc-dropdown (Settings wires every .stg-dropdown, wireStgDropdowns); a server from before
15
+ // the mode existed reports no `fullControl` and the section stays hidden. Disconnect and Revoke pairing are confirmed
16
+ // too; Take back is immediate and never closes the tab.
17
+ const SYMBOL = {
18
+ ok: '<path d="m5 12 4 4 10-10"></path>',
19
+ warn: '<path d="M9 5v14M15 5v14"></path>',
20
+ err: '<path d="m12 3 10 18H2L12 3ZM12 9v5M12 17h.01"></path>',
21
+ off: '<path d="M10 14a4 4 0 0 0 5.66 0l3-3a4 4 0 0 0-5.66-5.66l-1 1M14 10a4 4 0 0 0-5.66 0l-3 3a4 4 0 0 0 5.66 5.66l1-1"></path>',
22
+ sync: '<path d="M20 7a9 9 0 0 0-15-1L2 9m0-6v6h6M4 17a9 9 0 0 0 15 1l3-3m0 6v-6h-6"></path>',
23
+ };
24
+ const CHEVRON = '<svg class="cc-section-chevron" viewBox="0 0 24 24" aria-hidden="true"><polyline points="9 18 15 12 9 6"></polyline></svg>';
25
+
26
+ export function extensionSettingsHTML(kit) {
27
+ const t = key => kit.te(`browserExtension.${key}`);
28
+ const c = key => kit.te(`browserExtension.card.${key}`);
29
+ const button = (action, key, extra = '') => `<button type="button" class="cli-detect-btn" data-extension-action="${action}"${extra}>${t(key)}</button>`;
30
+ const modes = [['full', t('modeFull')], ['restricted', t('modeRestricted')]];
31
+ const symbols = Object.entries(SYMBOL).map(([name, path]) => `<svg class="bc-ext-sym" data-sym="${name}" viewBox="0 0 24 24">${path}</svg>`).join('');
32
+ return `<div class="stg-field bc-extension" id="bc-extension" data-card-state="loading" hidden>
33
+ <div class="bc-ext-head" id="bc-extension-head" data-tone="">
34
+ <div class="bc-ext-status-row">
35
+ <span class="bc-ext-symbol" aria-hidden="true">${symbols}</span>
36
+ <span class="bc-ext-label" id="bc-extension-status-label">${t('statusTitle')}</span>
37
+ <span class="stg-badge bc-ext-status" id="bc-extension-status" role="status" aria-live="polite" aria-labelledby="bc-extension-status-label"></span>
38
+ </div>
39
+ <p class="stg-help bc-ext-text bc-ext-status-help" id="bc-extension-status-help"></p>
40
+ <div class="bc-inline-group bc-ext-actions" id="bc-extension-status-actions" hidden>
41
+ <button type="button" class="cli-detect-btn bc-ext-primary" data-extension-action="resume">${c('reconnect')}</button>
42
+ <button type="button" class="cli-detect-btn" data-extension-action="retry" hidden>${c('retry')}</button>
43
+ </div>
44
+ </div>
45
+ <section class="bc-ext-section" data-extension-section="mode" aria-labelledby="bc-extension-mode-title" hidden>
46
+ <div class="bc-ext-mode-row">
47
+ <h4 class="stg-subhead" id="bc-extension-mode-title">${t('modeTitle')}</h4>
48
+ <input type="hidden" id="bc-extension-mode" value="full">
49
+ <div class="cc-dropdown stg-dropdown bc-ext-mode" data-for="bc-extension-mode" role="group">
50
+ <button class="cc-dropdown-trigger" type="button" aria-haspopup="listbox" aria-labelledby="bc-extension-mode-title"><span class="cc-dropdown-value">${modes[0][1]}</span><svg class="cc-dropdown-arrow" viewBox="0 0 24 24" aria-hidden="true"><polyline points="6 9 12 15 18 9"></polyline></svg></button>
51
+ <div class="cc-dropdown-menu">${modes.map(([value, label], i) => `<div class="cc-dropdown-item${i === 0 ? ' active' : ''}" data-value="${value}">${label}</div>`).join('')}</div>
52
+ </div>
53
+ </div>
54
+ <p class="stg-help bc-ext-text" id="bc-extension-mode-help" data-full-text="${t('modeFullHelp')}" data-restricted-text="${t('modeRestrictedHelp')}"></p>
55
+ </section>
56
+ <section class="bc-ext-section" data-extension-section="shared" aria-labelledby="bc-extension-shared-title" hidden>
57
+ <div class="bc-ext-title-row"><h4 class="stg-subhead" id="bc-extension-shared-title">${t('sharedTitle')}</h4><span class="bc-ext-count" id="bc-extension-count"></span></div>
58
+ <p class="stg-help bc-ext-text" id="bc-extension-summary" hidden></p>
59
+ <div class="bc-ext-list" id="bc-extension-tabs" data-empty-text="${t('noTabs')}" data-empty-full-text="${t('noControlled')}"></div>
60
+ <div class="bc-ext-list" id="bc-extension-sites" aria-label="${c('sharedSites')}"></div>
61
+ <p class="stg-help bc-ext-text" id="bc-extension-tabs-help" data-live-text="${c('takeBackHelp')}" data-stale-text="${c('staleHelp')}" hidden></p>
62
+ </section>
63
+ <section class="bc-ext-section" data-extension-section="setup" id="bc-extension-setup" data-state="idle" aria-labelledby="bc-extension-setup-title" hidden>
64
+ <h4 class="stg-subhead" id="bc-extension-setup-title" data-connect-text="${c('settingsTitle')}" data-again-text="${c('setupAgainTitle')}">${c('settingsTitle')}</h4>
65
+ <p class="stg-help bc-ext-text" id="bc-extension-setup-help" data-connect-text="${t('setupHelp')}" data-again-text="${c('setupAgainHelp')}">${t('setupHelp')}</p>
66
+ <div class="bc-inline-group bc-ext-actions">
67
+ <button type="button" class="cli-detect-btn" id="bc-extension-setup-start" data-extension-action="setup-start" data-connect-text="${t('setupConnect')}" data-reconnect-text="${t('setupReconnect')}" data-reinstall-text="${t('setupReinstall')}">${t('setupConnect')}</button>
68
+ <button type="button" class="cli-detect-btn" id="bc-extension-setup-reopen" data-extension-action="setup-reopen" hidden>${c('openGuide')}</button>
69
+ <button type="button" class="cli-detect-btn" id="bc-extension-setup-cancel" data-extension-action="setup-cancel" hidden>${t('setupCancel')}</button>
70
+ </div>
71
+ <p class="stg-help bc-ext-text" id="bc-extension-setup-status" role="status" aria-live="polite"></p>
72
+ <div class="bc-inline-group bc-ext-actions" id="bc-extension-setup-alternatives" hidden></div>
73
+ <p class="stg-help bc-ext-text bc-ext-note" id="bc-extension-setup-default">${c('setupDefault')}</p>
74
+ <p class="stg-help bc-ext-text bc-ext-note" id="bc-extension-reload" data-tone="warn" hidden>${t('reloadNeeded')}</p>
75
+ </section>
76
+ <details class="stg-advanced bc-ext-advanced" id="bc-extension-files" data-extension-section="files">
77
+ <summary>${CHEVRON}<span>${c('advanced')}</span></summary>
78
+ <div class="bc-ext-advanced-body">
79
+ <h4 class="stg-subhead" id="bc-extension-uploads-title">${t('uploadsTitle')}</h4>
80
+ <p class="stg-help bc-ext-text" id="bc-extension-upload"></p>
81
+ <p class="stg-help bc-ext-text">${c('uploadHelp')}</p>
82
+ <p class="stg-help bc-ext-text bc-ext-limits">${t('limits')}</p>
83
+ </div>
84
+ </details>
85
+ <details class="stg-advanced bc-ext-advanced" id="bc-extension-details" data-extension-section="details">
86
+ <summary>${CHEVRON}<span>${c('details')}</span></summary>
87
+ <div class="bc-ext-advanced-body">
88
+ <section class="bc-ext-part" data-extension-section="install" aria-labelledby="bc-extension-install-title">
89
+ <h4 class="stg-subhead" id="bc-extension-install-title">${t('installTitle')}</h4>
90
+ <p class="stg-help bc-ext-text">${t('install')}</p>
91
+ <label class="bc-ext-label" for="bc-extension-folder">${t('folder')}</label>
92
+ <div class="bc-ext-control-row">
93
+ <input class="browser-cfg-input bc-ext-path" id="bc-extension-folder" readonly spellcheck="false" autocomplete="off">
94
+ <div class="bc-inline-group bc-ext-actions">${button('copy', 'copy')}${button('refresh', 'refresh')}</div>
95
+ </div>
96
+ </section>
97
+ <section class="bc-ext-part" data-extension-section="pairing" aria-labelledby="bc-extension-pairing-title">
98
+ <h4 class="stg-subhead" id="bc-extension-pairing-title">${t('pairingTitle')}</h4>
99
+ <p class="stg-help bc-ext-text">${c('manualPairHelp')}</p>
100
+ <div class="bc-ext-port-row">
101
+ <label class="bc-ext-label" for="bc-extension-port">${t('port')}</label>
102
+ <input class="browser-cfg-input bc-ext-port" id="bc-extension-port" type="number" min="1024" max="65535" value="3345">
103
+ </div>
104
+ <div class="bc-inline-group bc-ext-actions">${button('pair', 'pair')}</div>
105
+ <p class="bc-ext-code" id="bc-extension-code" role="status"></p>
106
+ </section>
107
+ </div>
108
+ </details>
109
+ <div class="bc-ext-footer" id="bc-extension-footer" hidden>
110
+ <div class="bc-inline-group bc-ext-actions">${button('disconnect', 'disconnect')}${button('revoke', 'revoke', ' data-tone="danger"')}</div>
111
+ </div>
112
+ <div class="bc-ext-confirm" id="bc-extension-confirm" role="alertdialog" aria-labelledby="bc-extension-confirm-title" aria-describedby="bc-extension-confirm-body" hidden>
113
+ <h4 class="stg-subhead" id="bc-extension-confirm-title"></h4>
114
+ <p class="stg-help bc-ext-text" id="bc-extension-confirm-body"></p>
115
+ <div class="bc-inline-group bc-ext-actions">
116
+ <button type="button" class="cli-detect-btn" id="bc-extension-confirm-cancel" data-extension-action="confirm-cancel">${c('cancel')}</button>
117
+ <button type="button" class="cli-detect-btn" id="bc-extension-confirm-ok" data-extension-action="confirm-ok"></button>
118
+ </div>
119
+ </div>
120
+ </div>`;
121
+ }
122
+
123
+ // ── what the card shows, decided without the DOM (exported for tests) ──
124
+ /**
125
+ * The card's state. `data`: GET /api/browser/extension (null when it failed); `setup`: the setup status (when one is
126
+ * running); `failed`: the last read failed; `launching`: the owner's setup start is on its way.
127
+ */
128
+ export function cardState(data, setup = null, { failed = false, launching = false } = {}) {
129
+ if (failed && !data) return 'error';
130
+ const running = setup?.state || data?.setup;
131
+ if (launching) return 'launching';
132
+ if (data?.connected) return failed ? 'error' : 'connected';
133
+ if (running === 'waiting-for-extension') return 'setup';
134
+ if (running === 'pairing') return 'pairing';
135
+ if (running === 'unsupported') return 'unsupported';
136
+ if (failed) return 'error';
137
+ if (data?.paired) return 'disconnected';
138
+ return 'unpaired';
139
+ }
140
+ /** Host and path of an address: the query and fragment (sign-in challenges, tokens) are never shown. */
141
+ export function shownAddress(url) {
142
+ let u;
143
+ try { u = new URL(String(url || '')); } catch { return ''; }
144
+ if (u.href === 'about:blank') return 'about:blank';
145
+ if (u.protocol !== 'http:' && u.protocol !== 'https:') return `${u.protocol}//`;
146
+ return `${u.host}${u.pathname === '/' ? '' : u.pathname}`;
147
+ }
148
+ /** The tabs agents hold, grouped by the opaque agent id the server reports, in the server's order. */
149
+ export function groupByAgent(tabs = []) {
150
+ const groups = new Map();
151
+ for (const tab of tabs) {
152
+ if (!tab?.owner) continue;
153
+ const id = String(tab.owner).replace(/[^a-z0-9]/gi, '').slice(0, 6).toUpperCase() || '?';
154
+ if (!groups.has(tab.owner)) groups.set(tab.owner, { owner: tab.owner, id, tabs: [] });
155
+ groups.get(tab.owner).tabs.push(tab);
156
+ }
157
+ return [...groups.values()];
158
+ }
159
+
160
+ // The badge's tone for each state the card reports (Settings' own .stg-badge-ok / -warn / -err; none is the plain word).
161
+ const STATUS_TONES = ['stg-badge-ok', 'stg-badge-warn', 'stg-badge-err'];
162
+ const HEAD = {
163
+ connected: ['ok', 'connectedHelp'], disconnected: ['warn', 'disconnectedHelp'], unpaired: ['off', 'unpairedHelp'],
164
+ launching: ['sync', 'launchingHelp'], setup: ['sync', 'setupRunningHelp'], pairing: ['sync', 'pairingHelp'],
165
+ unsupported: ['err', 'unsupportedHelp'], error: ['err', 'errorHelp'],
166
+ };
167
+ const CONFIRMS = {
168
+ disconnect: ['disconnectTitle', 'disconnectBody', 'disconnect'],
169
+ revoke: ['revokeTitle', 'revokeBody', 'revoke'],
170
+ restrict: ['restrictTitle', 'restrictBody', 'restrictConfirm'],
171
+ full: ['fullTitle', 'fullBody', 'fullConfirm'],
172
+ };
173
+
174
+ export function wireExtensionSettings(root, { tx, signal }) {
175
+ const pane = root.querySelector('#bc-extension'); if (!pane) return;
176
+ const t = (key, params) => tx(`browserExtension.${key}`, params);
177
+ const c = (key, params) => tx(`browserExtension.card.${key}`, params);
178
+ const query = id => root.querySelector(`#bc-extension-${id}`);
179
+ let folder = '', busy = false, full = null, last = null, lastSetup = null, launching = false;
180
+ const pendingTabs = new Set(), failedTabs = new Set();
181
+ function setStatus(text, tone = '') {
182
+ const node = query('status'); node.textContent = text;
183
+ for (const name of STATUS_TONES) node.classList.remove(name);
184
+ if (tone) node.classList.add(`stg-badge-${tone}`);
185
+ }
186
+ async function api(action, body = {}) {
187
+ // `setup/status` is a read; every other action a POST.
188
+ const read = !action || action === 'setup/status';
189
+ const res = await fetch(`/api/browser/extension${action ? '/' + action : ''}`, read ? { signal } : { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-SynaBun-UI': '1' }, body: JSON.stringify(body), signal });
190
+ const value = await res.json(); if (!res.ok) throw new Error(value.error || t('restart')); return value;
191
+ }
192
+ const el = (tag, className, text) => { const node = document.createElement(tag); if (className) node.className = className; if (text != null) node.textContent = text; return node; };
193
+ // One tab: its title and safe address, and its one action.
194
+ function tabRow(tab, { action, label, aria, disabled }) {
195
+ void action; // take-back or stop-sharing: both end the tab's sharing or holding (revoke-tab)
196
+ const row = el('div', 'bc-ext-item'); row.dataset.handle = tab.handle;
197
+ const text = el('div', 'bc-ext-item-label');
198
+ const title = String(tab.title || '').trim() || c('untitledTab');
199
+ const name = el('span', 'bc-ext-item-title', title); name.title = title;
200
+ text.append(name, el('span', 'bc-ext-item-address', shownAddress(tab.url)));
201
+ const pending = pendingTabs.has(tab.handle);
202
+ const button = el('button', 'cli-detect-btn', pending ? c('busy') : label); button.type = 'button';
203
+ button.setAttribute('aria-label', aria); button.disabled = !!disabled || pending;
204
+ button.addEventListener('click', () => takeBack(tab.handle), { signal });
205
+ row.append(text, button);
206
+ if (failedTabs.has(tab.handle)) { const error = el('p', 'stg-help bc-ext-row-error', c('actionError')); error.setAttribute('role', 'alert'); row.append(error); }
207
+ return row;
208
+ }
209
+ function empty(node, text) { const p = el('p', 'stg-help bc-ext-empty', text); node.append(p); }
210
+ // The tabs: agents' tabs grouped by agent (Take back), and in restricted mode the shared tabs nobody holds yet (Stop
211
+ // sharing) and the shared sites (Remove). Rebuilt only when what they show changed, so a focused button stays.
212
+ let shownKey = '';
213
+ function showTabs(data, live) {
214
+ const tabs = Array.isArray(data?.tabs) ? data.tabs : [], sites = full ? [] : Array.isArray(data?.sites) ? data.sites : [];
215
+ const groups = groupByAgent(tabs), waiting = full ? [] : tabs.filter(tab => tab && !tab.owner);
216
+ const total = groups.reduce((sum, g) => sum + g.tabs.length, 0);
217
+ const key = JSON.stringify([full, live, groups.map(g => [g.owner, g.tabs.map(x => [x.handle, x.title, shownAddress(x.url)])]), waiting.map(x => [x.handle, x.title, shownAddress(x.url)]), sites, [...pendingTabs], [...failedTabs]]);
218
+ query('count').textContent = total ? String(total) : '';
219
+ const summary = query('summary');
220
+ summary.hidden = !total;
221
+ summary.textContent = !total ? '' : total === 1 ? c('oneTab') : groups.length === 1 ? c('oneAgent', { tabs: total }) : c('agentCount', { agents: groups.length, tabs: total });
222
+ const help = query('tabs-help'); help.hidden = !total; help.textContent = live ? help.dataset.liveText : help.dataset.staleText;
223
+ if (key === shownKey) return;
224
+ shownKey = key;
225
+ const list = query('tabs'); list.replaceChildren();
226
+ for (const group of groups) {
227
+ const box = el('div', 'bc-ext-agent'); box.dataset.owner = group.owner;
228
+ const head = el('div', 'bc-ext-agent-head');
229
+ const mark = el('span', 'bc-ext-agent-mark', group.id.slice(0, 2)); mark.setAttribute('aria-hidden', 'true');
230
+ const agent = c('unknownAgent', { id: group.id });
231
+ head.append(mark, el('span', 'bc-ext-agent-name', agent));
232
+ box.append(head);
233
+ for (const tab of group.tabs) {
234
+ const title = String(tab.title || '').trim() || c('untitledTab');
235
+ box.append(tabRow(tab, { action: 'take-back', label: t('takeBack'), aria: c('takeBackLabel', { title, agent }), disabled: !live }));
236
+ }
237
+ list.append(box);
238
+ }
239
+ if (waiting.length) {
240
+ const box = el('div', 'bc-ext-agent'); box.append(el('div', 'bc-ext-agent-head', c('sharedTabs')));
241
+ for (const tab of waiting) {
242
+ const title = String(tab.title || '').trim() || c('untitledTab');
243
+ box.append(tabRow(tab, { action: 'stop-sharing', label: c('stopSharing'), aria: c('stopSharingLabel', { title }), disabled: !live }));
244
+ }
245
+ list.append(box);
246
+ }
247
+ if (!total && !waiting.length && list.dataset.emptyText) empty(list, full ? list.dataset.emptyFullText : list.dataset.emptyText);
248
+ const siteList = query('sites'); siteList.replaceChildren();
249
+ for (const site of sites) {
250
+ const row = el('div', 'bc-ext-item');
251
+ const label = el('span', 'bc-ext-item-label'); label.append(el('code', 'bc-ext-item-site', site));
252
+ const button = el('button', 'cli-detect-btn', c('removeSite')); button.type = 'button';
253
+ button.setAttribute('aria-label', c('removeSiteLabel', { site }));
254
+ button.addEventListener('click', () => perform('revoke-site', { site }), { signal });
255
+ row.append(label, button); siteList.append(row);
256
+ }
257
+ }
258
+ function showCode(code) {
259
+ const node = query('code');
260
+ if (code == null) { node.textContent = ''; return; }
261
+ const lead = el('span', 'bc-ext-code-lead', `${t('code')} `);
262
+ const value = el('strong', 'bc-ext-code-value', code);
263
+ const expiry = el('span', 'bc-ext-code-expiry', ` · ${t('expires')}`);
264
+ node.replaceChildren(lead, value, expiry);
265
+ }
266
+ // The mode as the server reports it: the dropdown, its sentence, the tabs part's title. `fullControl` missing is a
267
+ // server from before the mode: the section stays hidden and the card reads as it did.
268
+ function showMode(value, visible = true) {
269
+ full = typeof value === 'boolean' ? value : null;
270
+ const section = pane.querySelector('[data-extension-section="mode"]');
271
+ section.hidden = full === null || !visible;
272
+ if (full === null) return;
273
+ const chosen = full ? 'full' : 'restricted', input = query('mode'), dropdown = pane.querySelector('.bc-ext-mode');
274
+ input.value = chosen;
275
+ for (const item of dropdown.querySelectorAll('.cc-dropdown-item')) {
276
+ const on = item.dataset.value === chosen; item.classList.toggle('active', on);
277
+ if (on) dropdown.querySelector('.cc-dropdown-value').textContent = item.textContent;
278
+ }
279
+ const help = query('mode-help'); help.textContent = full ? help.dataset.fullText : help.dataset.restrictedText;
280
+ query('shared-title').textContent = t(full ? 'controlledTitle' : 'sharedTitle');
281
+ }
282
+ // The one-button setup ("Connect your browser"): shown only by a server that has it (`setup` in the status). Not
283
+ // paired, it is the card's main action; paired, it is the way to run the setup again (Reconnect while away,
284
+ // Reinstall while connected), lower in the card.
285
+ function showSetup(data, setup, state) {
286
+ const section = query('setup');
287
+ section.hidden = typeof data?.setup !== 'string';
288
+ if (section.hidden) return;
289
+ const running = setup?.state || data.setup;
290
+ section.dataset.state = running;
291
+ const again = !!data.paired && !['setup', 'pairing', 'unsupported', 'launching'].includes(state);
292
+ section.dataset.mode = again ? 'again' : 'connect';
293
+ const title = query('setup-title'), help = query('setup-help');
294
+ title.textContent = again ? title.dataset.againText : title.dataset.connectText;
295
+ help.textContent = again ? help.dataset.againText : help.dataset.connectText;
296
+ const start = query('setup-start');
297
+ start.textContent = data.connected ? start.dataset.reinstallText : data.paired ? start.dataset.reconnectText : start.dataset.connectText;
298
+ start.classList.toggle('bc-ext-primary', !data.paired);
299
+ start.disabled = launching;
300
+ const active = !['idle', 'connected'].includes(running);
301
+ start.hidden = ['waiting-for-extension', 'pairing'].includes(running);
302
+ query('setup-cancel').hidden = !active;
303
+ query('setup-reopen').hidden = running !== 'waiting-for-extension';
304
+ query('setup-default').hidden = again || active;
305
+ const name = setup?.browser?.name || '';
306
+ const known = ['waiting-for-extension', 'pairing', 'connected', 'unsupported'].includes(running);
307
+ query('setup-status').textContent = launching ? c('launching') : running === 'idle' ? '' : known ? tx(`browserExtension.setup.settings_${running.replace(/-/g, '_')}`, { browser: name })
308
+ : tx('browserExtension.setup.settings_error', { code: setup?.code || '' });
309
+ const alternatives = query('setup-alternatives'); alternatives.replaceChildren();
310
+ const others = running === 'unsupported' ? (setup?.installedBrowsers || []).filter(b => b?.supported && b.id !== setup?.browser?.id) : [];
311
+ for (const browser of others) {
312
+ const option = el('button', 'cli-detect-btn', tx('browserExtension.setup.openIn', { browser: browser.name })); option.type = 'button';
313
+ option.dataset.extensionAction = 'setup-open-in'; option.dataset.browser = browser.id;
314
+ alternatives.append(option);
315
+ }
316
+ alternatives.hidden = !others.length;
317
+ query('reload').hidden = !(data.reloadNeeded === true);
318
+ }
319
+ // The status at the top: a symbol, the word (Settings' badge), what it means, the one action that helps.
320
+ function showHead(state, data, error) {
321
+ const [tone, help] = HEAD[state] || HEAD.error;
322
+ pane.dataset.cardState = state;
323
+ query('head').dataset.tone = tone;
324
+ const modeWord = full === null ? '' : ` · ${t(full ? 'statusFull' : 'statusRestricted')}`;
325
+ if (error) setStatus(`${t('restart')} ${error}`, 'err');
326
+ else if (state === 'connected') setStatus(`${t('connected')}${modeWord}`, 'ok');
327
+ else if (state === 'disconnected') setStatus(`${t('disconnected')}${modeWord}`, 'warn');
328
+ else if (['setup', 'pairing', 'launching'].includes(state)) setStatus(c(state === 'setup' ? 'setupRunningTitle' : state, { browser: lastSetup?.browser?.name || '' }));
329
+ else if (state === 'unsupported') setStatus(c('unsupported'));
330
+ else setStatus(t('unpaired'));
331
+ query('status-help').textContent = c(help, { browser: lastSetup?.browser?.name || '' });
332
+ const actions = query('status-actions');
333
+ const resume = actions.querySelector('[data-extension-action="resume"]'), retry = actions.querySelector('[data-extension-action="retry"]');
334
+ resume.hidden = state !== 'disconnected'; retry.hidden = !error;
335
+ actions.hidden = resume.hidden && retry.hidden;
336
+ query('footer').hidden = !data?.paired;
337
+ query('files').hidden = !data?.paired;
338
+ }
339
+ function render(error = '') {
340
+ const data = last, state = cardState(data, lastSetup, { failed: !!error, launching });
341
+ if (data) {
342
+ folder = data.folder; query('folder').value = folder || ''; query('folder').title = folder || '';
343
+ const path = el('code', 'bc-ext-path-text', data.uploadFolder ?? ''); path.title = data.uploadFolder ?? '';
344
+ query('upload').replaceChildren(`${t('upload')} `, path);
345
+ }
346
+ const connected = !!data?.connected;
347
+ showMode(data?.fullControl, connected);
348
+ showSetup(data, lastSetup, state);
349
+ showHead(state, data, error);
350
+ // Full control: the server lists every tab of the browser; the card shows the ones agents hold. Sites are not
351
+ // shared in that mode. While the browser is away the last tabs stay, marked out of date, their actions off.
352
+ const section = pane.querySelector('[data-extension-section="shared"]');
353
+ section.hidden = !data || !(connected || (data.paired && (data.tabs || []).some(tab => tab.owner)));
354
+ showTabs(data, connected && !error);
355
+ }
356
+ async function refresh() {
357
+ const data = await api();
358
+ let setup = null;
359
+ if (typeof data.setup === 'string' && data.setup !== 'idle') { try { setup = await api('setup/status'); } catch { setup = null; } }
360
+ last = data; lastSetup = setup;
361
+ render();
362
+ }
363
+ async function takeBack(handle) {
364
+ if (pendingTabs.has(handle)) return;
365
+ pendingTabs.add(handle); failedTabs.delete(handle); render();
366
+ try { await api('revoke-tab', { tab: handle }); }
367
+ catch { failedTabs.add(handle); }
368
+ finally { pendingTabs.delete(handle); }
369
+ try { await refresh(); } catch (error) { if (!signal.aborted) render(error.message); }
370
+ }
371
+ // Confirmations: in the card itself (it lives inside the Settings dialog), Cancel focused first, Escape cancels, the
372
+ // focus returns to the control that asked.
373
+ let confirming = null;
374
+ function confirmFirst(kind, opener, then) {
375
+ const [title, body, ok] = CONFIRMS[kind];
376
+ const box = query('confirm');
377
+ query('confirm-title').textContent = c(title); query('confirm-body').textContent = c(body);
378
+ const button = query('confirm-ok'); button.textContent = c(ok); button.dataset.kind = kind;
379
+ box.dataset.kind = kind;
380
+ // Next to what asked: after the part of the card that holds the control.
381
+ let part = opener; while (part && part.parentNode !== pane) part = part.parentNode;
382
+ if (part && part !== box && part.nextSibling !== box) part.after(box);
383
+ confirming = { then, opener };
384
+ box.hidden = false;
385
+ query('confirm-cancel').focus?.();
386
+ }
387
+ function closeConfirm(run) {
388
+ const box = query('confirm'), pending = confirming;
389
+ confirming = null; box.hidden = true;
390
+ if (!run && pending?.cancelled) pending.cancelled();
391
+ if (pending?.opener?.isConnected && !pending.opener.hidden) pending.opener.focus?.();
392
+ if (run && pending) pending.then();
393
+ }
394
+ let queuedMode = null;
395
+ async function perform(action, body) {
396
+ // A mode switch made while a refresh runs is not lost: it runs right after.
397
+ if (busy) { if (action === 'mode') queuedMode = body; return; }
398
+ busy = true;
399
+ try {
400
+ if (action === 'copy') { await navigator.clipboard.writeText(folder); }
401
+ else if (action === 'setup-start' || action === 'setup-open-in') {
402
+ launching = true; render();
403
+ try { await api('setup/start', action === 'setup-open-in' ? { browser: body?.browser } : {}); } finally { launching = false; }
404
+ }
405
+ else if (action === 'setup-cancel') await api('setup/cancel', {});
406
+ else if (action === 'setup-reopen') await api('setup/reopen', {});
407
+ else if (!['refresh', 'retry'].includes(action)) {
408
+ const data = await api(action, body || (action === 'pair' ? { port: Number(query('port').value) } : {}));
409
+ if (action !== 'mode') showCode(action === 'pair' ? data.code : null);
410
+ if (action === 'pair') setTimeout(() => { if (!signal.aborted) showCode(null); }, 120000);
411
+ }
412
+ await refresh();
413
+ } catch (error) { if (!signal.aborted) render(error.message); }
414
+ finally {
415
+ busy = false;
416
+ if (queuedMode) { const next = queuedMode; queuedMode = null; if (next.fullControl !== full) void perform('mode', next); }
417
+ }
418
+ }
419
+ // The owner's mode switch: the dropdown writes its hidden input and fires `change`; the change is confirmed first,
420
+ // and a cancelled one puts the dropdown back.
421
+ query('mode').addEventListener('change', () => {
422
+ const next = query('mode').value === 'full';
423
+ if (next === full) return;
424
+ const trigger = pane.querySelector('.bc-ext-mode .cc-dropdown-trigger'), current = full;
425
+ confirmFirst(next ? 'full' : 'restrict', trigger, () => perform('mode', { fullControl: next }));
426
+ confirming.cancelled = () => showMode(current, true);
427
+ }, { signal });
428
+ pane.addEventListener('click', event => {
429
+ const target = event.target.closest('[data-extension-action]'), action = target?.dataset.extensionAction;
430
+ if (!action) return;
431
+ if (action === 'confirm-cancel') { closeConfirm(false); return; }
432
+ if (action === 'confirm-ok') { closeConfirm(true); return; }
433
+ if (action === 'disconnect' || action === 'revoke') { confirmFirst(action, target, () => perform(action)); return; }
434
+ void perform(action, action === 'setup-open-in' ? { browser: target.dataset.browser } : undefined);
435
+ }, { signal });
436
+ pane.addEventListener('keydown', event => {
437
+ if (event.key === 'Escape' && confirming) { event.preventDefault(); event.stopPropagation(); closeConfirm(false); }
438
+ }, { signal });
439
+ const mode = root.querySelector('#bc-connectMode');
440
+ const show = () => { pane.hidden = mode?.value !== 'extension'; if (!pane.hidden) void perform('refresh'); };
441
+ mode?.addEventListener('change', show, { signal });
442
+ root.querySelectorAll('.bc-dropdown[data-for="bc-connectMode"] .cc-dropdown-item').forEach(item => item.addEventListener('click', show, { signal }));
443
+ const timer = setInterval(() => { if (!pane.hidden && !busy) void perform('refresh'); }, 3000);
444
+ signal.addEventListener('abort', () => clearInterval(timer), { once: true });
445
+ show(); return show;
446
+ }
@@ -106,6 +106,7 @@ export const SETTINGS_PAGES = [
106
106
  sections: [
107
107
  { id: 'stg-sec-default-tools', key: 'default_tools', state: 'open' },
108
108
  { id: 'stg-sec-added-servers', key: 'added_servers', state: 'open' },
109
+ { id: 'stg-sec-ml-default', key: 'morelogin_default', state: 'open' },
109
110
  { id: 'stg-sec-ml-connection', key: 'morelogin_connection', state: 'open' },
110
111
  { id: 'stg-sec-ml-profiles', key: 'morelogin_profiles', state: 'open' },
111
112
  { id: 'stg-sec-ml-credentials', key: 'morelogin_credentials', state: 'advanced' },
@@ -265,19 +266,20 @@ export const SETTINGS_CONTROLS = {
265
266
  'stg-sec-workspaces': 'PRJ013 PRJ007 PRJ008 PRJ009 PRJ010 PRJ011 PRJ014 PRJ015 PRJ016 PRJ017 PRJ018',
266
267
  'project-storage-manager': 'PRJ001 PRJ012 PRJ002 PRJ003 PRJ004 PRJ005 PRJ006',
267
268
  'setup-browser': 'BRW003 BRW001 BRW002 BRW084 BRW004 BRW005 BRW006 BRW007 BRW008 BRW009',
268
- 'bcg-profiles': 'BRW011 BRW012 BRW013 BRW014 BRW083 BRW010 BRW015 BRW016 BRW017 BRW018 BRW019 BRW020',
269
+ 'bcg-profiles': 'BRW011 BRW012 BRW083 BRW010 BRW015 BRW016 BRW017 BRW018 BRW019 BRW020',
269
270
  'bcg-owner-access': 'BRW087',
270
271
  'bcg-identity': 'BRW021 BRW022 BRW023 BRW024 BRW025',
271
272
  'bcg-viewport': 'BRW026 BRW027 BRW028 BRW029 BRW030 BRW031 BRW032',
272
273
  'bcg-advanced': 'BRW033 BRW034 BRW035 BRW036 BRW037 BRW038 BRW039 BRW040 BRW041 BRW042 BRW043 BRW044 BRW045 BRW046 BRW047 BRW048 BRW049 BRW050 BRW051 BRW052 BRW053 BRW054 BRW055 BRW056 BRW057 BRW058 BRW059 BRW060 BRW061 BRW062 BRW063 BRW064 BRW065 BRW066 BRW067 BRW068 BRW069 BRW070 BRW071 BRW072 BRW073 BRW074 BRW075 BRW076 BRW077 BRW078 BRW079 BRW080',
273
274
  'stg-sec-default-tools': 'MCP022 MCP024 MCP005 MCP004',
274
275
  'stg-sec-added-servers': 'MCP026 MCP006 MCP007 MCP008 MCP009 MCP010 MCP011 MCP012 MCP013 MCP014 MCP015 MCP027 MCP016 MCP017 MCP018 MCP019 MCP020 MCP021',
276
+ 'stg-sec-ml-default': 'ML037 ML038 ML039',
275
277
  'stg-sec-ml-connection': 'ML015 ML001 ML002 ML003',
276
278
  'stg-sec-ml-profiles': 'ML004 ML020 ML005 ML006 ML016 ML017 ML018 ML019 ML021 ML022 ML023 ML024 ML025 ML026 ML027 ML028 ML029 ML030 ML031 ML032 ML033 ML034 ML035 ML036',
277
279
  'stg-sec-ml-credentials': 'ML007 ML008 ML009 ML010 ML011',
278
280
  'stg-sec-ml-server': 'ML012 ML013 ML014',
279
281
  'stg-sec-skills': 'SKL004 SKL001',
280
- 'stg-sec-tool-permissions': 'PER012 PER001 PER002 PER003 PER004 PER005 PER006 PER008 PER009 PER010 PER011',
282
+ 'stg-sec-tool-permissions': 'PER012 PER013 PER001 PER002 PER003 PER004 PER005 PER006 PER008 PER009 PER010 PER011',
281
283
  'stg-sec-editor-editing': 'EDT014 EDT015 EDT016 EDT017 EDT018 EDT019 EDT020 EDT021 EDT022 EDT023',
282
284
  'stg-sec-editor-ai': 'EDT001 EDT002 EDT003 EDT004 EDT005 EDT006 EDT007 EDT008 EDT009 EDT010 EDT011 EDT012 EDT013',
283
285
  'stg-sec-greetings': 'AUT058 AUT059 AUT060',