synabun 2.3.1 → 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 (356) hide show
  1. package/CHANGELOG.md +24 -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 +1117 -47
  103. package/neural-interface/i18n/pt-BR.json +1117 -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-tool-policy.js +1 -1
  135. package/neural-interface/lib/claude-account-links.js +301 -0
  136. package/neural-interface/lib/claude-accounts.js +45 -20
  137. package/neural-interface/lib/claude-agent-bridge.js +142 -10
  138. package/neural-interface/lib/claude-model-catalog.js +6 -0
  139. package/neural-interface/lib/claude-panel-session.js +33 -0
  140. package/neural-interface/lib/codex-accounts.js +67 -24
  141. package/neural-interface/lib/coordination/README.md +384 -0
  142. package/neural-interface/lib/coordination/service.js +563 -0
  143. package/neural-interface/lib/coordination/store.js +1138 -0
  144. package/neural-interface/lib/db.js +22 -1
  145. package/neural-interface/lib/effort-levels.js +10 -1
  146. package/neural-interface/lib/memory-list-page.js +49 -0
  147. package/neural-interface/lib/memory-list-stamp.js +60 -0
  148. package/neural-interface/lib/morelogin-outside-close.js +186 -0
  149. package/neural-interface/lib/morelogin-profile-failures.js +206 -0
  150. package/neural-interface/lib/morelogin-start-cooldown.js +160 -0
  151. package/neural-interface/lib/morelogin.js +194 -8
  152. package/neural-interface/lib/native-loop-runtime.js +20 -0
  153. package/neural-interface/lib/opencode-build-preflight.js +16 -1
  154. package/neural-interface/lib/opencode-native-boundary.js +83 -13
  155. package/neural-interface/lib/opencode-serve-records.js +14 -9
  156. package/neural-interface/lib/page-session.js +1 -1
  157. package/neural-interface/lib/peer-identity.js +60 -21
  158. package/neural-interface/lib/process-identity.js +68 -7
  159. package/neural-interface/lib/request-gate.js +3 -0
  160. package/neural-interface/lib/screenshot-location.js +33 -0
  161. package/neural-interface/lib/skills/creation.js +1 -1
  162. package/neural-interface/lib/skills/known-bridge-digests.json +40 -0
  163. package/neural-interface/lib/studio-attention.js +56 -0
  164. package/neural-interface/lib/teams/README.md +382 -0
  165. package/neural-interface/lib/teams/api.js +287 -0
  166. package/neural-interface/lib/teams/brief.js +185 -0
  167. package/neural-interface/lib/teams/claims.js +315 -0
  168. package/neural-interface/lib/teams/git.js +293 -0
  169. package/neural-interface/lib/teams/index.js +122 -0
  170. package/neural-interface/lib/teams/integration.js +580 -0
  171. package/neural-interface/lib/teams/landing.js +184 -0
  172. package/neural-interface/lib/teams/recovery.js +256 -0
  173. package/neural-interface/lib/teams/scheduler.js +1474 -0
  174. package/neural-interface/lib/teams/schema.js +559 -0
  175. package/neural-interface/lib/teams/state.js +181 -0
  176. package/neural-interface/lib/teams/test-runner.js +86 -0
  177. package/neural-interface/lib/teams/test-sandbox.js +99 -0
  178. package/neural-interface/lib/teams/worktrees.js +757 -0
  179. package/neural-interface/lib/tool-permission-choices.js +226 -0
  180. package/neural-interface/lib/whatsapp/cards.js +24 -10
  181. package/neural-interface/lib/worker-confinement.js +206 -6
  182. package/neural-interface/package-lock.json +2 -2
  183. package/neural-interface/package.json +1 -1
  184. package/neural-interface/public/extension-setup.html +107 -0
  185. package/neural-interface/public/index.html +52 -12
  186. package/neural-interface/public/shared/agent-runtime-options.js +3 -1
  187. package/neural-interface/public/shared/agents/studio/ax-agent-view.js +614 -0
  188. package/neural-interface/public/shared/agents/studio/ax-api.js +198 -0
  189. package/neural-interface/public/shared/agents/studio/ax-create-view.js +221 -0
  190. package/neural-interface/public/shared/agents/studio/ax-diff.js +143 -0
  191. package/neural-interface/public/shared/agents/studio/ax-editor-view.js +392 -0
  192. package/neural-interface/public/shared/agents/studio/ax-export-view.js +94 -0
  193. package/neural-interface/public/shared/agents/studio/ax-form.js +191 -0
  194. package/neural-interface/public/shared/agents/studio/ax-icons.js +87 -0
  195. package/neural-interface/public/shared/agents/studio/ax-library-view.js +158 -0
  196. package/neural-interface/public/shared/agents/studio/ax-library.js +162 -0
  197. package/neural-interface/public/shared/agents/studio/ax-main.js +712 -0
  198. package/neural-interface/public/shared/agents/studio/ax-native-export.js +35 -0
  199. package/neural-interface/public/shared/agents/studio/ax-options.js +198 -0
  200. package/neural-interface/public/shared/agents/studio/ax-review-view.js +175 -0
  201. package/neural-interface/public/shared/agents/studio/ax-revisions-view.js +189 -0
  202. package/neural-interface/public/shared/agents/studio/ax-runs-view.js +202 -0
  203. package/neural-interface/public/shared/agents/studio/ax-runs.js +82 -0
  204. package/neural-interface/public/shared/agents/studio/ax-teams-view.js +256 -0
  205. package/neural-interface/public/shared/agents/studio/ax-teams.js +200 -0
  206. package/neural-interface/public/shared/agents/studio/ax-templates.js +50 -0
  207. package/neural-interface/public/shared/agents/studio/ax-ui.js +194 -0
  208. package/neural-interface/public/shared/agents/studio/ax-views.js +170 -0
  209. package/neural-interface/public/shared/agy/agy-panel.js +142 -28
  210. package/neural-interface/public/shared/agy/agy-styles.js +25 -5
  211. package/neural-interface/public/shared/assistant/asst-account-menu.js +13 -13
  212. package/neural-interface/public/shared/assistant/asst-ask-styles.js +2 -3
  213. package/neural-interface/public/shared/assistant/asst-brain-picker.js +91 -9
  214. package/neural-interface/public/shared/assistant/asst-control.js +3 -0
  215. package/neural-interface/public/shared/assistant/asst-interaction-hold.js +99 -0
  216. package/neural-interface/public/shared/assistant/asst-limit-dismissals.js +111 -0
  217. package/neural-interface/public/shared/assistant/asst-limit-dock.js +37 -3
  218. package/neural-interface/public/shared/assistant/asst-limit-wait.js +30 -7
  219. package/neural-interface/public/shared/assistant/asst-panel.js +177 -30
  220. package/neural-interface/public/shared/assistant/asst-rack-styles.js +15 -8
  221. package/neural-interface/public/shared/assistant/asst-render.js +36 -6
  222. package/neural-interface/public/shared/assistant/asst-route.js +78 -12
  223. package/neural-interface/public/shared/assistant/asst-routes-editor.js +148 -70
  224. package/neural-interface/public/shared/assistant/asst-roving.js +17 -1
  225. package/neural-interface/public/shared/assistant/asst-scene-styles.js +7 -2
  226. package/neural-interface/public/shared/assistant/asst-scenes.js +12 -1
  227. package/neural-interface/public/shared/assistant/asst-sidepanel.js +12 -2
  228. package/neural-interface/public/shared/assistant/asst-state.js +66 -1
  229. package/neural-interface/public/shared/assistant/asst-styles.js +98 -44
  230. package/neural-interface/public/shared/assistant/route-identity.js +16 -0
  231. package/neural-interface/public/shared/cdx/cdx-output.js +10 -0
  232. package/neural-interface/public/shared/cdx/cdx-panel.js +18 -16
  233. package/neural-interface/public/shared/cdx/cdx-plan.js +3 -2
  234. package/neural-interface/public/shared/cdx/cdx-render.js +122 -45
  235. package/neural-interface/public/shared/cdx/cdx-requests.js +4 -4
  236. package/neural-interface/public/shared/cdx/cdx-styles.js +8 -36
  237. package/neural-interface/public/shared/cdx/cdx-tabs.js +110 -42
  238. package/neural-interface/public/shared/claude-panel-lazy.js +12 -0
  239. package/neural-interface/public/shared/code-copy.js +120 -0
  240. package/neural-interface/public/shared/constants.js +7 -0
  241. package/neural-interface/public/shared/context-menu-model.js +1 -0
  242. package/neural-interface/public/shared/cp/cp-markdown.js +7 -2
  243. package/neural-interface/public/shared/cp/cp-session-model.js +86 -5
  244. package/neural-interface/public/shared/cp/cp-session-settings.js +58 -30
  245. package/neural-interface/public/shared/cp/cp-styles.js +9 -0
  246. package/neural-interface/public/shared/dom-change-flag.js +66 -0
  247. package/neural-interface/public/shared/dom-morph.js +124 -0
  248. package/neural-interface/public/shared/extension-setup/es-page.css +134 -0
  249. package/neural-interface/public/shared/extension-setup/es-page.js +120 -0
  250. package/neural-interface/public/shared/extension-setup/es-view.js +100 -0
  251. package/neural-interface/public/shared/html-shell.js +33 -4
  252. package/neural-interface/public/shared/i18n.js +14 -1
  253. package/neural-interface/public/shared/idle-queue.js +78 -0
  254. package/neural-interface/public/shared/iface-config.js +227 -0
  255. package/neural-interface/public/shared/lazy-module.js +108 -0
  256. package/neural-interface/public/shared/memory-list.js +117 -0
  257. package/neural-interface/public/shared/morelogin-profile-choices.js +1 -1
  258. package/neural-interface/public/shared/morelogin-profile-field.js +3 -3
  259. package/neural-interface/public/shared/mtc/mtc-panel.js +3 -1
  260. package/neural-interface/public/shared/mtc/mtc-styles.js +4 -1
  261. package/neural-interface/public/shared/ocp-v2/ocp-v2-manager.js +35 -15
  262. package/neural-interface/public/shared/ocp-v2/ocp-v2-panel.js +77 -23
  263. package/neural-interface/public/shared/ocp-v2/ocp-v2-projectbar.js +3 -6
  264. package/neural-interface/public/shared/ocp-v2/ocp-v2-render.js +24 -21
  265. package/neural-interface/public/shared/ocp-v2/ocp-v2-send-logic.js +16 -5
  266. package/neural-interface/public/shared/ocp-v2/ocp-v2-sessions-logic.js +16 -2
  267. package/neural-interface/public/shared/ocp-v2/ocp-v2-styles.js +27 -43
  268. package/neural-interface/public/shared/ocp-v2/ocp-v2-ws.js +73 -9
  269. package/neural-interface/public/shared/schedules-view.js +2 -2
  270. package/neural-interface/public/shared/session-project-items.js +11 -0
  271. package/neural-interface/public/shared/settings/settings-ai-browser.js +119 -0
  272. package/neural-interface/public/shared/settings/settings-browser-extension.js +446 -0
  273. package/neural-interface/public/shared/settings/settings-ia.js +4 -2
  274. package/neural-interface/public/shared/settings/settings-morelogin-cooldown.js +63 -0
  275. package/neural-interface/public/shared/settings/settings-tool-permissions.js +70 -0
  276. package/neural-interface/public/shared/sidepanel-lazy.js +40 -0
  277. package/neural-interface/public/shared/sidepanel-session-status.js +8 -14
  278. package/neural-interface/public/shared/sidepanel-shown.js +73 -0
  279. package/neural-interface/public/shared/storage.js +6 -1
  280. package/neural-interface/public/shared/studio-attention.js +83 -0
  281. package/neural-interface/public/shared/styles.css +682 -50
  282. package/neural-interface/public/shared/term-browser-tabs.js +34 -0
  283. package/neural-interface/public/shared/transcript-rows.js +334 -0
  284. package/neural-interface/public/shared/tray-auto-close.js +106 -0
  285. package/neural-interface/public/shared/ui-agents.js +97 -0
  286. package/neural-interface/public/shared/ui-antigravity-panel.js +16 -14
  287. package/neural-interface/public/shared/ui-automation-studio.js +3 -3
  288. package/neural-interface/public/shared/ui-claude-panel.js +162 -95
  289. package/neural-interface/public/shared/ui-code-copy.js +256 -0
  290. package/neural-interface/public/shared/ui-codex-panel.js +14 -10
  291. package/neural-interface/public/shared/ui-context-menu.js +1 -1
  292. package/neural-interface/public/shared/ui-file-explorer.js +2 -3
  293. package/neural-interface/public/shared/ui-games.js +1 -1
  294. package/neural-interface/public/shared/ui-loading.js +12 -1
  295. package/neural-interface/public/shared/ui-maritaca-panel.js +12 -11
  296. package/neural-interface/public/shared/ui-menubar.js +23 -0
  297. package/neural-interface/public/shared/ui-native-loop-router.js +1 -1
  298. package/neural-interface/public/shared/ui-navbar.js +15 -9
  299. package/neural-interface/public/shared/ui-opencode-panel-v2.js +13 -11
  300. package/neural-interface/public/shared/ui-schedules-studio.js +3 -3
  301. package/neural-interface/public/shared/ui-scroll-follow.js +39 -0
  302. package/neural-interface/public/shared/ui-sessions.js +3 -3
  303. package/neural-interface/public/shared/ui-settings-entry.js +55 -0
  304. package/neural-interface/public/shared/ui-settings.js +355 -400
  305. package/neural-interface/public/shared/ui-sidepanel-layout.js +44 -25
  306. package/neural-interface/public/shared/ui-sidepanel-session-entry.js +22 -9
  307. package/neural-interface/public/shared/ui-sidepanel-sessions.js +10 -2
  308. package/neural-interface/public/shared/ui-sidepanel-tray.js +36 -41
  309. package/neural-interface/public/shared/ui-sidepanel-windows.js +14 -1
  310. package/neural-interface/public/shared/ui-styleguide.js +10 -2
  311. package/neural-interface/public/shared/ui-sync.js +5 -0
  312. package/neural-interface/public/shared/ui-terminal.js +13 -9
  313. package/neural-interface/public/shared/ui-tooltip.js +28 -7
  314. package/neural-interface/public/shared/ui-topright-overflow.js +26 -4
  315. package/neural-interface/public/shared/ui-tray-columns.js +375 -0
  316. package/neural-interface/public/shared/ui-whiteboard.js +51 -6
  317. package/neural-interface/public/shared/ui-worker-end.js +28 -1
  318. package/neural-interface/public/shared/ui-workspaces.js +13 -0
  319. package/neural-interface/public/shared/window-keys.js +71 -0
  320. package/neural-interface/public/variant/2d/main.js +2 -0
  321. package/neural-interface/public/variant/3d/app.js +620 -0
  322. package/neural-interface/public/variant/3d/boot-reveal.js +47 -0
  323. package/neural-interface/public/variant/3d/main.js +21 -544
  324. package/neural-interface/public/variant/3d/map-controls.js +4 -2
  325. package/neural-interface/public/vendor/fonts/fonts.css +508 -0
  326. package/neural-interface/public/vendor/fonts/inter-OFL.txt +93 -0
  327. package/neural-interface/public/vendor/fonts/inter-cyrillic-ext.woff2 +0 -0
  328. package/neural-interface/public/vendor/fonts/inter-cyrillic.woff2 +0 -0
  329. package/neural-interface/public/vendor/fonts/inter-greek-ext.woff2 +0 -0
  330. package/neural-interface/public/vendor/fonts/inter-greek.woff2 +0 -0
  331. package/neural-interface/public/vendor/fonts/inter-latin-ext.woff2 +0 -0
  332. package/neural-interface/public/vendor/fonts/inter-latin.woff2 +0 -0
  333. package/neural-interface/public/vendor/fonts/inter-vietnamese.woff2 +0 -0
  334. package/neural-interface/public/vendor/fonts/jetbrains-mono-OFL.txt +93 -0
  335. package/neural-interface/public/vendor/fonts/jetbrains-mono-cyrillic-ext.woff2 +0 -0
  336. package/neural-interface/public/vendor/fonts/jetbrains-mono-cyrillic.woff2 +0 -0
  337. package/neural-interface/public/vendor/fonts/jetbrains-mono-greek.woff2 +0 -0
  338. package/neural-interface/public/vendor/fonts/jetbrains-mono-latin-ext.woff2 +0 -0
  339. package/neural-interface/public/vendor/fonts/jetbrains-mono-latin.woff2 +0 -0
  340. package/neural-interface/public/vendor/fonts/jetbrains-mono-vietnamese.woff2 +0 -0
  341. package/neural-interface/public/vendor/fonts/manifest.json +142 -0
  342. package/neural-interface/public/vendor/fonts/space-grotesk-OFL.txt +93 -0
  343. package/neural-interface/public/vendor/fonts/space-grotesk-latin-ext.woff2 +0 -0
  344. package/neural-interface/public/vendor/fonts/space-grotesk-latin.woff2 +0 -0
  345. package/neural-interface/public/vendor/fonts/space-grotesk-vietnamese.woff2 +0 -0
  346. package/neural-interface/scripts/boot-graph.mjs +270 -0
  347. package/neural-interface/scripts/vendor-fonts.mjs +124 -0
  348. package/neural-interface/server.js +1050 -140
  349. package/npm-shrinkwrap.json +2 -2
  350. package/package.json +3 -1
  351. package/skills/agent-forge/SKILL.md +182 -0
  352. package/skills/agent-forge/evals/evals.json +56 -0
  353. package/skills/agent-forge/references/definition-fields.md +61 -0
  354. package/skills/agent-forge/references/examples.md +105 -0
  355. package/skills/agent-forge/references/instructions.md +51 -0
  356. package/skills/agent-forge/references/review-and-export.md +84 -0
@@ -0,0 +1,198 @@
1
+ // ═══════════════════════════════════════════
2
+ // SynaBun Neural Interface — Agents Studio: its requests
3
+ // ═══════════════════════════════════════════
4
+ //
5
+ // Every request of Agents Studio (docs/agents.md → REST API, /api/agents-studio/v1), in one client: the library of
6
+ // agent definitions, a draft and its etag, the review transitions, export and import, the runs of an agent, the
7
+ // owner's test run, and the teams (the contract of the team scheduler: a server that does not have those routes yet
8
+ // answers as "not there", never as an error). No DOM and no imports: `fetch` is handed in, so the client is tested
9
+ // under Node with a stand-in (tests/agents-studio-logic.test.mjs).
10
+ //
11
+ // What a caller gets back is the server's JSON; what it gets thrown is an AgentsApiError that keeps the status, the
12
+ // code and the body. Two of them are part of the editor's flow and have a name of their own:
13
+ // 428 etag_required the request named no etag (a programming mistake of the page; `currentEtag` says which one)
14
+ // 409 etag_conflict the draft changed since it was read: `currentEtag` and `current` (the definition now stored)
15
+ // The owner's writes carry `X-SynaBun-UI: 1`. A request refused because this boot's page secret is missing (a tab
16
+ // left open across a restart: 403 PAGE_SECRET_REQUIRED or UI_ONLY) asks for it once and is sent again.
17
+
18
+ export const AGENTS_BASE = '/api/agents-studio/v1';
19
+ export const PAGE_SESSION_PATH = '/api/page-session';
20
+ const PAGE_SECRET_CODES = new Set(['PAGE_SECRET_REQUIRED', 'UI_ONLY']);
21
+ const ID_RE = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/;
22
+ const TEAM_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
23
+
24
+ export class AgentsApiError extends Error {
25
+ /** @param {string} message @param {{ status?: number, code?: string|null, body?: object|null }} [o] */
26
+ constructor(message, { status = 0, code = null, body = null } = {}) {
27
+ super(message);
28
+ this.name = 'AgentsApiError';
29
+ this.status = status;
30
+ this.code = code;
31
+ this.body = body;
32
+ }
33
+ /** The draft changed since it was read: `currentEtag` and `current` say what is stored now. */
34
+ get conflict() { return this.status === 409 && this.code === 'etag_conflict'; }
35
+ /** The request named no etag. */
36
+ get etagRequired() { return this.status === 428; }
37
+ /** The route is not on this server (an older one, or a phase that is not built yet). */
38
+ get absent() { return this.status === 404 && (!this.body || this.code === 'not_json'); }
39
+ get currentEtag() { return typeof this.body?.currentEtag === 'string' ? this.body.currentEtag : null; }
40
+ get current() { return this.body?.current && typeof this.body.current === 'object' ? this.body.current : null; }
41
+ /** The problems a refusal lists (a definition that is not valid). */
42
+ get errors() { return Array.isArray(this.body?.errors) ? this.body.errors : []; }
43
+ }
44
+
45
+ /** The query of a scope: `{ scope: 'project', project }` for a project's agent, nothing for the global library. */
46
+ export function scopeQuery(scope) {
47
+ if (scope && scope.kind === 'project') return { scope: 'project', project: String(scope.path || '') };
48
+ return {};
49
+ }
50
+
51
+ /** `?a=1&b=2` of the values that are there ('' when none). */
52
+ export function queryString(params = {}) {
53
+ const parts = [];
54
+ for (const [key, value] of Object.entries(params)) {
55
+ if (value === undefined || value === null || value === '') continue;
56
+ parts.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
57
+ }
58
+ return parts.length ? `?${parts.join('&')}` : '';
59
+ }
60
+
61
+ /**
62
+ * The team routes are not served here: the route is not on this server (404 with no JSON of the scheduler's), or the
63
+ * scheduler is not running yet (503 TEAMS_UNAVAILABLE, lib/teams/api.js: the Assistant has not started). Both are
64
+ * "not there", never an error.
65
+ */
66
+ export function teamsUnavailable(error) {
67
+ if (!(error instanceof AgentsApiError)) return false;
68
+ return error.status === 404 || (error.status === 503 && error.code === 'TEAMS_UNAVAILABLE');
69
+ }
70
+
71
+ /** The parts of one team's answer (GET /teams/:id, lib/teams/api.js `teamDetail`) that sit beside `team`. */
72
+ const TEAM_DETAIL_PARTS = Object.freeze(['plan', 'slices', 'claims', 'integration', 'landing', 'events', 'messages', 'messagesNotice']);
73
+
74
+ /**
75
+ * One team as the page reads it: the scheduler answers `{ team, plan, slices, claims, integration, landing, events,
76
+ * messages }` with the summary in `team` (where `slices` is a count) and the rest beside it; a part named beside
77
+ * `team` is the one kept. An answer with everything inside `team` is taken as it is.
78
+ */
79
+ export function teamDetailOf(data) {
80
+ const team = data?.team && typeof data.team === 'object' && !Array.isArray(data.team) ? data.team : null;
81
+ if (!team) return null;
82
+ const out = { ...team };
83
+ for (const part of TEAM_DETAIL_PARTS) if (data[part] !== undefined && data[part] !== null) out[part] = data[part];
84
+ return out;
85
+ }
86
+
87
+ /** The key of an agent as the routes take it: its id checked by shape (never a path), and its scope. */
88
+ export function agentPath(key) {
89
+ const id = String(key?.id || '');
90
+ if (!ID_RE.test(id)) throw new AgentsApiError('Not an agent id.', { status: 400, code: 'invalid_id' });
91
+ return { id, query: scopeQuery(key?.scope) };
92
+ }
93
+
94
+ /**
95
+ * @param {object} [o]
96
+ * @param {typeof fetch} [o.fetch] the page's fetch (a stand-in under test)
97
+ * @param {string} [o.base]
98
+ */
99
+ export function createAgentsApi({ fetch: fetchFn = (...args) => globalThis.fetch(...args), base = AGENTS_BASE } = {}) {
100
+ async function send(method, url, { body, etag } = {}) {
101
+ const headers = { Accept: 'application/json', 'X-SynaBun-UI': '1' };
102
+ if (body !== undefined) headers['Content-Type'] = 'application/json';
103
+ if (etag) headers['If-Match'] = `"${etag}"`;
104
+ // Never from the browser's cache: a route's ETag is the content's digest, and a draft that only changed its status
105
+ // (sent to review, sent back) would be answered from an earlier reading.
106
+ const init = { method, headers, credentials: 'same-origin', cache: 'no-store', ...(body !== undefined ? { body: JSON.stringify(body) } : {}) };
107
+ let res = await fetchFn(url, init);
108
+ let data = await read(res);
109
+ // A tab that outlived a restart holds the earlier boot's page secret: ask for this boot's once, send again.
110
+ if (res.status === 403 && PAGE_SECRET_CODES.has(data?.code)) {
111
+ const refreshed = await fetchFn(PAGE_SESSION_PATH, { method: 'GET', credentials: 'same-origin', cache: 'no-store', headers: { Accept: 'application/json' } }).then((r) => !!r?.ok, () => false);
112
+ if (refreshed) { res = await fetchFn(url, init); data = await read(res); }
113
+ }
114
+ if (!res.ok) {
115
+ const json = data && typeof data === 'object' ? data : null;
116
+ throw new AgentsApiError(json?.error || `HTTP ${res.status}`, { status: res.status, code: json ? (json.code || null) : 'not_json', body: json });
117
+ }
118
+ if (!data || typeof data !== 'object') throw new AgentsApiError('The server answered something that is not JSON.', { status: res.status, code: 'not_json' });
119
+ return data;
120
+ }
121
+ async function read(res) {
122
+ try { return await res.json(); } catch { return null; }
123
+ }
124
+ const agentUrl = (key, rest = '', extra = {}) => {
125
+ const { id, query } = agentPath(key);
126
+ return `${base}/agents/${encodeURIComponent(id)}${rest}${queryString({ ...query, ...extra })}`;
127
+ };
128
+ const teamUrl = (teamId, rest = '') => {
129
+ const id = String(teamId || '');
130
+ if (!TEAM_ID_RE.test(id)) throw new AgentsApiError('Not a team id.', { status: 400, code: 'invalid_id' });
131
+ return `${base}/teams/${encodeURIComponent(id)}${rest}`;
132
+ };
133
+
134
+ return {
135
+ base,
136
+ // ── reading ──
137
+ capabilities: () => send('GET', `${base}/capabilities`),
138
+ list: ({ scope = null, project = null, status = null, q = '' } = {}) => send('GET', `${base}/agents${queryString({ scope, project, status: Array.isArray(status) ? status.join(',') : status, q })}`),
139
+ get: async (key) => send('GET', agentUrl(key)),
140
+ revisions: async (key) => send('GET', agentUrl(key, '/revisions')),
141
+ revision: async (key, which) => send('GET', agentUrl(key, `/revisions/${encodeURIComponent(String(which))}`)),
142
+ diff: async (key, { from = null, to = null } = {}) => send('GET', agentUrl(key, '/diff', { from, to })),
143
+ exportAgent: async (key) => send('GET', agentUrl(key, '/export')),
144
+ nativeFormats: () => send('GET', `${base}/native-export/formats`),
145
+ nativePreview: (key, options) => send('GET', agentUrl(key, '/native-export', options)),
146
+ nativeWrite: (key, body) => send('POST', agentUrl(key, '/native-export'), { body }),
147
+ exportAll: ({ scope = null, project = null } = {}) => send('GET', `${base}/export${queryString({ scope, project })}`),
148
+ resolve: (ref, cwd = null) => send('GET', `${base}/resolve${queryString({ ref, cwd })}`),
149
+ runs: async (key, { limit = 50 } = {}) => send('GET', agentUrl(key, '/runs', { limit })),
150
+ // ── checks: nothing is stored ──
151
+ validate: (definition) => send('POST', `${base}/validate`, { body: { definition } }),
152
+ lint: (definition) => send('POST', `${base}/lint`, { body: { definition } }),
153
+ // ── drafts ──
154
+ create: (definition) => send('POST', `${base}/agents`, { body: { definition } }),
155
+ openDraft: async (key) => send('POST', agentUrl(key, '/draft'), { body: {} }),
156
+ /** Change the draft. `etag` is the one that was read: it rides as If-Match and as `expectedEtag`. */
157
+ updateDraft: async (key, patch, etag) => send('PATCH', agentUrl(key, '/draft'), { body: { expectedEtag: etag || undefined, patch }, etag }),
158
+ discardDraft: async (key, etag = null) => send('DELETE', agentUrl(key, '/draft'), { body: etag ? { expectedEtag: etag } : {}, etag }),
159
+ copy: async (key, { id = null, scope = null } = {}) => send('POST', agentUrl(key, '/copy'), { body: { ...(id ? { id } : {}), ...(scope ? { scope } : {}) } }),
160
+ importBundle: (bundle, { scope = null, replaceDrafts = false, prefer = 'approved' } = {}) => send('POST', `${base}/import`, { body: { bundle, ...(scope ? { scope } : {}), replaceDrafts, prefer } }),
161
+ importClaudeAgent: ({ markdown, fileName = '', id = null, scope = null, replaceDraft = false }) => send('POST', `${base}/import-claude-agent`, { body: { markdown, fileName, ...(id ? { id } : {}), ...(scope ? { scope } : {}), replaceDraft } }),
162
+ // ── review ──
163
+ submit: async (key, { etag = null, note = '' } = {}) => send('POST', agentUrl(key, '/submit'), { body: { ...(etag ? { expectedEtag: etag } : {}), ...(note ? { note } : {}) }, etag }),
164
+ requestChanges: async (key, { etag = null, note = '' } = {}) => send('POST', agentUrl(key, '/request-changes'), { body: { ...(etag ? { expectedEtag: etag } : {}), ...(note ? { note } : {}) }, etag }),
165
+ /** The owner approves the content it read: the etag is required (428 without). */
166
+ approve: async (key, { etag, note = '' } = {}) => send('POST', agentUrl(key, '/approve'), { body: { expectedEtag: etag || undefined, ...(note ? { note } : {}) }, etag }),
167
+ withdraw: async (key, { revision = null, all = false, note = '' } = {}) => send('POST', agentUrl(key, '/withdraw'), { body: { ...(revision !== null ? { revision } : {}), ...(all ? { all: true } : {}), ...(note ? { note } : {}) } }),
168
+ remove: async (key) => send('DELETE', agentUrl(key), { body: {} }),
169
+ // ── a test run ──
170
+ testRun: async (key, { task, cwd = null, revision = null, maxMinutes = null } = {}) => send('POST', agentUrl(key, '/test-run'), { body: { task, ...(cwd ? { cwd } : {}), ...(revision !== null ? { revision } : {}), ...(maxMinutes ? { maxMinutes } : {}) } }),
171
+ // ── teams (the team scheduler's routes: absent on a server from before it) ──
172
+ /**
173
+ * → { available, teams, notRunning? }. A server without the route (404, or an answer with no list) and a scheduler
174
+ * that is not running yet (503 TEAMS_UNAVAILABLE, then `notRunning: true`) are `available: false`.
175
+ */
176
+ async teams() {
177
+ try {
178
+ const data = await send('GET', `${base}/teams`);
179
+ return Array.isArray(data.teams) ? { available: true, teams: data.teams } : { available: false, teams: [] };
180
+ } catch (error) {
181
+ if (teamsUnavailable(error)) return error.status === 503 ? { available: false, teams: [], notRunning: true } : { available: false, teams: [] };
182
+ throw error;
183
+ }
184
+ },
185
+ /** → { available, team }. `team` null: the route is not there, or the team is gone (teamDetailOf). */
186
+ async team(teamId) {
187
+ try {
188
+ const team = teamDetailOf(await send('GET', teamUrl(teamId)));
189
+ return team ? { available: true, team } : { available: false, team: null };
190
+ } catch (error) {
191
+ if (teamsUnavailable(error)) return { available: error.status === 404 && !error.absent, team: null };
192
+ throw error;
193
+ }
194
+ },
195
+ landTeam: async (teamId, body = {}) => send('POST', teamUrl(teamId, '/land'), { body }),
196
+ discardTeam: async (teamId, body = {}) => send('POST', teamUrl(teamId, '/discard'), { body }),
197
+ };
198
+ }
@@ -0,0 +1,221 @@
1
+ // ═══════════════════════════════════════════
2
+ // SynaBun Neural Interface — Agents Studio: Create
3
+ // ═══════════════════════════════════════════
4
+ //
5
+ // The short way to a new agent. Five starts: a blank form, one of a few sensible roles, a copy of an agent that
6
+ // exists, a file (a Claude Code agent `.md`, or a JSON bundle exported from an Agents Studio), or a description
7
+ // handed to the SynaBun Assistant, which drafts the agent and sends it to Review. Whatever the start, the result
8
+ // is a draft: nothing is approved by creating, copying or importing (an import lands as a draft whatever the file
9
+ // says). Blank and template open the editor on an unsaved form; copy and import make drafts on the server and say
10
+ // what happened to each; "Describe it" opens the Assistant with the request and then waits for the draft to arrive.
11
+
12
+ import { html, setHTML, ICONS } from '../../skills/studio/sx-dom.js';
13
+ import { wireDropdowns } from '../../cc-dropdown.js';
14
+ import { CREATE_MODES, keyOf, agentKeyText } from './ax-views.js';
15
+ import { TEMPLATES, templateById, templateForm, describeRequest } from './ax-templates.js';
16
+ import { scopeEntries, scopeFromValue } from './ax-options.js';
17
+ import { sortAgents } from './ax-library.js';
18
+ import { AX_ICONS } from './ax-icons.js';
19
+ import { agentMark, dropdown, errorText, readFileText, wordOr, scopeTag } from './ax-ui.js';
20
+ import { duplicateAgent } from './ax-agent-view.js';
21
+
22
+ let life = null;
23
+
24
+ export function leaveCreate() {
25
+ life?.abort();
26
+ life = null;
27
+ }
28
+
29
+ const START_ICON = { blank: ICONS.plus, template: ICONS.spark, copy: AX_ICONS.copy, import: ICONS.upload, describe: AX_ICONS.send };
30
+
31
+ /** The file types Import takes. */
32
+ export const IMPORT_ACCEPT = '.md,.markdown,.json,text/markdown,application/json';
33
+
34
+ /** What an import's file is, by its name and its first character: a Claude Code agent file, or a JSON bundle. */
35
+ export function importKind(fileName, text) {
36
+ const name = String(fileName || '').toLowerCase();
37
+ if (name.endsWith('.json')) return 'bundle';
38
+ if (name.endsWith('.md') || name.endsWith('.markdown')) return 'claude';
39
+ return /^\s*[[{]/.test(String(text || '')) ? 'bundle' : 'claude';
40
+ }
41
+
42
+ function startsHTML(ctx) {
43
+ const { t } = ctx;
44
+ const modes = CREATE_MODES.filter((mode) => (mode === 'copy' ? ctx.caps.has('copy') && ctx.agents.length : mode === 'import' ? ctx.caps.has('import') || ctx.caps.has('import-claude-agent') : true));
45
+ return html`<div class="ax-starts" role="list">${modes.map((mode, n) => html`<div role="listitem"><button type="button" class="ax-start" data-act="start" data-mode="${mode}"${n === 0 ? html` data-autofocus` : ''}>
46
+ <span class="ax-start-icon" aria-hidden="true">${START_ICON[mode]}</span>
47
+ <span class="ax-start-text"><span class="ax-start-name">${t(`agentsStudio.create.start.${mode}.name`)}</span><span class="ax-start-desc">${t(`agentsStudio.create.start.${mode}.desc`)}</span></span>
48
+ </button></div>`)}</div>`;
49
+ }
50
+
51
+ function templatesHTML(ctx) {
52
+ const { t } = ctx;
53
+ return html`<div class="ax-templates" role="list">${TEMPLATES.map((tpl, n) => html`<div role="listitem"><button type="button" class="ax-template" data-act="use-template" data-template="${tpl.id}"${n === 0 ? html` data-autofocus` : ''}>
54
+ <span class="ax-template-top">${agentMark(tpl, 18)}<span class="ax-template-name">${t(`agentsStudio.templates.${tpl.id}.name`)}</span></span>
55
+ <span class="ax-template-desc">${t(`agentsStudio.templates.${tpl.id}.description`)}</span>
56
+ <span class="ax-template-facts"><span class="sx-chip ax-chip">${wordOr(t, `agentsStudio.capability.${tpl.capability}`, 'name')}</span>${tpl.usesBrowser ? html`<span class="sx-chip ax-chip">${t('agentsStudio.field.usesBrowser')}</span>` : ''}${tpl.taskClasses.map((cls) => html`<span class="sx-chip ax-chip">${wordOr(t, 'agentsStudio.taskClass', cls)}</span>`)}</span>
57
+ </button></div>`)}</div>`;
58
+ }
59
+
60
+ function copyHTML(ctx) {
61
+ const { t } = ctx;
62
+ const rows = sortAgents(ctx.agents, 'name');
63
+ return html`<ul class="ax-pick-list" aria-label="${t('agentsStudio.create.copy.pick')}">${rows.map((agent, n) => html`<li><button type="button" class="ax-pick" data-act="copy-agent" data-agent="${agentKeyText(keyOf(agent))}"${n === 0 ? html` data-autofocus` : ''}>
64
+ ${agentMark(agent, 16)}<span class="ax-pick-name">${agent.name || agent.id}</span><span class="sx-mono ax-pick-id">${agent.id}</span>${scopeTag(t, agent.scope, ctx.info?.projects)}
65
+ </button></li>`)}</ul>`;
66
+ }
67
+
68
+ function resultHTML(ctx, result) {
69
+ const { t } = ctx;
70
+ if (!result) return '';
71
+ if (result.error) return html`<div class="sx-banner sx-banner--warn" role="alert">${ICONS.warn}<span class="sx-banner-text">${result.error}</span></div>`;
72
+ const rows = result.rows || [];
73
+ const tone = { created: 'ok', drafted: 'ok', unchanged: 'off', skipped: 'warn', invalid: 'err' };
74
+ return html`<section class="ax-import-result" aria-labelledby="ax-import-result-title">
75
+ <h4 class="sx-section-title" id="ax-import-result-title" tabindex="-1">${ctx.tp('agentsStudio.create.import.done', result.imported ?? 0)}</h4>
76
+ <p class="sx-help">${t('agentsStudio.create.import.asDrafts')}</p>
77
+ <ul class="sx-results ax-import-rows">${rows.map((row) => html`<li class="sx-result">
78
+ <span class="sx-state-chip ax-run-state ax-run-state--${tone[row.action] || 'idle'}">${wordOr(t, 'agentsStudio.create.import.action', row.action)}</span>
79
+ <span class="sx-mono">${row.id || t('agentsStudio.create.import.noId')}</span>
80
+ ${row.reason ? html`<span class="sx-dim">${wordOr(t, 'agentsStudio.create.import.reason', row.reason)}</span>` : ''}
81
+ ${Array.isArray(row.errors) && row.errors.length ? html`<span class="sx-err-text">${row.errors.slice(0, 3).map((issue) => issue.message).join(' ')}</span>` : ''}
82
+ ${row.id && (row.action === 'created' || row.action === 'drafted' || row.action === 'unchanged') ? html`<button type="button" class="sx-btn sx-btn--sm" data-act="open-imported" data-id="${row.id}" data-scope="${row.scope?.kind === 'project' ? `project:${row.scope.path}` : 'global'}">${t('agentsStudio.create.import.open')}</button>` : ''}
83
+ </li>`)}</ul>
84
+ ${result.notes?.length ? html`<div class="sx-note"><p class="ax-note-title">${t('agentsStudio.create.import.notes')}</p><ul class="sx-plain-list">${result.notes.map((note) => html`<li>${note}</li>`)}</ul></div>` : ''}
85
+ </section>`;
86
+ }
87
+
88
+ function importHTML(ctx, st) {
89
+ const { t } = ctx;
90
+ const scopes = [{ value: 'keep', label: t('agentsStudio.create.import.scopeKeep'), selected: st.scope === 'keep' }, ...scopeEntries(ctx.info?.projects || [], st.scope === 'keep' ? null : scopeFromValue(st.scope), { globalLabel: t('agentsStudio.scope.globalLibrary'), projectsLabel: t('agentsStudio.scope.pinTo') }).map((entry) => (entry.value === 'global' ? { ...entry, selected: st.scope === 'global' } : entry))];
91
+ return html`<div class="ax-import">
92
+ <div class="ax-drop" id="ax-drop" tabindex="-1">
93
+ <span class="ax-start-icon" aria-hidden="true">${ICONS.upload}</span>
94
+ <p class="ax-drop-text">${t('agentsStudio.create.import.drop')}</p>
95
+ <button type="button" class="sx-btn sx-btn--primary" data-act="pick-file" data-autofocus${st.busy ? html` disabled` : ''}>${t('agentsStudio.create.import.choose')}</button>
96
+ <input type="file" id="ax-import-file" accept="${IMPORT_ACCEPT}" hidden>
97
+ <p class="sx-help">${t('agentsStudio.create.import.kinds')}</p>
98
+ </div>
99
+ <div class="ax-import-options">
100
+ <div class="sx-field"><span class="sx-field-label" id="ax-import-scope-label">${t('agentsStudio.create.import.scope')}</span>${dropdown('ax-import-scope', scopes, { labelledBy: 'ax-import-scope-label' })}<p class="sx-field-note">${t('agentsStudio.create.import.scopeHelp')}</p></div>
101
+ <label class="sx-choice"><input type="checkbox" class="sx-check" id="ax-import-replace"${st.replace ? html` checked` : ''}><span>${t('agentsStudio.create.import.replace')}</span></label>
102
+ </div>
103
+ <div id="ax-import-result" aria-live="polite">${st.busy ? html`<p class="sx-note" role="status"><span class="ax-spinner" aria-hidden="true"></span> ${t('agentsStudio.create.import.reading')}</p>` : resultHTML(ctx, st.result)}</div>
104
+ </div>`;
105
+ }
106
+
107
+ function describeHTML(ctx, st) {
108
+ const { t } = ctx;
109
+ const scopes = scopeEntries(ctx.info?.projects || [], scopeFromValue(st.scope), { globalLabel: t('agentsStudio.scope.globalLibrary'), projectsLabel: t('agentsStudio.scope.pinTo') });
110
+ return html`<div class="ax-describe">
111
+ <div class="sx-field"><label class="sx-field-label" for="ax-describe-text">${t('agentsStudio.create.describe.label')}</label>
112
+ <textarea class="sx-input sx-textarea ax-describe-text" id="ax-describe-text" rows="6" placeholder="${t('agentsStudio.create.describe.placeholder')}" data-autofocus>${st.text}</textarea>
113
+ <p class="sx-field-note">${t('agentsStudio.create.describe.help')}</p></div>
114
+ <div class="sx-field ax-describe-scope"><span class="sx-field-label" id="ax-describe-scope-label">${t('agentsStudio.field.scope')}</span>${dropdown('ax-describe-scope', scopes, { labelledBy: 'ax-describe-scope-label' })}</div>
115
+ <div class="sx-row"><button type="button" class="sx-btn sx-btn--primary" data-act="send-describe">${AX_ICONS.send}${t('agentsStudio.create.describe.send')}</button><span class="sx-help">${t('agentsStudio.create.describe.review')}</span></div>
116
+ ${st.sent ? html`<div class="sx-banner sx-banner--ok" role="status">${ICONS.ok}<span class="sx-banner-text">${ctx.awaitingDraft ? t('agentsStudio.create.describe.sent') : t('agentsStudio.create.describe.arrived')}</span><button type="button" class="sx-btn sx-btn--sm" data-act="go-review">${t('agentsStudio.create.describe.openReview')}</button></div>` : ''}
117
+ </div>`;
118
+ }
119
+
120
+ const STEP_HTML = { template: templatesHTML, copy: copyHTML };
121
+
122
+ /** Draw Create in the main area: its starts, or the step of the start that was chosen. */
123
+ export function renderCreate(main, ctx, st) {
124
+ leaveCreate();
125
+ life = new AbortController();
126
+ const { signal } = life;
127
+ const { t } = ctx;
128
+ const mode = ['template', 'copy', 'import', 'describe'].includes(ctx.view.create) ? ctx.view.create : null;
129
+ const step = !mode ? startsHTML(ctx) : mode === 'import' ? importHTML(ctx, st.import) : mode === 'describe' ? describeHTML(ctx, st.describe) : STEP_HTML[mode](ctx);
130
+ setHTML(main, html`<section class="sx-place ax-place" aria-labelledby="ax-create-title">
131
+ <header class="sx-place-head">
132
+ ${mode ? html`<button type="button" class="sx-link" data-act="back">${ICONS.back}${t('agentsStudio.rail.create')}</button>` : ''}
133
+ <h3 class="sx-place-title" id="ax-create-title" tabindex="-1">${mode ? t(`agentsStudio.create.start.${mode}.name`) : t('agentsStudio.create.title')}</h3>
134
+ <p class="sx-place-sub">${mode ? t(`agentsStudio.create.step.${mode}`) : t('agentsStudio.create.sub')}</p>
135
+ </header>
136
+ <div class="sx-place-scroll"><div class="ax-create">${!ctx.canDraft ? html`<p class="sx-note">${t('agentsStudio.error.ownerOnly')}</p>` : step}
137
+ ${!mode ? html`<p class="sx-explain ax-create-foot">${t('agentsStudio.create.foot')}</p>` : ''}</div></div>
138
+ </section>`);
139
+ wireDropdowns(main, { signal });
140
+ const provider = ctx.info?.providers?.[0] || '';
141
+
142
+ const runImport = async (file) => {
143
+ const s = st.import;
144
+ if (!file || s.busy) return;
145
+ s.busy = true;
146
+ s.result = null;
147
+ ctx.render({ keepFocus: true });
148
+ try {
149
+ const text = await readFileText(file);
150
+ const kind = importKind(file.name, text);
151
+ const scope = s.scope === 'keep' ? null : scopeFromValue(s.scope);
152
+ if (kind === 'claude') {
153
+ const res = await ctx.api.importClaudeAgent({ markdown: text, fileName: file.name, scope, replaceDraft: s.replace });
154
+ s.result = { imported: 1, rows: [{ id: res.agent.id, scope: res.agent.scope, action: res.action || 'created' }], notes: res.notes || [] };
155
+ } else {
156
+ let bundle;
157
+ try { bundle = JSON.parse(text); } catch { throw Object.assign(new Error(t('agentsStudio.create.import.notJson')), { code: 'not_json_file' }); }
158
+ const res = await ctx.api.importBundle(bundle, { scope, replaceDrafts: s.replace });
159
+ s.result = { imported: res.imported, rows: res.results || [], notes: [] };
160
+ }
161
+ ctx.changed();
162
+ await ctx.reload({ quiet: true });
163
+ } catch (error) {
164
+ s.result = { error: error.code === 'file_too_large' ? t('agentsStudio.create.import.tooLarge') : error.code === 'not_json_file' ? error.message : t('agentsStudio.create.import.failed', { error: errorText(t, error) }) };
165
+ }
166
+ s.busy = false;
167
+ ctx.render();
168
+ requestAnimationFrame(() => main.ownerDocument.getElementById('ax-import-result-title')?.focus({ preventScroll: true }));
169
+ };
170
+
171
+ main.addEventListener('click', async (e) => {
172
+ const el = e.target.closest?.('[data-act]');
173
+ if (!el || !main.contains(el) || el.disabled) return;
174
+ const act = el.dataset.act;
175
+ if (act === 'back') ctx.go({ type: 'back' });
176
+ else if (act === 'start') {
177
+ const chosen = el.dataset.mode;
178
+ if (chosen === 'blank') ctx.startNew({ source: 'blank', provider });
179
+ else ctx.go({ type: 'place', place: 'create', create: chosen });
180
+ } else if (act === 'use-template') {
181
+ const tpl = templateById(el.dataset.template);
182
+ ctx.startNew({ source: 'template', form: templateForm(tpl, t, { provider, taskClasses: ctx.info?.taskClasses, idLimit: Number(ctx.info?.limits?.id) || 64 }) });
183
+ } else if (act === 'copy-agent') {
184
+ const agent = ctx.agents.find((a) => agentKeyText(keyOf(a)) === el.dataset.agent);
185
+ if (!agent) return;
186
+ const made = await duplicateAgent(ctx, keyOf(agent), agent.name);
187
+ if (made) { await ctx.reload({ quiet: true }); ctx.go({ type: 'agent', key: made, tab: 'edit' }); }
188
+ } else if (act === 'pick-file') main.querySelector('#ax-import-file')?.click();
189
+ else if (act === 'open-imported') ctx.go({ type: 'agent', key: { id: el.dataset.id, scope: scopeFromValue(el.dataset.scope) }, tab: 'edit' });
190
+ else if (act === 'go-review') ctx.go({ type: 'place', place: 'review' });
191
+ else if (act === 'send-describe') {
192
+ const s = st.describe;
193
+ const text = s.text.trim();
194
+ if (!text) { ctx.toast(t('agentsStudio.create.describe.required'), 'error'); main.querySelector('#ax-describe-text')?.focus(); return; }
195
+ ctx.askAssistant(describeRequest(text, t, { scope: scopeFromValue(s.scope) }));
196
+ s.sent = true;
197
+ ctx.render({ keepFocus: true });
198
+ }
199
+ }, { signal });
200
+ main.addEventListener('input', (e) => { if (e.target.id === 'ax-describe-text') st.describe.text = e.target.value; }, { signal });
201
+ main.addEventListener('change', (e) => {
202
+ if (e.target.id === 'ax-import-scope') st.import.scope = e.target.value;
203
+ else if (e.target.id === 'ax-import-replace') st.import.replace = e.target.checked;
204
+ else if (e.target.id === 'ax-describe-scope') st.describe.scope = e.target.value;
205
+ else if (e.target.id === 'ax-import-file') { const file = e.target.files?.[0]; e.target.value = ''; runImport(file); }
206
+ }, { signal });
207
+ // A file dropped on the import box is imported like a picked one.
208
+ const drop = main.querySelector('#ax-drop');
209
+ if (drop) {
210
+ const over = (on) => drop.classList.toggle('is-over', on);
211
+ drop.addEventListener('dragover', (e) => { e.preventDefault(); over(true); }, { signal });
212
+ drop.addEventListener('dragleave', () => over(false), { signal });
213
+ drop.addEventListener('drop', (e) => { e.preventDefault(); over(false); runImport(e.dataTransfer?.files?.[0]); }, { signal });
214
+ }
215
+ }
216
+
217
+ /** What Create remembers between drawings while the window is open. */
218
+ export function newCreateState() {
219
+ return { import: { scope: 'keep', replace: false, busy: false, result: null }, describe: { text: '', scope: 'global', sent: false } };
220
+ }
221
+
@@ -0,0 +1,143 @@
1
+ // ═══════════════════════════════════════════
2
+ // SynaBun Neural Interface — Agents Studio: what changed, and what an agent may do
3
+ // ═══════════════════════════════════════════
4
+ //
5
+ // The registry compares two revisions (GET /agents/:id/diff): `changes` field by field, the instructions also line
6
+ // by line, and `privileges` (what the newer one may do that the older may not). This module turns that answer into
7
+ // what the Review queue, the Revisions tab and the approval's summary draw: rows with both values as text, the
8
+ // instructions as hunks (the unchanged middle folded), and the privilege summary of a definition with what differs
9
+ // from the last approved revision marked. Whether a change widens what the agent may do is the server's word
10
+ // (`escalates`); the page never decides it.
11
+ // No DOM and no imports.
12
+
13
+ /** The privilege fields, in the order a review reads them. */
14
+ export const PRIVILEGE_FIELDS = Object.freeze(['capability', 'permissionPolicy', 'tools', 'mcpServers', 'usesBrowser', 'moreloginProfile', 'usesComputer', 'skills', 'scope']);
15
+
16
+ const isList = (value) => Array.isArray(value);
17
+
18
+ /**
19
+ * A field's value as text. `words` gives the page's words: `{ yes, no, none, defaultTools, allTools, allServers,
20
+ * global, capability(level), policy(id), taskClass(id), provider(id) }`; without it, plain values.
21
+ */
22
+ export function valueText(field, value, words = {}) {
23
+ const none = words.none ?? '—';
24
+ if (field === 'tools') {
25
+ if (value === null || value === undefined) return words.defaultTools ?? 'default';
26
+ if (!value.length) return words.alwaysOn ?? none;
27
+ return value.includes('all') ? (words.allTools ?? 'all') : value.join(', ');
28
+ }
29
+ if (field === 'mcpServers') {
30
+ if (!isList(value) || !value.length) return none;
31
+ return value.includes('*') ? (words.allServers ?? '*') : value.join(', ');
32
+ }
33
+ if (field === 'scope') {
34
+ const kind = typeof value === 'string' ? value : value?.kind;
35
+ if (kind === 'project') return typeof value === 'object' && value?.path ? value.path : (words.project ?? 'project');
36
+ return kind ? (words.global ?? 'global') : none;
37
+ }
38
+ if (value === true) return words.yes ?? 'yes';
39
+ if (value === false) return words.no ?? 'no';
40
+ if (value === null || value === undefined || value === '') return none;
41
+ if (isList(value)) {
42
+ if (!value.length) return none;
43
+ return (field === 'taskClasses' && words.taskClass ? value.map(words.taskClass) : value).join(', ');
44
+ }
45
+ if (field === 'capability' && words.capability) return words.capability(value);
46
+ if (field === 'permissionPolicy' && words.policy) return words.policy(value);
47
+ if (field === 'provider' && words.provider) return words.provider(value);
48
+ return String(value);
49
+ }
50
+
51
+ /** For a list field: what was added and what was taken out (`null` lists count as empty). */
52
+ export function listDelta(from, to) {
53
+ const a = isList(from) ? from : [];
54
+ const b = isList(to) ? to : [];
55
+ return { added: b.filter((item) => !a.includes(item)), removed: a.filter((item) => !b.includes(item)) };
56
+ }
57
+
58
+ /**
59
+ * The rows of a diff: `{ field, kind, from, to, added, removed }` with `kind` one of `instructions` (drawn as
60
+ * hunks), `list` (added / removed items), `value`. The instructions come last: they are the long part.
61
+ */
62
+ export function diffRows(diff, words = {}) {
63
+ const changes = Array.isArray(diff?.changes) ? diff.changes : [];
64
+ const rows = changes.map((change) => {
65
+ if (change.field === 'instructions') {
66
+ return { field: 'instructions', kind: 'instructions', lines: Array.isArray(change.lines) ? change.lines : null, added: change.added ?? null, removed: change.removed ?? null, from: change.from ?? '', to: change.to ?? '' };
67
+ }
68
+ const lists = isList(change.from) || isList(change.to);
69
+ const delta = lists && change.field !== 'tools' ? listDelta(change.from, change.to) : null;
70
+ return { field: change.field, kind: delta ? 'list' : 'value', from: valueText(change.field, change.from, words), to: valueText(change.field, change.to, words), added: delta?.added || [], removed: delta?.removed || [] };
71
+ });
72
+ return [...rows.filter((row) => row.kind !== 'instructions'), ...rows.filter((row) => row.kind === 'instructions')];
73
+ }
74
+
75
+ /**
76
+ * A line diff (`[{ op: ' ' | '+' | '-', line }]`) as what is drawn: changed lines with `context` unchanged lines
77
+ * around them, the rest folded into `{ gap: n }`. Lines carry their numbers on each side.
78
+ */
79
+ export function hunksOf(lines, context = 2) {
80
+ const rows = Array.isArray(lines) ? lines : [];
81
+ let oldNo = 0;
82
+ let newNo = 0;
83
+ const numbered = rows.map((row) => {
84
+ const op = row?.op === '+' || row?.op === '-' ? row.op : ' ';
85
+ if (op !== '+') oldNo += 1;
86
+ if (op !== '-') newNo += 1;
87
+ return { op, line: String(row?.line ?? ''), oldNo: op === '+' ? null : oldNo, newNo: op === '-' ? null : newNo };
88
+ });
89
+ const keep = new Array(numbered.length).fill(false);
90
+ numbered.forEach((row, i) => {
91
+ if (row.op === ' ') return;
92
+ for (let k = Math.max(0, i - context); k <= Math.min(numbered.length - 1, i + context); k += 1) keep[k] = true;
93
+ });
94
+ const out = [];
95
+ let gap = 0;
96
+ numbered.forEach((row, i) => {
97
+ if (keep[i]) { if (gap) { out.push({ gap }); gap = 0; } out.push(row); } else gap += 1;
98
+ });
99
+ if (gap) out.push({ gap });
100
+ return out;
101
+ }
102
+
103
+ /** What a definition lets its worker do, as rows (the contract's privilegesOf, read from the definition itself). */
104
+ export function privilegeRows(definition, words = {}) {
105
+ const d = definition && typeof definition === 'object' ? definition : {};
106
+ return PRIVILEGE_FIELDS.map((field) => {
107
+ const value = field === 'scope' ? d.scope : d[field];
108
+ return { field, value: value ?? null, text: valueText(field, value, words) };
109
+ });
110
+ }
111
+
112
+ /**
113
+ * The privilege summary before an approval: every row of `definition`, with `changed` where it differs from
114
+ * `approved` (the last approved revision; null for a first revision, where every row that grants something is new)
115
+ * and `escalates` where the server's privilege delta says the change widens what the agent may do.
116
+ * @param {object} definition the revision being approved
117
+ * @param {object|null} approved
118
+ * @param {{ changes?: { field: string, escalates: boolean }[] }|null} [delta] the diff's `privileges`
119
+ */
120
+ export function privilegeSummary(definition, approved = null, delta = null, words = {}) {
121
+ const now = privilegeRows(definition, words);
122
+ const before = approved ? privilegeRows(approved, words) : null;
123
+ const wider = new Map((Array.isArray(delta?.changes) ? delta.changes : []).map((change) => [change.field, change.escalates === true]));
124
+ return now.map((row, i) => {
125
+ const was = before ? before[i] : null;
126
+ const changed = before ? JSON.stringify(was.value ?? null) !== JSON.stringify(row.value ?? null) : false;
127
+ return { ...row, changed, was: changed ? was.text : null, escalates: wider.get(row.field) === true, first: !before };
128
+ });
129
+ }
130
+
131
+ /** The server's privilege delta as rows: `{ field, from, to, escalates }` with both values as text. */
132
+ export function privilegeChanges(delta, words = {}) {
133
+ return (Array.isArray(delta?.changes) ? delta.changes : []).map((change) => ({
134
+ field: change.field, from: valueText(change.field, change.from, words), to: valueText(change.field, change.to, words), escalates: change.escalates === true,
135
+ }));
136
+ }
137
+
138
+ /** One line for a diff's size: `{ fields, added, removed }`. */
139
+ export function diffSize(diff) {
140
+ const changes = Array.isArray(diff?.changes) ? diff.changes : [];
141
+ const text = changes.find((change) => change.field === 'instructions');
142
+ return { fields: changes.length, added: text?.added ?? 0, removed: text?.removed ?? 0 };
143
+ }