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
@@ -16,9 +16,10 @@
16
16
  // A new native attachment still waits for every actual serve's process-bound probe, including startup races.
17
17
  // - A serve that fails its check is stopped: SIGTERM, then SIGKILL after a bounded wait, until the OS confirms its
18
18
  // process and its listener are gone. Until then (and for good when that cannot be confirmed) every native
19
- // attachment is refused, and contexts already attached are revoked (their pages closed, the browser
20
- // disconnected). A failure that is only a missing answer (a timeout) stops the serve when a native context is
21
- // held; otherwise it blocks native attachment and is asked again.
19
+ // attachment is refused, and contexts already attached are revoked (one page emptied to about:blank, every other
20
+ // page closed, the browser disconnected: the profile's window is kept, revokeNativeContext). A failure that is only
21
+ // a missing answer (a timeout) stops the serve when a native context is held; otherwise it blocks native
22
+ // attachment and is asked again.
22
23
  // - Serves SynaBun did not start (a terminal, another app, an earlier SynaBun), on any port: found by the processes
23
24
  // listening on TCP (lib/opencode-serve-scan.js) whenever a context is attached and every NATIVE_WATCH_MS while one
24
25
  // is. SynaBun holds no password for them, so the probe asks them as `foreign`: loopback only, every route of the
@@ -44,6 +45,8 @@ export const NATIVE_SERVE_VERSIONS = NATIVE_SERVE_KNOWN_GOOD;
44
45
  export const NATIVE_SERVE_MIN_VERSION = '2.1.0';
45
46
  // How often the OpenCode serves of this computer are looked at again while a native context is attached.
46
47
  export const NATIVE_WATCH_MS = 15_000;
48
+ // How long a watch pass waits for a foreign serve that failed only by not answering to be confirmed gone (ensureWatch).
49
+ export const NATIVE_EXIT_GRACE_MS = 3_000;
47
50
 
48
51
  /** "2.3.0", "v2.3.0", "opencode v2.3.0" → "2.3.0"; null for anything else (a prerelease, four parts, extra words). */
49
52
  export function nativeServeVersionOf(version) {
@@ -242,16 +245,44 @@ export async function readServeGeneration(pid, { identity = readProcessIdentityA
242
245
  return { pid, startedAt: id.startedAt, executable: exe || null, addresses: socks, key: listenerGenerationKey({ pid, startedAt: id.startedAt, addresses: socks }) };
243
246
  }
244
247
 
248
+ // Contexts this process revoked: context → { at, why }. server.js reads it when the context's close event comes, so a
249
+ // revocation is never reported as a profile "closed outside SynaBun" and never blocks the runs that worked there.
250
+ const _revoked = new WeakMap();
251
+
252
+ /** When and why SynaBun revoked `context` ({ at, why }), or null. */
253
+ export function nativeContextRevocation(context) {
254
+ if (!context || (typeof context !== 'object' && typeof context !== 'function')) return null;
255
+ return _revoked.get(context) || null;
256
+ }
257
+
245
258
  /**
246
- * Take a native context's pages away from a serve that failed: every page closed (a page closed in the browser runs no
247
- * more script), then the browser connection closed, so SynaBun's session must attach again (through the boundary).
248
- * Bounded; never throws.
259
+ * Take a native context's pages away from a serve that failed: no page of it runs a site's script any more, then the
260
+ * browser connection is closed, so SynaBun's session must attach again (through the boundary). Bounded; never throws.
261
+ *
262
+ * The browser's window is kept (2026-11-15). Before, every page was closed: closing the last tab of a MoreLogin
263
+ * profile closes its window, MoreLogin then closes the whole profile (envkit log: close_click + CloseBrowser), and the
264
+ * runs' next browser call started it again, which spends one of the plan's daily launches. On 2026-11-15 at 21:13:30
265
+ * one revocation (a foreign OpenCode serve, pid 21487, failed "http-anonymous" while it was exiting) closed P-1 and P-4
266
+ * 37 ms apart, and one at 21:14:22 (pid 54472, exiting too) closed P-1 again. Now one page is emptied
267
+ * (about:blank: the page that was there runs no more script) and every other page is closed; only when the emptying
268
+ * fails is that page closed too (the window may then go: the boundary's protection comes first).
249
269
  */
250
- export async function revokeNativeContext(context, { timeoutMs = 5_000 } = {}) {
270
+ export async function revokeNativeContext(context, { timeoutMs = 5_000, why = null, stepMs = 2_000 } = {}) {
271
+ try { if (context && typeof context === 'object') _revoked.set(context, { at: Date.now(), why: why ? String(why).slice(0, 500) : null }); } catch { /* not markable */ }
251
272
  const work = (async () => {
252
273
  let pages = [];
253
- try { pages = context?.pages?.() || []; } catch { pages = []; }
254
- await Promise.all(pages.map((page) => Promise.resolve().then(() => page.close({ runBeforeUnload: false })).catch(() => {})));
274
+ try { pages = (context?.pages?.() || []).filter((page) => !page?.isClosed?.()); } catch { pages = []; }
275
+ const [keep, ...rest] = pages;
276
+ const close = (page) => Promise.resolve().then(() => page.close({ runBeforeUnload: false })).catch(() => {});
277
+ // The kept page: emptied within `stepMs`, else (an error, no answer) closed after all.
278
+ const empty = async (page) => {
279
+ let timer;
280
+ const late = new Promise((resolve) => { timer = setTimeout(() => resolve('late'), stepMs); timer.unref?.(); });
281
+ const done = await Promise.race([Promise.resolve().then(() => page.goto('about:blank')).then(() => 'empty', () => 'failed'), late])
282
+ .finally(() => clearTimeout(timer));
283
+ if (done !== 'empty') await close(page);
284
+ };
285
+ await Promise.all([...rest.map(close), keep ? empty(keep) : null]);
255
286
  try { await context?.browser?.()?.close?.(); } catch { /* already gone */ }
256
287
  })();
257
288
  await within(work, timeoutMs);
@@ -283,7 +314,7 @@ export function createNativeServeBoundary({ probe = probeOpencodeServe, identify
283
314
  scan = scanOpencodeServes, readGeneration = readServeGeneration, portListeners = listPortListenersAsync, pidAlive = pidExists,
284
315
  signalPid = (pid, signal) => process.kill(pid, signal), revoke = revokeNativeContext, platform = process.platform,
285
316
  now = Date.now, retryMs = 5_000, termMs = 3_000, killMs = 3_000, gonePollMs = 100, refreshMs = 8_000, foreignTtlMs = 5 * 60_000,
286
- watchMs = NATIVE_WATCH_MS, preflight = null, log = () => {} } = {}) {
317
+ watchMs = NATIVE_WATCH_MS, exitGraceMs = NATIVE_EXIT_GRACE_MS, exitPollMs = 250, preflight = null, log = () => {} } = {}) {
287
318
  const processes = new Map();
288
319
  // Process-local admission evidence: persisted diagnostic verdicts and ordinary runtime passes cannot grant it.
289
320
  const builds = new Map(), buildChecks = new Map();
@@ -314,7 +345,7 @@ export function createNativeServeBoundary({ probe = probeOpencodeServe, identify
314
345
  if (rec.revoking) continue;
315
346
  rec.revoking = true;
316
347
  log(`revoking a native browser context: ${why}`);
317
- Promise.resolve().then(() => revoke(context)).catch(() => {}).finally(() => rec.release());
348
+ Promise.resolve().then(() => revoke(context, { why })).catch(() => {}).finally(() => rec.release());
318
349
  }
319
350
  }
320
351
 
@@ -577,13 +608,52 @@ export function createNativeServeBoundary({ probe = probeOpencodeServe, identify
577
608
  await within(Promise.allSettled(jobs), refreshMs);
578
609
  }
579
610
 
611
+ // ── A foreign serve that is going away ──
612
+ // On 2026-11-15 two revocations (21:13:30, 21:14:22 local) came from foreign serves that were exiting: the probe got no
613
+ // answer (pid 21487: "GET /api/session did not answer", its exit handler ran at 21:13:29.03) or a reset (pid 54472:
614
+ // ECONNRESET, exit handler at 21:14:22.60). A serve that answered nothing gave nothing away; once the OS confirms its
615
+ // process ended, or that it no longer listens on that port, no page can reach it. So when EVERY offender of a watch
616
+ // pass is such a failure (a foreign serve, `transient`, nothing `exposed`), the pass waits up to `exitGraceMs` for the
617
+ // OS to confirm them gone, and revokes only for those that are not. Anything else (an exposed answer, a serve still
618
+ // being checked, a scan that failed, a serve SynaBun started) is revoked at once, as before.
619
+ const foreignVerdictOf = (o) => {
620
+ const serve = (foreign.result?.serves || []).find((s) => s.pid === o.pid);
621
+ return serve ? foreign.verdicts.get(listenerGenerationKey(serve))?.verdict || null : null;
622
+ };
623
+ const settlingForeign = (o) => {
624
+ if (o?.reason !== 'foreign' || !Number.isInteger(o.pid) || !(o.pid > 0) || !(Number(o.port) > 0)) return false;
625
+ const v = foreignVerdictOf(o);
626
+ return !!v && !v.ok && v.transient === true && v.exposed !== true;
627
+ };
628
+ async function foreignGone(o) {
629
+ let alive;
630
+ try { alive = pidAlive(o.pid); } catch { alive = null; }
631
+ if (alive === false) return true;
632
+ let pids;
633
+ try { pids = await portListeners(Number(o.port)); } catch { pids = null; }
634
+ return Array.isArray(pids) && !pids.includes(o.pid);
635
+ }
636
+ async function withoutExitingForeign(bad) {
637
+ if (!(exitGraceMs > 0) || !bad.length || !bad.every(settlingForeign)) return bad;
638
+ const end = now() + exitGraceMs;
639
+ let left = bad;
640
+ for (;;) {
641
+ const gone = await Promise.all(left.map((o) => foreignGone(o).catch(() => false)));
642
+ const settled = left.filter((_, i) => gone[i]);
643
+ for (const o of settled) log(`OpenCode serve pid ${o.pid} port ${o.port}, not started by SynaBun, failed "${o.check}" while it was going away and is gone now: no browser context revoked for it`);
644
+ left = left.filter((_, i) => !gone[i]);
645
+ if (!left.length || now() >= end) return left;
646
+ await defaultSleep(Math.max(1, Math.min(exitPollMs, end - now())));
647
+ }
648
+ }
649
+
580
650
  function ensureWatch() {
581
651
  if (watchTimer || !(watchMs > 0)) return;
582
652
  watchTimer = setInterval(() => {
583
653
  if (!attachedContexts().length) { clearInterval(watchTimer); watchTimer = null; return; }
584
- refresh().then(() => {
654
+ refresh().then(async () => {
585
655
  if (!foreign.result?.ok) { revokeAll('the OpenCode listening processes could not be verified'); return; }
586
- const bad = foreignOffenders(new Set());
656
+ const bad = await withoutExitingForeign(foreignOffenders(new Set()));
587
657
  if (bad.length) revokeAll(`an OpenCode serve SynaBun did not start could not be verified (pid ${bad[0].pid || '?'}, port ${bad[0].port || '?'}, check "${bad[0].check || bad[0].reason}")`);
588
658
  }).catch(() => {});
589
659
  }, watchMs);
@@ -429,29 +429,32 @@ export function createServeRecords({
429
429
  * not carry this start's token (macOS, Linux), or whose start time is not to the fraction of a second (Windows);
430
430
  * nor while the machine, the user or the boot cannot be told. A live record of another start under the same pid
431
431
  * is never written over. Resolves the record or null.
432
+ * `quiet`: why nothing was recorded is not logged. For the try right after the spawn, which can come before the
433
+ * process shows its environment, when a second try follows once it answers (and logs if that one fails too).
432
434
  */
433
- async function record({ kind, id = null, port, pid, token } = {}) {
435
+ async function record({ kind, id = null, port, pid, token, quiet = false } = {}) {
434
436
  const n = Number(pid);
435
437
  if (!kinds.includes(kind) || !isPid(n) || !isPort(Number(port)) || !TOKEN.test(str(token))) return null;
438
+ const say = quiet ? () => {} : log;
436
439
  const at = await scopeLater();
437
- if (!at) { log(`no record for the ${kind} ${noun} on port ${port}: the machine, the user or the boot could not be read`); return null; }
440
+ if (!at) { say(`no record for the ${kind} ${noun} on port ${port}: the machine, the user or the boot could not be read`); return null; }
438
441
  const identity = await readIdentityAsync(n);
439
- if (!identity) { log(`no record for the ${kind} ${noun} on port ${port}: the identity of process ${n} could not be read`); return null; }
442
+ if (!identity) { say(`no record for the ${kind} ${noun} on port ${port}: the identity of process ${n} could not be read`); return null; }
440
443
  const entry = {
441
444
  v: RECORD_VERSION, kind, id: id == null ? null : String(id), port: Number(port),
442
445
  pid: n, startedAt: identity.startedAt, command: identity.command, token,
443
446
  scope: { ...at }, owner: owner(), recordedAt: new Date(now()).toISOString(),
444
447
  };
445
- if (!whole(entry)) { log(`no record for the ${kind} ${noun} on port ${port}: process ${n} is not a ${noun} on that port (${identity.command})`); return null; }
448
+ if (!whole(entry)) { say(`no record for the ${kind} ${noun} on port ${port}: process ${n} is not a ${noun} on that port (${identity.command})`); return null; }
446
449
  if (platform === 'win32') {
447
- if (!FINE_START.test(entry.startedAt)) { log(`no record for the ${kind} ${noun} on port ${port}: the start time of process ${n} is not precise enough to tell it apart`); return null; }
450
+ if (!FINE_START.test(entry.startedAt)) { say(`no record for the ${kind} ${noun} on port ${port}: the start time of process ${n} is not precise enough to tell it apart`); return null; }
448
451
  } else {
449
- if (String(identity.uid ?? '') !== at.uid) { log(`no record for the ${kind} ${noun} on port ${port}: process ${n} is not this user's`); return null; }
450
- if (await readTokenAsync(n, token, identity.command) !== true) { log(`no record for the ${kind} ${noun} on port ${port}: process ${n} does not carry this start's token`); return null; }
452
+ if (String(identity.uid ?? '') !== at.uid) { say(`no record for the ${kind} ${noun} on port ${port}: process ${n} is not this user's`); return null; }
453
+ if (await readTokenAsync(n, token, identity.command) !== true) { say(`no record for the ${kind} ${noun} on port ${port}: process ${n} does not carry this start's token`); return null; }
451
454
  }
452
455
  const onFile = readFile(`${n}.json`);
453
456
  if (onFile && str(onFile.token) && onFile.token !== token && !issued.has(onFile.token) && await verify(onFile) === 'same') {
454
- log(`no record for the ${kind} ${noun} on port ${port}: process ${n} is on record for another start`);
457
+ say(`no record for the ${kind} ${noun} on port ${port}: process ${n} is on record for another start`);
455
458
  return null;
456
459
  }
457
460
  if (!write(entry)) return null;
@@ -521,7 +524,9 @@ export function createServeRecords({
521
524
  const pids = await listeners(Number(port));
522
525
  if (exited()) return { state: 'foreign' };
523
526
  if (!Array.isArray(pids)) return { state: 'unknown' };
524
- if (!pids.length) return { state: 'foreign' };
527
+ // Windows can miss a listener that just answered. This is not evidence of a competing process; the native
528
+ // boundary still consumes [] directly when confirming that a stopped listener is gone.
529
+ if (!pids.length) return { state: platform === 'win32' ? 'unknown' : 'foreign' };
525
530
  let ours = null;
526
531
  for (const listener of pids) {
527
532
  if (listener !== n && await descendsFrom(listener, n) !== true) return { state: 'foreign', pids };
@@ -142,7 +142,7 @@ export function isLocalMarkerHost(hostname, extraNames = []) {
142
142
  * The pages the cookie is set on: the app's shells and the detached side panel's window, each the first page a
143
143
  * browser window loads. The Studio's library read sets it too (server.js), as does GET /api/page-session.
144
144
  */
145
- export const PAGE_SECRET_PATHS = Object.freeze(['/', '/index.html', '/index2d.html', '/onboarding.html', '/sidepanel-session.html']);
145
+ export const PAGE_SECRET_PATHS = Object.freeze(['/', '/index.html', '/index2d.html', '/onboarding.html', '/sidepanel-session.html', '/extension-setup']);
146
146
  /** The route an open tab asks for this boot's cookie after a restart (public/shared/page-session.js). */
147
147
  export const PAGE_SECRET_REFRESH_PATH = '/api/page-session';
148
148
  /** The app's service worker (public/sw.js): a browser that may not hold the secret gets SERVICE_WORKER_NOOP instead. */
@@ -38,7 +38,7 @@
38
38
  // app's pages and every other read still load). A failure that may pass (a timeout, a busy system) is tried once
39
39
  // more at once and is kept on its connection for a moment only (NEGATIVE_TTL_MS), so an open tab recovers by
40
40
  // itself; a client that left is never kept. The server probes netstat and ps once at start (probe()), keeps the
41
- // state for GET /api/health (`ownerAuthority`: ok / degraded / unsupported / off), says the change in one loud log
41
+ // state for GET /api/health (`ownerAuthority`: pending / ok / degraded / unsupported / off), says the change in one loud log
42
42
  // line, and the page shows a banner while it is degraded (public/shared/ui-owner-authority.js).
43
43
  // Only a machine elsewhere on the network ('remote', below) still keeps the rules from before without a lookup: what to
44
44
  // do about a LAN client is a separate decision (TODO(peer-identity-remote): decide the LAN policy).
@@ -582,6 +582,23 @@ function failureText(error) {
582
582
  return String(error?.code || error?.message || error || 'failed');
583
583
  }
584
584
 
585
+ const STDERR_NOTE_MAX = 200;
586
+ /**
587
+ * What a program wrote to stderr, for a failure's reason: ` (netstat said: "…")`, on one line and at most
588
+ * STDERR_NOTE_MAX characters, or '' when it wrote nothing.
589
+ */
590
+ export function stderrNote(text, program = 'netstat') {
591
+ const said = String(text ?? '').replace(/\s+/g, ' ').trim();
592
+ if (!said) return '';
593
+ return ` (${program} said: "${said.length > STDERR_NOTE_MAX ? `${said.slice(0, STDERR_NOTE_MAX - 1)}…` : said}")`;
594
+ }
595
+
596
+ /** A run's answer as `{ stdout, stderr }`: a run may answer stdout alone (a string) or both (`{ stdout, stderr }`). */
597
+ function outputOf(answer) {
598
+ if (answer && typeof answer === 'object' && 'stdout' in answer) return { stdout: String(answer.stdout ?? ''), stderr: String(answer.stderr ?? '') };
599
+ return { stdout: String(answer ?? ''), stderr: '' };
600
+ }
601
+
585
602
  /**
586
603
  * What a request's peer verdict means for the owner's authority: the one reading lib/page-session.js,
587
604
  * lib/owner-authority.js and lib/assistant-api.js share. Pure, never throws.
@@ -615,11 +632,16 @@ export function peerAuthority(verdict) {
615
632
 
616
633
  // ── The reader ───────────────────────────────────────────────────────────────
617
634
 
618
- function defaultRun(file, args, { timeout }) {
635
+ // `stderr: true` answers `{ stdout, stderr }` instead of stdout alone; a failure always carries what the program wrote
636
+ // to stderr (`error.stderr`).
637
+ function defaultRun(file, args, { timeout, stderr: withStderr = false }) {
619
638
  return new Promise((resolve, reject) => {
620
639
  try {
621
- execFile(file, args, { encoding: 'utf8', timeout, maxBuffer: 64 * 1024 * 1024, windowsHide: true, env: { PATH: '/usr/bin:/bin:/usr/sbin:/sbin', LANG: 'C', LC_ALL: 'C' } }, (error, stdout) => {
622
- if (error) reject(error); else resolve(String(stdout || ''));
640
+ execFile(file, args, { encoding: 'utf8', timeout, maxBuffer: 64 * 1024 * 1024, windowsHide: true, env: { PATH: '/usr/bin:/bin:/usr/sbin:/sbin', LANG: 'C', LC_ALL: 'C' } }, (error, stdout, stderr) => {
641
+ if (error) {
642
+ if (error && typeof error === 'object' && error.stderr === undefined) { try { error.stderr = String(stderr || ''); } catch { /* frozen */ } }
643
+ reject(error);
644
+ } else resolve(withStderr ? { stdout: String(stdout || ''), stderr: String(stderr || '') } : String(stdout || ''));
623
645
  });
624
646
  } catch (error) { reject(error); }
625
647
  });
@@ -671,7 +693,7 @@ export function createPeerIdentity({ platform = process.platform, selfPid = proc
671
693
  return typeof real === 'string' && real !== written ? [written, real] : [written];
672
694
  }))];
673
695
  const logged = new Map(); // key → last time
674
- const stats = { lookups: 0, tableReads: 0, psReads: 0, envReads: 0, refused: 0, unknown: 0, failed: 0, retries: 0, gone: 0, totalMs: 0, maxMs: 0 };
696
+ const stats = { lookups: 0, tableReads: 0, tableRetries: 0, psReads: 0, envReads: 0, refused: 0, unknown: 0, failed: 0, retries: 0, gone: 0, totalMs: 0, maxMs: 0 };
675
697
  let addrCache = null;
676
698
  let addrAt = 0;
677
699
 
@@ -685,15 +707,14 @@ export function createPeerIdentity({ platform = process.platform, selfPid = proc
685
707
  const say = (line) => { try { log(line); } catch { /* a logger's own failure */ } };
686
708
 
687
709
  // ── The state of the owner's authority (GET /api/health `ownerAuthority`, the page's banner) ──
688
- // off / unsupported never change. On macOS it is ok until the start probe or a lookup fails (degraded, with the
689
- // reason), and ok again after a whole lookup works (one that read the process table, not just this server's own
690
- // call, which needs netstat only). Each change is said once, loudly; a lookup that keeps failing is not said again.
710
+ // On macOS readiness is pending until the start probe or a whole lookup settles.
711
+ // This describes the verifier. Each request still needs its own peer verdict.
691
712
  const iso = (ms) => { try { return new Date(ms).toISOString(); } catch { return null; } };
692
713
  let authority = disabled
693
714
  ? { state: 'off', reason: 'SYNABUN_PEER_IDENTITY=off', retryable: false, since: iso(now()) }
694
715
  : !supported
695
716
  ? { state: 'unsupported', reason: unsupportedReason, retryable: false, since: iso(now()) }
696
- : { state: 'ok', reason: null, retryable: false, since: iso(now()) };
717
+ : { state: 'pending', reason: null, retryable: false, since: iso(now()) };
697
718
  let probed = null; // the start probe's promise
698
719
  function degrade(reason, { retryable = false, source = 'lookup' } = {}) {
699
720
  if (!supported) return;
@@ -714,7 +735,7 @@ export function createPeerIdentity({ platform = process.platform, selfPid = proc
714
735
  if (!supported || authority.state === 'ok') return;
715
736
  const was = authority.reason;
716
737
  authority = { state: 'ok', reason: null, retryable: false, since: iso(now()) };
717
- say(`[peer-identity] owner authority restored (${source}): local programs are identified again${was ? ` (it was: ${was})` : ''}`);
738
+ if (was) say(`[peer-identity] owner authority restored (${source}): local programs are identified again (it was: ${was})`);
718
739
  }
719
740
  /** What a lookup said about the lookup itself: a whole answer restores, a failure degrades (one about a single
720
741
  * connection — it has no address any more — says nothing about the tools). */
@@ -723,7 +744,7 @@ export function createPeerIdentity({ platform = process.platform, selfPid = proc
723
744
  if (verdict.status === 'unknown' && verdict.kind === 'failed') { if (!verdict.connection) degrade(verdict.reason, { retryable: verdict.retryable === true }); }
724
745
  else if (verdict.status === 'ok' && !verdict.self) restore();
725
746
  }
726
- /** The state for GET /api/health: { state: 'ok'|'degraded'|'unsupported'|'off', reason, retryable, since }. */
747
+ /** The state for GET /api/health: { state: 'pending'|'ok'|'degraded'|'unsupported'|'off', reason, retryable, since }. */
727
748
  function authorityState() {
728
749
  return { state: authority.state, reason: authority.reason, retryable: authority.retryable === true, since: authority.since };
729
750
  }
@@ -738,23 +759,28 @@ export function createPeerIdentity({ platform = process.platform, selfPid = proc
738
759
  probed = (async () => {
739
760
  const failures = [];
740
761
  let retryable = false;
741
- try {
742
- const table = parseNetstatTcp(await run(NETSTAT, NETSTAT_ARGS, { timeout: TABLE_TIMEOUT_MS }));
743
- if (!table.rows.length) failures.push('netstat listed no TCP sockets');
744
- else if (!table.rows.some((r) => r.pid > 0)) failures.push('netstat named no processes (an unknown output layout)');
745
- } catch (error) { failures.push(`netstat: ${failureText(error)}`); retryable = retryable || isTransientLookupError(error); }
762
+ try { await readNetstat(); } catch (error) {
763
+ failures.push(error?.netstatTable ? error.message : netstatFailure(error));
764
+ retryable = retryable || isTransientLookupError(error);
765
+ }
746
766
  try {
747
767
  const parents = parsePsParents(await run(PS, ['-Ao', 'pid=,ppid=,ucomm='], { timeout: PS_TIMEOUT_MS }));
748
768
  if (!parents.size) failures.push('ps listed no processes');
749
769
  else if (!parents.has(selfPid)) failures.push('ps did not list this server');
750
770
  } catch (error) { failures.push(`ps: ${failureText(error)}`); retryable = retryable || isTransientLookupError(error); }
771
+ // A request can finish its full lookup while this boot-time sample is in flight.
772
+ // Its observed outcome takes precedence over the preflight in either direction.
773
+ if (authority.state !== 'pending') return authorityState();
751
774
  if (failures.length) degrade(failures.join('; '), { retryable, source: 'start probe' });
752
775
  else {
753
776
  say('[peer-identity] start probe: netstat and ps answer; the owner\'s authority is checked against the calling process');
754
777
  restore('start probe');
755
778
  }
756
779
  return authorityState();
757
- })().catch((error) => { degrade(`the probe failed (${error?.message || error})`, { source: 'start probe' }); return authorityState(); });
780
+ })().catch((error) => {
781
+ if (authority.state === 'pending') degrade(`the probe failed (${error?.message || error})`, { source: 'start probe' });
782
+ return authorityState();
783
+ });
758
784
  return probed;
759
785
  }
760
786
  const isThisMachine = (addr) => {
@@ -763,6 +789,34 @@ export function createPeerIdentity({ platform = process.platform, selfPid = proc
763
789
  return addrCache.has(addr);
764
790
  };
765
791
 
792
+ /**
793
+ * netstat's TCP table: `{ rows, listening, startedAt }` (when the read that gave it started). A table that lists no
794
+ * socket at all is read again once, at once: a busy system can answer one read with nothing (seen at a cold start,
795
+ * right after login), and that is not worth the owner's 503s. What netstat wrote to stderr is kept in the reason of a
796
+ * table that stays unreadable. Rejects with the reason (`error.netstatTable`: the table, not the program, failed);
797
+ * a program that cannot run rejects with its own error (netstatFailure).
798
+ */
799
+ async function readNetstat() {
800
+ let said = '';
801
+ for (let attempt = 0; attempt < 2; attempt++) {
802
+ if (attempt) stats.tableRetries++;
803
+ const startedAt = now();
804
+ // -l: full IPv6 addresses (without it macOS cuts a long one, fe80::105e:de82:…, and the client's row would not
805
+ // be found: a connection taken for one that closed, refused).
806
+ const out = outputOf(await run(NETSTAT, NETSTAT_ARGS, { timeout: TABLE_TIMEOUT_MS, stderr: true }));
807
+ if (out.stderr.trim()) said = out.stderr;
808
+ const table = parseNetstatTcp(out.stdout);
809
+ if (!table.rows.length) continue;
810
+ // A layout this parser does not read gives no process at all: that is a lookup that cannot run (the rules from
811
+ // before), never "every client left". Not read again: the layout does not change between two reads.
812
+ if (!table.rows.some((r) => r.pid > 0)) throw Object.assign(new Error(`netstat named no processes (an unknown output layout)${stderrNote(said)}`), { netstatTable: true });
813
+ return { ...table, startedAt };
814
+ }
815
+ throw Object.assign(new Error(`netstat listed no TCP sockets${stderrNote(said)}`), { netstatTable: true });
816
+ }
817
+ /** The reason of a netstat that failed as a program: `netstat: <why>`, with what it wrote to stderr. */
818
+ const netstatFailure = (error) => `netstat: ${failureText(error)}${error && typeof error === 'object' && !error.netstatTable ? stderrNote(error.stderr) : ''}`;
819
+
766
820
  // One TCP table read serves every lookup that was waiting when it STARTED (a socket accepted after a read began
767
821
  // may not be in it, so its lookup waits for the next read).
768
822
  let tableRunning = null;
@@ -773,17 +827,7 @@ export function createPeerIdentity({ platform = process.platform, selfPid = proc
773
827
  tableNext = after.catch(() => {}).then(() => {
774
828
  tableNext = null;
775
829
  stats.tableReads++;
776
- const startedAt = now();
777
- // -l: full IPv6 addresses (without it macOS cuts a long one, fe80::105e:de82:…, and the client's row would not
778
- // be found: a connection taken for one that closed, refused).
779
- const read = run(NETSTAT, NETSTAT_ARGS, { timeout: TABLE_TIMEOUT_MS }).then((text) => {
780
- const table = parseNetstatTcp(text);
781
- if (!table.rows.length) throw new Error('netstat listed no TCP sockets');
782
- // A layout this parser does not read gives no process at all: that is a lookup that cannot run (the rules from
783
- // before), never "every client left".
784
- if (!table.rows.some((r) => r.pid > 0)) throw new Error('netstat named no processes (an unknown output layout)');
785
- return { ...table, startedAt };
786
- });
830
+ const read = readNetstat();
787
831
  tableRunning = read;
788
832
  read.catch(() => {}).then(() => { if (tableRunning === read) tableRunning = null; });
789
833
  return read;
@@ -875,7 +919,7 @@ export function createPeerIdentity({ platform = process.platform, selfPid = proc
875
919
  if (!isThisMachine(remote)) return { status: 'remote' };
876
920
  if (!supported) return unsupportedPeerVerdict(unsupportedReason);
877
921
  let table;
878
- try { table = await tcpTable(); } catch (error) { return failedPeerVerdict(`netstat: ${failureText(error)}`, { retryable: isTransientLookupError(error) }); }
922
+ try { table = await tcpTable(); } catch (error) { return failedPeerVerdict(netstatFailure(error), { retryable: isTransientLookupError(error) }); }
879
923
  const row = table.rows.find((r) => r.local.port === remotePort && r.local.addr === remote && r.foreign.port === localPort && (r.foreign.addr === local || !local));
880
924
  if (!row || !row.pid) return { status: 'gone', reason: 'the connection closed before its request was identified', ms: now() - started };
881
925
  if (row.pid === selfPid) return { status: 'ok', self: true, pid: row.pid, name: row.name, chain: [], refuse: null, ms: now() - started };
@@ -119,9 +119,12 @@ export async function readProcessIdentityAsync(pid, { platform = process.platfor
119
119
  }
120
120
  }
121
121
 
122
- function runFile(file, args, options) {
122
+ function runFile(file, args, { rejectStderr = false, ...options }) {
123
123
  return new Promise((resolve, reject) => {
124
- execFile(file, args, options, (error, stdout, stderr) => (error ? reject(Object.assign(error, { stdout, stderr })) : resolve(stdout)));
124
+ execFile(file, args, options, (error, stdout, stderr) => {
125
+ if (error || (rejectStderr && String(stderr || '').trim())) reject(Object.assign(error || new Error('OS query warning'), { stdout, stderr }));
126
+ else resolve(stdout);
127
+ });
125
128
  });
126
129
  }
127
130
 
@@ -494,11 +497,62 @@ export async function readProcessExecutableAsync(pid, { platform = process.platf
494
497
  } catch { return null; }
495
498
  }
496
499
 
500
+ // Evidence: peer-identity.js / peer-identity.test.mjs identify MoreLogin.app and MoreLogin Helper under
501
+ // Application Support/MoreLogin/env-kit/Core/chrome_64_*. morelogin-kernel.test.mjs also records Windows
502
+ // AppData/Roaming/MoreLogin/env-kit/Core/{chrome,firefox}_64_* driver paths. isMoreLoginInstalled uses the
503
+ // MoreLogin directory on Linux. Match those directory components and kernel names, never arbitrary arguments
504
+ // (a node test runner's arguments often contain "morelogin"). Include the desktop/helpers conservatively.
505
+ const MORELOGIN_EXECUTABLE = /(?:^|\/)morelogin(?: [^/]*)?\.app(?:\/|$)|(?:^|\/)morelogin(?:\/|$)|\/env-kit\/core\/(?:chrome|firefox)_/i;
506
+ const MORELOGIN_NAME = /^morelogin(?:[ ._-]|$)/i;
507
+ const POSSIBLE_PROFILE_BROWSER = /^(?:chrome|chromium|firefox|morelogin)(?:[ ._-]|$)/i;
508
+
509
+ /**
510
+ * true when a MoreLogin process survives its API, false only after a readable process snapshot excludes it,
511
+ * null on unreadable/partial output. No process is signalled. macOS reports full executable paths via ps;
512
+ * Windows uses CIM Name/ExecutablePath; Linux resolves browser names through /proc/<pid>/exe because ps comm
513
+ * may be only a basename. Missing paths for a possible profile browser are unknown, never evidence of absence.
514
+ */
515
+ export async function moreLoginProcessesRunning({ platform = process.platform, run = runFile,
516
+ executable = (pid) => readProcessExecutableAsync(pid, { platform, run }) } = {}) {
517
+ if (!['darwin', 'linux', 'win32'].includes(platform)) return null;
518
+ let rows;
519
+ try {
520
+ if (platform === 'win32') {
521
+ const query = powershell("$WarningPreference = 'Stop'; try { $rows = @(Get-CimInstance Win32_Process -ErrorAction Stop | Select-Object ProcessId,Name,ExecutablePath); ConvertTo-Json -Compress -InputObject $rows } catch { exit 1 }");
522
+ const data = JSON.parse(await run(query.file, query.args, { ...query.options, rejectStderr: true, maxBuffer: 16 * 1024 * 1024 }));
523
+ if (!Array.isArray(data) || !data.length || data.some(p => !Number.isInteger(p?.ProcessId) || p.ProcessId < 0
524
+ || typeof p.Name !== 'string' || !p.Name.trim() || (p.ExecutablePath != null && typeof p.ExecutablePath !== 'string'))) return null;
525
+ rows = data.map(p => ({ pid: p.ProcessId, name: p.Name.trim(), path: p.ExecutablePath?.trim() || '' }));
526
+ } else {
527
+ const out = await run('ps', ['-A', '-ww', '-o', 'pid=', '-o', 'comm='],
528
+ { encoding: 'utf8', timeout: 5000, env: C_ENV(), rejectStderr: true, maxBuffer: 16 * 1024 * 1024 });
529
+ const lines = String(out ?? '').trim().split(/\r?\n/);
530
+ rows = [];
531
+ for (const line of lines) {
532
+ const m = /^\s*(\d+)\s+(\S.*)$/.exec(line);
533
+ if (!m || !pidOf(m[1])) return null;
534
+ const path = m[2].trim();
535
+ rows.push({ pid: Number(m[1]), name: path.split('/').at(-1), path: path.startsWith('/') ? path : '' });
536
+ }
537
+ }
538
+ let unknown = false;
539
+ for (const row of rows) {
540
+ if (MORELOGIN_NAME.test(row.name) || MORELOGIN_EXECUTABLE.test(row.path.replaceAll('\\', '/'))) return true;
541
+ if (!POSSIBLE_PROFILE_BROWSER.test(row.name)) continue;
542
+ let path = row.path;
543
+ if (!path && platform === 'linux') path = await executable(row.pid);
544
+ if (!path) { unknown = true; continue; }
545
+ if (MORELOGIN_EXECUTABLE.test(path.replaceAll('\\', '/'))) return true;
546
+ }
547
+ return unknown ? null : false;
548
+ } catch { return null; }
549
+ }
550
+
497
551
  /**
498
552
  * The pids that listen on a local TCP port: a list (empty: nothing listens that the user may see), or null when the
499
553
  * OS could not be asked. macOS and Linux: lsof (exit 1 with nothing printed is "none"; no lsof is null); Windows:
500
- * Get-NetTCPConnection, where an empty answer is null too (it lists every user's listeners: something answered on
501
- * the port a moment ago).
554
+ * Get-NetTCPConnection, with an explicit JSON array after a successful query. [] confirms the listener is gone;
555
+ * missing output, a failed query or malformed data is still unknown (null).
502
556
  * @param {number} port
503
557
  * @param {{ platform?: string, run?: (file: string, args: string[], options: object) => Promise<string> }} [o]
504
558
  */
@@ -508,10 +562,17 @@ export async function listPortListenersAsync(port, { platform = process.platform
508
562
  const pidsIn = (out) => [...new Set(String(out ?? '').split(/\r?\n/).map((l) => l.trim()).filter((l) => /^\d+$/.test(l)).map(Number))]
509
563
  .filter((n) => n > 0 && n !== selfPid);
510
564
  if (platform === 'win32') {
511
- const query = powershell(`Get-NetTCPConnection -LocalPort ${p} -State Listen -ErrorAction SilentlyContinue | ForEach-Object { $_.OwningProcess }`);
565
+ // Filter in CIM: querying all TCP connections on every gone() poll is expensive on a busy machine. Only
566
+ // the cmdlet's specific CIM "no matching objects" error proves absence. Denials/timeouts/warnings do not.
567
+ const query = powershell(`$WarningPreference = 'Stop'; try { $listeners = @(Get-NetTCPConnection -LocalPort ${p} -State Listen -ErrorAction Stop); ConvertTo-Json -Compress -InputObject @($listeners | ForEach-Object { $_.OwningProcess }) } catch { ConvertTo-Json -Compress -InputObject @{ category = [string]$_.CategoryInfo.Category; reason = [string]$_.CategoryInfo.Reason; id = [string]$_.FullyQualifiedErrorId } }`);
512
568
  try {
513
- const pids = pidsIn(await run(query.file, query.args, query.options));
514
- return pids.length ? pids : null;
569
+ const pids = JSON.parse(await run(query.file, query.args, { ...query.options, rejectStderr: true }));
570
+ // Get-NetTCPConnection's no-match exception is CimJobException (some CIM versions report CimException).
571
+ // Do not use localized error text or a generic ObjectNotFound: a missing command/module is not absence.
572
+ if (pids?.category === 'ObjectNotFound' && ['CimJobException', 'CimException'].includes(pids.reason)
573
+ && /^CmdletizationQuery_NotFound(?:_[A-Za-z]+)?,Get-NetTCPConnection$/.test(pids.id)) return [];
574
+ if (!Array.isArray(pids) || pids.some(n => !Number.isSafeInteger(n) || n <= 0)) return null;
575
+ return [...new Set(pids)].filter(n => n !== selfPid);
515
576
  } catch {
516
577
  return null;
517
578
  }
@@ -79,6 +79,9 @@ export const ADMIN_ONLY_PREFIXES = Object.freeze([
79
79
  // The Skills Service's installs, rollbacks and removals, the move of the old bridges, and its settings: the
80
80
  // owner's, from the app's own page (lib/skills/api-v2.js refuses guests and agents on its own too).
81
81
  '/api/skills-studio/v2/installations', '/api/skills-studio/v2/migrations', '/api/skills-studio/v2/config',
82
+ // Agent definitions (their instructions, what they may touch) and their runs: the owner's (lib/agents-studio-api.js
83
+ // refuses guests on every route on its own too). The Assistant and agents reach it with their own headers.
84
+ '/api/agents-studio',
82
85
  '/api/tunnel/start', '/api/tunnel/stop',
83
86
  '/api/bridges', '/api/keybinds',
84
87
  '/api/cli',
@@ -0,0 +1,33 @@
1
+ // Where macOS saves screenshots, for the screenshot watcher (server.js: a new screenshot is pasted on the whiteboard).
2
+ //
3
+ // The folder chosen in the Screenshot app is `defaults read com.apple.screencapture location`. When none was ever
4
+ // chosen (the usual case), `defaults` exits 1 and writes "Could not find key 'location' in domain
5
+ // 'com.apple.screencapture'" to stderr: that is the default (~/Desktop), not an error, so its stderr is never passed
6
+ // through to SynaBun's own output (it used to show up in the boot log as a bare "Error: …" line).
7
+
8
+ import { execFileSync } from 'node:child_process';
9
+ import { existsSync } from 'node:fs';
10
+ import { homedir } from 'node:os';
11
+ import { join } from 'node:path';
12
+
13
+ export const DEFAULTS = '/usr/bin/defaults';
14
+ export const SCREENCAPTURE_LOCATION_ARGS = Object.freeze(['read', 'com.apple.screencapture', 'location']);
15
+ const READ_TIMEOUT_MS = 5000;
16
+
17
+ /**
18
+ * The folder macOS saves screenshots in: the one set in the Screenshot app when it exists, else ~/Desktop.
19
+ * Never throws and never writes to the console.
20
+ * @param {{ run?: typeof execFileSync, exists?: (path: string) => boolean, home?: string }} [o] tests inject these.
21
+ * @returns {string}
22
+ */
23
+ export function macScreenshotDir({ run = execFileSync, exists = existsSync, home = homedir() } = {}) {
24
+ let dir = '';
25
+ try {
26
+ dir = String(run(DEFAULTS, [...SCREENCAPTURE_LOCATION_ARGS], {
27
+ encoding: 'utf8', timeout: READ_TIMEOUT_MS, windowsHide: true, stdio: ['ignore', 'pipe', 'ignore'],
28
+ }) ?? '').trim();
29
+ } catch { dir = ''; } // never set (exit 1), or `defaults` could not run: the default
30
+ let found = false;
31
+ try { found = !!dir && exists(dir) === true; } catch { found = false; }
32
+ return found ? dir : join(home, 'Desktop');
33
+ }