synabun 2.3.1 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (370) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +1 -1
  3. package/browser-extension/content.js +189 -0
  4. package/browser-extension/engine.js +508 -0
  5. package/browser-extension/icons/icon-128.png +0 -0
  6. package/browser-extension/icons/icon-16.png +0 -0
  7. package/browser-extension/icons/icon-32.png +0 -0
  8. package/browser-extension/icons/icon-48.png +0 -0
  9. package/browser-extension/icons/status-off-16.png +0 -0
  10. package/browser-extension/icons/status-off-32.png +0 -0
  11. package/browser-extension/icons/status-off-48.png +0 -0
  12. package/browser-extension/icons/status-on-16.png +0 -0
  13. package/browser-extension/icons/status-on-32.png +0 -0
  14. package/browser-extension/icons/status-on-48.png +0 -0
  15. package/browser-extension/manifest.json +56 -0
  16. package/browser-extension/popup-strings.js +250 -0
  17. package/browser-extension/popup-view.js +151 -0
  18. package/browser-extension/popup.css +166 -0
  19. package/browser-extension/popup.html +108 -0
  20. package/browser-extension/popup.js +359 -0
  21. package/browser-extension/protocol.js +232 -0
  22. package/browser-extension/service-worker.js +275 -0
  23. package/browser-extension/setup-content.js +36 -0
  24. package/browser-extension/tokens.css +326 -0
  25. package/docs/browser-extension-bridge.md +84 -0
  26. package/docs/whatsapp.md +1 -1
  27. package/lib/data-home-files.js +45 -0
  28. package/lib/data-home-migration.js +34 -58
  29. package/mcp-server/dist/http.d.ts +2 -0
  30. package/mcp-server/dist/http.d.ts.map +1 -1
  31. package/mcp-server/dist/http.js +9 -1
  32. package/mcp-server/dist/http.js.map +1 -1
  33. package/mcp-server/dist/index.d.ts +11 -0
  34. package/mcp-server/dist/index.d.ts.map +1 -1
  35. package/mcp-server/dist/index.js +38 -3
  36. package/mcp-server/dist/index.js.map +1 -1
  37. package/mcp-server/dist/services/browser-route-flow.d.ts +6 -2
  38. package/mcp-server/dist/services/browser-route-flow.d.ts.map +1 -1
  39. package/mcp-server/dist/services/browser-route-flow.js +10 -3
  40. package/mcp-server/dist/services/browser-route-flow.js.map +1 -1
  41. package/mcp-server/dist/services/codex-config-heal.d.ts.map +1 -1
  42. package/mcp-server/dist/services/codex-config-heal.js +7 -0
  43. package/mcp-server/dist/services/codex-config-heal.js.map +1 -1
  44. package/mcp-server/dist/services/neural-interface.d.ts +95 -3
  45. package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
  46. package/mcp-server/dist/services/neural-interface.js +168 -23
  47. package/mcp-server/dist/services/neural-interface.js.map +1 -1
  48. package/mcp-server/dist/services/team-context.d.ts +18 -0
  49. package/mcp-server/dist/services/team-context.d.ts.map +1 -0
  50. package/mcp-server/dist/services/team-context.js +29 -0
  51. package/mcp-server/dist/services/team-context.js.map +1 -0
  52. package/mcp-server/dist/services/tool-catalog.d.ts +5 -2
  53. package/mcp-server/dist/services/tool-catalog.d.ts.map +1 -1
  54. package/mcp-server/dist/services/tool-catalog.js +22 -6
  55. package/mcp-server/dist/services/tool-catalog.js.map +1 -1
  56. package/mcp-server/dist/services/tool-list.d.ts.map +1 -1
  57. package/mcp-server/dist/services/tool-list.js +4 -0
  58. package/mcp-server/dist/services/tool-list.js.map +1 -1
  59. package/mcp-server/dist/services/tool-runtime.d.ts +8 -1
  60. package/mcp-server/dist/services/tool-runtime.d.ts.map +1 -1
  61. package/mcp-server/dist/services/tool-runtime.js +18 -1
  62. package/mcp-server/dist/services/tool-runtime.js.map +1 -1
  63. package/mcp-server/dist/tools/agent-definition.d.ts +133 -0
  64. package/mcp-server/dist/tools/agent-definition.d.ts.map +1 -0
  65. package/mcp-server/dist/tools/agent-definition.js +483 -0
  66. package/mcp-server/dist/tools/agent-definition.js.map +1 -0
  67. package/mcp-server/dist/tools/agents.d.ts +92 -9
  68. package/mcp-server/dist/tools/agents.d.ts.map +1 -1
  69. package/mcp-server/dist/tools/agents.js +163 -20
  70. package/mcp-server/dist/tools/agents.js.map +1 -1
  71. package/mcp-server/dist/tools/browser-advanced.d.ts +8 -1
  72. package/mcp-server/dist/tools/browser-advanced.d.ts.map +1 -1
  73. package/mcp-server/dist/tools/browser-advanced.js +70 -6
  74. package/mcp-server/dist/tools/browser-advanced.js.map +1 -1
  75. package/mcp-server/dist/tools/git-tools.d.ts +4 -2
  76. package/mcp-server/dist/tools/git-tools.d.ts.map +1 -1
  77. package/mcp-server/dist/tools/git-tools.js +283 -2
  78. package/mcp-server/dist/tools/git-tools.js.map +1 -1
  79. package/mcp-server/dist/tools/morelogin.d.ts +8 -2
  80. package/mcp-server/dist/tools/morelogin.d.ts.map +1 -1
  81. package/mcp-server/dist/tools/morelogin.js +22 -5
  82. package/mcp-server/dist/tools/morelogin.js.map +1 -1
  83. package/mcp-server/dist/tools/team.d.ts +32 -0
  84. package/mcp-server/dist/tools/team.d.ts.map +1 -0
  85. package/mcp-server/dist/tools/team.js +87 -0
  86. package/mcp-server/dist/tools/team.js.map +1 -0
  87. package/mcp-server/package-lock.json +2 -2
  88. package/mcp-server/package.json +1 -1
  89. package/mcp-server/src/http.ts +9 -1
  90. package/mcp-server/src/index.ts +34 -4
  91. package/mcp-server/src/services/browser-route-flow.ts +12 -5
  92. package/mcp-server/src/services/codex-config-heal.ts +7 -0
  93. package/mcp-server/src/services/neural-interface.ts +191 -29
  94. package/mcp-server/src/services/team-context.ts +27 -0
  95. package/mcp-server/src/services/tool-catalog.ts +26 -8
  96. package/mcp-server/src/services/tool-list.ts +4 -0
  97. package/mcp-server/src/services/tool-runtime.ts +21 -2
  98. package/mcp-server/src/tools/agent-definition.ts +458 -0
  99. package/mcp-server/src/tools/agents.ts +177 -19
  100. package/mcp-server/src/tools/browser-advanced.ts +60 -6
  101. package/mcp-server/src/tools/git-tools.ts +249 -3
  102. package/mcp-server/src/tools/morelogin.ts +20 -5
  103. package/mcp-server/src/tools/team.ts +97 -0
  104. package/neural-interface/i18n/en.json +1119 -47
  105. package/neural-interface/i18n/pt-BR.json +1119 -47
  106. package/neural-interface/lib/account-usage.js +1 -1
  107. package/neural-interface/lib/agents/builtins.json +207 -0
  108. package/neural-interface/lib/agents/density.js +101 -0
  109. package/neural-interface/lib/agents/forge-host.js +223 -0
  110. package/neural-interface/lib/agents/native-export-targets.js +190 -0
  111. package/neural-interface/lib/agents/native-export.js +365 -0
  112. package/neural-interface/lib/agents/registry.js +885 -0
  113. package/neural-interface/lib/agents/resolve.js +603 -0
  114. package/neural-interface/lib/agents/schema.js +642 -0
  115. package/neural-interface/lib/agents/split.js +37 -0
  116. package/neural-interface/lib/agents-studio-api.js +591 -0
  117. package/neural-interface/lib/assistant-api.js +76 -7
  118. package/neural-interface/lib/assistant-brains/opencode.js +60 -11
  119. package/neural-interface/lib/assistant-catalog.js +2 -0
  120. package/neural-interface/lib/assistant-continuity.js +49 -0
  121. package/neural-interface/lib/assistant-dispatch.js +351 -121
  122. package/neural-interface/lib/assistant-persona.js +105 -8
  123. package/neural-interface/lib/assistant-route-gate.js +24 -9
  124. package/neural-interface/lib/assistant-router.js +432 -47
  125. package/neural-interface/lib/assistant-run-tail.js +151 -0
  126. package/neural-interface/lib/assistant-run-wait.js +183 -0
  127. package/neural-interface/lib/assistant-runtime.js +449 -94
  128. package/neural-interface/lib/assistant-task-prompt.js +11 -2
  129. package/neural-interface/lib/assistant-usage.js +3 -2
  130. package/neural-interface/lib/automation-approval.js +2 -2
  131. package/neural-interface/lib/backup-service.js +64 -105
  132. package/neural-interface/lib/browser-close-evidence.js +80 -0
  133. package/neural-interface/lib/browser-default.js +210 -0
  134. package/neural-interface/lib/browser-extension-adapter.js +264 -0
  135. package/neural-interface/lib/browser-extension-bridge.js +441 -0
  136. package/neural-interface/lib/browser-extension-folder.js +116 -0
  137. package/neural-interface/lib/browser-extension-setup.js +140 -0
  138. package/neural-interface/lib/browser-profile-choices.js +3 -3
  139. package/neural-interface/lib/browser-tool-policy.js +1 -1
  140. package/neural-interface/lib/claude-account-links.js +301 -0
  141. package/neural-interface/lib/claude-accounts.js +45 -20
  142. package/neural-interface/lib/claude-agent-bridge.js +142 -10
  143. package/neural-interface/lib/claude-model-catalog.js +6 -0
  144. package/neural-interface/lib/claude-panel-session.js +33 -0
  145. package/neural-interface/lib/codex-accounts.js +67 -24
  146. package/neural-interface/lib/coordination/README.md +384 -0
  147. package/neural-interface/lib/coordination/service.js +563 -0
  148. package/neural-interface/lib/coordination/store.js +1138 -0
  149. package/neural-interface/lib/db.js +22 -1
  150. package/neural-interface/lib/effort-levels.js +10 -1
  151. package/neural-interface/lib/memory-list-page.js +49 -0
  152. package/neural-interface/lib/memory-list-stamp.js +60 -0
  153. package/neural-interface/lib/morelogin-outside-close.js +186 -0
  154. package/neural-interface/lib/morelogin-profile-failures.js +206 -0
  155. package/neural-interface/lib/morelogin-start-cooldown.js +160 -0
  156. package/neural-interface/lib/morelogin.js +194 -8
  157. package/neural-interface/lib/native-loop-runtime.js +26 -7
  158. package/neural-interface/lib/opencode-build-preflight.js +28 -8
  159. package/neural-interface/lib/opencode-native-boundary.js +83 -13
  160. package/neural-interface/lib/opencode-serve-records.js +14 -9
  161. package/neural-interface/lib/page-session.js +1 -1
  162. package/neural-interface/lib/peer-identity.js +73 -29
  163. package/neural-interface/lib/process-identity.js +68 -7
  164. package/neural-interface/lib/request-gate.js +3 -0
  165. package/neural-interface/lib/screenshot-location.js +33 -0
  166. package/neural-interface/lib/session-cache-builder.js +41 -3
  167. package/neural-interface/lib/skills/creation.js +1 -1
  168. package/neural-interface/lib/skills/known-bridge-digests.json +40 -0
  169. package/neural-interface/lib/studio-attention.js +56 -0
  170. package/neural-interface/lib/teams/README.md +382 -0
  171. package/neural-interface/lib/teams/api.js +287 -0
  172. package/neural-interface/lib/teams/brief.js +185 -0
  173. package/neural-interface/lib/teams/claims.js +315 -0
  174. package/neural-interface/lib/teams/git.js +293 -0
  175. package/neural-interface/lib/teams/index.js +122 -0
  176. package/neural-interface/lib/teams/integration.js +580 -0
  177. package/neural-interface/lib/teams/landing.js +184 -0
  178. package/neural-interface/lib/teams/recovery.js +256 -0
  179. package/neural-interface/lib/teams/scheduler.js +1474 -0
  180. package/neural-interface/lib/teams/schema.js +559 -0
  181. package/neural-interface/lib/teams/state.js +181 -0
  182. package/neural-interface/lib/teams/test-runner.js +86 -0
  183. package/neural-interface/lib/teams/test-sandbox.js +99 -0
  184. package/neural-interface/lib/teams/worktrees.js +757 -0
  185. package/neural-interface/lib/tool-permission-choices.js +226 -0
  186. package/neural-interface/lib/whatsapp/cards.js +24 -10
  187. package/neural-interface/lib/worker-confinement.js +206 -6
  188. package/neural-interface/package-lock.json +2 -2
  189. package/neural-interface/package.json +1 -1
  190. package/neural-interface/public/extension-setup.html +107 -0
  191. package/neural-interface/public/index.html +103 -12
  192. package/neural-interface/public/offline.html +4 -3
  193. package/neural-interface/public/shared/agent-runtime-options.js +3 -1
  194. package/neural-interface/public/shared/agents/studio/ax-agent-view.js +614 -0
  195. package/neural-interface/public/shared/agents/studio/ax-api.js +198 -0
  196. package/neural-interface/public/shared/agents/studio/ax-create-view.js +221 -0
  197. package/neural-interface/public/shared/agents/studio/ax-diff.js +143 -0
  198. package/neural-interface/public/shared/agents/studio/ax-editor-view.js +392 -0
  199. package/neural-interface/public/shared/agents/studio/ax-export-view.js +94 -0
  200. package/neural-interface/public/shared/agents/studio/ax-form.js +191 -0
  201. package/neural-interface/public/shared/agents/studio/ax-icons.js +87 -0
  202. package/neural-interface/public/shared/agents/studio/ax-library-view.js +158 -0
  203. package/neural-interface/public/shared/agents/studio/ax-library.js +162 -0
  204. package/neural-interface/public/shared/agents/studio/ax-main.js +712 -0
  205. package/neural-interface/public/shared/agents/studio/ax-native-export.js +35 -0
  206. package/neural-interface/public/shared/agents/studio/ax-options.js +198 -0
  207. package/neural-interface/public/shared/agents/studio/ax-review-view.js +175 -0
  208. package/neural-interface/public/shared/agents/studio/ax-revisions-view.js +189 -0
  209. package/neural-interface/public/shared/agents/studio/ax-runs-view.js +202 -0
  210. package/neural-interface/public/shared/agents/studio/ax-runs.js +82 -0
  211. package/neural-interface/public/shared/agents/studio/ax-teams-view.js +256 -0
  212. package/neural-interface/public/shared/agents/studio/ax-teams.js +200 -0
  213. package/neural-interface/public/shared/agents/studio/ax-templates.js +50 -0
  214. package/neural-interface/public/shared/agents/studio/ax-ui.js +194 -0
  215. package/neural-interface/public/shared/agents/studio/ax-views.js +170 -0
  216. package/neural-interface/public/shared/agy/agy-panel.js +142 -28
  217. package/neural-interface/public/shared/agy/agy-styles.js +25 -5
  218. package/neural-interface/public/shared/api.js +2 -1
  219. package/neural-interface/public/shared/assistant/asst-account-menu.js +13 -13
  220. package/neural-interface/public/shared/assistant/asst-ask-styles.js +2 -3
  221. package/neural-interface/public/shared/assistant/asst-brain-picker.js +91 -9
  222. package/neural-interface/public/shared/assistant/asst-control.js +3 -0
  223. package/neural-interface/public/shared/assistant/asst-interaction-hold.js +99 -0
  224. package/neural-interface/public/shared/assistant/asst-limit-dismissals.js +111 -0
  225. package/neural-interface/public/shared/assistant/asst-limit-dock.js +37 -3
  226. package/neural-interface/public/shared/assistant/asst-limit-wait.js +30 -7
  227. package/neural-interface/public/shared/assistant/asst-panel.js +177 -30
  228. package/neural-interface/public/shared/assistant/asst-rack-styles.js +15 -8
  229. package/neural-interface/public/shared/assistant/asst-render.js +37 -6
  230. package/neural-interface/public/shared/assistant/asst-route.js +80 -12
  231. package/neural-interface/public/shared/assistant/asst-routes-editor.js +148 -70
  232. package/neural-interface/public/shared/assistant/asst-roving.js +17 -1
  233. package/neural-interface/public/shared/assistant/asst-scene-styles.js +7 -2
  234. package/neural-interface/public/shared/assistant/asst-scenes.js +12 -1
  235. package/neural-interface/public/shared/assistant/asst-sidepanel.js +12 -2
  236. package/neural-interface/public/shared/assistant/asst-state.js +66 -1
  237. package/neural-interface/public/shared/assistant/asst-styles.js +98 -44
  238. package/neural-interface/public/shared/assistant/route-identity.js +16 -0
  239. package/neural-interface/public/shared/cc-dropdown.js +21 -15
  240. package/neural-interface/public/shared/cdx/cdx-output.js +10 -0
  241. package/neural-interface/public/shared/cdx/cdx-panel.js +18 -16
  242. package/neural-interface/public/shared/cdx/cdx-plan.js +3 -2
  243. package/neural-interface/public/shared/cdx/cdx-render.js +122 -45
  244. package/neural-interface/public/shared/cdx/cdx-requests.js +4 -4
  245. package/neural-interface/public/shared/cdx/cdx-styles.js +8 -36
  246. package/neural-interface/public/shared/cdx/cdx-tabs.js +110 -42
  247. package/neural-interface/public/shared/claude-panel-lazy.js +12 -0
  248. package/neural-interface/public/shared/code-copy.js +120 -0
  249. package/neural-interface/public/shared/constants.js +7 -0
  250. package/neural-interface/public/shared/context-menu-model.js +1 -0
  251. package/neural-interface/public/shared/cp/cp-markdown.js +7 -2
  252. package/neural-interface/public/shared/cp/cp-session-model.js +86 -5
  253. package/neural-interface/public/shared/cp/cp-session-settings.js +58 -30
  254. package/neural-interface/public/shared/cp/cp-styles.js +9 -0
  255. package/neural-interface/public/shared/dom-change-flag.js +66 -0
  256. package/neural-interface/public/shared/dom-morph.js +124 -0
  257. package/neural-interface/public/shared/extension-setup/es-page.css +134 -0
  258. package/neural-interface/public/shared/extension-setup/es-page.js +120 -0
  259. package/neural-interface/public/shared/extension-setup/es-view.js +100 -0
  260. package/neural-interface/public/shared/html-shell.js +34 -4
  261. package/neural-interface/public/shared/i18n.js +14 -1
  262. package/neural-interface/public/shared/idle-queue.js +78 -0
  263. package/neural-interface/public/shared/iface-config.js +227 -0
  264. package/neural-interface/public/shared/lazy-module.js +108 -0
  265. package/neural-interface/public/shared/memory-list.js +117 -0
  266. package/neural-interface/public/shared/morelogin-profile-choices.js +1 -1
  267. package/neural-interface/public/shared/morelogin-profile-field.js +3 -3
  268. package/neural-interface/public/shared/mtc/mtc-panel.js +3 -1
  269. package/neural-interface/public/shared/mtc/mtc-styles.js +4 -1
  270. package/neural-interface/public/shared/ocp-v2/ocp-v2-manager.js +35 -15
  271. package/neural-interface/public/shared/ocp-v2/ocp-v2-panel.js +77 -23
  272. package/neural-interface/public/shared/ocp-v2/ocp-v2-projectbar.js +3 -6
  273. package/neural-interface/public/shared/ocp-v2/ocp-v2-render.js +24 -21
  274. package/neural-interface/public/shared/ocp-v2/ocp-v2-send-logic.js +16 -5
  275. package/neural-interface/public/shared/ocp-v2/ocp-v2-sessions-logic.js +16 -2
  276. package/neural-interface/public/shared/ocp-v2/ocp-v2-styles.js +27 -43
  277. package/neural-interface/public/shared/ocp-v2/ocp-v2-ws.js +73 -9
  278. package/neural-interface/public/shared/owner-authority-view.js +4 -10
  279. package/neural-interface/public/shared/page-session.js +1 -1
  280. package/neural-interface/public/shared/schedules-view.js +2 -2
  281. package/neural-interface/public/shared/session-project-items.js +11 -0
  282. package/neural-interface/public/shared/settings/settings-ai-browser.js +119 -0
  283. package/neural-interface/public/shared/settings/settings-browser-extension.js +446 -0
  284. package/neural-interface/public/shared/settings/settings-ia.js +4 -2
  285. package/neural-interface/public/shared/settings/settings-morelogin-cooldown.js +63 -0
  286. package/neural-interface/public/shared/settings/settings-tool-permissions.js +70 -0
  287. package/neural-interface/public/shared/sidepanel-lazy.js +40 -0
  288. package/neural-interface/public/shared/sidepanel-session-status.js +8 -14
  289. package/neural-interface/public/shared/sidepanel-shown.js +73 -0
  290. package/neural-interface/public/shared/start-bridge.js +2 -2
  291. package/neural-interface/public/shared/storage.js +6 -1
  292. package/neural-interface/public/shared/studio-attention.js +83 -0
  293. package/neural-interface/public/shared/styles.css +694 -50
  294. package/neural-interface/public/shared/term-browser-tabs.js +34 -0
  295. package/neural-interface/public/shared/transcript-rows.js +334 -0
  296. package/neural-interface/public/shared/tray-auto-close.js +106 -0
  297. package/neural-interface/public/shared/ui-agents.js +97 -0
  298. package/neural-interface/public/shared/ui-antigravity-panel.js +16 -14
  299. package/neural-interface/public/shared/ui-automation-studio.js +3 -3
  300. package/neural-interface/public/shared/ui-claude-panel.js +162 -95
  301. package/neural-interface/public/shared/ui-code-copy.js +256 -0
  302. package/neural-interface/public/shared/ui-codex-panel.js +14 -10
  303. package/neural-interface/public/shared/ui-context-menu.js +1 -1
  304. package/neural-interface/public/shared/ui-file-explorer.js +2 -3
  305. package/neural-interface/public/shared/ui-games.js +1 -1
  306. package/neural-interface/public/shared/ui-loading.js +83 -19
  307. package/neural-interface/public/shared/ui-maritaca-panel.js +12 -11
  308. package/neural-interface/public/shared/ui-menubar.js +23 -0
  309. package/neural-interface/public/shared/ui-native-loop-router.js +50 -21
  310. package/neural-interface/public/shared/ui-navbar.js +15 -9
  311. package/neural-interface/public/shared/ui-opencode-panel-v2.js +13 -11
  312. package/neural-interface/public/shared/ui-owner-authority.js +48 -25
  313. package/neural-interface/public/shared/ui-schedules-studio.js +3 -3
  314. package/neural-interface/public/shared/ui-scroll-follow.js +39 -0
  315. package/neural-interface/public/shared/ui-sessions.js +3 -3
  316. package/neural-interface/public/shared/ui-settings-entry.js +55 -0
  317. package/neural-interface/public/shared/ui-settings.js +363 -400
  318. package/neural-interface/public/shared/ui-sidepanel-layout.js +44 -25
  319. package/neural-interface/public/shared/ui-sidepanel-session-entry.js +22 -9
  320. package/neural-interface/public/shared/ui-sidepanel-sessions.js +10 -2
  321. package/neural-interface/public/shared/ui-sidepanel-tray.js +36 -41
  322. package/neural-interface/public/shared/ui-sidepanel-windows.js +14 -1
  323. package/neural-interface/public/shared/ui-styleguide.js +10 -2
  324. package/neural-interface/public/shared/ui-sync.js +6 -0
  325. package/neural-interface/public/shared/ui-terminal.js +13 -9
  326. package/neural-interface/public/shared/ui-tooltip.js +28 -7
  327. package/neural-interface/public/shared/ui-topright-overflow.js +26 -4
  328. package/neural-interface/public/shared/ui-tray-columns.js +375 -0
  329. package/neural-interface/public/shared/ui-whiteboard.js +51 -6
  330. package/neural-interface/public/shared/ui-worker-end.js +28 -1
  331. package/neural-interface/public/shared/ui-workspaces.js +13 -0
  332. package/neural-interface/public/shared/window-keys.js +71 -0
  333. package/neural-interface/public/sw.js +4 -3
  334. package/neural-interface/public/variant/2d/main.js +2 -0
  335. package/neural-interface/public/variant/3d/app.js +620 -0
  336. package/neural-interface/public/variant/3d/boot-reveal.js +47 -0
  337. package/neural-interface/public/variant/3d/main.js +30 -544
  338. package/neural-interface/public/variant/3d/map-controls.js +4 -2
  339. package/neural-interface/public/vendor/fonts/fonts.css +508 -0
  340. package/neural-interface/public/vendor/fonts/inter-OFL.txt +93 -0
  341. package/neural-interface/public/vendor/fonts/inter-cyrillic-ext.woff2 +0 -0
  342. package/neural-interface/public/vendor/fonts/inter-cyrillic.woff2 +0 -0
  343. package/neural-interface/public/vendor/fonts/inter-greek-ext.woff2 +0 -0
  344. package/neural-interface/public/vendor/fonts/inter-greek.woff2 +0 -0
  345. package/neural-interface/public/vendor/fonts/inter-latin-ext.woff2 +0 -0
  346. package/neural-interface/public/vendor/fonts/inter-latin.woff2 +0 -0
  347. package/neural-interface/public/vendor/fonts/inter-vietnamese.woff2 +0 -0
  348. package/neural-interface/public/vendor/fonts/jetbrains-mono-OFL.txt +93 -0
  349. package/neural-interface/public/vendor/fonts/jetbrains-mono-cyrillic-ext.woff2 +0 -0
  350. package/neural-interface/public/vendor/fonts/jetbrains-mono-cyrillic.woff2 +0 -0
  351. package/neural-interface/public/vendor/fonts/jetbrains-mono-greek.woff2 +0 -0
  352. package/neural-interface/public/vendor/fonts/jetbrains-mono-latin-ext.woff2 +0 -0
  353. package/neural-interface/public/vendor/fonts/jetbrains-mono-latin.woff2 +0 -0
  354. package/neural-interface/public/vendor/fonts/jetbrains-mono-vietnamese.woff2 +0 -0
  355. package/neural-interface/public/vendor/fonts/manifest.json +142 -0
  356. package/neural-interface/public/vendor/fonts/space-grotesk-OFL.txt +93 -0
  357. package/neural-interface/public/vendor/fonts/space-grotesk-latin-ext.woff2 +0 -0
  358. package/neural-interface/public/vendor/fonts/space-grotesk-latin.woff2 +0 -0
  359. package/neural-interface/public/vendor/fonts/space-grotesk-vietnamese.woff2 +0 -0
  360. package/neural-interface/scripts/boot-graph.mjs +270 -0
  361. package/neural-interface/scripts/vendor-fonts.mjs +124 -0
  362. package/neural-interface/server.js +1083 -164
  363. package/npm-shrinkwrap.json +2 -2
  364. package/package.json +4 -1
  365. package/skills/agent-forge/SKILL.md +182 -0
  366. package/skills/agent-forge/evals/evals.json +56 -0
  367. package/skills/agent-forge/references/definition-fields.md +61 -0
  368. package/skills/agent-forge/references/examples.md +105 -0
  369. package/skills/agent-forge/references/instructions.md +51 -0
  370. package/skills/agent-forge/references/review-and-export.md +84 -0
@@ -0,0 +1,140 @@
1
+ // The one-button setup of the everyday-browser extension (Settings → Browser → "Connect your browser";
2
+ // docs/browser-extension-bridge.md → One-button setup). The owner presses the button; SynaBun finds the default
3
+ // browser, prepares the extension folder, opens its own "Connect your browser" page (SETUP_PAGE_PATH) in that browser and
4
+ // shows the folder in Finder, Explorer or the file manager. The owner does the three steps no app may do for them
5
+ // (the extensions page, Developer mode, Load unpacked); the extension then pairs by itself with a one-time token.
6
+ //
7
+ // Every route that reaches this is the owner's (server.js mounts them behind the same guard as pairing and the mode:
8
+ // ownerRouteGuard, this boot's page secret, no automation caller). Nothing here starts a program by itself: `exec` is
9
+ // injected (server.js: execFile, no shell, detached) and gets a plan from lib/browser-default.js.
10
+ //
11
+ // The token: made by ticket(), only while a setup is active and still waiting for the extension, at most
12
+ // MAX_TICKETS times per setup (each one replaces the last), each valid TICKET_MS (and never past the setup's end). The
13
+ // bridge accepts it once, in its pairing handshake, and forgets it (lib/browser-extension-bridge.js
14
+ // beginSetupPairing). It is never logged, never in a status and never in a URL.
15
+ import { launchPlan, revealPlan, SUPPORTED_BROWSER_IDS } from './browser-default.js';
16
+ import { SETUP_PAGE_PATH } from './browser-extension-folder.js';
17
+ import { randomBytes } from 'node:crypto';
18
+
19
+ export const SETUP_STATES = Object.freeze(['idle', 'waiting-for-extension', 'pairing', 'connected', 'unsupported', 'error']);
20
+ export const SETUP_WINDOW_MS = 15 * 60 * 1000;
21
+ export const TICKET_MS = 2 * 60 * 1000;
22
+ export const MAX_TICKETS = 5;
23
+ const fail = (code, message = code) => { throw Object.assign(new Error(message), { code }); };
24
+
25
+ /**
26
+ * `bridge` (createExtensionBridge), `detect()` → { browser, installedBrowsers } (browser-default.js detectBrowsers with
27
+ * the system's runners), `prepare()` → { folder, version, changed } (browser-extension-folder.js), `exec(cmd, args)`
28
+ * starts a program (never a shell), `appOrigin()` is this server's own origin on loopback (http://127.0.0.1:<port>),
29
+ * `platform` the OS, `folderVersion()` the version the folder holds.
30
+ */
31
+ export function createExtensionSetup({ bridge, detect, prepare, exec, appOrigin, platform = process.platform, now = Date.now,
32
+ windowMs = SETUP_WINDOW_MS, ticketMs = TICKET_MS, maxTickets = MAX_TICKETS, folderVersion = () => null } = {}) {
33
+ let setup = null;
34
+ const pageUrl = () => `${appOrigin()}${SETUP_PAGE_PATH}`;
35
+ const describe = browser => browser ? { id: browser.id, name: browser.name, supported: browser.supported === true, extensionsUrl: browser.extensionsUrl || null } : null;
36
+ function state() {
37
+ if (!setup) return 'idle';
38
+ if (setup.error) return 'error';
39
+ const bridgeStatus = bridge.status();
40
+ // Paired by this setup: a pairing made after it began (its token, or the typed code as a fallback). Connected once
41
+ // the extension's first inventory arrived; "Pairing…" from the token's handshake until then.
42
+ if (bridgeStatus.paired && bridgeStatus.pairedAt !== setup.pairedBefore) return bridgeStatus.connected ? 'connected' : 'pairing';
43
+ if (bridge.setupPairing().attempted) return 'pairing';
44
+ if (now() >= setup.until) { expire(); return 'error'; }
45
+ if (!setup.browser?.supported) return 'unsupported';
46
+ return 'waiting-for-extension';
47
+ }
48
+ function expire() {
49
+ if (!setup || setup.error) return;
50
+ bridge.endSetupPairing(); setup.error = { code: 'SETUP_EXPIRED' };
51
+ }
52
+ async function open(browser) {
53
+ try { const plan = launchPlan(platform, browser, pageUrl()); await exec(plan.cmd, plan.args); return true; } catch { return false; }
54
+ }
55
+ async function reveal() {
56
+ if (!setup?.folder) fail('SETUP_NOT_ACTIVE');
57
+ try { const plan = revealPlan(platform, setup.folder); await exec(plan.cmd, plan.args); return { ok: true, folder: setup.folder }; }
58
+ catch { return { ok: false, code: 'REVEAL_FAILED', folder: setup.folder }; }
59
+ }
60
+ function view() {
61
+ const current = state(), bridgeStatus = bridge.status();
62
+ const version = folderVersion();
63
+ return {
64
+ state: current,
65
+ ...(setup ? { setupId: setup.id, browser: describe(setup.browser), defaultBrowser: describe(setup.defaultBrowser), installedBrowsers: setup.installed.map(describe),
66
+ folder: setup.folder, extensionsUrl: setup.browser?.extensionsUrl || null, opened: setup.opened, revealed: setup.revealed, expiresAt: setup.until } : {}),
67
+ ...(setup?.error ? { code: setup.error.code } : {}),
68
+ connected: bridgeStatus.connected, paired: bridgeStatus.paired, bridgePort: bridgeStatus.port,
69
+ extensionVersion: bridgeStatus.extensionVersion || null, folderVersion: version,
70
+ // The browser runs an older copy than the folder holds (or an extension from before versions were reported).
71
+ reloadNeeded: !!(bridgeStatus.connected && version && bridgeStatus.extensionVersion !== version),
72
+ };
73
+ }
74
+ return {
75
+ /**
76
+ * Starts (or restarts) a setup. `browserId`: one of the installed supported browsers, for "open in X instead";
77
+ * without it the default browser, which may be unsupported (then the page is not opened and the state is
78
+ * `unsupported` with the installed browsers to choose from).
79
+ */
80
+ async start({ browserId } = {}) {
81
+ if (browserId !== undefined && browserId !== null && !SUPPORTED_BROWSER_IDS.includes(browserId)) fail('INVALID_MESSAGE');
82
+ if (setup) bridge.endSetupPairing();
83
+ let detected;
84
+ try { detected = await detect(); } catch { detected = { browser: null, installedBrowsers: [] }; }
85
+ const installed = Array.isArray(detected?.installedBrowsers) ? detected.installedBrowsers.filter(b => b?.supported) : [];
86
+ const defaultBrowser = detected?.browser || { id: 'unknown', name: 'Unknown browser', supported: false, extensionsUrl: null };
87
+ let browser = defaultBrowser;
88
+ if (browserId) {
89
+ browser = installed.find(b => b.id === browserId);
90
+ if (!browser) fail('BROWSER_NOT_INSTALLED');
91
+ }
92
+ setup = { id: randomBytes(12).toString('hex'), startedAt: now(), until: now() + windowMs, browser, defaultBrowser, installed,
93
+ folder: null, opened: false, revealed: false, tickets: 0, pairedBefore: bridge.status().pairedAt || 0, error: null };
94
+ try { setup.folder = (await prepare()).folder; }
95
+ catch { setup.error = { code: 'EXTENSION_FOLDER_FAILED' }; return view(); }
96
+ if (browser.supported) {
97
+ setup.opened = await open(browser);
98
+ setup.revealed = (await reveal()).ok === true;
99
+ if (!setup.opened) setup.error = { code: 'OPEN_FAILED' };
100
+ }
101
+ return view();
102
+ },
103
+ status: view,
104
+ /**
105
+ * The one-time token for the setup page (POST …/setup/ticket): only while the setup waits for the extension.
106
+ * Returns { token, bridgePort, expiresAt }.
107
+ */
108
+ async ticket() {
109
+ const current = state();
110
+ if (!setup || current === 'idle') fail('SETUP_NOT_ACTIVE');
111
+ if (current !== 'waiting-for-extension') fail(current === 'error' ? setup.error?.code || 'SETUP_NOT_ACTIVE' : 'SETUP_NOT_WAITING');
112
+ if (setup.tickets >= maxTickets) fail('SETUP_TICKETS_USED');
113
+ setup.tickets++;
114
+ const until = Math.min(setup.until, now() + ticketMs);
115
+ const made = await bridge.beginSetupPairing({ until });
116
+ return { token: made.token, bridgePort: made.port, expiresAt: made.expiresAt };
117
+ },
118
+ cancel() { if (setup) bridge.endSetupPairing(); setup = null; return view(); },
119
+ reveal,
120
+ /** Opens the setup page again (in the setup's browser). */
121
+ async reopen() { if (!setup?.browser?.supported) fail('SETUP_NOT_ACTIVE'); setup.opened = await open(setup.browser); return view(); },
122
+ };
123
+ }
124
+
125
+ /** Fixed sentences for the setup's own codes (never a path, a token or a program's output). */
126
+ export const SETUP_ERROR_TEXT = Object.freeze({
127
+ SETUP_NOT_ACTIVE: 'No browser setup is running. Press "Connect your browser" in SynaBun Settings → Browser.',
128
+ SETUP_NOT_WAITING: 'This setup is no longer waiting for the extension (it is pairing or connected).',
129
+ SETUP_TICKETS_USED: 'This setup handed out its pairing tokens. Start "Connect your browser" again, or pair with a code.',
130
+ SETUP_EXPIRED: 'This setup ran out of time (15 minutes). Start "Connect your browser" again.',
131
+ BROWSER_NOT_INSTALLED: 'That browser was not found on this computer.',
132
+ EXTENSION_FOLDER_FAILED: 'SynaBun could not prepare the extension folder in its data folder.',
133
+ OPEN_FAILED: 'SynaBun could not open the setup page in the browser. Open it yourself from Settings → Browser.',
134
+ REVEAL_FAILED: 'SynaBun could not show the folder. Copy its path from the setup page.',
135
+ INVALID_MESSAGE: 'Invalid setup request.',
136
+ });
137
+ export function setupError(error) {
138
+ const code = Object.hasOwn(SETUP_ERROR_TEXT, error?.code) ? error.code : null;
139
+ return code ? { ok: false, code, error: `${code}: ${SETUP_ERROR_TEXT[code]}` } : null;
140
+ }
@@ -3,13 +3,13 @@
3
3
  // A run can be launched with a MoreLogin profile (a schedule's, a group's, a timer's, a launch's, a dispatch's:
4
4
  // server.js pinRunMoreLoginProfile). A session can also choose one for itself while it runs (the `morelogin` tool's
5
5
  // "use" action, POST /api/morelogin/use): the same pin, set for the caller's own owner key and for nobody else. The
6
- // default of Settings → Browser and every other session stay as they are.
6
+ // default AI browser (Settings → Connected tools → MoreLogin) and every other session stay as they are.
7
7
  //
8
8
  // The pin map lives in memory, and a run's launch pin is read back from its loop file after a restart. A choice a
9
9
  // session made itself has no such file (a side panel, the Assistant's brain, a CLI window), and losing it would send
10
10
  // that session's next browser call to the default profile without a word: another account. So choices are kept in one
11
11
  // small file (DATA_HOME/data/browser-profile-choices.json) and put back into the pin map when the server starts.
12
- // `envId: null` is a choice too: "the Browser settings default", made by a run that was launched with a profile.
12
+ // `envId: null` is a choice too: "the default AI browser", made by a run that was launched with a profile.
13
13
 
14
14
  import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
15
15
  import { dirname } from 'node:path';
@@ -121,7 +121,7 @@ export function createProfileChoiceStore({ file, now = Date.now, log = () => {},
121
121
  const row = loaded().get(ownerKey);
122
122
  return row ? { envId: row.envId, name: row.name } : undefined;
123
123
  },
124
- /** Keep `ownerKey`'s choice: a profile, or null for "the Browser settings default". */
124
+ /** Keep `ownerKey`'s choice: a profile, or null for "the default AI browser". */
125
125
  set(ownerKey, choice) {
126
126
  if (!OWNER_RE.test(String(ownerKey || ''))) return false;
127
127
  const envId = cleanId(choice?.envId);
@@ -103,7 +103,7 @@ export function browserPolicyText({ tools = '', host = null } = {}) {
103
103
  const web = WEB_TOOL_WORDS[hostKey(host)] || 'WebSearch / WebFetch (OpenCode webfetch / websearch, Codex web_search)';
104
104
  return [
105
105
  `- Every page, public or localhost, goes through SynaBun's browser tools (${t.navigate}, ${t.snapshot}, ${t.screenshot}, ${t.console} and the other browser_* tools); they open the browser configured in SynaBun (MoreLogin). Nothing else opens a page.`,
106
- `- MoreLogin profiles: the browser tools work in your own profile (the default of Settings → Browser, or the one your run was started with). To work in another profile (a second account), call ${t.morelogin} with action "use" (envId or name): only your own browser tools move there, in a tab of your own, while other automations keep working in theirs. You can choose only a profile the owner allowed agents to choose (the tool's "list" and "status" say which; none until the owner switches one on in SynaBun's Settings → Connected tools → MoreLogin). When a profile is refused as not on the owner's list, nothing was opened: tell the user which profile to switch on there and stop; never work in another profile or browser instead. Never try to change the default for that (the default profile is the owner's choice in Settings → Browser: use_default is refused for every agent; "start" takes only a profile on the owner's list too), and never say a second profile cannot be driven: a refused one is not on the owner's list, which is what you say.`,
106
+ `- MoreLogin profiles: the browser tools work in your own profile (the default AI browser, set in Settings → Connected tools → MoreLogin (Default AI browser), or the one your run was started with). To work in another profile (a second account), call ${t.morelogin} with action "use" (envId or name): only your own browser tools move there, in a tab of your own, while other automations keep working in theirs. You can choose only a profile the owner allowed agents to choose (the tool's "list" and "status" say which; none until the owner switches one on in SynaBun's Settings → Connected tools → MoreLogin). When a profile is refused as not on the owner's list, nothing was opened: tell the user which profile to switch on there and stop; never work in another profile or browser instead. Never try to change the default for that (the default profile is the owner's choice in the MoreLogin tab in Settings: use_default is refused for every agent; "start" takes only a profile on the owner's list too), and never say a second profile cannot be driven: a refused one is not on the owner's list, which is what you say.`,
107
107
  '- Never run Playwright, Puppeteer or Selenium code of your own to look at a page (a script, node -e, python -c, a heredoc), and never `npx playwright` except to run automated tests (npx playwright test).',
108
108
  `- ${TEST_RUN_RULE}`,
109
109
  '- Never launch Chrome, Chromium, Edge, chrome-headless-shell or any other browser binary, and never take headless screenshots (--headless, --screenshot).',
@@ -0,0 +1,301 @@
1
+ // ═══════════════════════════════════════════
2
+ // SynaBun — how a named account shares the default account's files
3
+ // ═══════════════════════════════════════════
4
+ //
5
+ // A named Claude account is a config directory of its own (lib/claude-accounts.js). What is not an identity
6
+ // (SHARED_LINKS there: settings.json with its allow list and hooks, CLAUDE.md, rules, skills, ...) is shared
7
+ // with the default ~/.claude, so the account reads what the default reads. A named Codex account
8
+ // (lib/codex-accounts.js) shares config.toml, AGENTS.md and prompts/ of the default CODEX_HOME through the same
9
+ // functions: nothing here knows a provider, only a default's entry (`source`) and an account's name for it
10
+ // (`target`).
11
+ //
12
+ // A folder is shared by a link to it: a symbolic link on macOS / Linux, a junction on Windows (a junction needs
13
+ // no administrator rights and no Developer Mode). A FILE cannot be shared by a junction: Windows makes a junction
14
+ // to a file, and it opens as a broken folder, so Claude Code in the account reads no settings.json at all (every
15
+ // tool asks again). Older SynaBun versions did exactly that. A file is shared, in this order, by:
16
+ // 1. a symbolic link (macOS / Linux always; Windows only with Developer Mode or as administrator),
17
+ // 2. a hard link (Windows without either: no privilege needed, the same file under two names, same volume),
18
+ // 3. a copy (another volume, or a file system without hard links).
19
+ // A hard link holds only while every writer writes the file in place. Claude Code writes settings.json, and
20
+ // Codex its config.toml, by writing a new file and renaming it over the old one, which leaves the two names two
21
+ // files. So a hard link or a copy is kept in step by syncSharedFile(): at a start, before every launch of the
22
+ // account, after SynaBun writes the default's file: the name that changed since the two were last in step is the
23
+ // content, the other name is linked to it again; when both changed, the newer wins and the other is kept in the
24
+ // account's backups/.
25
+ //
26
+ // Never removes anything but a link (lstat says so), a hard-linked / copied file SynaBun itself made and
27
+ // recorded, or, only when a caller says the account's file is SynaBun's own doing (`adopt`), that file after a
28
+ // copy of it is in the account's backups/; never follows a link to remove; never touches the default's file
29
+ // except to write the newer content into it, in place when it has other names.
30
+
31
+ import { createHash } from 'node:crypto';
32
+ import * as nodeFs from 'node:fs';
33
+ import { resolve } from 'node:path';
34
+
35
+ /** The entries of Claude's SHARED_LINKS that are files (everything else is a folder). */
36
+ export const SHARED_FILE_NAMES = Object.freeze(['settings.json', 'CLAUDE.md', 'keybindings.json']);
37
+
38
+ const code = (error) => (error && typeof error.code === 'string' ? error.code : '');
39
+ const sha = (buffer) => createHash('sha256').update(buffer).digest('hex');
40
+ function digestOf(fs, path) { try { return sha(fs.readFileSync(path)); } catch { return null; } }
41
+
42
+ /** Is `path` a link (a symbolic link, or a junction: Node reports both as one)? */
43
+ function isLink(fs, path) {
44
+ try { return fs.lstatSync(path).isSymbolicLink(); } catch { return false; }
45
+ }
46
+
47
+ /** Does `path` read as a regular file (following a link)? */
48
+ function readsAsFile(fs, path) {
49
+ try {
50
+ if (!fs.statSync(path).isFile()) return false;
51
+ fs.readFileSync(path);
52
+ return true;
53
+ } catch { return false; }
54
+ }
55
+
56
+ /** The same file under both names (device and file index / inode)? */
57
+ export function sameFile(fs, a, b) {
58
+ try {
59
+ const x = fs.statSync(a, { bigint: true });
60
+ const y = fs.statSync(b, { bigint: true });
61
+ return x.dev === y.dev && x.ino === y.ino && x.ino !== 0n;
62
+ } catch { return false; }
63
+ }
64
+
65
+ /** Remove a link without touching what it points at. A junction on Windows is a folder to rmdir. */
66
+ function removeLink(fs, path) {
67
+ try { fs.unlinkSync(path); return; } catch (error) {
68
+ if (!['EPERM', 'EISDIR', 'EACCES'].includes(code(error))) throw error;
69
+ }
70
+ fs.rmdirSync(path);
71
+ }
72
+
73
+ /**
74
+ * Write `text` to the file at `path` so every name of it reads the new content: in place when the file has
75
+ * other names (a hard link of a named account), else a new file renamed over it (atomic).
76
+ */
77
+ export function writeKeepingLinks(fs, path, text) {
78
+ let real = path;
79
+ try { real = fs.realpathSync(path); } catch {}
80
+ let names = 1;
81
+ try { names = Number(fs.statSync(real).nlink) || 1; } catch {}
82
+ if (names > 1) { fs.writeFileSync(real, text); return; }
83
+ const tmp = `${real}.tmp-${process.pid}-${Date.now().toString(36)}`;
84
+ try {
85
+ fs.writeFileSync(tmp, text);
86
+ fs.renameSync(tmp, real);
87
+ } catch (error) {
88
+ try { fs.unlinkSync(tmp); } catch {}
89
+ throw error;
90
+ }
91
+ }
92
+
93
+ /**
94
+ * Share the file `source` as `target` (which must not exist). Returns how: 'symlink' | 'hardlink' | 'copy'.
95
+ * Throws when none of them works.
96
+ */
97
+ export function linkSharedFile({ source, target, platform = process.platform, fs = nodeFs }) {
98
+ try {
99
+ fs.symlinkSync(source, target, platform === 'win32' ? 'file' : undefined);
100
+ if (platform !== 'win32' || readsAsFile(fs, target)) return 'symlink';
101
+ removeLink(fs, target);
102
+ } catch (error) {
103
+ // Without the right to make symbolic links (Windows: no Developer Mode, not elevated) or where the file
104
+ // system has none: the next way. Anything else (the folder is gone, no space) is a real failure.
105
+ if (!['EPERM', 'EACCES', 'ENOSYS', 'ENOTSUP', 'EOPNOTSUPP', 'EINVAL'].includes(code(error))) throw error;
106
+ }
107
+ // A default that is itself a link (dotfiles, a synced folder): the file behind it is the one shared.
108
+ let real = source;
109
+ try { real = fs.realpathSync(source); } catch {}
110
+ try {
111
+ fs.linkSync(real, target);
112
+ return 'hardlink';
113
+ } catch (error) {
114
+ if (!['EXDEV', 'EPERM', 'EACCES', 'ENOSYS', 'ENOTSUP', 'EOPNOTSUPP', 'EMLINK'].includes(code(error))) throw error;
115
+ }
116
+ fs.copyFileSync(real, target, fs.constants?.COPYFILE_EXCL ?? 1);
117
+ return 'copy';
118
+ }
119
+
120
+ /** Share the folder `source` as `target`: a junction on Windows, a symbolic link elsewhere. */
121
+ export function linkSharedFolder({ source, target, platform = process.platform, fs = nodeFs }) {
122
+ fs.symlinkSync(source, target, platform === 'win32' ? 'junction' : undefined);
123
+ return platform === 'win32' ? 'junction' : 'symlink';
124
+ }
125
+
126
+ /**
127
+ * Keep `content`, the losing side of `target`, in the account's backups folder as
128
+ * `<name>.synabun-<side>-<time>` and return its path. A backup of that name and side with the same content is
129
+ * already enough (an adoption that could not finish, a file in use, made it, and the next start tries again):
130
+ * it is returned and nothing is written. Otherwise the file is created exclusively under the first free name
131
+ * (`-<time>`, then `-<time>-2`, ...): two backups made in the same millisecond never meet, and an earlier
132
+ * backup is never overwritten.
133
+ */
134
+ function keepBackup(fs, backupDir, target, side, now, content) {
135
+ fs.mkdirSync(backupDir, { recursive: true });
136
+ const prefix = `${target.split(/[\\/]/).pop()}.synabun-${side}-`;
137
+ let existing = [];
138
+ try { existing = fs.readdirSync(backupDir).filter((name) => name.startsWith(prefix)).sort(); } catch {}
139
+ for (const name of existing) {
140
+ const path = resolve(backupDir, name);
141
+ try {
142
+ if (fs.lstatSync(path).isFile() && fs.readFileSync(path).equals(content)) return path;
143
+ } catch {}
144
+ }
145
+ const stamp = new Date(now()).toISOString().replace(/[:.]/g, '-');
146
+ for (let n = 1; ; n += 1) {
147
+ const path = resolve(backupDir, `${prefix}${stamp}${n === 1 ? '' : `-${n}`}`);
148
+ try {
149
+ // Owner-only: a config.toml can hold an MCP server's token.
150
+ fs.writeFileSync(path, content, { flag: 'wx', mode: 0o600 });
151
+ return path;
152
+ } catch (error) {
153
+ if (code(error) !== 'EEXIST' || n >= 1000) throw error;
154
+ }
155
+ }
156
+ }
157
+
158
+ /**
159
+ * Put one shared file of an account in order. `recorded` is SynaBun's note of how it shared the file before,
160
+ * `{ how: 'hardlink' | 'copy', sha }` (sha: the content the two names last had in common), or undefined.
161
+ * Returns `{ how, action, backup, sha }`:
162
+ * how — what the target is now: 'symlink' | 'hardlink' | 'copy' | 'own' (a file of the account's own,
163
+ * left alone) | null (nothing to share: the default has no such file, or the account has none
164
+ * and `linkMissing` is false)
165
+ * action — 'none' | 'linked' (it was missing) | 'repaired' (a link that does not read as a file was
166
+ * replaced) | 'relinked' (a hard link two writes apart, linked again) | 'synced' (a copy updated) |
167
+ * 'adopted' (with `adopt`: a file nothing recorded was replaced by the default's)
168
+ * backup — where content that lost was kept (when both names changed since they were last in step, and the
169
+ * account's own file when it was adopted and differed)
170
+ * sha — for a hard link or a copy, the content both names have now (the next `recorded.sha`)
171
+ * `adopt` is for a file SynaBun knows it left in the account by a failed link (a named Codex account's
172
+ * config.toml on Windows): the default's content always wins there, never the newer one, because the
173
+ * account's file was never the shared one.
174
+ */
175
+ export function syncSharedFile({
176
+ source, target, recorded = undefined, platform = process.platform, fs = nodeFs, now = Date.now, backupDir = null,
177
+ linkMissing = true, adopt = false,
178
+ }) {
179
+ const result = (how, action, backup = null) => ({
180
+ how, action, backup, sha: how === 'hardlink' || how === 'copy' ? digestOf(fs, source) : null,
181
+ });
182
+ if (!readsAsFile(fs, source)) return result(null, 'none');
183
+ let present = true;
184
+ try { fs.lstatSync(target); } catch { present = false; }
185
+ if (!present) {
186
+ // Made when the account is made; later, a name the owner removed from the account stays removed.
187
+ if (!linkMissing) return result(null, 'none');
188
+ return result(linkSharedFile({ source, target, platform, fs }), 'linked');
189
+ }
190
+
191
+ if (isLink(fs, target)) {
192
+ if (readsAsFile(fs, target)) return result('symlink', 'none');
193
+ // A link that does not read as a file: on Windows, the junction to settings.json SynaBun made before.
194
+ // Elsewhere a broken link is the owner's (left alone).
195
+ if (platform !== 'win32') return result('own', 'none');
196
+ removeLink(fs, target);
197
+ return result(linkSharedFile({ source, target, platform, fs }), 'repaired');
198
+ }
199
+
200
+ if (sameFile(fs, source, target)) return result('hardlink', 'none');
201
+ // A file SynaBun did not make (no record) is the account's own choice: left alone, unless the caller knows
202
+ // it is what a link that could not be made left behind.
203
+ const was = recorded?.how;
204
+ if (was !== 'hardlink' && was !== 'copy') {
205
+ if (!adopt) return result('own', 'none');
206
+ let kept = null;
207
+ const own = fs.readFileSync(target);
208
+ if (!fs.readFileSync(source).equals(own)) {
209
+ if (!backupDir) return result('own', 'none');
210
+ kept = keepBackup(fs, backupDir, target, 'account', now, own);
211
+ }
212
+ fs.unlinkSync(target);
213
+ return result(linkSharedFile({ source, target, platform, fs }), 'adopted', kept);
214
+ }
215
+
216
+ const a = fs.readFileSync(source);
217
+ const b = fs.readFileSync(target);
218
+ let backup = null;
219
+ if (!a.equals(b)) {
220
+ const base = typeof recorded.sha === 'string' ? recorded.sha : null;
221
+ const aChanged = !base || sha(a) !== base;
222
+ const bChanged = !base || sha(b) !== base;
223
+ // The side that changed since the two were last in step wins; when both did, the newer one.
224
+ const accountWins = bChanged && (!aChanged || fs.statSync(target).mtimeMs > fs.statSync(source).mtimeMs);
225
+ if (aChanged && bChanged && backupDir) {
226
+ backup = keepBackup(fs, backupDir, target, accountWins ? 'default' : 'account', now, accountWins ? a : b);
227
+ }
228
+ // The newer content goes into the default's file (in place when other accounts share it too).
229
+ if (accountWins) writeKeepingLinks(fs, source, b);
230
+ if (was === 'copy') {
231
+ if (!accountWins) writeKeepingLinks(fs, target, a);
232
+ return result('copy', 'synced', backup);
233
+ }
234
+ } else if (was === 'copy') {
235
+ return result('copy', 'none');
236
+ }
237
+ // The two names are one file again (a hard link where possible, else a fresh copy).
238
+ fs.unlinkSync(target);
239
+ return result(linkSharedFile({ source, target, platform, fs }), 'relinked', backup);
240
+ }
241
+
242
+ /** The folder under an account's home where content that lost a sync is kept. */
243
+ export function sharedBackupDir(home) { return resolve(home, 'backups'); }
244
+
245
+ /** Do two records of how an account's files are shared (`{ [name]: { how, sha } }`) say the same? */
246
+ export function sameSharedRecords(a = {}, b = {}) {
247
+ const keys = new Set([...Object.keys(a), ...Object.keys(b)]);
248
+ for (const key of keys) if (a[key]?.how !== b[key]?.how || a[key]?.sha !== b[key]?.sha) return false;
249
+ return true;
250
+ }
251
+
252
+ /**
253
+ * Put the shared entries of one account in order: every name of `names` (in that order) that the default has,
254
+ * a name of `fileNames` through syncSharedFile(), any other as a folder link made when it is missing.
255
+ * `recorded` is the account's record (`{ [name]: { how, sha } }`); only a hard link or a copy is recorded,
256
+ * because only those are kept in step by SynaBun. `adopt` lists the file names an unrecorded file of the
257
+ * account is replaced for (see syncSharedFile). Never throws: a name that fails is logged, listed in `failed`
258
+ * and keeps its record. Returns `{ linked, repaired, failed, modes }` (`modes`: the record to keep now).
259
+ */
260
+ export function syncSharedEntries({
261
+ defaultHome, home, names, fileNames = [], recorded = {}, linkMissing = true, adopt = [],
262
+ platform = process.platform, fs = nodeFs, now = Date.now, log = () => {}, tag = 'accounts',
263
+ }) {
264
+ const linked = [];
265
+ const repaired = [];
266
+ const failed = [];
267
+ const modes = {};
268
+ const nothing = { how: null, action: 'none', backup: null };
269
+ const entry = (name) => {
270
+ const source = resolve(defaultHome, name);
271
+ const target = resolve(home, name);
272
+ if (fileNames.includes(name)) {
273
+ return syncSharedFile({
274
+ source, target, recorded: recorded[name], platform, fs, now, backupDir: sharedBackupDir(home), linkMissing,
275
+ adopt: adopt.includes(name),
276
+ });
277
+ }
278
+ if (!fs.existsSync(source)) return nothing;
279
+ try { fs.lstatSync(target); return { how: 'link', action: 'none', backup: null }; } catch {}
280
+ if (!linkMissing) return nothing;
281
+ return { how: linkSharedFolder({ source, target, platform, fs }), action: 'linked', backup: null };
282
+ };
283
+ for (const name of names) {
284
+ try {
285
+ const result = entry(name);
286
+ if (result.how === 'hardlink' || result.how === 'copy') modes[name] = { how: result.how, sha: result.sha };
287
+ else if (result.how === 'own' && recorded[name]) modes[name] = recorded[name];
288
+ if (result.action === 'linked') linked.push(name);
289
+ else if (result.action !== 'none') repaired.push(name);
290
+ if (result.action === 'repaired') log(tag, `${name} of ${home} was a link that does not open as a file (a junction): shared again as a ${result.how}`);
291
+ else if (result.action === 'adopted') log(tag, `${name} of ${home} was a file of its own, left where a link could not be made: it is the default's again, shared as a ${result.how}${result.backup ? `; what it held is kept as ${result.backup}` : ''}`);
292
+ else if (result.backup) log(tag, `${name} of ${home} and the default's both changed since they were last in step: the newer was kept, the other saved as ${result.backup}`);
293
+ } catch (error) {
294
+ log(tag, `link ${name} failed: ${error?.message || error}`);
295
+ failed.push(name);
296
+ if (recorded[name]) modes[name] = recorded[name];
297
+ }
298
+ }
299
+ return { linked, repaired, failed, modes };
300
+ }
301
+
@@ -7,8 +7,10 @@
7
7
  // session history, plugins AND credentials under CLAUDE_CONFIG_DIR (on macOS
8
8
  // the Keychain entry is keyed to that directory too), so pointing a spawn at a
9
9
  // different directory switches the logged-in account. Shared, non-identity
10
- // resources are symlinked back to ~/.claude so skills/commands/settings stay in
11
- // sync; identity-bearing files stay isolated.
10
+ // resources are linked back to ~/.claude so skills/commands/settings stay in
11
+ // sync; identity-bearing files stay isolated. How a file and a folder are linked
12
+ // on each system (and kept in step where a link cannot be made) is
13
+ // lib/claude-account-links.js.
12
14
  //
13
15
  // Default follows CLAUDE_CONFIG_DIR when set, otherwise ~/.claude.
14
16
  //
@@ -23,11 +25,12 @@
23
25
  // launchFor() is the one place a Claude Code process gets its credential.
24
26
 
25
27
  import {
26
- existsSync, lstatSync, mkdirSync, readFileSync, renameSync, rmSync, statSync, symlinkSync, writeFileSync,
28
+ existsSync, mkdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync,
27
29
  } from 'node:fs';
28
30
  import { dirname, resolve } from 'node:path';
29
31
  import { homedir } from 'node:os';
30
32
  import { readClaudeProfileApiKey, saveClaudeProfileApiKey, clearClaudeProfileApiKey } from './claude-profile-api-key.js';
33
+ import { SHARED_FILE_NAMES, sameSharedRecords, syncSharedEntries } from './claude-account-links.js';
31
34
 
32
35
  export const DEFAULT_ACCOUNT_ID = 'default';
33
36
  // `rules` carries SynaBun's rules file (rules/synabun.md) to accounts created
@@ -134,6 +137,9 @@ export function createClaudeAccounts({
134
137
  log = () => {},
135
138
  now = Date.now,
136
139
  pollIntervalMs = 2000,
140
+ platform = process.platform,
141
+ // The file system the shared links are made with (node:fs; a test stands in for Windows rights).
142
+ linkFs = undefined,
137
143
  // async (id) => Claude Code's own `auth status --json` for that account
138
144
  // ({ loggedIn, email, orgName, subscriptionType, authMethod }), or null.
139
145
  readNativeStatus = null,
@@ -296,6 +302,8 @@ export function createClaudeAccounts({
296
302
  if (!profile || !profile.home) {
297
303
  return { ok: false, accountId: wanted, code: 'account_unavailable', message: 'That Claude account is no longer set up in SynaBun.' };
298
304
  }
305
+ // The account reads the default's settings (its allow list included): in step before every launch.
306
+ if (wanted !== DEFAULT_ACCOUNT_ID) syncShared(wanted);
299
307
  const { row, key } = describeProfile(profile, data);
300
308
  const launchEnv = {};
301
309
  if (wanted !== DEFAULT_ACCOUNT_ID) launchEnv.CLAUDE_CONFIG_DIR = profile.home;
@@ -403,23 +411,40 @@ export function createClaudeAccounts({
403
411
  for (const listener of [...listeners]) { try { listener({ accountId, ...extra }); } catch {} }
404
412
  }
405
413
 
406
- function linkShared(home) {
407
- const linked = [];
408
- for (const name of SHARED_LINKS) {
409
- const source = resolve(defaultHome, name);
410
- const target = resolve(home, name);
411
- if (!existsSync(source)) continue;
412
- try {
413
- if (lstatSync(target)) continue;
414
- } catch {}
415
- try {
416
- symlinkSync(source, target, process.platform === 'win32' ? 'junction' : undefined);
417
- linked.push(name);
418
- } catch (error) {
419
- log('claude-accounts', `link ${name} failed: ${error?.message || error}`);
414
+ // The shared entries of one account put in order (lib/claude-account-links.js). A file shared by a hard link
415
+ // or a copy is recorded on the account's row (`shared`), because only those are kept in step by SynaBun.
416
+ function linkShared(home, recordedModes = {}, { linkMissing = true } = {}) {
417
+ return syncSharedEntries({
418
+ defaultHome, home, names: SHARED_LINKS, fileNames: SHARED_FILE_NAMES, recorded: recordedModes, linkMissing,
419
+ platform, fs: linkFs, now, log, tag: 'claude-accounts',
420
+ });
421
+ }
422
+ /**
423
+ * Put the shared entries of one account (or every named account) in order (a missing one linked only with
424
+ * `linkMissing`, which only making the account asks for), a junction to a file (Windows, made by an older SynaBun)
425
+ * replaced, a hard link or a copy two writes apart brought back in step.
426
+ * Never throws; returns what it did per account.
427
+ */
428
+ function syncShared(id = null, { linkMissing = false } = {}) {
429
+ const results = [];
430
+ try {
431
+ const data = load();
432
+ let changed = false;
433
+ for (const account of data.accounts) {
434
+ if (id && account.id !== id) continue;
435
+ if (!account.home || !existsSync(account.home)) continue;
436
+ const result = linkShared(account.home, account.shared || {}, { linkMissing });
437
+ if (!sameSharedRecords(account.shared || {}, result.modes)) {
438
+ if (Object.keys(result.modes).length) account.shared = result.modes; else delete account.shared;
439
+ changed = true;
440
+ }
441
+ results.push({ id: account.id, linked: result.linked, repaired: result.repaired });
420
442
  }
443
+ if (changed) save(data);
444
+ } catch (error) {
445
+ log('claude-accounts', `shared files check failed: ${error?.message || error}`);
421
446
  }
422
- return linked;
447
+ return results;
423
448
  }
424
449
  function seedClaudeJson(home) {
425
450
  const target = resolve(home, '.claude.json');
@@ -437,7 +462,7 @@ export function createClaudeAccounts({
437
462
  if (!account) throw new ClaudeAccountError('ACCOUNT_NOT_FOUND', `Claude account not found: ${id}`, 404);
438
463
  mkdirSync(resolve(account.home, 'projects'), { recursive: true });
439
464
  mkdirSync(resolve(account.home, 'todos'), { recursive: true });
440
- const linked = linkShared(account.home);
465
+ const { linked } = syncShared(wanted, { linkMissing: true })[0] || { linked: [] };
441
466
  const seededJson = seedClaudeJson(account.home);
442
467
  return { home: account.home, linked, seededJson };
443
468
  }
@@ -535,7 +560,7 @@ export function createClaudeAccounts({
535
560
  list, listForClient, describe, describeForClient, profileFor, readApiKey, saveApiKey, clearApiKey, get, find, homeFor, envFor,
536
561
  launchFor, unusableReason, setMode, noteNativeStatus, forgetNativeStatus, noteSubscriptionSignIn, setNativeStatusReader,
537
562
  refreshStatus, stale, subscribe,
538
- create, rename, remove, seedHome, recordIdentity, watchLogin, loginCommand,
563
+ create, rename, remove, seedHome, syncShared, recordIdentity, watchLogin, loginCommand,
539
564
  readIdentity: (id) => (id === DEFAULT_ACCOUNT_ID ? readClaudeIdentity(defaultHome, defaultConfigFile) : readClaudeIdentity(homeFor(id))),
540
565
  };
541
566
  }