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,226 @@
1
+ // ═══════════════════════════════════════════
2
+ // SynaBun — Tool permissions: the owner's choices, kept by SynaBun
3
+ // ═══════════════════════════════════════════
4
+ //
5
+ // Settings → Tool permissions switches SynaBun's tools on and off. What a switch
6
+ // changes is Claude Code's own allow list (permissions.allow of the user's
7
+ // ~/.claude/settings.json), which is also what the switches are drawn from. That
8
+ // file belongs to another program: it is rewritten by Claude Code, replaced by a
9
+ // restore or a dotfiles sync, lost with a profile. Until this module the list in
10
+ // it was the only record of what the owner chose, so whatever replaced the file
11
+ // took every choice with it and Settings showed all of them off.
12
+ //
13
+ // DATA_HOME/data/tool-permissions.json is SynaBun's own record of those choices
14
+ // ({ choices: { <tool key>: true | false } }). The data home is never touched by
15
+ // an install or an update (and is part of every backup and pre-update snapshot).
16
+ //
17
+ // on the owner switched the tool on here, or the allow list has it (a rule
18
+ // granted in Claude Code is a choice too: it is adopted)
19
+ // off the owner switched it off here (or removed its rule in the side
20
+ // panel's /permissions). SynaBun never allows such a tool by itself
21
+ // none never chosen: the product's default applies (a tool is off until it is
22
+ // switched on; the memory tools are allowed when the MCP server is
23
+ // registered). A tool that is new in an update has no choice
24
+ //
25
+ // The allow list stays what is true (Claude Code reads nothing else). The record
26
+ // is what brings it back:
27
+ //
28
+ // at every start every tool whose choice is `on` and whose rule is missing is
29
+ // put back (planStart). An update is a start
30
+ // at a read only when every saved `on` tool is missing at once
31
+ // (lostWholesale): that is a replaced file, never one rule the
32
+ // owner took out in Claude Code, which waits for the next start
33
+ //
34
+ // Nothing here ever removes a rule. No DOM, no server: the file is the only
35
+ // state, read on every call (its writers are this process's routes).
36
+
37
+ import { existsSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from 'node:fs';
38
+ import { dirname } from 'node:path';
39
+
40
+ export const TOOL_CHOICES_FILE = 'tool-permissions.json';
41
+ export const TOOL_CHOICES_VERSION = 1;
42
+ /** A replaced file is told from a rule taken out by hand by this many saved tools missing together. */
43
+ export const WHOLESALE_MIN = 3;
44
+ /** How many restores the record remembers (what was put back, when, by which version). */
45
+ export const RESTORE_HISTORY = 10;
46
+
47
+ const isKey = (value) => typeof value === 'string' && value.length > 0 && value.length <= 300;
48
+ const keyList = (value) => [...new Set((Array.isArray(value) ? value : []).filter(isKey))];
49
+
50
+ /** A record as it is used: unknown shapes are an empty record, never an exception. */
51
+ export function normalizeChoices(data) {
52
+ const out = { version: TOOL_CHOICES_VERSION, choices: {}, restores: [] };
53
+ if (!data || typeof data !== 'object' || Array.isArray(data)) return out;
54
+ const choices = data.choices && typeof data.choices === 'object' && !Array.isArray(data.choices) ? data.choices : {};
55
+ for (const [key, value] of Object.entries(choices)) if (isKey(key) && typeof value === 'boolean') out.choices[key] = value;
56
+ for (const entry of Array.isArray(data.restores) ? data.restores : []) {
57
+ if (!entry || typeof entry !== 'object') continue;
58
+ const keys = keyList(entry.keys);
59
+ if (!keys.length) continue;
60
+ out.restores.push({
61
+ at: typeof entry.at === 'string' ? entry.at : null,
62
+ reason: entry.reason === 'read' ? 'read' : 'start',
63
+ appVersion: typeof entry.appVersion === 'string' ? entry.appVersion : null,
64
+ keys,
65
+ });
66
+ }
67
+ out.restores = out.restores.slice(-RESTORE_HISTORY);
68
+ if (typeof data.updatedAt === 'string') out.updatedAt = data.updatedAt;
69
+ return out;
70
+ }
71
+
72
+ /** The tools of `known` whose saved choice is on. */
73
+ export function savedOn(choices, known) {
74
+ const set = known instanceof Set ? known : new Set(known || []);
75
+ return Object.keys(choices || {}).filter((key) => choices[key] === true && set.has(key));
76
+ }
77
+
78
+ /**
79
+ * What a start does to an allow list: the saved `on` tools that are missing are put back (`restored`, appended in
80
+ * the order of `known`), and the tools the list allows without a saved `on` are adopted as such (`adopted`).
81
+ * `allow` is returned as it was when nothing is missing: the caller writes only when `restored` is not empty.
82
+ * Rules that are not SynaBun's tools (Bash(...), another server's) are never looked at.
83
+ */
84
+ export function planStart({ allow, choices, known }) {
85
+ const list = Array.isArray(allow) ? allow.filter((rule) => typeof rule === 'string') : [];
86
+ const present = new Set(list);
87
+ const order = [...(known instanceof Set ? known : new Set(known || []))];
88
+ const restored = order.filter((key) => choices?.[key] === true && !present.has(key));
89
+ const adopted = order.filter((key) => present.has(key) && choices?.[key] !== true);
90
+ return { allow: restored.length ? [...list, ...restored] : list, restored, adopted };
91
+ }
92
+
93
+ /**
94
+ * True when the allow list lost every saved `on` tool at once: the file was replaced (or emptied), which no owner
95
+ * does one rule at a time. Fewer than WHOLESALE_MIN saved tools never count: one or two missing rules can be a
96
+ * removal by hand.
97
+ */
98
+ export function lostWholesale({ allow, choices, known }) {
99
+ const saved = savedOn(choices, known);
100
+ if (saved.length < WHOLESALE_MIN) return false;
101
+ const present = new Set(Array.isArray(allow) ? allow : []);
102
+ return saved.every((key) => !present.has(key));
103
+ }
104
+
105
+ /**
106
+ * The record over one file.
107
+ * @param {object} o
108
+ * @param {string} o.path DATA_HOME/data/tool-permissions.json
109
+ * @param {() => Date} [o.now]
110
+ * @param {(line: string) => void} [o.log]
111
+ * @param {string} [o.appVersion] written with every restore (which version put the tools back)
112
+ */
113
+ export function createToolPermissionChoices({ path, now = () => new Date(), log = () => {}, appVersion = '' } = {}) {
114
+ if (!path) throw new Error('createToolPermissionChoices requires a path');
115
+ let warned = false;
116
+
117
+ /** The record. A file that cannot be read is kept aside (`.damaged`) and counts as an empty one. */
118
+ function read() {
119
+ let raw;
120
+ try {
121
+ if (!existsSync(path)) return normalizeChoices(null);
122
+ raw = readFileSync(path, 'utf8');
123
+ } catch (error) {
124
+ if (!warned) { warned = true; log(`[tool-permissions] ${path} could not be read (${error?.message || error}); the saved choices are not used.`); }
125
+ return normalizeChoices(null);
126
+ }
127
+ try {
128
+ return normalizeChoices(JSON.parse(raw.replace(/^/, '')));
129
+ } catch (error) {
130
+ try { renameSync(path, `${path}.damaged`); } catch { /* it stays where it is; the next write replaces it */ }
131
+ log(`[tool-permissions] ${path} was not valid JSON (${error?.message || error}); it is kept as ${path}.damaged and the choices start again from the allow list.`);
132
+ return normalizeChoices(null);
133
+ }
134
+ }
135
+
136
+ /** Never throws: a record that cannot be written must not stop a switch from working. */
137
+ function write(record) {
138
+ const next = { ...normalizeChoices(record), updatedAt: now().toISOString() };
139
+ const tmp = `${path}.${process.pid}.tmp`;
140
+ try {
141
+ mkdirSync(dirname(path), { recursive: true });
142
+ writeFileSync(tmp, `${JSON.stringify(next, null, 2)}\n`, 'utf8');
143
+ renameSync(tmp, path);
144
+ return true;
145
+ } catch (error) {
146
+ try { if (existsSync(tmp)) unlinkSync(tmp); } catch { /* nothing to clean */ }
147
+ log(`[tool-permissions] the saved choices could not be written to ${path}: ${error?.message || error}`);
148
+ return false;
149
+ }
150
+ }
151
+
152
+ /** The owner switched these tools on or off (Settings, or a rule removed in the side panel). */
153
+ function note(keys, enabled) {
154
+ const list = keyList(keys);
155
+ if (!list.length || typeof enabled !== 'boolean') return false;
156
+ const record = read();
157
+ let changed = false;
158
+ for (const key of list) if (record.choices[key] !== enabled) { record.choices[key] = enabled; changed = true; }
159
+ return changed ? write(record) : false;
160
+ }
161
+
162
+ /** The tools the allow list has are `on` choices from now on (a grant made in Claude Code, the memory tools' default). */
163
+ function adopt(allow, known) {
164
+ const record = read();
165
+ const { adopted } = planStart({ allow, choices: record.choices, known });
166
+ if (!adopted.length) return [];
167
+ for (const key of adopted) record.choices[key] = true;
168
+ write(record);
169
+ return adopted;
170
+ }
171
+
172
+ /** These tools were put back into the allow list (what, when, why, by which version). */
173
+ function noteRestore(keys, reason) {
174
+ const list = keyList(keys);
175
+ if (!list.length) return;
176
+ const record = read();
177
+ record.restores = [...record.restores, { at: now().toISOString(), reason: reason === 'read' ? 'read' : 'start', appVersion: appVersion || null, keys: list }].slice(-RESTORE_HISTORY);
178
+ write(record);
179
+ }
180
+
181
+ /** True when the owner switched this tool off: SynaBun then never allows it by itself. */
182
+ function isOff(key) { return read().choices[key] === false; }
183
+
184
+ return { path, read, note, adopt, noteRestore, isOff, choices: () => read().choices };
185
+ }
186
+
187
+ /**
188
+ * Bring an allow list in line with the saved choices, through the caller's own reading and writing of the settings
189
+ * file (server.js readClaudeSettingsForWrite / writeClaudeSettings: a file that is not JSON is never written over).
190
+ *
191
+ * @param {object} o
192
+ * @param {ReturnType<typeof createToolPermissionChoices>} o.store
193
+ * @param {string} o.settingsPath ~/.claude/settings.json
194
+ * @param {(path: string) => object} o.read {} when the file does not exist; throws when it is not JSON
195
+ * @param {(path: string, settings: object) => void} o.write
196
+ * @param {Iterable<string>} o.known every tool key the running version has
197
+ * @param {'start' | 'read'} [o.reason] `read` restores only a wholesale loss
198
+ * @returns {{ state: 'unchanged' | 'restored' | 'error', restored: string[], adopted: string[], allow: string[], message?: string }}
199
+ */
200
+ export function reconcileToolPermissions({ store, settingsPath, read, write, known, reason = 'start', log = () => {} }) {
201
+ const knownSet = known instanceof Set ? known : new Set(known || []);
202
+ let settings;
203
+ try { settings = read(settingsPath); } catch (error) {
204
+ return { state: 'error', restored: [], adopted: [], allow: [], message: String(error?.message || error) };
205
+ }
206
+ if (!settings || typeof settings !== 'object' || Array.isArray(settings)) {
207
+ return { state: 'error', restored: [], adopted: [], allow: [], message: `${settingsPath} does not hold a settings object.` };
208
+ }
209
+ const allow = Array.isArray(settings.permissions?.allow) ? settings.permissions.allow : [];
210
+ const choices = store.choices();
211
+ const plan = planStart({ allow, choices, known: knownSet });
212
+ const due = plan.restored.length > 0 && (reason !== 'read' || lostWholesale({ allow, choices, known: knownSet }));
213
+ if (!due) {
214
+ const adopted = plan.adopted.length ? store.adopt(allow, knownSet) : [];
215
+ return { state: 'unchanged', restored: [], adopted, allow: allow.filter((rule) => typeof rule === 'string') };
216
+ }
217
+ const permissions = settings.permissions && typeof settings.permissions === 'object' && !Array.isArray(settings.permissions) ? settings.permissions : {};
218
+ settings.permissions = { ...permissions, allow: plan.allow };
219
+ try { write(settingsPath, settings); } catch (error) {
220
+ return { state: 'error', restored: [], adopted: [], allow: allow.filter((rule) => typeof rule === 'string'), message: String(error?.message || error) };
221
+ }
222
+ store.noteRestore(plan.restored, reason);
223
+ const adopted = plan.adopted.length ? store.adopt(plan.allow, knownSet) : [];
224
+ log(`[tool-permissions] ${plan.restored.length} saved tool permission${plan.restored.length === 1 ? ' was' : 's were'} missing from ${settingsPath} and ${plan.restored.length === 1 ? 'was' : 'were'} put back (${reason === 'read' ? 'Settings was opened' : 'server start'}).`);
225
+ return { state: 'restored', restored: plan.restored, adopted, allow: plan.allow };
226
+ }
@@ -48,7 +48,7 @@
48
48
  // model, or a card without that sentence, approves the route only.
49
49
 
50
50
  import { CONTROL_KINDS, buildControlResponse, describeToolInput, normalizeAnswers, normalizeControlRequest } from '../../public/shared/assistant/asst-control.js';
51
- import { buildRouteResponse, normalizeRouteRequest, routeOptions } from '../../public/shared/assistant/asst-route.js';
51
+ import { buildRouteResponse, normalizeRouteRequest, routeHereModelLabel, routeOptions, routeTitleWithEffort, routeTitleWithoutEffort } from '../../public/shared/assistant/asst-route.js';
52
52
  import { isComputerTool, isDeniedRemoteTool, providerLabel } from '../remote-policy.js';
53
53
 
54
54
  // Codes a person can read out loud: no 0/O, 1/I/L, 2/Z, 5/S, 8/B.
@@ -260,14 +260,20 @@ function questionLines(card, lead, leadMany) {
260
260
  if (questions.length === 1) return [`${lead}${questionLine(questions[0])}`];
261
261
  return [leadMany, ...questions.map((q) => `- ${questionLine(q)}`), 'One message with your answers is fine.'];
262
262
  }
263
- /** What picking a route choice means, in words: "do it here with Sonnet 5" / "hand it to GPT-6 Sol". */
263
+ /** A choice that runs in this conversation: "here" on its model, or on another model of its provider. */
264
+ const runsHere = (choice) => !!choice?.here || choice?.kind === 'direct';
265
+ /**
266
+ * What picking a route choice means, in words: "do it here with Sonnet 5 · high" / "hand it to GPT-6 Sol".
267
+ * The router labels a "here" option "Do it here with <model>": the sentence names the model, then its effort
268
+ * in the card's words (" · xhigh", thinking off " · off"; no effort, nothing), as the card's title does, so
269
+ * two choices done here on one model read apart. A worker's label already ends in its effort when it has one.
270
+ */
264
271
  function choiceName(choice) {
265
- // The router labels a "here" option "Do it here with <model>": the sentence names the model only.
266
272
  const strip = (value) => clean(value).replace(/^do it here with /i, '');
267
- return strip(choice.label) || strip(choice.title) || 'that model';
273
+ if (!runsHere(choice)) return strip(choice.label) || strip(choice.title) || 'that model';
274
+ const model = clean(routeHereModelLabel(choice)) || routeTitleWithoutEffort(strip(choice.title), choice.effort);
275
+ return model ? routeTitleWithEffort(model, choice.effort) : 'that model';
268
276
  }
269
- /** A choice that runs in this conversation: "here" on its model, or on another model of its provider. */
270
- const runsHere = (choice) => !!choice?.here || choice?.kind === 'direct';
271
277
  function routePhrase(choice, { it = 'it' } = {}) {
272
278
  return runsHere(choice) ? `do ${it} here with ${choiceName(choice)}` : `hand ${it} to ${choiceName(choice)}`;
273
279
  }
@@ -415,6 +421,8 @@ function matchOption(options, text) {
415
421
  const hits = (options || []).filter((option) => plain(option.label) === said);
416
422
  return hits.length === 1 ? hits[0] : null;
417
423
  }
424
+ // A route name as typed or as written: "Opus 5.5 · high" and "opus 5.5 high" are one name.
425
+ const routePlain = (value) => plain(value).replace(/\s*·\s*/g, ' ').replace(/\s+/g, ' ').trim();
418
426
  const PICK_LEAD = /^(?:please )?(?:use|with|on|pick|choose|take|try|go with|lets use|lets go with|hand it to|give it to|send it to|run it on|make it) /;
419
427
  /**
420
428
  * The offered route choice a reply names, else null. The reply is the name and
@@ -422,7 +430,7 @@ const PICK_LEAD = /^(?:please )?(?:use|with|on|pick|choose|take|try|go with|lets
422
430
  * such a verb) and an optional "please" / "instead". "don't use haiku" names nothing.
423
431
  */
424
432
  function matchRouteChoice(card, text) {
425
- let said = plain(text);
433
+ let said = routePlain(text);
426
434
  if (!said) return null;
427
435
  said = said.replace(/^(?:yes|yep|yeah|ok|okay|sure) (?=\S)/, '');
428
436
  const afterNo = said.replace(/^(?:no|nope|nah) /, '');
@@ -435,10 +443,16 @@ function matchRouteChoice(card, text) {
435
443
  const firstHere = card.routeChoices.find((choice) => choice.here) || card.routeChoices.find(runsHere) || null;
436
444
  const firstWorker = card.routeChoices.find((choice) => !runsHere(choice)) || null;
437
445
  const names = (choice) => {
438
- const list = [choice.label, choiceName(choice), choice.model, choice.title, String(choice.model || '').split('/').pop()].map(plain).filter(Boolean);
439
- if (choice === firstHere) list.push('here', 'do it here', 'do it yourself', 'yourself', 'you do it', `here with ${plain(choice.label)}`);
446
+ const list = [choice.label, choiceName(choice), choice.model, choice.title, String(choice.model || '').split('/').pop()];
447
+ // A choice done here is also named as the sentence says it: "do it here with Opus 5.5 · high".
448
+ if (runsHere(choice)) list.push(`do it here with ${choiceName(choice)}`, `here with ${choiceName(choice)}`);
449
+ if (choice === firstHere) {
450
+ list.push('here', 'do it here', 'do it yourself', 'yourself', 'you do it');
451
+ // "here with <model>" without an effort is this one only while no other choice done here is on that model.
452
+ if (!card.routeChoices.some((other) => other !== choice && runsHere(other) && routePlain(other.label) === routePlain(choice.label))) list.push(`here with ${choice.label}`);
453
+ }
440
454
  if (choice === firstWorker) list.push('dispatch', 'dispatch it', 'a worker', 'worker', 'hand it off', 'delegate', 'delegate it');
441
- return [...new Set(list)];
455
+ return [...new Set(list.map(routePlain).filter(Boolean))];
442
456
  };
443
457
  // A whole name first: "do it here" is the "here" option even when another option's label starts with it
444
458
  // ("Do it here with Haiku 4.5"); only then the start of a name ("sonnet" for "Sonnet 5").
@@ -35,10 +35,35 @@
35
35
  // off today's behaviour before this guard: Claude's read-only tool list, Codex's sandbox with the parent
36
36
  // folder, OpenCode answering "always"
37
37
  // Capability "full" is never guarded whatever the setting.
38
+ //
39
+ // Team slices (lib/teams/): a run that works one slice of a team is confined further, and always. Its working
40
+ // directory is the slice's own worktree (<project>/.worktrees/<team>/<slice>), and of the project's files it
41
+ // writes only the ones its slice owns:
42
+ //
43
+ // - a file tool, a redirection or a writing program that names a file of another slice, or one no slice owns,
44
+ // is refused, and the refusal tells the worker to ask the owner over the team channel;
45
+ // - a file git ignores (build output, node_modules) may be written: it is never committed;
46
+ // - the temp folder and the run's scratch folder stay writable, as for any workspace run;
47
+ // - git is for reading (status, diff, log, show…). SynaBun commits the slice's work when it finishes, on the
48
+ // slice's own branch; add, commit, stash, switch, push and the rest are refused. `git stash` in particular is
49
+ // shared by every worktree of a repository: a worker's pop would take the user's own stash.
50
+ //
51
+ // A team slice has no escape hatch: capability "full" is read as "workspace", and the Protect workers setting does
52
+ // not turn the rule off or down to a warning (resolveWorkerConfinement). The user's checkout and branch are never a
53
+ // worker's (owner decision, 2026-11-15), and files owned by one slice each are what lets a team's work be joined.
54
+ // A run is a team slice when resolveWorkerConfinement is given `team`, or when its working directory is inside a
55
+ // worktree registered with registerTeamSlice (lib/teams/claims.js registers every slice of a team under way), so
56
+ // an adapter that knows nothing about teams confines one all the same. Runs with no team context are unchanged.
57
+ //
58
+ // The limit above holds for a team slice too: a program the worker runs (a script, a build, a test runner, a
59
+ // formatter) writes what it writes, and the guard does not see it. On Codex the sandbox confines a slice to its
60
+ // worktree but knows nothing of owned paths. What catches such a write is the check after the fact: when a slice
61
+ // finishes, what its branch changed is compared with what it owns, and a slice that changed anything else is
62
+ // rejected (lib/teams/claims.js verifyOwnership, lib/teams/integration.js finishSlice).
38
63
 
39
64
  import { existsSync, lstatSync, realpathSync } from 'node:fs';
40
65
  import { homedir, tmpdir } from 'node:os';
41
- import { dirname, isAbsolute, join, resolve, sep } from 'node:path';
66
+ import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
42
67
  import { acpCall, acpToolPaths } from './antigravity/tool-call.js';
43
68
 
44
69
  export const WORKER_GUARD_MODES = Object.freeze(['enforce', 'warn', 'off']);
@@ -190,6 +215,147 @@ export function placeOf(raw, { cwd, home = homedir(), env = process.env, vars =
190
215
  return realPlace(abs);
191
216
  }
192
217
 
218
+ // ── Team slices ─────────────────────────────────────────────────────────────
219
+
220
+ /** The rule a refusal of a team slice carries (a file that is not the slice's, a git command that is not a read). */
221
+ export const TEAM_OWNERSHIP_RULE = 'team-ownership';
222
+ export const TEAM_GIT_RULE = 'team-git';
223
+
224
+ // The slices of teams under way, by their worktree (where it really is). In memory, for this process:
225
+ // lib/teams/claims.js fills it when a team starts and again after a restart (restore).
226
+ const teamSlices = new Map();
227
+
228
+ /**
229
+ * A team slice's context in the form the guard keeps, or null when it is not one. `check(relPath)` answers for a
230
+ * path relative to the worktree: `{ allow, owner, code, beneath }` (lib/teams/claims.js checkRelative).
231
+ */
232
+ function teamContext(value) {
233
+ if (!value || typeof value !== 'object') return null;
234
+ const { teamId, sliceId, worktree, check } = value;
235
+ if (typeof teamId !== 'string' || !teamId || typeof sliceId !== 'string' || !sliceId) return null;
236
+ if (typeof worktree !== 'string' || !isAbsolute(worktree) || typeof check !== 'function') return null;
237
+ return Object.freeze({
238
+ teamId, sliceId,
239
+ worktree: realPlace(resolve(worktree)),
240
+ projectPath: typeof value.projectPath === 'string' && isAbsolute(value.projectPath) ? realPlace(resolve(value.projectPath)) : null,
241
+ ownedPaths: Object.freeze(Array.isArray(value.ownedPaths) ? value.ownedPaths.filter((glob) => typeof glob === 'string') : []),
242
+ channel: typeof value.channel === 'string' && value.channel ? value.channel : `team:${teamId}`,
243
+ check,
244
+ });
245
+ }
246
+
247
+ /**
248
+ * Register a slice of a team under way: a run whose working directory is inside its worktree is then confined to
249
+ * the slice's own files, whoever starts it. Throws for a context without a team, a slice, an absolute worktree or
250
+ * a `check` function. Registering a worktree again replaces what was there.
251
+ * @returns {object} the context as kept
252
+ */
253
+ export function registerTeamSlice(context) {
254
+ const made = teamContext(context);
255
+ if (!made) throw new Error('A team slice context needs teamId, sliceId, an absolute worktree and a check(relPath) function.');
256
+ teamSlices.set(made.worktree, made);
257
+ return made;
258
+ }
259
+
260
+ /** Take a slice off the guard, by its context or its worktree. True when one was registered. */
261
+ export function unregisterTeamSlice(contextOrWorktree) {
262
+ const worktree = typeof contextOrWorktree === 'string' ? contextOrWorktree : contextOrWorktree?.worktree;
263
+ if (typeof worktree !== 'string' || !worktree) return false;
264
+ return teamSlices.delete(worktree) || teamSlices.delete(realPlace(resolve(worktree)));
265
+ }
266
+
267
+ /** The registered slice whose worktree is this folder or holds it, or null. */
268
+ export function teamSliceFor(cwd) {
269
+ if (typeof cwd !== 'string' || !cwd || !teamSlices.size) return null;
270
+ const place = realPlace(resolve(cwd));
271
+ for (const [worktree, context] of teamSlices) if (inside(worktree, place, true)) return context;
272
+ return null;
273
+ }
274
+
275
+ /** Every registered slice (for a status view and tests). */
276
+ export const registeredTeamSlices = () => [...teamSlices.values()];
277
+
278
+ /** A path inside the slice's worktree as the forward-slash path relative to it; '' for the worktree itself; null outside. */
279
+ function teamRelative(place, team) {
280
+ if (!inside(team.worktree, place, true)) return null;
281
+ return relative(team.worktree, place).split(sep).join('/');
282
+ }
283
+
284
+ const ownedText = (team) => (team.ownedPaths.length ? team.ownedPaths.slice(0, 8).join(', ') + (team.ownedPaths.length > 8 ? ', …' : '') : 'the paths its plan gives it');
285
+ const askText = (team, owner) => `Do not write it: ask ${owner && owner !== team.sliceId ? `slice "${owner}", which owns it,` : 'the team'} over the team channel (${team.channel}) for the change, and carry on with your own files.`;
286
+
287
+ // Programs that run in a folder and write what they decide themselves (a package manager's install, build or test
288
+ // script): the folder they are given is where they run, not a file they write. What they write is not seen here;
289
+ // the check when the slice finishes is what answers for it.
290
+ const WHOLE_FOLDER_KINDS = new Set(['pkg', 'pip', 'cargo']);
291
+
292
+ /**
293
+ * Whether a write a team slice's run names is the slice's to make: null when it is (or when this is not a team
294
+ * slice, or the place is outside the worktree, where the capability's own rule has already decided), else a
295
+ * refusal that names the owner and tells the worker to ask over the team channel.
296
+ * @param {string} place the resolved location (placeOf)
297
+ * @param {object} confinement
298
+ * @param {{ what: string, kind?: string|null, program?: string|null }} about
299
+ */
300
+ function teamRefusal(place, confinement, { what, kind = null, program = null } = {}) {
301
+ const team = confinement?.team;
302
+ if (!team || !place) return null;
303
+ const rel = teamRelative(place, team);
304
+ if (rel === null) {
305
+ // Outside the slice's worktree the capability's rule has decided already, with one thing more for a team: the
306
+ // rest of the project (the user's checkout, another slice's worktree) is never a slice's to write, also where
307
+ // the project happens to sit under a folder a workspace run may write (a project kept in the temp folder).
308
+ if (team.projectPath && inside(team.projectPath, place, true)) {
309
+ return refusal(TEAM_OWNERSHIP_RULE, `${what} would write ${place}, which is in the project but outside the worktree of slice "${team.sliceId}" (${team.worktree}): the user's checkout and the other slices' worktrees are never a slice's to write. ${askText(team, null)}`, place);
310
+ }
311
+ return null;
312
+ }
313
+ // sed -i and perl -i are given their program among the words: a word that names no file is the program, not a
314
+ // file they edit. `{}` is find's stand-in for a file it found: the folders find searches are checked instead.
315
+ if ((kind === 'sed' || kind === 'perl') && !existsSync(place)) return null;
316
+ if (/(?:^|\/)\{\}$/.test(rel)) return null;
317
+ const whole = kind !== null && WHOLE_FOLDER_KINDS.has(kind);
318
+ if (rel === '') {
319
+ if (whole) return null;
320
+ return refusal(TEAM_OWNERSHIP_RULE, `${what} names the whole worktree of slice "${team.sliceId}" (team ${team.teamId}), which also holds files of other slices. This slice writes ${ownedText(team)} only: name the files or folders of your own.`, place);
321
+ }
322
+ let verdict;
323
+ try { verdict = team.check(rel); } catch (err) { return refusal('check-failed', `The team's ownership of ${rel} could not be checked (${err?.message || err}), so the write is refused.`, place); }
324
+ if (verdict?.allow) return null;
325
+ // A program that runs in a folder may run in any folder of the worktree; making a folder on the way to the
326
+ // slice's own files changes nobody's file.
327
+ if (whole && verdict?.code !== 'reserved_path') return null;
328
+ if (program === 'mkdir' && verdict?.beneath) return null;
329
+ let isFolder = false;
330
+ try { isFolder = lstatSync(place).isDirectory(); } catch { isFolder = false; }
331
+ const owner = verdict?.owner || null;
332
+ const why = verdict?.code === 'reserved_path' ? `${rel} is git's own data or a worktree folder`
333
+ : verdict?.code === 'claim_released' ? `${rel} is this slice's, but the slice has finished and gave its files back`
334
+ : verdict?.code === 'lockfile' ? (owner ? `${rel} is a dependency lockfile, and only the lockfile owner (slice "${owner}") changes it` : `${rel} is a dependency lockfile, and this team has no lockfile owner`)
335
+ : isFolder ? `${rel} is a folder that holds files this slice does not own`
336
+ : owner ? `${rel} belongs to slice "${owner}"` : `${rel} is not owned by any slice of team ${team.teamId}`;
337
+ return refusal(TEAM_OWNERSHIP_RULE, `${what} would write a file that is not this slice's: ${why}. Slice "${team.sliceId}" (team ${team.teamId}) writes ${ownedText(team)} only. ${askText(team, owner)} SynaBun rejects a slice that changed files outside its ownership when it finishes.`, place);
338
+ }
339
+
340
+ /** git in a team slice: reading only. Null when the command reads, else the refusal. */
341
+ function teamGitRefusal(args, confinement) {
342
+ const team = confinement?.team;
343
+ if (!team) return null;
344
+ let rest = args;
345
+ while (rest.length && isOption(rest[0])) {
346
+ if ((rest[0] === '-C' || rest[0] === '-c') && rest[1] !== undefined) { rest = rest.slice(2); continue; }
347
+ if (rest[0] === '--no-pager' || rest[0] === '-P') { rest = rest.slice(1); continue; }
348
+ return refusal(TEAM_GIT_RULE, `git with the global option ${rest[0]} did not run: in a team slice git is for reading your own worktree (status, diff, log, show, blame…).`);
349
+ }
350
+ const [sub, ...subArgs] = rest;
351
+ if (!sub) return null;
352
+ // `git tag <name>` makes a tag (the table above takes any word for a pattern to list).
353
+ const makesTag = sub === 'tag' && subArgs.some((w) => !w.startsWith('-')) && !subArgs.some((w) => /^(-l|--list|-n\d*|--contains|--no-contains|--merged|--no-merged|--points-at)$/.test(w));
354
+ if (!makesTag && (GIT_READ.has(sub) || GIT_READ_WITH_ARGS.get(sub)?.(subArgs)) && !subArgs.some((w) => blockedFlag(w, GIT_BLOCKED))) return null;
355
+ const stash = sub === 'stash' ? ' The stash is shared by every worktree of the repository: a pop here would take the user\'s own stashed work.' : '';
356
+ return refusal(TEAM_GIT_RULE, `git ${sub} did not run: in a team slice git is for reading (status, diff, log, show, blame…). SynaBun commits the work of slice "${team.sliceId}" on its own branch when the slice finishes, and joins it with the team's; leave your changes in the working tree, and put a file back with "git show HEAD:<path> > <path>".${stash} If you need something else done in the repository, ask over the team channel (${team.channel}).`);
357
+ }
358
+
193
359
  // ── The confinement ─────────────────────────────────────────────────────────
194
360
 
195
361
  /**
@@ -205,10 +371,22 @@ export function placeOf(raw, { cwd, home = homedir(), env = process.env, vars =
205
371
  * @param {number[]} [o.localPorts] other local ports of SynaBun's the shell may not call (the run's own OpenCode serve)
206
372
  * @param {{ from:number, to:number }} [o.localPortRange] the ports SynaBun keeps for its OpenCode serves (4096-4400),
207
373
  * the same band the macOS sandbox denies (lib/worker-sandbox.js)
374
+ * @param {object} [o.team] the team slice this run works (lib/teams/claims.js `context(teamId, sliceId)`). Without
375
+ * it, a working directory inside a registered slice's worktree (registerTeamSlice) makes the run that slice's.
376
+ * A team slice is always guarded: capability full is read as workspace and the mode as enforce, the working
377
+ * directory must be inside the slice's worktree, and `confinement.team` carries the slice.
208
378
  */
209
- export function resolveWorkerConfinement({ capability, cwd, mode = WORKER_GUARD_DEFAULT, scratchDir = null, tmpDirs = null, home = homedir(), serverPort = null, localPorts = null, localPortRange = null } = {}) {
210
- const cap = String(capability || 'full');
211
- const guard = normalizeWorkerGuardMode(mode);
379
+ export function resolveWorkerConfinement({ capability, cwd, mode = WORKER_GUARD_DEFAULT, scratchDir = null, tmpDirs = null, home = homedir(), serverPort = null, localPorts = null, localPortRange = null, team = null } = {}) {
380
+ let cap = String(capability || 'full');
381
+ let guard = normalizeWorkerGuardMode(mode);
382
+ const given = team !== null && team !== undefined;
383
+ const slice = given ? teamContext(team) : teamSliceFor(cwd);
384
+ if (given && !slice) throw new Error('A team slice run needs its slice context (team, slice, worktree and the ownership check): the run did not start.');
385
+ if (slice) {
386
+ // A team's rule is not the Protect workers setting's to switch off, and has no escape hatch.
387
+ if (cap !== 'read-only') cap = 'workspace';
388
+ guard = 'enforce';
389
+ }
212
390
  if (!GUARDED_CAPABILITIES.includes(cap) || guard === 'off') return null;
213
391
  // A guarded run is rooted where the dispatcher put it, never where the server happens to run: without a working
214
392
  // directory its scratch folder is the only writable root, and without either it does not start.
@@ -218,6 +396,10 @@ export function resolveWorkerConfinement({ capability, cwd, mode = WORKER_GUARD_
218
396
  // later) is kept as named: the rule still holds by its name, and realPlace() resolves what exists at each call.
219
397
  let root;
220
398
  try { root = realpathSync(rootDir); } catch { root = resolve(rootDir); }
399
+ // A team slice works in its own worktree: never the project's checkout, never another slice's.
400
+ if (slice && !(cwd && typeof cwd === 'string' && inside(slice.worktree, root, true))) {
401
+ throw new Error(`A run of slice "${slice.sliceId}" (team ${slice.teamId}) works in the slice's own worktree (${slice.worktree}), not in ${cwd || 'a scratch folder'}: the run did not start.`);
402
+ }
221
403
  const temps = Array.isArray(tmpDirs) ? tmpDirs : [tmpdir(), '/tmp'];
222
404
  const writable = [root];
223
405
  for (const dir of [...temps, scratchDir].filter(Boolean)) {
@@ -229,6 +411,7 @@ export function resolveWorkerConfinement({ capability, cwd, mode = WORKER_GUARD_
229
411
  localPorts: Object.freeze([...new Set((Array.isArray(localPorts) ? localPorts : []).map(Number).filter(validPort))]),
230
412
  localPortRange: portRange(localPortRange),
231
413
  protectedDirs: Object.freeze(PROTECTED_HOME_DIRS.map((d) => join(home, d))),
414
+ ...(slice ? { team: slice } : {}),
232
415
  });
233
416
  }
234
417
 
@@ -297,11 +480,15 @@ export function workerToolDecision(toolName, input, confinement) {
297
480
  const place = raw ? placeOf(raw, { cwd: confinement.cwd, home: confinement.home }) : null;
298
481
  if (!place) return refusal('unknown-path', `${name} needs a plain path: SynaBun could not read "${String(raw || '').slice(0, 200)}". This run writes inside ${rootsText(confinement)} only.`);
299
482
  if (!mayWrite(place, confinement)) return refusal('write-outside', `${name} to ${place} is outside this run's workspace. This run (capability workspace) writes inside ${rootsText(confinement)} only; nothing is written under the home folder, another project or a tool's configuration.`, place);
300
- return null;
483
+ return teamRefusal(place, confinement, { what: name });
301
484
  }
302
485
  if (/^mcp__SynaBun__git$/.test(name) && confinement.capability === 'read-only' && String(args.action || '') === 'commit') {
303
486
  return refusal('read-only', 'This run has capability read-only: the git tool\'s commit action is not available.');
304
487
  }
488
+ // A team slice's work is committed by SynaBun when the slice finishes: the git tool reads, for a slice.
489
+ if (/^mcp__SynaBun__git$/.test(name) && confinement.team && String(args.action || '') === 'commit') {
490
+ return refusal(TEAM_GIT_RULE, `The git tool's commit action is not available in a team slice: SynaBun commits the work of slice "${confinement.team.sliceId}" on its own branch when the slice finishes. Leave your changes in the working tree.`);
491
+ }
305
492
  // Another MCP server's tool under read-only: one whose name says it writes is refused (SynaBun's own tools go
306
493
  // through SynaBun's own policies and stay; a third-party server's writes are its own and cannot be confined).
307
494
  const mcp = /^mcp__([^_].*?)__(.+)$/.exec(name);
@@ -938,6 +1125,8 @@ function checkSegment(seg, confinement, readOnly) {
938
1125
  const place = placeOf(target, { cwd, home: confinement.home, vars: seg.vars });
939
1126
  if (!place) return refusal('unknown-path', `The redirection target "${target.slice(0, 200)}" uses a value SynaBun could not resolve (an unknown variable, a command substitution other than $(mktemp …), or an odd character), so the command did not run. ${passHint(confinement)}`);
940
1127
  if (!mayWrite(place, confinement)) return refusal('write-outside', `${r.op} ${target} would write ${place}, outside this run's workspace. This run writes inside ${rootsText(confinement)} only.`, place);
1128
+ const notMine = teamRefusal(place, confinement, { what: `${r.op} ${target}` });
1129
+ if (notMine) return notMine;
941
1130
  }
942
1131
  return checkWords(seg.words, { cwd, piped: seg.piped, stdin: seg.stdin, vars: seg.vars }, confinement, readOnly);
943
1132
  }
@@ -1006,6 +1195,8 @@ function checkWords(rawWords, ctx, confinement, readOnly, depth = 0) {
1006
1195
  const place = placeOf(root, { cwd, home: confinement.home, vars: ctx.vars });
1007
1196
  if (!place) return refusal('unknown-path', `${program} names a folder SynaBun could not read ("${String(root).slice(0, 200)}"), so its -exec ${innerProgram} did not run.`);
1008
1197
  if (!mayWrite(place, confinement)) return refusal('write-outside', `${program} … -exec ${innerProgram} would act on files under ${place}, outside this run's workspace. This run writes inside ${rootsText(confinement)} only.`, place);
1198
+ const notMine = teamRefusal(place, confinement, { what: `${program} … -exec ${innerProgram}` });
1199
+ if (notMine) return notMine;
1009
1200
  }
1010
1201
  }
1011
1202
  }
@@ -1036,6 +1227,11 @@ function checkWords(rawWords, ctx, confinement, readOnly, depth = 0) {
1036
1227
  return null;
1037
1228
  }
1038
1229
  // workspace
1230
+ // A team slice: git reads only (SynaBun commits the slice's work when it finishes).
1231
+ if (confinement.team && program === 'git') {
1232
+ const notRead = teamGitRefusal(args, confinement);
1233
+ if (notRead) return notRead;
1234
+ }
1039
1235
  const kind = WRITERS.get(program);
1040
1236
  if (!kind) return null;
1041
1237
  const targets = writtenPaths(program, kind, args);
@@ -1045,6 +1241,8 @@ function checkWords(rawWords, ctx, confinement, readOnly, depth = 0) {
1045
1241
  const place = placeOf(target, { cwd, home: confinement.home, vars: ctx.vars });
1046
1242
  if (!place) return refusal('unknown-path', `${program} names a path SynaBun could not resolve ("${String(target).slice(0, 200)}": an unknown variable, a command substitution other than $(mktemp …), or an odd character), so it did not run. ${passHint(confinement)}`);
1047
1243
  if (!mayWrite(place, confinement)) return refusal('write-outside', `${program} would write ${place}, outside this run's workspace. This run (capability workspace) writes inside ${rootsText(confinement)} only; nothing is written under the home folder, another project or a tool's configuration.`, place);
1244
+ const notMine = teamRefusal(place, confinement, { what: `${program} ${target}`, kind, program });
1245
+ if (notMine) return notMine;
1048
1246
  }
1049
1247
  return null;
1050
1248
  }
@@ -1140,7 +1338,7 @@ export function openCodePermissionDecision(request, confinement, { toolName = nu
1140
1338
  const place = raw ? placeOf(raw, { cwd: confinement.cwd, home: confinement.home }) : null;
1141
1339
  if (!place) return refusal('unknown-path', `${kind} names a path SynaBun could not read; this run writes inside ${rootsText(confinement)} only.`);
1142
1340
  if (!mayWrite(place, confinement)) return refusal('write-outside', `${kind} to ${place} is outside this run's workspace: this run writes inside ${rootsText(confinement)} only.`, place);
1143
- return null;
1341
+ return teamRefusal(place, confinement, { what: kind });
1144
1342
  }
1145
1343
  if (kind === 'external_directory') {
1146
1344
  // Reads outside the workspace are allowed; writes are not. The adapter resolves the ask's tool reference
@@ -1205,6 +1403,8 @@ export function acpPermissionDecision(rawCall, confinement) {
1205
1403
  const place = placeOf(raw, { cwd: confinement.cwd, home: confinement.home });
1206
1404
  if (!place) return refusal('unknown-path', `${label} names a path SynaBun could not read ("${String(raw).slice(0, 200)}"); this run writes inside ${rootsText(confinement)} only.`);
1207
1405
  if (!mayWrite(place, confinement)) return refusal('write-outside', `${label} (${kind}) to ${place} is outside this run's workspace: this run writes inside ${rootsText(confinement)} only.`, place);
1406
+ const notMine = teamRefusal(place, confinement, { what: `${label} (${kind})` });
1407
+ if (notMine) return notMine;
1208
1408
  }
1209
1409
  return null;
1210
1410
  }