synabun 2.3.1 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (370) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +1 -1
  3. package/browser-extension/content.js +189 -0
  4. package/browser-extension/engine.js +508 -0
  5. package/browser-extension/icons/icon-128.png +0 -0
  6. package/browser-extension/icons/icon-16.png +0 -0
  7. package/browser-extension/icons/icon-32.png +0 -0
  8. package/browser-extension/icons/icon-48.png +0 -0
  9. package/browser-extension/icons/status-off-16.png +0 -0
  10. package/browser-extension/icons/status-off-32.png +0 -0
  11. package/browser-extension/icons/status-off-48.png +0 -0
  12. package/browser-extension/icons/status-on-16.png +0 -0
  13. package/browser-extension/icons/status-on-32.png +0 -0
  14. package/browser-extension/icons/status-on-48.png +0 -0
  15. package/browser-extension/manifest.json +56 -0
  16. package/browser-extension/popup-strings.js +250 -0
  17. package/browser-extension/popup-view.js +151 -0
  18. package/browser-extension/popup.css +166 -0
  19. package/browser-extension/popup.html +108 -0
  20. package/browser-extension/popup.js +359 -0
  21. package/browser-extension/protocol.js +232 -0
  22. package/browser-extension/service-worker.js +275 -0
  23. package/browser-extension/setup-content.js +36 -0
  24. package/browser-extension/tokens.css +326 -0
  25. package/docs/browser-extension-bridge.md +84 -0
  26. package/docs/whatsapp.md +1 -1
  27. package/lib/data-home-files.js +45 -0
  28. package/lib/data-home-migration.js +34 -58
  29. package/mcp-server/dist/http.d.ts +2 -0
  30. package/mcp-server/dist/http.d.ts.map +1 -1
  31. package/mcp-server/dist/http.js +9 -1
  32. package/mcp-server/dist/http.js.map +1 -1
  33. package/mcp-server/dist/index.d.ts +11 -0
  34. package/mcp-server/dist/index.d.ts.map +1 -1
  35. package/mcp-server/dist/index.js +38 -3
  36. package/mcp-server/dist/index.js.map +1 -1
  37. package/mcp-server/dist/services/browser-route-flow.d.ts +6 -2
  38. package/mcp-server/dist/services/browser-route-flow.d.ts.map +1 -1
  39. package/mcp-server/dist/services/browser-route-flow.js +10 -3
  40. package/mcp-server/dist/services/browser-route-flow.js.map +1 -1
  41. package/mcp-server/dist/services/codex-config-heal.d.ts.map +1 -1
  42. package/mcp-server/dist/services/codex-config-heal.js +7 -0
  43. package/mcp-server/dist/services/codex-config-heal.js.map +1 -1
  44. package/mcp-server/dist/services/neural-interface.d.ts +95 -3
  45. package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
  46. package/mcp-server/dist/services/neural-interface.js +168 -23
  47. package/mcp-server/dist/services/neural-interface.js.map +1 -1
  48. package/mcp-server/dist/services/team-context.d.ts +18 -0
  49. package/mcp-server/dist/services/team-context.d.ts.map +1 -0
  50. package/mcp-server/dist/services/team-context.js +29 -0
  51. package/mcp-server/dist/services/team-context.js.map +1 -0
  52. package/mcp-server/dist/services/tool-catalog.d.ts +5 -2
  53. package/mcp-server/dist/services/tool-catalog.d.ts.map +1 -1
  54. package/mcp-server/dist/services/tool-catalog.js +22 -6
  55. package/mcp-server/dist/services/tool-catalog.js.map +1 -1
  56. package/mcp-server/dist/services/tool-list.d.ts.map +1 -1
  57. package/mcp-server/dist/services/tool-list.js +4 -0
  58. package/mcp-server/dist/services/tool-list.js.map +1 -1
  59. package/mcp-server/dist/services/tool-runtime.d.ts +8 -1
  60. package/mcp-server/dist/services/tool-runtime.d.ts.map +1 -1
  61. package/mcp-server/dist/services/tool-runtime.js +18 -1
  62. package/mcp-server/dist/services/tool-runtime.js.map +1 -1
  63. package/mcp-server/dist/tools/agent-definition.d.ts +133 -0
  64. package/mcp-server/dist/tools/agent-definition.d.ts.map +1 -0
  65. package/mcp-server/dist/tools/agent-definition.js +483 -0
  66. package/mcp-server/dist/tools/agent-definition.js.map +1 -0
  67. package/mcp-server/dist/tools/agents.d.ts +92 -9
  68. package/mcp-server/dist/tools/agents.d.ts.map +1 -1
  69. package/mcp-server/dist/tools/agents.js +163 -20
  70. package/mcp-server/dist/tools/agents.js.map +1 -1
  71. package/mcp-server/dist/tools/browser-advanced.d.ts +8 -1
  72. package/mcp-server/dist/tools/browser-advanced.d.ts.map +1 -1
  73. package/mcp-server/dist/tools/browser-advanced.js +70 -6
  74. package/mcp-server/dist/tools/browser-advanced.js.map +1 -1
  75. package/mcp-server/dist/tools/git-tools.d.ts +4 -2
  76. package/mcp-server/dist/tools/git-tools.d.ts.map +1 -1
  77. package/mcp-server/dist/tools/git-tools.js +283 -2
  78. package/mcp-server/dist/tools/git-tools.js.map +1 -1
  79. package/mcp-server/dist/tools/morelogin.d.ts +8 -2
  80. package/mcp-server/dist/tools/morelogin.d.ts.map +1 -1
  81. package/mcp-server/dist/tools/morelogin.js +22 -5
  82. package/mcp-server/dist/tools/morelogin.js.map +1 -1
  83. package/mcp-server/dist/tools/team.d.ts +32 -0
  84. package/mcp-server/dist/tools/team.d.ts.map +1 -0
  85. package/mcp-server/dist/tools/team.js +87 -0
  86. package/mcp-server/dist/tools/team.js.map +1 -0
  87. package/mcp-server/package-lock.json +2 -2
  88. package/mcp-server/package.json +1 -1
  89. package/mcp-server/src/http.ts +9 -1
  90. package/mcp-server/src/index.ts +34 -4
  91. package/mcp-server/src/services/browser-route-flow.ts +12 -5
  92. package/mcp-server/src/services/codex-config-heal.ts +7 -0
  93. package/mcp-server/src/services/neural-interface.ts +191 -29
  94. package/mcp-server/src/services/team-context.ts +27 -0
  95. package/mcp-server/src/services/tool-catalog.ts +26 -8
  96. package/mcp-server/src/services/tool-list.ts +4 -0
  97. package/mcp-server/src/services/tool-runtime.ts +21 -2
  98. package/mcp-server/src/tools/agent-definition.ts +458 -0
  99. package/mcp-server/src/tools/agents.ts +177 -19
  100. package/mcp-server/src/tools/browser-advanced.ts +60 -6
  101. package/mcp-server/src/tools/git-tools.ts +249 -3
  102. package/mcp-server/src/tools/morelogin.ts +20 -5
  103. package/mcp-server/src/tools/team.ts +97 -0
  104. package/neural-interface/i18n/en.json +1119 -47
  105. package/neural-interface/i18n/pt-BR.json +1119 -47
  106. package/neural-interface/lib/account-usage.js +1 -1
  107. package/neural-interface/lib/agents/builtins.json +207 -0
  108. package/neural-interface/lib/agents/density.js +101 -0
  109. package/neural-interface/lib/agents/forge-host.js +223 -0
  110. package/neural-interface/lib/agents/native-export-targets.js +190 -0
  111. package/neural-interface/lib/agents/native-export.js +365 -0
  112. package/neural-interface/lib/agents/registry.js +885 -0
  113. package/neural-interface/lib/agents/resolve.js +603 -0
  114. package/neural-interface/lib/agents/schema.js +642 -0
  115. package/neural-interface/lib/agents/split.js +37 -0
  116. package/neural-interface/lib/agents-studio-api.js +591 -0
  117. package/neural-interface/lib/assistant-api.js +76 -7
  118. package/neural-interface/lib/assistant-brains/opencode.js +60 -11
  119. package/neural-interface/lib/assistant-catalog.js +2 -0
  120. package/neural-interface/lib/assistant-continuity.js +49 -0
  121. package/neural-interface/lib/assistant-dispatch.js +351 -121
  122. package/neural-interface/lib/assistant-persona.js +105 -8
  123. package/neural-interface/lib/assistant-route-gate.js +24 -9
  124. package/neural-interface/lib/assistant-router.js +432 -47
  125. package/neural-interface/lib/assistant-run-tail.js +151 -0
  126. package/neural-interface/lib/assistant-run-wait.js +183 -0
  127. package/neural-interface/lib/assistant-runtime.js +449 -94
  128. package/neural-interface/lib/assistant-task-prompt.js +11 -2
  129. package/neural-interface/lib/assistant-usage.js +3 -2
  130. package/neural-interface/lib/automation-approval.js +2 -2
  131. package/neural-interface/lib/backup-service.js +64 -105
  132. package/neural-interface/lib/browser-close-evidence.js +80 -0
  133. package/neural-interface/lib/browser-default.js +210 -0
  134. package/neural-interface/lib/browser-extension-adapter.js +264 -0
  135. package/neural-interface/lib/browser-extension-bridge.js +441 -0
  136. package/neural-interface/lib/browser-extension-folder.js +116 -0
  137. package/neural-interface/lib/browser-extension-setup.js +140 -0
  138. package/neural-interface/lib/browser-profile-choices.js +3 -3
  139. package/neural-interface/lib/browser-tool-policy.js +1 -1
  140. package/neural-interface/lib/claude-account-links.js +301 -0
  141. package/neural-interface/lib/claude-accounts.js +45 -20
  142. package/neural-interface/lib/claude-agent-bridge.js +142 -10
  143. package/neural-interface/lib/claude-model-catalog.js +6 -0
  144. package/neural-interface/lib/claude-panel-session.js +33 -0
  145. package/neural-interface/lib/codex-accounts.js +67 -24
  146. package/neural-interface/lib/coordination/README.md +384 -0
  147. package/neural-interface/lib/coordination/service.js +563 -0
  148. package/neural-interface/lib/coordination/store.js +1138 -0
  149. package/neural-interface/lib/db.js +22 -1
  150. package/neural-interface/lib/effort-levels.js +10 -1
  151. package/neural-interface/lib/memory-list-page.js +49 -0
  152. package/neural-interface/lib/memory-list-stamp.js +60 -0
  153. package/neural-interface/lib/morelogin-outside-close.js +186 -0
  154. package/neural-interface/lib/morelogin-profile-failures.js +206 -0
  155. package/neural-interface/lib/morelogin-start-cooldown.js +160 -0
  156. package/neural-interface/lib/morelogin.js +194 -8
  157. package/neural-interface/lib/native-loop-runtime.js +26 -7
  158. package/neural-interface/lib/opencode-build-preflight.js +28 -8
  159. package/neural-interface/lib/opencode-native-boundary.js +83 -13
  160. package/neural-interface/lib/opencode-serve-records.js +14 -9
  161. package/neural-interface/lib/page-session.js +1 -1
  162. package/neural-interface/lib/peer-identity.js +73 -29
  163. package/neural-interface/lib/process-identity.js +68 -7
  164. package/neural-interface/lib/request-gate.js +3 -0
  165. package/neural-interface/lib/screenshot-location.js +33 -0
  166. package/neural-interface/lib/session-cache-builder.js +41 -3
  167. package/neural-interface/lib/skills/creation.js +1 -1
  168. package/neural-interface/lib/skills/known-bridge-digests.json +40 -0
  169. package/neural-interface/lib/studio-attention.js +56 -0
  170. package/neural-interface/lib/teams/README.md +382 -0
  171. package/neural-interface/lib/teams/api.js +287 -0
  172. package/neural-interface/lib/teams/brief.js +185 -0
  173. package/neural-interface/lib/teams/claims.js +315 -0
  174. package/neural-interface/lib/teams/git.js +293 -0
  175. package/neural-interface/lib/teams/index.js +122 -0
  176. package/neural-interface/lib/teams/integration.js +580 -0
  177. package/neural-interface/lib/teams/landing.js +184 -0
  178. package/neural-interface/lib/teams/recovery.js +256 -0
  179. package/neural-interface/lib/teams/scheduler.js +1474 -0
  180. package/neural-interface/lib/teams/schema.js +559 -0
  181. package/neural-interface/lib/teams/state.js +181 -0
  182. package/neural-interface/lib/teams/test-runner.js +86 -0
  183. package/neural-interface/lib/teams/test-sandbox.js +99 -0
  184. package/neural-interface/lib/teams/worktrees.js +757 -0
  185. package/neural-interface/lib/tool-permission-choices.js +226 -0
  186. package/neural-interface/lib/whatsapp/cards.js +24 -10
  187. package/neural-interface/lib/worker-confinement.js +206 -6
  188. package/neural-interface/package-lock.json +2 -2
  189. package/neural-interface/package.json +1 -1
  190. package/neural-interface/public/extension-setup.html +107 -0
  191. package/neural-interface/public/index.html +103 -12
  192. package/neural-interface/public/offline.html +4 -3
  193. package/neural-interface/public/shared/agent-runtime-options.js +3 -1
  194. package/neural-interface/public/shared/agents/studio/ax-agent-view.js +614 -0
  195. package/neural-interface/public/shared/agents/studio/ax-api.js +198 -0
  196. package/neural-interface/public/shared/agents/studio/ax-create-view.js +221 -0
  197. package/neural-interface/public/shared/agents/studio/ax-diff.js +143 -0
  198. package/neural-interface/public/shared/agents/studio/ax-editor-view.js +392 -0
  199. package/neural-interface/public/shared/agents/studio/ax-export-view.js +94 -0
  200. package/neural-interface/public/shared/agents/studio/ax-form.js +191 -0
  201. package/neural-interface/public/shared/agents/studio/ax-icons.js +87 -0
  202. package/neural-interface/public/shared/agents/studio/ax-library-view.js +158 -0
  203. package/neural-interface/public/shared/agents/studio/ax-library.js +162 -0
  204. package/neural-interface/public/shared/agents/studio/ax-main.js +712 -0
  205. package/neural-interface/public/shared/agents/studio/ax-native-export.js +35 -0
  206. package/neural-interface/public/shared/agents/studio/ax-options.js +198 -0
  207. package/neural-interface/public/shared/agents/studio/ax-review-view.js +175 -0
  208. package/neural-interface/public/shared/agents/studio/ax-revisions-view.js +189 -0
  209. package/neural-interface/public/shared/agents/studio/ax-runs-view.js +202 -0
  210. package/neural-interface/public/shared/agents/studio/ax-runs.js +82 -0
  211. package/neural-interface/public/shared/agents/studio/ax-teams-view.js +256 -0
  212. package/neural-interface/public/shared/agents/studio/ax-teams.js +200 -0
  213. package/neural-interface/public/shared/agents/studio/ax-templates.js +50 -0
  214. package/neural-interface/public/shared/agents/studio/ax-ui.js +194 -0
  215. package/neural-interface/public/shared/agents/studio/ax-views.js +170 -0
  216. package/neural-interface/public/shared/agy/agy-panel.js +142 -28
  217. package/neural-interface/public/shared/agy/agy-styles.js +25 -5
  218. package/neural-interface/public/shared/api.js +2 -1
  219. package/neural-interface/public/shared/assistant/asst-account-menu.js +13 -13
  220. package/neural-interface/public/shared/assistant/asst-ask-styles.js +2 -3
  221. package/neural-interface/public/shared/assistant/asst-brain-picker.js +91 -9
  222. package/neural-interface/public/shared/assistant/asst-control.js +3 -0
  223. package/neural-interface/public/shared/assistant/asst-interaction-hold.js +99 -0
  224. package/neural-interface/public/shared/assistant/asst-limit-dismissals.js +111 -0
  225. package/neural-interface/public/shared/assistant/asst-limit-dock.js +37 -3
  226. package/neural-interface/public/shared/assistant/asst-limit-wait.js +30 -7
  227. package/neural-interface/public/shared/assistant/asst-panel.js +177 -30
  228. package/neural-interface/public/shared/assistant/asst-rack-styles.js +15 -8
  229. package/neural-interface/public/shared/assistant/asst-render.js +37 -6
  230. package/neural-interface/public/shared/assistant/asst-route.js +80 -12
  231. package/neural-interface/public/shared/assistant/asst-routes-editor.js +148 -70
  232. package/neural-interface/public/shared/assistant/asst-roving.js +17 -1
  233. package/neural-interface/public/shared/assistant/asst-scene-styles.js +7 -2
  234. package/neural-interface/public/shared/assistant/asst-scenes.js +12 -1
  235. package/neural-interface/public/shared/assistant/asst-sidepanel.js +12 -2
  236. package/neural-interface/public/shared/assistant/asst-state.js +66 -1
  237. package/neural-interface/public/shared/assistant/asst-styles.js +98 -44
  238. package/neural-interface/public/shared/assistant/route-identity.js +16 -0
  239. package/neural-interface/public/shared/cc-dropdown.js +21 -15
  240. package/neural-interface/public/shared/cdx/cdx-output.js +10 -0
  241. package/neural-interface/public/shared/cdx/cdx-panel.js +18 -16
  242. package/neural-interface/public/shared/cdx/cdx-plan.js +3 -2
  243. package/neural-interface/public/shared/cdx/cdx-render.js +122 -45
  244. package/neural-interface/public/shared/cdx/cdx-requests.js +4 -4
  245. package/neural-interface/public/shared/cdx/cdx-styles.js +8 -36
  246. package/neural-interface/public/shared/cdx/cdx-tabs.js +110 -42
  247. package/neural-interface/public/shared/claude-panel-lazy.js +12 -0
  248. package/neural-interface/public/shared/code-copy.js +120 -0
  249. package/neural-interface/public/shared/constants.js +7 -0
  250. package/neural-interface/public/shared/context-menu-model.js +1 -0
  251. package/neural-interface/public/shared/cp/cp-markdown.js +7 -2
  252. package/neural-interface/public/shared/cp/cp-session-model.js +86 -5
  253. package/neural-interface/public/shared/cp/cp-session-settings.js +58 -30
  254. package/neural-interface/public/shared/cp/cp-styles.js +9 -0
  255. package/neural-interface/public/shared/dom-change-flag.js +66 -0
  256. package/neural-interface/public/shared/dom-morph.js +124 -0
  257. package/neural-interface/public/shared/extension-setup/es-page.css +134 -0
  258. package/neural-interface/public/shared/extension-setup/es-page.js +120 -0
  259. package/neural-interface/public/shared/extension-setup/es-view.js +100 -0
  260. package/neural-interface/public/shared/html-shell.js +34 -4
  261. package/neural-interface/public/shared/i18n.js +14 -1
  262. package/neural-interface/public/shared/idle-queue.js +78 -0
  263. package/neural-interface/public/shared/iface-config.js +227 -0
  264. package/neural-interface/public/shared/lazy-module.js +108 -0
  265. package/neural-interface/public/shared/memory-list.js +117 -0
  266. package/neural-interface/public/shared/morelogin-profile-choices.js +1 -1
  267. package/neural-interface/public/shared/morelogin-profile-field.js +3 -3
  268. package/neural-interface/public/shared/mtc/mtc-panel.js +3 -1
  269. package/neural-interface/public/shared/mtc/mtc-styles.js +4 -1
  270. package/neural-interface/public/shared/ocp-v2/ocp-v2-manager.js +35 -15
  271. package/neural-interface/public/shared/ocp-v2/ocp-v2-panel.js +77 -23
  272. package/neural-interface/public/shared/ocp-v2/ocp-v2-projectbar.js +3 -6
  273. package/neural-interface/public/shared/ocp-v2/ocp-v2-render.js +24 -21
  274. package/neural-interface/public/shared/ocp-v2/ocp-v2-send-logic.js +16 -5
  275. package/neural-interface/public/shared/ocp-v2/ocp-v2-sessions-logic.js +16 -2
  276. package/neural-interface/public/shared/ocp-v2/ocp-v2-styles.js +27 -43
  277. package/neural-interface/public/shared/ocp-v2/ocp-v2-ws.js +73 -9
  278. package/neural-interface/public/shared/owner-authority-view.js +4 -10
  279. package/neural-interface/public/shared/page-session.js +1 -1
  280. package/neural-interface/public/shared/schedules-view.js +2 -2
  281. package/neural-interface/public/shared/session-project-items.js +11 -0
  282. package/neural-interface/public/shared/settings/settings-ai-browser.js +119 -0
  283. package/neural-interface/public/shared/settings/settings-browser-extension.js +446 -0
  284. package/neural-interface/public/shared/settings/settings-ia.js +4 -2
  285. package/neural-interface/public/shared/settings/settings-morelogin-cooldown.js +63 -0
  286. package/neural-interface/public/shared/settings/settings-tool-permissions.js +70 -0
  287. package/neural-interface/public/shared/sidepanel-lazy.js +40 -0
  288. package/neural-interface/public/shared/sidepanel-session-status.js +8 -14
  289. package/neural-interface/public/shared/sidepanel-shown.js +73 -0
  290. package/neural-interface/public/shared/start-bridge.js +2 -2
  291. package/neural-interface/public/shared/storage.js +6 -1
  292. package/neural-interface/public/shared/studio-attention.js +83 -0
  293. package/neural-interface/public/shared/styles.css +694 -50
  294. package/neural-interface/public/shared/term-browser-tabs.js +34 -0
  295. package/neural-interface/public/shared/transcript-rows.js +334 -0
  296. package/neural-interface/public/shared/tray-auto-close.js +106 -0
  297. package/neural-interface/public/shared/ui-agents.js +97 -0
  298. package/neural-interface/public/shared/ui-antigravity-panel.js +16 -14
  299. package/neural-interface/public/shared/ui-automation-studio.js +3 -3
  300. package/neural-interface/public/shared/ui-claude-panel.js +162 -95
  301. package/neural-interface/public/shared/ui-code-copy.js +256 -0
  302. package/neural-interface/public/shared/ui-codex-panel.js +14 -10
  303. package/neural-interface/public/shared/ui-context-menu.js +1 -1
  304. package/neural-interface/public/shared/ui-file-explorer.js +2 -3
  305. package/neural-interface/public/shared/ui-games.js +1 -1
  306. package/neural-interface/public/shared/ui-loading.js +83 -19
  307. package/neural-interface/public/shared/ui-maritaca-panel.js +12 -11
  308. package/neural-interface/public/shared/ui-menubar.js +23 -0
  309. package/neural-interface/public/shared/ui-native-loop-router.js +50 -21
  310. package/neural-interface/public/shared/ui-navbar.js +15 -9
  311. package/neural-interface/public/shared/ui-opencode-panel-v2.js +13 -11
  312. package/neural-interface/public/shared/ui-owner-authority.js +48 -25
  313. package/neural-interface/public/shared/ui-schedules-studio.js +3 -3
  314. package/neural-interface/public/shared/ui-scroll-follow.js +39 -0
  315. package/neural-interface/public/shared/ui-sessions.js +3 -3
  316. package/neural-interface/public/shared/ui-settings-entry.js +55 -0
  317. package/neural-interface/public/shared/ui-settings.js +363 -400
  318. package/neural-interface/public/shared/ui-sidepanel-layout.js +44 -25
  319. package/neural-interface/public/shared/ui-sidepanel-session-entry.js +22 -9
  320. package/neural-interface/public/shared/ui-sidepanel-sessions.js +10 -2
  321. package/neural-interface/public/shared/ui-sidepanel-tray.js +36 -41
  322. package/neural-interface/public/shared/ui-sidepanel-windows.js +14 -1
  323. package/neural-interface/public/shared/ui-styleguide.js +10 -2
  324. package/neural-interface/public/shared/ui-sync.js +6 -0
  325. package/neural-interface/public/shared/ui-terminal.js +13 -9
  326. package/neural-interface/public/shared/ui-tooltip.js +28 -7
  327. package/neural-interface/public/shared/ui-topright-overflow.js +26 -4
  328. package/neural-interface/public/shared/ui-tray-columns.js +375 -0
  329. package/neural-interface/public/shared/ui-whiteboard.js +51 -6
  330. package/neural-interface/public/shared/ui-worker-end.js +28 -1
  331. package/neural-interface/public/shared/ui-workspaces.js +13 -0
  332. package/neural-interface/public/shared/window-keys.js +71 -0
  333. package/neural-interface/public/sw.js +4 -3
  334. package/neural-interface/public/variant/2d/main.js +2 -0
  335. package/neural-interface/public/variant/3d/app.js +620 -0
  336. package/neural-interface/public/variant/3d/boot-reveal.js +47 -0
  337. package/neural-interface/public/variant/3d/main.js +30 -544
  338. package/neural-interface/public/variant/3d/map-controls.js +4 -2
  339. package/neural-interface/public/vendor/fonts/fonts.css +508 -0
  340. package/neural-interface/public/vendor/fonts/inter-OFL.txt +93 -0
  341. package/neural-interface/public/vendor/fonts/inter-cyrillic-ext.woff2 +0 -0
  342. package/neural-interface/public/vendor/fonts/inter-cyrillic.woff2 +0 -0
  343. package/neural-interface/public/vendor/fonts/inter-greek-ext.woff2 +0 -0
  344. package/neural-interface/public/vendor/fonts/inter-greek.woff2 +0 -0
  345. package/neural-interface/public/vendor/fonts/inter-latin-ext.woff2 +0 -0
  346. package/neural-interface/public/vendor/fonts/inter-latin.woff2 +0 -0
  347. package/neural-interface/public/vendor/fonts/inter-vietnamese.woff2 +0 -0
  348. package/neural-interface/public/vendor/fonts/jetbrains-mono-OFL.txt +93 -0
  349. package/neural-interface/public/vendor/fonts/jetbrains-mono-cyrillic-ext.woff2 +0 -0
  350. package/neural-interface/public/vendor/fonts/jetbrains-mono-cyrillic.woff2 +0 -0
  351. package/neural-interface/public/vendor/fonts/jetbrains-mono-greek.woff2 +0 -0
  352. package/neural-interface/public/vendor/fonts/jetbrains-mono-latin-ext.woff2 +0 -0
  353. package/neural-interface/public/vendor/fonts/jetbrains-mono-latin.woff2 +0 -0
  354. package/neural-interface/public/vendor/fonts/jetbrains-mono-vietnamese.woff2 +0 -0
  355. package/neural-interface/public/vendor/fonts/manifest.json +142 -0
  356. package/neural-interface/public/vendor/fonts/space-grotesk-OFL.txt +93 -0
  357. package/neural-interface/public/vendor/fonts/space-grotesk-latin-ext.woff2 +0 -0
  358. package/neural-interface/public/vendor/fonts/space-grotesk-latin.woff2 +0 -0
  359. package/neural-interface/public/vendor/fonts/space-grotesk-vietnamese.woff2 +0 -0
  360. package/neural-interface/scripts/boot-graph.mjs +270 -0
  361. package/neural-interface/scripts/vendor-fonts.mjs +124 -0
  362. package/neural-interface/server.js +1083 -164
  363. package/npm-shrinkwrap.json +2 -2
  364. package/package.json +4 -1
  365. package/skills/agent-forge/SKILL.md +182 -0
  366. package/skills/agent-forge/evals/evals.json +56 -0
  367. package/skills/agent-forge/references/definition-fields.md +61 -0
  368. package/skills/agent-forge/references/examples.md +105 -0
  369. package/skills/agent-forge/references/instructions.md +51 -0
  370. package/skills/agent-forge/references/review-and-export.md +84 -0
@@ -0,0 +1,200 @@
1
+ // ═══════════════════════════════════════════
2
+ // SynaBun Neural Interface — Agents Studio: teams, as the page reads them
3
+ // ═══════════════════════════════════════════
4
+ //
5
+ // A team is one task given to several agents, each in its own worktree and branch, joined on an integration branch
6
+ // and landed on the owner's branch only by the owner (lib/teams/README.md). The page reads them through
7
+ // GET /api/agents-studio/v1/teams and /teams/:id. Those routes belong to the team scheduler, which is built beside
8
+ // this page: everything here reads an answer defensively (either spelling of a field the journal and the route may
9
+ // use: `id` / `teamId`, `status` / `state`, slices as a list or as a record by id), so a field that is not there
10
+ // shows as nothing, never as an error. The words are the journal's own states (lib/teams/schema.js TEAM_STATES,
11
+ // SLICE_STATES) and the scheduler's statuses of a team (lib/teams/scheduler.js TEAM_STATUSES, phase P4: a team's
12
+ // `status` is the scheduler's, its `state` the journal's, and the status is what the list and the summary say); a
13
+ // state this page does not know is shown as written, in the neutral tone. The scheduler's answer for one team
14
+ // (lib/teams/api.js `teamDetail`) is read with its parts put back inside the team (ax-api.js `teamDetailOf`): claims
15
+ // by `glob`, the landing's `landed` / `refused` records, a slice's `lastReport`, an event's `event`, a message's
16
+ // `fromSlice`, the team's `attention`.
17
+ // No DOM and no imports.
18
+
19
+ export const TEAM_STATES = Object.freeze(['creating', 'planned', 'running', 'integrating', 'ready', 'landing', 'merged', 'completed', 'failed', 'cancelled']);
20
+ /** The scheduler's statuses of a team (phase P4, lib/teams/scheduler.js TEAM_STATUSES): what `status` holds there. */
21
+ export const SCHEDULER_TEAM_STATUSES = Object.freeze(['running', 'needs_attention', 'ready', 'completed', 'landed', 'discarded', 'failed']);
22
+ export const SLICE_STATES = Object.freeze(['planned', 'pending', 'blocked', 'running', 'done', 'rejected', 'integrating', 'integrated', 'conflict', 'tests-failed', 'completed', 'failed', 'cancelled']);
23
+
24
+ const TEAM_TONES = { creating: 'idle', planned: 'idle', running: 'active', integrating: 'active', ready: 'ok', landing: 'active', merged: 'done', completed: 'done', failed: 'err', cancelled: 'off', needs_attention: 'warn', landed: 'done', discarded: 'off' };
25
+ /** A team that reached the owner's branch, is on its way there, or was thrown away: nothing more to land or discard. */
26
+ const SETTLED_TEAM = new Set(['merged', 'landing', 'landed', 'discarded', 'completed']);
27
+ const SLICE_TONES = { planned: 'idle', pending: 'idle', blocked: 'warn', running: 'active', done: 'ok', rejected: 'err', integrating: 'active', integrated: 'done', completed: 'done', conflict: 'err', 'tests-failed': 'err', failed: 'err', cancelled: 'off' };
28
+
29
+ const isObject = (value) => !!value && typeof value === 'object' && !Array.isArray(value);
30
+ const text = (value, max = 4000) => (typeof value === 'string' ? value.slice(0, max) : '');
31
+ const first = (...values) => values.find((value) => value !== undefined && value !== null && value !== '');
32
+ const number = (value) => (Number.isFinite(Number(value)) && value !== null && value !== '' ? Number(value) : null);
33
+ const stateOf = (value) => text(first(value?.status, value?.state), 40).toLowerCase();
34
+
35
+ /** The tone of a team's or a slice's state: idle / active / ok / done / warn / err / off. */
36
+ export const teamTone = (state) => TEAM_TONES[state] || 'idle';
37
+ export const sliceTone = (state) => SLICE_TONES[state] || 'idle';
38
+
39
+ /** A row of the teams list. */
40
+ export function teamRow(team) {
41
+ const t = isObject(team) ? team : {};
42
+ const slices = Array.isArray(t.slices) ? t.slices.length : isObject(t.slices) ? Object.keys(t.slices).length : number(first(t.slices, t.sliceCount, t.slicesCount));
43
+ const status = stateOf(t);
44
+ return {
45
+ id: text(first(t.id, t.teamId), 128),
46
+ title: text(first(t.title, t.plan?.title, t.name), 200),
47
+ project: text(first(t.project, t.projectPath, t.plan?.projectPath), 1024),
48
+ status, tone: teamTone(status),
49
+ density: text(first(t.density, t.plan?.density), 40),
50
+ slices: slices ?? null,
51
+ createdAt: text(first(t.createdAt, t.created_at), 40),
52
+ updatedAt: text(first(t.updatedAt, t.updated_at), 40),
53
+ };
54
+ }
55
+
56
+ /** The list, newest first, a team without an id left out. */
57
+ export function teamRows(teams) {
58
+ return (Array.isArray(teams) ? teams : []).map(teamRow).filter((row) => row.id)
59
+ .sort((a, b) => String(b.createdAt).localeCompare(String(a.createdAt)));
60
+ }
61
+
62
+ /** How many teams are under way (the rail's count). */
63
+ export function activeTeams(rows) {
64
+ // A team that waits on the owner (`needs_attention`) is still under way.
65
+ return (Array.isArray(rows) ? rows : []).filter((row) => ['active', 'ok', 'warn'].includes(row.tone)).length;
66
+ }
67
+
68
+ function sliceOf(raw, plan) {
69
+ const s = isObject(raw) ? raw : {};
70
+ const id = text(first(s.id, s.sliceId), 128);
71
+ const planned = isObject(plan) ? plan : {};
72
+ const status = stateOf(s) || 'planned';
73
+ const ab = isObject(s.aheadBehind) ? s.aheadBehind : s;
74
+ return {
75
+ id,
76
+ title: text(first(s.title, planned.title, id), 200),
77
+ task: text(first(s.task, planned.task), 4000),
78
+ agentRef: text(first(s.agentRef, s.agent_ref, planned.agentRef, planned.agent_ref), 200),
79
+ status, tone: sliceTone(status),
80
+ runId: text(first(s.runId, s.run_id), 128) || null,
81
+ worktree: text(first(s.worktree, s.worktreePath, s.path), 1024),
82
+ branch: text(first(s.branch, s.branchName), 300),
83
+ ownedPaths: (Array.isArray(first(s.ownedPaths, s.owned, s.paths, planned.ownedPaths)) ? first(s.ownedPaths, s.owned, s.paths, planned.ownedPaths) : []).filter((p) => typeof p === 'string').slice(0, 200),
84
+ dependsOn: (Array.isArray(first(s.dependsOn, planned.dependsOn)) ? first(s.dependsOn, planned.dependsOn) : []).filter((p) => typeof p === 'string'),
85
+ ahead: number(first(ab.ahead, s.ahead)),
86
+ behind: number(first(ab.behind, s.behind)),
87
+ note: text(first(s.cleanup?.kept ? `Worktree kept: ${s.cleanup.kept.reason} (${s.cleanup.kept.path})` : null, s.error, s.reason, s.note, isObject(s.lastReport) ? s.lastReport.message : null), 600),
88
+ updatedAt: text(first(s.updatedAt, s.updated_at), 40),
89
+ };
90
+ }
91
+
92
+ /** The slices of a team, in the plan's order (a slice the plan does not name comes after). */
93
+ export function sliceRows(team) {
94
+ const t = isObject(team) ? team : {};
95
+ const planned = Array.isArray(t.plan?.slices) ? t.plan.slices.filter(isObject) : [];
96
+ const stored = Array.isArray(t.slices) ? t.slices.filter(isObject) : isObject(t.slices) ? Object.entries(t.slices).map(([id, slice]) => ({ id, ...(isObject(slice) ? slice : {}) })) : [];
97
+ const byId = new Map(stored.map((slice) => [text(first(slice.id, slice.sliceId), 128), slice]));
98
+ const out = [];
99
+ for (const plan of planned) {
100
+ const id = text(plan.id, 128);
101
+ if (!id) continue;
102
+ out.push(sliceOf({ id, ...(byId.get(id) || {}) }, plan));
103
+ byId.delete(id);
104
+ }
105
+ for (const [id, slice] of byId) if (id) out.push(sliceOf(slice, null));
106
+ return out;
107
+ }
108
+
109
+ /** The integration branch: its state, where its head is, and the last test run on it. */
110
+ export function integrationOf(team) {
111
+ const i = isObject(team?.integration) ? team.integration : {};
112
+ const tests = isObject(first(i.tests, i.lastTest, i.test)) ? first(i.tests, i.lastTest, i.test) : null;
113
+ const passed = tests ? (tests.ok === true || tests.passed === true || tests.status === 'passed' ? true : (tests.ok === false || tests.passed === false || tests.status === 'failed' ? false : null)) : null;
114
+ return {
115
+ state: stateOf(i),
116
+ branch: text(first(i.branch, i.branchName), 300),
117
+ head: text(first(i.head, i.commit), 80),
118
+ lastGood: text(first(i.lastGood, i.last_good), 80),
119
+ tests: tests ? {
120
+ passed,
121
+ command: Array.isArray(tests.command) ? tests.command.join(' ') : text(first(tests.command, tests.cmd), 600),
122
+ exitCode: number(first(tests.exitCode, tests.code)),
123
+ at: text(first(tests.at, tests.finishedAt, tests.createdAt), 40),
124
+ commit: text(first(tests.commit, tests.head), 80),
125
+ summary: text(first(tests.summary, tests.output, tests.tail), 2000),
126
+ } : null,
127
+ };
128
+ }
129
+
130
+ /** The landing: whether the team's result reached the owner's branch, and how. */
131
+ export function landingOf(team) {
132
+ const l = isObject(team?.landing) ? team.landing : {};
133
+ // The scheduler keeps the landing git made (`landed`: targetBranch, mode, mergeCommit, to, at) and the last refusal
134
+ // (`refused`: code, message, at) as records of their own.
135
+ const landed = isObject(l.landed) ? l.landed : {};
136
+ const refused = isObject(l.refused) ? l.refused : {};
137
+ const str = (value) => (typeof value === 'string' ? value : null);
138
+ return {
139
+ state: stateOf(l),
140
+ targetBranch: text(first(str(l.targetBranch), str(landed.targetBranch), str(l.target), str(team?.baseBranch)), 300),
141
+ mode: text(first(str(l.mode), str(landed.mode)), 20),
142
+ commit: text(first(str(l.commit), str(l.head), str(landed.mergeCommit), str(landed.to)), 80),
143
+ at: text(first(str(l.at), str(l.landedAt), str(l.finishedAt), str(landed.at)), 40),
144
+ error: text(first(str(l.error), str(l.reason), str(refused.message)), 600),
145
+ };
146
+ }
147
+
148
+ /** The claims: which slice holds which path. */
149
+ export function claimRows(team) {
150
+ const claims = Array.isArray(team?.claims) ? team.claims : [];
151
+ return claims.filter(isObject).map((claim) => ({
152
+ path: text(first(claim.path, claim.glob, claim.resource, claim.key), 1024),
153
+ sliceId: text(first(claim.sliceId, claim.slice, claim.owner), 128),
154
+ })).filter((row) => row.path).slice(0, 500);
155
+ }
156
+
157
+ /** The team's events and messages as one feed, newest last, the last `limit` of them. */
158
+ export function feedItems(team, limit = 100) {
159
+ const rows = [];
160
+ const take = (list, kindWord) => {
161
+ for (const item of Array.isArray(list) ? list : []) {
162
+ if (!isObject(item)) continue;
163
+ const body = first(item.text, item.body, item.message, item.summary, item.data?.text, item.data?.summary);
164
+ rows.push({
165
+ seq: number(first(item.seq, item.id)),
166
+ kind: text(first(item.kind, item.type, item.event, kindWord), 80),
167
+ message: kindWord === 'message' || item.kind === 'message' || item.type === 'message',
168
+ at: text(first(item.at, item.createdAt, item.created_at, item.time), 40),
169
+ from: text(first(item.fromSlice, item.from, item.sender, item.sliceId, item.slice, item.runId, item.author), 200),
170
+ text: typeof body === 'string' ? body.slice(0, 2000) : '',
171
+ });
172
+ }
173
+ };
174
+ take(team?.events, 'event');
175
+ take(team?.messages, 'message');
176
+ rows.sort((a, b) => String(a.at).localeCompare(String(b.at)) || (a.seq ?? 0) - (b.seq ?? 0));
177
+ return rows.slice(-Math.max(1, limit));
178
+ }
179
+
180
+ /** One team as the page draws it. */
181
+ export function teamView(team) {
182
+ const row = teamRow(team);
183
+ const slices = sliceRows(team);
184
+ const integration = integrationOf(team);
185
+ return {
186
+ ...row,
187
+ slices,
188
+ readOnly: team?.plan?.readOnly === true,
189
+ baseBranch: text(first(team?.baseBranch, team?.plan?.baseBranch), 300),
190
+ baseCommit: text(first(team?.baseCommit, team?.plan?.baseCommit), 80),
191
+ integration, landing: landingOf(team), claims: claimRows(team), feed: feedItems(team),
192
+ // What the scheduler waits on the owner for (status `needs_attention`): its sentence, shown as text.
193
+ attention: text(isObject(team?.attention) ? first(team.attention.message, team.attention.code) : team?.attention, 600),
194
+ // Landing is offered once the integration branch is ready (the server refuses anything else and says why).
195
+ canLand: team?.plan?.readOnly !== true && row.status === 'ready',
196
+ // A team that reached the owner's branch, or is on its way there, is not thrown away from here.
197
+ canDiscard: !!row.id && !SETTLED_TEAM.has(row.status) && team?.removed !== true,
198
+ sliceCounts: slices.reduce((acc, slice) => { acc[slice.tone] = (acc[slice.tone] || 0) + 1; return acc; }, {}),
199
+ };
200
+ }
@@ -0,0 +1,50 @@
1
+ // ═══════════════════════════════════════════
2
+ // SynaBun Neural Interface — Agents Studio: starting points for a new agent
3
+ // ═══════════════════════════════════════════
4
+ //
5
+ // The creator offers a few sensible roles to start from. A template is only a filled form: what it sets is what
6
+ // the editor then shows, the owner changes anything, and the result is a draft like any other (nothing is approved
7
+ // by choosing one). The words (name, description, instructions) are the page's strings
8
+ // (`agentsStudio.templates.<id>.*`), so a template reads in the page's language. Every template asks for the least
9
+ // it needs: review and research read only, the rest stay in the workspace; none is `full`.
10
+ // No DOM and no imports.
11
+
12
+ import { blankForm, slugOf } from './ax-form.js';
13
+
14
+ export const TEMPLATES = Object.freeze([
15
+ { id: 'reviewer', icon: 'eye', color: 'status.warning', capability: 'read-only', permissionPolicy: 'auto', usesBrowser: false, taskClasses: ['review'] },
16
+ { id: 'implementer', icon: 'code', color: 'primary.500', capability: 'workspace', permissionPolicy: 'auto', usesBrowser: false, taskClasses: ['code', 'complex'] },
17
+ { id: 'researcher', icon: 'search', color: 'status.running', capability: 'read-only', permissionPolicy: 'auto', usesBrowser: true, taskClasses: ['research'] },
18
+ { id: 'writer', icon: 'pen', color: 'secondary.500', capability: 'workspace', permissionPolicy: 'auto', usesBrowser: false, taskClasses: ['quick'] },
19
+ { id: 'tester', icon: 'globe', color: 'status.success', capability: 'workspace', permissionPolicy: 'auto', usesBrowser: true, taskClasses: ['browser'] },
20
+ ]);
21
+
22
+ export const templateById = (id) => TEMPLATES.find((template) => template.id === id) || null;
23
+
24
+ /**
25
+ * The form a template starts the editor with. `t` gives the template's words; `known.taskClasses` (the server's
26
+ * list) drops a class the server does not name, `provider` is the one a new agent starts on.
27
+ */
28
+ export function templateForm(template, t, { provider = '', scope = null, taskClasses = null, idLimit = 64 } = {}) {
29
+ const form = blankForm({ provider, scope });
30
+ if (!template) return form;
31
+ const name = t(`agentsStudio.templates.${template.id}.name`);
32
+ const known = Array.isArray(taskClasses) ? new Set(taskClasses) : null;
33
+ return {
34
+ ...form,
35
+ name, id: slugOf(name, idLimit),
36
+ description: t(`agentsStudio.templates.${template.id}.description`),
37
+ instructions: t(`agentsStudio.templates.${template.id}.instructions`),
38
+ icon: template.icon, color: template.color,
39
+ capability: template.capability, permissionPolicy: template.permissionPolicy,
40
+ usesBrowser: template.usesBrowser === true,
41
+ taskClasses: template.taskClasses.filter((cls) => !known || known.has(cls)),
42
+ };
43
+ }
44
+
45
+ /** The text handed to the Assistant when the owner describes an agent instead of filling the form. */
46
+ export function describeRequest(description, t, { scope = null } = {}) {
47
+ const what = String(description || '').trim();
48
+ const where = scope?.kind === 'project' ? t('agentsStudio.create.describe.requestProject', { path: scope.path }) : t('agentsStudio.create.describe.requestGlobal');
49
+ return `${t('agentsStudio.create.describe.request')}\n\n${what}\n\n${where}`;
50
+ }
@@ -0,0 +1,194 @@
1
+ // ═══════════════════════════════════════════
2
+ // SynaBun Neural Interface — Agents Studio: the markup its views share
3
+ // ═══════════════════════════════════════════
4
+ //
5
+ // The pieces more than one view draws: an agent's mark (its icon on its colour), the status and scope labels, a
6
+ // form field with its note, the app's dropdown as a field, a diff (field rows, the instructions as hunks, the
7
+ // privilege delta), the privilege summary, the loading / empty / error states, and the words the pure modules ask
8
+ // for. Everything goes through the Studio's escaping `html` (skills/studio/sx-dom.js): a name, a description, a
9
+ // path or a server's message is text, never markup. The dropdown is the app's `.cc-dropdown`; no view writes a
10
+ // native one.
11
+
12
+ import { html, raw, ICONS, relativeTime, fullTime } from '../../skills/studio/sx-dom.js';
13
+ import { dropdownHTML } from '../../cc-dropdown.js';
14
+ import { agentIcon, toneOf, AX_ICONS } from './ax-icons.js';
15
+ import { standingOf, scopeLabel, authorKind } from './ax-library.js';
16
+ import { diffRows, hunksOf, privilegeChanges, privilegeSummary, diffSize } from './ax-diff.js';
17
+
18
+ /** The words the pure modules take (ax-diff.js valueText): the page's strings for values. */
19
+ export function wordsOf(t, { projects = [], profiles = [] } = {}) {
20
+ const or = (key, fallback) => { const said = t(key); return said === key ? fallback : said; };
21
+ return {
22
+ yes: t('agentsStudio.value.yes'), no: t('agentsStudio.value.no'), none: t('agentsStudio.value.none'),
23
+ defaultTools: t('agentsStudio.value.defaultTools'), alwaysOn: t('agentsStudio.value.alwaysOn'), allTools: t('agentsStudio.value.allTools'),
24
+ allServers: t('agentsStudio.value.allServers'), global: t('agentsStudio.scope.global'), project: t('agentsStudio.scope.project'),
25
+ capability: (level) => or(`agentsStudio.capability.${level}.name`, level),
26
+ policy: (id) => or(`agentsStudio.policy.${id}.name`, id),
27
+ taskClass: (id) => or(`agentsStudio.taskClass.${id}`, id),
28
+ provider: (id) => or(`agentsStudio.provider.${id}`, id),
29
+ projects, profiles,
30
+ };
31
+ }
32
+
33
+ /** A word of a family, or the value as written when the family has no word for it (a state from a newer server). */
34
+ export function wordOr(t, family, value) {
35
+ const key = `${family}.${value}`;
36
+ const said = t(key);
37
+ return said === key ? String(value ?? '') : said;
38
+ }
39
+
40
+ /** An agent's mark: its icon on its colour token's tone. */
41
+ export function agentMark(agent, size = 18) {
42
+ return html`<span class="ax-mark ax-tone--${toneOf(agent?.color)}" aria-hidden="true">${agentIcon(agent?.icon, size)}</span>`;
43
+ }
44
+
45
+ export function statusLabel(t, status) {
46
+ return html`<span class="sx-label ax-status ax-status--${status}">${wordOr(t, 'agentsStudio.status', status)}</span>`;
47
+ }
48
+
49
+ /** The labels of where an agent stands: its status with the revision, and a working revision on top of it. */
50
+ export function standingLabels(t, agent) {
51
+ const s = standingOf(agent);
52
+ return html`${agent.source === 'builtin' ? html`<span class="sx-chip ax-chip" title="${t('agentsStudio.builtinHelp')}">${t('agentsStudio.builtin')}</span>` : ''}${statusLabel(t, s.status)}${s.revision ? html`<span class="ax-rev">${t('agentsStudio.revisionShort', { n: s.revision })}</span>` : ''}${s.pending ? html`<span class="sx-label ax-status ax-status--${s.pending}">${t(`agentsStudio.pending.${s.pending}`, { n: s.draftRevision ?? '' })}</span>` : ''}${s.damaged ? html`<span class="sx-label ax-status ax-status--damaged" title="${t('agentsStudio.damagedHelp')}">${t('agentsStudio.damaged')}</span>` : ''}`;
53
+ }
54
+
55
+ export function scopeTag(t, scope, projects = []) {
56
+ const project = scope?.kind === 'project';
57
+ return html`<span class="sx-tag ax-scope" title="${project ? scope.path : t('agentsStudio.scope.globalHelp')}">${project ? AX_ICONS.pin : AX_ICONS.global}<span>${scopeLabel(scope, projects, t('agentsStudio.scope.global'))}</span></span>`;
58
+ }
59
+
60
+ /** "3 min ago" with the full date as its title; '' for nothing. */
61
+ export function timeTag(iso, locale) {
62
+ const said = relativeTime(iso, locale);
63
+ return said ? html`<time datetime="${iso}" title="${fullTime(iso, locale)}">${said}</time>` : '';
64
+ }
65
+
66
+ /** Who made a revision. */
67
+ export const authorText = (t, author) => t(`agentsStudio.author.${authorKind(author)}`);
68
+
69
+ /** A field: its label (with an optional count), its control, and the place its problems are written. */
70
+ export function field({ id, label, control, help = '', count = null, field: name = '', wide = false, required = false }) {
71
+ return html`<div class="sx-field ax-field${wide ? ' ax-field--wide' : ''}"${name ? html` data-field="${name}"` : ''}>
72
+ <span class="sx-field-label" id="${id}-label"><span>${label}${required ? html`<span class="ax-required" aria-hidden="true"> *</span>` : ''}</span>${count !== null ? html`<span class="sx-count" data-count-for="${name}">${count}</span>` : ''}</span>
73
+ ${control}
74
+ ${help ? html`<p class="sx-field-note" id="${id}-help">${help}</p>` : ''}
75
+ ${name ? html`<div class="ax-issues" data-issues-for="${name}" id="${id}-issues" role="status"></div>` : ''}
76
+ </div>`;
77
+ }
78
+
79
+ /** The app's dropdown as markup for `html` (the hidden input has `id`; its change event bubbles). */
80
+ export function dropdown(id, entries, { labelledBy = '', label = '', multiple = false, summary = '', disabled = false, field: name = '', classes = '' } = {}) {
81
+ return raw(dropdownHTML(id, entries, { labelledBy, label, multiple, summary, disabled, fitTrigger: !!name, classes: `sx-dd ${classes}`.trim(), inputAttrs: name ? `data-form-field="${name}"` : '' }));
82
+ }
83
+
84
+ /** The problems of one field, as the lines under it. */
85
+ export function issuesHTML(found) {
86
+ if (!found || (!found.errors.length && !found.warnings.length)) return '';
87
+ return html`${found.errors.map((issue) => html`<p class="sx-field-note sx-err-text">${ICONS.err}<span>${issue.message}</span></p>`)}${found.warnings.map((issue) => html`<p class="sx-field-note sx-warn-text">${ICONS.warn}<span>${issue.message}</span></p>`)}`;
88
+ }
89
+
90
+ // ── States ──
91
+
92
+ export function loadingHTML(t, text = null) {
93
+ return html`<div class="sx-empty ax-state" role="status" aria-busy="true"><span class="ax-spinner" aria-hidden="true"></span><p>${text || t('agentsStudio.state.loading')}</p></div>`;
94
+ }
95
+
96
+ export function errorHTML(t, error, { retry = true } = {}) {
97
+ return html`<div class="sx-empty ax-state" role="alert">
98
+ <span class="sx-placeholder-icon ax-state-icon ax-state-icon--err">${ICONS.err}</span>
99
+ <h3 class="sx-empty-title" tabindex="-1" data-autofocus>${t('agentsStudio.state.failedTitle')}</h3>
100
+ <p>${errorText(t, error)}</p>
101
+ ${retry ? html`<button type="button" class="sx-btn" data-act="retry">${t('agentsStudio.state.retry')}</button>` : ''}
102
+ </div>`;
103
+ }
104
+
105
+ export function emptyHTML({ icon = ICONS.info, title, lines = [], actions = '' }) {
106
+ return html`<div class="sx-empty ax-state">
107
+ <span class="sx-placeholder-icon ax-state-icon">${icon}</span>
108
+ <h3 class="sx-empty-title" tabindex="-1" data-autofocus>${title}</h3>
109
+ ${lines.map((line) => html`<p>${line}</p>`)}
110
+ ${actions ? html`<div class="sx-row ax-state-actions">${actions}</div>` : ''}
111
+ </div>`;
112
+ }
113
+
114
+ /** What an error says to the owner: the server's sentence, or the page's own for what it knows. */
115
+ export function errorText(t, error) {
116
+ const code = error?.code;
117
+ if (code === 'WORKER_BROWSER') return t('agentsStudio.error.automationBrowser');
118
+ if (code === 'PEER_UNAVAILABLE') return t('agentsStudio.error.peerUnavailable');
119
+ if (error?.status === 403 && (code === 'GUEST_FORBIDDEN' || code === 'UI_ONLY' || code === 'PAGE_SECRET_REQUIRED' || code === 'OWNER_ROUTE' || code === 'PEER_REFUSED')) return t('agentsStudio.error.ownerOnly');
120
+ if (code === 'not_json' || error?.absent) return t('agentsStudio.error.olderServer');
121
+ if (error?.name === 'TypeError' || /failed to fetch|networkerror|load failed/i.test(String(error?.message || ''))) return t('agentsStudio.error.network');
122
+ return String(error?.message || error || t('agentsStudio.error.unknown'));
123
+ }
124
+
125
+ // ── Diff ──
126
+
127
+ /** The instructions' line diff, the unchanged middle folded. */
128
+ function hunksHTML(t, lines) {
129
+ if (!lines) return html`<p class="sx-help">${t('agentsStudio.diff.tooLong')}</p>`;
130
+ const hunks = hunksOf(lines, 2);
131
+ return html`<table class="sx-diff-hunk ax-hunks"><tbody>${hunks.map((row) => (row.gap
132
+ ? html`<tr class="ax-diff-gap"><td class="sx-diff-num" colspan="2"></td><td class="sx-diff-sign"></td><td class="sx-diff-text">${t(row.gap === 1 ? 'agentsStudio.diff.unchangedOne' : 'agentsStudio.diff.unchanged', { count: row.gap })}</td></tr>`
133
+ : html`<tr class="${row.op === '+' ? 'sx-diff-row--add' : row.op === '-' ? 'sx-diff-row--del' : ''}"><td class="sx-diff-num">${row.oldNo ?? ''}</td><td class="sx-diff-num">${row.newNo ?? ''}</td><td class="sx-diff-sign">${row.op === ' ' ? '' : row.op}<span class="sx-sr">${row.op === '+' ? t('agentsStudio.diff.added') : row.op === '-' ? t('agentsStudio.diff.removed') : ''}</span></td><td class="sx-diff-text">${row.line}</td></tr>`))}</tbody></table>`;
134
+ }
135
+
136
+ /**
137
+ * A diff as the registry answers it: which revisions, the privilege delta first (what the newer one may newly do),
138
+ * then every changed field, the instructions last.
139
+ */
140
+ export function diffHTML(t, diff, words, { open = true } = {}) {
141
+ if (!diff) return '';
142
+ const rows = diffRows(diff, words);
143
+ const size = diffSize(diff);
144
+ const delta = privilegeChanges(diff.privileges, words);
145
+ const first = !diff.from;
146
+ const head = first
147
+ ? t('agentsStudio.diff.first', { to: diff.to?.revision ?? '' })
148
+ : t('agentsStudio.diff.between', { from: diff.from.revision, to: diff.to?.revision ?? '' });
149
+ if (!diff.changed && !first) return html`<div class="ax-diff"><p class="ax-diff-head">${head}</p><p class="sx-note">${t('agentsStudio.diff.same')}</p></div>`;
150
+ return html`<div class="ax-diff">
151
+ <p class="ax-diff-head">${head}<span class="ax-diff-size">${t('agentsStudio.diff.size', { fields: size.fields })}${size.added || size.removed ? html` · <span class="sx-diff-plus">+${size.added}</span> <span class="sx-diff-minus">−${size.removed}</span>` : ''}</span></p>
152
+ ${delta.length ? html`<div class="ax-delta${diff.privileges?.escalates ? ' ax-delta--wider' : ''}" role="group" aria-label="${t('agentsStudio.privilege.deltaTitle')}">
153
+ <p class="ax-delta-title">${diff.privileges?.escalates ? html`${AX_ICONS.wider}<span>${t('agentsStudio.privilege.wider')}</span>` : html`${ICONS.ok}<span>${t('agentsStudio.privilege.notWider')}</span>`}</p>
154
+ <ul class="ax-delta-list">${delta.map((row) => html`<li class="${row.escalates ? 'is-wider' : ''}"><span class="ax-delta-field">${t(`agentsStudio.field.${row.field}`)}</span><span class="ax-delta-from">${row.from}</span><span aria-hidden="true">→</span><span class="ax-delta-to">${row.to}</span>${row.escalates ? html`<span class="sx-label ax-wider">${t('agentsStudio.privilege.widerTag')}</span>` : ''}</li>`)}</ul>
155
+ </div>` : ''}
156
+ ${rows.length ? html`<div class="ax-changes">${rows.map((row) => (row.kind === 'instructions'
157
+ ? html`<details class="sx-diff-file ax-change"${open ? html` open` : ''}><summary><span class="sx-diff-path">${t('agentsStudio.field.instructions')}</span><span class="sx-diff-counts"><span class="sx-diff-plus">+${row.added ?? 0}</span> <span class="sx-diff-minus">−${row.removed ?? 0}</span></span></summary>${hunksHTML(t, row.lines)}</details>`
158
+ : html`<div class="ax-change ax-change--value"><span class="ax-change-field">${t(`agentsStudio.field.${row.field}`)}</span>
159
+ ${row.kind === 'list' ? html`<span class="ax-change-list">${row.removed.map((item) => html`<span class="ax-pill ax-pill--del">− ${item}</span>`)}${row.added.map((item) => html`<span class="ax-pill ax-pill--add">+ ${item}</span>`)}</span>`
160
+ : html`<span class="ax-change-from">${row.from}</span><span aria-hidden="true">→</span><span class="ax-change-to">${row.to}</span>`}</div>`))}</div>` : ''}
161
+ </div>`;
162
+ }
163
+
164
+ /** The privilege summary: what this agent may do, with what changed against the last approved revision marked. */
165
+ export function privilegeHTML(t, definition, approved, delta, words) {
166
+ const rows = privilegeSummary(definition, approved, delta, words);
167
+ const icon = { capability: ICONS.lock, permissionPolicy: ICONS.review, tools: ICONS.code, mcpServers: AX_ICONS.server, usesBrowser: AX_ICONS.browser, moreloginProfile: AX_ICONS.browser, usesComputer: AX_ICONS.computer, skills: ICONS.spark, scope: AX_ICONS.global };
168
+ return html`<dl class="ax-priv">${rows.map((row) => html`<div class="ax-priv-row${row.changed ? ' is-changed' : ''}${row.escalates ? ' is-wider' : ''}">
169
+ <dt>${icon[row.field] || ICONS.info}<span>${t(`agentsStudio.field.${row.field}`)}</span></dt>
170
+ <dd><span class="ax-priv-value">${row.text}</span>${row.changed ? html`<span class="ax-priv-was">${t('agentsStudio.privilege.was', { value: row.was })}</span>` : ''}${row.escalates ? html`<span class="sx-label ax-wider">${t('agentsStudio.privilege.widerTag')}</span>` : row.changed ? html`<span class="sx-label ax-changed">${t('agentsStudio.privilege.changedTag')}</span>` : ''}</dd>
171
+ </div>`)}</dl>`;
172
+ }
173
+
174
+ // ── Files ──
175
+
176
+ /** Save text as a file the browser downloads. */
177
+ export function downloadText(fileName, text, type = 'application/json') {
178
+ const url = URL.createObjectURL(new Blob([text], { type }));
179
+ const link = document.createElement('a');
180
+ link.href = url;
181
+ link.download = fileName;
182
+ link.rel = 'noopener';
183
+ document.body.appendChild(link);
184
+ link.click();
185
+ link.remove();
186
+ setTimeout(() => URL.revokeObjectURL(url), 2000);
187
+ }
188
+
189
+ /** The text of a picked file (bounded: an agent file or a bundle is small). */
190
+ export async function readFileText(file, maxBytes = 2 * 1024 * 1024) {
191
+ if (!file) throw new Error('no file');
192
+ if (file.size > maxBytes) { const error = new Error('too large'); error.code = 'file_too_large'; throw error; }
193
+ return file.text();
194
+ }
@@ -0,0 +1,170 @@
1
+ // ═══════════════════════════════════════════
2
+ // SynaBun Neural Interface — Agents Studio: the view machine
3
+ // ═══════════════════════════════════════════
4
+ //
5
+ // Where the window is: one of four places of the rail (Library · Create · Review · Teams), or one agent opened from
6
+ // a place, with its tabs (Edit · Revisions · Runs · Test run). A view is a small plain object; `navigate` is the one
7
+ // function that moves it, so every way in (a rail button, a card, the menu's "Review queue", a link from the
8
+ // Assistant) lands the same way, and what is saved when the window closes is the view itself.
9
+ // No DOM and no imports.
10
+
11
+ export const PLACES = Object.freeze(['library', 'create', 'review', 'teams']);
12
+ export const AGENT_TABS = Object.freeze(['edit', 'revisions', 'runs', 'test']);
13
+ /** The ways into Create (the creator's first step). */
14
+ export const CREATE_MODES = Object.freeze(['blank', 'template', 'copy', 'import', 'describe']);
15
+
16
+ const ID_RE = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/;
17
+ const TEAM_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
18
+
19
+ /** A scope as the registry writes it, or null when the value is not one. */
20
+ export function cleanScope(scope) {
21
+ if (!scope || typeof scope !== 'object') return null;
22
+ if (scope.kind === 'global') return { kind: 'global' };
23
+ if (scope.kind === 'project' && typeof scope.path === 'string' && scope.path && scope.path.length <= 1024) return { kind: 'project', path: scope.path };
24
+ return null;
25
+ }
26
+
27
+ /** One text for an agent of one scope: what a row, a workspace and a saved view are found by. */
28
+ export function agentKeyText(key) {
29
+ const scope = cleanScope(key?.scope) || { kind: 'global' };
30
+ return `${scope.kind === 'project' ? `p:${scope.path}` : 'global'}|${String(key?.id || '')}`;
31
+ }
32
+
33
+ /** The same key from an agent's summary, or null when the id has not its shape. */
34
+ export function keyOf(agent) {
35
+ const id = String(agent?.id || '');
36
+ if (!ID_RE.test(id)) return null;
37
+ return { id, scope: cleanScope(agent?.scope) || { kind: 'global' } };
38
+ }
39
+
40
+ export const DEFAULT_VIEW = Object.freeze({ place: 'library', agent: null, tab: 'edit', create: null, teamId: null, from: 'library' });
41
+
42
+ /**
43
+ * A link into the Studio (`agents:open` with a detail), normalised: an unknown place falls back to the Library, an
44
+ * id is kept only when it has its shape.
45
+ * @param {object} detail `{ view | place, id, scope, tab, create, teamId }`
46
+ */
47
+ export function parseOpen(detail) {
48
+ const d = detail && typeof detail === 'object' ? detail : {};
49
+ const named = typeof d.view === 'string' ? d.view : d.place;
50
+ const id = typeof d.id === 'string' && ID_RE.test(d.id) ? d.id : null;
51
+ const tab = AGENT_TABS.includes(d.tab) ? d.tab : null;
52
+ const create = CREATE_MODES.includes(d.create) ? d.create : null;
53
+ const teamId = typeof d.teamId === 'string' && TEAM_ID_RE.test(d.teamId) ? d.teamId : null;
54
+ let place = PLACES.includes(named) ? named : null;
55
+ // The menu's words for the places: "new" is Create, "queue" is Review.
56
+ if (named === 'new') place = 'create';
57
+ if (named === 'queue') place = 'review';
58
+ if (!place) place = id ? 'agent' : create ? 'create' : teamId ? 'teams' : null;
59
+ if (id && (place === null || place === 'library' || place === 'agent')) place = 'agent';
60
+ return { place, id: place === 'agent' ? id : null, scope: place === 'agent' ? (cleanScope(d.scope) || { kind: 'global' }) : null, tab, create, teamId, explicit: !!place };
61
+ }
62
+
63
+ /** The view a window starts in: what was saved the last time it closed, when it still reads as a view. */
64
+ export function initialView(saved) {
65
+ const s = saved && typeof saved === 'object' ? saved : {};
66
+ const place = PLACES.includes(s.place) || s.place === 'agent' ? s.place : 'library';
67
+ const agent = place === 'agent' && typeof s.agent?.id === 'string' && ID_RE.test(s.agent.id) ? { id: s.agent.id, scope: cleanScope(s.agent.scope) || { kind: 'global' } } : null;
68
+ return {
69
+ place: place === 'agent' && !agent ? 'library' : place,
70
+ agent,
71
+ tab: AGENT_TABS.includes(s.tab) ? s.tab : 'edit',
72
+ create: null,
73
+ teamId: typeof s.teamId === 'string' && TEAM_ID_RE.test(s.teamId) ? s.teamId : null,
74
+ from: PLACES.includes(s.from) ? s.from : 'library',
75
+ };
76
+ }
77
+
78
+ /** What is kept of a view (never the creator's step: a half-made agent is not restored as a place). */
79
+ export function viewToSave(view) {
80
+ return { place: view.place, agent: view.place === 'agent' ? view.agent : null, tab: view.tab, teamId: view.teamId || null, from: view.from };
81
+ }
82
+
83
+ /**
84
+ * Move the view. Actions:
85
+ * { type: 'place', place, create?, teamId? } a place of the rail
86
+ * { type: 'agent', key, tab? } open an agent (from the place the view is in)
87
+ * { type: 'tab', tab } another tab of the open agent
88
+ * { type: 'back' } from an agent to the place it was opened from; from a team to the list
89
+ * { type: 'team', teamId } one team, or the list (null)
90
+ * { type: 'open', want } a parsed link (parseOpen)
91
+ * An action that makes no sense where the view is leaves it as it was (the same object: nothing to draw).
92
+ */
93
+ export function navigate(view, action) {
94
+ const a = action && typeof action === 'object' ? action : {};
95
+ if (a.type === 'place') {
96
+ if (!PLACES.includes(a.place)) return view;
97
+ return { ...view, place: a.place, agent: null, create: a.place === 'create' && CREATE_MODES.includes(a.create) ? a.create : null, teamId: a.place === 'teams' ? (a.teamId && TEAM_ID_RE.test(a.teamId) ? a.teamId : null) : view.teamId, from: a.place };
98
+ }
99
+ if (a.type === 'agent') {
100
+ const key = keyOf(a.key);
101
+ if (!key) return view;
102
+ return { ...view, place: 'agent', agent: key, tab: AGENT_TABS.includes(a.tab) ? a.tab : (view.place === 'agent' && agentKeyText(view.agent) === agentKeyText(key) ? view.tab : 'edit'), create: null, from: view.place === 'agent' ? view.from : (PLACES.includes(view.place) ? view.place : 'library') };
103
+ }
104
+ if (a.type === 'tab') {
105
+ if (view.place !== 'agent' || !AGENT_TABS.includes(a.tab) || a.tab === view.tab) return view;
106
+ return { ...view, tab: a.tab };
107
+ }
108
+ if (a.type === 'team') {
109
+ const teamId = typeof a.teamId === 'string' && TEAM_ID_RE.test(a.teamId) ? a.teamId : null;
110
+ if (view.place === 'teams' && view.teamId === teamId) return view;
111
+ return { ...view, place: 'teams', agent: null, create: null, teamId, from: 'teams' };
112
+ }
113
+ if (a.type === 'back') {
114
+ if (view.place === 'agent') return { ...view, place: PLACES.includes(view.from) ? view.from : 'library', agent: null };
115
+ if (view.place === 'teams' && view.teamId) return { ...view, teamId: null };
116
+ if (view.place === 'create' && view.create) return { ...view, create: null };
117
+ return view;
118
+ }
119
+ if (a.type === 'open') {
120
+ const want = a.want || {};
121
+ if (want.place === 'agent' && want.id) return navigate(view, { type: 'agent', key: { id: want.id, scope: want.scope }, tab: want.tab || undefined });
122
+ if (PLACES.includes(want.place)) return navigate(view, { type: 'place', place: want.place, create: want.create, teamId: want.teamId });
123
+ return view;
124
+ }
125
+ return view;
126
+ }
127
+
128
+ /**
129
+ * The rail: one item per place, the current one marked, a count where a place has one. An open agent keeps the
130
+ * place it was opened from marked. `caps` (the server's capabilities, a Set) hides what the server cannot serve;
131
+ * while it is unknown (null) nothing is hidden.
132
+ * @param {object} view
133
+ * @param {{ total?: number, review?: number, teams?: number|null }} [counts]
134
+ * @param {Set<string>|null} [caps]
135
+ */
136
+ export function railModel(view, counts = {}, caps = null) {
137
+ const current = view.place === 'agent' ? (PLACES.includes(view.from) ? view.from : 'library') : view.place;
138
+ const has = (cap) => !caps || caps.has(cap);
139
+ return PLACES.map((place) => ({
140
+ place,
141
+ current: place === current,
142
+ count: place === 'library' ? (counts.total ?? null) : place === 'review' ? (counts.review || null) : place === 'teams' ? (counts.teams || null) : null,
143
+ hidden: (place === 'review' && !has('reviews')) || (place === 'create' && !has('drafts')),
144
+ })).filter((item) => !item.hidden);
145
+ }
146
+
147
+ /** The tabs of an agent the server can serve (`revisions`, `runs`, `test-run` are capabilities of their own). */
148
+ export function agentTabs(caps = null) {
149
+ const has = (cap) => !caps || caps.has(cap);
150
+ return AGENT_TABS.filter((tab) => tab === 'edit' || (tab === 'revisions' && has('revisions')) || (tab === 'runs' && has('runs')) || (tab === 'test' && has('test-run')));
151
+ }
152
+
153
+ /** The refusals that mean "this caller is not the owner here" (lib/owner-authority.js, lib/page-session.js, the routes). */
154
+ export const REFUSAL_CODES = Object.freeze(['WORKER_BROWSER', 'OWNER_ROUTE', 'GUEST_FORBIDDEN', 'UI_ONLY', 'PAGE_SECRET_REQUIRED', 'PEER_REFUSED', 'PEER_UNAVAILABLE']);
155
+
156
+ /**
157
+ * Why the Studio's first read (GET /capabilities) failed, so the window says the true reason:
158
+ * 'refused' the server answered, and will not serve this caller (SynaBun's automation browser, a guest, a
159
+ * page without the owner's access): restarting changes nothing, and is never suggested
160
+ * 'older' the routes are not on this server (a server from before the Agents system): a restart loads them
161
+ * 'unreachable' no answer at all
162
+ * @param {{ status?: number, code?: string|null, absent?: boolean }|null} error
163
+ */
164
+ export function capsFailure(error) {
165
+ const status = Number(error?.status) || 0;
166
+ if (REFUSAL_CODES.includes(error?.code) || status === 401 || status === 403) return 'refused';
167
+ if (error?.absent || error?.code === 'not_json' || status === 404) return 'older';
168
+ if (!status) return 'unreachable';
169
+ return status === 503 ? 'refused' : 'older';
170
+ }