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
@@ -0,0 +1,620 @@
1
+ // ═══════════════════════════════════════════
2
+ // SynaBun Neural Interface — 3D Variant: the app behind the loading overlay
3
+ // ═══════════════════════════════════════════
4
+ //
5
+ // main.js paints the loading overlay from about twenty modules, then imports this file. Everything here used to be
6
+ // in main.js and runs in the same order: the help section, the map, the event bus, the shared UI's init functions
7
+ // (initLoading excepted, which main.js ran first, as before) and boot(). The overlay hides only when boot() says so,
8
+ // so the page the user first sees is the same page.
9
+ //
10
+ // The side panels (sidepanel-lazy.js) and the Settings window (ui-settings-entry.js) are not imported here: their
11
+ // facades load them on first use or in idle time after the page is shown.
12
+
13
+ // ── Storage (self-hydrating — importing it populates the cache) ──
14
+ import { storage } from '../../shared/storage.js';
15
+ import { posStore } from '../../shared/node-positions-store.js';
16
+
17
+ // ── Shared foundation ──
18
+ import { state, emit, on } from '../../shared/state.js';
19
+ import { registerHelpSection } from '../../shared/registry.js';
20
+ import { normalizeNodes } from '../../shared/utils.js';
21
+ import { loadMemoryList } from '../../shared/memory-list.js';
22
+ import { FOCUS_BOARD_WAIT_MS, mapToggleAction, settleWithin } from './boot-reveal.js';
23
+ import { KEYS } from '../../shared/constants.js';
24
+ import { t } from '../../shared/i18n.js';
25
+
26
+ // ── Shared UI modules (side-effect: each registers its own event listeners) ──
27
+ import { initTooltip } from '../../shared/ui-tooltip.js';
28
+ import { initPanelSystem, initPinToggle, clampPanelsToViewport } from '../../shared/ui-panels.js';
29
+ import { showLoadingError, hideLoading, rememberHealth } from '../../shared/ui-loading.js';
30
+ import { initNavbar } from '../../shared/ui-navbar.js';
31
+ import { initMenubar, closeMenubar } from '../../shared/ui-menubar.js';
32
+ import { initSearch, clearSearch } from '../../shared/ui-search.js';
33
+ import { buildCategorySidebar, initSidebar, loadCategories } from '../../shared/ui-sidebar.js';
34
+ import { openMemoryCard, restoreOpenCards, initDetailPanel, setDetailCallbacks } from '../../shared/ui-detail.js';
35
+ import { initSettings } from '../../shared/ui-settings-entry.js';
36
+ import { restoreInterfaceConfig, restoreSkin, loadIfaceConfig } from '../../shared/iface-config.js';
37
+ import { initTrash } from '../../shared/ui-trash.js';
38
+ import { initBookmarks } from '../../shared/ui-bookmarks.js';
39
+ import { initResume } from '../../shared/ui-resume.js';
40
+ import { initHelp } from '../../shared/ui-help.js';
41
+ import { initMultiSelect, clearMultiSelect } from '../../shared/ui-multiselect.js';
42
+ import { updateStats, initStats } from '../../shared/ui-stats.js';
43
+ import { initExplorer } from '../../shared/ui-explorer.js';
44
+ import { initFileExplorer } from '../../shared/ui-file-explorer.js';
45
+ import { initSkillsStudio } from '../../shared/ui-skills.js';
46
+ import { initAgentsStudio } from '../../shared/ui-agents.js';
47
+ import { initStyleGuide } from '../../shared/ui-styleguide.js';
48
+ import { initTerminal } from '../../shared/ui-terminal.js';
49
+ import { initLink } from '../../shared/ui-link.js';
50
+ import { initWhiteboard, whiteboardLoaded } from '../../shared/ui-whiteboard.js';
51
+ import { initCostWidget } from '../../shared/ui-cost-widget.js';
52
+ import { initGames, clearGameOnLoad } from '../../shared/ui-games.js';
53
+ import { initWorkspaces } from '../../shared/ui-workspaces.js';
54
+ import { initInvite } from '../../shared/ui-invite.js';
55
+ import { initSync, isGuest } from '../../shared/ui-sync.js';
56
+ import { startLaunchPrefetch } from '../../shared/launch-prefetch.js';
57
+ import { initKeybinds, registerAction } from '../../shared/ui-keybinds.js';
58
+ import { initTutorial } from '../../shared/ui-tutorial.js';
59
+ import { initImageGallery } from '../../shared/ui-image-gallery.js';
60
+ import { initScheduleQueue } from '../../shared/ui-schedule-queue.js';
61
+ import { initAutomationStudio } from '../../shared/ui-automation-studio.js';
62
+ import { initSchedulesStudio } from '../../shared/ui-schedules-studio.js';
63
+ import { initNativeLoopRouter } from '../../shared/ui-native-loop-router.js';
64
+ import { initCommandRunner } from '../../shared/ui-command-runner.js';
65
+ import { initAppContextMenu, openAppContextMenu, registerContextMenuArea } from '../../shared/ui-context-menu.js';
66
+ // The side panels' module-level listeners and their launch steps (sidepanel-lazy.js), before any init runs.
67
+ import '../../shared/sidepanel-lazy.js';
68
+
69
+ // ── Memory map (three.js itself loads only when the map is shown) ──
70
+ import { createLabelLayer } from './map-labels.js';
71
+ import { createMapView } from './map-view.js';
72
+ import { initMapControls } from './map-controls.js';
73
+ import { fetchMap, requestRebuild } from './map-data.js';
74
+
75
+
76
+ // ═══════════════════════════════════════════
77
+ // 2. HELP (translations and the shared HTML are main.js's)
78
+ // ═══════════════════════════════════════════
79
+
80
+ const helpRow = (keys, desc) =>
81
+ `<div class="help-row"><div class="help-keys">${keys.map((k) => `<span class="help-key">${k}</span>`).join('')}</div><span class="help-desc">${desc}</span></div>`;
82
+ registerHelpSection({
83
+ order: 50,
84
+ html: `<div class="help-section">
85
+ <div class="help-section-title">${t('map.help.title')}</div>
86
+ ${helpRow(['Drag'], t('map.help.orbit'))}
87
+ ${helpRow(['Right-drag'], t('map.help.pan'))}
88
+ ${helpRow(['Scroll'], t('map.help.zoom'))}
89
+ ${helpRow(['←', '→', '↑', '↓'], t('map.help.keysPan'))}
90
+ ${helpRow(['Shift', '←', '→'], t('map.help.keysOrbit'))}
91
+ ${helpRow(['Click'], t('map.help.open'))}
92
+ ${helpRow(['⌘/Ctrl', 'Click'], t('map.help.multi'))}
93
+ ${helpRow(['Click name'], t('map.help.flyTo'))}
94
+ ${helpRow(['H'], t('map.help.frameAll'))}
95
+ ${helpRow(['Esc'], t('map.help.clear'))}
96
+ <div class="help-row"><span class="help-desc">${t('map.help.legend')}</span></div>
97
+ </div>`,
98
+ });
99
+
100
+
101
+ // ═══════════════════════════════════════════
102
+ // 3. THE MAP
103
+ // ═══════════════════════════════════════════
104
+
105
+ let renderer = null;
106
+ let labels = null;
107
+ let view = null;
108
+ let mapInit = null;
109
+ let _vizEnabled = loadIfaceConfig().visualizationEnabled !== false;
110
+ let _inFocusMode = false;
111
+ let _bootComplete = false;
112
+ // Boot has decided whether it draws the map (from _vizEnabled); a toggle before that is boot's to read.
113
+ let _mapDecided = false;
114
+ // state.allNodes holds the whole memory list (boot or a reload put it there). Until then it is empty, never a part.
115
+ let _memoriesReady = false;
116
+ // The /api/map answer index.html asked for, while boot has not used it (a boot in Focus Mode never does).
117
+ let _bootMapP = null;
118
+ const _seenCategories = new Set();
119
+
120
+ function statusPill(container) {
121
+ let el = document.getElementById('map-status');
122
+ if (!el) {
123
+ el = document.createElement('div');
124
+ el.id = 'map-status';
125
+ container.appendChild(el);
126
+ }
127
+ return el;
128
+ }
129
+
130
+ function showMapMessage(text) {
131
+ const container = document.getElementById('graph-container');
132
+ if (!container) return;
133
+ const el = statusPill(container);
134
+ el.textContent = text;
135
+ el.classList.add('visible', 'error');
136
+ }
137
+
138
+ /** Create renderer, labels, view and input once; three.js is fetched here. */
139
+ function ensureMap() {
140
+ if (!mapInit) {
141
+ mapInit = (async () => {
142
+ const container = document.getElementById('graph-container');
143
+ const { createMapRenderer } = await import('./map-renderer.js');
144
+ labels = createLabelLayer(container);
145
+ let v = null;
146
+ renderer = createMapRenderer(container, {
147
+ onFrame: (now) => (v ? v.drawLabels(now) : false),
148
+ onSettle: () => v?.onSettle(),
149
+ onResize: (w, h) => labels.resize(w, h),
150
+ onMorphEnd: () => v?.onMorphEnd(),
151
+ });
152
+ labels.resize(renderer.size.width, renderer.size.height);
153
+ v = createMapView({ renderer, labels, statusEl: statusPill(container), onMissingNodes: (ids) => addMissingMemories(ids) });
154
+ initMapControls({ renderer, view: v, labels, onContextMenu: openMapMenu });
155
+ view = v;
156
+ applyRunState();
157
+ syncMapMenuChecks();
158
+ return v;
159
+ })();
160
+ mapInit.catch((err) => {
161
+ console.error('[map] could not start:', err);
162
+ showMapMessage(t('map.status.noWebgl'));
163
+ });
164
+ }
165
+ return mapInit;
166
+ }
167
+
168
+ /** The map renders only while the visualisation is on and focus mode is off. */
169
+ function applyRunState() {
170
+ if (!view) return;
171
+ if (_vizEnabled && !_inFocusMode) view.resume();
172
+ else view.pause();
173
+ }
174
+
175
+
176
+ // ═══════════════════════════════════════════
177
+ // 4. DATA
178
+ // ═══════════════════════════════════════════
179
+
180
+ const prefetch = window.__synPrefetch || {};
181
+
182
+ /** What index.html / main.js started for the boot, taken once: a boot the overlay retries asks again. */
183
+ function takePrefetch(key) {
184
+ const value = prefetch[key] || null;
185
+ prefetch[key] = null;
186
+ return value;
187
+ }
188
+
189
+ /** A request index.html started before any module loaded (a fetch() promise), taken once. */
190
+ function takeEarlyFetch(url) {
191
+ const value = prefetch.early?.[url] || null;
192
+ if (prefetch.early) prefetch.early[url] = null;
193
+ return value;
194
+ }
195
+
196
+ function activateNewCategories(names) {
197
+ for (const name of names) {
198
+ if (_seenCategories.has(name)) continue;
199
+ _seenCategories.add(name);
200
+ state.activeCategories.add(name);
201
+ }
202
+ }
203
+
204
+ // Memories the map already shows but the page has no data for (written through
205
+ // MCP, which never broadcasts). A few are fetched one by one; the 23 MB list is
206
+ // re-downloaded only when many are missing, and at most once a minute.
207
+ const _missingAsked = new Map(); // id → when it was last requested
208
+ let _lastFullReload = 0;
209
+ async function addMissingMemories(ids) {
210
+ const now = Date.now();
211
+ if (!ids) {
212
+ if (now - _lastFullReload < 60_000) return;
213
+ _lastFullReload = now;
214
+ scheduleReload();
215
+ return;
216
+ }
217
+ const want = ids.filter((id) => now - (_missingAsked.get(id) || 0) > 60_000);
218
+ if (!want.length) return;
219
+ for (const id of want) _missingAsked.set(id, now);
220
+ const fetched = [];
221
+ for (let i = 0; i < want.length; i += 6) {
222
+ const batch = await Promise.all(want.slice(i, i + 6).map((id) =>
223
+ fetch(`/api/memory/${encodeURIComponent(id)}`).then((r) => (r.ok ? r.json() : null)).catch(() => null)));
224
+ for (const m of batch) if (m?.id && m.payload) fetched.push({ id: m.id, payload: m.payload });
225
+ }
226
+ const known = new Set(state.allNodes.map((n) => n.id));
227
+ const fresh = normalizeNodes(fetched).filter((n) => !known.has(n.id));
228
+ if (!fresh.length) return;
229
+ state.allNodes = [...fresh, ...state.allNodes]; // the list is newest-first
230
+ const presentCats = new Set(state.allNodes.map((n) => n.payload.category));
231
+ activateNewCategories([...presentCats]);
232
+ buildCategorySidebar(presentCats);
233
+ view?.hydrate();
234
+ view?.refreshVisibility();
235
+ updateStats();
236
+ }
237
+
238
+ let _reloadTimer = null;
239
+ let _reloading = null;
240
+ function scheduleReload() {
241
+ if (_reloadTimer) return;
242
+ _reloadTimer = setTimeout(() => { _reloadTimer = null; reloadMemories(); }, 300);
243
+ }
244
+
245
+ /** Refetch the memory list (slim payload) and the map (304 when unchanged). */
246
+ async function reloadMemories() {
247
+ if (_reloading) return _reloading;
248
+ _reloading = (async () => {
249
+ try {
250
+ const data = await loadMemoryList({ concurrency: 2 });
251
+ if (data?.error) throw data.error;
252
+ state.allNodes = normalizeNodes(data.nodes);
253
+ state.allLinks = data.links || [];
254
+ _memoriesReady = true;
255
+ await loadCategories();
256
+ const presentCats = new Set(state.allNodes.map((n) => n.payload.category));
257
+ activateNewCategories([...presentCats, ...state.allCategoryNames]);
258
+ buildCategorySidebar(presentCats);
259
+ view?.hydrate();
260
+ view?.refreshColors();
261
+ view?.refreshVisibility();
262
+ view?.refetch();
263
+ updateStats();
264
+ } catch (err) {
265
+ console.error('data:reload failed:', err);
266
+ } finally {
267
+ _reloading = null;
268
+ }
269
+ })();
270
+ return _reloading;
271
+ }
272
+
273
+ /** Old 3D renderer state that nothing reads any more. Idempotent. */
274
+ function dropLegacy3dState() {
275
+ try {
276
+ posStore.removeItem(KEYS.NODE_POS_3D);
277
+ for (const key of ['neural-gfx-config', 'neural-gfx-preset', 'neural-cam-hud-pinned', 'neural-cam-hud-pos', 'synabun-layout-version']) {
278
+ storage.removeItem(key);
279
+ }
280
+ } catch {}
281
+ }
282
+
283
+
284
+ // ═══════════════════════════════════════════
285
+ // 5. EVENT BUS
286
+ // ═══════════════════════════════════════════
287
+
288
+ on('graph:navigate', ({ node }) => { if (node) view?.select(node.id, { fly: true }); });
289
+
290
+ on('node-selected', (node) => {
291
+ if (!node) return;
292
+ view?.select(node.id, { fly: true });
293
+ openMemoryCard(node);
294
+ });
295
+
296
+ on('search:apply', ({ ids, results } = {}) => view?.applySearch(ids, results));
297
+ on('search:clear', () => view?.clearSearch());
298
+
299
+ // A category toggle emits links:dirty immediately and graph:refresh 600 ms later.
300
+ on('links:dirty', () => view?.refreshVisibility());
301
+ on('graph:refresh', () => { view?.refreshVisibility(); updateStats(); });
302
+
303
+ const onCategoriesChanged = () => { view?.refreshColors(); view?.refreshVisibility(); };
304
+ on('categories-changed', onCategoriesChanged);
305
+ on('categories:changed', onCategoriesChanged);
306
+ on('graph:nodeThreeObject', () => view?.refreshColors()); // a category colour changed
307
+
308
+ on('data:reload', () => scheduleReload());
309
+ on('graph:reload', () => scheduleReload());
310
+
311
+ on('multiselect:cleared', () => view?.refreshVisibility());
312
+ on('detail:opened', () => view?.syncSelectionFromState());
313
+ on('detail:closed', () => view?.syncSelectionFromState());
314
+
315
+ on('layout:reset', () => view?.frameAll());
316
+ on('sync:map:updated', (msg) => view?.onServerUpdate(msg));
317
+
318
+ on('workspace:get-scene', (callback) => callback(view ? view.getScene() : { nodePositions: {}, camera: null }));
319
+ on('workspace:restore-scene', (scene) => view?.restoreScene(scene));
320
+
321
+ // Visualisation off / focus mode (whiteboard): zero frames, no input.
322
+ on('viz:toggle', (enabled) => {
323
+ _vizEnabled = !!enabled;
324
+ const action = mapToggleAction({ decided: _mapDecided, enabled: _vizEnabled, hasMap: !!mapInit });
325
+ if (action === 'start') startMapAfterBoot();
326
+ else if (action === 'apply') applyRunState();
327
+ });
328
+
329
+ /**
330
+ * The map, switched on after a boot in Focus Mode: the overlay is gone and the memory list may still be on its way.
331
+ * The map draws from /api/map alone; its titles, tooltips and the stats' visible flags come from the list, and
332
+ * only from the whole list: `hydrate` before it arrived would take every memory on the map for a removed one.
333
+ */
334
+ function startMapAfterBoot() {
335
+ ensureMap().then(async (v) => {
336
+ // index.html's answer while boot is still reading the list (it is seconds old at most), else a fresh one.
337
+ const early = _bootComplete ? null : _bootMapP;
338
+ _bootMapP = null;
339
+ let json = early ? await Promise.resolve(early).catch(() => null) : null;
340
+ if (!json) json = await fetchMap().catch(() => null);
341
+ if (!json) return;
342
+ if (!_memoriesReady) {
343
+ // As boot does when the map comes before the list: every category on, so no island starts hidden.
344
+ state.activeCategories = new Set([...state.allCategoryNames, ...(json.islands || []).map((i) => i.name)]);
345
+ }
346
+ v.applyMap(json, { morph: false });
347
+ if (_memoriesReady) v.hydrate();
348
+ v.refreshVisibility();
349
+ v.frameAll(0);
350
+ }).catch(() => {});
351
+ }
352
+ on('focus:enter', () => {
353
+ _inFocusMode = true;
354
+ state.hoveredNodeId = null;
355
+ applyRunState();
356
+ });
357
+ on('focus:exit', () => {
358
+ _inFocusMode = false;
359
+ applyRunState();
360
+ });
361
+
362
+
363
+ // ═══════════════════════════════════════════
364
+ // 6. DETAIL CARD CALLBACKS (the names ui-detail.js calls)
365
+ // ═══════════════════════════════════════════
366
+
367
+ setDetailCallbacks({
368
+ applyGraphData: () => {
369
+ view?.hydrate();
370
+ view?.syncFocusFromState();
371
+ view?.refreshVisibility();
372
+ },
373
+ updateStats: () => updateStats(),
374
+ buildCategorySidebar: (cats) => buildCategorySidebar(cats),
375
+ clearMultiSelect: () => clearMultiSelect(),
376
+ fetchTrashItems: () => emit('trash:refresh'),
377
+ refreshNodeAppearance: () => { view?.refreshColors(); view?.refreshVisibility(); },
378
+ });
379
+
380
+
381
+ // ═══════════════════════════════════════════
382
+ // 7. MAP MENU + KEYS
383
+ // ═══════════════════════════════════════════
384
+
385
+ const MAP_TOGGLES = { 'menu-map-neighbors': 'neighbors', 'menu-map-recency': 'recency', 'menu-map-grid': 'grid' };
386
+
387
+ function syncMapMenuChecks() {
388
+ const opts = view?.options;
389
+ if (!opts) return;
390
+ for (const [id, key] of Object.entries(MAP_TOGGLES)) document.getElementById(id)?.classList.toggle('active', !!opts[key]);
391
+ }
392
+
393
+ function wireMapMenu() {
394
+ const click = (id, fn) => {
395
+ const el = document.getElementById(id);
396
+ if (el) el.addEventListener('click', () => { closeMenubar(); fn(el); });
397
+ return el;
398
+ };
399
+ click('menu-map-frame-all', () => view?.frameAll());
400
+ for (const [id, key] of Object.entries(MAP_TOGGLES)) {
401
+ click(id, () => { if (!view) return; view.setOption(key, !view.options[key]); syncMapMenuChecks(); });
402
+ }
403
+ const rebuild = click('menu-map-rebuild', () => {
404
+ requestRebuild().catch((err) => console.warn('[map] rebuild failed:', err?.message || err));
405
+ });
406
+ const syncGuest = () => { if (rebuild) rebuild.style.display = isGuest() ? 'none' : ''; };
407
+ syncGuest();
408
+ on('session:info', syncGuest);
409
+ }
410
+
411
+ registerAction('map-frame-all', () => view?.frameAll());
412
+
413
+
414
+ // ═══════════════════════════════════════════
415
+ // 8. CONTEXT MENU (shared/ui-context-menu.js)
416
+ // ═══════════════════════════════════════════
417
+ // A right-click (no drag) on the map opens the app's menu with the map's part on top: a memory, a name on the
418
+ // map, or its empty space. The same functions as the map's clicks and Apps › Map.
419
+
420
+ const mapActions = {
421
+ frameAll: () => view?.frameAll(),
422
+ toggleOption: (key) => { if (!view) return; view.setOption(key, !view.options[key]); syncMapMenuChecks(); },
423
+ toggleSelect: (id) => view?.toggleMulti(id),
424
+ flyToIsland: (name) => view?.flyToIsland(name),
425
+ clearSearch: () => clearSearch(),
426
+ clearSelection: () => view?.clearSelection(),
427
+ };
428
+
429
+ /** The map's part of the menu for what a press resolved to (map-controls.js resolve), null before the map exists. */
430
+ function mapMenuArea(hit) {
431
+ if (!view?.map) return null;
432
+ if (hit && hit.i >= 0) {
433
+ const d = view.describe(hit.i);
434
+ if (d) {
435
+ const island = view.map.islands[view.map.islandOf[hit.i]]?.name || d.category;
436
+ return {
437
+ kind: 'memory',
438
+ memory: { id: d.id, onMap: true, island, selected: state.multiSelected.has(d.id) },
439
+ act: { ...mapActions, openMemory: () => view.clickPoint(hit.i) },
440
+ };
441
+ }
442
+ }
443
+ const label = hit?.label && hit.label.type !== 'memory' ? hit.label : null;
444
+ return {
445
+ kind: 'map',
446
+ map: { options: view.options, searching: view.searching, selected: !!view.selectedId, label, variant: '3d' },
447
+ act: { ...mapActions, flyToLabel: () => label && view.clickLabel(label) },
448
+ };
449
+ }
450
+
451
+ function openMapMenu({ clientX, clientY, hit }) {
452
+ openAppContextMenu({ x: clientX, y: clientY, target: renderer?.canvas || null, area: mapMenuArea(hit),
453
+ returnFocus: renderer?.canvas || null });
454
+ }
455
+
456
+ // From the keyboard (ContextMenu key, Shift+F10) on the focused map: the selected memory, else the map.
457
+ registerContextMenuArea({
458
+ id: 'memory-map',
459
+ match(el) {
460
+ if (!renderer || el !== renderer.canvas) return null;
461
+ const i = view?.selectedId ? view.map?.indexOf.get(view.selectedId) : undefined;
462
+ return mapMenuArea(i === undefined ? null : { i, label: null });
463
+ },
464
+ });
465
+
466
+
467
+ // ═══════════════════════════════════════════
468
+ // 9. BOOT
469
+ // ═══════════════════════════════════════════
470
+
471
+ export async function boot() {
472
+ try {
473
+ restoreInterfaceConfig();
474
+ restoreSkin();
475
+ dropLegacy3dState();
476
+
477
+ try {
478
+ const healthRes = await (takeEarlyFetch('/api/health') || fetch('/api/health'));
479
+ const health = await healthRes.json();
480
+ rememberHealth(health);
481
+ if (!health.ok) {
482
+ const messages = {
483
+ db_missing: [t('loading.health.databaseUnreachable.title'), health.detail || t('loading.health.databaseUnreachable.sub')],
484
+ db_error: [t('loading.health.databaseUnreachable.title'), health.detail || t('loading.health.databaseUnreachable.sub')],
485
+ remote_unreachable: [t('loading.health.remoteUnreachable.title'), health.detail || t('loading.health.remoteUnreachable.sub')],
486
+ auth_error: [t('loading.health.authError.title'), health.detail || t('loading.health.authError.sub')],
487
+ };
488
+ const [title, sub] = messages[health.reason] || [t('loading.health.connectionError.title'), health.detail || t('loading.health.connectionError.sub')];
489
+ showLoadingError(title, sub, !!health.canAutoStart);
490
+ return;
491
+ }
492
+ } catch {
493
+ // /api/health failed — continue to try the data
494
+ }
495
+
496
+ // The whole memory list, read page by page since main.js ran (shared/memory-list.js); never rejects.
497
+ const memoriesP = takePrefetch('memories') || loadMemoryList({ concurrency: 2 });
498
+ const mapP = takePrefetch('map') || fetchMap().catch(() => null);
499
+
500
+ // Categories first, so the first frame already has the sidebar's colours.
501
+ await loadCategories();
502
+
503
+ // From here a switch of the visualisation is the map's own business (viz:toggle), not boot's.
504
+ _mapDecided = true;
505
+ _bootMapP = _vizEnabled ? null : mapP;
506
+ if (_vizEnabled) {
507
+ try {
508
+ const [v, mapJson] = await Promise.all([ensureMap(), mapP]);
509
+ if (mapJson) {
510
+ state.activeCategories = new Set([...state.allCategoryNames, ...mapJson.islands.map((i) => i.name)]);
511
+ v.applyMap(mapJson, { morph: false });
512
+ v.frameAll(0);
513
+ hideLoading(150); // the map is up; the rest fills in behind it
514
+ } else {
515
+ showMapMessage(t('map.status.error'));
516
+ }
517
+ } catch {
518
+ // ensureMap already reported it; the rest of the app still works
519
+ }
520
+ } else {
521
+ // Focus Mode: the first view is the whiteboard (static background, saved board), and nothing shown there reads
522
+ // the memory list. The page shows once the board is drawn; the list fills in behind it, as it does behind the map.
523
+ await settleWithin(whiteboardLoaded(), FOCUS_BOARD_WAIT_MS);
524
+ hideLoading(150);
525
+ }
526
+
527
+ const data = await memoriesP;
528
+ if (data?.error) throw data.error;
529
+ try { performance.mark('synabun:memories-ready'); } catch {}
530
+ state.allNodes = normalizeNodes(data.nodes);
531
+ state.allLinks = data.links || [];
532
+ _memoriesReady = true;
533
+ _bootMapP = null;
534
+ const presentCats = new Set(state.allNodes.map((n) => n.payload.category));
535
+ state.activeCategories = new Set([...presentCats, ...state.allCategoryNames]);
536
+ for (const name of state.activeCategories) _seenCategories.add(name);
537
+ buildCategorySidebar(presentCats);
538
+ view?.hydrate();
539
+ view?.refreshVisibility();
540
+ updateStats();
541
+
542
+ emit('data-loaded', data);
543
+ restoreOpenCards();
544
+
545
+ // Recover a selected memory handed over by a legacy 2D tab
546
+ const switchNodeId = sessionStorage.getItem('neural-selected-node-switch');
547
+ if (switchNodeId) {
548
+ sessionStorage.removeItem('neural-selected-node-switch');
549
+ const node = state.allNodes.find((n) => n.id === switchNodeId);
550
+ if (node) {
551
+ openMemoryCard(node);
552
+ view?.select(node.id, { fly: true });
553
+ }
554
+ }
555
+
556
+ try { emit('trash:refresh'); } catch {}
557
+ hideLoading(400);
558
+ _bootComplete = true;
559
+ // Painted: what the windows, menus and Settings wait for is read now, in idle time (launch-prefetch.js).
560
+ startLaunchPrefetch({ isGuest });
561
+ } catch (err) {
562
+ console.error('Init error:', err);
563
+ const isNetworkError = err.message === 'Failed to fetch' || err.name === 'TypeError';
564
+ showLoadingError(
565
+ isNetworkError ? t('loading.serverOffline') : t('loading.connectionFailed'),
566
+ isNetworkError ? t('loading.serverNotRunning') : err.message,
567
+ false,
568
+ isNetworkError,
569
+ );
570
+ }
571
+ }
572
+
573
+
574
+ // ═══════════════════════════════════════════
575
+ // 10. INIT ALL SHARED UI SYSTEMS
576
+ // ═══════════════════════════════════════════
577
+
578
+ initKeybinds();
579
+ initTooltip();
580
+ initPanelSystem();
581
+ initPinToggle();
582
+ initNavbar();
583
+ initMenubar();
584
+ initSearch();
585
+ initSidebar();
586
+ initDetailPanel();
587
+ initSettings();
588
+ initTrash();
589
+ initBookmarks();
590
+ initResume();
591
+ initWorkspaces();
592
+ initInvite();
593
+ initSync();
594
+ initHelp();
595
+ initMultiSelect();
596
+ initStats();
597
+ initExplorer();
598
+ initFileExplorer();
599
+ initSkillsStudio();
600
+ initAgentsStudio();
601
+ initStyleGuide();
602
+ initAutomationStudio();
603
+ initSchedulesStudio();
604
+ initNativeLoopRouter();
605
+ initImageGallery();
606
+ initScheduleQueue();
607
+ initCommandRunner();
608
+ initTerminal();
609
+ initLink();
610
+ clearGameOnLoad();
611
+ initWhiteboard();
612
+ initCostWidget();
613
+ initGames();
614
+ initTutorial();
615
+ initAppContextMenu();
616
+ wireMapMenu();
617
+
618
+ window.addEventListener('resize', () => clampPanelsToViewport());
619
+
620
+ boot();
@@ -0,0 +1,47 @@
1
+ // SynaBun — when the 3D page shows itself, and what a map toggle does while the memory list is still being read
2
+ // (variant/3d/app.js boot). No imports, no DOM: tests/boot-reveal.test.mjs runs it under node.
3
+ //
4
+ // The page reads every memory before the views that need them are filled (sidebar counts, explorer, search, cards,
5
+ // the map's titles): 14 pages, 34 MB for 34,000 memories, 5 to 13 s. The overlay does not wait for that:
6
+ // - map on: it hides once the map is drawn from /api/map, which needs no memory;
7
+ // - Focus Mode (visualizationEnabled false): it hides once the whiteboard, Focus Mode's first view, has its saved
8
+ // board. Focus Mode hides the stats bar, the category sidebar, the controls and the search, so nothing the user
9
+ // sees there reads the memory list.
10
+ // The list still arrives whole, in one step, or not at all (shared/memory-list.js): no view is ever given a part of it.
11
+
12
+ /** The longest the overlay waits for the saved board in Focus Mode; a board that takes longer draws itself after. */
13
+ export const FOCUS_BOARD_WAIT_MS = 3000;
14
+
15
+ /**
16
+ * Resolves when `promise` settles or after `ms`, whichever is first. Never rejects.
17
+ * @param {Promise<unknown> | null | undefined} promise
18
+ * @param {number} ms
19
+ * @param {{ setTimer?: (fn: () => void, ms: number) => unknown, clearTimer?: (id: unknown) => void }} [timers]
20
+ * @returns {Promise<'settled' | 'timeout'>}
21
+ */
22
+ export function settleWithin(promise, ms, { setTimer = setTimeout, clearTimer = clearTimeout } = {}) {
23
+ return new Promise((resolve) => {
24
+ let timer = null;
25
+ const finish = (how) => {
26
+ if (timer !== null) { clearTimer(timer); timer = null; }
27
+ resolve(how);
28
+ };
29
+ timer = setTimer(() => { timer = null; resolve('timeout'); }, Math.max(0, ms));
30
+ Promise.resolve(promise).then(() => finish('settled'), () => finish('settled'));
31
+ });
32
+ }
33
+
34
+ /**
35
+ * What the map does when the visualisation is switched on or off.
36
+ * - 'wait': boot has not decided yet whether it draws the map; it reads the setting itself when it gets there;
37
+ * - 'start': the map was never made (the page booted in Focus Mode): make it and draw /api/map. Its titles and
38
+ * stats come from the memory list only once that is whole (`hydrate` waits for it);
39
+ * - 'apply': the map exists: render it or pause it.
40
+ * @param {{ decided: boolean, enabled: boolean, hasMap: boolean }} state
41
+ * @returns {'wait' | 'start' | 'apply'}
42
+ */
43
+ export function mapToggleAction({ decided, enabled, hasMap }) {
44
+ if (!decided) return 'wait';
45
+ if (enabled && !hasMap) return 'start';
46
+ return 'apply';
47
+ }