synabun 2.3.0 → 2.4.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 (367) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +1 -1
  3. package/browser-extension/content.js +169 -0
  4. package/browser-extension/engine.js +477 -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 +244 -0
  17. package/browser-extension/popup-view.js +151 -0
  18. package/browser-extension/popup.css +165 -0
  19. package/browser-extension/popup.html +105 -0
  20. package/browser-extension/popup.js +347 -0
  21. package/browser-extension/protocol.js +226 -0
  22. package/browser-extension/service-worker.js +267 -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/mcp-server/dist/http.d.ts +2 -0
  28. package/mcp-server/dist/http.d.ts.map +1 -1
  29. package/mcp-server/dist/http.js +9 -1
  30. package/mcp-server/dist/http.js.map +1 -1
  31. package/mcp-server/dist/index.d.ts +11 -0
  32. package/mcp-server/dist/index.d.ts.map +1 -1
  33. package/mcp-server/dist/index.js +38 -3
  34. package/mcp-server/dist/index.js.map +1 -1
  35. package/mcp-server/dist/services/browser-route-flow.d.ts +6 -2
  36. package/mcp-server/dist/services/browser-route-flow.d.ts.map +1 -1
  37. package/mcp-server/dist/services/browser-route-flow.js +10 -3
  38. package/mcp-server/dist/services/browser-route-flow.js.map +1 -1
  39. package/mcp-server/dist/services/codex-config-heal.d.ts.map +1 -1
  40. package/mcp-server/dist/services/codex-config-heal.js +7 -0
  41. package/mcp-server/dist/services/codex-config-heal.js.map +1 -1
  42. package/mcp-server/dist/services/neural-interface.d.ts +94 -3
  43. package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
  44. package/mcp-server/dist/services/neural-interface.js +168 -23
  45. package/mcp-server/dist/services/neural-interface.js.map +1 -1
  46. package/mcp-server/dist/services/team-context.d.ts +18 -0
  47. package/mcp-server/dist/services/team-context.d.ts.map +1 -0
  48. package/mcp-server/dist/services/team-context.js +29 -0
  49. package/mcp-server/dist/services/team-context.js.map +1 -0
  50. package/mcp-server/dist/services/tool-catalog.d.ts +5 -2
  51. package/mcp-server/dist/services/tool-catalog.d.ts.map +1 -1
  52. package/mcp-server/dist/services/tool-catalog.js +22 -6
  53. package/mcp-server/dist/services/tool-catalog.js.map +1 -1
  54. package/mcp-server/dist/services/tool-list.d.ts.map +1 -1
  55. package/mcp-server/dist/services/tool-list.js +4 -0
  56. package/mcp-server/dist/services/tool-list.js.map +1 -1
  57. package/mcp-server/dist/services/tool-runtime.d.ts +8 -1
  58. package/mcp-server/dist/services/tool-runtime.d.ts.map +1 -1
  59. package/mcp-server/dist/services/tool-runtime.js +18 -1
  60. package/mcp-server/dist/services/tool-runtime.js.map +1 -1
  61. package/mcp-server/dist/tools/agent-definition.d.ts +133 -0
  62. package/mcp-server/dist/tools/agent-definition.d.ts.map +1 -0
  63. package/mcp-server/dist/tools/agent-definition.js +483 -0
  64. package/mcp-server/dist/tools/agent-definition.js.map +1 -0
  65. package/mcp-server/dist/tools/agents.d.ts +91 -9
  66. package/mcp-server/dist/tools/agents.d.ts.map +1 -1
  67. package/mcp-server/dist/tools/agents.js +161 -20
  68. package/mcp-server/dist/tools/agents.js.map +1 -1
  69. package/mcp-server/dist/tools/browser-advanced.d.ts +8 -1
  70. package/mcp-server/dist/tools/browser-advanced.d.ts.map +1 -1
  71. package/mcp-server/dist/tools/browser-advanced.js +70 -6
  72. package/mcp-server/dist/tools/browser-advanced.js.map +1 -1
  73. package/mcp-server/dist/tools/git-tools.d.ts +4 -2
  74. package/mcp-server/dist/tools/git-tools.d.ts.map +1 -1
  75. package/mcp-server/dist/tools/git-tools.js +283 -2
  76. package/mcp-server/dist/tools/git-tools.js.map +1 -1
  77. package/mcp-server/dist/tools/morelogin.d.ts +8 -2
  78. package/mcp-server/dist/tools/morelogin.d.ts.map +1 -1
  79. package/mcp-server/dist/tools/morelogin.js +22 -5
  80. package/mcp-server/dist/tools/morelogin.js.map +1 -1
  81. package/mcp-server/dist/tools/team.d.ts +32 -0
  82. package/mcp-server/dist/tools/team.d.ts.map +1 -0
  83. package/mcp-server/dist/tools/team.js +87 -0
  84. package/mcp-server/dist/tools/team.js.map +1 -0
  85. package/mcp-server/package-lock.json +2 -2
  86. package/mcp-server/package.json +1 -1
  87. package/mcp-server/src/http.ts +9 -1
  88. package/mcp-server/src/index.ts +34 -4
  89. package/mcp-server/src/services/browser-route-flow.ts +12 -5
  90. package/mcp-server/src/services/codex-config-heal.ts +7 -0
  91. package/mcp-server/src/services/neural-interface.ts +190 -29
  92. package/mcp-server/src/services/team-context.ts +27 -0
  93. package/mcp-server/src/services/tool-catalog.ts +26 -8
  94. package/mcp-server/src/services/tool-list.ts +4 -0
  95. package/mcp-server/src/services/tool-runtime.ts +21 -2
  96. package/mcp-server/src/tools/agent-definition.ts +458 -0
  97. package/mcp-server/src/tools/agents.ts +175 -19
  98. package/mcp-server/src/tools/browser-advanced.ts +60 -6
  99. package/mcp-server/src/tools/git-tools.ts +249 -3
  100. package/mcp-server/src/tools/morelogin.ts +20 -5
  101. package/mcp-server/src/tools/team.ts +97 -0
  102. package/neural-interface/i18n/en.json +1174 -47
  103. package/neural-interface/i18n/pt-BR.json +1174 -47
  104. package/neural-interface/lib/account-usage.js +1 -1
  105. package/neural-interface/lib/agents/density.js +101 -0
  106. package/neural-interface/lib/agents/forge-host.js +223 -0
  107. package/neural-interface/lib/agents/native-export-targets.js +190 -0
  108. package/neural-interface/lib/agents/native-export.js +365 -0
  109. package/neural-interface/lib/agents/registry.js +840 -0
  110. package/neural-interface/lib/agents/resolve.js +544 -0
  111. package/neural-interface/lib/agents/schema.js +642 -0
  112. package/neural-interface/lib/agents/split.js +37 -0
  113. package/neural-interface/lib/agents-studio-api.js +591 -0
  114. package/neural-interface/lib/assistant-api.js +76 -7
  115. package/neural-interface/lib/assistant-catalog.js +2 -0
  116. package/neural-interface/lib/assistant-continuity.js +49 -0
  117. package/neural-interface/lib/assistant-dispatch.js +229 -102
  118. package/neural-interface/lib/assistant-persona.js +105 -8
  119. package/neural-interface/lib/assistant-route-gate.js +24 -9
  120. package/neural-interface/lib/assistant-router.js +384 -42
  121. package/neural-interface/lib/assistant-run-tail.js +151 -0
  122. package/neural-interface/lib/assistant-run-wait.js +183 -0
  123. package/neural-interface/lib/assistant-runtime.js +440 -93
  124. package/neural-interface/lib/assistant-task-prompt.js +11 -2
  125. package/neural-interface/lib/assistant-usage.js +3 -2
  126. package/neural-interface/lib/automation-approval.js +2 -2
  127. package/neural-interface/lib/browser-close-evidence.js +80 -0
  128. package/neural-interface/lib/browser-default.js +210 -0
  129. package/neural-interface/lib/browser-extension-adapter.js +255 -0
  130. package/neural-interface/lib/browser-extension-bridge.js +418 -0
  131. package/neural-interface/lib/browser-extension-folder.js +116 -0
  132. package/neural-interface/lib/browser-extension-setup.js +140 -0
  133. package/neural-interface/lib/browser-profile-choices.js +3 -3
  134. package/neural-interface/lib/browser-profiles.js +1 -1
  135. package/neural-interface/lib/browser-tool-policy.js +1 -1
  136. package/neural-interface/lib/claude-account-links.js +301 -0
  137. package/neural-interface/lib/claude-accounts.js +45 -20
  138. package/neural-interface/lib/claude-agent-bridge.js +142 -10
  139. package/neural-interface/lib/claude-model-catalog.js +6 -0
  140. package/neural-interface/lib/claude-panel-session.js +33 -0
  141. package/neural-interface/lib/cli-install-api.js +23 -0
  142. package/neural-interface/lib/codex-accounts.js +67 -24
  143. package/neural-interface/lib/coordination/README.md +384 -0
  144. package/neural-interface/lib/coordination/service.js +563 -0
  145. package/neural-interface/lib/coordination/store.js +1138 -0
  146. package/neural-interface/lib/db.js +22 -1
  147. package/neural-interface/lib/editor-completion-opencode.js +4 -3
  148. package/neural-interface/lib/effort-levels.js +10 -1
  149. package/neural-interface/lib/maritaca/opencode-proxy.js +7 -2
  150. package/neural-interface/lib/maritaca/opencode.js +35 -0
  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 +219 -7
  157. package/neural-interface/lib/native-loop-runtime.js +24 -1
  158. package/neural-interface/lib/opencode-build-preflight.js +116 -0
  159. package/neural-interface/lib/opencode-launch-error.js +13 -0
  160. package/neural-interface/lib/opencode-native-boundary.js +800 -84
  161. package/neural-interface/lib/opencode-serve-probe.js +426 -0
  162. package/neural-interface/lib/opencode-serve-records.js +14 -9
  163. package/neural-interface/lib/opencode-serve-scan.js +108 -0
  164. package/neural-interface/lib/page-session.js +1 -1
  165. package/neural-interface/lib/peer-identity.js +60 -21
  166. package/neural-interface/lib/process-identity.js +235 -7
  167. package/neural-interface/lib/request-gate.js +3 -0
  168. package/neural-interface/lib/screenshot-location.js +33 -0
  169. package/neural-interface/lib/skills/creation.js +1 -1
  170. package/neural-interface/lib/skills/known-bridge-digests.json +40 -0
  171. package/neural-interface/lib/studio-attention.js +56 -0
  172. package/neural-interface/lib/teams/README.md +382 -0
  173. package/neural-interface/lib/teams/api.js +287 -0
  174. package/neural-interface/lib/teams/brief.js +185 -0
  175. package/neural-interface/lib/teams/claims.js +315 -0
  176. package/neural-interface/lib/teams/git.js +293 -0
  177. package/neural-interface/lib/teams/index.js +122 -0
  178. package/neural-interface/lib/teams/integration.js +580 -0
  179. package/neural-interface/lib/teams/landing.js +184 -0
  180. package/neural-interface/lib/teams/recovery.js +256 -0
  181. package/neural-interface/lib/teams/scheduler.js +1474 -0
  182. package/neural-interface/lib/teams/schema.js +559 -0
  183. package/neural-interface/lib/teams/state.js +181 -0
  184. package/neural-interface/lib/teams/test-runner.js +86 -0
  185. package/neural-interface/lib/teams/test-sandbox.js +99 -0
  186. package/neural-interface/lib/teams/worktrees.js +757 -0
  187. package/neural-interface/lib/tool-permission-choices.js +226 -0
  188. package/neural-interface/lib/whatsapp/cards.js +24 -10
  189. package/neural-interface/lib/worker-confinement.js +206 -6
  190. package/neural-interface/lib/worker-mcp-channel.js +38 -1
  191. package/neural-interface/package-lock.json +4 -2
  192. package/neural-interface/package.json +3 -1
  193. package/neural-interface/public/extension-setup.html +107 -0
  194. package/neural-interface/public/index.html +52 -12
  195. package/neural-interface/public/shared/agent-runtime-options.js +3 -1
  196. package/neural-interface/public/shared/agents/studio/ax-agent-view.js +614 -0
  197. package/neural-interface/public/shared/agents/studio/ax-api.js +198 -0
  198. package/neural-interface/public/shared/agents/studio/ax-create-view.js +221 -0
  199. package/neural-interface/public/shared/agents/studio/ax-diff.js +143 -0
  200. package/neural-interface/public/shared/agents/studio/ax-editor-view.js +392 -0
  201. package/neural-interface/public/shared/agents/studio/ax-export-view.js +94 -0
  202. package/neural-interface/public/shared/agents/studio/ax-form.js +191 -0
  203. package/neural-interface/public/shared/agents/studio/ax-icons.js +87 -0
  204. package/neural-interface/public/shared/agents/studio/ax-library-view.js +158 -0
  205. package/neural-interface/public/shared/agents/studio/ax-library.js +162 -0
  206. package/neural-interface/public/shared/agents/studio/ax-main.js +712 -0
  207. package/neural-interface/public/shared/agents/studio/ax-native-export.js +35 -0
  208. package/neural-interface/public/shared/agents/studio/ax-options.js +198 -0
  209. package/neural-interface/public/shared/agents/studio/ax-review-view.js +175 -0
  210. package/neural-interface/public/shared/agents/studio/ax-revisions-view.js +189 -0
  211. package/neural-interface/public/shared/agents/studio/ax-runs-view.js +202 -0
  212. package/neural-interface/public/shared/agents/studio/ax-runs.js +82 -0
  213. package/neural-interface/public/shared/agents/studio/ax-teams-view.js +256 -0
  214. package/neural-interface/public/shared/agents/studio/ax-teams.js +200 -0
  215. package/neural-interface/public/shared/agents/studio/ax-templates.js +50 -0
  216. package/neural-interface/public/shared/agents/studio/ax-ui.js +194 -0
  217. package/neural-interface/public/shared/agents/studio/ax-views.js +170 -0
  218. package/neural-interface/public/shared/agy/agy-panel.js +142 -28
  219. package/neural-interface/public/shared/agy/agy-styles.js +25 -5
  220. package/neural-interface/public/shared/assistant/asst-account-menu.js +13 -13
  221. package/neural-interface/public/shared/assistant/asst-ask-styles.js +2 -3
  222. package/neural-interface/public/shared/assistant/asst-brain-picker.js +91 -9
  223. package/neural-interface/public/shared/assistant/asst-control.js +3 -0
  224. package/neural-interface/public/shared/assistant/asst-interaction-hold.js +99 -0
  225. package/neural-interface/public/shared/assistant/asst-limit-dismissals.js +111 -0
  226. package/neural-interface/public/shared/assistant/asst-limit-dock.js +37 -3
  227. package/neural-interface/public/shared/assistant/asst-limit-wait.js +30 -7
  228. package/neural-interface/public/shared/assistant/asst-panel.js +177 -30
  229. package/neural-interface/public/shared/assistant/asst-rack-styles.js +15 -8
  230. package/neural-interface/public/shared/assistant/asst-render.js +36 -6
  231. package/neural-interface/public/shared/assistant/asst-route.js +78 -12
  232. package/neural-interface/public/shared/assistant/asst-routes-editor.js +148 -70
  233. package/neural-interface/public/shared/assistant/asst-roving.js +17 -1
  234. package/neural-interface/public/shared/assistant/asst-scene-styles.js +7 -2
  235. package/neural-interface/public/shared/assistant/asst-scenes.js +12 -1
  236. package/neural-interface/public/shared/assistant/asst-sidepanel.js +12 -2
  237. package/neural-interface/public/shared/assistant/asst-state.js +66 -1
  238. package/neural-interface/public/shared/assistant/asst-styles.js +98 -44
  239. package/neural-interface/public/shared/assistant/route-identity.js +16 -0
  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 +33 -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/opencode-verify-view.js +175 -0
  279. package/neural-interface/public/shared/schedules-view.js +2 -2
  280. package/neural-interface/public/shared/session-project-items.js +11 -0
  281. package/neural-interface/public/shared/settings/settings-ai-browser.js +119 -0
  282. package/neural-interface/public/shared/settings/settings-browser-extension.js +446 -0
  283. package/neural-interface/public/shared/settings/settings-ia.js +4 -2
  284. package/neural-interface/public/shared/settings/settings-morelogin-cooldown.js +63 -0
  285. package/neural-interface/public/shared/settings/settings-tool-permissions.js +70 -0
  286. package/neural-interface/public/shared/sidepanel-lazy.js +40 -0
  287. package/neural-interface/public/shared/sidepanel-session-status.js +8 -14
  288. package/neural-interface/public/shared/sidepanel-shown.js +73 -0
  289. package/neural-interface/public/shared/storage.js +6 -1
  290. package/neural-interface/public/shared/studio-attention.js +83 -0
  291. package/neural-interface/public/shared/styles.css +713 -61
  292. package/neural-interface/public/shared/term-browser-tabs.js +34 -0
  293. package/neural-interface/public/shared/transcript-rows.js +334 -0
  294. package/neural-interface/public/shared/tray-auto-close.js +106 -0
  295. package/neural-interface/public/shared/ui-agents.js +97 -0
  296. package/neural-interface/public/shared/ui-antigravity-panel.js +16 -14
  297. package/neural-interface/public/shared/ui-automation-studio.js +3 -3
  298. package/neural-interface/public/shared/ui-claude-panel.js +162 -95
  299. package/neural-interface/public/shared/ui-code-copy.js +256 -0
  300. package/neural-interface/public/shared/ui-codex-panel.js +14 -10
  301. package/neural-interface/public/shared/ui-context-menu.js +1 -1
  302. package/neural-interface/public/shared/ui-file-explorer.js +2 -3
  303. package/neural-interface/public/shared/ui-games.js +1 -1
  304. package/neural-interface/public/shared/ui-loading.js +12 -1
  305. package/neural-interface/public/shared/ui-maritaca-panel.js +12 -11
  306. package/neural-interface/public/shared/ui-menubar.js +23 -0
  307. package/neural-interface/public/shared/ui-native-loop-router.js +1 -1
  308. package/neural-interface/public/shared/ui-navbar.js +15 -9
  309. package/neural-interface/public/shared/ui-opencode-panel-v2.js +13 -11
  310. package/neural-interface/public/shared/ui-opencode-verify.js +120 -0
  311. package/neural-interface/public/shared/ui-schedules-studio.js +3 -3
  312. package/neural-interface/public/shared/ui-scroll-follow.js +39 -0
  313. package/neural-interface/public/shared/ui-sessions.js +3 -3
  314. package/neural-interface/public/shared/ui-settings-entry.js +55 -0
  315. package/neural-interface/public/shared/ui-settings.js +372 -402
  316. package/neural-interface/public/shared/ui-sidepanel-layout.js +44 -25
  317. package/neural-interface/public/shared/ui-sidepanel-session-entry.js +22 -9
  318. package/neural-interface/public/shared/ui-sidepanel-sessions.js +10 -2
  319. package/neural-interface/public/shared/ui-sidepanel-tray.js +36 -41
  320. package/neural-interface/public/shared/ui-sidepanel-windows.js +14 -1
  321. package/neural-interface/public/shared/ui-styleguide.js +10 -2
  322. package/neural-interface/public/shared/ui-sync.js +5 -0
  323. package/neural-interface/public/shared/ui-terminal.js +13 -9
  324. package/neural-interface/public/shared/ui-tooltip.js +28 -7
  325. package/neural-interface/public/shared/ui-topright-overflow.js +26 -4
  326. package/neural-interface/public/shared/ui-tray-columns.js +375 -0
  327. package/neural-interface/public/shared/ui-whiteboard.js +51 -6
  328. package/neural-interface/public/shared/ui-worker-end.js +28 -1
  329. package/neural-interface/public/shared/ui-workspaces.js +13 -0
  330. package/neural-interface/public/shared/window-keys.js +71 -0
  331. package/neural-interface/public/variant/2d/main.js +2 -0
  332. package/neural-interface/public/variant/3d/app.js +620 -0
  333. package/neural-interface/public/variant/3d/boot-reveal.js +47 -0
  334. package/neural-interface/public/variant/3d/main.js +21 -544
  335. package/neural-interface/public/variant/3d/map-controls.js +4 -2
  336. package/neural-interface/public/vendor/fonts/fonts.css +508 -0
  337. package/neural-interface/public/vendor/fonts/inter-OFL.txt +93 -0
  338. package/neural-interface/public/vendor/fonts/inter-cyrillic-ext.woff2 +0 -0
  339. package/neural-interface/public/vendor/fonts/inter-cyrillic.woff2 +0 -0
  340. package/neural-interface/public/vendor/fonts/inter-greek-ext.woff2 +0 -0
  341. package/neural-interface/public/vendor/fonts/inter-greek.woff2 +0 -0
  342. package/neural-interface/public/vendor/fonts/inter-latin-ext.woff2 +0 -0
  343. package/neural-interface/public/vendor/fonts/inter-latin.woff2 +0 -0
  344. package/neural-interface/public/vendor/fonts/inter-vietnamese.woff2 +0 -0
  345. package/neural-interface/public/vendor/fonts/jetbrains-mono-OFL.txt +93 -0
  346. package/neural-interface/public/vendor/fonts/jetbrains-mono-cyrillic-ext.woff2 +0 -0
  347. package/neural-interface/public/vendor/fonts/jetbrains-mono-cyrillic.woff2 +0 -0
  348. package/neural-interface/public/vendor/fonts/jetbrains-mono-greek.woff2 +0 -0
  349. package/neural-interface/public/vendor/fonts/jetbrains-mono-latin-ext.woff2 +0 -0
  350. package/neural-interface/public/vendor/fonts/jetbrains-mono-latin.woff2 +0 -0
  351. package/neural-interface/public/vendor/fonts/jetbrains-mono-vietnamese.woff2 +0 -0
  352. package/neural-interface/public/vendor/fonts/manifest.json +142 -0
  353. package/neural-interface/public/vendor/fonts/space-grotesk-OFL.txt +93 -0
  354. package/neural-interface/public/vendor/fonts/space-grotesk-latin-ext.woff2 +0 -0
  355. package/neural-interface/public/vendor/fonts/space-grotesk-latin.woff2 +0 -0
  356. package/neural-interface/public/vendor/fonts/space-grotesk-vietnamese.woff2 +0 -0
  357. package/neural-interface/scripts/boot-graph.mjs +270 -0
  358. package/neural-interface/scripts/vendor-fonts.mjs +124 -0
  359. package/neural-interface/server.js +1164 -157
  360. package/npm-shrinkwrap.json +2 -2
  361. package/package.json +3 -1
  362. package/skills/agent-forge/SKILL.md +182 -0
  363. package/skills/agent-forge/evals/evals.json +56 -0
  364. package/skills/agent-forge/references/definition-fields.md +61 -0
  365. package/skills/agent-forge/references/examples.md +105 -0
  366. package/skills/agent-forge/references/instructions.md +51 -0
  367. package/skills/agent-forge/references/review-and-export.md +84 -0
@@ -1,3 +1,4 @@
1
+ import { extensionSettingsHTML, wireExtensionSettings } from './settings/settings-browser-extension.js';
1
2
  import { fetchToolCatalog } from './agent-runtime-options.js';
2
3
  import { reloadAfterRestore } from './server-back.js';
3
4
  import { configureToolPickerTranslation, toolPickerHTML, readToolPicker, toolWord, toolServersNote } from './tool-list-picker.js';
@@ -15,6 +16,7 @@ import { readUserContextResponse, describeUserContext, describeUserContextSaveFa
15
16
  import { readWorkerGuardResponse, describeWorkerGuard, describeWorkerGuardSaveFailure } from './settings/settings-worker-guard.js';
16
17
  import { readOwnerAccessResponse, describeOwnerAccess, describeOwnerAccessSaveFailure } from './settings/settings-browser-owner-access.js';
17
18
  import { CLAUDE_HOOK_ROWS, readClaudeHooksResponse, describeClaudeHooks, describeClaudeHooksSaveFailure } from './settings/settings-claude-hooks.js';
19
+ import { masterView, masterRequests, countTools } from './settings/settings-tool-permissions.js';
18
20
  import { readGreetingStatus, describeGreeting, describeGreetingSaveFailure } from './settings/settings-greeting.js';
19
21
  import { describeOpencodeInstall } from './settings/settings-opencode.js';
20
22
  import { maritacaOpencodeCardView, maritacaOpencodeModelRows, MARITACA_OPENCODE_KEYS, MARITACA_OPENCODE_PROVIDER } from './settings/settings-maritaca-opencode.js';
@@ -25,11 +27,18 @@ import { recheckCliStatus, getCliStatus, addCliToPath } from './cli-status.js';
25
27
  import { cliInstallText, setCliInstallTranslator } from './cli-install-view.js';
26
28
  import { dropdownHTML, wireDropdowns, setDropdownItems, setDropdownValue } from './cc-dropdown.js';
27
29
  import { PROXY_TYPES, isLocalProfile, proxySummary, defaultCreateWhere, isPlanLimit, formOfProfile, readLocalProfileForm, proxyOfForm, createAction, whereOptions, passwordNeededAgain } from './settings/settings-local-profiles.js';
28
- import { setStaticBgVisible } from './static-bg-state.js';
30
+ import { startLimitNotes, closedOutsideNotes } from './settings/settings-morelogin-cooldown.js';
31
+ import { AI_BROWSER_EVENT, aiBrowserOf, aiBrowserOfStatus, localConnectModeOf, browserSaveFields, switchRequest, pickRequest, aiBrowserLine, profileOf, aiBrowserDetail } from './settings/settings-ai-browser.js';
32
+ import { IFACE_DEFAULTS, loadIfaceConfig, saveIfaceConfig, applyIfaceConfig, restoreInterfaceConfig, loadSkinStylesheet, removeSkinStylesheet, restoreSkin, setSkinsTabRefresher } from './iface-config.js';
33
+ // The interface config and the skin, for the modules that import them from here.
34
+ export { loadIfaceConfig, saveIfaceConfig, applyIfaceConfig, restoreInterfaceConfig, restoreSkin };
29
35
  setCliInstallTranslator((key, params) => kit.tx(`cliInstall.${key}`, params));
30
36
  import { setGitBashTranslator } from './git-bash-view.js';
31
37
  import { gitBashRowHtml, wireGitBashRow } from './ui-git-bash.js';
38
+ import { setOpencodeVerifyTranslator } from './opencode-verify-view.js';
39
+ import { opencodeVerifyRowHtml, wireOpencodeVerifyRow } from './ui-opencode-verify.js';
32
40
  setGitBashTranslator((key, params) => kit.tx(`gitBash.${key}`, params));
41
+ setOpencodeVerifyTranslator((key, params) => kit.tx(`opencodeVerify.${key}`, params));
33
42
  import { initI18n, isReady as i18nReady, SUPPORTED_LOCALES, LOCALE_NAMES, SYSTEM_LOCALE, getLocale, getLocaleChoice, setLocaleChoice, getSystemLocale, englishTranslator, loadEnglishTranslator } from './i18n.js';
34
43
  import { wireSettingsShell, wireSettingsSearch, collectSearchRows, revealSettingsTarget, followSettingsTarget, onSettingsTakeover, applyStoredSections, storeSectionState } from './settings/settings-shell.js';
35
44
  import { buildSettingsSearchIndex } from './settings/settings-search.js';
@@ -130,24 +139,9 @@ function showCCToast(msg, duration = 3500) {
130
139
  // INTERFACE CUSTOMIZATION — config, presets, apply
131
140
  // ═══════════════════════════════════════════
132
141
 
133
- // Optional legacy view preferences must never reintroduce a 2D selection.
134
- const IFACE_DEFAULTS = {
135
- visualizationEnabled: true,
136
- scale: 1,
137
- glassOpacity: 0.72,
138
- // 16 keeps the glass look at a fraction of the compositing cost — users can
139
- // still crank the slider to 80 to explicitly opt back into heavier blur
140
- glassBlur: 16,
141
- glassSaturate: 1.4,
142
- glassBorderOpacity: 0.06,
143
- glassShadowOpacity: 0.4,
144
- glassShadowSpread: 20,
145
- glassRadius: 14,
146
- fontScale: 1,
147
- accentHue: 0,
148
- accentSaturation: 0,
149
- accentLightness: 80,
150
- };
142
+ // IFACE_DEFAULTS, loading / saving / applying the config and the skin stylesheet live in iface-config.js: the boot
143
+ // needs them before this module (the Settings window, loaded on first open or in idle time) has loaded.
144
+ setSkinsTabRefresher((panel) => refreshSkinsTab(panel));
151
145
 
152
146
  const IFACE_PRESETS = {
153
147
  default: { label: 'Default', desc: 'Standard glass look', values: { ...IFACE_DEFAULTS } },
@@ -176,197 +170,6 @@ const IFACE_SLIDERS = {
176
170
  ],
177
171
  };
178
172
 
179
- export function loadIfaceConfig() {
180
- try {
181
- const raw = storage.getItem('neural-interface-config');
182
- if (raw) return { ...IFACE_DEFAULTS, ...normalizeViewConfig(JSON.parse(raw)) };
183
- // Migrate legacy ui-scale if present
184
- const legacyScale = storage.getItem('neural-ui-scale');
185
- if (legacyScale) {
186
- const cfg = { ...IFACE_DEFAULTS, scale: parseFloat(legacyScale) || 1 };
187
- saveIfaceConfig(cfg);
188
- return cfg;
189
- }
190
- return { ...IFACE_DEFAULTS };
191
- } catch { return { ...IFACE_DEFAULTS }; }
192
- }
193
-
194
- export function saveIfaceConfig(cfg) {
195
- storage.setItem('neural-interface-config', JSON.stringify(normalizeViewConfig(cfg)));
196
- // Keep legacy key in sync for backwards compat
197
- storage.setItem('neural-ui-scale', cfg.scale);
198
- }
199
-
200
- export function applyIfaceConfig(cfg, { instant = false } = {}) {
201
- const r = document.documentElement.style;
202
- r.setProperty('--ui-scale', cfg.scale);
203
- r.setProperty('--glass-opacity', cfg.glassOpacity);
204
- r.setProperty('--glass-blur', cfg.glassBlur);
205
- r.setProperty('--glass-saturate', cfg.glassSaturate);
206
- r.setProperty('--glass-border-opacity', cfg.glassBorderOpacity);
207
- r.setProperty('--glass-shadow-opacity', cfg.glassShadowOpacity);
208
- r.setProperty('--glass-shadow-spread', cfg.glassShadowSpread);
209
- r.setProperty('--glass-radius', cfg.glassRadius);
210
- r.setProperty('--font-scale', cfg.fontScale);
211
- r.setProperty('--accent-hue', cfg.accentHue);
212
- r.setProperty('--accent-saturation', cfg.accentSaturation + '%');
213
- r.setProperty('--accent-lightness', cfg.accentLightness + '%');
214
-
215
- // Focus Mode — scale+blur transition with staggered controls
216
- const vizEnabled = cfg.visualizationEnabled !== false;
217
- const graphContainer = document.getElementById('graph-container');
218
- const staticBg = document.getElementById('static-bg');
219
-
220
- if (!vizEnabled) {
221
- // ENTERING FOCUS MODE
222
-
223
- // ── Clean up all interactive state ──
224
- // Hide 3D tooltip + detach its mousemove listener
225
- const $tooltip = document.getElementById('tooltip');
226
- if ($tooltip) {
227
- $tooltip.classList.remove('visible');
228
- if ($tooltip._moveHandler) {
229
- document.removeEventListener('mousemove', $tooltip._moveHandler);
230
- $tooltip._moveHandler = null;
231
- }
232
- }
233
- // Hide data-tooltip tooltips
234
- const uiTip = document.querySelector('.ui-tooltip');
235
- if (uiTip) {
236
- uiTip.classList.remove('visible');
237
- uiTip.style.display = 'none';
238
- }
239
- // Clear hover state
240
- state.hoveredNodeId = null;
241
- // Clear multi-select
242
- if (state.multiSelected.size > 0) {
243
- state.multiSelected.clear();
244
- const bar = document.getElementById('multi-select-bar');
245
- if (bar) bar.classList.remove('open');
246
- emit('multiselect:cleared');
247
- }
248
- // Reset cursor
249
- document.body.style.cursor = 'default';
250
-
251
- // Hide controls, 2D canvases, category sidebar
252
- for (const id of ['controls-panel', 'stats-bar', 'category-sidebar']) {
253
- const el = document.getElementById(id);
254
- if (el) el.classList.add('viz-hidden');
255
- }
256
- for (const id of ['bg-canvas', 'hull-canvas', 'lasso-canvas']) {
257
- const el = document.getElementById(id);
258
- if (el) el.classList.add('viz-hidden-2d');
259
- }
260
- if (instant) {
261
- // Page load — apply immediately without animation
262
- if (graphContainer) graphContainer.classList.add('focus-active');
263
- setStaticBgVisible(staticBg, true);
264
- } else {
265
- // User toggle — stagger: controls fade first, then iris closes
266
- setTimeout(() => {
267
- if (graphContainer) graphContainer.classList.add('focus-active');
268
- setStaticBgVisible(staticBg, true);
269
- }, 100);
270
- }
271
- // Notify variant-specific cleanup (lasso, context menu, etc.)
272
- emit('focus:enter');
273
- } else {
274
- // EXITING FOCUS MODE
275
- // Iris open the graph + close focus bg
276
- if (graphContainer) graphContainer.classList.remove('focus-active');
277
- setStaticBgVisible(staticBg, false);
278
- // 2D canvases
279
- for (const id of ['bg-canvas', 'hull-canvas', 'lasso-canvas']) {
280
- const el = document.getElementById(id);
281
- if (el) el.classList.remove('viz-hidden-2d');
282
- }
283
- if (instant) {
284
- // Page load — show controls immediately
285
- for (const id of ['controls-panel', 'stats-bar', 'category-sidebar']) {
286
- const el = document.getElementById(id);
287
- if (el) el.classList.remove('viz-hidden');
288
- }
289
- } else {
290
- // User toggle — delay controls until iris starts opening
291
- setTimeout(() => {
292
- for (const id of ['controls-panel', 'stats-bar', 'category-sidebar']) {
293
- const el = document.getElementById(id);
294
- if (el) el.classList.remove('viz-hidden');
295
- }
296
- }, 200);
297
- }
298
- emit('focus:exit');
299
- }
300
- // Notify variants to pause/resume rendering
301
- emit('viz:toggle', vizEnabled);
302
- }
303
-
304
- /** Call on page load to restore saved interface config */
305
- export function restoreInterfaceConfig() {
306
- // Suppress transitions during initial load to prevent flash
307
- document.documentElement.classList.add('no-transition');
308
- applyIfaceConfig(loadIfaceConfig(), { instant: true });
309
- // Re-enable transitions after a frame
310
- requestAnimationFrame(() => {
311
- requestAnimationFrame(() => {
312
- document.documentElement.classList.remove('no-transition');
313
- });
314
- });
315
- }
316
-
317
- // ═══════════════════════════════════════════
318
- // SKIN LOADING — stylesheet injection + boot restore
319
- // ═══════════════════════════════════════════
320
-
321
- const SKIN_LINK_ID = 'synabun-skin-css';
322
-
323
- /** Insert or update the skin stylesheet <link> */
324
- function loadSkinStylesheet(skinId) {
325
- if (!skinId || skinId === 'default') {
326
- removeSkinStylesheet();
327
- return;
328
- }
329
- let link = document.getElementById(SKIN_LINK_ID);
330
- if (!link) {
331
- link = document.createElement('link');
332
- link.id = SKIN_LINK_ID;
333
- link.rel = 'stylesheet';
334
- // Insert after the main styles.css
335
- const mainCSS = document.querySelector('link[href*="styles.css"]');
336
- if (mainCSS && mainCSS.nextSibling) {
337
- mainCSS.parentNode.insertBefore(link, mainCSS.nextSibling);
338
- } else {
339
- document.head.appendChild(link);
340
- }
341
- }
342
- link.href = `/skins/${skinId}/skin.css`;
343
- storage.setItem(KEYS.ACTIVE_SKIN, skinId);
344
- }
345
-
346
- /** Remove the skin stylesheet */
347
- function removeSkinStylesheet() {
348
- const link = document.getElementById(SKIN_LINK_ID);
349
- if (link) link.remove();
350
- storage.setItem(KEYS.ACTIVE_SKIN, 'default');
351
- }
352
-
353
- /** Restore active skin on page load. Export for variant main.js to call. */
354
- export function restoreSkin() {
355
- const skinId = storage.getItem(KEYS.ACTIVE_SKIN) || 'default';
356
- if (skinId && skinId !== 'default') {
357
- loadSkinStylesheet(skinId);
358
- }
359
- }
360
-
361
- // Listen for cross-tab skin changes via WebSocket
362
- on('sync:skin:changed', (msg) => {
363
- const id = msg?.id || 'default';
364
- if (id === 'default') removeSkinStylesheet();
365
- else loadSkinStylesheet(id);
366
- // Update settings panel if open
367
- const panel = document.getElementById('settings-panel');
368
- if (panel) refreshSkinsTab(panel);
369
- });
370
173
 
371
174
  // ═══════════════════════════════════════════
372
175
  // SKINS TAB — builder + interaction
@@ -762,7 +565,6 @@ function buildServerTab(settings, connections = []) {
762
565
  function buildBrowserTab(ownerAccess = null) {
763
566
  const b = (key) => kit.te(`settings.redesign.browser.${key}`);
764
567
  const SEARCH = '<svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>';
765
- const REFRESH = '<svg viewBox="0 0 24 24" aria-hidden="true"><polyline points="23 4 23 10 17 10"/><polyline points="1 20 1 14 7 14"/><path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"/></svg>';
766
568
  const FOLDER = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z"/></svg>';
767
569
 
768
570
  // The app's custom select, wired by the browser pane itself (.bc-dropdown). `name` picks the option labels.
@@ -818,7 +620,13 @@ function buildBrowserTab(ownerAccess = null) {
818
620
  ${kit.card({
819
621
  id: 'setup-browser', section: 'browser.browser_choice',
820
622
  body: `
821
- ${kit.field('BRW003', `<div class="bc-inline-group">${dd('BRW003', 'bc-browser', 'browser', ['auto', 'chrome', 'msedge', 'chromium', 'morelogin', 'custom'], { attrs: 'id="bc-browser-dropdown"' })}<input type="hidden" id="bc-channel" value=""></div>`)}
623
+ <div class="stg-field" id="bc-ai-browser-row" style="display:none">
624
+ <div class="stg-action-row" style="align-items:center;flex-wrap:wrap;gap:8px">
625
+ <span class="stg-inline-status" id="bc-ai-browser-text" role="status" aria-live="polite"></span>
626
+ <button type="button" class="stg-action-btn compact" id="bc-ai-browser-open">${b('aiBrowser.open')}</button>
627
+ </div>
628
+ </div>
629
+ ${kit.field('BRW003', `<div class="bc-inline-group">${dd('BRW003', 'bc-browser', 'browser', ['auto', 'chrome', 'msedge', 'chromium', 'custom'], { attrs: 'id="bc-browser-dropdown"' })}<input type="hidden" id="bc-channel" value=""></div>`)}
822
630
  <div class="stg-field bc-card-row" id="bcg-executable" ${kit.inv('BRW001')}>
823
631
  <label for="bc-executablePath">${kit.L('BRW001')}</label>
824
632
  <div class="browser-cfg-input-row">
@@ -846,19 +654,10 @@ function buildBrowserTab(ownerAccess = null) {
846
654
  id: 'bcg-profiles', section: 'browser.browser_profiles',
847
655
  body: `
848
656
  <input type="hidden" id="bc-userDataDir" value="">
849
- ${kit.field('BRW011', dd('BRW011', 'bc-connectMode', 'connect', ['mirror', 'attach', 'morelogin']))}
657
+ ${kit.field('BRW011', `${dd('BRW011', 'bc-connectMode', 'connect', ['mirror', 'attach', 'extension'])}
658
+ <div class="stg-help" id="bc-connectMode-ai-note" style="display:none">${b('aiBrowser.connectionNote')}</div>`)}
659
+ ${extensionSettingsHTML(kit)}
850
660
  ${kit.field('BRW012', dd('BRW012', 'bc-attachSeed', 'seed', ['real', 'fresh']), { attrs: 'id="bc-attachSeed-row" style="display:none"' })}
851
- <div class="stg-field bc-card-row" id="bc-morelogin-row" ${kit.inv('BRW013')} style="display:none">
852
- <label id="bc-morelogin-env-id-label" for="bc-morelogin-env-id-trigger">${kit.L('BRW013')}</label>
853
- <div class="browser-cfg-input-row">
854
- ${dropdownHTML('bc-morelogin-env-id', [{ value: '', label: kit.tx('settings.redesign.browser.loadingProfiles') }], { classes: 'bc-ml-dropdown', labelledBy: 'bc-morelogin-env-id-label', attrs: 'style="flex:1;min-width:0"' }).replace('role="combobox"', 'role="combobox" aria-describedby="bc-morelogin-env-id-help"')}
855
- <button type="button" class="cli-detect-btn" id="bc-morelogin-refresh" ${kit.inv('BRW014')} title="${kit.H('BRW014')}">${REFRESH}${kit.L('BRW014')}</button>
856
- </div>
857
- <div class="stg-help" id="bc-morelogin-env-id-help">${kit.H('BRW013')}</div>
858
- </div>
859
- <div class="stg-field" id="bc-morelogin-status-row" style="display:none">
860
- <span class="bc-hint-inline stg-help" id="bc-morelogin-status-text" role="status" aria-live="polite"></span>
861
- </div>
862
661
  <div class="stg-field bc-card-row" ${kit.inv('BRW083')}>
863
662
  <label id="bc-profile-list-label">${kit.L('BRW083')}</label>
864
663
  <div class="browser-cfg-input-row">
@@ -1194,6 +993,7 @@ function buildTerminalTab(cliConfig) {
1194
993
  ${kit.help('CLI002', { forId: 'cli-paths-detect' })}
1195
994
  ${cliProfiles.map(pathRow).join('')}
1196
995
  ${gitBashRowHtml()}
996
+ ${opencodeVerifyRowHtml()}
1197
997
  <button type="button" class="stg-action-btn stg-save-btn" id="cli-paths-save" ${kit.inv('CLI006')} aria-describedby="cli-paths-save-help">
1198
998
  ${kit.L('CLI006')}
1199
999
  </button>
@@ -1756,7 +1556,7 @@ function buildSkillsTab(ccSkills) {
1756
1556
  </div>`;
1757
1557
  }
1758
1558
 
1759
- function buildPermissionsTab(toolCategories, toolPermissions) {
1559
+ function buildPermissionsTab(toolCategories, toolPermissions, capabilities = []) {
1760
1560
  const categories = (toolCategories || []).filter(c => c.id !== 'social');
1761
1561
  const perms = toolPermissions || {};
1762
1562
  // The inventory ids of the "all tools of this group" switches, by group.
@@ -1773,6 +1573,12 @@ function buildPermissionsTab(toolCategories, toolPermissions) {
1773
1573
  return { ...cat, onCount };
1774
1574
  });
1775
1575
  const allOn = !!totalAll && totalOn === totalAll;
1576
+ // The switch for every tool of the section, next to the total (settings/settings-tool-permissions.js): on, off
1577
+ // or mixed. `data-bulk`: this server takes all the groups in one request.
1578
+ const master = masterView(countTools(categories, perms), { tx: kit.tx });
1579
+ const masterHTML = !master.shown ? '' : `<button type="button" class="cc-tools-master" id="cc-tools-master" ${kit.inv('PER013')} role="checkbox" aria-checked="${master.checked}" data-state="${master.state}"${(capabilities || []).includes('categories') ? ' data-bulk="1"' : ''} title="${kit.esc(master.title)}">
1580
+ <span class="cc-tools-master-label">${kit.L('PER013')}</span><span class="cc-tools-master-switch" aria-hidden="true"></span>
1581
+ </button>`;
1776
1582
 
1777
1583
  const categoryHTML = catData.map(cat => {
1778
1584
  const catAllOn = cat.onCount === cat.tools.length;
@@ -1794,7 +1600,7 @@ function buildPermissionsTab(toolCategories, toolPermissions) {
1794
1600
  <div class="stg-pane" data-stg-pane="permissions">
1795
1601
  ${kit.card({
1796
1602
  id: 'stg-sec-tool-permissions', section: 'tool_access.tool_permissions',
1797
- status: `<span class="cc-hooks-badge${allOn ? ' all-on' : ''}" id="cc-tools-badge" title="${kit.te('settings.redesign.permissions.badge')}">${totalOn}/${totalAll}</span>`,
1603
+ status: `<span class="cc-hooks-badge${allOn ? ' all-on' : ''}" id="cc-tools-badge" title="${kit.te('settings.redesign.permissions.badge')}">${totalOn}/${totalAll}</span>${masterHTML}`,
1798
1604
  body: categories.length
1799
1605
  ? `<div ${kit.inv('PER012')} role="group" aria-label="${kit.L('PER012')}">${categoryHTML}</div>`
1800
1606
  : `<div class="stg-help" style="margin-top:0">${kit.te('settings.redesign.permissions.none')}</div>`,
@@ -2518,10 +2324,33 @@ function buildMoreLoginTab() {
2518
2324
  const text = (id, { ph = '', type = 'text' } = {}) =>
2519
2325
  `<input type="${type}" id="${id}" value=""${ph ? ` placeholder="${ph}"` : ''} autocomplete="off" spellcheck="false" aria-describedby="${id}-help">`;
2520
2326
  const btn = (invId, id) => `<button type="button" class="stg-action-btn compact" id="${id}" ${kit.inv(invId)} title="${kit.H(invId)}">${kit.L(invId)}</button>`;
2327
+ const REFRESH = '<svg viewBox="0 0 24 24" aria-hidden="true"><polyline points="23 4 23 10 17 10"/><polyline points="1 20 1 14 7 14"/><path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"/></svg>';
2521
2328
 
2522
2329
  return `
2523
2330
  <div class="stg-pane" data-stg-pane="morelogin">
2524
2331
 
2332
+ ${kit.card({
2333
+ // Everything about choosing a profile as the AI browser (settings-ai-browser.js). The Browser tab only says so.
2334
+ // The picker is driven by cc-dropdown.js alone (wireMoreLoginTab): never `.stg-dropdown`, which the panel's older
2335
+ // per-element wiring (wireStgDropdowns) also takes, and a second click handler closes it as it opens.
2336
+ id: 'stg-sec-ml-default', section: 'connected_tools.morelogin_default',
2337
+ status: kit.pill(m('aiBrowser.stateOff'), { id: 'ml-ai-state', state: 'off' }),
2338
+ body: `
2339
+ ${kit.toggleField('ML037', kit.switchInput('ml-ai-on'), { forId: 'ml-ai-on' })}
2340
+ <div class="stg-field bc-card-row" id="ml-ai-profile-row" ${kit.inv('ML038')}>
2341
+ <label id="ml-ai-env-id-label" for="ml-ai-env-id-trigger">${kit.L('ML038')}</label>
2342
+ <div class="browser-cfg-input-row">
2343
+ ${dropdownHTML('ml-ai-env-id', [{ value: '', label: kit.tx('settings.redesign.morelogin.aiBrowser.loadingProfiles') }], { classes: 'bc-ml-dropdown', labelledBy: 'ml-ai-env-id-label', attrs: 'style="flex:1;min-width:0"' }).replace('role="combobox"', 'role="combobox" aria-describedby="ml-ai-env-id-help"')}
2344
+ <button type="button" class="cli-detect-btn" id="ml-ai-refresh" ${kit.inv('ML039')} title="${kit.H('ML039')}">${REFRESH}${kit.L('ML039')}</button>
2345
+ </div>
2346
+ <div class="stg-help" id="ml-ai-env-id-help">${kit.H('ML038')}</div>
2347
+ </div>
2348
+ <div class="stg-field">
2349
+ <div class="stg-inline-status" id="ml-ai-line" role="status" aria-live="polite">${m('aiBrowser.line.off')}</div>
2350
+ <span class="bc-hint-inline stg-help" id="ml-ai-status-text" role="status" aria-live="polite"></span>
2351
+ </div>`,
2352
+ })}
2353
+
2525
2354
  ${kit.card({
2526
2355
  id: 'stg-sec-ml-connection', section: 'connected_tools.morelogin_connection',
2527
2356
  status: `<span id="ml-conn-status">…</span>`,
@@ -2624,6 +2453,7 @@ function wireMoreLoginTab(overlay, signal) {
2624
2453
  { value: 'morelogin', label: kit.tx('settings.redesign.morelogin.local.whereMoreLogin'), selected: true },
2625
2454
  ], { classes: 'stg-dropdown', label: kit.tx('settings.redesign.control.ml020.label') }); }
2626
2455
  { const card = $('stg-sec-ml-profiles'); if (card) wireDropdowns(card, { signal }); }
2456
+ { const card = $('stg-sec-ml-default'); if (card) wireDropdowns(card, { signal }); }
2627
2457
  $('ml-create-where')?.addEventListener('change', () => { _whereTouched = true; });
2628
2458
  // "Where" follows what MoreLogin can do until the owner picks: Local while MoreLogin is closed, refusing or full.
2629
2459
  function syncCreateWhere() {
@@ -2655,15 +2485,18 @@ function wireMoreLoginTab(overlay, signal) {
2655
2485
  else { dot.className = 'settings-status-dot connected'; line.textContent = kit.tx('settings.redesign.morelogin.connectedProfileSPort', { profileCount: s.profileCount, port: s.port }); if (conn) conn.textContent = kit.tx('settings.redesign.morelogin.connected'); }
2656
2486
  const hint = $('ml-path-hint');
2657
2487
  if (hint) hint.hidden = !!(s.installed && s.running);
2658
- _defaultEnvId = s.defaultEnvId || null;
2488
+ // A row is marked as the default only while a profile is the AI browser (a leftover id of a switched-off one is not).
2489
+ _defaultEnvId = s.isDefault ? (s.defaultEnvId || null) : null;
2659
2490
  _status = s;
2660
2491
  const ds = $('ml-default-status');
2661
2492
  if (ds) ds.textContent = (s.isDefault && s.defaultEnvId) ? kit.tx('settings.redesign.morelogin.defaultAiBrowserSet') : kit.tx('settings.redesign.morelogin.noDefaultSet');
2493
+ noteAi(aiBrowserOfStatus(s));
2662
2494
  }
2663
2495
 
2664
2496
  // `agentProfiles`: the owner's list of profiles agents may choose (GET /api/morelogin/profiles). A server from
2665
2497
  // before that list sends none: the switches are then left out and the pane says a restart is missing.
2666
- function renderProfiles(envs, agentProfiles) {
2498
+ function renderProfiles(envs, agentProfiles, staleProfiles = []) {
2499
+ envs = [...(envs || []), ...staleProfiles.map(p => ({ id: p.envId, name: p.name || p.envId, stale: true }))];
2667
2500
  const list = $('ml-profile-list');
2668
2501
  if (!list) return;
2669
2502
  // The open editor's typed values outlive a redraw of the list (a Start, a switch, the quiet ask again).
@@ -2678,6 +2511,9 @@ function wireMoreLoginTab(overlay, signal) {
2678
2511
  list.innerHTML = missing + envs.map(e => {
2679
2512
  const id = escapeHtml(String(e.id));
2680
2513
  const isDefault = String(e.id) === String(_defaultEnvId);
2514
+ if (e.stale) return `<div data-ml-stale="${id}" class="settings-hint"><span>${escapeHtml(kit.tx('settings.redesign.morelogin.staleProfile', { name: e.name, id: String(e.id) }))}</span>
2515
+ ${isDefault ? `<span>${kit.te('settings.redesign.morelogin.staleDefault')}</span>` : ''}
2516
+ ${allowed.has(String(e.id)) ? `<button type="button" class="conn-add-btn ml-remove-stale" data-env-id="${id}">${kit.te('settings.redesign.morelogin.removeStale')}</button>` : ''}</div>`;
2681
2517
  // SynaBun drives a profile over CDP: a Firefox-type one (`browser` from the server; absent = not known) cannot
2682
2518
  // be the AI browser, so "Use as default" is not offered for it. Start and Stop stay for either kind.
2683
2519
  const firefox = e.browser === 'firefox';
@@ -2716,10 +2552,16 @@ function wireMoreLoginTab(overlay, signal) {
2716
2552
  if (r && r.ok) showCCToast(kit.tx(want ? 'settings.redesign.morelogin.agentsMayChooseOn' : 'settings.redesign.morelogin.agentsMayChooseOff', { name }));
2717
2553
  else { box.checked = !want; showCCToast(kit.tx('settings.redesign.morelogin.agentsMayChooseFailed', { error: (r && r.error) || kit.tx('settings.redesign.morelogin.failed') })); }
2718
2554
  }));
2555
+ list.querySelectorAll('.ml-remove-stale').forEach(b => b.addEventListener('click', async () => {
2556
+ b.disabled = true;
2557
+ const r = await jsend('PUT', '/api/morelogin/agent-profiles', { envId: b.dataset.envId, allowed: false });
2558
+ if (!r.ok) { showCCToast(r.error || kit.tx('settings.redesign.morelogin.failed')); b.disabled = false; }
2559
+ else await reload();
2560
+ }));
2561
+ // The same request as the Default AI browser card's: the card follows (useDefault), without a reload of the page.
2719
2562
  list.querySelectorAll('.ml-use').forEach(b => b.addEventListener('click', async () => {
2720
- const r = await jpost('/api/morelogin/use-default', { envId: b.dataset.envId });
2721
- showCCToast(r.ok ? kit.tx('settings.redesign.morelogin.moreloginSetAsDefaultAiBrowser') : (r.error || kit.tx('settings.redesign.morelogin.failed')));
2722
- reload();
2563
+ b.disabled = true;
2564
+ await useDefault({ envId: b.dataset.envId });
2723
2565
  }));
2724
2566
  list.querySelectorAll('.ml-start').forEach(b => b.addEventListener('click', async () => {
2725
2567
  b.disabled = true; const t = b.textContent; b.textContent = kit.tx('settings.redesign.morelogin.starting');
@@ -2884,6 +2726,7 @@ function wireMoreLoginTab(overlay, signal) {
2884
2726
  const s = await jget('/api/morelogin/status');
2885
2727
  // No owner access (SynaBun's automation browser opened this page): "No access", never "not installed" or defaults.
2886
2728
  if (markPaneRefused(overlay, 'morelogin', refusalOfError({ status: s._status, code: s.code }))) {
2729
+ _refused = true;
2887
2730
  const dot = $('ml-status-dot'), line = $('ml-status-line');
2888
2731
  if (dot) dot.className = 'settings-status-dot disconnected';
2889
2732
  if (line) line.textContent = ownerAccessSay('panelTitle');
@@ -2912,7 +2755,9 @@ function wireMoreLoginTab(overlay, signal) {
2912
2755
  if (d && d.ok && Array.isArray(d.profiles)) _localDetails = new Map(d.profiles.map(row => [String(row.id), row]));
2913
2756
  } else _localDetails = new Map();
2914
2757
  _moreloginError = p.moreloginError || '';
2915
- renderProfiles(p.envs || [], p.agentProfiles);
2758
+ _profileRows = p.envs || [];
2759
+ renderProfiles(p.envs || [], p.agentProfiles, p.moreloginError ? [] : p.staleProfiles || []);
2760
+ drawAiBrowser();
2916
2761
  // The server is still asking MoreLogin which browser some profiles run: ask again quietly, a few times.
2917
2762
  clearTimeout(_browsersTimer);
2918
2763
  if (Number(p.browsersPending) > 0 && _browsersTries < 8 && $('ml-profile-list')?.isConnected) {
@@ -2923,6 +2768,184 @@ function wireMoreLoginTab(overlay, signal) {
2923
2768
  let _browsersTimer = null;
2924
2769
  let _browsersTries = 0;
2925
2770
 
2771
+ // ── Default AI browser: a MoreLogin or SynaBun local profile as the browser of SynaBun's web tasks ──
2772
+ // The only place that turns it on or off (settings-ai-browser.js). The switch and a new pick save at once through
2773
+ // POST /api/morelogin/use-default, as a row's "Use as default" does: one request, one state (_ai), drawn in the card,
2774
+ // the list's default mark and, through AI_BROWSER_EVENT on the overlay, the Browser tab's line.
2775
+ let _ai = { moreLogin: false, envId: null }; // what the server holds
2776
+ let _aiWanted = ''; // the picker's profile: the AI browser's, or the owner's pick while it is off
2777
+ let _aiEnvs = []; // the picker's rows (GET /api/browser/morelogin-envs)
2778
+ let _profileRows = []; // the list's rows (GET /api/morelogin/profiles): names while the picker has none
2779
+ let _refused = false; // no owner access: nothing more is asked
2780
+ let _aiBrowsersTimer = null;
2781
+ let _aiBrowsersTries = 0;
2782
+ // keepShown: a redraw of the list (the quiet ask again, a change of the choice) keeps what the picker shows;
2783
+ // without it the AI browser's profile is put back, as on open and on Refresh.
2784
+ async function loadMoreLoginEnvs(keepShown = false) {
2785
+ const sel = $('ml-ai-env-id');
2786
+ // A placeholder choice (loading / error / not running) keeps its reason visible in the closed dropdown.
2787
+ const only = (key) => setDropdownItems(sel, [{ value: '', label: kit.tx(key), selected: true }]);
2788
+ const statusEl = $('ml-ai-status-text');
2789
+ if (!sel) return;
2790
+ try {
2791
+ const r = await fetch('/api/browser/morelogin-envs');
2792
+ const d = await r.json();
2793
+ // SynaBun's own local profiles (`kind: 'local'`) are in every answer, whatever MoreLogin does: with one or
2794
+ // more, the picker lists them and the line under it says why MoreLogin's are missing.
2795
+ const localEnvs = (d && Array.isArray(d.envs) ? d.envs : []).filter(e => e && e.kind === 'local');
2796
+ // MoreLogin refused a start for its plan's daily limit: SynaBun asks it for no start of that profile until
2797
+ // MoreLogin's day resets (lib/morelogin-start-cooldown.js). Said per profile, with the reset in local time, on
2798
+ // every line below: the hold stays while MoreLogin is closed, and opening it does not end the hold.
2799
+ const limits = startLimitNotes(d && d.startCooldowns, d && d.envs, { locale: getLocale() });
2800
+ const limitText = (limits.length
2801
+ ? ' · ⚠ ' + limits.map(n => kit.tx('settings.redesign.morelogin.aiBrowser.moreloginStartLimitReached', { name: n.name, time: n.time })).join(' · ⚠ ')
2802
+ : '')
2803
+ // A profile closed outside SynaBun: no session, run, agent or script starts it again until the owner does (in
2804
+ // MoreLogin, or Start here) or its next scheduled run (lib/morelogin-outside-close.js). Said the same way.
2805
+ + closedOutsideNotes(d && d.closedOutside, d && d.envs, { locale: getLocale() })
2806
+ .map(n => ' · ⚠ ' + kit.tx('settings.redesign.morelogin.aiBrowser.moreloginClosedOutside', { name: n.name, time: n.time })).join('');
2807
+ let moreloginNote = '';
2808
+ // With a local profile to list, MoreLogin's state is a note under the picker; without one it is the picker's
2809
+ // only choice, as before. → true when the picker was filled with the reason (nothing more to draw).
2810
+ const without = (message, placeholder) => {
2811
+ if (localEnvs.length) { moreloginNote = message; return false; }
2812
+ placeholder();
2813
+ _aiEnvs = [];
2814
+ if (statusEl) {
2815
+ statusEl.textContent = message + limitText;
2816
+ if (limitText) statusEl.style.color = 'var(--stg-warn)';
2817
+ }
2818
+ return true;
2819
+ };
2820
+ if (!d || d.ok === false) { if (without((d && d.error) || kit.tx('settings.redesign.morelogin.aiBrowser.failedToLoadMoreloginProfiles'), () => only('settings.redesign.morelogin.aiBrowser.error'))) return; }
2821
+ else if (!d.installed) { if (without(kit.tx('settings.redesign.morelogin.aiBrowser.moreloginDesktopAppIsNotInstalled') + ' ' + kit.tx('settings.redesign.morelogin.aiBrowser.moreloginCustomPathHint'), () => only('settings.redesign.morelogin.aiBrowser.moreloginNotInstalled'))) return; }
2822
+ else if (!d.running) { if (without(kit.tx('settings.redesign.morelogin.aiBrowser.moreloginNotRunningOpenTheApp', { port: d.port }) + (d.error ? ' ' + String(d.error) : ''), () => only('settings.redesign.morelogin.aiBrowser.startMorelogin'))) return; }
2823
+ const envs = moreloginNote ? localEnvs : (d.envs || []);
2824
+ _aiEnvs = envs;
2825
+ if (!envs.length) { only('settings.redesign.morelogin.aiBrowser.noProfiles'); if (statusEl) statusEl.textContent = kit.tx('settings.redesign.morelogin.aiBrowser.noMoreloginProfilesYetOneIs'); drawAiBrowser(); return; }
2826
+ const want = (keepShown === true && sel.value) || _aiWanted || sel.value || '';
2827
+ // Show each env's proxy — without it there is no way to tell from SynaBun
2828
+ // whether a profile's traffic leaves the machine.
2829
+ const proxyLabel = (p) => {
2830
+ if (!p) return '';
2831
+ const where = [p.host, p.port].filter(Boolean).join(':');
2832
+ return ` · ${[p.type, where, p.country].filter(Boolean).join(' ')}`;
2833
+ };
2834
+ // SynaBun drives the profile over CDP, so a Firefox-type one (`browser` from the server; absent = not known)
2835
+ // is listed, said as such and cannot be picked. One already saved as the default stays shown, with a warning.
2836
+ // dropdownHTML escapes the labels itself.
2837
+ setDropdownItems(sel, envs.map(e => (e.browser === 'firefox'
2838
+ ? { value: String(e.id), label: kit.tx('settings.redesign.morelogin.aiBrowser.moreloginFirefoxOption', { name: String(e.name ?? e.id) }), disabled: true }
2839
+ : { value: String(e.id), label: `${e.kind === 'local' ? kit.tx('settings.redesign.morelogin.aiBrowser.moreloginLocalOption', { name: String(e.name ?? e.id) }) : (e.name ?? '')}${e.status ? ` (${String(e.status)})` : ''}${proxyLabel(e.proxy)}` })));
2840
+ if (want && envs.some(e => String(e.id) === String(want))) setDropdownValue(sel, String(want));
2841
+ const chosenFirefox = envs.some(e => String(e.id) === String(sel.value) && e.browser === 'firefox');
2842
+ if (statusEl) statusEl.style.color = chosenFirefox ? 'var(--stg-warn)' : '';
2843
+ // The server is still asking MoreLogin which browser some profiles run: ask again quietly, a few times.
2844
+ clearTimeout(_aiBrowsersTimer);
2845
+ if (Number(d.browsersPending) > 0 && _aiBrowsersTries < 8 && sel.isConnected) {
2846
+ _aiBrowsersTries += 1;
2847
+ _aiBrowsersTimer = setTimeout(() => loadMoreLoginEnvs(true), 2500);
2848
+ } else _aiBrowsersTries = 0;
2849
+ if (statusEl) {
2850
+ let msg = chosenFirefox
2851
+ ? kit.tx('settings.redesign.morelogin.aiBrowser.moreloginFirefoxDefault')
2852
+ : (moreloginNote
2853
+ ? kit.tx('settings.redesign.morelogin.aiBrowser.localProfilesOnly', { count: envs.length }) + ' ' + moreloginNote
2854
+ : kit.tx('settings.redesign.morelogin.aiBrowser.profileSApiPort', { count: envs.length, port: d.port }));
2855
+ // MoreLogin silently redirects a navigation it refuses to its stop page: a
2856
+ // localhost port missing from the profile's Port scan protection list, or a
2857
+ // host its website blacklist/whitelist refuses. Surface it; nothing else in
2858
+ // the UI can explain it.
2859
+ if (d.blockedNavigations > 0) {
2860
+ msg += (" " + kit.tx('settings.redesign.morelogin.aiBrowser.moreloginBlockedNavigationS', { blockedNavigations: d.blockedNavigations }));
2861
+ if (d.lastBlockedUrl) msg += kit.tx('settings.redesign.morelogin.aiBrowser.mostRecently', { lastBlockedUrl: String(d.lastBlockedUrl).slice(0, 80) });
2862
+ msg += kit.tx('settings.redesign.morelogin.aiBrowser.aLocalhostPortMustBeIn');
2863
+ }
2864
+ // The plan's daily start limit (limitText, above).
2865
+ if (limitText) {
2866
+ msg += limitText;
2867
+ statusEl.style.color = 'var(--stg-warn)';
2868
+ }
2869
+ statusEl.textContent = msg;
2870
+ }
2871
+ drawAiBrowser();
2872
+ } catch {
2873
+ only('settings.redesign.morelogin.aiBrowser.error');
2874
+ _aiEnvs = [];
2875
+ if (statusEl) statusEl.textContent = kit.tx('settings.redesign.morelogin.aiBrowser.failedToReachMorelogin');
2876
+ }
2877
+ }
2878
+ /** The listed profile with this id: the picker's rows first, then the list's. */
2879
+ const aiProfile = (envId) => profileOf(_aiEnvs, envId) || profileOf(_profileRows, envId);
2880
+ /** The card as _ai says, and the news for the Browser tab (it keeps the last one on the overlay, for a late reader). */
2881
+ function drawAiBrowser() {
2882
+ const box = $('ml-ai-on');
2883
+ if (box) box.checked = _ai.moreLogin;
2884
+ const profile = aiProfile(_ai.envId);
2885
+ const line = aiBrowserLine(_ai, profile);
2886
+ const text = $('ml-ai-line');
2887
+ if (text) text.textContent = kit.tx(`settings.redesign.morelogin.aiBrowser.line.${line.key}`, line.params);
2888
+ const pill = $('ml-ai-state');
2889
+ if (pill) {
2890
+ pill.textContent = kit.tx(_ai.moreLogin ? 'settings.redesign.morelogin.aiBrowser.stateOn' : 'settings.redesign.morelogin.aiBrowser.stateOff');
2891
+ pill.dataset.state = _ai.moreLogin ? 'ok' : 'off';
2892
+ }
2893
+ const detail = aiBrowserDetail(_ai, profile);
2894
+ overlay._stgAiBrowser = detail;
2895
+ overlay.dispatchEvent(new CustomEvent(AI_BROWSER_EVENT, { detail }));
2896
+ }
2897
+ /** What the server holds now (GET /api/morelogin/status, a use-default answer). The picker follows the AI browser's
2898
+ * profile; while it is off, a profile the owner picked by hand stays picked. */
2899
+ function noteAi(state) {
2900
+ _ai = { moreLogin: state.moreLogin === true, envId: state.envId || null };
2901
+ if (_ai.envId && (_ai.moreLogin || !_aiWanted)) {
2902
+ _aiWanted = _ai.envId;
2903
+ const sel = $('ml-ai-env-id');
2904
+ if (sel && _aiEnvs.some(e => String(e.id) === _ai.envId)) setDropdownValue(sel, _ai.envId);
2905
+ }
2906
+ drawAiBrowser();
2907
+ }
2908
+ /** POST /api/morelogin/use-default: `{ envId }` makes it the AI browser, `{ clear: true }` goes back to SynaBun's own
2909
+ * browser (connect mode 'mirror'). A refusal leaves everything as the server holds it, and says why. */
2910
+ async function useDefault(body) {
2911
+ const box = $('ml-ai-on');
2912
+ if (box) box.disabled = true;
2913
+ const r = await jpost('/api/morelogin/use-default', body);
2914
+ if (box) box.disabled = false;
2915
+ if (r && r.ok) {
2916
+ noteAi(aiBrowserOf(r));
2917
+ showCCToast(kit.tx(body.clear ? 'settings.redesign.morelogin.aiBrowser.offToast' : 'settings.redesign.morelogin.moreloginSetAsDefaultAiBrowser'));
2918
+ } else {
2919
+ showCCToast(kit.tx('settings.redesign.morelogin.aiBrowser.changeFailed', { error: (r && r.error) || kit.tx('settings.redesign.morelogin.failed') }));
2920
+ drawAiBrowser();
2921
+ }
2922
+ await reload();
2923
+ loadMoreLoginEnvs();
2924
+ return !!(r && r.ok);
2925
+ }
2926
+ $('ml-ai-on')?.addEventListener('change', async () => {
2927
+ const box = $('ml-ai-on');
2928
+ // What the picker shows, nothing else: a profile remembered from before but not listed now is not offered.
2929
+ const chosen = $('ml-ai-env-id')?.value || '';
2930
+ const ask = switchRequest({ on: box.checked, chosen, firefox: aiProfile(chosen)?.browser === 'firefox' });
2931
+ if (ask.refuse) {
2932
+ box.checked = _ai.moreLogin;
2933
+ showCCToast(kit.tx(`settings.redesign.morelogin.aiBrowser.${ask.refuse}`));
2934
+ return;
2935
+ }
2936
+ await useDefault(ask.body);
2937
+ }, { signal });
2938
+ // Another profile chosen: saved at once while a profile is the AI browser; the line under the picker says what
2939
+ // holds for that one (the Firefox warning goes).
2940
+ $('ml-ai-env-id')?.addEventListener('change', async () => {
2941
+ const chosen = $('ml-ai-env-id').value;
2942
+ _aiWanted = chosen;
2943
+ const ask = pickRequest({ on: _ai.moreLogin, chosen, current: _ai, firefox: aiProfile(chosen)?.browser === 'firefox' });
2944
+ if (ask) { await useDefault(ask.body); return; }
2945
+ loadMoreLoginEnvs(true);
2946
+ }, { signal });
2947
+ $('ml-ai-refresh')?.addEventListener('click', (e) => { e.preventDefault(); loadMoreLoginEnvs(); }, { signal });
2948
+
2926
2949
  const saveCfg = (key, value) => fetch('/api/morelogin/config', { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ key, value }) });
2927
2950
 
2928
2951
  $('ml-port-save')?.addEventListener('click', async () => { await saveCfg('port', ($('ml-port').value || '').trim()); showCCToast(kit.tx('settings.redesign.morelogin.portSaved')); reload(); });
@@ -2998,7 +3021,7 @@ function wireMoreLoginTab(overlay, signal) {
2998
3021
  if (res) { res.style.display = 'block'; res.textContent = r.ok ? kit.tx('settings.redesign.morelogin.removedFrom', { targets: (r.targets || []).join(', ') || kit.tx('settings.redesign.morelogin.none') }) : (r.error || kit.tx('settings.redesign.morelogin.failed')); res.style.background = 'var(--s-darker)'; res.style.color = 'var(--t-secondary)'; }
2999
3022
  });
3000
3023
 
3001
- reload();
3024
+ reload().then(() => { if (!_refused) loadMoreLoginEnvs(); });
3002
3025
  }
3003
3026
 
3004
3027
  function buildDiscordTab(discordConfig) {
@@ -3693,6 +3716,7 @@ async function openSettingsModalNow(options = {}) {
3693
3716
  let setupStatus = { claude: {}, antigravity: {}, codex: {}, opencode: {}, paths: {} };
3694
3717
  let cliConfig = {};
3695
3718
  let toolPermissions = {};
3719
+ let toolPermissionCaps = [];
3696
3720
  let toolCategories = [];
3697
3721
  let discordConfig = {};
3698
3722
  let skinsData = { skins: [], active: 'default' };
@@ -3746,7 +3770,10 @@ async function openSettingsModalNow(options = {}) {
3746
3770
  if (greetRes.status === 'fulfilled') greetingReading = greetRes.value;
3747
3771
  if (setupRes.status === 'fulfilled' && setupRes.value.ok) setupStatus = setupRes.value;
3748
3772
  if (cliRes.status === 'fulfilled' && cliRes.value.ok) cliConfig = cliRes.value.config;
3749
- if (toolPermsRes.status === 'fulfilled' && toolPermsRes.value.ok) toolPermissions = toolPermsRes.value.tools;
3773
+ if (toolPermsRes.status === 'fulfilled' && toolPermsRes.value.ok) {
3774
+ toolPermissions = toolPermsRes.value.tools;
3775
+ toolPermissionCaps = Array.isArray(toolPermsRes.value.capabilities) ? toolPermsRes.value.capabilities : [];
3776
+ }
3750
3777
  if (toolCatsRes.status === 'fulfilled' && toolCatsRes.value.ok) toolCategories = toolCatsRes.value.categories;
3751
3778
  if (discordRes.status === 'fulfilled' && discordRes.value.ok) discordConfig = discordRes.value.config;
3752
3779
  if (skinsRes.status === 'fulfilled' && skinsRes.value.ok) skinsData = skinsRes.value;
@@ -3822,7 +3849,7 @@ async function openSettingsModalNow(options = {}) {
3822
3849
  discord: buildDiscordTab(discordConfig),
3823
3850
  whatsapp: buildWhatsAppTab(),
3824
3851
  morelogin: buildMoreLoginTab(),
3825
- permissions: buildPermissionsTab(toolCategories, toolPermissions),
3852
+ permissions: buildPermissionsTab(toolCategories, toolPermissions, toolPermissionCaps),
3826
3853
  editor: buildCodeEditorTab(),
3827
3854
  social: buildSocialTab(toolCategories, toolPermissions),
3828
3855
  youtube: buildYoutubeTab(youtubeConfig),
@@ -5107,6 +5134,7 @@ async function openSettingsModalNow(options = {}) {
5107
5134
  });
5108
5135
  // Windows: the Git Bash every Claude Code SynaBun starts gets (ui-git-bash.js; hidden on macOS and Linux).
5109
5136
  wireGitBashRow(overlay.querySelector('#cli-git-bash'));
5137
+ wireOpencodeVerifyRow(overlay.querySelector('#cli-opencode-verify'));
5110
5138
  overlay.querySelector('#cli-path-diagnostics')?.addEventListener('click', async () => {
5111
5139
  try {
5112
5140
  const response = await fetch('/api/cli/path');
@@ -5723,6 +5751,14 @@ async function openSettingsModalNow(options = {}) {
5723
5751
  badge.textContent = `${totalOn}/${totalAll}`;
5724
5752
  badge.classList.toggle('all-on', totalOn === totalAll);
5725
5753
  }
5754
+ // The switch for every tool: on, off or mixed, from the same count as the total next to it.
5755
+ const master = overlay.querySelector('#cc-tools-master');
5756
+ if (master) {
5757
+ const view = masterView({ on: totalOn, total: totalAll }, { tx: kit.tx });
5758
+ master.dataset.state = view.state;
5759
+ master.setAttribute('aria-checked', view.checked);
5760
+ master.title = view.title;
5761
+ }
5726
5762
  }
5727
5763
 
5728
5764
  function applyToolPermissionResult(tools) {
@@ -5771,6 +5807,34 @@ async function openSettingsModalNow(options = {}) {
5771
5807
  });
5772
5808
  });
5773
5809
 
5810
+ // The switch for every tool of the section (its header, next to the total): everything on switches all off,
5811
+ // anything else switches all on. One request where the server takes the groups together, else one per group.
5812
+ {
5813
+ const master = overlay.querySelector('#cc-tools-master');
5814
+ if (master) {
5815
+ master.addEventListener('click', async (e) => {
5816
+ e.stopPropagation(); // the header it sits in opens and closes the section
5817
+ const section = master.closest('.stg-card');
5818
+ const groups = [...(section?.querySelectorAll('.cc-tool-category[data-tool-category]') || [])].map(el => el.dataset.toolCategory);
5819
+ const requests = masterRequests({
5820
+ categories: groups, enabled: master.dataset.state !== 'on',
5821
+ capabilities: master.dataset.bulk === '1' ? ['categories'] : [],
5822
+ });
5823
+ if (!requests.length) return;
5824
+ master.disabled = true;
5825
+ try {
5826
+ for (const body of requests) {
5827
+ const res = await fetch('/api/claude-code/tool-permissions', { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) });
5828
+ const data = await res.json();
5829
+ if (!data.ok) { alert(data.error || kit.tx('settings.redesign.permissions.failedToToggleAll')); break; }
5830
+ applyToolPermissionResult(data.tools);
5831
+ }
5832
+ } catch (err) { alert(kit.tx('settings.redesign.permissions.failed', { message: err.message })); }
5833
+ finally { master.disabled = false; }
5834
+ });
5835
+ }
5836
+ }
5837
+
5774
5838
  // ── User Learning threshold handler ──
5775
5839
  {
5776
5840
  const ulInput = overlay.querySelector('#cc-ul-threshold-input');
@@ -6399,25 +6463,7 @@ async function openSettingsModalNow(options = {}) {
6399
6463
  const execInput = overlay.querySelector('#bc-executablePath');
6400
6464
  const channelInput = overlay.querySelector('#bc-channel');
6401
6465
  const pathRow = overlay.querySelector('#bc-executablePath')?.closest('.bc-card-row');
6402
- const connectHidden = overlay.querySelector('#bc-connectMode');
6403
- const wasMoreLogin = connectHidden?.value === 'morelogin';
6404
6466
 
6405
- if (val === 'morelogin') {
6406
- // MoreLogin is a browser backend — mirror it into the Connection dropdown.
6407
- if (channelInput) channelInput.value = '';
6408
- if (execInput) execInput.value = '';
6409
- if (pathRow) pathRow.style.display = '';
6410
- if (connectHidden) connectHidden.value = 'morelogin';
6411
- syncBcDropdowns();
6412
- applyMoreLoginMode(true);
6413
- return;
6414
- }
6415
- // Leaving MoreLogin → revert the Connection dropdown to Mirror.
6416
- if (wasMoreLogin) {
6417
- if (connectHidden) connectHidden.value = 'mirror';
6418
- syncBcDropdowns();
6419
- applyMoreLoginMode(false);
6420
- }
6421
6467
  if (val === 'auto') {
6422
6468
  if (execInput) execInput.value = '';
6423
6469
  if (channelInput) channelInput.value = '';
@@ -6455,118 +6501,45 @@ async function openSettingsModalNow(options = {}) {
6455
6501
  })();
6456
6502
  }
6457
6503
 
6458
- // ── Connection mode (mirror / attach / MoreLogin) ──
6459
- let _moreloginDesiredEnvId = '';
6460
- let _moreloginBrowsersTimer = null;
6461
- let _moreloginBrowsersTries = 0;
6462
- // keepShown: a redraw of the list (the quiet ask again, a change of the choice) keeps what the picker shows;
6463
- // without it the saved default is put back, as on open and on Refresh.
6464
- async function loadMoreLoginEnvs(keepShown = false) {
6465
- const sel = overlay.querySelector('#bc-morelogin-env-id');
6466
- // A placeholder choice (loading / error / not running) keeps its reason visible in the closed dropdown.
6467
- const only = (key) => setDropdownItems(sel, [{ value: '', label: kit.tx(key), selected: true }]);
6468
- const statusEl = overlay.querySelector('#bc-morelogin-status-text');
6469
- if (!sel) return;
6470
- try {
6471
- const r = await fetch('/api/browser/morelogin-envs');
6472
- const d = await r.json();
6473
- // SynaBun's own local profiles (`kind: 'local'`) are in every answer, whatever MoreLogin does: with one or
6474
- // more, the picker lists them and the line under it says why MoreLogin's are missing.
6475
- const localEnvs = (d && Array.isArray(d.envs) ? d.envs : []).filter(e => e && e.kind === 'local');
6476
- let moreloginNote = '';
6477
- // With a local profile to list, MoreLogin's state is a note under the picker; without one it is the picker's
6478
- // only choice, as before. → true when the picker was filled with the reason (nothing more to draw).
6479
- const without = (message, placeholder) => {
6480
- if (localEnvs.length) { moreloginNote = message; return false; }
6481
- placeholder();
6482
- if (statusEl) statusEl.textContent = message;
6483
- return true;
6484
- };
6485
- if (!d || d.ok === false) { if (without((d && d.error) || kit.tx('settings.redesign.browser.failedToLoadMoreloginProfiles'), () => only('settings.redesign.browser.error'))) return; }
6486
- else if (!d.installed) { if (without(kit.tx('settings.redesign.browser.moreloginDesktopAppIsNotInstalled') + ' ' + kit.tx('settings.redesign.browser.moreloginCustomPathHint'), () => only('settings.redesign.browser.moreloginNotInstalled'))) return; }
6487
- else if (!d.running) { if (without(kit.tx('settings.redesign.browser.moreloginNotRunningOpenTheApp', { port: d.port }) + (d.error ? ' ' + String(d.error) : ''), () => only('settings.redesign.browser.startMorelogin'))) return; }
6488
- const envs = moreloginNote ? localEnvs : (d.envs || []);
6489
- if (!envs.length) { only('settings.redesign.browser.noProfiles'); if (statusEl) statusEl.textContent = kit.tx('settings.redesign.browser.noMoreloginProfilesYetOneIs'); return; }
6490
- const want = (keepShown === true && sel.value) || _moreloginDesiredEnvId || sel.value || '';
6491
- // Show each env's proxy — without it there is no way to tell from SynaBun
6492
- // whether a profile's traffic leaves the machine.
6493
- const proxyLabel = (p) => {
6494
- if (!p) return '';
6495
- const where = [p.host, p.port].filter(Boolean).join(':');
6496
- return ` · ${[p.type, where, p.country].filter(Boolean).join(' ')}`;
6497
- };
6498
- // SynaBun drives the profile over CDP, so a Firefox-type one (`browser` from the server; absent = not known)
6499
- // is listed, said as such and cannot be picked. One already saved as the default stays shown, with a warning.
6500
- // dropdownHTML escapes the labels itself.
6501
- setDropdownItems(sel, envs.map(e => (e.browser === 'firefox'
6502
- ? { value: String(e.id), label: kit.tx('settings.redesign.browser.moreloginFirefoxOption', { name: String(e.name ?? e.id) }), disabled: true }
6503
- : { value: String(e.id), label: `${e.kind === 'local' ? kit.tx('settings.redesign.browser.moreloginLocalOption', { name: String(e.name ?? e.id) }) : (e.name ?? '')}${e.status ? ` (${String(e.status)})` : ''}${proxyLabel(e.proxy)}` })));
6504
- if (want && envs.some(e => String(e.id) === String(want))) setDropdownValue(sel, String(want));
6505
- const chosenFirefox = envs.some(e => String(e.id) === String(sel.value) && e.browser === 'firefox');
6506
- if (statusEl) statusEl.style.color = chosenFirefox ? 'var(--stg-warn)' : '';
6507
- // The server is still asking MoreLogin which browser some profiles run: ask again quietly, a few times.
6508
- clearTimeout(_moreloginBrowsersTimer);
6509
- if (Number(d.browsersPending) > 0 && _moreloginBrowsersTries < 8 && sel.isConnected) {
6510
- _moreloginBrowsersTries += 1;
6511
- _moreloginBrowsersTimer = setTimeout(() => loadMoreLoginEnvs(true), 2500);
6512
- } else _moreloginBrowsersTries = 0;
6513
- if (statusEl) {
6514
- let msg = chosenFirefox
6515
- ? kit.tx('settings.redesign.browser.moreloginFirefoxDefault')
6516
- : (moreloginNote
6517
- ? kit.tx('settings.redesign.browser.localProfilesOnly', { count: envs.length }) + ' ' + moreloginNote
6518
- : kit.tx('settings.redesign.browser.profileSApiPort', { count: envs.length, port: d.port }));
6519
- // MoreLogin silently redirects a navigation it refuses to its stop page: a
6520
- // localhost port missing from the profile's Port scan protection list, or a
6521
- // host its website blacklist/whitelist refuses. Surface it; nothing else in
6522
- // the UI can explain it.
6523
- if (d.blockedNavigations > 0) {
6524
- msg += (" " + kit.tx('settings.redesign.browser.moreloginBlockedNavigationS', { blockedNavigations: d.blockedNavigations }));
6525
- if (d.lastBlockedUrl) msg += kit.tx('settings.redesign.browser.mostRecently', { lastBlockedUrl: String(d.lastBlockedUrl).slice(0, 80) });
6526
- msg += kit.tx('settings.redesign.browser.aLocalhostPortMustBeIn');
6527
- }
6528
- statusEl.textContent = msg;
6529
- }
6530
- } catch {
6531
- only('settings.redesign.browser.error');
6532
- if (statusEl) statusEl.textContent = kit.tx('settings.redesign.browser.failedToReachMorelogin');
6533
- }
6534
- }
6535
- // Toggle MoreLogin-backend UI: show the MoreLogin profile picker, hide the
6536
- // Chrome-only controls (Chrome Profile row + list, profile Path, attach Seed).
6537
- function applyMoreLoginMode(on) {
6538
- const mlRow = overlay.querySelector('#bc-morelogin-row');
6539
- const mlStatusRow = overlay.querySelector('#bc-morelogin-status-row');
6540
- if (mlRow) mlRow.style.display = on ? '' : 'none';
6541
- if (mlStatusRow) mlStatusRow.style.display = on ? '' : 'none';
6542
- const chromeProfRow = overlay.querySelector('#bc-detect-profiles')?.closest('.bc-card-row');
6543
- const profileList = overlay.querySelector('#bc-profile-list');
6544
- const profPathRow = overlay.querySelector('#bc-custom-profile-path')?.closest('.bc-card-row');
6545
- if (chromeProfRow) chromeProfRow.style.display = on ? 'none' : '';
6546
- if (profileList) profileList.style.display = on ? 'none' : '';
6547
- if (profPathRow) profPathRow.style.display = on ? 'none' : '';
6548
- if (on) {
6549
- const seedRow = overlay.querySelector('#bc-attachSeed-row');
6550
- if (seedRow) seedRow.style.display = 'none';
6551
- loadMoreLoginEnvs();
6552
- }
6553
- }
6504
+ // ── The AI browser: a MoreLogin / local profile chosen in the MoreLogin tab (settings-ai-browser.js) ──
6505
+ // This tab only says so, with the way there. It never turns a profile on or off and never changes or clears it: a
6506
+ // save carries back what the server holds (browserSaveFields). Its own fields stay the local browser's.
6507
+ let _aiBrowser = { moreLogin: false, envId: null };
6508
+ let _aiBrowserProfile = null; // { envId, name, kind } as the MoreLogin tab listed it
6509
+ function showAiBrowser() {
6510
+ const profile = _aiBrowserProfile && _aiBrowserProfile.envId === _aiBrowser.envId ? _aiBrowserProfile : null;
6511
+ const line = aiBrowserLine(_aiBrowser, profile);
6512
+ const on = line.key !== 'off';
6513
+ const row = overlay.querySelector('#bc-ai-browser-row');
6514
+ if (row) row.style.display = on ? '' : 'none';
6515
+ const text = overlay.querySelector('#bc-ai-browser-text');
6516
+ if (text) text.textContent = on ? kit.tx(`settings.redesign.browser.aiBrowser.${line.key}`, line.params) : '';
6517
+ // The Connection field is the local browser's mode: not in use while a profile is the AI browser.
6518
+ const mode = overlay.querySelector('#bc-connectMode');
6519
+ if (mode) mode.disabled = on;
6520
+ const note = overlay.querySelector('#bc-connectMode-ai-note');
6521
+ if (note) note.style.display = on ? '' : 'none';
6522
+ syncBcDropdowns();
6523
+ }
6524
+ /** The AI browser as last heard: the MoreLogin tab's news (with the profile's name), or a read of the config. */
6525
+ function noteAiBrowser(detail) {
6526
+ if (!detail || typeof detail !== 'object') return;
6527
+ _aiBrowser = { moreLogin: detail.moreLogin === true, envId: detail.envId == null || detail.envId === '' ? null : String(detail.envId) };
6528
+ if (detail.name != null || detail.kind) _aiBrowserProfile = { envId: _aiBrowser.envId, name: detail.name ?? null, kind: detail.kind || null };
6529
+ showAiBrowser();
6530
+ }
6531
+ overlay.addEventListener(AI_BROWSER_EVENT, (e) => noteAiBrowser(e.detail), { signal: panelLife.signal });
6532
+ if (overlay._stgAiBrowser) noteAiBrowser(overlay._stgAiBrowser);
6533
+ overlay.querySelector('#bc-ai-browser-open')?.addEventListener('click', (e) => {
6534
+ e.preventDefault();
6535
+ applySettingsOpenOptions(overlay, { tab: 'connected-tools', expand: 'stg-sec-ml-default', scrollTo: 'stg-sec-ml-default', highlight: 'stg-sec-ml-default' });
6536
+ }, { signal: panelLife.signal });
6537
+
6538
+ // ── Connection mode (mirror / attach / extension) ──
6554
6539
  function refreshAttachSeedRow() {
6555
6540
  const mode = overlay.querySelector('#bc-connectMode')?.value || 'mirror';
6556
6541
  const seedRow = overlay.querySelector('#bc-attachSeed-row');
6557
6542
  if (seedRow) seedRow.style.display = mode === 'attach' ? '' : 'none';
6558
- const showMl = mode === 'morelogin';
6559
- // Keep the Browser dropdown in sync — MoreLogin appears in BOTH dropdowns.
6560
- const browserHidden = overlay.querySelector('#bc-browser');
6561
- if (showMl && browserHidden && browserHidden.value !== 'morelogin') {
6562
- browserHidden.value = 'morelogin';
6563
- syncBcDropdowns();
6564
- } else if (!showMl && browserHidden && browserHidden.value === 'morelogin') {
6565
- browserHidden.value = 'auto';
6566
- const chan = overlay.querySelector('#bc-channel'); if (chan) chan.value = '';
6567
- syncBcDropdowns();
6568
- }
6569
- applyMoreLoginMode(showMl);
6570
6543
  updateChromeRunningWarning();
6571
6544
  }
6572
6545
  const connectModeDd = overlay.querySelector('.bc-dropdown[data-for="bc-connectMode"]');
@@ -6576,10 +6549,6 @@ async function openSettingsModalNow(options = {}) {
6576
6549
  item.addEventListener('click', refreshAttachSeedRow);
6577
6550
  });
6578
6551
  }
6579
- { const mlRow = overlay.querySelector('#bc-morelogin-row'); if (mlRow) wireDropdowns(mlRow, { signal: panelLife.signal }); }
6580
- // Another profile chosen: the line under the picker says what holds for that one (the Firefox warning goes).
6581
- overlay.querySelector('#bc-morelogin-env-id')?.addEventListener('change', () => loadMoreLoginEnvs(true), { signal: panelLife.signal });
6582
- overlay.querySelector('#bc-morelogin-refresh')?.addEventListener('click', (e) => { e.preventDefault(); loadMoreLoginEnvs(); });
6583
6552
  const attachSeedDd = overlay.querySelector('.bc-dropdown[data-for="bc-attachSeed"]');
6584
6553
  if (attachSeedDd) {
6585
6554
  attachSeedDd.querySelectorAll('.cc-dropdown-item').forEach(item => {
@@ -6863,10 +6832,13 @@ async function openSettingsModalNow(options = {}) {
6863
6832
  }
6864
6833
 
6865
6834
  // Collect all config from the form
6835
+ const refreshExtensionSettings = wireExtensionSettings(overlay, { tx: kit.tx, signal: panelLife.signal });
6836
+
6866
6837
  function collectBrowserConfig() {
6867
6838
  const val = (id) => (overlay.querySelector(`#${id}`)?.value || '').trim();
6868
6839
  const num = (id, def) => { const v = parseInt(val(id), 10); return isNaN(v) ? def : v; };
6869
6840
  const numF = (id, def) => { const v = parseFloat(val(id)); return isNaN(v) ? def : v; };
6841
+ const connection = browserSaveFields(val('bc-connectMode'), _aiBrowser);
6870
6842
 
6871
6843
  // Permissions
6872
6844
  const permissions = [];
@@ -6878,11 +6850,12 @@ async function openSettingsModalNow(options = {}) {
6878
6850
  // Executable
6879
6851
  executablePath: val('bc-executablePath') || null,
6880
6852
  userDataDir: val('bc-userDataDir') || null,
6881
- browser: (val('bc-browser') === 'morelogin' ? 'auto' : (val('bc-browser') || 'auto')),
6853
+ browser: val('bc-browser') || 'auto',
6882
6854
  channel: val('bc-channel') || null,
6883
- connectMode: ['attach', 'morelogin'].includes(val('bc-connectMode')) ? val('bc-connectMode') : 'mirror',
6855
+ // The AI browser goes back as the server holds it (a MoreLogin profile stays on, its id is never cleared here).
6856
+ connectMode: connection.connectMode,
6884
6857
  attachSeed: val('bc-attachSeed') === 'fresh' ? 'fresh' : 'real',
6885
- moreloginEnvId: val('bc-morelogin-env-id') || null,
6858
+ moreloginEnvId: connection.moreloginEnvId,
6886
6859
  slowMo: num('bc-slowMo', 0),
6887
6860
  timeout: num('bc-timeout', 30000),
6888
6861
  navigationTimeout: num('bc-navigationTimeout', 30000),
@@ -6991,16 +6964,14 @@ async function openSettingsModalNow(options = {}) {
6991
6964
  setVal('bc-executablePath', cfg.executablePath);
6992
6965
  setVal('bc-userDataDir', cfg.userDataDir || '');
6993
6966
  matchProfileSelection(cfg.userDataDir || '', _synabunProfile);
6994
- const _showMl = cfg.connectMode === 'morelogin';
6995
- // MoreLogin shows in BOTH dropdowns — label the Browser dropdown 'morelogin' too.
6996
- setVal('bc-browser', _showMl ? 'morelogin' : (cfg.browser || 'auto'));
6967
+ // The local browser's own fields; a MoreLogin AI browser is shown by showAiBrowser, never as one of their values.
6968
+ setVal('bc-browser', cfg.browser && cfg.browser !== 'morelogin' ? cfg.browser : 'auto');
6997
6969
  setVal('bc-channel', cfg.channel || '');
6998
- setVal('bc-connectMode', cfg.connectMode || 'mirror');
6970
+ setVal('bc-connectMode', localConnectModeOf(cfg));
6971
+ refreshExtensionSettings?.();
6999
6972
  setVal('bc-attachSeed', cfg.attachSeed || 'real');
7000
6973
  const _seedRow = overlay.querySelector('#bc-attachSeed-row');
7001
6974
  if (_seedRow) _seedRow.style.display = (cfg.connectMode === 'attach') ? '' : 'none';
7002
- _moreloginDesiredEnvId = cfg.moreloginEnvId || '';
7003
- applyMoreLoginMode(_showMl);
7004
6975
  setVal('bc-slowMo', cfg.slowMo ?? 0);
7005
6976
  setVal('bc-timeout', cfg.timeout ?? 30000);
7006
6977
  setVal('bc-navigationTimeout', cfg.navigationTimeout ?? 30000);
@@ -7130,7 +7101,7 @@ async function openSettingsModalNow(options = {}) {
7130
7101
  return r.json();
7131
7102
  }).then(async (data) => {
7132
7103
  if (!data) return;
7133
- if (data.config) { applyBrowserConfig(data.config); syncBcDropdowns(); }
7104
+ if (data.config) { applyBrowserConfig(data.config); syncBcDropdowns(); noteAiBrowser(aiBrowserOf(data.config)); }
7134
7105
  // Show detected path
7135
7106
  const hint = overlay.querySelector('#bc-detected-path');
7136
7107
  if (hint && data.detectedPath) hint.textContent = kit.tx('settings.redesign.browser.detected', { detectedPath: data.detectedPath });
@@ -7145,10 +7116,22 @@ async function openSettingsModalNow(options = {}) {
7145
7116
  const saveBtn = overlay.querySelector('#bc-save-all');
7146
7117
  if (saveBtn) {
7147
7118
  saveBtn.addEventListener('click', async () => {
7148
- const config = collectBrowserConfig();
7149
7119
  saveBtn.style.opacity = '0.5'; saveBtn.style.pointerEvents = 'none';
7150
7120
  const status = overlay.querySelector('#bc-save-status');
7121
+ // The AI browser as the server holds it now: the MoreLogin tab, or another window, may have changed it since this
7122
+ // page read it, and this save carries it back unchanged. A failed read keeps the last one heard.
7151
7123
  try {
7124
+ const fresh = await fetch('/api/browser/config');
7125
+ const freshData = fresh.ok ? await fresh.json() : null;
7126
+ if (freshData && freshData.config) noteAiBrowser(aiBrowserOf(freshData.config));
7127
+ } catch { /* the last state heard stands */ }
7128
+ const config = collectBrowserConfig();
7129
+ try {
7130
+ // Public assets can reload before the backend. An older server normalizes an unknown mode to mirror.
7131
+ if (config.connectMode === 'extension') {
7132
+ const support = await fetch('/api/browser/extension');
7133
+ if (!support.ok || !(await support.json()).extensionId) throw new Error(kit.tx('browserExtension.restart'));
7134
+ }
7152
7135
  const res = await fetch('/api/browser/config', {
7153
7136
  method: 'PUT',
7154
7137
  headers: { 'Content-Type': 'application/json' },
@@ -10395,34 +10378,21 @@ function showSyncCopiedModal(count) {
10395
10378
  // INIT — wire settings button clicks
10396
10379
  // ═══════════════════════════════════════════
10397
10380
 
10398
- export function initSettings() {
10399
- const settingsBtn = document.getElementById('settings-btn');
10400
- if (settingsBtn) settingsBtn.addEventListener('click', () => openSettingsModal());
10401
-
10402
- const titlebarBtn = document.getElementById('titlebar-settings-btn');
10403
- if (titlebarBtn) titlebarBtn.addEventListener('click', () => openSettingsModal());
10404
-
10405
- const menubarBtn = document.getElementById('menubar-settings-btn');
10406
- if (menubarBtn) menubarBtn.addEventListener('click', () => openSettingsModal());
10381
+ // The buttons, the shortcut, the launch prefetches and the sync listeners are wired by ui-settings-entry.js (its
10382
+ // initSettings, re-exported here), which loads this module on the first open or in idle time after the page shows.
10383
+ export { initSettings } from './ui-settings-entry.js';
10407
10384
 
10408
- registerAction('open-settings', openSettingsModal);
10409
-
10410
- // A language change reloaded the app: open Settings again where the user was, once the rest of the app has started.
10385
+ /** A language change reloaded the app: open Settings again where the user was (ui-settings-entry.js, once). */
10386
+ export function reopenSettingsAfterReload() {
10411
10387
  const reopenPage = takeSettingsReopen();
10412
- if (reopenPage) setTimeout(() => openSettingsModal({ tab: reopenPage, expand: ['stg-sec-language'] }), 0);
10413
-
10414
- // Launch: what Settings is built from, and its search index (the English names too), read and made once the
10415
- // page has painted, so the first open and the first search wait for nothing.
10416
- registerLaunchPrefetch('settings-data', () => prefetchSettingsData(), { order: 60, owner: true });
10417
- registerLaunchPrefetch('settings-search-index', () => prebuildSettingsSearchIndex(), { order: 62 });
10418
- // Changes other windows announce: the next open shows them.
10419
- on('sync:skin:changed', () => refreshSettingsData(['skins']));
10420
- on('sync:greeting:changed', () => refreshSettingsData(['greeting']));
10421
- on('sync:assistant:user-context-changed', () => refreshSettingsData(['userContext']));
10422
-
10423
- // Expose sync functions for inline onclick attributes (if any remain)
10424
- window.checkSyncStatus = checkSyncStatus;
10425
- window.copySyncPrompt = copySyncPrompt;
10388
+ if (reopenPage) openSettingsModal({ tab: reopenPage, expand: ['stg-sec-language'] });
10426
10389
  }
10427
10390
 
10391
+ /** The launch step that makes the Settings search index (ui-settings-entry.js registers it). */
10392
+ export { prebuildSettingsSearchIndex };
10393
+
10394
+ // Expose sync functions for inline onclick attributes (if any remain)
10395
+ window.checkSyncStatus = checkSyncStatus;
10396
+ window.copySyncPrompt = copySyncPrompt;
10397
+
10428
10398
  configureToolPickerTranslation((key, params) => kit.tx(key, params));