@desplega.ai/agent-swarm 2.7.6 → 2.7.8

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 (361) hide show
  1. package/dist/{acp-adapter-bp91d37f.js → acp-adapter-vg5hqkvj.js} +6 -5
  2. package/dist/{actions-yj0eeaqh.js → actions-4m1ct4nh.js} +18 -18
  3. package/dist/{amp-adapter-4pg9h34q.js → amp-adapter-txqh7eqj.js} +2 -2
  4. package/dist/{anthropic-messages-x4q6rfq5.js → anthropic-messages-xey2skwx.js} +7 -7
  5. package/dist/{app-909e97cr.js → app-e00m45gn.js} +3 -3
  6. package/dist/{assistant-qdyb5fyy.js → assistant-gd08kr9e.js} +20 -20
  7. package/dist/{azure-openai-responses-s1w5n70z.js → azure-openai-responses-26t7j9ra.js} +5 -5
  8. package/dist/boot-args-schema-tjrkpbvm.js +89 -0
  9. package/dist/{boot-reembed-fk0s9z18.js → boot-reembed-21hbck22.js} +1 -1
  10. package/dist/{boot-reembed-gs1rzrnh.js → boot-reembed-mdxd3wgp.js} +1 -1
  11. package/dist/{boot-scrub-sweep-4qfd4kfx.js → boot-scrub-sweep-qy0zr9t2.js} +3 -3
  12. package/dist/{boot-seeds-yr00k13d.js → boot-seeds-n46eaxdv.js} +4 -4
  13. package/dist/{boxd-vdmfssd9.js → boxd-nv507va8.js} +1 -1
  14. package/dist/{claude-adapter-qta1f1xn.js → claude-adapter-j37w2eds.js} +6 -5
  15. package/dist/{claude-managed-adapter-dvs2xw5n.js → claude-managed-adapter-8jvcma9a.js} +3 -3
  16. package/dist/{claude-managed-setup-sc6j4dm0.js → claude-managed-setup-rzkjmgc1.js} +3 -3
  17. package/dist/{claude-sdk-session-zgrz6yvc.js → claude-sdk-session-4k7w73t0.js} +8290 -8226
  18. package/dist/{cli-w6dt9ged.js → cli-0ykgn1h5.js} +1 -1
  19. package/dist/{cli-89knwags.js → cli-1cxrbkk6.js} +2 -2
  20. package/dist/{cli-drr5v6av.js → cli-269q28a1.js} +4 -2
  21. package/dist/{cli-es6va8jk.js → cli-32m9eda8.js} +60 -53
  22. package/dist/{cli-q0k1w5zd.js → cli-3e4snnzf.js} +1 -1
  23. package/dist/{cli-dxae2yg7.js → cli-4t50yq3j.js} +2 -2
  24. package/dist/{cli-nhrvpaj7.js → cli-5j0m12ns.js} +520 -7
  25. package/dist/{cli-dhar9qay.js → cli-5ja3b75e.js} +2 -2
  26. package/dist/{cli-gdhpcbhf.js → cli-66ww7fer.js} +1 -1
  27. package/dist/{cli-bsn8nhrq.js → cli-6vcp76qk.js} +3 -3
  28. package/dist/{cli-8bc1w0tw.js → cli-7axf41jq.js} +29 -16
  29. package/dist/cli-82j36f2m.js +45 -0
  30. package/dist/{cli-svj5090z.js → cli-84rj785g.js} +5 -5
  31. package/dist/{cli-pd7vagab.js → cli-85gzce7b.js} +5 -5
  32. package/dist/{cli-xnrwazav.js → cli-8h0ayw8c.js} +1 -1
  33. package/dist/cli-8rpcng8j.js +67 -0
  34. package/dist/{cli-shpbx5ee.js → cli-8sdejs1f.js} +1728 -72
  35. package/dist/{cli-yx4kfngt.js → cli-9m8hdawy.js} +30 -17
  36. package/dist/{cli-436532ck.js → cli-ae0dnfee.js} +166 -154
  37. package/dist/{cli-bqt1mptt.js → cli-az48n0nr.js} +4 -4
  38. package/dist/{cli-386tyxxg.js → cli-bb0mmdk8.js} +2 -2
  39. package/dist/{cli-yy3rhsdw.js → cli-bbw9wj9m.js} +8 -8
  40. package/dist/{cli-xds5f77d.js → cli-bshb7jas.js} +2 -2
  41. package/dist/{cli-wp9sp1qb.js → cli-btfsp3mv.js} +3 -3
  42. package/dist/{cli-4zsenjhy.js → cli-c0kqky8y.js} +16 -3
  43. package/dist/{cli-a7v854rf.js → cli-dq8x79v8.js} +264 -13
  44. package/dist/{cli-ftyxyspd.js → cli-eqtfgfr6.js} +1 -1
  45. package/dist/{cli-yn4kxs06.js → cli-eyg1pa00.js} +4 -4
  46. package/dist/{cli-71ptav7x.js → cli-ferkkrg9.js} +1 -1
  47. package/dist/{cli-vpf89f34.js → cli-fmjd0t1y.js} +3 -3
  48. package/dist/{cli-4necwtsv.js → cli-fyhr5h4s.js} +38 -16
  49. package/dist/{cli-xnqgpshy.js → cli-fzachfnf.js} +1 -1
  50. package/dist/{cli-ehq736cn.js → cli-g7s47cc5.js} +4 -4
  51. package/dist/{cli-0qatpy8q.js → cli-ga786dzg.js} +34 -11
  52. package/dist/{cli-bjb3z51z.js → cli-gazw7kpa.js} +2 -2
  53. package/dist/{cli-54t00gt8.js → cli-gvx71kqv.js} +2 -2
  54. package/dist/{cli-c60vetmm.js → cli-jdv6ypxs.js} +1 -1
  55. package/dist/{cli-611a1294.js → cli-k0wwfqbg.js} +18 -1
  56. package/dist/{cli-cm5yqn35.js → cli-kf3pxxdg.js} +1 -0
  57. package/dist/{cli-0at8w34w.js → cli-kyr67fgx.js} +8 -8
  58. package/dist/{cli-vvpx3gsx.js → cli-m0hmeqma.js} +2 -2
  59. package/dist/{cli-he9wchme.js → cli-mkk9rnzz.js} +4 -4
  60. package/dist/{cli-e3r2neck.js → cli-msg9m2ny.js} +7 -5
  61. package/dist/{cli-m48g6p95.js → cli-nbsf8yvn.js} +15 -3
  62. package/dist/{cli-tfyyvzx6.js → cli-njwac61j.js} +5 -0
  63. package/dist/{cli-faxe6thg.js → cli-nn3ysbqk.js} +186 -54
  64. package/dist/{cli-decfb6v8.js → cli-p3vsj0d3.js} +24 -10
  65. package/dist/{cli-ekwks2vs.js → cli-ppjxh6ah.js} +3 -3
  66. package/dist/{cli-aa6yxc7m.js → cli-pz4rk021.js} +1 -1
  67. package/dist/{cli-nwj0ee2w.js → cli-q4ebh7h7.js} +4 -4
  68. package/dist/{cli-75gkpjvw.js → cli-qd57hhhh.js} +2 -2
  69. package/dist/{cli-zbbwez0r.js → cli-rjknb2ae.js} +4 -4
  70. package/dist/{cli-hgaazk69.js → cli-s4ss5g59.js} +5 -5
  71. package/dist/{cli-1h3wcpbw.js → cli-snpj5zbj.js} +2 -2
  72. package/dist/{cli-3ypk9vk1.js → cli-sq4n7af4.js} +1 -1
  73. package/dist/{cli-vfym7wmz.js → cli-ssnjfg5p.js} +5 -5
  74. package/dist/{cli-8snvgs5r.js → cli-t60ajbbp.js} +10 -10
  75. package/dist/{cli-hr2e2fft.js → cli-tpksw2nr.js} +22 -18
  76. package/dist/{cli-k2gzwsj2.js → cli-w4xnbm46.js} +300 -74
  77. package/dist/{cli-p5gp8pcx.js → cli-wemma3jd.js} +8 -7
  78. package/dist/{cli-70r77n04.js → cli-xae4g51r.js} +1 -1
  79. package/dist/{cli-waqbxg08.js → cli-xq9r2wtt.js} +50 -26
  80. package/dist/{cli-zm72anhg.js → cli-xr8908my.js} +11 -11
  81. package/dist/{cli-73jzwksr.js → cli-ycscb2ar.js} +4 -1
  82. package/dist/{cli-kqdg1bsb.js → cli-yndmfxb3.js} +2 -2
  83. package/dist/{cli-0yv5z2pg.js → cli-yqefz277.js} +1 -1
  84. package/dist/{cli-rmmmrjkd.js → cli-z1srzaf6.js} +11 -3
  85. package/dist/{cli-xbbndvjy.js → cli-z75yxkjh.js} +3 -3
  86. package/dist/{cli-jm2vfpfd.js → cli-zkky4t5g.js} +1 -1
  87. package/dist/cli.js +24 -22
  88. package/dist/{cloudflare-workers-ai-system-one-bm60fjm0.js → cloudflare-workers-ai-system-one-ef2a980q.js} +2 -2
  89. package/dist/{codex-adapter-ayd1fb6h.js → codex-adapter-88z6psm4.js} +5 -4
  90. package/dist/{codex-hook-9efm2x1m.js → codex-hook-fac6175r.js} +2 -2
  91. package/dist/{codex-login-y0pmff1c.js → codex-login-74wa4hmq.js} +1 -1
  92. package/dist/{codex-session-runner-jesa32xc.js → codex-session-runner-zwbcwzvx.js} +5 -4
  93. package/dist/{commands-hanewgf2.js → commands-7amxs716.js} +3 -3
  94. package/dist/{controller-dt1n3c1q.js → controller-5rkkc37m.js} +3 -3
  95. package/dist/{controllers-connect-xx8x64n5.js → controllers-connect-m7d4vxxb.js} +19 -19
  96. package/dist/{cursor-adapter-9s4dwwdw.js → cursor-adapter-x1q18693.js} +1 -1
  97. package/dist/{db-9dv0g1ab.js → db-athc68zt.js} +6 -2
  98. package/dist/{db-3vttcbv4.js → db-h2fsfve3.js} +3 -3
  99. package/dist/{dispatcher-tx9hd1sv.js → dispatcher-b1yz2bnn.js} +17 -17
  100. package/dist/{dsh-adapter-007y4ejs.js → dsh-adapter-e33bkxq9.js} +1 -1
  101. package/dist/{e2b-we6hs6q5.js → e2b-fr12yccx.js} +1 -1
  102. package/dist/{e2b-a19d28rz.js → e2b-x6ywzak3.js} +1 -1
  103. package/dist/{easter-egg-3d-rgbrqb8s.js → easter-egg-3d-pv5qnzc8.js} +1 -1
  104. package/dist/{embedding-space-ny1e2940.js → embedding-space-b4txbwrk.js} +6 -6
  105. package/dist/{embeddings-2t386t13.js → embeddings-m6zn6tad.js} +1 -1
  106. package/dist/{execute-pksh0ceh.js → execute-68nwny8m.js} +1 -1
  107. package/dist/{external-channel-phgmhmd7.js → external-channel-gkckmhzh.js} +2 -2
  108. package/dist/{fx-adapter-fy8rr921.js → fx-adapter-m5jbgd5q.js} +7 -6
  109. package/dist/{google-generative-ai-8y3m3k4b.js → google-generative-ai-v94hr7h0.js} +5 -5
  110. package/dist/{google-vertex-w3v98n7b.js → google-vertex-g7vr6cf8.js} +5 -5
  111. package/dist/{grok-adapter-q0abvpaj.js → grok-adapter-csvv7sac.js} +7 -6
  112. package/dist/handlers-8x5gfbzx.js +32 -0
  113. package/dist/{heartbeat-kadyek8p.js → heartbeat-6c2y3267.js} +20 -20
  114. package/dist/{hook-5zs3msf6.js → hook-q5fv0jy2.js} +25 -10
  115. package/dist/{hook-9k551xnj.js → hook-w0q2wcrv.js} +5 -4
  116. package/dist/{http-mhz9vw1f.js → http-bxat8dg3.js} +1242 -250
  117. package/dist/{index-rvr00sg7.js → index-bxrexmfy.js} +1020 -577
  118. package/dist/{index-vdygbq10.js → index-cqhqpgrv.js} +1 -1
  119. package/dist/{index-q361cg2f.js → index-fm0czesf.js} +1 -1
  120. package/dist/index-hpfte8jd.js +33 -0
  121. package/dist/index-ncf7yb5s.js +30 -0
  122. package/dist/index-vte6dyeh.js +37 -0
  123. package/dist/{keepalive-w56f32cg.js → keepalive-qnt21cv0.js} +3 -3
  124. package/dist/lead-4bvftzm6.js +71 -0
  125. package/dist/{maintenance-7mdgxcea.js → maintenance-btdr68y4.js} +1 -1
  126. package/dist/{mistral-conversations-4pmwj1c0.js → mistral-conversations-3gjpdb4b.js} +4 -4
  127. package/dist/{oauth-refresh-sweep-29txy9vk.js → oauth-refresh-sweep-vczabeh4.js} +2 -2
  128. package/dist/{onboard-kpsrkarj.js → onboard-k33ezyq8.js} +3 -3
  129. package/dist/{openai-codex-responses-44j573nm.js → openai-codex-responses-8pbxq9h5.js} +5 -5
  130. package/dist/{openai-completions-a4gee2a8.js → openai-completions-rm00s912.js} +4 -4
  131. package/dist/{openai-decisions-w4qkrcar.js → openai-decisions-8v957r2r.js} +1 -1
  132. package/dist/{openai-responses-rbp6h5kr.js → openai-responses-agxpf96k.js} +5 -5
  133. package/dist/{opencode-adapter-j25vm3rr.js → opencode-adapter-3dst2ka7.js} +5 -4
  134. package/dist/{otel-impl-6kkct7a8.js → otel-impl-13am7a65.js} +4 -4
  135. package/dist/{pi-mono-adapter-exhkzhn2.js → pi-mono-adapter-c53de1gd.js} +16 -9
  136. package/dist/{pricing-refresh-n2x7jh6k.js → pricing-refresh-9fcbnq3f.js} +3 -3
  137. package/dist/{rbac-roles-b5htkjby.js → rbac-roles-66j5h4y5.js} +5 -3
  138. package/dist/{rbac-roles-81ypx6es.js → rbac-roles-gw0p9h3j.js} +2 -2
  139. package/dist/{render-v2-qn6jmpk4.js → render-v2-fg8bmdn4.js} +3 -3
  140. package/dist/{resume-wd30wx23.js → resume-1c8kr3nh.js} +6 -6
  141. package/dist/{runtime-4hsg7h60.js → runtime-tzf9j7tc.js} +1 -1
  142. package/dist/{session-access-5qvfevhk.js → session-access-d0atq10j.js} +7 -5
  143. package/dist/{session-source-backfill-n1czavbr.js → session-source-backfill-0vscqmsa.js} +2 -2
  144. package/dist/{setup-dnb56qy5.js → setup-tvfa7rwe.js} +1 -1
  145. package/dist/{typesafe-system-one-5mavm259.js → typesafe-system-one-0bmqcxfg.js} +2 -2
  146. package/dist/{virtual-modules-76xxv9fs.js → virtual-modules-efxcp740.js} +5 -5
  147. package/dist/{work-objects-4n21tfkm.js → work-objects-ks71xqeb.js} +20 -20
  148. package/dist/worker-e7v2bvm9.js +71 -0
  149. package/dist/{worker-follow-up-77hvzxww.js → worker-follow-up-bfx0h9hg.js} +17 -17
  150. package/openapi.json +300 -27
  151. package/package.json +7 -5
  152. package/src/apps/definition.ts +6 -5
  153. package/src/be/db/model-profiles.ts +1 -1
  154. package/src/be/db/page-theme-tokens.ts +12 -0
  155. package/src/be/db/session-tree.ts +9 -5
  156. package/src/be/db/session-visibility.ts +25 -9
  157. package/src/be/db/tasks/read.ts +20 -7
  158. package/src/be/db/tasks/write.ts +96 -7
  159. package/src/be/db-client.ts +107 -7
  160. package/src/be/db-queries/tracker.ts +4 -2
  161. package/src/be/db.ts +83 -19
  162. package/src/be/migrations/269_pages_design_system.sql +23 -0
  163. package/src/be/migrations/271_subscription_usage_model.sql +30 -0
  164. package/src/be/model-validation.ts +19 -1
  165. package/src/be/rbac-roles.ts +21 -0
  166. package/src/be/runtime-pools/routing.ts +1 -1
  167. package/src/be/scripts/boot-args-schema.ts +95 -0
  168. package/src/be/scripts/extract-schema.ts +15 -10
  169. package/src/be/seed/schedules-seeder.ts +0 -10
  170. package/src/be/seed-scripts/catalog/boot-triage.inline.ts +1 -1
  171. package/src/be/seed-scripts/catalog/boot-triage.ts +1 -1
  172. package/src/be/seed-scripts/catalog/catalog-report.inline.ts +2 -0
  173. package/src/be/seed-scripts/catalog/catalog-report.ts +2 -0
  174. package/src/be/seed-scripts/catalog/get-child-outputs.ts +1 -1
  175. package/src/be/seed-scripts/catalog/memory-eval.ts +2 -0
  176. package/src/be/seed-scripts/catalog/swarm-update-check.ts +150 -0
  177. package/src/be/seed-scripts/catalog/wait-for-task.ts +1 -1
  178. package/src/be/seed-scripts/index.ts +9 -0
  179. package/src/be/seed-skills/bundled-files.generated.json +3 -3
  180. package/src/be/swarm-config-guard.ts +39 -0
  181. package/src/be/task-auto-title-listener.ts +127 -0
  182. package/src/be/users.ts +6 -4
  183. package/src/commands/claude-managed-setup.ts +1 -1
  184. package/src/commands/onboard/agent-fs-version.ts +1 -1
  185. package/src/commands/profile-sync.ts +151 -16
  186. package/src/commands/runner.ts +41 -16
  187. package/src/extensions/contract-types.generated.ts +1 -1
  188. package/src/hooks/hook.ts +20 -9
  189. package/src/http/agents.ts +7 -1
  190. package/src/http/approval-requests.ts +30 -6
  191. package/src/http/codex-oauth-device.ts +2 -2
  192. package/src/http/index.ts +11 -0
  193. package/src/http/mcp-oauth.ts +6 -0
  194. package/src/http/mcp-servers.ts +8 -0
  195. package/src/http/models-catalog.ts +1 -1
  196. package/src/http/pages-public.ts +131 -130
  197. package/src/http/pages.ts +94 -21
  198. package/src/http/poll.ts +3 -4
  199. package/src/http/prompt-templates.ts +1 -1
  200. package/src/http/schedules.ts +4 -0
  201. package/src/http/script-runs.ts +6 -1
  202. package/src/http/session-access.ts +61 -6
  203. package/src/http/sessions.ts +23 -7
  204. package/src/http/tasks.ts +53 -9
  205. package/src/http/users.ts +30 -1
  206. package/src/http/utils.ts +2 -1
  207. package/src/http/workflows.ts +11 -7
  208. package/src/pages/browser-sdk.ts +48 -21
  209. package/src/pages/color-literals.ts +115 -0
  210. package/src/pages/page-head.ts +766 -0
  211. package/src/pages/version.ts +3 -0
  212. package/src/prompts/session-templates.ts +1 -0
  213. package/src/providers/acp-targets.ts +1 -1
  214. package/src/providers/amp-adapter.ts +1 -1
  215. package/src/providers/codex-adapter.ts +10 -2
  216. package/src/providers/codex-app-server.ts +27 -1
  217. package/src/providers/codex-oauth/device.ts +49 -15
  218. package/src/providers/codex-oauth/flow.ts +2 -1
  219. package/src/providers/pi-mono-adapter.ts +8 -0
  220. package/src/providers/pi-mono-extension.ts +30 -15
  221. package/src/providers/pricing-sources.md +16 -1
  222. package/src/providers/swarm-events-shared.ts +15 -2
  223. package/src/rbac/legacy-policy.ts +1 -0
  224. package/src/rbac/permissions.ts +5 -0
  225. package/src/scheduler/deferred-task-waits.ts +9 -4
  226. package/src/scripts-runtime/extract-args-schema.ts +3 -1
  227. package/src/scripts-runtime/swarm-sdk.ts +1 -1
  228. package/src/scripts-runtime/types/swarm-extension.d.ts +29 -28
  229. package/src/server-user.ts +1 -1
  230. package/src/slack/ack.ts +48 -12
  231. package/src/slack/blocks.ts +1 -0
  232. package/src/slack/reaction-shortcode.ts +8 -2
  233. package/src/slack/render-v2.ts +30 -3
  234. package/src/slack/task-output.ts +4 -1
  235. package/src/slack/thread-buffer.ts +2 -2
  236. package/src/tasks/follow-up-gate.ts +318 -0
  237. package/src/tasks/task-skip.ts +28 -0
  238. package/src/tasks/terminal-result-guard.ts +3 -2
  239. package/src/tasks/worker-follow-up.ts +21 -1
  240. package/src/telemetry.ts +28 -1
  241. package/src/tests/agentmail-inbox-mapping.test.ts +73 -0
  242. package/src/tests/approval-requests.test.ts +58 -0
  243. package/src/tests/claude-managed-setup.test.ts +36 -0
  244. package/src/tests/codex-adapter.test.ts +2 -2
  245. package/src/tests/codex-app-server.test.ts +59 -0
  246. package/src/tests/codex-gateway-route.test.ts +50 -1
  247. package/src/tests/codex-oauth-device.test.ts +60 -0
  248. package/src/tests/codex-swarm-events.test.ts +43 -1
  249. package/src/tests/context-window.test.ts +14 -0
  250. package/src/tests/create-page-tool.test.ts +501 -0
  251. package/src/tests/db-client-busy-retry.test.ts +81 -0
  252. package/src/tests/db-queries-tracker.test.ts +2 -1
  253. package/src/tests/db-task-read-contract.test.ts +2 -0
  254. package/src/tests/db-task-write-contract.test.ts +4 -0
  255. package/src/tests/db-tasks-read.test.ts +21 -0
  256. package/src/tests/deferred-task-wake.test.ts +7 -2
  257. package/src/tests/e2e-coverage-contract.test.ts +235 -0
  258. package/src/tests/empty-output-schema.test.ts +160 -0
  259. package/src/tests/env-flag.test.ts +1 -0
  260. package/src/tests/explicit-model-validation.test.ts +14 -0
  261. package/src/tests/fixtures/pages/head-v1.html +56 -0
  262. package/src/tests/follow-up-gate-shadow.test.ts +513 -0
  263. package/src/tests/http-api-integration.test.ts +2 -2
  264. package/src/tests/http-users.test.ts +63 -0
  265. package/src/tests/identity-field-budget.test.ts +1 -1
  266. package/src/tests/internal-ai/credentials.test.ts +62 -0
  267. package/src/tests/internal-ai/task-title.test.ts +283 -0
  268. package/src/tests/mcp-input-caps.test.ts +4 -3
  269. package/src/tests/merge-gate-detect-changes.test.ts +167 -0
  270. package/src/tests/page-proxy.test.ts +1 -1
  271. package/src/tests/page-session-dev-cookie.test.ts +188 -0
  272. package/src/tests/pages-authed-mode.test.ts +13 -2
  273. package/src/tests/pages-frame-ancestors.test.ts +28 -1
  274. package/src/tests/pages-head-v2.test.ts +534 -0
  275. package/src/tests/pages-http.test.ts +330 -0
  276. package/src/tests/pages-public-html.test.ts +43 -0
  277. package/src/tests/pages-storage.test.ts +182 -0
  278. package/src/tests/pages-versioning.test.ts +72 -0
  279. package/src/tests/pi-mono-adapter.test.ts +39 -4
  280. package/src/tests/profile-sync-stale-writeback.test.ts +334 -0
  281. package/src/tests/profile-sync.test.ts +11 -15
  282. package/src/tests/rbac-engine.test.ts +1 -0
  283. package/src/tests/runner-context-usage.test.ts +119 -0
  284. package/src/tests/scheduled-task-required-params-migration.test.ts +3 -1
  285. package/src/tests/script-connections.test.ts +4 -0
  286. package/src/tests/script-executor-quickjs.test.ts +2 -0
  287. package/src/tests/script-runs-http.test.ts +57 -0
  288. package/src/tests/scripts-boot-args-schema.test.ts +181 -0
  289. package/src/tests/scripts-runtime.test.ts +24 -0
  290. package/src/tests/sdk-store-progress-skipped.test.ts +155 -0
  291. package/src/tests/seed-registry.test.ts +28 -6
  292. package/src/tests/seed-schedules.test.ts +61 -8
  293. package/src/tests/seed-scripts.test.ts +142 -2
  294. package/src/tests/session-costs-model-key-normalize.test.ts +59 -0
  295. package/src/tests/session-sharing.test.ts +212 -2
  296. package/src/tests/slack-reaction-config.test.ts +1 -0
  297. package/src/tests/slack-render-v2.test.ts +73 -0
  298. package/src/tests/slack-skip-reaction.test.ts +203 -0
  299. package/src/tests/store-progress-skipped.test.ts +159 -0
  300. package/src/tests/subscription-usage-migration.test.ts +57 -0
  301. package/src/tests/swarm-config-reserved-keys.test.ts +3 -0
  302. package/src/tests/swarm-diff.test.ts +121 -2
  303. package/src/tests/task-auto-title-config-guard.test.ts +37 -0
  304. package/src/tests/task-auto-title-listener.test.ts +165 -0
  305. package/src/tests/telemetry-endpoint-override.test.ts +27 -0
  306. package/src/tests/theme-import.test.ts +758 -0
  307. package/src/tests/themes-page-theme.test.ts +155 -0
  308. package/src/tests/themes-presets.test.ts +172 -0
  309. package/src/tests/trigger-claiming.test.ts +2 -0
  310. package/src/tests/workflow-script-principal.test.ts +2 -1
  311. package/src/tests/workflow-system-one-extraction.test.ts +29 -0
  312. package/src/themes/classics.ts +949 -0
  313. package/src/themes/import.ts +420 -0
  314. package/src/themes/page-fields.ts +40 -0
  315. package/src/themes/page-theme.ts +102 -0
  316. package/src/themes/presets.ts +561 -0
  317. package/src/themes/tokens.ts +218 -0
  318. package/src/tools/app-upsert.ts +1 -1
  319. package/src/tools/create-channel.ts +1 -1
  320. package/src/tools/create-page.ts +118 -12
  321. package/src/tools/defer-task.ts +1 -1
  322. package/src/tools/register-agentmail-inbox.ts +5 -0
  323. package/src/tools/repos/update-repo.ts +1 -1
  324. package/src/tools/request-human-input.ts +1 -1
  325. package/src/tools/send-task.ts +1 -1
  326. package/src/tools/store-progress.ts +39 -8
  327. package/src/tools/tracker/tracker-unlink.ts +2 -1
  328. package/src/tools/utils.ts +33 -0
  329. package/src/tools/workflows/retry-workflow-run.ts +3 -0
  330. package/src/types.ts +56 -5
  331. package/src/utils/constants.ts +19 -0
  332. package/src/utils/context-window.ts +6 -1
  333. package/src/utils/follow-up-gate-schedule-ids.ts +13 -0
  334. package/src/utils/internal-ai/credentials.ts +146 -93
  335. package/src/utils/internal-ai/index.ts +10 -0
  336. package/src/utils/internal-ai/models.ts +18 -0
  337. package/src/utils/internal-ai/task-title.ts +282 -0
  338. package/src/utils/output-schema.ts +23 -0
  339. package/src/utils/page-session.ts +37 -0
  340. package/src/workflows/executors/system-one-providers.ts +25 -6
  341. package/src/workflows/recovery.ts +8 -4
  342. package/src/workflows/resume.ts +19 -0
  343. package/templates/schedules/daily-status-report/content.md +88 -2
  344. package/templates/schedules/daily-swarm-update-check/content.md +16 -40
  345. package/templates/skills/apps/SKILL.md +1 -1
  346. package/templates/skills/apps/content.md +1 -1
  347. package/templates/skills/heartbeat-runbook/content.md +1 -1
  348. package/templates/skills/pages/config.json +1 -1
  349. package/templates/skills/pages/content.md +539 -86
  350. package/templates/skills/pages/files/examples/annotated-pr.html +21 -12
  351. package/templates/skills/pages/files/examples/multiplayer-board.html +41 -41
  352. package/templates/skills/pages/files/examples/report-page.html +125 -124
  353. package/dist/cli-2pnswgh8.js +0 -189
  354. package/dist/handlers-by3sfxyx.js +0 -32
  355. package/dist/index-4f2pvxae.js +0 -37
  356. package/dist/index-98gz7tmp.js +0 -30
  357. package/dist/index-k08z2cak.js +0 -33
  358. package/dist/lead-enq35nqp.js +0 -70
  359. package/dist/worker-gg1576j3.js +0 -70
  360. package/templates/schedules/daily-workflow-health-audit/config.json +0 -19
  361. package/templates/schedules/daily-workflow-health-audit/content.md +0 -191
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  bedrockProviderModule
3
- } from "./cli-ehq736cn.js";
3
+ } from "./cli-g7s47cc5.js";
4
4
  import {
5
5
  chatThreadOfContextKey,
6
6
  agentContextKey,
@@ -248,9 +248,11 @@ import {
248
248
  updateTaskClaudeSessionId2,
249
249
  recordTaskProviderIfUnset2,
250
250
  updateTaskTitle2,
251
+ setTaskTitleIfUnset2,
251
252
  completeTask2,
252
253
  failTask2,
253
254
  cancelTask2,
255
+ skipTask2,
254
256
  supersedeTask2,
255
257
  settleSupersededTaskDependents2,
256
258
  backfillSupersedeTaskResumeTaskId2,
@@ -259,6 +261,7 @@ import {
259
261
  getPausedTasksForAgent2,
260
262
  resetOrphanedInProgressTasksForAgent2,
261
263
  updateTaskProgress2,
264
+ init_write,
262
265
  IdempotencyKeyTakenError,
263
266
  workflowRequestFingerprint,
264
267
  assertWorkflowIdempotencyKeyUnused,
@@ -297,7 +300,6 @@ import {
297
300
  getUnassignedTaskIdsForAgent2,
298
301
  updateAgentProfile2,
299
302
  updateAgentName2,
300
- getInboxSummary2,
301
303
  claimMentions2,
302
304
  createSessionLogs2,
303
305
  getSessionLogsByTaskId2,
@@ -477,7 +479,7 @@ import {
477
479
  countScriptRunJournalSteps2,
478
480
  countScriptRunJournalAgentTaskSteps2,
479
481
  init_db4
480
- } from "./cli-k2gzwsj2.js";
482
+ } from "./cli-w4xnbm46.js";
481
483
  import {
482
484
  PRIMARY_ROLE_NAMES2,
483
485
  getUserGrant2,
@@ -488,8 +490,8 @@ import {
488
490
  assertNotLastAdmin2,
489
491
  setUserRoles2,
490
492
  init_rbac_roles
491
- } from "./cli-rmmmrjkd.js";
492
- import"./cli-zbbwez0r.js";
493
+ } from "./cli-z1srzaf6.js";
494
+ import"./cli-rjknb2ae.js";
493
495
  import {
494
496
  upsertModelCatalogOverlay,
495
497
  deleteModelCatalogOverlay,
@@ -497,12 +499,12 @@ import {
497
499
  init_model_catalog_store,
498
500
  requestModelCatalogRefresh2,
499
501
  init_pricing_refresh
500
- } from "./cli-89knwags.js";
502
+ } from "./cli-1cxrbkk6.js";
501
503
  import {
502
504
  workflowEventBus2,
503
505
  init_event_bus
504
506
  } from "./cli-wx3rhnm0.js";
505
- import"./cli-w6dt9ged.js";
507
+ import"./cli-0ykgn1h5.js";
506
508
  import {
507
509
  require_dist4,
508
510
  getSlackConnectionState,
@@ -533,12 +535,12 @@ import {
533
535
  startSlackApp2,
534
536
  stopSlackApp2,
535
537
  init_app3
536
- } from "./cli-waqbxg08.js";
538
+ } from "./cli-xq9r2wtt.js";
537
539
  import {
538
540
  retryFailedRun2,
539
541
  cancelWorkflowRun2,
540
542
  init_resume
541
- } from "./cli-m48g6p95.js";
543
+ } from "./cli-nbsf8yvn.js";
542
544
  import {
543
545
  DEFAULT_NEGOTIATED_PROTOCOL_VERSION,
544
546
  SUPPORTED_PROTOCOL_VERSIONS,
@@ -626,6 +628,9 @@ import {
626
628
  hasKvViewArgs,
627
629
  resolveKvView,
628
630
  init_kv_view,
631
+ COLOR_LITERAL_THRESHOLD,
632
+ countColorLiterals,
633
+ init_color_literals,
629
634
  toolErr,
630
635
  createToolRegistrar,
631
636
  init_utils,
@@ -766,10 +771,13 @@ import {
766
771
  init_app2,
767
772
  init_linear,
768
773
  init_slack,
774
+ verifyPageSession,
775
+ LEGACY_PAGE_SESSION_COOKIE,
769
776
  isCookieSafePageId,
770
777
  extractPageSession,
771
778
  extractLegacyPageSession,
772
779
  extractAndVerifyCookie,
780
+ isLocalDevPageRequest,
773
781
  pageSessionSetCookies,
774
782
  init_page_session,
775
783
  resolveHttpRequestAuth,
@@ -817,6 +825,12 @@ import {
817
825
  init_page_versions,
818
826
  snapshotPage,
819
827
  init_version3,
828
+ DEFAULT_THEME_ID,
829
+ THEME_PRESET_IDS,
830
+ getThemePreset,
831
+ init_presets,
832
+ readThemeFields,
833
+ init_page_fields,
820
834
  assertOAuthAppUrlsSafe,
821
835
  assertOAuthEgressUrlSafe,
822
836
  init_app_validation,
@@ -824,7 +838,7 @@ import {
824
838
  listOAuthPresetIds,
825
839
  getOAuthPreset,
826
840
  hydrateOAuthAppFromPreset,
827
- init_presets,
841
+ init_presets2,
828
842
  scopedResourceScopeIdSchema,
829
843
  resolveScopedResourceId,
830
844
  init_scoped_resource,
@@ -928,6 +942,9 @@ import {
928
942
  steerTaskOutputSchema,
929
943
  steerTaskHandler,
930
944
  init_steer_task,
945
+ skipReasonFrom,
946
+ finalizeSkippedTaskReaction,
947
+ init_task_skip,
931
948
  canClaim,
932
949
  init_budget_admission,
933
950
  emitBudgetRefusalSideEffects,
@@ -947,7 +964,7 @@ import {
947
964
  getEnabledCapabilities,
948
965
  createServer,
949
966
  init_server
950
- } from "./cli-shpbx5ee.js";
967
+ } from "./cli-8sdejs1f.js";
951
968
  import {
952
969
  FilesError,
953
970
  normalizeFilesError,
@@ -979,7 +996,7 @@ import {
979
996
  resolvePoolDelivery2,
980
997
  createPoolAgent2,
981
998
  init_db2
982
- } from "./cli-yn4kxs06.js";
999
+ } from "./cli-eyg1pa00.js";
983
1000
  import {
984
1001
  duplicateGuardedQueryKey,
985
1002
  warnIfCorsAllowsAnyOrigin,
@@ -1017,6 +1034,7 @@ import {
1017
1034
  resolveHttpFavoriteOwner,
1018
1035
  init_favorite_owner,
1019
1036
  resolveSessionActor2,
1037
+ withReadAll2,
1020
1038
  sessionAccessFor2,
1021
1039
  SESSION_READ_DENIED2,
1022
1040
  canReadSession2,
@@ -1033,7 +1051,7 @@ import {
1033
1051
  describeRequestRoute,
1034
1052
  route,
1035
1053
  init_route_def
1036
- } from "./cli-4necwtsv.js";
1054
+ } from "./cli-fyhr5h4s.js";
1037
1055
  import {
1038
1056
  startPoolRouting,
1039
1057
  stopPoolRouting,
@@ -1046,13 +1064,17 @@ import {
1046
1064
  checkHeartbeatChecklist2,
1047
1065
  runHeartbeatSweep2,
1048
1066
  stopHeartbeat2
1049
- } from "./cli-zm72anhg.js";
1050
- import"./cli-xnrwazav.js";
1067
+ } from "./cli-xr8908my.js";
1068
+ import"./cli-8h0ayw8c.js";
1051
1069
  import {
1052
1070
  runtimeSupervisorStatus,
1053
1071
  startRuntimeSupervisor,
1054
1072
  stopRuntimeSupervisor
1055
- } from "./cli-8snvgs5r.js";
1073
+ } from "./cli-t60ajbbp.js";
1074
+ import {
1075
+ TASK_TITLE_TIMEOUT_MS,
1076
+ generateTaskTitle
1077
+ } from "./cli-nn3ysbqk.js";
1056
1078
  import"./cli-ns59dc6r.js";
1057
1079
  import {
1058
1080
  ACP_TARGET_IDS
@@ -1073,11 +1095,11 @@ import {
1073
1095
  isUnknownModelError,
1074
1096
  checkProviderPoolKey,
1075
1097
  writeSkillsToFilesystem
1076
- } from "./cli-bjb3z51z.js";
1098
+ } from "./cli-gazw7kpa.js";
1077
1099
  import {
1078
1100
  inviteEmailToSharedOrg,
1079
1101
  ensureAgentFsCredentialsForAgent
1080
- } from "./cli-xds5f77d.js";
1102
+ } from "./cli-bshb7jas.js";
1081
1103
  import {
1082
1104
  Anthropic
1083
1105
  } from "./cli-318r69gq.js";
@@ -1093,7 +1115,7 @@ import {
1093
1115
  ampBillsCacheWrites,
1094
1116
  resolveAmpModel,
1095
1117
  init_amp_models
1096
- } from "./cli-q0k1w5zd.js";
1118
+ } from "./cli-3e4snnzf.js";
1097
1119
  import {
1098
1120
  RATING_MODEL_MAX_LENGTH,
1099
1121
  REFERENCES_SOURCE_MAX_LENGTH,
@@ -1103,7 +1125,7 @@ import {
1103
1125
  import {
1104
1126
  normalizeModelKey,
1105
1127
  init_pricing_normalize
1106
- } from "./cli-c60vetmm.js";
1128
+ } from "./cli-jdv6ypxs.js";
1107
1129
  import {
1108
1130
  require_dist2,
1109
1131
  getMcpOAuthToken,
@@ -1192,7 +1214,7 @@ import {
1192
1214
  init_typecheck,
1193
1215
  parseSkillContent,
1194
1216
  init_skill_parser
1195
- } from "./cli-hr2e2fft.js";
1217
+ } from "./cli-tpksw2nr.js";
1196
1218
  import {
1197
1219
  signalProcessGroup,
1198
1220
  detachedProcessGroup,
@@ -1209,7 +1231,7 @@ import {
1209
1231
  forceRefreshAuthorizationOrThrow,
1210
1232
  forceRefreshTokenOrThrow,
1211
1233
  init_ensure_token
1212
- } from "./cli-xnqgpshy.js";
1234
+ } from "./cli-fzachfnf.js";
1213
1235
  import {
1214
1236
  automationIntegrationFixUrl,
1215
1237
  preflightAutomation,
@@ -1253,7 +1275,7 @@ import {
1253
1275
  definitionNodeIds,
1254
1276
  validateDefinition,
1255
1277
  init_definition2
1256
- } from "./cli-8bc1w0tw.js";
1278
+ } from "./cli-7axf41jq.js";
1257
1279
  import {
1258
1280
  _fetchHolder,
1259
1281
  CLIENT_ID,
@@ -1269,7 +1291,7 @@ import {
1269
1291
  loadAllCodexOAuthSlots,
1270
1292
  getValidCodexOAuth,
1271
1293
  init_storage
1272
- } from "./cli-75gkpjvw.js";
1294
+ } from "./cli-qd57hhhh.js";
1273
1295
  import {
1274
1296
  isMultiRuntimeEnabled,
1275
1297
  init_multi_runtime2
@@ -1277,7 +1299,7 @@ import {
1277
1299
  import {
1278
1300
  require_content_type
1279
1301
  } from "./cli-yjdgea32.js";
1280
- import"./cli-gdhpcbhf.js";
1302
+ import"./cli-66ww7fer.js";
1281
1303
  import {
1282
1304
  isInvalidClientError,
1283
1305
  publicEndpointSsrfOptions,
@@ -1295,11 +1317,11 @@ import {
1295
1317
  revokeMcpToken,
1296
1318
  computeExpiresAt,
1297
1319
  init_mcp_wrapper
1298
- } from "./cli-hgaazk69.js";
1320
+ } from "./cli-s4ss5g59.js";
1299
1321
  import {
1300
1322
  createRuntimeProvider,
1301
1323
  init_runtime_providers
1302
- } from "./cli-kqdg1bsb.js";
1324
+ } from "./cli-yndmfxb3.js";
1303
1325
  import {
1304
1326
  registerSessionTokenConnection,
1305
1327
  init_session_token_connections,
@@ -1326,12 +1348,12 @@ import {
1326
1348
  revokeAgentTokens,
1327
1349
  fingerprintApiKey,
1328
1350
  init_users
1329
- } from "./cli-drr5v6av.js";
1351
+ } from "./cli-269q28a1.js";
1330
1352
  import"./cli-v41kn3cd.js";
1331
1353
  import {
1332
1354
  setBedrockProviderModule,
1333
1355
  init_bedrock_converse_stream_lazy
1334
- } from "./cli-aa6yxc7m.js";
1356
+ } from "./cli-pz4rk021.js";
1335
1357
  import {
1336
1358
  import_websocket,
1337
1359
  import_websocket_server,
@@ -1345,7 +1367,7 @@ import {
1345
1367
  clearAuditSink,
1346
1368
  can,
1347
1369
  init_rbac
1348
- } from "./cli-tfyyvzx6.js";
1370
+ } from "./cli-njwac61j.js";
1349
1371
  import {
1350
1372
  ASSET_KEY_MAX_LENGTH,
1351
1373
  normalizeAssetKey,
@@ -1354,6 +1376,10 @@ import {
1354
1376
  init_key,
1355
1377
  isSafeBundlePath,
1356
1378
  init_bundle_path,
1379
+ PAGE_THEME_SHARED_TOKENS,
1380
+ PAGE_THEME_TOKENS,
1381
+ HIVE_PAGE_TOKENS,
1382
+ init_tokens2,
1357
1383
  init_zod_openapi,
1358
1384
  AssetKeySchema,
1359
1385
  AssetEntityTypeSchema,
@@ -1444,6 +1470,7 @@ import {
1444
1470
  WorkflowVersionSchema,
1445
1471
  PageContentTypeSchema,
1446
1472
  PageAuthModeSchema,
1473
+ PageThemeTokensInputSchema,
1447
1474
  PageSchema,
1448
1475
  PageVersionSchema,
1449
1476
  MetricWidgetSchema,
@@ -1498,7 +1525,7 @@ import {
1498
1525
  KvKeySchema,
1499
1526
  KvEntrySchema,
1500
1527
  init_types4
1501
- } from "./cli-nhrvpaj7.js";
1528
+ } from "./cli-5j0m12ns.js";
1502
1529
  import {
1503
1530
  CODEX_AUTH_FAILURE_BENCH_THRESHOLD,
1504
1531
  CODEX_AUTH_WATCH_NAMESPACE,
@@ -1509,7 +1536,7 @@ import {
1509
1536
  IDENTITY_FIELD_BUDGETS,
1510
1537
  IdentityFieldBudgetError,
1511
1538
  init_identity_field_budget
1512
- } from "./cli-a7v854rf.js";
1539
+ } from "./cli-dq8x79v8.js";
1513
1540
  import {
1514
1541
  getSlackConfiguration,
1515
1542
  init_config4
@@ -1546,7 +1573,7 @@ import {
1546
1573
  resolveTemplate,
1547
1574
  init_resolver,
1548
1575
  init_session_templates
1549
- } from "./cli-cm5yqn35.js";
1576
+ } from "./cli-kf3pxxdg.js";
1550
1577
  import {
1551
1578
  init_zod
1552
1579
  } from "./cli-k5671be5.js";
@@ -1575,14 +1602,10 @@ import {
1575
1602
  ZodIssueCode,
1576
1603
  exports_coerce
1577
1604
  } from "./cli-agfm16v9.js";
1578
- import {
1579
- getNodeEnv,
1580
- init_node_env
1581
- } from "./cli-rgeadyvq.js";
1582
1605
  import {
1583
1606
  init_package,
1584
1607
  package_default
1585
- } from "./cli-e3r2neck.js";
1608
+ } from "./cli-msg9m2ny.js";
1586
1609
  import {
1587
1610
  realtimeBus,
1588
1611
  init_bus
@@ -1592,13 +1615,14 @@ import {
1592
1615
  DEFAULT_APP_URL,
1593
1616
  getConfiguredAppUrls,
1594
1617
  getAppUrl,
1618
+ getLocalDevAppOrigins,
1595
1619
  getMcpBaseUrl,
1596
1620
  getPublicMcpBaseUrl,
1597
1621
  agentFsFileRoute,
1598
1622
  isCombEnabled,
1599
1623
  isAgentFsProxyEnabled,
1600
1624
  init_constants3
1601
- } from "./cli-611a1294.js";
1625
+ } from "./cli-k0wwfqbg.js";
1602
1626
  import {
1603
1627
  parseEnvFlag,
1604
1628
  isEnvFlagEnabled,
@@ -2532,6 +2556,88 @@ async function seedLegacyCapabilitiesConfig() {
2532
2556
  return { seeded: true, added: [...added] };
2533
2557
  }
2534
2558
 
2559
+ // src/be/task-auto-title-listener.ts
2560
+ init_api_key();
2561
+ init_constants3();
2562
+ init_env_flag();
2563
+ init_secret_scrubber();
2564
+ init_event_bus();
2565
+ init_read();
2566
+ init_write();
2567
+ var TASK_AUTO_TITLE_CONCURRENCY = 3;
2568
+ function isTaskAutoTitleEnabled(env = process.env) {
2569
+ return parseEnvFlag(env.TASK_AUTO_TITLE_ENABLED, true);
2570
+ }
2571
+ function startTaskAutoTitleListener(options = {}) {
2572
+ const env = options.env ?? process.env;
2573
+ const generate = options.generate ?? generateTaskTitle;
2574
+ const queue = [];
2575
+ let active = 0;
2576
+ let idleWaiters = [];
2577
+ const settleIdle = () => {
2578
+ if (active > 0 || queue.length > 0)
2579
+ return;
2580
+ const waiters = idleWaiters;
2581
+ idleWaiters = [];
2582
+ for (const resolve of waiters)
2583
+ resolve();
2584
+ };
2585
+ const pump = () => {
2586
+ while (active < TASK_AUTO_TITLE_CONCURRENCY) {
2587
+ const taskId = queue.shift();
2588
+ if (!taskId)
2589
+ break;
2590
+ active++;
2591
+ titleTask(taskId, env, generate).catch((error) => console.error("[task-title] Failed:", scrubSecrets(String(error)))).finally(() => {
2592
+ active--;
2593
+ pump();
2594
+ settleIdle();
2595
+ });
2596
+ }
2597
+ };
2598
+ const onTaskCreated = (data) => {
2599
+ if (!isTaskAutoTitleEnabled(env))
2600
+ return;
2601
+ const taskId = data.taskId;
2602
+ if (typeof taskId !== "string" || !taskId)
2603
+ return;
2604
+ queue.push(taskId);
2605
+ pump();
2606
+ };
2607
+ workflowEventBus2.on("task.created", onTaskCreated);
2608
+ return {
2609
+ stop: () => workflowEventBus2.off("task.created", onTaskCreated),
2610
+ idle: () => new Promise((resolve) => {
2611
+ idleWaiters.push(resolve);
2612
+ settleIdle();
2613
+ })
2614
+ };
2615
+ }
2616
+ async function titleTask(taskId, env, generate) {
2617
+ const task = await getTaskById2(taskId);
2618
+ if (!task || task.title)
2619
+ return;
2620
+ const shortId = taskId.slice(0, 8);
2621
+ const startedAt = Date.now();
2622
+ const result = await generate({
2623
+ task: task.task,
2624
+ env,
2625
+ apiUrl: getMcpBaseUrl(),
2626
+ apiKey: getApiKey(),
2627
+ callerTag: `task-title:${task.source}`,
2628
+ signal: AbortSignal.timeout(TASK_TITLE_TIMEOUT_MS)
2629
+ });
2630
+ if (!result.ok) {
2631
+ if (result.reason !== "short-task") {
2632
+ console.log(`[task-title] ${shortId}: no title (${result.reason})`);
2633
+ }
2634
+ return;
2635
+ }
2636
+ const updated = await setTaskTitleIfUnset2(taskId, result.title);
2637
+ const elapsed = Date.now() - startedAt;
2638
+ console.log(scrubSecrets(`[task-title] ${shortId}: "${result.title}" via ${result.model} in ${elapsed}ms${updated ? "" : " (kept the existing title)"}`));
2639
+ }
2640
+
2535
2641
  // src/http/index.ts
2536
2642
  init_telemetry_enable();
2537
2643
 
@@ -5307,7 +5413,7 @@ var updateAgentProfileRoute = route({
5307
5413
  profileSyncRejection: ProfileSyncRejectionSchema.optional()
5308
5414
  })
5309
5415
  },
5310
- 404: { description: "Agent not found" }
5416
+ 404: { description: "Agent not found, or changedByAgentId names no agent" }
5311
5417
  }
5312
5418
  });
5313
5419
  var updateAgentActivityRoute = route({
@@ -5622,6 +5728,10 @@ async function handleAgentsRest(req, res, pathSegments, queryParams, myAgentId)
5622
5728
  jsonError(res, "At least one field (role, description, capabilities, claudeMd, soulMd, identityMd, setupScript, toolsMd, heartbeatMd, avatar, or slackIcon) must be provided", 400);
5623
5729
  return true;
5624
5730
  }
5731
+ if (body.changedByAgentId && !await getAgentById2(body.changedByAgentId)) {
5732
+ jsonError(res, "changed_by_agent_not_found", 404);
5733
+ return true;
5734
+ }
5625
5735
  const validChangeSources = ["self_edit", "lead_coaching", "api", "system", "session_sync"];
5626
5736
  const versionMeta = body.changeSource || body.changedByAgentId || body.changeReason ? {
5627
5737
  changeSource: validChangeSources.includes(body.changeSource ?? "") ? body.changeSource : undefined,
@@ -7715,7 +7825,10 @@ var QuestionSchema = object2({
7715
7825
  defaultValue: boolean().optional(),
7716
7826
  config: ConfigQuestionSettingsSchema.optional().describe("Config question settings. Answers are written to swarm_config and replaced by a result that never holds a secret value.")
7717
7827
  });
7718
- var QuestionInputSchema = QuestionSchema.extend({ label: string2().optional() });
7828
+ var QuestionInputSchema = QuestionSchema.extend({
7829
+ label: string2().optional(),
7830
+ required: boolean().default(true)
7831
+ });
7719
7832
  var ApproversSchema = object2({
7720
7833
  users: array2(string2()).optional(),
7721
7834
  roles: array2(string2()).optional(),
@@ -7861,8 +7974,18 @@ function hasRequiredResponse(question, response) {
7861
7974
  }
7862
7975
  }
7863
7976
  }
7977
+ function isUnanswered(response) {
7978
+ return response === undefined || response === null || typeof response === "string" && response.trim() === "" || Array.isArray(response) && response.length === 0;
7979
+ }
7864
7980
  function missingRequiredResponseIds(questions, responses) {
7865
- return questions.filter((question) => question.required && !hasRequiredResponse(question, responses[question.id])).map((question) => question.id);
7981
+ return questions.filter((question) => {
7982
+ const response = responses[question.id];
7983
+ if (hasRequiredResponse(question, response))
7984
+ return false;
7985
+ if (question.required)
7986
+ return true;
7987
+ return question.type !== "config" && !isUnanswered(response);
7988
+ }).map((question) => question.id);
7866
7989
  }
7867
7990
  var createRoute = route({
7868
7991
  method: "post",
@@ -8042,7 +8165,7 @@ async function handleApprovalRequests(req, res, pathSegments, queryParams) {
8042
8165
  const questions = existing.questions;
8043
8166
  const missingRequired = missingRequiredResponseIds(questions, parsed.body.responses);
8044
8167
  if (missingRequired.length > 0) {
8045
- jsonError(res, `Required responses missing or invalid: ${missingRequired.join(", ")}`, 400);
8168
+ jsonError(res, `Responses missing or invalid: ${missingRequired.join(", ")}`, 400);
8046
8169
  return true;
8047
8170
  }
8048
8171
  const configQuestions = questions.filter(isConfigQuestion);
@@ -9679,11 +9802,27 @@ init_auth_json();
9679
9802
 
9680
9803
  // src/providers/codex-oauth/device.ts
9681
9804
  init_flow();
9682
- var DEVICE_CODE_URL = "https://auth.openai.com/api/accounts/deviceauth/usercode";
9683
- var DEVICE_TOKEN_URL = "https://auth.openai.com/api/accounts/deviceauth/token";
9684
- var DEVICE_REDIRECT_URI = "https://auth.openai.com/deviceauth/callback";
9805
+ var DEFAULT_DEVICE_BASE_URL = "https://auth.openai.com";
9685
9806
  var UPSTREAM_TIMEOUT_MS = 15000;
9686
- var CODEX_DEVICE_VERIFICATION_URL = "https://auth.openai.com/codex/device";
9807
+ function resolveCodexDeviceBaseUrl(raw) {
9808
+ const configured = raw?.trim();
9809
+ if (!configured)
9810
+ return DEFAULT_DEVICE_BASE_URL;
9811
+ try {
9812
+ const url = new URL(configured);
9813
+ const loopback = url.hostname === "127.0.0.1" || url.hostname === "localhost" || url.hostname === "[::1]";
9814
+ if (url.protocol === "http:" && loopback)
9815
+ return url.origin;
9816
+ } catch {}
9817
+ console.warn("[codex-oauth] CODEX_OAUTH_DEVICE_BASE_URL must be a loopback http origin; ignored");
9818
+ return DEFAULT_DEVICE_BASE_URL;
9819
+ }
9820
+ function deviceBaseUrl() {
9821
+ return resolveCodexDeviceBaseUrl(process.env.CODEX_OAUTH_DEVICE_BASE_URL);
9822
+ }
9823
+ function codexDeviceVerificationUrl() {
9824
+ return `${deviceBaseUrl()}/codex/device`;
9825
+ }
9687
9826
 
9688
9827
  class DeviceCodeNotEnabledError extends Error {
9689
9828
  }
@@ -9698,7 +9837,7 @@ function parseInterval(value) {
9698
9837
  return 5;
9699
9838
  }
9700
9839
  async function requestDeviceCode() {
9701
- const response = await _fetchHolder.current(DEVICE_CODE_URL, {
9840
+ const response = await _fetchHolder.current(`${deviceBaseUrl()}/api/accounts/deviceauth/usercode`, {
9702
9841
  method: "POST",
9703
9842
  headers: {
9704
9843
  "Content-Type": "application/json",
@@ -9725,7 +9864,7 @@ async function requestDeviceCode() {
9725
9864
  };
9726
9865
  }
9727
9866
  async function pollDeviceToken(deviceAuthId, userCode) {
9728
- const response = await _fetchHolder.current(DEVICE_TOKEN_URL, {
9867
+ const response = await _fetchHolder.current(`${deviceBaseUrl()}/api/accounts/deviceauth/token`, {
9729
9868
  method: "POST",
9730
9869
  headers: {
9731
9870
  "Content-Type": "application/json",
@@ -9750,7 +9889,7 @@ async function pollDeviceToken(deviceAuthId, userCode) {
9750
9889
  };
9751
9890
  }
9752
9891
  async function exchangeDeviceAuthorizationCode(authorizationCode, codeVerifier) {
9753
- const token = await exchangeAuthorizationCode2(authorizationCode, codeVerifier, DEVICE_REDIRECT_URI, AbortSignal.timeout(UPSTREAM_TIMEOUT_MS));
9892
+ const token = await exchangeAuthorizationCode2(authorizationCode, codeVerifier, `${deviceBaseUrl()}/deviceauth/callback`, AbortSignal.timeout(UPSTREAM_TIMEOUT_MS), `${deviceBaseUrl()}/oauth/token`);
9754
9893
  if (token.type !== "success")
9755
9894
  return null;
9756
9895
  const accountId = getAccountId(token.access);
@@ -10001,7 +10140,7 @@ async function handleCodexOAuthDevice(req, res, pathSegments, queryParams) {
10001
10140
  startDeviceFlow.respond(res, 200, {
10002
10141
  flowId,
10003
10142
  userCode: device.userCode,
10004
- verificationUrl: CODEX_DEVICE_VERIFICATION_URL,
10143
+ verificationUrl: codexDeviceVerificationUrl(),
10005
10144
  intervalSeconds: device.intervalSeconds,
10006
10145
  expiresAt: new Date(expiresAt).toISOString()
10007
10146
  });
@@ -10988,6 +11127,7 @@ declare module "swarm-extension" {
10988
11127
  agentId?: string | null | undefined;
10989
11128
  creatorAgentId?: string | undefined;
10990
11129
  source?:
11130
+ | "chat"
10991
11131
  | "workflow"
10992
11132
  | "schedule"
10993
11133
  | "slack"
@@ -11003,7 +11143,6 @@ declare module "swarm-extension" {
11003
11143
  | "ui"
11004
11144
  | "system"
11005
11145
  | "comb"
11006
- | "chat"
11007
11146
  | undefined;
11008
11147
  routingReason?:
11009
11148
  | "skill"
@@ -11043,7 +11182,7 @@ declare module "swarm-extension" {
11043
11182
  parentTaskId?: string | undefined;
11044
11183
  model?: string | undefined;
11045
11184
  modelTier?: "smol" | "regular" | "smart" | "ultra" | undefined;
11046
- effort?: "off" | "low" | "medium" | "high" | "xhigh" | "max" | undefined;
11185
+ effort?: "low" | "medium" | "high" | "max" | "off" | "xhigh" | undefined;
11047
11186
  profile?: string | undefined;
11048
11187
  scheduleId?: string | undefined;
11049
11188
  workflowRunId?: string | undefined;
@@ -11070,18 +11209,18 @@ declare module "swarm-extension" {
11070
11209
  sourceAgentId?: string | undefined;
11071
11210
  role?: string | undefined;
11072
11211
  harnessProvider?:
11073
- | "claude"
11074
- | "codex"
11075
11212
  | "pi"
11076
- | "devin"
11213
+ | "claude"
11077
11214
  | "claude-managed"
11215
+ | "codex"
11216
+ | "grok"
11217
+ | "fx"
11078
11218
  | "opencode"
11079
- | "acp"
11080
11219
  | "dsh"
11081
- | "amp"
11082
11220
  | "cursor"
11083
- | "grok"
11084
- | "fx"
11221
+ | "amp"
11222
+ | "devin"
11223
+ | "acp"
11085
11224
  | undefined;
11086
11225
  leadOnly?: boolean | undefined;
11087
11226
  }
@@ -11094,6 +11233,7 @@ declare module "swarm-extension" {
11094
11233
  agentId: string | null;
11095
11234
  task: string;
11096
11235
  status:
11236
+ | "skipped"
11097
11237
  | "draft"
11098
11238
  | "backlog"
11099
11239
  | "unassigned"
@@ -11107,6 +11247,7 @@ declare module "swarm-extension" {
11107
11247
  | "cancelled"
11108
11248
  | "superseded";
11109
11249
  source:
11250
+ | "chat"
11110
11251
  | "workflow"
11111
11252
  | "schedule"
11112
11253
  | "slack"
@@ -11121,8 +11262,7 @@ declare module "swarm-extension" {
11121
11262
  | "api"
11122
11263
  | "ui"
11123
11264
  | "system"
11124
- | "comb"
11125
- | "chat";
11265
+ | "comb";
11126
11266
  tags: string[];
11127
11267
  priority: number;
11128
11268
  dependsOn: string[];
@@ -11177,11 +11317,11 @@ declare module "swarm-extension" {
11177
11317
  claudeSessionId?: string | undefined;
11178
11318
  model?: string | undefined;
11179
11319
  modelTier?: "smol" | "regular" | "smart" | "ultra" | undefined;
11180
- effort?: "off" | "low" | "medium" | "high" | "xhigh" | "max" | undefined;
11320
+ effort?: "low" | "medium" | "high" | "max" | "off" | "xhigh" | undefined;
11181
11321
  resolvedModel?: string | undefined;
11182
11322
  modelSource?: string | undefined;
11183
11323
  modelAlias?: string | undefined;
11184
- resolvedEffort?: "off" | "low" | "medium" | "high" | "xhigh" | "max" | undefined;
11324
+ resolvedEffort?: "low" | "medium" | "high" | "max" | "off" | "xhigh" | undefined;
11185
11325
  profile?: string | undefined;
11186
11326
  resolvedProfile?: string | undefined;
11187
11327
  scheduleId?: string | undefined;
@@ -11206,18 +11346,18 @@ declare module "swarm-extension" {
11206
11346
  requestedByUserId?: string | undefined;
11207
11347
  swarmVersion?: string | undefined;
11208
11348
  provider?:
11209
- | "claude"
11210
- | "codex"
11211
11349
  | "pi"
11212
- | "devin"
11350
+ | "claude"
11213
11351
  | "claude-managed"
11352
+ | "codex"
11353
+ | "grok"
11354
+ | "fx"
11214
11355
  | "opencode"
11215
- | "acp"
11216
11356
  | "dsh"
11217
- | "amp"
11218
11357
  | "cursor"
11219
- | "grok"
11220
- | "fx"
11358
+ | "amp"
11359
+ | "devin"
11360
+ | "acp"
11221
11361
  | undefined;
11222
11362
  providerMeta?: Record<string, unknown> | undefined;
11223
11363
  harnessVariant?: string | undefined;
@@ -11229,18 +11369,18 @@ declare module "swarm-extension" {
11229
11369
  sourceAgentId?: string | undefined;
11230
11370
  role?: string | undefined;
11231
11371
  harnessProvider?:
11232
- | "claude"
11233
- | "codex"
11234
11372
  | "pi"
11235
- | "devin"
11373
+ | "claude"
11236
11374
  | "claude-managed"
11375
+ | "codex"
11376
+ | "grok"
11377
+ | "fx"
11237
11378
  | "opencode"
11238
- | "acp"
11239
11379
  | "dsh"
11240
- | "amp"
11241
11380
  | "cursor"
11242
- | "grok"
11243
- | "fx"
11381
+ | "amp"
11382
+ | "devin"
11383
+ | "acp"
11244
11384
  | undefined;
11245
11385
  leadOnly?: boolean | undefined;
11246
11386
  }
@@ -11264,7 +11404,7 @@ declare module "swarm-extension" {
11264
11404
 
11265
11405
  export type SteerMode = "steer" | "queue";
11266
11406
 
11267
- export type SteeringSource = "script" | "slack" | "mcp" | "api" | "ui" | "chat";
11407
+ export type SteeringSource = "chat" | "script" | "slack" | "mcp" | "api" | "ui";
11268
11408
 
11269
11409
  export type RequestInfo = {
11270
11410
  sessionId: string | undefined;
@@ -18620,7 +18760,10 @@ var metadataRoute = route({
18620
18760
  schema: MetadataResponseSchema
18621
18761
  },
18622
18762
  400: { description: "MCP has no URL / invalid transport" },
18623
- 404: { description: "MCP server not found" }
18763
+ 404: { description: "MCP server not found" },
18764
+ 502: {
18765
+ description: "Metadata discovery failed: the protected-resource or authorization-server metadata could not be fetched or was refused by the egress guard"
18766
+ }
18624
18767
  }
18625
18768
  });
18626
18769
  var statusRoute = route({
@@ -18720,6 +18863,7 @@ var disconnectRoute = route({
18720
18863
  path: "/api/mcp-oauth/{mcpServerId}",
18721
18864
  pattern: ["api", "mcp-oauth", null],
18722
18865
  summary: "Revoke and delete the OAuth token for an MCP server",
18866
+ description: "Idempotent: the connection row is kept with status revoked (its tokens are cleared) and the server returns to static auth, so a repeat call answers 200 and /status keeps returning the revoked token object.",
18723
18867
  tags: ["MCP OAuth"],
18724
18868
  auth: { apiKey: true },
18725
18869
  params: object2({ mcpServerId: string2() }),
@@ -19293,7 +19437,10 @@ var createMcpServerRoute = route({
19293
19437
  }),
19294
19438
  responses: {
19295
19439
  201: { description: "MCP server created", schema: object2({ server: McpServerSchema }) },
19296
- 400: { description: "Validation error" }
19440
+ 400: { description: "Validation error" },
19441
+ 409: {
19442
+ description: "A server with this name already exists in the same scope and owner (mcp_server_name_taken)"
19443
+ }
19297
19444
  },
19298
19445
  rbac: { permission: "mcp-server.create.swarm" }
19299
19446
  });
@@ -19616,6 +19763,10 @@ async function handleMcpServers(req, res, pathSegments, queryParams) {
19616
19763
  await emitMcpServerConnectedTelemetry2();
19617
19764
  createMcpServerRoute.respond(res, 201, { server });
19618
19765
  } catch (err) {
19766
+ if (err instanceof Error && err.message.includes("UNIQUE constraint")) {
19767
+ jsonError(res, "mcp_server_name_taken", 409);
19768
+ return true;
19769
+ }
19619
19770
  jsonError(res, err instanceof Error ? err.message : "Create failed", 400);
19620
19771
  }
19621
19772
  return true;
@@ -19715,7 +19866,7 @@ var userSendTaskInputSchema = object2({
19715
19866
  priority: number2().int().min(0).max(100).optional().describe("Priority 0-100 (default: 50)."),
19716
19867
  model: string2().trim().min(1).optional().describe("Concrete model override interpreted by the assignee's harness/provider."),
19717
19868
  modelTier: ModelTierSchema.optional().describe("Portable model tier: 'smol', 'regular', 'smart', or 'ultra'. Resolved by the assignee's harness/provider."),
19718
- outputSchema: record2(string2(), unknown()).optional().describe("Optional JSON Schema the assignee's final output must satisfy. store-progress rejects a completion that does not match. Supported keywords: type, required, properties, enum, const, items.")
19869
+ outputSchema: record2(string2(), unknown()).optional().describe("Optional JSON Schema the assignee's final output must satisfy. store-progress rejects a completion that does not match. Supported keywords: type, required, properties, enum, const, items. An empty object {} means no schema.")
19719
19870
  }).superRefine((data, ctx) => checkOutputSchemaShape(data.outputSchema, ctx));
19720
19871
  function permission(verb) {
19721
19872
  return { permission: verb };
@@ -22222,7 +22373,7 @@ var getCatalog = route({
22222
22373
  path: "/api/models-catalog",
22223
22374
  pattern: ["api", "models-catalog"],
22224
22375
  summary: "Get the live model catalog for the picker-reachable providers",
22225
- description: "Slim projection of the models.dev payload (openrouter / anthropic / openai / amazon-bedrock only), refreshed server-side at boot and every 12h by the pricing-refresh loop. `source` is 'snapshot' with `updatedAt: null` until the first successful fetch (or when models.dev is unreachable), in which case the vendored snapshot is served instead.",
22376
+ description: "Slim projection of the models.dev payload (the vendored models.dev snapshot, or the live fetch once one succeeds) plus the OpenAI-compatible registry providers; see the `providers` field for the live list. Refreshed server-side at boot and every 12h by the pricing-refresh loop. `source` is 'snapshot' with `updatedAt: null` until the first successful fetch (or when models.dev is unreachable), in which case the vendored snapshot is served instead.",
22226
22377
  tags: ["Pricing"],
22227
22378
  responses: {
22228
22379
  200: {
@@ -24166,9 +24317,10 @@ init_version3();
24166
24317
  init_resolver();
24167
24318
  init_session_templates();
24168
24319
  init_sibling_awareness();
24320
+ init_page_fields();
24321
+ init_presets();
24169
24322
  init_types4();
24170
24323
  init_constants3();
24171
- init_node_env();
24172
24324
  init_page_session();
24173
24325
  init_request_auth_context();
24174
24326
  init_favorite_owner();
@@ -24191,6 +24343,7 @@ init_rbac();
24191
24343
  init_context_key();
24192
24344
  init_errors2();
24193
24345
  init_sibling_awareness();
24346
+ init_task_skip();
24194
24347
  init_terminal_result_guard();
24195
24348
  init_worker_follow_up();
24196
24349
  init_types4();
@@ -24369,7 +24522,7 @@ var listTasks = route({
24369
24522
  path: "/api/tasks",
24370
24523
  pattern: ["api", "tasks"],
24371
24524
  summary: "List tasks with filters",
24372
- description: "Returns tasks with the full `task` text replaced by a bounded `taskPreview` and completion/integration blobs dropped by default — list views only need the preview. Pass `fields=full` to restore the full `AgentTask`, or `fields=timeline` for the narrow shape the dashboard timeline draws. Every shape gives a user caller only tasks of sessions they can read. Fetch a single task in full via `GET /api/tasks/{id}`. `total` (the filtered row count, ignoring limit/offset) is computed only with `includeTotal=true`.",
24525
+ description: "Returns tasks with the full `task` text replaced by a bounded `taskPreview` and completion/integration blobs dropped by default — list views only need the preview. Pass `fields=full` to restore the full `AgentTask`, or `fields=timeline` for the narrow shape the dashboard timeline draws. Every shape gives a user caller only tasks of sessions they can read, unless `scope=all` applies. Fetch a single task in full via `GET /api/tasks/{id}`. `total` (the filtered row count, ignoring limit/offset) is computed only with `includeTotal=true`.",
24373
24526
  tags: ["Tasks"],
24374
24527
  query: object2({
24375
24528
  status: string2().optional(),
@@ -24388,7 +24541,8 @@ var listTasks = route({
24388
24541
  limit: exports_coerce.number().int().optional(),
24389
24542
  offset: exports_coerce.number().int().optional(),
24390
24543
  fields: _enum2(["full", "slim", "timeline"]).optional(),
24391
- includeTotal: _enum2(["true", "false"]).optional()
24544
+ includeTotal: _enum2(["true", "false"]).optional(),
24545
+ scope: _enum2(["all"]).optional().describe("all: every user's tasks, read-only, for a user with an admin role or session.read.all; ignored for anyone else. The X-Swarm-Session-Scope: all header opts in the same way.")
24392
24546
  }),
24393
24547
  responses: {
24394
24548
  200: {
@@ -24722,11 +24876,12 @@ var finishTask = route({
24722
24876
  path: "/api/tasks/{id}/finish",
24723
24877
  pattern: ["api", "tasks", null, "finish"],
24724
24878
  session: { taskParam: "id" },
24725
- summary: "Mark task as completed or failed (runner endpoint)",
24879
+ summary: "Mark task as completed, failed, or skipped (runner endpoint)",
24880
+ description: "`skipped` ends a task that is not the caller's to handle. It needs a one-line reason in `failureReason` (or `output`), keeps `output` empty, posts nothing, and creates no follow-up.",
24726
24881
  tags: ["Tasks"],
24727
24882
  params: object2({ id: string2() }),
24728
24883
  body: object2({
24729
- status: _enum2(["completed", "failed"]),
24884
+ status: _enum2(["completed", "failed", "skipped"]),
24730
24885
  output: string2().optional(),
24731
24886
  failureReason: string2().optional(),
24732
24887
  force: boolean().optional(),
@@ -24735,7 +24890,7 @@ var finishTask = route({
24735
24890
  auth: { apiKey: true, agentId: true },
24736
24891
  responses: {
24737
24892
  200: { description: "Task finished", schema: FinishTaskSuccessSchema },
24738
- 400: { description: "Invalid status" },
24893
+ 400: { description: "Invalid status, or a skip without a reason" },
24739
24894
  403: { description: "Not assigned to this agent" },
24740
24895
  404: { description: "Task not found" },
24741
24896
  409: {
@@ -24966,7 +25121,9 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
24966
25121
  if (validated.length > 0)
24967
25122
  source = validated;
24968
25123
  }
24969
- const actor = await resolveSessionActor2(req, myAgentId);
25124
+ const actor = await resolveSessionActor2(req, myAgentId, {
25125
+ allUsers: parsed.query.scope === "all"
25126
+ });
24970
25127
  const filters = {
24971
25128
  status,
24972
25129
  agentId: parsed.query.agentId || undefined,
@@ -24984,7 +25141,7 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
24984
25141
  orderBy: parsed.query.orderBy,
24985
25142
  limit: parsed.query.limit,
24986
25143
  offset: parsed.query.offset,
24987
- readableBy: actor.kind === "user" ? { userId: actor.userId } : undefined
25144
+ readableBy: readableByFor2(actor)
24988
25145
  };
24989
25146
  const tasks = parsed.query.fields === "full" ? await getAllTasks2(filters) : parsed.query.fields === "timeline" ? await getAllTasks2(filters, { fields: "timeline" }) : await getAllTasks2(filters, { slim: true });
24990
25147
  if (parsed.query.includeTotal === "true") {
@@ -25542,7 +25699,14 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
25542
25699
  if (task.agentId && task.agentId !== myAgentId) {
25543
25700
  return { error: "Task is assigned to another agent", status: 403 };
25544
25701
  }
25545
- const terminalResultGuard = await guardTerminalTaskResultWrite(task, parsed.body);
25702
+ const skipReason = parsed.body.status === "skipped" ? skipReasonFrom(parsed.body.failureReason, parsed.body.output) : undefined;
25703
+ if (parsed.body.status === "skipped" && !skipReason) {
25704
+ return {
25705
+ error: 'Status "skipped" needs a one-line reason in failureReason',
25706
+ status: 400
25707
+ };
25708
+ }
25709
+ const terminalResultGuard = await guardTerminalTaskResultWrite(task, parsed.body.status === "skipped" ? { status: "skipped", failureReason: skipReason, force: parsed.body.force } : parsed.body);
25546
25710
  if (terminalResultGuard.handled) {
25547
25711
  const { handled: _handled, ...guardResult } = terminalResultGuard;
25548
25712
  return { ...guardResult, alreadyFinished: true };
@@ -25561,6 +25725,12 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
25561
25725
  return { error: "Failed to complete task", status: 500 };
25562
25726
  }
25563
25727
  updatedTask = result;
25728
+ } else if (parsed.body.status === "skipped") {
25729
+ const result = await skipTask2(parsed.params.id, skipReason);
25730
+ if (!result) {
25731
+ return { error: "Failed to mark task as skipped", status: 500 };
25732
+ }
25733
+ updatedTask = result;
25564
25734
  } else {
25565
25735
  const result = await failTask2(parsed.params.id, parsed.body.failureReason || "Process exited without explicit completion");
25566
25736
  if (!result) {
@@ -25584,7 +25754,9 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
25584
25754
  });
25585
25755
  return true;
25586
25756
  }
25587
- if (result.task && isFreshFinishResult(result)) {
25757
+ if (result.task && isFreshFinishResult(result) && parsed.body.status === "skipped") {
25758
+ finalizeSkippedTaskReaction(result.task, "tasks.finish");
25759
+ } else if (result.task && isFreshFinishResult(result)) {
25588
25760
  const finishEventId = parsed.body.status === "completed" ? "completed" : "failed";
25589
25761
  ensure({
25590
25762
  id: finishEventId,
@@ -25604,7 +25776,7 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
25604
25776
  try {
25605
25777
  const followUp = await createWorkerTaskFollowUp2({
25606
25778
  task: result.task,
25607
- status: parsed.body.status,
25779
+ status: finishEventId,
25608
25780
  output: parsed.body.output,
25609
25781
  failureReason: parsed.body.failureReason
25610
25782
  });
@@ -25803,6 +25975,9 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
25803
25975
  }
25804
25976
  if (task.workflowRunStepId != null) {
25805
25977
  const failed = await failTask2(parsed.params.id, SUPERSEDED_WORKFLOW_TASK_REASON);
25978
+ if (task.agentId) {
25979
+ await updateAgentStatusFromCapacity2(task.agentId);
25980
+ }
25806
25981
  ensure({
25807
25982
  id: "task.workflow_step_failed_on_supersede",
25808
25983
  flow: "task",
@@ -25836,6 +26011,9 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
25836
26011
  });
25837
26012
  return true;
25838
26013
  }
26014
+ if (task.agentId) {
26015
+ await updateAgentStatusFromCapacity2(task.agentId);
26016
+ }
25839
26017
  const followUp = await createResumeFollowUp2({
25840
26018
  parentId: parsed.params.id,
25841
26019
  reason: parsed.body.reason
@@ -25887,11 +26065,22 @@ var PageWithShareUrlsSchema = PageSchema.extend({
25887
26065
  api_url: string2(),
25888
26066
  app_url: string2()
25889
26067
  });
25890
- var PageListItemSchema = PageSchema.partial({ body: true, passwordHash: true }).extend({
26068
+ var PageListItemSchema = PageSchema.partial({
26069
+ body: true,
26070
+ passwordHash: true,
26071
+ theme: true,
26072
+ themeTokens: true,
26073
+ designVersion: true
26074
+ }).extend({
25891
26075
  favorite: boolean(),
25892
26076
  api_url: string2(),
25893
26077
  app_url: string2()
25894
26078
  });
26079
+ var pageDesignBodyFields = {
26080
+ theme: string2().nullable().optional().describe(`Theme preset id that restyles the whole page. One of: ${THEME_PRESET_IDS.join(", ")}. Omit to follow the viewer's theme. Pass null on update to clear it.`),
26081
+ themeTokens: PageThemeTokensInputSchema.nullable().optional().describe('Per-page token overrides, applied on top of the preset. Send { light, dark } maps of token name to CSS value, or { format: "css", css } with a CSS variable block (:root, .dark, @theme). Stored normalized. Names outside the token contract, and values that reference a variable outside it, are ignored and listed in ignoredTokens. Replaces the stored overrides. Pass null on update to clear them.'),
26082
+ designVersion: number2().int().min(1).max(2).optional().describe("Design system version. 2 is the swarm design system and the default for new pages. 1 is the original look that older pages keep. Omit on update to keep the stored value.")
26083
+ };
25895
26084
  var createPageRoute = route({
25896
26085
  method: "post",
25897
26086
  path: "/api/pages",
@@ -25907,7 +26096,8 @@ var createPageRoute = route({
25907
26096
  authMode: PageAuthModeSchema.default("authed"),
25908
26097
  password: string2().min(1).optional(),
25909
26098
  body: string2(),
25910
- needsCredentials: array2(string2()).optional()
26099
+ needsCredentials: array2(string2()).optional(),
26100
+ ...pageDesignBodyFields
25911
26101
  }),
25912
26102
  responses: {
25913
26103
  201: {
@@ -25917,10 +26107,12 @@ var createPageRoute = route({
25917
26107
  key: AssetKeySchema,
25918
26108
  version: literal2(1),
25919
26109
  api_url: string2(),
25920
- app_url: string2()
26110
+ app_url: string2(),
26111
+ ignoredTokens: array2(string2()).optional().describe("Theme tokens the importer ignored. A bare name is outside the token contract. Other entries give the reason, for example --font-sans (references --font-geist-sans) or --ring (in .card). Absent when none were ignored."),
26112
+ designVersion: number2().int().min(1).describe("The design version of the new page: 2 unless the body set designVersion: 1.")
25921
26113
  })
25922
26114
  },
25923
- 400: { description: "Invalid body" },
26115
+ 400: { description: "Invalid body, unknown theme, or invalid themeTokens" },
25924
26116
  409: { description: "Slug already exists for this agent" }
25925
26117
  }
25926
26118
  });
@@ -25979,13 +26171,21 @@ var updatePageRoute = route({
25979
26171
  authMode: PageAuthModeSchema.optional(),
25980
26172
  password: string2().min(1).nullable().optional(),
25981
26173
  body: string2().optional(),
25982
- needsCredentials: array2(string2()).nullable().optional()
26174
+ needsCredentials: array2(string2()).nullable().optional(),
26175
+ ...pageDesignBodyFields
25983
26176
  }),
25984
26177
  responses: {
25985
26178
  200: {
25986
26179
  description: "Page updated",
25987
- schema: object2({ id: string2(), key: AssetKeySchema, version: number2().int().min(1) })
26180
+ schema: object2({
26181
+ id: string2(),
26182
+ key: AssetKeySchema,
26183
+ version: number2().int().min(1),
26184
+ ignoredTokens: array2(string2()).optional().describe("Theme tokens the importer ignored. A bare name is outside the token contract. Other entries give the reason, for example --font-sans (references --font-geist-sans) or --ring (in .card). Absent when none were ignored."),
26185
+ designVersion: number2().int().min(1).describe("The design version the page has after the update. An omitted designVersion keeps the stored one, so an older page stays on 1.")
26186
+ })
25988
26187
  },
26188
+ 400: { description: "Unknown theme or invalid themeTokens" },
25989
26189
  404: { description: "Page not found" },
25990
26190
  413: { description: "Payload too large" }
25991
26191
  }
@@ -26196,12 +26396,6 @@ function formatFeedbackComments(comments) {
26196
26396
 
26197
26397
  `);
26198
26398
  }
26199
- function isDevRequest(req) {
26200
- if (getNodeEnv() === "production")
26201
- return false;
26202
- const origin = req.headers.origin ?? "";
26203
- return origin === "" || origin.startsWith("http://localhost") || origin.startsWith("http://127.0.0.1");
26204
- }
26205
26399
  async function handlePages(req, res, pathSegments, queryParams, myAgentId) {
26206
26400
  if (createPageRoute.match(req.method, pathSegments)) {
26207
26401
  if (enforceContentLengthCap(req, res, MAX_PAGE_BODY_BYTES) === BODY_TOO_LARGE)
@@ -26213,6 +26407,11 @@ async function handlePages(req, res, pathSegments, queryParams, myAgentId) {
26213
26407
  jsonError(res, "X-Agent-ID header required", 400);
26214
26408
  return true;
26215
26409
  }
26410
+ const themeFields = readThemeFields(parsed.body);
26411
+ if ("error" in themeFields) {
26412
+ jsonError(res, themeFields.error, 400);
26413
+ return true;
26414
+ }
26216
26415
  const slug = parsed.body.slug ?? slugify2(parsed.body.title);
26217
26416
  let passwordHash;
26218
26417
  if (parsed.body.password) {
@@ -26230,14 +26429,19 @@ async function handlePages(req, res, pathSegments, queryParams, myAgentId) {
26230
26429
  authMode: parsed.body.authMode,
26231
26430
  passwordHash,
26232
26431
  body: parsed.body.body,
26233
- needsCredentials: parsed.body.needsCredentials
26432
+ needsCredentials: parsed.body.needsCredentials,
26433
+ theme: themeFields.theme,
26434
+ themeTokens: themeFields.themeTokens,
26435
+ designVersion: parsed.body.designVersion
26234
26436
  });
26235
26437
  createPageRoute.respond(res, 201, {
26236
26438
  id: page.id,
26237
26439
  key: page.key,
26238
26440
  version: 1,
26239
26441
  api_url: `${getApiBaseUrl()}/p/${page.id}`,
26240
- app_url: `${getAppBaseUrl()}/pages/${page.slug}`
26442
+ app_url: `${getAppBaseUrl()}/pages/${page.slug}`,
26443
+ ...themeFields.ignored.length > 0 ? { ignoredTokens: themeFields.ignored } : {},
26444
+ designVersion: page.designVersion
26241
26445
  });
26242
26446
  } catch (err) {
26243
26447
  if (err instanceof AssetKeyAuthorizationError) {
@@ -26401,6 +26605,11 @@ async function handlePages(req, res, pathSegments, queryParams, myAgentId) {
26401
26605
  jsonError(res, "Page belongs to another agent", 403);
26402
26606
  return true;
26403
26607
  }
26608
+ const themeFields = readThemeFields(parsed.body);
26609
+ if ("error" in themeFields) {
26610
+ jsonError(res, themeFields.error, 400);
26611
+ return true;
26612
+ }
26404
26613
  let passwordHashUpdate;
26405
26614
  if (parsed.body.password === null) {
26406
26615
  passwordHashUpdate = null;
@@ -26430,7 +26639,10 @@ async function handlePages(req, res, pathSegments, queryParams, myAgentId) {
26430
26639
  authMode: parsed.body.authMode,
26431
26640
  passwordHash: passwordHashUpdate,
26432
26641
  body: parsed.body.body,
26433
- needsCredentials: parsed.body.needsCredentials ?? undefined
26642
+ needsCredentials: parsed.body.needsCredentials ?? undefined,
26643
+ theme: themeFields.theme,
26644
+ themeTokens: themeFields.themeTokens,
26645
+ designVersion: parsed.body.designVersion
26434
26646
  });
26435
26647
  if (!updated) {
26436
26648
  res.writeHead(404);
@@ -26440,7 +26652,9 @@ async function handlePages(req, res, pathSegments, queryParams, myAgentId) {
26440
26652
  updatePageRoute.respond(res, 200, {
26441
26653
  id: updated.id,
26442
26654
  key: updated.key,
26443
- version: await getPageEditCounter(updated.id)
26655
+ version: await getPageEditCounter(updated.id),
26656
+ ...themeFields.ignored.length > 0 ? { ignoredTokens: themeFields.ignored } : {},
26657
+ designVersion: updated.designVersion
26444
26658
  });
26445
26659
  return true;
26446
26660
  }
@@ -26549,7 +26763,7 @@ ${defuseFeedbackTags(note)}
26549
26763
  const user = authUser(auth);
26550
26764
  const identity = user ? { uid: user.id, name: user.name } : isOperatorAuth(auth) ? { name: `guest-${randomUUID4().slice(0, 8)}`, op: true } : undefined;
26551
26765
  const cookies = await pageSessionSetCookies(req, page.id, {
26552
- dev: isDevRequest(req),
26766
+ dev: isLocalDevPageRequest(req),
26553
26767
  ...identity
26554
26768
  });
26555
26769
  applyLaunchCors(req, res);
@@ -26897,11 +27111,23 @@ var SWARM_UI_JS = `
26897
27111
  closeCursorRoomIfUnused(record);
26898
27112
  }
26899
27113
 
27114
+ // Colors and fonts read the page theme tokens (designVersion 2). Each
27115
+ // fallback is the original literal, so a designVersion 1 page, which has no
27116
+ // tokens, renders exactly as before.
26900
27117
  var SEV_COLOR = {
26901
- error: '#ef4444',
26902
- warn: '#f59e0b',
26903
- info: '#3b82f6',
27118
+ error: 'var(--color-status-error-strong, #ef4444)',
27119
+ warn: 'var(--color-status-warning-strong, #f59e0b)',
27120
+ info: 'var(--color-status-info-strong, #3b82f6)',
26904
27121
  };
27122
+ var MUTED = 'var(--color-muted-foreground, #7c8aa6)';
27123
+ var MONO = "var(--font-mono, 'Space Mono', ui-monospace, monospace)";
27124
+
27125
+ // A color at a lower alpha. Mixing with transparent keeps the color and
27126
+ // scales its alpha, so tint('#ef4444', '13.33%') equals #ef444422 and
27127
+ // tint('rgb(34,197,94)', '10%') equals rgba(34,197,94,0.10).
27128
+ function tint(color, percent) {
27129
+ return 'color-mix(in srgb, ' + color + ' ' + percent + ', transparent)';
27130
+ }
26905
27131
 
26906
27132
  function esc(s) {
26907
27133
  return String(s == null ? '' : s)
@@ -26936,7 +27162,7 @@ var SWARM_UI_JS = `
26936
27162
  '<span class="swarm-diff-annot no-print" '
26937
27163
  + 'style="display:inline-block;margin-left:8px;padding:1px 6px;'
26938
27164
  + 'border-radius:4px;font-size:11px;font-weight:600;'
26939
- + 'background:' + color + '22;color:' + color + ';border:1px solid ' + color + '55;">'
27165
+ + 'background:' + tint(color, '13.33%') + ';color:' + color + ';border:1px solid ' + tint(color, '33.33%') + ';">'
26940
27166
  + esc((ann && ann.severity ? ann.severity.toUpperCase() : 'INFO')) + ' · ' + esc(ann && ann.text || '')
26941
27167
  + '</span>'
26942
27168
  );
@@ -26968,12 +27194,12 @@ var SWARM_UI_JS = `
26968
27194
  var text = line.text == null ? '' : line.text;
26969
27195
  var bg, oldCell, newCell, sign;
26970
27196
  if (type === 'add') {
26971
- bg = 'rgba(34,197,94,0.10)';
27197
+ bg = tint('var(--color-status-success, rgb(34,197,94))', '10%');
26972
27198
  oldCell = '';
26973
27199
  newCell = String(newN++);
26974
27200
  sign = '+';
26975
27201
  } else if (type === 'del') {
26976
- bg = 'rgba(239,68,68,0.10)';
27202
+ bg = tint('var(--color-status-error, rgb(239,68,68))', '10%');
26977
27203
  oldCell = String(oldN++);
26978
27204
  newCell = '';
26979
27205
  sign = '-';
@@ -26985,15 +27211,17 @@ var SWARM_UI_JS = `
26985
27211
  }
26986
27212
 
26987
27213
  var annHtml = '';
26988
- var anns = annByLine[Number(newCell)] || annByLine[Number(oldCell)] || [];
27214
+ // Annotations name new-side lines. A deleted row has no new-side
27215
+ // number, so only a deleted row matches on its old-side number.
27216
+ var anns = annByLine[Number(type === 'del' ? oldCell : newCell)] || [];
26989
27217
  for (var k = 0; k < anns.length; k++) annHtml += renderAnnotation(anns[k]);
26990
27218
 
26991
27219
  rowsHtml += (
26992
27220
  '<tr style="background:' + bg + ';">'
26993
- + '<td class="swarm-diff-gutter" style="user-select:none;text-align:right;padding:0 8px;color:#7c8aa6;font-size:12px;width:48px;">' + esc(oldCell) + '</td>'
26994
- + '<td class="swarm-diff-gutter" style="user-select:none;text-align:right;padding:0 8px;color:#7c8aa6;font-size:12px;width:48px;">' + esc(newCell) + '</td>'
26995
- + '<td class="swarm-diff-sign" style="user-select:none;text-align:center;padding:0 4px;color:#7c8aa6;font-size:12px;width:18px;">' + esc(sign) + '</td>'
26996
- + '<td class="swarm-diff-code" style="padding:0 8px;white-space:pre-wrap;word-break:break-word;font-family:\\'Space Mono\\',ui-monospace,monospace;font-size:12px;">' + esc(text) + annHtml + '</td>'
27221
+ + '<td class="swarm-diff-gutter" style="user-select:none;text-align:right;padding:0 8px;color:' + MUTED + ';font-size:12px;width:48px;">' + esc(oldCell) + '</td>'
27222
+ + '<td class="swarm-diff-gutter" style="user-select:none;text-align:right;padding:0 8px;color:' + MUTED + ';font-size:12px;width:48px;">' + esc(newCell) + '</td>'
27223
+ + '<td class="swarm-diff-sign" style="user-select:none;text-align:center;padding:0 4px;color:' + MUTED + ';font-size:12px;width:18px;">' + esc(sign) + '</td>'
27224
+ + '<td class="swarm-diff-code" style="padding:0 8px;white-space:pre-wrap;word-break:break-word;font-family:' + MONO + ';font-size:12px;">' + esc(text) + annHtml + '</td>'
26997
27225
  + '</tr>'
26998
27226
  );
26999
27227
  }
@@ -27005,8 +27233,8 @@ var SWARM_UI_JS = `
27005
27233
  );
27006
27234
 
27007
27235
  return (
27008
- '<a id="' + esc(anchorId) + '" class="swarm-diff-anchor" data-hunk="' + esc(anchorSlug) + '"></a>'
27009
- + '<div class="swarm-diff-hunk-header" style="padding:6px 12px;background:rgba(124,138,166,0.10);color:#7c8aa6;font-family:\\'Space Mono\\',ui-monospace,monospace;font-size:11px;border-top:1px solid var(--swarm-border,#22304a);">'
27236
+ '<a id="' + esc(anchorId) + '" class="swarm-diff-anchor" data-hunk="' + esc(anchorSlug) + '" data-new-start="' + esc(newStart) + '"></a>'
27237
+ + '<div class="swarm-diff-hunk-header" style="padding:6px 12px;background:' + tint('var(--color-muted-foreground, rgb(124,138,166))', '10%') + ';color:' + MUTED + ';font-family:' + MONO + ';font-size:11px;border-top:1px solid var(--swarm-border,#22304a);">'
27010
27238
  + esc(header)
27011
27239
  + '</div>'
27012
27240
  + '<table class="swarm-diff-table" style="width:100%;border-collapse:collapse;table-layout:fixed;">'
@@ -27023,7 +27251,7 @@ var SWARM_UI_JS = `
27023
27251
 
27024
27252
  var shaLine = '';
27025
27253
  if (baseSha || headSha) {
27026
- shaLine = '<span class="swarm-diff-sha" style="font-family:\\'Space Mono\\',ui-monospace,monospace;font-size:11px;color:#7c8aa6;">'
27254
+ shaLine = '<span class="swarm-diff-sha" style="font-family:' + MONO + ';font-size:11px;color:' + MUTED + ';">'
27027
27255
  + esc(baseSha) + ' → ' + esc(headSha)
27028
27256
  + '</span>';
27029
27257
  }
@@ -27035,8 +27263,8 @@ var SWARM_UI_JS = `
27035
27263
 
27036
27264
  rootEl.innerHTML = (
27037
27265
  '<div class="swarm-diff-root" style="border:1px solid var(--swarm-border,#22304a);border-radius:8px;background:var(--swarm-card,#121826);overflow:hidden;margin:12px 0;break-inside:avoid;">'
27038
- + '<div class="swarm-diff-header" style="display:flex;align-items:center;justify-content:space-between;padding:10px 12px;background:rgba(59,130,246,0.10);border-bottom:1px solid var(--swarm-border,#22304a);">'
27039
- + '<span class="swarm-diff-file" style="font-family:\\'Space Mono\\',ui-monospace,monospace;font-size:13px;font-weight:700;color:var(--swarm-text,#e6eaf2);">' + esc(file || '(untitled)') + '</span>'
27266
+ + '<div class="swarm-diff-header" style="display:flex;align-items:center;justify-content:space-between;padding:10px 12px;background:var(--color-surface, rgba(59,130,246,0.10));border-bottom:1px solid var(--swarm-border,#22304a);">'
27267
+ + '<span class="swarm-diff-file" style="font-family:' + MONO + ';font-size:13px;font-weight:700;color:var(--swarm-text,#e6eaf2);">' + esc(file || '(untitled)') + '</span>'
27040
27268
  + shaLine
27041
27269
  + '</div>'
27042
27270
  + hunksHtml
@@ -27100,21 +27328,34 @@ var SWARM_UI_JS = `
27100
27328
  var renderJumps = function() {
27101
27329
  var anchors = document.querySelectorAll('.swarm-diff-anchor[data-hunk]');
27102
27330
  if (!anchors.length) {
27103
- self.innerHTML = '<span class="no-print" style="color:#7c8aa6;font-size:12px;">No hunks yet.</span>';
27331
+ self.innerHTML = '<span class="no-print" style="color:' + MUTED + ';font-size:12px;">No hunks yet.</span>';
27104
27332
  return;
27105
27333
  }
27106
- var items = '';
27334
+ var labels = [];
27335
+ var fileCounts = new Map();
27107
27336
  for (var i = 0; i < anchors.length; i++) {
27108
27337
  var a = anchors[i];
27109
27338
  var slug = a.getAttribute('data-hunk') || ('hunk-' + i);
27110
27339
  // Hunk title = nearest preceding diff's file attribute if available.
27111
27340
  var diff = a.closest && a.closest('swarm-diff');
27112
27341
  var file = (diff && diff.getAttribute('file')) || slug;
27113
- items += '<li style="margin:0;padding:2px 0;"><a href="#' + esc(a.id) + '" style="color:#3b82f6;text-decoration:none;font-family:\\'Space Mono\\',ui-monospace,monospace;font-size:12px;">' + esc(file) + '</a></li>';
27342
+ labels.push(file);
27343
+ fileCounts.set(file, (fileCounts.get(file) || 0) + 1);
27344
+ }
27345
+ var items = '';
27346
+ for (var n = 0; n < anchors.length; n++) {
27347
+ // A file with more than one hunk gets each hunk's new-side start
27348
+ // line (src/x.ts:58), so its links differ.
27349
+ var label = labels[n];
27350
+ var newStart = anchors[n].getAttribute('data-new-start');
27351
+ if (fileCounts.get(label) > 1 && newStart) label += ':' + newStart;
27352
+ // target=_self: the page head sets <base target="_blank">, which would
27353
+ // open these in-page anchors in a new tab.
27354
+ items += '<li style="margin:0;padding:2px 0;"><a href="#' + esc(anchors[n].id) + '" target="_self" style="color:var(--color-primary, #3b82f6);text-decoration:none;font-family:' + MONO + ';font-size:12px;">' + esc(label) + '</a></li>';
27114
27355
  }
27115
27356
  self.innerHTML = (
27116
- '<nav class="swarm-diff-jumps no-print" style="padding:8px 12px;border:1px dashed var(--swarm-border,#22304a);border-radius:8px;background:rgba(124,138,166,0.05);">'
27117
- + '<div style="font-size:10px;text-transform:uppercase;letter-spacing:0.08em;color:#7c8aa6;margin-bottom:4px;">Jump to</div>'
27357
+ '<nav class="swarm-diff-jumps no-print" style="padding:8px 12px;border:1px dashed var(--swarm-border,#22304a);border-radius:8px;background:' + tint('var(--color-muted-foreground, rgb(124,138,166))', '5%') + ';">'
27358
+ + '<div style="font-size:10px;text-transform:uppercase;letter-spacing:0.08em;color:' + MUTED + ';margin-bottom:4px;">Jump to</div>'
27118
27359
  + '<ul style="list-style:none;padding:0;margin:0;">' + items + '</ul>'
27119
27360
  + '</nav>'
27120
27361
  );
@@ -27380,6 +27621,9 @@ var SWARM_UI_JS = `
27380
27621
  })();
27381
27622
  `;
27382
27623
 
27624
+ // src/http/pages-public.ts
27625
+ init_color_literals();
27626
+
27383
27627
  // src/pages/feedback-overlay.ts
27384
27628
  var PAGE_FEEDBACK_PARAM = "__swarm-feedback";
27385
27629
  function isPageFeedbackRequested(queryParams) {
@@ -27928,58 +28172,82 @@ function feedbackKeyGuardScript() {
27928
28172
  return `<script>${FEEDBACK_KEY_GUARD_JS}</script>`;
27929
28173
  }
27930
28174
 
27931
- // src/http/pages-public.ts
27932
- init_types4();
27933
- init_constants3();
27934
- init_node_env();
27935
- init_page_session();
27936
- init_secret_scrubber();
27937
- init_route_def();
27938
- var PublicPageJsonSchema = PageSchema.pick({
27939
- id: true,
27940
- title: true,
27941
- description: true,
27942
- contentType: true,
27943
- authMode: true,
27944
- body: true
27945
- }).extend({
27946
- version: literal2(1)
27947
- });
27948
- var publicPageRoute = route({
27949
- method: "get",
27950
- path: "/p/{id}",
27951
- pattern: ["p", null],
27952
- summary: "Render a page (HTML/SVG inline; JSON redirects to SPA)",
27953
- tags: ["Pages"],
27954
- params: object2({ id: string2() }),
27955
- responses: {
27956
- 200: {
27957
- description: "Rendered HTML page or raw SVG image",
27958
- unstructured: "Serves raw image/svg+xml bytes, the page's agent-authored HTML body (SDK-injected) or, for ?print=1 on a JSON-content page, a standalone printable HTML document — not a JSON shape"
27959
- },
27960
- 302: { description: "Redirect to SPA for JSON content" },
27961
- 401: { description: "Page requires an authenticated session" },
27962
- 403: { description: "Cookie does not match this page id" },
27963
- 404: { description: "Page not found" }
27964
- },
27965
- auth: { apiKey: false }
27966
- });
27967
- var publicPageJsonRoute = route({
27968
- method: "get",
27969
- path: "/p/{id}.json",
27970
- pattern: ["p", null],
27971
- summary: "Page metadata + body as JSON (used by SPA renderer)",
27972
- tags: ["Pages"],
27973
- params: object2({ id: string2() }),
27974
- responses: {
27975
- 200: { description: "Page JSON", schema: PublicPageJsonSchema },
27976
- 401: { description: "Page requires an authenticated session" },
27977
- 403: { description: "Cookie does not match this page id" },
27978
- 404: { description: "Page not found" }
27979
- },
27980
- auth: { apiKey: false }
27981
- });
27982
- var PAGE_HEAD_DEFAULTS = `<base target="_blank">
28175
+ // src/themes/page-theme.ts
28176
+ init_presets();
28177
+ init_tokens2();
28178
+ var SWARM_ALIASES = [
28179
+ ["--swarm-bg", "--color-background"],
28180
+ ["--swarm-card", "--color-card"],
28181
+ ["--swarm-border", "--color-border"],
28182
+ ["--swarm-text", "--color-foreground"],
28183
+ ["--swarm-muted", "--color-muted-foreground"],
28184
+ ["--swarm-primary", "--color-primary"]
28185
+ ];
28186
+ function contractValues(vars) {
28187
+ const values = {};
28188
+ if (!vars)
28189
+ return values;
28190
+ for (const token of PAGE_THEME_TOKENS) {
28191
+ const value = vars[token];
28192
+ if (value !== undefined)
28193
+ values[token] = value;
28194
+ }
28195
+ return values;
28196
+ }
28197
+ function resolvePageTheme({
28198
+ pageTheme,
28199
+ viewerTheme,
28200
+ overrides
28201
+ }) {
28202
+ const preset = getThemePreset(pageTheme) ?? getThemePreset(viewerTheme) ?? getThemePreset(DEFAULT_THEME_ID);
28203
+ const lightOverrides = contractValues(overrides?.light);
28204
+ const darkOverrides = contractValues(overrides?.dark);
28205
+ const light = {
28206
+ ...HIVE_PAGE_TOKENS.light,
28207
+ ...contractValues(preset?.vars.light),
28208
+ ...lightOverrides
28209
+ };
28210
+ const dark = { ...HIVE_PAGE_TOKENS.dark, ...contractValues(preset?.vars.dark), ...darkOverrides };
28211
+ for (const token of PAGE_THEME_SHARED_TOKENS) {
28212
+ const value = lightOverrides[token];
28213
+ if (value !== undefined && darkOverrides[token] === undefined)
28214
+ dark[token] = value;
28215
+ }
28216
+ return { presetId: preset?.id ?? DEFAULT_THEME_ID, light, dark };
28217
+ }
28218
+ function declarationLines(values, indent) {
28219
+ return PAGE_THEME_TOKENS.map((token) => `${indent}${token}: ${values[token]};`).join(`
28220
+ `);
28221
+ }
28222
+ function renderPageThemeCss(theme) {
28223
+ const aliases = SWARM_ALIASES.map(([alias, token]) => ` ${alias}: var(${token});`).join(`
28224
+ `);
28225
+ return [
28226
+ `:root {
28227
+ color-scheme: light;
28228
+ ${declarationLines(theme.light, " ")}
28229
+ ${aliases}
28230
+ }`,
28231
+ `:root.dark {
28232
+ color-scheme: dark;
28233
+ ${declarationLines(theme.dark, " ")}
28234
+ }`,
28235
+ `@media print {
28236
+ :root.dark {
28237
+ color-scheme: light;
28238
+ ${declarationLines(theme.light, " ")}
28239
+ }
28240
+ }`
28241
+ ].join(`
28242
+
28243
+ `);
28244
+ }
28245
+
28246
+ // src/pages/page-head.ts
28247
+ init_tokens2();
28248
+ var PAGE_THEME_PARAM = "__swarm-theme";
28249
+ var PAGE_MODE_PARAM = "__swarm-mode";
28250
+ var PAGE_HEAD_V1 = `<base target="_blank">
27983
28251
  <link rel="preconnect" href="https://fonts.googleapis.com">
27984
28252
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
27985
28253
  <link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Space+Mono:wght@400;700&display=swap" rel="stylesheet">
@@ -28035,14 +28303,689 @@ var PAGE_HEAD_DEFAULTS = `<base target="_blank">
28035
28303
  .swarm-card, swarm-diff { break-inside: avoid; }
28036
28304
  }
28037
28305
  </style>`;
28038
- function injectBrowserSdk(html, headFirst = "") {
28039
- const injection = `${headFirst}${PAGE_HEAD_DEFAULTS}<script>${BROWSER_SDK_JS}</script><script>${SWARM_UI_JS}</script>`;
28040
- const headOpenMatch = html.match(/<head\b[^>]*>/i);
28041
- if (headOpenMatch) {
28042
- const idx = headOpenMatch.index + headOpenMatch[0].length;
28043
- return html.slice(0, idx) + injection + html.slice(idx);
28306
+ var TAILWIND_BROWSER_SRC = "https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4.3.3/dist/index.global.js";
28307
+ var TAILWIND_BROWSER_INTEGRITY = "sha384-2ql948lIdLcGEE0/qxNiudyTjgauA3RDJERu5xW75kFCvSl5a9odyQYCb6tEjnmB";
28308
+ var IN_PAGE_LINK_SCRIPT = `<script>document.addEventListener("click", function (event) {
28309
+ var link = event.target && event.target.closest && event.target.closest('a[href^="#"]:not([target])');
28310
+ if (link) link.setAttribute("target", "_self");
28311
+ }, true);</script>`;
28312
+ var FONT_LINKS = `<link rel="preconnect" href="https://fonts.googleapis.com">
28313
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
28314
+ <link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Space+Mono:wght@400;700&display=swap" rel="stylesheet">`;
28315
+ var TAILWIND_SOURCE = [
28316
+ '@import "tailwindcss/theme" layer(theme);',
28317
+ '@import "tailwindcss/utilities" layer(utilities);',
28318
+ "@custom-variant dark (&:where(.dark, .dark *));",
28319
+ "@theme inline reference {",
28320
+ ...PAGE_THEME_TOKENS.map((token) => ` ${token}: var(${token});`),
28321
+ "}"
28322
+ ].join(`
28323
+ `);
28324
+ var TAILWIND_SOURCE_SCRIPT = `<script>(function () {
28325
+ var style = document.createElement("style");
28326
+ style.type = "text/tailwindcss";
28327
+ style.textContent = ${JSON.stringify(TAILWIND_SOURCE).replace(/</g, "\\u003c")};
28328
+ document.head.appendChild(style);
28329
+ })();</script>`;
28330
+ var CONTROL_LOOK = `min-width: 0;
28331
+ padding: 7px 12px;
28332
+ font-size: 14px;
28333
+ line-height: 20px;
28334
+ color: var(--color-foreground);
28335
+ background-color: var(--color-card);
28336
+ border: 1px solid var(--color-input);
28337
+ border-radius: var(--radius-md);
28338
+ transition: border-color 150ms, box-shadow 150ms;`;
28339
+ var BUTTON_LOOK = `display: inline-flex;
28340
+ align-items: center;
28341
+ justify-content: center;
28342
+ gap: 8px;
28343
+ padding: 7px 14px;
28344
+ font-size: 14px;
28345
+ font-weight: 500;
28346
+ line-height: 20px;
28347
+ color: var(--color-foreground);
28348
+ background-color: var(--color-card);
28349
+ border: 1px solid var(--color-input);
28350
+ border-radius: var(--radius-md);
28351
+ text-decoration: none;
28352
+ white-space: nowrap;
28353
+ cursor: pointer;
28354
+ transition: color 150ms, background-color 150ms, border-color 150ms, box-shadow 150ms;`;
28355
+ var FOCUS_RING = `outline: none;
28356
+ border-color: var(--color-ring);
28357
+ box-shadow: 0 0 0 2px color-mix(in oklab, var(--color-ring) 60%, transparent);`;
28358
+ var TEXT_CONTROLS = `:where(input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"], [type="button"], [type="submit"], [type="reset"], [type="image"], [type="hidden"]), select, textarea)`;
28359
+ var BUTTON_CONTROLS = `:where(button, input[type="button"], input[type="submit"], input[type="reset"])`;
28360
+ var EDGE_SHADOW = "color-mix(in oklab, var(--color-foreground) 14%, transparent)";
28361
+ var TONES = [
28362
+ ["neutral", "--color-status-neutral", "--color-status-neutral-strong"],
28363
+ ["primary", "--color-primary", "--color-primary"],
28364
+ ...["success", "warning", "error", "info", "pending", "paused", "active"].map((tone) => [tone, `--color-status-${tone}`, `--color-status-${tone}-strong`])
28365
+ ];
28366
+ var TONE_RULES = TONES.map(([tone, soft, strong]) => ` :is(.swarm-badge, .swarm-callout, .swarm-metric)[data-tone="${tone}"] {
28367
+ --swarm-tone: var(${soft});
28368
+ --swarm-tone-strong: var(${strong});
28369
+ }`).join(`
28370
+ `);
28371
+ var PAGE_DESIGN_CSS = `@layer base {
28372
+ *, ::before, ::after, ::backdrop, ::file-selector-button {
28373
+ box-sizing: border-box;
28374
+ border: 0 solid var(--color-border);
28375
+ }
28376
+ html {
28377
+ color: var(--color-foreground);
28378
+ -webkit-text-size-adjust: 100%;
28379
+ text-size-adjust: 100%;
28380
+ tab-size: 4;
28044
28381
  }
28045
- return injection + html;
28382
+ body {
28383
+ margin: 0;
28384
+ padding: 24px;
28385
+ background-color: var(--color-background);
28386
+ color: var(--color-foreground);
28387
+ font-family: var(--font-sans), ui-sans-serif, system-ui, sans-serif;
28388
+ font-size: 15px;
28389
+ line-height: 1.55;
28390
+ -webkit-font-smoothing: antialiased;
28391
+ -moz-osx-font-smoothing: grayscale;
28392
+ }
28393
+ @media (max-width: 640px) {
28394
+ body { padding: 16px; }
28395
+ }
28396
+ :focus-visible {
28397
+ outline: 2px solid var(--color-ring);
28398
+ outline-offset: 2px;
28399
+ }
28400
+ h1, h2, h3, h4, h5, h6 {
28401
+ margin: 0;
28402
+ font-weight: 600;
28403
+ text-wrap: balance;
28404
+ }
28405
+ h1 { margin: 0 0 12px; font-size: 30px; line-height: 1.2; letter-spacing: -0.02em; }
28406
+ h2 { margin: 40px 0 12px; font-size: 20px; line-height: 1.3; letter-spacing: -0.015em; }
28407
+ h3 { margin: 28px 0 8px; font-size: 16px; line-height: 1.4; letter-spacing: -0.01em; }
28408
+ h4 { margin: 24px 0 6px; font-size: 15px; line-height: 1.45; }
28409
+ h5, h6 { margin: 20px 0 6px; font-size: 13px; line-height: 1.45; }
28410
+ p { margin: 0 0 12px; text-wrap: pretty; }
28411
+ ul, ol { margin: 0 0 12px; padding-left: 1.5em; }
28412
+ li { margin: 4px 0; }
28413
+ li > ul, li > ol { margin: 4px 0 0; }
28414
+ li::marker { color: var(--color-muted-foreground); }
28415
+ dl, figure, blockquote, pre, table, details, fieldset, form { margin: 0 0 16px; }
28416
+ dt { font-weight: 500; }
28417
+ dd { margin: 0 0 8px; }
28418
+ :where(h1, h2, h3, h4, h5, h6):first-child { margin-top: 0; }
28419
+ :where(p, ul, ol, dl, dd, figure, blockquote, pre, table, details, fieldset, form):last-child { margin-bottom: 0; }
28420
+ a {
28421
+ color: var(--color-primary);
28422
+ text-decoration-line: underline;
28423
+ text-decoration-thickness: 1px;
28424
+ text-decoration-color: color-mix(in oklab, currentColor 35%, transparent);
28425
+ text-underline-offset: 3px;
28426
+ }
28427
+ a:hover { text-decoration-color: currentColor; }
28428
+ hr {
28429
+ height: 0;
28430
+ margin: 32px 0;
28431
+ color: inherit;
28432
+ border-top: 1px solid var(--color-border-subtle);
28433
+ }
28434
+ b, strong { font-weight: 600; }
28435
+ mark {
28436
+ padding: 0 2px;
28437
+ color: inherit;
28438
+ background-color: color-mix(in oklab, var(--color-status-pending) 35%, transparent);
28439
+ border-radius: 2px;
28440
+ }
28441
+ code, kbd, samp, pre {
28442
+ font-family: var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace;
28443
+ font-size: 0.85em;
28444
+ }
28445
+ code {
28446
+ padding: 0.1em 0.35em;
28447
+ background-color: var(--color-muted);
28448
+ border-radius: var(--radius-sm);
28449
+ -webkit-box-decoration-break: clone;
28450
+ box-decoration-break: clone;
28451
+ }
28452
+ kbd {
28453
+ padding: 0.05em 0.4em;
28454
+ background-color: var(--color-card);
28455
+ border: 1px solid var(--color-border);
28456
+ border-bottom-width: 2px;
28457
+ border-radius: var(--radius-sm);
28458
+ }
28459
+ pre {
28460
+ padding: 12px 14px;
28461
+ overflow: auto;
28462
+ line-height: 1.6;
28463
+ background-color: var(--color-surface);
28464
+ border: 1px solid var(--color-border);
28465
+ border-radius: var(--radius-lg);
28466
+ }
28467
+ pre code {
28468
+ padding: 0;
28469
+ font-size: inherit;
28470
+ background-color: transparent;
28471
+ border-radius: 0;
28472
+ }
28473
+ blockquote {
28474
+ padding: 2px 0 2px 16px;
28475
+ color: var(--color-muted-foreground);
28476
+ border-left: 2px solid var(--color-border);
28477
+ }
28478
+ summary {
28479
+ cursor: pointer;
28480
+ font-weight: 500;
28481
+ }
28482
+ summary::marker { color: var(--color-muted-foreground); }
28483
+ details[open] > summary { margin-bottom: 8px; }
28484
+ img, video {
28485
+ display: block;
28486
+ max-width: 100%;
28487
+ height: auto;
28488
+ }
28489
+ figcaption {
28490
+ margin-top: 8px;
28491
+ font-size: 13px;
28492
+ color: var(--color-muted-foreground);
28493
+ }
28494
+ table {
28495
+ width: 100%;
28496
+ border-collapse: collapse;
28497
+ font-size: 14px;
28498
+ font-variant-numeric: tabular-nums;
28499
+ }
28500
+ caption {
28501
+ padding-bottom: 8px;
28502
+ font-size: 13px;
28503
+ text-align: left;
28504
+ color: var(--color-muted-foreground);
28505
+ }
28506
+ th, td {
28507
+ padding: 8px 12px;
28508
+ text-align: left;
28509
+ vertical-align: middle;
28510
+ border-bottom: 1px solid var(--color-border-subtle);
28511
+ }
28512
+ th {
28513
+ font-size: 11px;
28514
+ font-weight: 500;
28515
+ line-height: 1.45;
28516
+ letter-spacing: 0.05em;
28517
+ text-transform: uppercase;
28518
+ vertical-align: bottom;
28519
+ color: var(--color-muted-foreground);
28520
+ border-bottom-color: var(--color-border);
28521
+ }
28522
+ th[scope="row"] {
28523
+ font-size: inherit;
28524
+ letter-spacing: normal;
28525
+ text-transform: none;
28526
+ vertical-align: middle;
28527
+ color: inherit;
28528
+ border-bottom-color: var(--color-border-subtle);
28529
+ }
28530
+ tfoot :is(td, th) {
28531
+ font-weight: 600;
28532
+ border-top: 1px solid var(--color-border);
28533
+ }
28534
+ tbody:has(+ tfoot) > tr:last-child > :is(td, th) { border-bottom-color: var(--color-border); }
28535
+ :where(button, input, optgroup, select, textarea), ::file-selector-button {
28536
+ font: inherit;
28537
+ font-feature-settings: inherit;
28538
+ font-variation-settings: inherit;
28539
+ letter-spacing: inherit;
28540
+ color: inherit;
28541
+ }
28542
+ ${TEXT_CONTROLS} {
28543
+ ${CONTROL_LOOK}
28544
+ }
28545
+ ${TEXT_CONTROLS}:focus-visible {
28546
+ ${FOCUS_RING}
28547
+ }
28548
+ :where(input, select, textarea)::placeholder {
28549
+ color: var(--color-muted-foreground);
28550
+ opacity: 1;
28551
+ }
28552
+ :where(input, select, textarea, button):disabled {
28553
+ cursor: not-allowed;
28554
+ opacity: 0.5;
28555
+ }
28556
+ :where(input, select, textarea)[aria-invalid="true"] { border-color: var(--color-destructive); }
28557
+ textarea {
28558
+ min-height: 80px;
28559
+ line-height: 1.5;
28560
+ resize: vertical;
28561
+ }
28562
+ select:not([multiple], [size]) {
28563
+ appearance: none;
28564
+ padding-right: 32px;
28565
+ background-image:
28566
+ linear-gradient(45deg, transparent 50%, var(--color-muted-foreground) 50%),
28567
+ linear-gradient(135deg, var(--color-muted-foreground) 50%, transparent 50%);
28568
+ background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
28569
+ background-size: 5px 5px;
28570
+ background-repeat: no-repeat;
28571
+ }
28572
+ ${BUTTON_CONTROLS} {
28573
+ ${BUTTON_LOOK}
28574
+ }
28575
+ ${BUTTON_CONTROLS}:hover:not(:disabled) {
28576
+ color: var(--color-accent-foreground);
28577
+ background-color: var(--color-accent);
28578
+ }
28579
+ ${BUTTON_CONTROLS}:focus-visible {
28580
+ ${FOCUS_RING}
28581
+ }
28582
+ ::file-selector-button {
28583
+ margin-right: 12px;
28584
+ padding: 4px 10px;
28585
+ font-size: 13px;
28586
+ font-weight: 500;
28587
+ color: var(--color-foreground);
28588
+ background-color: var(--color-card);
28589
+ border: 1px solid var(--color-input);
28590
+ border-radius: var(--radius-sm);
28591
+ cursor: pointer;
28592
+ }
28593
+ input[type="checkbox"], input[type="radio"], input[type="range"], progress {
28594
+ accent-color: var(--color-primary);
28595
+ }
28596
+ fieldset {
28597
+ min-width: 0;
28598
+ padding: 12px 16px 16px;
28599
+ border: 1px solid var(--color-border);
28600
+ border-radius: var(--radius-lg);
28601
+ }
28602
+ legend {
28603
+ padding: 0 6px;
28604
+ font-size: 13px;
28605
+ font-weight: 500;
28606
+ color: var(--color-muted-foreground);
28607
+ }
28608
+ label:has(input, select, textarea), label[for] { cursor: pointer; }
28609
+ ::selection {
28610
+ color: var(--color-primary-foreground);
28611
+ background-color: var(--color-primary);
28612
+ }
28613
+ }
28614
+
28615
+ @layer components {
28616
+ .swarm-page {
28617
+ max-width: 1120px;
28618
+ margin-inline: auto;
28619
+ padding-block: 8px 24px;
28620
+ }
28621
+ .swarm-eyebrow {
28622
+ margin: 0 0 8px;
28623
+ font-size: 11px;
28624
+ font-weight: 500;
28625
+ line-height: 1.45;
28626
+ letter-spacing: 0.08em;
28627
+ text-transform: uppercase;
28628
+ color: var(--color-muted-foreground);
28629
+ }
28630
+ .swarm-lede {
28631
+ max-width: 68ch;
28632
+ margin: 0 0 16px;
28633
+ font-size: 17px;
28634
+ line-height: 1.55;
28635
+ color: var(--color-muted-foreground);
28636
+ text-wrap: pretty;
28637
+ }
28638
+ .swarm-section { margin-block: 40px; }
28639
+ .swarm-section:last-child { margin-bottom: 0; }
28640
+ .swarm-section > :first-child { margin-top: 0; }
28641
+
28642
+ .swarm-metrics {
28643
+ display: grid;
28644
+ grid-template-columns: repeat(auto-fit, minmax(min(100%, 148px), 1fr));
28645
+ gap: 12px;
28646
+ margin: 24px 0;
28647
+ }
28648
+ .swarm-metric {
28649
+ display: flex;
28650
+ flex-direction: column;
28651
+ gap: 4px;
28652
+ min-width: 0;
28653
+ padding: 14px 16px;
28654
+ color: var(--color-card-foreground);
28655
+ background-color: var(--color-card);
28656
+ border: 1px solid var(--color-border);
28657
+ border-radius: var(--radius-xl);
28658
+ }
28659
+ .swarm-metric-value {
28660
+ font-size: 26px;
28661
+ font-weight: 600;
28662
+ line-height: 1.15;
28663
+ letter-spacing: -0.02em;
28664
+ font-variant-numeric: tabular-nums;
28665
+ overflow-wrap: anywhere;
28666
+ }
28667
+ .swarm-metric[data-tone] .swarm-metric-value { color: var(--swarm-tone-strong); }
28668
+ .swarm-metric-label {
28669
+ font-size: 12px;
28670
+ line-height: 1.45;
28671
+ color: var(--color-muted-foreground);
28672
+ }
28673
+
28674
+ .swarm-panel, .swarm-card {
28675
+ padding: 20px;
28676
+ color: var(--color-card-foreground);
28677
+ background-color: var(--color-card);
28678
+ border: 1px solid var(--color-border);
28679
+ border-radius: var(--radius-xl);
28680
+ }
28681
+ :is(.swarm-panel, .swarm-card) > :first-child { margin-top: 0; }
28682
+ :is(.swarm-panel, .swarm-card) > :last-child { margin-bottom: 0; }
28683
+
28684
+ .swarm-badge {
28685
+ --swarm-tone: var(--color-status-neutral);
28686
+ --swarm-tone-strong: var(--color-status-neutral-strong);
28687
+ display: inline-flex;
28688
+ align-items: center;
28689
+ gap: 6px;
28690
+ height: 22px;
28691
+ padding: 0 8px;
28692
+ font-size: 12px;
28693
+ font-weight: 500;
28694
+ line-height: 1;
28695
+ white-space: nowrap;
28696
+ vertical-align: middle;
28697
+ color: var(--swarm-tone-strong);
28698
+ background-color: color-mix(in oklab, var(--swarm-tone) 16%, transparent);
28699
+ border: 1px solid color-mix(in oklab, var(--swarm-tone) 28%, transparent);
28700
+ border-radius: 999px;
28701
+ }
28702
+ .swarm-badge[data-dot]::before {
28703
+ content: "";
28704
+ flex: none;
28705
+ width: 6px;
28706
+ height: 6px;
28707
+ background: var(--swarm-dot, currentColor);
28708
+ border-radius: 999px;
28709
+ }
28710
+
28711
+ .swarm-table-wrap {
28712
+ max-height: min(70vh, 720px);
28713
+ margin: 0 0 16px;
28714
+ overflow: auto;
28715
+ background:
28716
+ linear-gradient(to right, var(--color-card) 30%, transparent) left / 40px 100% no-repeat local,
28717
+ linear-gradient(to left, var(--color-card) 30%, transparent) right / 40px 100% no-repeat local,
28718
+ linear-gradient(to right, ${EDGE_SHADOW}, transparent) left / 14px 100% no-repeat scroll,
28719
+ linear-gradient(to left, ${EDGE_SHADOW}, transparent) right / 14px 100% no-repeat scroll,
28720
+ var(--color-card);
28721
+ border: 1px solid var(--color-border);
28722
+ border-radius: var(--radius-xl);
28723
+ }
28724
+ .swarm-table-wrap:last-child { margin-bottom: 0; }
28725
+ .swarm-table-wrap > table { margin: 0; }
28726
+ .swarm-table {
28727
+ width: 100%;
28728
+ border-collapse: separate;
28729
+ border-spacing: 0;
28730
+ font-size: 13px;
28731
+ line-height: 1.45;
28732
+ font-variant-numeric: tabular-nums;
28733
+ }
28734
+ .swarm-table :is(th, td) { padding: 8px 12px; }
28735
+ .swarm-table thead th {
28736
+ position: sticky;
28737
+ top: 0;
28738
+ z-index: 1;
28739
+ padding-block: 10px 8px;
28740
+ white-space: nowrap;
28741
+ background-color: var(--color-card);
28742
+ }
28743
+ .swarm-table tbody tr:hover > :is(td, th) { background-color: color-mix(in oklab, var(--color-accent) 70%, transparent); }
28744
+ .swarm-table-wrap > .swarm-table > :last-child > tr:last-child > :is(td, th) { border-bottom: 0; }
28745
+ :is(td, th).num {
28746
+ text-align: right;
28747
+ white-space: nowrap;
28748
+ font-variant-numeric: tabular-nums;
28749
+ }
28750
+ :is(td, th).nowrap { white-space: nowrap; }
28751
+ .swarm-diff-root :is(table, th, td) { margin: 0; border: 0; }
28752
+
28753
+ .swarm-button {
28754
+ ${BUTTON_LOOK}
28755
+ }
28756
+ .swarm-button:hover {
28757
+ color: var(--color-accent-foreground);
28758
+ background-color: var(--color-accent);
28759
+ }
28760
+ .swarm-button[data-variant="primary"] {
28761
+ color: var(--color-primary-foreground);
28762
+ background-color: var(--color-primary);
28763
+ border-color: transparent;
28764
+ }
28765
+ .swarm-button[data-variant="primary"]:hover {
28766
+ color: var(--color-primary-foreground);
28767
+ background-color: color-mix(in oklab, var(--color-primary) 90%, transparent);
28768
+ }
28769
+ .swarm-button[data-variant="ghost"] {
28770
+ background-color: transparent;
28771
+ border-color: transparent;
28772
+ }
28773
+ .swarm-button[data-variant="ghost"]:hover { background-color: var(--color-accent); }
28774
+ .swarm-button:focus-visible {
28775
+ ${FOCUS_RING}
28776
+ }
28777
+ .swarm-button:is(:disabled, [aria-disabled="true"]) {
28778
+ opacity: 0.5;
28779
+ pointer-events: none;
28780
+ }
28781
+
28782
+ .swarm-input {
28783
+ ${CONTROL_LOOK}
28784
+ }
28785
+ .swarm-input:focus-visible {
28786
+ ${FOCUS_RING}
28787
+ }
28788
+ select.swarm-input:not([multiple], [size]) { padding-right: 32px; }
28789
+
28790
+ .swarm-toolbar {
28791
+ display: flex;
28792
+ flex-wrap: wrap;
28793
+ align-items: center;
28794
+ gap: 8px;
28795
+ margin: 0 0 12px;
28796
+ }
28797
+ .swarm-toolbar > :is(input[type="search"], input[type="text"], input:not([type])) { flex: 1 1 260px; }
28798
+
28799
+ .swarm-segmented {
28800
+ display: inline-flex;
28801
+ align-items: center;
28802
+ gap: 2px;
28803
+ height: 36px;
28804
+ padding: 2px;
28805
+ vertical-align: middle;
28806
+ background-color: color-mix(in oklab, var(--color-muted) 40%, transparent);
28807
+ border: 1px solid var(--color-border);
28808
+ border-radius: var(--radius-md);
28809
+ }
28810
+ .swarm-segmented > :is(button, a) {
28811
+ display: inline-flex;
28812
+ align-items: center;
28813
+ justify-content: center;
28814
+ gap: 6px;
28815
+ height: 100%;
28816
+ padding: 0 12px;
28817
+ font-size: 12px;
28818
+ font-weight: 500;
28819
+ line-height: 1;
28820
+ white-space: nowrap;
28821
+ text-decoration: none;
28822
+ color: var(--color-muted-foreground);
28823
+ background-color: transparent;
28824
+ border: 0;
28825
+ border-radius: calc(var(--radius-md) - 3px);
28826
+ box-shadow: none;
28827
+ cursor: pointer;
28828
+ transition: color 150ms, background-color 150ms;
28829
+ }
28830
+ .swarm-segmented > :is(button, a):hover {
28831
+ color: var(--color-foreground);
28832
+ background-color: transparent;
28833
+ }
28834
+ .swarm-segmented > :is([aria-pressed="true"], [data-active]:not([data-active="false"])) {
28835
+ color: var(--color-primary-foreground);
28836
+ background-color: var(--color-primary);
28837
+ }
28838
+ .swarm-segmented > :is(button, a):focus-visible {
28839
+ outline: none;
28840
+ box-shadow: 0 0 0 2px color-mix(in oklab, var(--color-ring) 60%, transparent);
28841
+ }
28842
+
28843
+ .swarm-callout {
28844
+ --swarm-tone: var(--color-status-info);
28845
+ --swarm-tone-strong: var(--color-status-info-strong);
28846
+ margin: 0 0 12px;
28847
+ padding: 12px 16px;
28848
+ color: var(--color-foreground);
28849
+ background-color: color-mix(in oklab, var(--swarm-tone) 12%, transparent);
28850
+ border: 1px solid color-mix(in oklab, var(--swarm-tone) 40%, transparent);
28851
+ border-radius: var(--radius-lg);
28852
+ }
28853
+ .swarm-callout:last-child { margin-bottom: 0; }
28854
+ .swarm-callout > :first-child { margin-top: 0; }
28855
+ .swarm-callout > :last-child { margin-bottom: 0; }
28856
+
28857
+ .swarm-kv {
28858
+ display: grid;
28859
+ grid-template-columns: minmax(96px, max-content) minmax(0, 1fr);
28860
+ gap: 8px 20px;
28861
+ margin: 0 0 16px;
28862
+ font-size: 14px;
28863
+ }
28864
+ .swarm-kv:last-child { margin-bottom: 0; }
28865
+ .swarm-kv > dt {
28866
+ font-weight: 400;
28867
+ color: var(--color-muted-foreground);
28868
+ }
28869
+ .swarm-kv > dd {
28870
+ min-width: 0;
28871
+ margin: 0;
28872
+ overflow-wrap: anywhere;
28873
+ }
28874
+
28875
+ ${TONE_RULES}
28876
+ }
28877
+
28878
+ @media print {
28879
+ html, body { background: white !important; color: black !important; }
28880
+ a:not(.swarm-button) { color: black !important; text-decoration: underline; }
28881
+ .no-print { display: none !important; }
28882
+ .swarm-panel, .swarm-card, swarm-diff, .swarm-metric { break-inside: avoid; }
28883
+ .swarm-table-wrap { max-height: none; overflow: visible; }
28884
+ .swarm-table { font-size: 12px; }
28885
+ .swarm-table :is(th, td):not(.num) { white-space: normal; }
28886
+ .swarm-table thead th { position: static; }
28887
+ tfoot { display: table-row-group; }
28888
+ }`;
28889
+ function buildPageHeadV2({
28890
+ theme,
28891
+ mode
28892
+ }) {
28893
+ return [
28894
+ '<base target="_blank">',
28895
+ IN_PAGE_LINK_SCRIPT,
28896
+ "<style>@layer properties, theme, base, components, utilities;</style>",
28897
+ FONT_LINKS,
28898
+ `<style id="swarm-theme">
28899
+ ${renderPageThemeCss(theme)}
28900
+ </style>`,
28901
+ `<style id="swarm-design">
28902
+ ${PAGE_DESIGN_CSS}
28903
+ </style>`,
28904
+ TAILWIND_SOURCE_SCRIPT,
28905
+ `<script src="${TAILWIND_BROWSER_SRC}" integrity="${TAILWIND_BROWSER_INTEGRITY}" crossorigin="anonymous"></script>`,
28906
+ ...mode === "dark" ? ['<script>document.documentElement.classList.add("dark")</script>'] : []
28907
+ ].join(`
28908
+ `);
28909
+ }
28910
+
28911
+ // src/http/pages-public.ts
28912
+ init_types4();
28913
+ init_constants3();
28914
+ init_page_session();
28915
+ init_secret_scrubber();
28916
+ init_route_def();
28917
+ var PublicPageJsonSchema = PageSchema.pick({
28918
+ id: true,
28919
+ title: true,
28920
+ description: true,
28921
+ contentType: true,
28922
+ authMode: true,
28923
+ body: true
28924
+ }).extend({
28925
+ version: literal2(1)
28926
+ });
28927
+ var publicPageRoute = route({
28928
+ method: "get",
28929
+ path: "/p/{id}",
28930
+ pattern: ["p", null],
28931
+ summary: "Render a page (HTML/SVG inline; JSON redirects to SPA)",
28932
+ tags: ["Pages"],
28933
+ params: object2({ id: string2() }),
28934
+ responses: {
28935
+ 200: {
28936
+ description: "Rendered HTML page or raw SVG image",
28937
+ unstructured: "Serves raw image/svg+xml bytes, the page's agent-authored HTML body (SDK-injected) or, for ?print=1 on a JSON-content page, a standalone printable HTML document — not a JSON shape"
28938
+ },
28939
+ 302: { description: "Redirect to SPA for JSON content" },
28940
+ 401: { description: "Page requires an authenticated session" },
28941
+ 403: { description: "Cookie does not match this page id" },
28942
+ 404: { description: "Page not found" }
28943
+ },
28944
+ auth: { apiKey: false }
28945
+ });
28946
+ var publicPageJsonRoute = route({
28947
+ method: "get",
28948
+ path: "/p/{id}.json",
28949
+ pattern: ["p", null],
28950
+ summary: "Page metadata + body as JSON (used by SPA renderer)",
28951
+ tags: ["Pages"],
28952
+ params: object2({ id: string2() }),
28953
+ responses: {
28954
+ 200: { description: "Page JSON", schema: PublicPageJsonSchema },
28955
+ 401: { description: "Page requires an authenticated session" },
28956
+ 403: { description: "Cookie does not match this page id" },
28957
+ 404: { description: "Page not found" }
28958
+ },
28959
+ auth: { apiKey: false }
28960
+ });
28961
+ function pageHead(page, queryParams, wantsPrint) {
28962
+ if (page.designVersion === 1)
28963
+ return PAGE_HEAD_V1;
28964
+ const theme = resolvePageTheme({
28965
+ pageTheme: page.theme,
28966
+ viewerTheme: queryParams.get(PAGE_THEME_PARAM),
28967
+ overrides: page.themeTokens
28968
+ });
28969
+ const dark = !wantsPrint && queryParams.get(PAGE_MODE_PARAM) === "dark" && countColorLiterals(page.body) < COLOR_LITERAL_THRESHOLD;
28970
+ return buildPageHeadV2({ theme, mode: dark ? "dark" : "light" });
28971
+ }
28972
+ var LEADING_DOCTYPE_RE = /^\s*<!doctype\b[^>]*>/i;
28973
+ var LEADING_HTML_TAG_RE = /^\s*<!doctype\b[^>]*>\s*<html\b[^>]*>/i;
28974
+ function injectBrowserSdk(html, { head, headFirst, standardsMode }) {
28975
+ const injection = `${headFirst}${head}<script>${BROWSER_SDK_JS}</script><script>${SWARM_UI_JS}</script>`;
28976
+ const doc = standardsMode && !LEADING_DOCTYPE_RE.test(html) ? `<!doctype html>${html}` : html;
28977
+ const leading = standardsMode ? LEADING_HTML_TAG_RE.exec(doc) ?? LEADING_DOCTYPE_RE.exec(doc) : null;
28978
+ const idx = headTagEnd(doc) ?? (leading ? leading.index + leading[0].length : null);
28979
+ if (idx === null)
28980
+ return injection + doc;
28981
+ return doc.slice(0, idx) + injection + doc.slice(idx);
28982
+ }
28983
+ function headTagEnd(doc) {
28984
+ const start = doc.search(/<head\b/i);
28985
+ if (start === -1)
28986
+ return null;
28987
+ const close = doc.indexOf(">", start);
28988
+ return close === -1 ? null : close + 1;
28046
28989
  }
28047
28990
  var PRINT_AUTOTRIGGER_SCRIPT = `<script>
28048
28991
  (function () {
@@ -28152,14 +29095,7 @@ function getPageFrameAncestors() {
28152
29095
  }
28153
29096
  function buildCsp(page) {
28154
29097
  const configured = getConfiguredAppUrls();
28155
- const devFallbacks = getNodeEnv() === "production" ? [] : [
28156
- "http://localhost:5274",
28157
- "http://localhost:5175",
28158
- "http://127.0.0.1:5274",
28159
- "http://127.0.0.1:5175",
28160
- "https://*.localhost",
28161
- "http://*.localhost"
28162
- ];
29098
+ const devFallbacks = getLocalDevAppOrigins();
28163
29099
  const embedders = page.authMode === "public" ? getPageFrameAncestors() : [];
28164
29100
  const ancestors = Array.from(new Set([...configured, ...devFallbacks, ...embedders]));
28165
29101
  return [
@@ -28192,6 +29128,25 @@ function isAccessible(page, cookiePayload) {
28192
29128
  needsPassword: true
28193
29129
  };
28194
29130
  }
29131
+ async function hasSessionForOtherPage(req, pageId) {
29132
+ const header = req.headers.cookie;
29133
+ if (!header)
29134
+ return false;
29135
+ const pairs = (Array.isArray(header) ? header.join("; ") : header).split(";");
29136
+ for (const pair of pairs) {
29137
+ const eq = pair.indexOf("=");
29138
+ if (eq === -1)
29139
+ continue;
29140
+ const name = pair.slice(0, eq).trim();
29141
+ if (name !== LEGACY_PAGE_SESSION_COOKIE && !name.startsWith(`${LEGACY_PAGE_SESSION_COOKIE}_`)) {
29142
+ continue;
29143
+ }
29144
+ const payload = await verifyPageSession(pair.slice(eq + 1).trim());
29145
+ if (payload && payload.pageId !== pageId)
29146
+ return true;
29147
+ }
29148
+ return false;
29149
+ }
28195
29150
  function extractPasswordCandidate(req, queryParams) {
28196
29151
  const fromQuery = queryParams.get("key");
28197
29152
  if (fromQuery !== null)
@@ -28214,19 +29169,6 @@ function extractPasswordCandidate(req, queryParams) {
28214
29169
  return null;
28215
29170
  return decoded.slice(colonIdx + 1);
28216
29171
  }
28217
- function isLocalhostRequest(req) {
28218
- if (getNodeEnv() === "production")
28219
- return false;
28220
- const origin = req.headers.origin ?? "";
28221
- if (origin === "") {
28222
- const rawHost = req.headers.host;
28223
- const host = Array.isArray(rawHost) ? rawHost[0] : rawHost;
28224
- if (!host)
28225
- return true;
28226
- return host.startsWith("localhost") || host.startsWith("127.0.0.1");
28227
- }
28228
- return origin.startsWith("http://localhost") || origin.startsWith("http://127.0.0.1");
28229
- }
28230
29172
  async function handlePagesPublic(req, res, pathSegments, queryParams) {
28231
29173
  if (pathSegments.length !== 2 || pathSegments[0] !== "p")
28232
29174
  return false;
@@ -28267,7 +29209,7 @@ async function handlePagesPublic(req, res, pathSegments, queryParams) {
28267
29209
  }
28268
29210
  if (matched) {
28269
29211
  inlineSetCookie = await pageSessionSetCookies(req, page.id, {
28270
- dev: isLocalhostRequest(req)
29212
+ dev: isLocalDevPageRequest(req)
28271
29213
  });
28272
29214
  } else {
28273
29215
  res.writeHead(401, {
@@ -28286,6 +29228,13 @@ async function handlePagesPublic(req, res, pathSegments, queryParams) {
28286
29228
  return true;
28287
29229
  }
28288
29230
  } else {
29231
+ if (await hasSessionForOtherPage(req, page.id)) {
29232
+ res.writeHead(403, { "Content-Type": "application/json" });
29233
+ res.end(JSON.stringify({
29234
+ error: "page-session cookie does not match this page id; POST /api/pages/:id/launch"
29235
+ }));
29236
+ return true;
29237
+ }
28289
29238
  res.writeHead(access.status, { "Content-Type": "application/json" });
28290
29239
  res.end(JSON.stringify({ error: scrubSecrets(access.reason) }));
28291
29240
  return true;
@@ -28347,7 +29296,11 @@ async function handlePagesPublic(req, res, pathSegments, queryParams) {
28347
29296
  return true;
28348
29297
  }
28349
29298
  const feedback = isPageFeedbackRequested(queryParams);
28350
- const html = injectBrowserSdk(page.body, feedback ? feedbackKeyGuardScript() : "") + (wantsPrint ? PRINT_AUTOTRIGGER_SCRIPT : "") + (feedback ? feedbackOverlayScripts(page.id) : "");
29299
+ const html = injectBrowserSdk(page.body, {
29300
+ head: pageHead(page, queryParams, wantsPrint),
29301
+ headFirst: feedback ? feedbackKeyGuardScript() : "",
29302
+ standardsMode: page.designVersion !== 1
29303
+ }) + (wantsPrint ? PRINT_AUTOTRIGGER_SCRIPT : "") + (feedback ? feedbackOverlayScripts(page.id) : "");
28351
29304
  const headers = {
28352
29305
  "Content-Type": "text/html; charset=utf-8",
28353
29306
  "Cache-Control": "no-store",
@@ -28792,11 +29745,10 @@ async function handlePoll(req, res, pathSegments, queryParams, myAgentId) {
28792
29745
  }
28793
29746
  const claimedChannels = hasCapability("messaging") ? await claimMentions2(myAgentId) : [];
28794
29747
  if (claimedChannels.length > 0) {
28795
- const inbox = await getInboxSummary2(myAgentId);
28796
29748
  return {
28797
29749
  trigger: {
28798
29750
  type: "unread_mentions",
28799
- mentionsCount: inbox.mentionsCount,
29751
+ mentionsCount: claimedChannels.reduce((sum, c) => sum + c.mentionsCount, 0),
28800
29752
  claimedChannels: claimedChannels.map((c) => c.channelId)
28801
29753
  }
28802
29754
  };
@@ -29726,7 +30678,7 @@ ${templateBody}` : templateBody;
29726
30678
  checkoutRoute.respond(res, 200, { template: toPromptTemplateResponse(template) });
29727
30679
  } catch (error) {
29728
30680
  const message = error instanceof Error ? error.message : "Unknown error";
29729
- if (message.includes("not found")) {
30681
+ if (message.includes("not found") || message.startsWith("No history entry")) {
29730
30682
  jsonError(res, message, 404);
29731
30683
  } else {
29732
30684
  jsonError(res, message, 400);
@@ -31100,6 +32052,10 @@ async function handleSchedules(req, res, pathSegments, queryParams, myAgentId) {
31100
32052
  jsonError(res, "delayMs and runAt are only for one-time schedules. Set scheduleType to 'one_time'.", 400);
31101
32053
  return true;
31102
32054
  }
32055
+ if (!body.cronExpression && !body.intervalMs) {
32056
+ jsonError(res, "Either cronExpression or intervalMs must be provided.", 400);
32057
+ return true;
32058
+ }
31103
32059
  }
31104
32060
  if (body.cronExpression) {
31105
32061
  try {
@@ -31619,7 +32575,7 @@ init_vendored_openapi();
31619
32575
  init_app_validation();
31620
32576
  init_ensure_token();
31621
32577
  init_mcp_wrapper();
31622
- init_presets();
32578
+ init_presets2();
31623
32579
  init_wrapper();
31624
32580
  init_credential_broker();
31625
32581
  init_telemetry();
@@ -33758,6 +34714,7 @@ var postInternalStepRoute = route({
33758
34714
  pattern: ["api", "internal", "script-runs", null, "steps"],
33759
34715
  operationId: "script_runs_internal_step_create",
33760
34716
  summary: "Write a script run journal step",
34717
+ description: "Write-once per stepKey; a replay keeps the first journal entry and still answers 201.",
33761
34718
  tags: ["Script Runs"],
33762
34719
  params: runIdParamsSchema,
33763
34720
  body: journalStepBodySchema,
@@ -34259,7 +35216,7 @@ async function handleScriptRuns(req, res, pathSegments, queryParams, agentId) {
34259
35216
  agentTaskRoute.respond(res, 200, { taskId: latest.id, taskOutput: latest.output ?? null });
34260
35217
  return true;
34261
35218
  }
34262
- if (latest.status === "failed" || latest.status === "cancelled" || latest.status === "superseded") {
35219
+ if (latest.status === "failed" || latest.status === "cancelled" || latest.status === "superseded" || latest.status === "skipped") {
34263
35220
  json(res, { error: `Agent task ${latest.status}`, taskId: latest.id }, 409);
34264
35221
  return true;
34265
35222
  }
@@ -36195,7 +37152,7 @@ var listSessions = route({
36195
37152
  status: _enum2(["running", "failed", "needs"]).optional(),
36196
37153
  withUserId: string2().min(1).optional(),
36197
37154
  fields: _enum2(["full", "slim"]).optional(),
36198
- scope: _enum2(["mine", "shared", "tree"]).optional().describe("mine: owned sessions. shared: sessions shared with me. tree: Sessions that GET /api/session-tree counts: mine plus shared with me, no ownerless roots. A bypass actor sees every root with tree scope."),
37155
+ scope: _enum2(["mine", "shared", "tree", "all"]).optional().describe("mine: owned sessions. shared: sessions shared with me. tree: Sessions that GET /api/session-tree counts: mine plus shared with me, no ownerless roots. A bypass actor sees every root with tree scope. all: every user's sessions, read-only, for a user with an admin role or session.read.all; ignored for anyone else. The X-Swarm-Session-Scope: all header opts in the same way, also for tree."),
36199
37156
  show: SessionShowSchema,
36200
37157
  hideSource: SessionHideSourceSchema,
36201
37158
  showSource: SessionShowSourceSchema
@@ -36422,7 +37379,7 @@ var putSessionShares = route({
36422
37379
  rbac: { permission: "session.share" }
36423
37380
  });
36424
37381
  async function accessForRoot(actor, root) {
36425
- return actor.kind === "bypass" ? "owner" : sessionAccessForRoot(actor.userId, root);
37382
+ return actor.kind === "bypass" ? "owner" : withReadAll2(actor, await sessionAccessForRoot(actor.userId, root));
36426
37383
  }
36427
37384
  async function handleSessions(req, res, pathSegments, queryParams, myAgentId) {
36428
37385
  if (await handleAgentTokens(req, res, pathSegments, queryParams))
@@ -36504,9 +37461,10 @@ async function handleSessions(req, res, pathSegments, queryParams, myAgentId) {
36504
37461
  if (!parsed)
36505
37462
  return true;
36506
37463
  const sources = parsed.query.source ? parsed.query.source.split(",").map((s) => s.trim()).filter(Boolean) : undefined;
36507
- const actor = await resolveSessionActor2(req, myAgentId);
37464
+ const allUsers = parsed.query.scope === "all";
37465
+ const actor = await resolveSessionActor2(req, myAgentId, { allUsers });
36508
37466
  const limit = Math.min(200, Math.max(0, parsed.query.limit ?? 25));
36509
- if (actor.kind === "bypass" && parsed.query.scope && parsed.query.scope !== "tree") {
37467
+ if (actor.kind === "bypass" && (parsed.query.scope === "mine" || parsed.query.scope === "shared")) {
36510
37468
  listSessions.respond(res, 200, {
36511
37469
  sessions: [],
36512
37470
  total: 0,
@@ -36534,7 +37492,8 @@ async function handleSessions(req, res, pathSegments, queryParams, myAgentId) {
36534
37492
  ...actor.kind === "user" ? {
36535
37493
  viewer: {
36536
37494
  userId: actor.userId,
36537
- scope: parsed.query.scope === "tree" ? "all" : parsed.query.scope ?? "all"
37495
+ scope: parsed.query.scope === "mine" || parsed.query.scope === "shared" ? parsed.query.scope : "all",
37496
+ readAll: actor.readAll
36538
37497
  }
36539
37498
  } : {}
36540
37499
  };
@@ -36580,7 +37539,7 @@ async function handleSessions(req, res, pathSegments, queryParams, myAgentId) {
36580
37539
  return true;
36581
37540
  }
36582
37541
  const { action, show, ...list } = parsed.body;
36583
- const updated = await triageSessionList(actor.userId, { ...list, mine: show !== "all" }, action);
37542
+ const updated = await triageSessionList(actor.userId, { ...list, mine: show !== "all" }, action, actor.readAll);
36584
37543
  triageSessionListRoute.respond(res, 200, { updated });
36585
37544
  return true;
36586
37545
  }
@@ -36707,7 +37666,7 @@ async function handleSessions(req, res, pathSegments, queryParams, myAgentId) {
36707
37666
  getTaskSteeringFieldsForTasks(tasks),
36708
37667
  getTaskCitationsForTasks(tasks.map((task) => task.id)),
36709
37668
  getPendingApprovalsForTasks2(tasks.map((task) => task.id)),
36710
- actor.kind === "user" && actor.userId ? getSessionReadState(sessionRoot.id, actor.userId) : Promise.resolve(null),
37669
+ actor.kind === "user" && actor.userId ? getSessionReadState(sessionRoot.id, actor.userId, undefined, actor.readAll) : Promise.resolve(null),
36711
37670
  getSessionGroupKey(root)
36712
37671
  ]);
36713
37672
  const decorate = (task) => ({
@@ -39390,6 +40349,7 @@ init_constants3();
39390
40349
  init_egress_guard();
39391
40350
  init_request_auth_context();
39392
40351
  init_route_def();
40352
+ init_session_access();
39393
40353
  init_utils2();
39394
40354
  async function composeUser(userId, recentEventLimit = 5) {
39395
40355
  const user = await getUserById2(userId);
@@ -39467,7 +40427,8 @@ var whoamiRoute = route({
39467
40427
  grantsAll: boolean(),
39468
40428
  verbs: array2(string2()),
39469
40429
  roles: array2(string2())
39470
- }).optional()
40430
+ }).optional(),
40431
+ sessionReadAll: boolean().optional()
39471
40432
  })
39472
40433
  },
39473
40434
  401: { description: "Unauthorized" }
@@ -39517,7 +40478,8 @@ var createUserRoute = route({
39517
40478
  schema: object2({ user: ComposedUserSchema.nullable() })
39518
40479
  },
39519
40480
  400: { description: "Validation error" },
39520
- 401: { description: "Unauthorized" }
40481
+ 401: { description: "Unauthorized" },
40482
+ 409: { description: "A user with this email already exists (user_exists)" }
39521
40483
  },
39522
40484
  auth: { apiKey: true }
39523
40485
  });
@@ -39855,9 +40817,10 @@ var addIdentityRoute = route({
39855
40817
  description: "Updated identity list",
39856
40818
  schema: object2({ identities: array2(UserIdentityLinkSchema) })
39857
40819
  },
39858
- 400: { description: "Validation error or PK collision" },
40820
+ 400: { description: "Validation error" },
39859
40821
  401: { description: "Unauthorized" },
39860
- 404: { description: "User not found" }
40822
+ 404: { description: "User not found" },
40823
+ 409: { description: "The (kind, externalId) identity is already linked (identity_taken)" }
39861
40824
  },
39862
40825
  auth: { apiKey: true }
39863
40826
  });
@@ -39878,6 +40841,9 @@ var deleteIdentityRoute = route({
39878
40841
  },
39879
40842
  auth: { apiKey: true }
39880
40843
  });
40844
+ function isUniqueViolation(err, target) {
40845
+ return err instanceof Error && err.message.includes("UNIQUE constraint") && err.message.includes(target);
40846
+ }
39881
40847
  var UNMAPPED_KINDS = [
39882
40848
  "slack",
39883
40849
  "github",
@@ -39988,6 +40954,8 @@ async function handleUsers(req, res, pathSegments, queryParams) {
39988
40954
  if (!parsed)
39989
40955
  return true;
39990
40956
  const user = authUser(getRequestAuth(req));
40957
+ const scopeActor = await resolveSessionActor2(req, undefined, { allUsers: true });
40958
+ const sessionReadAll = scopeActor.kind === "bypass" || scopeActor.readAll === true;
39991
40959
  if (user) {
39992
40960
  const [grant, roles] = await Promise.all([getUserGrant2(user.id), listUserRoles2(user.id)]);
39993
40961
  const grantsAll = !isRbacEnabled() || grant.grantsAll;
@@ -39998,13 +40966,15 @@ async function handleUsers(req, res, pathSegments, queryParams) {
39998
40966
  grantsAll,
39999
40967
  verbs: grantsAll ? [] : [...grant.verbs].sort(),
40000
40968
  roles: roles.map((role) => role.name)
40001
- }
40969
+ },
40970
+ sessionReadAll
40002
40971
  });
40003
40972
  } else {
40004
40973
  whoamiRoute.respond(res, 200, {
40005
40974
  kind: "operator",
40006
40975
  user: null,
40007
- grants: { grantsAll: true, verbs: [], roles: [] }
40976
+ grants: { grantsAll: true, verbs: [], roles: [] },
40977
+ sessionReadAll
40008
40978
  });
40009
40979
  }
40010
40980
  return true;
@@ -40041,6 +41011,10 @@ async function handleUsers(req, res, pathSegments, queryParams) {
40041
41011
  const composed = await composeUser(user.id);
40042
41012
  createUserRoute.respond(res, 200, { user: composed });
40043
41013
  } catch (err) {
41014
+ if (isUniqueViolation(err, "users.email")) {
41015
+ jsonError(res, "user_exists", 409);
41016
+ return true;
41017
+ }
40044
41018
  jsonError(res, err instanceof Error ? err.message : "Failed to create user", 500);
40045
41019
  }
40046
41020
  return true;
@@ -40359,6 +41333,10 @@ async function handleUsers(req, res, pathSegments, queryParams) {
40359
41333
  identities: await getUserIdentities(parsed.params.id)
40360
41334
  });
40361
41335
  } catch (err) {
41336
+ if (isUniqueViolation(err, "user_external_ids")) {
41337
+ jsonError(res, "identity_taken", 409);
41338
+ return true;
41339
+ }
40362
41340
  jsonError(res, err instanceof Error ? err.message : "Failed to link identity", 400);
40363
41341
  }
40364
41342
  return true;
@@ -42013,7 +42991,8 @@ var retryWorkflowRunRoute = route({
42013
42991
  params: object2({ id: string2() }),
42014
42992
  responses: {
42015
42993
  200: { description: "Retry started", schema: SuccessResponseSchema },
42016
- 400: { description: "Cannot retry" }
42994
+ 400: { description: "Cannot retry" },
42995
+ 404: { description: "Run not found" }
42017
42996
  }
42018
42997
  });
42019
42998
  var cancelWorkflowRunRoute = route({
@@ -42314,7 +43293,11 @@ async function handleWorkflows(req, res, pathSegments, queryParams, myAgentId) {
42314
43293
  res.end();
42315
43294
  return true;
42316
43295
  }
42317
- jsonError(res, result.reason === "patch" ? result.errors.join("; ") : `Invalid definition: ${result.errors.join("; ")}`, 400);
43296
+ if (result.reason === "patch") {
43297
+ jsonError(res, result.errors.join("; "), 404);
43298
+ return true;
43299
+ }
43300
+ jsonError(res, `Invalid definition: ${result.errors.join("; ")}`, 400);
42318
43301
  return true;
42319
43302
  }
42320
43303
  patchWorkflowNodeRoute.respond(res, 200, await withSaveWarnings(result.workflow));
@@ -42597,6 +43580,10 @@ async function handleWorkflows(req, res, pathSegments, queryParams, myAgentId) {
42597
43580
  const parsed = await retryWorkflowRunRoute.parse(req, res, pathSegments, queryParams);
42598
43581
  if (!parsed)
42599
43582
  return true;
43583
+ if (!await getWorkflowRunSummary(parsed.params.id)) {
43584
+ jsonError(res, `Workflow run not found: ${parsed.params.id}`, 404);
43585
+ return true;
43586
+ }
42600
43587
  try {
42601
43588
  await retryFailedRun2(parsed.params.id, getExecutorRegistry2());
42602
43589
  } catch (err) {
@@ -43045,9 +44032,10 @@ var httpServer = createHttpServer(async (req, res) => {
43045
44032
  });
43046
44033
  });
43047
44034
  var detachRealtime = attachRealtimeTransport(httpServer);
43048
- var { attachControllerTransport } = await import("./controllers-connect-xx8x64n5.js");
44035
+ var { attachControllerTransport } = await import("./controllers-connect-m7d4vxxb.js");
43049
44036
  var detachControllers = attachControllerTransport(httpServer);
43050
44037
  var stopWorkerNudges = startWorkerNudgeListener();
44038
+ var taskAutoTitles = startTaskAutoTitleListener();
43051
44039
  var stopRoomDeletion = realtimeBus.subscribe("room:namespace-deleted", (namespace) => {
43052
44040
  Promise.resolve(removeNamespaceRooms(String(namespace))).catch((error) => console.error("[rooms] Deletion failed:", scrubSecrets(String(error))));
43053
44041
  });
@@ -43055,6 +44043,7 @@ globalState.__closeRealtime = () => {
43055
44043
  detachRealtime();
43056
44044
  detachControllers();
43057
44045
  stopWorkerNudges();
44046
+ taskAutoTitles.stop();
43058
44047
  stopRoomDeletion();
43059
44048
  };
43060
44049
  globalState.__httpServer = httpServer;
@@ -43074,7 +44063,7 @@ async function shutdown() {
43074
44063
  sessionsProcessed: getServerSessionsProcessed()
43075
44064
  });
43076
44065
  if (hasCapability("scheduling")) {
43077
- const { stopScheduler } = await import("./index-k08z2cak.js");
44066
+ const { stopScheduler } = await import("./index-hpfte8jd.js");
43078
44067
  stopScheduler();
43079
44068
  }
43080
44069
  stopHeartbeat2();
@@ -43086,7 +44075,7 @@ async function shutdown() {
43086
44075
  await stopSlackApp2();
43087
44076
  await stopChatSdk();
43088
44077
  if (!isEnvFlagEnabled("OAUTH_KEEPALIVE_DISABLE", false)) {
43089
- const { stopOAuthKeepalive } = await import("./keepalive-w56f32cg.js");
44078
+ const { stopOAuthKeepalive } = await import("./keepalive-qnt21cv0.js");
43090
44079
  await stopOAuthKeepalive();
43091
44080
  }
43092
44081
  stopOAuthPendingGc();
@@ -43168,21 +44157,21 @@ try {
43168
44157
  console.warn("[startup] CAPABILITIES upgrade seed failed (non-fatal):", err);
43169
44158
  }
43170
44159
  try {
43171
- const { ensurePricingSeeded } = await import("./boot-seeds-yr00k13d.js");
44160
+ const { ensurePricingSeeded } = await import("./boot-seeds-n46eaxdv.js");
43172
44161
  ensurePricingSeeded();
43173
- const { startPricingRefreshLoop } = await import("./pricing-refresh-n2x7jh6k.js");
44162
+ const { startPricingRefreshLoop } = await import("./pricing-refresh-9fcbnq3f.js");
43174
44163
  startPricingRefreshLoop();
43175
44164
  } catch (err) {
43176
44165
  console.error("[startup] Failed to seed pricing rows:", err);
43177
44166
  }
43178
44167
  try {
43179
- const { ensureModelProfilesSeeded } = await import("./boot-seeds-yr00k13d.js");
44168
+ const { ensureModelProfilesSeeded } = await import("./boot-seeds-n46eaxdv.js");
43180
44169
  await ensureModelProfilesSeeded();
43181
44170
  } catch (err) {
43182
44171
  console.error("[startup] Failed to seed model profiles:", err);
43183
44172
  }
43184
44173
  try {
43185
- const { ensureRbacSeeded } = await import("./boot-seeds-yr00k13d.js");
44174
+ const { ensureRbacSeeded } = await import("./boot-seeds-n46eaxdv.js");
43186
44175
  ensureRbacSeeded();
43187
44176
  } catch (err) {
43188
44177
  console.error("[startup] Failed to sync RBAC seed rows:", err);
@@ -43190,7 +44179,7 @@ try {
43190
44179
  throw err;
43191
44180
  }
43192
44181
  try {
43193
- const { runAllSeeders } = await import("./index-rvr00sg7.js");
44182
+ const { runAllSeeders } = await import("./index-bxrexmfy.js");
43194
44183
  await runAllSeeders({ scriptEmbeddingMode: "skip" });
43195
44184
  } catch (err) {
43196
44185
  console.error("[startup] Failed to seed built-in entities:", err);
@@ -43253,26 +44242,26 @@ httpServer.listen(port, async () => {
43253
44242
  await initWorkflows2();
43254
44243
  await startScriptRunSupervisor(getMcpBaseUrl());
43255
44244
  if (hasCapability("scheduling")) {
43256
- const { startScheduler } = await import("./index-k08z2cak.js");
43257
- const { getExecutorRegistry } = await import("./index-4f2pvxae.js");
44245
+ const { startScheduler } = await import("./index-hpfte8jd.js");
44246
+ const { getExecutorRegistry } = await import("./index-vte6dyeh.js");
43258
44247
  const intervalMs = Number(process.env.SCHEDULER_INTERVAL_MS) || 1e4;
43259
44248
  startScheduler(getExecutorRegistry(), intervalMs, {
43260
44249
  runId: globalState.__runId
43261
44250
  });
43262
44251
  }
43263
44252
  if (!isEnvFlagEnabled("HEARTBEAT_DISABLE", false)) {
43264
- const { startHeartbeat } = await import("./index-98gz7tmp.js");
44253
+ const { startHeartbeat } = await import("./index-ncf7yb5s.js");
43265
44254
  const heartbeatMs = Number(process.env.HEARTBEAT_INTERVAL_MS) || 90000;
43266
44255
  startHeartbeat(heartbeatMs);
43267
44256
  }
43268
44257
  startPoolRouting();
43269
44258
  startRuntimeSupervisor();
43270
44259
  if (!isEnvFlagEnabled("OAUTH_KEEPALIVE_DISABLE", false)) {
43271
- const { startOAuthKeepalive } = await import("./keepalive-w56f32cg.js");
44260
+ const { startOAuthKeepalive } = await import("./keepalive-qnt21cv0.js");
43272
44261
  startOAuthKeepalive();
43273
44262
  }
43274
44263
  if (!isEnvFlagEnabled("OAUTH_REFRESH_SWEEP_DISABLE", false)) {
43275
- const { startOAuthRefreshSweep } = await import("./oauth-refresh-sweep-29txy9vk.js");
44264
+ const { startOAuthRefreshSweep } = await import("./oauth-refresh-sweep-vczabeh4.js");
43276
44265
  startOAuthRefreshSweep();
43277
44266
  }
43278
44267
  startOAuthPendingGc();
@@ -43281,16 +44270,19 @@ httpServer.listen(port, async () => {
43281
44270
  await startDbRetention();
43282
44271
  startHumanFreeDrain();
43283
44272
  startTaskSearchBackfill();
43284
- import("./embedding-space-ny1e2940.js").then(({ runEmbeddingMaintenance, setDeploymentEnvReader }) => {
44273
+ import("./embedding-space-b4txbwrk.js").then(({ runEmbeddingMaintenance, setDeploymentEnvReader }) => {
43285
44274
  setDeploymentEnvReader(getDeploymentEnvValue);
43286
44275
  return runEmbeddingMaintenance({ backfill: true });
43287
44276
  }).catch((err) => {
43288
44277
  console.error("[embedding-space] startup maintenance failed (non-fatal):", err);
43289
44278
  });
43290
- import("./boot-scrub-sweep-4qfd4kfx.js").then(({ runBootScrubSweep }) => runBootScrubSweep()).catch((err) => {
44279
+ import("./boot-args-schema-tjrkpbvm.js").then(({ runBootArgsSchemaBackfill }) => runBootArgsSchemaBackfill()).catch((err) => {
44280
+ console.error("[boot-args-schema] startup backfill failed (non-fatal):", err);
44281
+ });
44282
+ import("./boot-scrub-sweep-qy0zr9t2.js").then(({ runBootScrubSweep }) => runBootScrubSweep()).catch((err) => {
43291
44283
  console.error("[boot-scrub-sweep] startup scrub failed (non-fatal):", err);
43292
44284
  });
43293
- import("./session-source-backfill-n1czavbr.js").then(({ runSessionSourceBackfill }) => runSessionSourceBackfill()).catch((err) => {
44285
+ import("./session-source-backfill-0vscqmsa.js").then(({ runSessionSourceBackfill }) => runSessionSourceBackfill()).catch((err) => {
43294
44286
  console.error("[session-source-backfill] startup run failed (non-fatal):", err);
43295
44287
  });
43296
44288
  }).on("error", (err) => {