@desplega.ai/agent-swarm 2.11.0 → 2.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (521) hide show
  1. package/dist/acp-adapter-cn53011z.js +17 -0
  2. package/dist/{acp-targets-5wyy2b9m.js → acp-targets-86f0sh6g.js} +10 -9
  3. package/dist/{actions-4nxq386s.js → actions-zv8vcxvr.js} +25 -22
  4. package/dist/{agent-fs-provision-v6enh76w.js → agent-fs-provision-jqshb33y.js} +10 -5
  5. package/dist/{amp-adapter-ze3x22qn.js → amp-adapter-gt503ywc.js} +3 -3
  6. package/dist/{app-kyqt8ehw.js → app-6t4k5rh1.js} +7 -5
  7. package/dist/{approval-notifications-a0db0esw.js → approval-notifications-fcfw063h.js} +8 -7
  8. package/dist/{assistant-9g5jzq25.js → assistant-9dzybh12.js} +26 -23
  9. package/dist/{boot-args-schema-d7fme4q1.js → boot-args-schema-xzfp2feg.js} +1 -1
  10. package/dist/{boot-reembed-6wpazmpw.js → boot-reembed-3jz0p2jk.js} +1 -1
  11. package/dist/{boot-reembed-jrwxeye2.js → boot-reembed-r88wngfg.js} +5 -2
  12. package/dist/{boot-scrub-sweep-52h7yntp.js → boot-scrub-sweep-scrqhw48.js} +2 -2
  13. package/dist/{boot-seeds-kb3dxjex.js → boot-seeds-vb2dcrrb.js} +4 -4
  14. package/dist/{boxd-jrrmkv3w.js → boxd-68n75y1s.js} +1 -1
  15. package/dist/{claude-adapter-0c0y8fqp.js → claude-adapter-h3mp9hgs.js} +9 -8
  16. package/dist/{claude-managed-adapter-w2es07qq.js → claude-managed-adapter-kpbyj2vb.js} +4 -4
  17. package/dist/{claude-managed-setup-9ssb7ct4.js → claude-managed-setup-0efr3wkg.js} +7 -7
  18. package/dist/{claude-sdk-session-p6t0gyse.js → claude-sdk-session-03dw669q.js} +11 -10
  19. package/dist/{cli-14xdms9a.js → cli-0b655smz.js} +6 -6
  20. package/dist/{cli-wz4e5am2.js → cli-0dg7ytxm.js} +400 -72
  21. package/dist/cli-0jkenasr.js +148 -0
  22. package/dist/{cli-0bgj4rh5.js → cli-0pazkmd4.js} +4 -4
  23. package/dist/{cli-892y3vfp.js → cli-117g15t4.js} +9 -12
  24. package/dist/{cli-v3zcnr8g.js → cli-1dbv9mj9.js} +1 -1
  25. package/dist/{cli-8zmpwe79.js → cli-1v82d2w6.js} +5 -5
  26. package/dist/{cli-6tvh1fwq.js → cli-2jk4s7z1.js} +3 -3
  27. package/dist/{cli-w5dar1bk.js → cli-2m6yaq6b.js} +1 -1
  28. package/dist/{cli-atm0hkes.js → cli-2skf1mdf.js} +11 -11
  29. package/dist/{cli-6c9ve77f.js → cli-3p288654.js} +2 -2
  30. package/dist/{cli-a02habn6.js → cli-48nvk6sb.js} +3 -3
  31. package/dist/{cli-q71g5q39.js → cli-49f5jyhh.js} +3 -3
  32. package/dist/{cli-2z2c4k6q.js → cli-50w82h6m.js} +21 -0
  33. package/dist/{cli-dd2k2mcd.js → cli-6a40p4kv.js} +1 -1
  34. package/dist/{cli-rwgwen5v.js → cli-6h88mn9q.js} +4 -4
  35. package/dist/cli-7dbhnsj9.js +681 -0
  36. package/dist/{cli-k3c13za2.js → cli-7wy8gbwb.js} +1 -1
  37. package/dist/{cli-g56fxddf.js → cli-8hp56wat.js} +3 -2
  38. package/dist/{cli-rhsc2zyx.js → cli-9fsagra4.js} +1 -1
  39. package/dist/{cli-f8yhybxr.js → cli-9m9kyw77.js} +3 -3
  40. package/dist/{cli-yzxqwcvq.js → cli-ajjvqhf3.js} +10 -3
  41. package/dist/cli-avqkr20b.js +69 -0
  42. package/dist/{cli-nbakg5xh.js → cli-avxh26pd.js} +46 -15
  43. package/dist/{cli-n6ygvrrm.js → cli-b2jh3dyb.js} +4 -4
  44. package/dist/{cli-9yjhshah.js → cli-bhgrhedp.js} +1 -1
  45. package/dist/{cli-7e8sxqv5.js → cli-bpje8n65.js} +30 -3
  46. package/dist/{cli-czvvnfr9.js → cli-c8v2yvej.js} +2 -2
  47. package/dist/{cli-raqw9fw9.js → cli-ct8sz3np.js} +18 -11
  48. package/dist/{cli-t2s7j5cy.js → cli-dka73bak.js} +2 -2
  49. package/dist/{cli-tb4j757d.js → cli-dkejt425.js} +76 -17
  50. package/dist/{cli-27fat7st.js → cli-dnh64e8e.js} +7 -7
  51. package/dist/{cli-453497a0.js → cli-eb279wn3.js} +2 -2
  52. package/dist/{cli-bf0t77nf.js → cli-ercwc8xn.js} +1 -1
  53. package/dist/{cli-qncx2r0s.js → cli-ex1y88j3.js} +1 -1
  54. package/dist/{cli-vy3fn0mz.js → cli-f1952kjy.js} +4 -4
  55. package/dist/{cli-1h4njv9y.js → cli-f8rcvf2x.js} +58 -13
  56. package/dist/{cli-xqbqwpxr.js → cli-fhvk2nvp.js} +26 -13
  57. package/dist/{cli-2jtfm8kh.js → cli-fz9pcjsw.js} +4 -4
  58. package/dist/{cli-bq97k63w.js → cli-g6j6ac3h.js} +2 -2
  59. package/dist/{cli-f7dhm7hh.js → cli-gfcv679k.js} +1 -1
  60. package/dist/cli-hbq0kwxz.js +252 -0
  61. package/dist/{cli-nc39ym5q.js → cli-hc6e4tac.js} +29 -150
  62. package/dist/{cli-m00c47q6.js → cli-hgsxnjyg.js} +58 -25
  63. package/dist/{cli-s9twe4x0.js → cli-hpb9x72z.js} +58 -13
  64. package/dist/{cli-9g12h1aq.js → cli-j53hpbsm.js} +2 -2
  65. package/dist/{cli-zhn4r1rz.js → cli-jj3c5nyb.js} +519 -144
  66. package/dist/{cli-ha4ek2nb.js → cli-js10kdk7.js} +1 -1
  67. package/dist/{cli-kbm659dk.js → cli-kde4ky90.js} +2 -2
  68. package/dist/{cli-4aswccje.js → cli-kspxjftk.js} +2 -2
  69. package/dist/{cli-p8zqbbt1.js → cli-m4ejz4nj.js} +1 -1
  70. package/dist/{cli-htymm48w.js → cli-mbwmqb5w.js} +1 -1
  71. package/dist/{cli-b82a13ga.js → cli-mh7pdxe0.js} +23 -27
  72. package/dist/{cli-rpmw4fsv.js → cli-mz34pxbk.js} +12 -12
  73. package/dist/{cli-ramn8jae.js → cli-n85m2wkq.js} +1 -1
  74. package/dist/{cli-cstggwq7.js → cli-nc6a8b5b.js} +7 -4
  75. package/dist/{cli-3bpr3wks.js → cli-pqfecppn.js} +1 -1
  76. package/dist/{cli-j2r1apqm.js → cli-prf7kz78.js} +59 -58
  77. package/dist/{cli-2gvdvsxj.js → cli-qec9bynj.js} +63 -60
  78. package/dist/{cli-zb1hff00.js → cli-qhhb30e8.js} +12 -12
  79. package/dist/{cli-h2qtafm4.js → cli-qm3ntjqs.js} +21 -21
  80. package/dist/{cli-5ptj757f.js → cli-rfejbpe1.js} +1 -1
  81. package/dist/{cli-fwjwkw66.js → cli-rtmqzat7.js} +2 -2
  82. package/dist/{cli-zqq57pgx.js → cli-s6zk31gr.js} +4 -4
  83. package/dist/{cli-mhrr4d5b.js → cli-sdh61g52.js} +38 -20
  84. package/dist/{cli-7cp6aa1q.js → cli-skd2c4ej.js} +25 -178
  85. package/dist/{cli-ynph3b70.js → cli-sq913bh1.js} +8 -8
  86. package/dist/{cli-hnh8erra.js → cli-t35hx078.js} +2 -2
  87. package/dist/{cli-r813c7rb.js → cli-tdk7jtka.js} +1 -1
  88. package/dist/{cli-yvzxbztc.js → cli-tn91wc6e.js} +2 -2
  89. package/dist/{cli-075ccjh6.js → cli-tstj6e8e.js} +3660 -232
  90. package/dist/{cli-4g323fjh.js → cli-w14j2z4k.js} +2 -2
  91. package/dist/{cli-4kzp7r0q.js → cli-wndegmns.js} +3 -3
  92. package/dist/{cli-p1a4khta.js → cli-wrhbym01.js} +10 -10
  93. package/dist/{cli-djt6wmrc.js → cli-wv20kbr3.js} +9 -9
  94. package/dist/{cli-2aacfdcn.js → cli-wxwv3t11.js} +64 -3
  95. package/dist/{cli-rytq7dm2.js → cli-xfjn2kyq.js} +59 -5
  96. package/dist/cli-y260hgep.js +186 -0
  97. package/dist/{cli-9knhkkgr.js → cli-y4a4458j.js} +3 -3
  98. package/dist/{cli-a6q6x15h.js → cli-y518qkjg.js} +10 -5
  99. package/dist/{cli-0b4zam62.js → cli-yfvhvw8m.js} +20 -0
  100. package/dist/cli-yn4kt85g.js +148 -0
  101. package/dist/{cli-k4r5sfaj.js → cli-ytc7fpza.js} +11 -11
  102. package/dist/{cli-thd3005a.js → cli-z4f346g5.js} +1 -1
  103. package/dist/{cli-6n7y5ypy.js → cli-z64t9pe6.js} +1 -1
  104. package/dist/{cli-6a3j25xd.js → cli-zqmmy073.js} +200 -20
  105. package/dist/cli.js +27 -22
  106. package/dist/{codex-adapter-ssahg4h4.js → codex-adapter-f3yp0kaj.js} +8 -8
  107. package/dist/{codex-hook-aqtj17yr.js → codex-hook-262cekfp.js} +73 -2
  108. package/dist/{codex-login-9c7aggxe.js → codex-login-1ven7yje.js} +1 -1
  109. package/dist/{codex-session-runner-xn63q3h7.js → codex-session-runner-ns4mv70p.js} +9 -9
  110. package/dist/{commands-ctey7tr5.js → commands-5bzf2tfw.js} +3 -3
  111. package/dist/{controller-rqhbppg9.js → controller-5xt7kvfm.js} +4 -4
  112. package/dist/{controllers-connect-w3qbpbt1.js → controllers-connect-0gg13mzp.js} +26 -23
  113. package/dist/core-0fqtbrxa.js +42 -0
  114. package/dist/{cursor-adapter-r819hf1a.js → cursor-adapter-p0c5zv6r.js} +2 -2
  115. package/dist/{db-p5drc1d1.js → db-2s68ycq7.js} +3 -3
  116. package/dist/{db-2ah39cyx.js → db-q7q639k5.js} +8 -2
  117. package/dist/{devin-adapter-bc6g0x29.js → devin-adapter-t8d86q9x.js} +1 -1
  118. package/dist/{dispatcher-x6w14pde.js → dispatcher-j2y1q7ae.js} +25 -20
  119. package/dist/{docker-6c4reetq.js → docker-1b41eysj.js} +2 -2
  120. package/dist/{dsh-adapter-h8qn14n4.js → dsh-adapter-pgnkf4st.js} +2 -2
  121. package/dist/{e2b-z4ec0qve.js → e2b-ew8c5j5v.js} +2 -2
  122. package/dist/{e2b-jg7kyyef.js → e2b-xm60c8ad.js} +2 -2
  123. package/dist/{easter-egg-3d-1y6r9gxy.js → easter-egg-3d-0kea97jf.js} +1 -1
  124. package/dist/{embedding-space-z6ptw3jk.js → embedding-space-3n6mhhmy.js} +6 -6
  125. package/dist/{embeddings-0sxb1d2h.js → embeddings-jfmj6yme.js} +1 -1
  126. package/dist/{event-bus-swr88jg5.js → event-bus-v4ywhc2p.js} +1 -1
  127. package/dist/{execute-6m1ex8ce.js → execute-tjrej979.js} +1 -1
  128. package/dist/{external-channel-ezer7pk0.js → external-channel-jy8w2gg3.js} +2 -2
  129. package/dist/fx-adapter-k6w3jvz9.js +20 -0
  130. package/dist/grok-adapter-4q5tssw0.js +20 -0
  131. package/dist/handlers-qxgfvvsf.js +41 -0
  132. package/dist/{heartbeat-6c4fr49t.js → heartbeat-6tr2w2da.js} +26 -23
  133. package/dist/{hook-02rt5tvq.js → hook-bpnncsec.js} +77 -18
  134. package/dist/{hook-t1c5avbv.js → hook-fv1jwrv7.js} +6 -5
  135. package/dist/{http-qa3h32a1.js → http-bpa26czn.js} +1277 -249
  136. package/dist/index-0mcxjdsa.js +44 -0
  137. package/dist/{index-akbgsdhh.js → index-52tgbhrw.js} +30 -27
  138. package/dist/index-dz4q23ag.js +40 -0
  139. package/dist/{index-kqv9ebfj.js → index-mpj0z9e0.js} +1 -1
  140. package/dist/index-s175jckx.js +39 -0
  141. package/dist/{index-qpjk2hxk.js → index-s8re7mvq.js} +1 -1
  142. package/dist/{index-e42j998x.js → index-w216g9y9.js} +222 -165
  143. package/dist/{k8s-7jrh5va2.js → k8s-fy8hbhkg.js} +2 -2
  144. package/dist/{keepalive-jmf6pn8c.js → keepalive-d6z12s04.js} +4 -4
  145. package/dist/lead-p3hx7h35.js +79 -0
  146. package/dist/{maintenance-g7v15tj1.js → maintenance-7kac6g2g.js} +1 -1
  147. package/dist/{oauth-refresh-sweep-ywgf8tbr.js → oauth-refresh-sweep-t1xjetbh.js} +3 -3
  148. package/dist/object-webhooks-6rdagg0r.js +21 -0
  149. package/dist/{onboard-m3fedypq.js → onboard-32y1cfxy.js} +5 -5
  150. package/dist/{opencode-adapter-19ktcbb9.js → opencode-adapter-enp3v31n.js} +8 -7
  151. package/dist/{otel-impl-3ehm1hgc.js → otel-impl-k0tm5ptj.js} +2 -2
  152. package/dist/{pending-fwj2fatd.js → pending-24zebgvs.js} +24 -21
  153. package/dist/{pi-mono-adapter-xdeesvc4.js → pi-mono-adapter-yj72xxxe.js} +89 -20
  154. package/dist/{pricing-refresh-4j8dzvxg.js → pricing-refresh-cf25x38j.js} +2 -2
  155. package/dist/{rbac-roles-8msjr07m.js → rbac-roles-0wydd22m.js} +3 -3
  156. package/dist/{rbac-roles-n7t2acv8.js → rbac-roles-at6crb3r.js} +7 -4
  157. package/dist/{registry-32b1mft6.js → registry-zv0zvxsx.js} +1 -1
  158. package/dist/{render-v2-j7qggj8h.js → render-v2-nvcw0jd7.js} +9 -5
  159. package/dist/{resume-hj1mn65y.js → resume-y4w0k5v3.js} +10 -9
  160. package/dist/{runtime-z31mdsgv.js → runtime-vpe43hx0.js} +1 -1
  161. package/dist/{session-access-w38fh09a.js → session-access-gkyvnfye.js} +5 -4
  162. package/dist/{session-source-backfill-ax6qxv20.js → session-source-backfill-3w2st4m2.js} +3 -3
  163. package/dist/{setup-dsqmpfcr.js → setup-axxvqtys.js} +1 -1
  164. package/dist/thread-buffer-rwa7d4dx.js +42 -0
  165. package/dist/{tree-visibility-6vqmnr71.js → tree-visibility-y4fqvab5.js} +2 -2
  166. package/dist/{user-merge-jobs-mvheb3ed.js → user-merge-jobs-kcmwvrc6.js} +3 -3
  167. package/dist/{virtual-modules-w2qk2wew.js → virtual-modules-7d92dct1.js} +3 -3
  168. package/dist/{work-objects-4ahy5es5.js → work-objects-f708e069.js} +28 -24
  169. package/dist/worker-8rg9gz74.js +79 -0
  170. package/dist/{worker-follow-up-1gs4aw7y.js → worker-follow-up-0by8wztc.js} +23 -20
  171. package/dist/{x-3wr8c5sh.js → x-3dtaf2r9.js} +2 -2
  172. package/dist/xlsx-9acfmxr1.js +31534 -0
  173. package/openapi.json +5227 -3511
  174. package/package.json +10 -5
  175. package/src/agentmail/handlers.ts +26 -19
  176. package/src/apps/catalog.generated.json +31 -0
  177. package/src/apps/row-store.ts +37 -14
  178. package/src/azure-devops/auth.ts +2 -3
  179. package/src/azure-devops/handlers.ts +2 -0
  180. package/src/be/agent-fs-identity.ts +46 -0
  181. package/src/be/agent-history.ts +215 -0
  182. package/src/be/audit-user.ts +46 -6
  183. package/src/be/db/agents.ts +34 -12
  184. package/src/be/db/kv-windows.ts +22 -0
  185. package/src/be/db/session-moves.ts +3 -3
  186. package/src/be/db/session-tree.ts +52 -5
  187. package/src/be/db/skill-audit.ts +17 -0
  188. package/src/be/db/tasks/write.ts +20 -5
  189. package/src/be/db.ts +116 -23
  190. package/src/be/extensions/assets.ts +11 -7
  191. package/src/be/memory/demotion-evidence.ts +2 -2
  192. package/src/be/memory/providers/sqlite-store.ts +151 -18
  193. package/src/be/memory/search-read-worker.ts +60 -0
  194. package/src/be/memory/search-reader.ts +223 -0
  195. package/src/be/migrations/332_primitive_objects.sql +31 -0
  196. package/src/be/migrations/334_agent_history.sql +23 -0
  197. package/src/be/migrations/335_primitive_object_webhooks.sql +36 -0
  198. package/src/be/migrations/337_favorites_session_hidden_key.sql +39 -0
  199. package/src/be/migrations/338_audit_agent_columns.sql +30 -0
  200. package/src/be/migrations/339_deferred_event_waits.sql +26 -0
  201. package/src/be/model-tier-resolution.ts +18 -1
  202. package/src/be/multi-runtime.ts +17 -0
  203. package/src/be/primitives/boards/elements.ts +717 -0
  204. package/src/be/primitives/boards/excalifont-metrics.json +516 -0
  205. package/src/be/primitives/boards/service.ts +121 -0
  206. package/src/be/primitives/object-embed.ts +250 -0
  207. package/src/be/primitives/object-webhooks.ts +348 -0
  208. package/src/be/primitives/objects.ts +706 -0
  209. package/src/be/primitives/sheets/a1.ts +136 -0
  210. package/src/be/primitives/sheets/engine-worker.ts +194 -0
  211. package/src/be/primitives/sheets/engine.ts +199 -0
  212. package/src/be/primitives/sheets/format.ts +106 -0
  213. package/src/be/primitives/sheets/service.ts +547 -0
  214. package/src/be/primitives/sheets/xlsx.ts +367 -0
  215. package/src/be/primitives/write-object.ts +83 -0
  216. package/src/be/rbac-roles.ts +3 -0
  217. package/src/be/repo-checked-update.ts +4 -4
  218. package/src/be/repo-merge-policy.ts +26 -9
  219. package/src/be/script-credential-broker.ts +8 -27
  220. package/src/be/scripts/boot-reembed.ts +6 -0
  221. package/src/be/scripts/db.ts +17 -5
  222. package/src/be/scripts/embeddings.ts +6 -0
  223. package/src/be/scripts/typecheck.ts +257 -0
  224. package/src/be/seed/agent-fs-provision.ts +18 -0
  225. package/src/be/seed/schedules-seeder.ts +9 -1
  226. package/src/be/seed/workflows-seeder.ts +9 -1
  227. package/src/be/seed-scripts/index.ts +2 -0
  228. package/src/be/seed-skills/index.ts +12 -0
  229. package/src/be/swarm-config-guard.ts +1 -0
  230. package/src/be/unmapped-identities.ts +95 -1
  231. package/src/be/users.ts +19 -0
  232. package/src/bitbucket/handlers.ts +2 -0
  233. package/src/commands/onboard/agent-fs-version.ts +1 -1
  234. package/src/commands/onboard/steps/harness.tsx +1 -1
  235. package/src/commands/provider-credentials.ts +1 -0
  236. package/src/e2b/env.ts +3 -1
  237. package/src/event-waits/github.ts +43 -0
  238. package/src/event-waits/index.ts +29 -0
  239. package/src/event-waits/types.ts +51 -0
  240. package/src/extensions/contract-types.generated.ts +1 -1
  241. package/src/extensions/dispatcher.ts +9 -0
  242. package/src/fs/agent-fs-provider.ts +37 -3
  243. package/src/github/handlers.ts +3 -1
  244. package/src/github/pull-request-state.ts +34 -0
  245. package/src/gitlab/auth.ts +3 -4
  246. package/src/gitlab/handlers.ts +12 -7
  247. package/src/heartbeat/heartbeat.ts +11 -11
  248. package/src/hooks/codex-hook.ts +99 -1
  249. package/src/hooks/hook.ts +85 -11
  250. package/src/hooks/native-tool-hooks.ts +245 -0
  251. package/src/http/agent-lifecycle.ts +152 -0
  252. package/src/http/agents.ts +12 -0
  253. package/src/http/all-routes.ts +3 -0
  254. package/src/http/assets.ts +4 -3
  255. package/src/http/auth.ts +2 -1
  256. package/src/http/comb.ts +2 -2
  257. package/src/http/favorite-owner.ts +2 -2
  258. package/src/http/favorites.ts +3 -2
  259. package/src/http/fs.ts +13 -4
  260. package/src/http/index.ts +17 -0
  261. package/src/http/mcp-bridge.ts +4 -0
  262. package/src/http/object-webhooks.ts +101 -0
  263. package/src/http/objects.ts +265 -0
  264. package/src/http/operator-actor.ts +2 -1
  265. package/src/http/pages.ts +3 -3
  266. package/src/http/poll.ts +43 -12
  267. package/src/http/repos.ts +7 -6
  268. package/src/http/schedules.ts +10 -6
  269. package/src/http/script-connections.ts +2 -2
  270. package/src/http/scripts.ts +9 -0
  271. package/src/http/sessions.ts +37 -12
  272. package/src/http/skills.ts +17 -0
  273. package/src/http/task-requester.ts +2 -2
  274. package/src/http/tasks.ts +13 -3
  275. package/src/http/tool-hooks.ts +24 -2
  276. package/src/http/trackers/authorize-gate.ts +2 -2
  277. package/src/http/users.ts +136 -1
  278. package/src/http/workflow-events.ts +13 -0
  279. package/src/http/workflows.ts +47 -5
  280. package/src/integrations/chat-sdk/outbound-files.ts +3 -2
  281. package/src/linear/sync.ts +3 -1
  282. package/src/prompts/base-prompt.ts +35 -13
  283. package/src/prompts/session-templates.ts +25 -0
  284. package/src/providers/acp-targets.ts +2 -2
  285. package/src/providers/amp-adapter.ts +1 -1
  286. package/src/providers/dsh-adapter.ts +1 -1
  287. package/src/providers/opencode-adapter.ts +5 -1
  288. package/src/providers/opencode-swarm-plugin.ts +50 -1
  289. package/src/providers/pi-mono-adapter.ts +139 -9
  290. package/src/providers/pi-mono-extension.ts +69 -0
  291. package/src/providers/runtime-dependencies.ts +1 -1
  292. package/src/rbac/legacy-policy.ts +5 -0
  293. package/src/rbac/permissions.ts +16 -1
  294. package/src/scheduler/deferred-task-waits.ts +170 -13
  295. package/src/script-workflows/guest-ctx.ts +32 -0
  296. package/src/script-workflows/workflow-ctx.ts +2 -0
  297. package/src/scripts-runtime/ctx.ts +9 -1
  298. package/src/scripts-runtime/executors/native.ts +106 -21
  299. package/src/scripts-runtime/executors/quickjs-prelude.ts +9 -2
  300. package/src/scripts-runtime/executors/quickjs-runner.ts +12 -1
  301. package/src/scripts-runtime/executors/types.ts +5 -0
  302. package/src/scripts-runtime/loader.ts +8 -0
  303. package/src/scripts-runtime/mcp-client.ts +4 -0
  304. package/src/scripts-runtime/sdk-allowlist.ts +101 -0
  305. package/src/scripts-runtime/swarm-config.ts +8 -0
  306. package/src/scripts-runtime/swarm-sdk.ts +55 -3
  307. package/src/scripts-runtime/types/stdlib.d.ts +310 -0
  308. package/src/scripts-runtime/types/swarm-extension.d.ts +1 -0
  309. package/src/scripts-runtime/types/swarm-sdk.d.ts +310 -0
  310. package/src/server.ts +52 -0
  311. package/src/slack/enrich.ts +81 -21
  312. package/src/slack/handlers.test.ts +55 -2
  313. package/src/slack/handlers.ts +38 -3
  314. package/src/slack/render-v2.ts +19 -0
  315. package/src/slack/session-mirror.ts +208 -0
  316. package/src/slack/thread-participants.ts +0 -5
  317. package/src/slack/watcher.ts +3 -0
  318. package/src/slack/work-objects.test.ts +2 -1
  319. package/src/slack/work-objects.ts +7 -2
  320. package/src/tests/agent-history.test.ts +313 -0
  321. package/src/tests/agentmail-filters.test.ts +4 -3
  322. package/src/tests/audit-agent-person.test.ts +825 -0
  323. package/src/tests/audit-updated-by.test.ts +19 -12
  324. package/src/tests/azure-devops-auth.test.ts +6 -0
  325. package/src/tests/chat-sdk-outbound-files.test.ts +3 -1
  326. package/src/tests/check-unit-test-allowlist.test.ts +193 -0
  327. package/src/tests/claude-hook-output.test.ts +107 -2
  328. package/src/tests/claude-managed-setup.test.ts +1 -1
  329. package/src/tests/codex-adapter.test.ts +6 -6
  330. package/src/tests/codex-gpt6-release.test.ts +4 -4
  331. package/src/tests/credential-check.test.ts +12 -0
  332. package/src/tests/db-task-read-contract.test.ts +3 -0
  333. package/src/tests/db-task-write-contract.test.ts +3 -0
  334. package/src/tests/dsh-adapter.test.ts +1 -1
  335. package/src/tests/e2e-coverage-contract.test.ts +6 -2
  336. package/src/tests/e2e-diff-coverage.test.ts +154 -0
  337. package/src/tests/e2e-rerun-quarantine.test.ts +180 -0
  338. package/src/tests/e2e-shards.test.ts +137 -0
  339. package/src/tests/e2e-tracker-ingest.test.ts +266 -0
  340. package/src/tests/extensions-catalog.test.ts +33 -25
  341. package/src/tests/extensions-heartbeat.test.ts +34 -0
  342. package/src/tests/fixtures/sheets/eocd-count-mismatch.xlsx +0 -0
  343. package/src/tests/fixtures/sheets/rich-budget.xlsx +0 -0
  344. package/src/tests/fixtures/sheets/tracker-export.xlsx +0 -0
  345. package/src/tests/gitlab-auth.test.ts +10 -0
  346. package/src/tests/heartbeat.test.ts +38 -0
  347. package/src/tests/http-api-integration.test.ts +0 -6
  348. package/src/tests/kv-storage.test.ts +3 -0
  349. package/src/tests/memory-search-reader.test.ts +258 -0
  350. package/src/tests/memory-search-stall.test.ts +197 -20
  351. package/src/tests/model-control.test.ts +4 -4
  352. package/src/tests/model-tier-resolution.test.ts +2 -2
  353. package/src/tests/multi-runtime-registration.test.ts +8 -2
  354. package/src/tests/native-tool-hooks.test.ts +188 -0
  355. package/src/tests/opencode-adapter.test.ts +11 -0
  356. package/src/tests/opencode-swarm-plugin.test.ts +6 -1
  357. package/src/tests/pi-provider-runtime-keys.test.ts +163 -0
  358. package/src/tests/poll-probe-readonly.test.ts +108 -0
  359. package/src/tests/primitives-boards.test.ts +686 -0
  360. package/src/tests/primitives-object-webhooks.test.ts +642 -0
  361. package/src/tests/primitives-objects.test.ts +248 -0
  362. package/src/tests/primitives-sheets-xlsx.test.ts +549 -0
  363. package/src/tests/prompt-template-session.test.ts +3 -2
  364. package/src/tests/rbac-roles.test.ts +3 -0
  365. package/src/tests/reasoning-kind-ui-parity.test.ts +112 -0
  366. package/src/tests/script-connections.test.ts +4 -0
  367. package/src/tests/script-native-sandbox-identity.test.ts +264 -0
  368. package/src/tests/scripts-namespaces.test.ts +211 -0
  369. package/src/tests/secret-scrub-gate.test.ts +1 -0
  370. package/src/tests/secret-scrubber-convex.test.ts +168 -0
  371. package/src/tests/secret-scrubber.test.ts +1 -1
  372. package/src/tests/seed-model-profiles.test.ts +1 -1
  373. package/src/tests/session-tokens.test.ts +27 -0
  374. package/src/tests/sessions-tree.test.ts +10 -2
  375. package/src/tests/sheet-engine.test.ts +58 -0
  376. package/src/tests/slack-file-tools-attachments.test.ts +74 -6
  377. package/src/tests/slack-read-boundaries.test.ts +4 -2
  378. package/src/tests/slack-thread-participants.test.ts +66 -4
  379. package/src/tests/task-start-after-commit.test.ts +82 -0
  380. package/src/tests/tool-registrar-no-input.test.ts +1 -0
  381. package/src/tests/ui-logs-parser.test.ts +67 -0
  382. package/src/tests/workflow-retry-v2.test.ts +101 -0
  383. package/src/tests/workflow-tla-races.test.ts +29 -0
  384. package/src/tools/boards.ts +260 -0
  385. package/src/tools/defer-task.ts +154 -12
  386. package/src/tools/objects.ts +196 -0
  387. package/src/tools/repos/update-repo.ts +6 -6
  388. package/src/tools/schedules/create-schedule.ts +1 -0
  389. package/src/tools/schedules/list-schedules.ts +3 -0
  390. package/src/tools/schedules/patch-schedule.ts +12 -3
  391. package/src/tools/schedules/update-schedule.ts +12 -3
  392. package/src/tools/sheets.ts +378 -0
  393. package/src/tools/skills/skill-create.ts +6 -0
  394. package/src/tools/skills/skill-install-remote.ts +6 -0
  395. package/src/tools/skills/skill-sync-remote.ts +9 -0
  396. package/src/tools/skills/skill-update.ts +9 -1
  397. package/src/tools/slack-read.ts +10 -3
  398. package/src/tools/tool-config.ts +25 -0
  399. package/src/tools/utils.ts +15 -0
  400. package/src/tools/workflows/create-workflow.ts +20 -5
  401. package/src/tools/workflows/patch-workflow-node.ts +5 -1
  402. package/src/tools/workflows/patch-workflow.ts +9 -2
  403. package/src/tools/workflows/update-workflow.ts +27 -4
  404. package/src/types.ts +112 -12
  405. package/src/utils/sandboxed-process.ts +47 -2
  406. package/src/utils/secret-scrubber.ts +61 -6
  407. package/src/workflows/engine.ts +35 -21
  408. package/src/workflows/input.ts +36 -1
  409. package/src/workflows/patch-definition.ts +24 -2
  410. package/src/workflows/retry-poller.ts +15 -2
  411. package/src/workflows/triggers.ts +11 -6
  412. package/src/workflows/validation.ts +10 -0
  413. package/src/workflows/version.ts +7 -1
  414. package/templates/ai-toolbox.manifest.json +1 -1
  415. package/templates/skills/agent-browser/SKILL.md +1 -0
  416. package/templates/skills/agent-browser/content.md +1 -0
  417. package/templates/skills/boards-and-sheets/config.json +14 -0
  418. package/templates/skills/boards-and-sheets/content.md +163 -0
  419. package/templates/skills/pages/content.md +5 -0
  420. package/templates/skills/swarm-docs/content.md +15 -1
  421. package/templates/skills/swarm-scripts/SKILL.md +1 -0
  422. package/templates/skills/swarm-scripts/content.md +1 -0
  423. package/templates/skills/tdd-planning/content.md +5 -2
  424. package/dist/acp-adapter-weaaxey3.js +0 -16
  425. package/dist/core-df1n049h.js +0 -39
  426. package/dist/fx-adapter-zwmps9re.js +0 -19
  427. package/dist/grok-adapter-q0avf919.js +0 -19
  428. package/dist/handlers-g5jq0e4q.js +0 -36
  429. package/dist/index-1f6m47mq.js +0 -37
  430. package/dist/index-1p1mpqda.js +0 -36
  431. package/dist/index-tnkd410q.js +0 -41
  432. package/dist/lead-m5e7xt93.js +0 -75
  433. package/dist/thread-buffer-nf55vwx3.js +0 -39
  434. package/dist/worker-ews1nyhw.js +0 -75
  435. package/src/slack/socket-mode-guard.test.ts +0 -25
  436. package/src/tests/agent-activity.test.ts +0 -247
  437. package/src/tests/agent-fs-live-url.test.ts +0 -55
  438. package/src/tests/agentmail-inbox-mapping.test.ts +0 -73
  439. package/src/tests/approval-sweeps-config.test.ts +0 -47
  440. package/src/tests/cards.test.ts +0 -169
  441. package/src/tests/chat-sdk-facts.test.ts +0 -23
  442. package/src/tests/config-env-export-chat-sdk.test.ts +0 -11
  443. package/src/tests/core-auth.test.ts +0 -156
  444. package/src/tests/date-utils.test.ts +0 -48
  445. package/src/tests/db-context-versions.test.ts +0 -37
  446. package/src/tests/db-runtime.test.ts +0 -132
  447. package/src/tests/enabled-capabilities.test.ts +0 -20
  448. package/src/tests/extensions-example-mcp-install.test.ts +0 -67
  449. package/src/tests/extensions-lead-equivalence.test.ts +0 -70
  450. package/src/tests/get-workflow-run-tool.test.ts +0 -98
  451. package/src/tests/github-event-labels.test.ts +0 -24
  452. package/src/tests/haiku-5-5-pricing.test.ts +0 -38
  453. package/src/tests/http-log-scrubbing.test.ts +0 -123
  454. package/src/tests/http-semconv-attributes.test.ts +0 -92
  455. package/src/tests/identity.test.ts +0 -117
  456. package/src/tests/inbox-state.test.ts +0 -167
  457. package/src/tests/internal-ai/models.test.ts +0 -54
  458. package/src/tests/launch-password-rejection.test.ts +0 -140
  459. package/src/tests/list-total-cache.test.ts +0 -88
  460. package/src/tests/match-route.test.ts +0 -187
  461. package/src/tests/memory-feature-flags.test.ts +0 -45
  462. package/src/tests/memory-get-tool.test.ts +0 -269
  463. package/src/tests/memory-health-endpoint.test.ts +0 -78
  464. package/src/tests/memory-http-access.test.ts +0 -221
  465. package/src/tests/memory-retrieval-purge.test.ts +0 -99
  466. package/src/tests/multi-runtime-enabled-stats.test.ts +0 -229
  467. package/src/tests/openai-embedding-provider.test.ts +0 -159
  468. package/src/tests/org-identity.test.ts +0 -44
  469. package/src/tests/pages-actions-endpoint.test.ts +0 -103
  470. package/src/tests/pages-browser-sdk.test.ts +0 -76
  471. package/src/tests/pages-feedback-keys.test.ts +0 -121
  472. package/src/tests/pages-frame-ancestors.test.ts +0 -189
  473. package/src/tests/pages-list-endpoint.test.ts +0 -148
  474. package/src/tests/pages-password-mode.test.ts +0 -266
  475. package/src/tests/pages-public-authed-401.test.ts +0 -103
  476. package/src/tests/pages-public-html.test.ts +0 -297
  477. package/src/tests/pages-public-json-redirect.test.ts +0 -122
  478. package/src/tests/pages-view-count.test.ts +0 -245
  479. package/src/tests/prompt-templates-db.test.ts +0 -616
  480. package/src/tests/rbac-engine.test.ts +0 -742
  481. package/src/tests/repo-allow-merge-gate.test.ts +0 -389
  482. package/src/tests/route-def-find-route.test.ts +0 -192
  483. package/src/tests/runtime-stale-threshold.test.ts +0 -40
  484. package/src/tests/schedule-validation-helper.test.ts +0 -51
  485. package/src/tests/scheduled-tasks-api.test.ts +0 -355
  486. package/src/tests/scheduler-backoff.test.ts +0 -166
  487. package/src/tests/script-run-token.test.ts +0 -75
  488. package/src/tests/scripts-extract-signature.test.ts +0 -47
  489. package/src/tests/scripts-sdk-bridge-tool-failure.test.ts +0 -141
  490. package/src/tests/seed-workflow-dreaming.test.ts +0 -117
  491. package/src/tests/short-id.test.ts +0 -23
  492. package/src/tests/skill-files-http.test.ts +0 -222
  493. package/src/tests/skill-get-file-tool.test.ts +0 -110
  494. package/src/tests/skill-script-refs.test.ts +0 -63
  495. package/src/tests/skill-update-scope.test.ts +0 -252
  496. package/src/tests/skills-bundle.test.ts +0 -99
  497. package/src/tests/slack-app-icon.test.ts +0 -94
  498. package/src/tests/slack-assistant-comention.test.ts +0 -139
  499. package/src/tests/slack-delete.test.ts +0 -157
  500. package/src/tests/slack-inbound-diagnostics-auth.test.ts +0 -93
  501. package/src/tests/slack-manifest.test.ts +0 -23
  502. package/src/tests/slack-task-output.test.ts +0 -90
  503. package/src/tests/store-progress-output-guidance.test.ts +0 -34
  504. package/src/tests/swarm-diff.test.ts +0 -728
  505. package/src/tests/task-lifecycle-events.test.ts +0 -53
  506. package/src/tests/template-asset-config.test.ts +0 -18
  507. package/src/tests/template-fetch.test.ts +0 -490
  508. package/src/tests/themes-page-theme.test.ts +0 -155
  509. package/src/tests/tool-annotations.test.ts +0 -442
  510. package/src/tests/tool-output-agent-id.test.ts +0 -202
  511. package/src/tests/update-profile-agentid.test.ts +0 -248
  512. package/src/tests/whoami-route.test.ts +0 -162
  513. package/src/tests/workflow-definition-telemetry.test.ts +0 -144
  514. package/src/tests/workflow-patch.test.ts +0 -169
  515. package/src/tests/workflow-run-steps-index.test.ts +0 -65
  516. package/src/tests/workflow-schedule-trigger.test.ts +0 -104
  517. package/src/tests/workflow-step-claims.test.ts +0 -152
  518. package/src/tests/workflow-step-order.test.ts +0 -92
  519. package/src/tests/workflow-trigger-schema.test.ts +0 -359
  520. package/src/tests/workflow-versions.test.ts +0 -240
  521. package/src/tests/workflow-wait.test.ts +0 -26
@@ -129,6 +129,8 @@ import {
129
129
  init_date_utils,
130
130
  updateAgentCredentialState2,
131
131
  updateAgentCredentialMissing2,
132
+ AgentDeletedError2,
133
+ isAgentDeleted2,
132
134
  createAgent2,
133
135
  getAgentById2,
134
136
  EXTENSION_AGENT_ROLE2,
@@ -149,6 +151,7 @@ import {
149
151
  getAgentHarnessProviders2,
150
152
  updateAgentActivity2,
151
153
  resetEmptyPollCount2,
154
+ deleteAgent2,
152
155
  hasCapacity2,
153
156
  updateAgentStatusFromCapacity2,
154
157
  getAgentDailyTaskCounts2,
@@ -234,6 +237,7 @@ import {
234
237
  init_harness_model_support,
235
238
  sanitizeModelTierOverrides,
236
239
  parseModelTierOverridesHeader,
240
+ modelTierOverridesDiffer,
237
241
  setAgentModelTierOverrides,
238
242
  previewModelTiers,
239
243
  recordClaimModelResolution,
@@ -347,6 +351,7 @@ import {
347
351
  getScriptRunExecutionArgs2,
348
352
  getScriptRunFollowUpGuard2,
349
353
  setScriptRunFollowUpGuard2,
354
+ setSkillUpdatedBy2,
350
355
  updateTaskVcs2,
351
356
  upsertAssetKeyMapping2,
352
357
  listAssetSummaries2,
@@ -471,6 +476,7 @@ import {
471
476
  listSkills2,
472
477
  searchSkills2,
473
478
  installSkill2,
479
+ installSystemDefaultSkillsForAgent2,
474
480
  uninstallSkill2,
475
481
  getAgentSkills2,
476
482
  createMcpServer2,
@@ -550,7 +556,7 @@ import {
550
556
  countScriptRunJournalSteps2,
551
557
  countScriptRunJournalAgentTaskSteps2,
552
558
  init_db4
553
- } from "./cli-zhn4r1rz.js";
559
+ } from "./cli-jj3c5nyb.js";
554
560
  import {
555
561
  PRIMARY_ROLE_NAMES2,
556
562
  OperatorGrantedTargetError2,
@@ -564,7 +570,7 @@ import {
564
570
  assertNotLastAdmin2,
565
571
  setUserRoles2,
566
572
  init_rbac_roles
567
- } from "./cli-cstggwq7.js";
573
+ } from "./cli-nc6a8b5b.js";
568
574
  import {
569
575
  MAX_MODEL_GROUP_MEMBERS,
570
576
  listModelGroups,
@@ -574,17 +580,17 @@ import {
574
580
  modelGroupReferences,
575
581
  deleteModelGroup,
576
582
  init_model_groups
577
- } from "./cli-f8yhybxr.js";
583
+ } from "./cli-9m9kyw77.js";
578
584
  import {
579
585
  requestModelCatalogRefresh2,
580
586
  init_pricing_refresh
581
- } from "./cli-hnh8erra.js";
587
+ } from "./cli-t35hx078.js";
582
588
  import {
583
589
  workflowEventBus2,
584
590
  init_event_bus
585
- } from "./cli-thd3005a.js";
586
- import"./cli-bq97k63w.js";
587
- import"./cli-rhsc2zyx.js";
591
+ } from "./cli-z4f346g5.js";
592
+ import"./cli-g6j6ac3h.js";
593
+ import"./cli-9fsagra4.js";
588
594
  import"./cli-9w8712tq.js";
589
595
  import"./cli-47hz21se.js";
590
596
  import {
@@ -617,12 +623,14 @@ import {
617
623
  callSlackWithRetry2,
618
624
  slackErrorCode2,
619
625
  init_render_v2,
626
+ mirrorSessionPrompt,
627
+ init_session_mirror,
620
628
  getSlackApp2,
621
629
  getSlackHttpReceiver2,
622
630
  startSlackApp2,
623
631
  stopSlackApp2,
624
632
  init_app4
625
- } from "./cli-6a3j25xd.js";
633
+ } from "./cli-zqmmy073.js";
626
634
  import {
627
635
  AGENT_MAX_TASKS_CONFIG_KEY,
628
636
  reconcileAgentMaxTasksPolicy,
@@ -632,6 +640,7 @@ import {
632
640
  upsertRuntimeInstance,
633
641
  getRuntimeInstanceById,
634
642
  touchRuntimeInstance,
643
+ isRuntimeInstanceFresh,
635
644
  listRuntimeInstancesForAgent,
636
645
  setRuntimeCredentialReady,
637
646
  reconcileAgentStatusFromRuntimes,
@@ -650,12 +659,12 @@ import {
650
659
  dispatchApprovalNotifications2,
651
660
  createApprovalFollowUpTask2,
652
661
  init_approval_notifications
653
- } from "./cli-raqw9fw9.js";
662
+ } from "./cli-ct8sz3np.js";
654
663
  import {
655
664
  retryFailedRun2,
656
665
  cancelWorkflowRun2,
657
666
  init_resume
658
- } from "./cli-14xdms9a.js";
667
+ } from "./cli-0b655smz.js";
659
668
  import {
660
669
  safeParse,
661
670
  getObjectShape,
@@ -707,6 +716,9 @@ import {
707
716
  init_manifest_format,
708
717
  handleWebhookTrigger,
709
718
  verifyHmacSignature,
719
+ decodeStandardWebhookSecret,
720
+ verifyStandardWebhookSignature,
721
+ verifyTokenEquality,
710
722
  WebhookError,
711
723
  init_triggers,
712
724
  snapshotAndUpdateWorkflow,
@@ -718,6 +730,13 @@ import {
718
730
  getExecutorRegistry2,
719
731
  initWorkflows2,
720
732
  init_workflows,
733
+ isGitHubEnabled,
734
+ initGitHub,
735
+ verifyWebhookSignature,
736
+ getWorkerInstallationToken,
737
+ init_app,
738
+ isReservedProviderEvent,
739
+ init_event_waits,
721
740
  stripSiblingBlock,
722
741
  init_sibling_block,
723
742
  createTaskWithSiblingAwareness,
@@ -774,12 +793,16 @@ import {
774
793
  loadEnabledExtensions,
775
794
  stopExtensionRuntime,
776
795
  init_lifecycle,
796
+ hasNativeToolHandlers2,
777
797
  dispatchPre2,
778
798
  dispatchPost2,
779
799
  init_dispatcher,
780
800
  resolveIdentity,
781
801
  renderIdentity,
782
802
  init_identity,
803
+ dismissedNamespace,
804
+ dismissUnmappedIdentity,
805
+ restoreUnmappedIdentity,
783
806
  recordUnmappedIdentity,
784
807
  init_unmapped_identities,
785
808
  MAX_TASK_ATTACHMENT_BYTES,
@@ -838,11 +861,6 @@ import {
838
861
  handlePullRequestCommentCreated,
839
862
  handlePullRequestClosed,
840
863
  init_bitbucket,
841
- isGitHubEnabled,
842
- initGitHub,
843
- verifyWebhookSignature,
844
- getWorkerInstallationToken,
845
- init_app,
846
864
  handlePullRequest,
847
865
  handleIssue,
848
866
  handleComment,
@@ -943,6 +961,10 @@ import {
943
961
  init_task_requester,
944
962
  handleApps,
945
963
  init_apps,
964
+ parseScene,
965
+ init_elements,
966
+ MAX_OBJECT_BYTES,
967
+ init_write_object,
946
968
  cancelApprovalRequest,
947
969
  init_approval_cancel,
948
970
  getUserCommsPrefs,
@@ -1038,7 +1060,7 @@ import {
1038
1060
  getKapsoNumberMapping,
1039
1061
  markKapsoMessageSeen,
1040
1062
  init_config2,
1041
- changesAllowMerge,
1063
+ changesMergePolicy,
1042
1064
  init_repo_merge_policy,
1043
1065
  updateSwarmRepoChecked,
1044
1066
  init_repo_checked_update,
@@ -1089,6 +1111,10 @@ import {
1089
1111
  sendTaskOutputSchema,
1090
1112
  sendTaskHandler,
1091
1113
  init_send_task,
1114
+ setSheetRange,
1115
+ appendSheetRows,
1116
+ clearSheetRange,
1117
+ init_service,
1092
1118
  steerTaskUserInputSchema,
1093
1119
  steerTaskOutputSchema,
1094
1120
  steerTaskHandler,
@@ -1129,17 +1155,11 @@ import {
1129
1155
  getEnabledCapabilities,
1130
1156
  createServer,
1131
1157
  init_server
1132
- } from "./cli-075ccjh6.js";
1158
+ } from "./cli-tstj6e8e.js";
1133
1159
  import {
1134
- FilesError,
1135
- normalizeFilesError,
1136
- init_provider,
1137
- agentFsRequestTimeoutMs,
1138
- AgentFsProvider,
1139
- init_agent_fs_provider,
1140
1160
  getFileStorageProvider2,
1141
1161
  init_registry2
1142
- } from "./cli-7cp6aa1q.js";
1162
+ } from "./cli-y260hgep.js";
1143
1163
  import {
1144
1164
  RuntimePoolError2,
1145
1165
  mintControllerToken,
@@ -1161,7 +1181,7 @@ import {
1161
1181
  resolvePoolDelivery2,
1162
1182
  createPoolAgent2,
1163
1183
  init_db2
1164
- } from "./cli-8zmpwe79.js";
1184
+ } from "./cli-1v82d2w6.js";
1165
1185
  import {
1166
1186
  duplicateGuardedQueryKey,
1167
1187
  warnIfCorsAllowsAnyOrigin,
@@ -1186,16 +1206,10 @@ import {
1186
1206
  deriveApiBaseUrl,
1187
1207
  httpServerSemconvAttributes,
1188
1208
  init_utils2,
1189
- hasSessionAccess,
1190
- getSessionRoot,
1191
- getSessionRoots,
1192
- sessionAccessForRoot,
1193
- listActiveSessionShares,
1194
- toSessionSharesState,
1195
- setSessionShares,
1196
- init_session_shares,
1197
1209
  resolveTaskAuditUserId,
1210
+ resolveHttpRequesterUserId,
1198
1211
  resolveHttpAuditUserId,
1212
+ resolveHttpAuditActor,
1199
1213
  init_audit_user,
1200
1214
  dashboardUserIdHeader,
1201
1215
  resolveHttpFavoriteOwner,
@@ -1218,7 +1232,7 @@ import {
1218
1232
  describeRequestRoute,
1219
1233
  route,
1220
1234
  init_route_def
1221
- } from "./cli-nc39ym5q.js";
1235
+ } from "./cli-hc6e4tac.js";
1222
1236
  import {
1223
1237
  startPoolRouting,
1224
1238
  stopPoolRouting,
@@ -1231,28 +1245,28 @@ import {
1231
1245
  checkHeartbeatChecklist2,
1232
1246
  runHeartbeatSweep2,
1233
1247
  stopHeartbeat2
1234
- } from "./cli-b82a13ga.js";
1235
- import"./cli-yvzxbztc.js";
1248
+ } from "./cli-mh7pdxe0.js";
1249
+ import"./cli-tn91wc6e.js";
1236
1250
  import {
1237
1251
  runtimeSupervisorStatus,
1238
1252
  startRuntimeSupervisor,
1239
1253
  stopRuntimeSupervisor
1240
- } from "./cli-rpmw4fsv.js";
1254
+ } from "./cli-mz34pxbk.js";
1241
1255
  import {
1242
1256
  TASK_TITLE_TIMEOUT_MS,
1243
1257
  generateTaskTitle
1244
- } from "./cli-4kzp7r0q.js";
1258
+ } from "./cli-wndegmns.js";
1245
1259
  import"./cli-ns59dc6r.js";
1246
1260
  import {
1247
1261
  ACP_TARGET_IDS
1248
- } from "./cli-r813c7rb.js";
1262
+ } from "./cli-tdk7jtka.js";
1249
1263
  import {
1250
1264
  reasoningCapability,
1251
1265
  supportedReasoningLevels
1252
- } from "./cli-fwjwkw66.js";
1266
+ } from "./cli-rtmqzat7.js";
1253
1267
  import {
1254
1268
  MAX_RATE_LIMIT_RESET_MS
1255
- } from "./cli-ramn8jae.js";
1269
+ } from "./cli-n85m2wkq.js";
1256
1270
  import {
1257
1271
  isLeadChannelMonitoringEnabled,
1258
1272
  ORG_IDENTITY_KEYS,
@@ -1262,7 +1276,7 @@ import {
1262
1276
  isUnknownModelError,
1263
1277
  checkProviderPoolKey,
1264
1278
  writeSkillsToFilesystem
1265
- } from "./cli-2jtfm8kh.js";
1279
+ } from "./cli-fz9pcjsw.js";
1266
1280
  import {
1267
1281
  AgentFsRequestError2,
1268
1282
  resolveAgentFsSharedContext2,
@@ -1271,12 +1285,18 @@ import {
1271
1285
  getCurrentOrgMembers2,
1272
1286
  roleRank2,
1273
1287
  agentFsRequest2,
1274
- resolveApiUrl2
1275
- } from "./cli-2gvdvsxj.js";
1288
+ resolveApiUrl2,
1289
+ init_agent_fs_provision
1290
+ } from "./cli-qec9bynj.js";
1276
1291
  import {
1277
1292
  Anthropic
1278
- } from "./cli-p8zqbbt1.js";
1279
- import"./cli-rwgwen5v.js";
1293
+ } from "./cli-m4ejz4nj.js";
1294
+ import {
1295
+ objectWebhookSecret2,
1296
+ handleObjectWebhookEvent2,
1297
+ init_object_webhooks
1298
+ } from "./cli-hbq0kwxz.js";
1299
+ import"./cli-6h88mn9q.js";
1280
1300
  import {
1281
1301
  createUserMergeJob2,
1282
1302
  getUserMergeJob2,
@@ -1285,7 +1305,7 @@ import {
1285
1305
  findFailedUserMergeJob2,
1286
1306
  requeueUserMergeJob2,
1287
1307
  runUserMergeJobs2
1288
- } from "./cli-q71g5q39.js";
1308
+ } from "./cli-49f5jyhh.js";
1289
1309
  import {
1290
1310
  isCodexOAuthConfigKey
1291
1311
  } from "./cli-j4bwnpkm.js";
@@ -1296,7 +1316,7 @@ import {
1296
1316
  import {
1297
1317
  runTaskUiAction,
1298
1318
  init_actions
1299
- } from "./cli-9knhkkgr.js";
1319
+ } from "./cli-y4a4458j.js";
1300
1320
  import {
1301
1321
  RATING_MODEL_MAX_LENGTH,
1302
1322
  REFERENCES_SOURCE_MAX_LENGTH,
@@ -1391,7 +1411,7 @@ import {
1391
1411
  init_typecheck,
1392
1412
  parseSkillContent,
1393
1413
  init_skill_parser
1394
- } from "./cli-wz4e5am2.js";
1414
+ } from "./cli-0dg7ytxm.js";
1395
1415
  import {
1396
1416
  signalProcessGroup,
1397
1417
  detachedProcessGroup,
@@ -1408,8 +1428,26 @@ import {
1408
1428
  forceRefreshAuthorizationOrThrow,
1409
1429
  forceRefreshTokenOrThrow,
1410
1430
  init_ensure_token
1411
- } from "./cli-4aswccje.js";
1412
- import"./cli-v3zcnr8g.js";
1431
+ } from "./cli-kspxjftk.js";
1432
+ import {
1433
+ PRIMITIVE_KINDS,
1434
+ ObjectsError,
1435
+ recordObjectVersion,
1436
+ init_objects
1437
+ } from "./cli-7dbhnsj9.js";
1438
+ import {
1439
+ agentFsClientFor,
1440
+ init_agent_fs_identity
1441
+ } from "./cli-avqkr20b.js";
1442
+ import {
1443
+ FilesError,
1444
+ normalizeFilesError,
1445
+ init_provider,
1446
+ agentFsRequestTimeoutMs,
1447
+ AgentFsProvider,
1448
+ init_agent_fs_provider
1449
+ } from "./cli-skd2c4ej.js";
1450
+ import"./cli-1dbv9mj9.js";
1413
1451
  import {
1414
1452
  automationIntegrationFixUrl,
1415
1453
  preflightAutomation,
@@ -1417,6 +1455,9 @@ import {
1417
1455
  listEnabledAutomationPreflightInputs,
1418
1456
  setupIntegrationFlags,
1419
1457
  init_automation_preflight,
1458
+ serverRefInputKeys,
1459
+ serverRefInputDeniedMessage,
1460
+ init_input,
1420
1461
  validateJsonSchema,
1421
1462
  init_json_schema_validator,
1422
1463
  workflowSaveWarnings,
@@ -1428,7 +1469,7 @@ import {
1428
1469
  definitionNodeIds,
1429
1470
  validateDefinition,
1430
1471
  init_definition2
1431
- } from "./cli-m00c47q6.js";
1472
+ } from "./cli-hgsxnjyg.js";
1432
1473
  import {
1433
1474
  _fetchHolder,
1434
1475
  CLIENT_ID,
@@ -1444,7 +1485,7 @@ import {
1444
1485
  loadAllCodexOAuthSlots,
1445
1486
  getValidCodexOAuth,
1446
1487
  init_storage
1447
- } from "./cli-w5dar1bk.js";
1488
+ } from "./cli-2m6yaq6b.js";
1448
1489
  import {
1449
1490
  isMultiRuntimeEnabled,
1450
1491
  init_multi_runtime2
@@ -1456,11 +1497,21 @@ import {
1456
1497
  import {
1457
1498
  createRuntimeProvider,
1458
1499
  init_runtime_providers
1459
- } from "./cli-zqq57pgx.js";
1500
+ } from "./cli-s6zk31gr.js";
1460
1501
  import {
1461
1502
  require_content_type
1462
1503
  } from "./cli-1jx0srjt.js";
1463
1504
  import"./cli-n3qe7tyr.js";
1505
+ import {
1506
+ hasSessionAccess,
1507
+ getSessionRoot,
1508
+ getSessionRoots,
1509
+ sessionAccessForRoot,
1510
+ listActiveSessionShares,
1511
+ toSessionSharesState,
1512
+ setSessionShares,
1513
+ init_session_shares
1514
+ } from "./cli-yn4kt85g.js";
1464
1515
  import {
1465
1516
  isInvalidClientError,
1466
1517
  publicEndpointSsrfOptions,
@@ -1478,7 +1529,7 @@ import {
1478
1529
  revokeMcpToken,
1479
1530
  computeExpiresAt,
1480
1531
  init_mcp_wrapper
1481
- } from "./cli-t2s7j5cy.js";
1532
+ } from "./cli-dka73bak.js";
1482
1533
  import"./cli-v41kn3cd.js";
1483
1534
  import {
1484
1535
  setBedrockProviderModule,
@@ -1515,9 +1566,14 @@ import {
1515
1566
  mintAgentToken,
1516
1567
  rotateAgentToken,
1517
1568
  revokeAgentTokens,
1569
+ revokeAllAgentSessionTokens,
1518
1570
  fingerprintApiKey,
1519
1571
  init_users
1520
- } from "./cli-yzxqwcvq.js";
1572
+ } from "./cli-ajjvqhf3.js";
1573
+ import {
1574
+ CORE_TOOLS,
1575
+ init_tool_config
1576
+ } from "./cli-yfvhvw8m.js";
1521
1577
  import {
1522
1578
  MAX_PROVIDER_QUOTA_ENTRIES,
1523
1579
  ProviderQuotaCapacityError,
@@ -1526,21 +1582,64 @@ import {
1526
1582
  providerAccountTelemetrySchema,
1527
1583
  rateLimitReplacementSchema,
1528
1584
  init_provider_account_telemetry
1529
- } from "./cli-k3c13za2.js";
1530
- import {
1531
- resolveGitHubHost,
1532
- init_github_host
1533
- } from "./cli-9ttx00s3.js";
1534
- import {
1535
- CORE_TOOLS,
1536
- init_tool_config
1537
- } from "./cli-0b4zam62.js";
1585
+ } from "./cli-7wy8gbwb.js";
1538
1586
  import {
1539
1587
  CODEX_AUTH_FAILURE_BENCH_THRESHOLD,
1540
1588
  CODEX_AUTH_WATCH_NAMESPACE,
1541
1589
  codexAuthBenchMarkerKey,
1542
1590
  init_codex_auth_failure
1543
1591
  } from "./cli-fw2w0kva.js";
1592
+ import {
1593
+ resolveGitHubHost,
1594
+ init_github_host
1595
+ } from "./cli-9ttx00s3.js";
1596
+ import {
1597
+ IDENTITY_FIELD_BUDGETS,
1598
+ IdentityFieldBudgetError,
1599
+ init_identity_field_budget
1600
+ } from "./cli-sdh61g52.js";
1601
+ import {
1602
+ getSlackConfiguration,
1603
+ init_config4
1604
+ } from "./cli-eetzmsy5.js";
1605
+ import {
1606
+ isSteeringEnabled2,
1607
+ init_steering_enabled
1608
+ } from "./cli-4sydckyj.js";
1609
+ import {
1610
+ SUBSCRIPTION_PLANS_CHECKED_AT,
1611
+ SUBSCRIPTION_PLANS,
1612
+ isSubscriptionPlanId,
1613
+ init_subscription_plans
1614
+ } from "./cli-nh7x3133.js";
1615
+ import {
1616
+ MODEL_SCOPED_WINDOWS,
1617
+ KEY_WIDE_WINDOWS,
1618
+ modelFamilyOf,
1619
+ isModelScopedWindow,
1620
+ activeModelBlocks,
1621
+ init_model_rate_limit_windows,
1622
+ CREDENTIAL_POOL_VARS,
1623
+ PROVIDER_CREDENTIAL_VARS,
1624
+ getModelAwareCredentialVars,
1625
+ splitCredentialPool,
1626
+ selectCredential,
1627
+ init_credentials2
1628
+ } from "./cli-js10kdk7.js";
1629
+ import {
1630
+ getOpenRouterAttributionHeaders,
1631
+ init_openrouter_base_url
1632
+ } from "./cli-dfyv0jdy.js";
1633
+ import {
1634
+ interpolate,
1635
+ init_template2,
1636
+ getTemplateDefinition,
1637
+ getAllTemplateDefinitions,
1638
+ init_registry3,
1639
+ resolveTemplate,
1640
+ init_resolver,
1641
+ init_session_templates
1642
+ } from "./cli-50w82h6m.js";
1544
1643
  import {
1545
1644
  ASSET_KEY_MAX_LENGTH,
1546
1645
  AssetKeyError,
@@ -1608,6 +1707,7 @@ import {
1608
1707
  AgentAvatarSchema,
1609
1708
  AgentSlackIconSchema,
1610
1709
  AgentSchema,
1710
+ AgentHistoryEventSchema,
1611
1711
  AgentLatestModelSchema,
1612
1712
  AgentAcpStatusSchema,
1613
1713
  AgentCredStatusSchema,
@@ -1713,54 +1813,7 @@ import {
1713
1813
  KvKeySchema,
1714
1814
  KvEntrySchema,
1715
1815
  init_types5
1716
- } from "./cli-1h4njv9y.js";
1717
- import {
1718
- IDENTITY_FIELD_BUDGETS,
1719
- IdentityFieldBudgetError,
1720
- init_identity_field_budget
1721
- } from "./cli-mhrr4d5b.js";
1722
- import {
1723
- isSteeringEnabled2,
1724
- init_steering_enabled
1725
- } from "./cli-4sydckyj.js";
1726
- import {
1727
- getSlackConfiguration,
1728
- init_config4
1729
- } from "./cli-eetzmsy5.js";
1730
- import {
1731
- SUBSCRIPTION_PLANS_CHECKED_AT,
1732
- SUBSCRIPTION_PLANS,
1733
- isSubscriptionPlanId,
1734
- init_subscription_plans
1735
- } from "./cli-nh7x3133.js";
1736
- import {
1737
- MODEL_SCOPED_WINDOWS,
1738
- KEY_WIDE_WINDOWS,
1739
- modelFamilyOf,
1740
- isModelScopedWindow,
1741
- activeModelBlocks,
1742
- init_model_rate_limit_windows,
1743
- CREDENTIAL_POOL_VARS,
1744
- PROVIDER_CREDENTIAL_VARS,
1745
- getModelAwareCredentialVars,
1746
- splitCredentialPool,
1747
- selectCredential,
1748
- init_credentials2
1749
- } from "./cli-ha4ek2nb.js";
1750
- import {
1751
- getOpenRouterAttributionHeaders,
1752
- init_openrouter_base_url
1753
- } from "./cli-dfyv0jdy.js";
1754
- import {
1755
- interpolate,
1756
- init_template2,
1757
- getTemplateDefinition,
1758
- getAllTemplateDefinitions,
1759
- init_registry3,
1760
- resolveTemplate,
1761
- init_resolver,
1762
- init_session_templates
1763
- } from "./cli-2z2c4k6q.js";
1816
+ } from "./cli-f8rcvf2x.js";
1764
1817
  import {
1765
1818
  init_zod
1766
1819
  } from "./cli-96234j5w.js";
@@ -1801,6 +1854,7 @@ import {
1801
1854
  getPublicMcpBaseUrl,
1802
1855
  getAgentFsLiveUrl,
1803
1856
  agentFsFileRoute,
1857
+ buildAgentFsLiveUrl,
1804
1858
  isCombEnabled,
1805
1859
  isAgentFsProxyEnabled,
1806
1860
  init_constants3
@@ -1813,7 +1867,7 @@ import {
1813
1867
  import {
1814
1868
  init_package,
1815
1869
  package_default
1816
- } from "./cli-a6q6x15h.js";
1870
+ } from "./cli-y518qkjg.js";
1817
1871
  import {
1818
1872
  realtimeBus,
1819
1873
  init_bus
@@ -1829,7 +1883,7 @@ import {
1829
1883
  registerVolatileSecret,
1830
1884
  registerEnvSecrets,
1831
1885
  init_secret_scrubber
1832
- } from "./cli-7e8sxqv5.js";
1886
+ } from "./cli-bpje8n65.js";
1833
1887
  import {
1834
1888
  __toESM
1835
1889
  } from "./cli-242037k3.js";
@@ -7089,6 +7143,319 @@ async function handleActiveSessions(req, res, pathSegments, queryParams, myAgent
7089
7143
  return false;
7090
7144
  }
7091
7145
 
7146
+ // src/http/agent-lifecycle.ts
7147
+ init_zod();
7148
+
7149
+ // src/be/agent-history.ts
7150
+ init_types5();
7151
+ init_secret_scrubber();
7152
+ init_db4();
7153
+ init_users();
7154
+
7155
+ class AgentHistoryError extends Error {
7156
+ status;
7157
+ code;
7158
+ blockers;
7159
+ constructor(message, status, code, blockers = []) {
7160
+ super(message);
7161
+ this.status = status;
7162
+ this.code = code;
7163
+ this.blockers = blockers;
7164
+ this.name = "AgentHistoryError";
7165
+ }
7166
+ }
7167
+ var NON_TERMINAL_SQL = `status NOT IN (${TERMINAL_TASK_STATUSES.map((s) => `'${s}'`).join(", ")})`;
7168
+ var COUNT_BLOCKERS = [
7169
+ [
7170
+ "open_tasks",
7171
+ `SELECT COUNT(*) AS n FROM agent_tasks WHERE (agentId = ?1 OR offeredTo = ?1) AND ${NON_TERMINAL_SQL}`,
7172
+ "non-terminal task(s) are assigned or offered to it; finish, cancel or reassign them"
7173
+ ],
7174
+ [
7175
+ "schedules",
7176
+ "SELECT COUNT(*) AS n FROM scheduled_tasks WHERE targetAgentId = ?1 AND enabled = 1",
7177
+ "enabled schedule(s) target it; disable or retarget them"
7178
+ ],
7179
+ [
7180
+ "owned_skills",
7181
+ "SELECT COUNT(*) AS n FROM skills WHERE ownerAgentId = ?1",
7182
+ "skill(s) are owned by it"
7183
+ ],
7184
+ [
7185
+ "owned_mcp_servers",
7186
+ "SELECT COUNT(*) AS n FROM mcp_servers WHERE ownerAgentId = ?1",
7187
+ "MCP server(s) are owned by it"
7188
+ ],
7189
+ [
7190
+ "inboxes",
7191
+ "SELECT COUNT(*) AS n FROM agentmail_inbox_mappings WHERE agentId = ?1",
7192
+ "AgentMail inbox(es) map to it"
7193
+ ]
7194
+ ];
7195
+ async function deleteBlockers(agent) {
7196
+ const blockers = [];
7197
+ if (agent.isLead)
7198
+ blockers.push({ code: "lead", message: "The lead agent cannot be deleted." });
7199
+ if (isExtensionAgent2(agent)) {
7200
+ blockers.push({ code: "extension", message: "Uninstall the extension instead." });
7201
+ }
7202
+ if (agent.status !== "offline") {
7203
+ blockers.push({ code: "not_offline", message: `Agent is ${agent.status}. Stop its worker.` });
7204
+ }
7205
+ if (agent.runtimePoolId) {
7206
+ blockers.push({ code: "pool_bound", message: `Unbind it from pool ${agent.runtimePoolId}.` });
7207
+ }
7208
+ for (const [code, sql, what] of COUNT_BLOCKERS) {
7209
+ const n = (await getDbClient2().get(sql, [agent.id]))?.n ?? 0;
7210
+ if (n > 0)
7211
+ blockers.push({ code, message: `${n} ${what}.` });
7212
+ }
7213
+ return blockers;
7214
+ }
7215
+ function rowToEvent(row) {
7216
+ return {
7217
+ id: row.id,
7218
+ agentId: row.agent_id,
7219
+ event: row.event,
7220
+ actorRef: row.actor_ref,
7221
+ reason: row.reason,
7222
+ snapshot: JSON.parse(row.snapshot_json),
7223
+ createdAt: row.created_at
7224
+ };
7225
+ }
7226
+ async function appendEvent(agentId, event, actorRef, reason) {
7227
+ const snapshot = await getDbClient2().get("SELECT * FROM agents WHERE id = ?", [agentId]);
7228
+ const row = await getDbClient2().get(`INSERT INTO agent_history (id, agent_id, event, actor_ref, reason, snapshot_json, created_at)
7229
+ VALUES (?, ?, ?, ?, ?, ?, ?) RETURNING *`, [
7230
+ crypto.randomUUID(),
7231
+ agentId,
7232
+ event,
7233
+ actorRef,
7234
+ scrubSecrets(reason.trim()),
7235
+ JSON.stringify(snapshot),
7236
+ new Date().toISOString()
7237
+ ]);
7238
+ if (!row)
7239
+ throw new Error("Failed to append agent history");
7240
+ return rowToEvent(row);
7241
+ }
7242
+ async function latestEvent(agentId) {
7243
+ return await getDbClient2().get("SELECT * FROM agent_history WHERE agent_id = ? ORDER BY created_at DESC, rowid DESC LIMIT 1", [agentId]);
7244
+ }
7245
+ async function deleteAgentToHistory(agentId, reason, actorRef) {
7246
+ return await getDbClient2().transaction(async () => {
7247
+ const agent = await getAgentById2(agentId);
7248
+ if (!agent)
7249
+ throw new AgentHistoryError("Agent not found", 404, "not_found");
7250
+ const blockers = await deleteBlockers(agent);
7251
+ if (blockers.length > 0) {
7252
+ throw new AgentHistoryError(blockers[0].message, 409, blockers[0].code, blockers);
7253
+ }
7254
+ const event = await appendEvent(agentId, "deleted", actorRef, reason);
7255
+ await revokeAllAgentSessionTokens(agentId);
7256
+ await getDbClient2().run("DELETE FROM agent_skills WHERE agentId = ?", [agentId]);
7257
+ await getDbClient2().run("DELETE FROM agent_mcp_servers WHERE agentId = ?", [agentId]);
7258
+ await deleteAgent2(agentId);
7259
+ return event;
7260
+ });
7261
+ }
7262
+ async function restoreAgentFromHistory(agentId, input, actorRef) {
7263
+ return await getDbClient2().transaction(async () => {
7264
+ if (await getAgentById2(agentId)) {
7265
+ throw new AgentHistoryError("Agent exists; nothing to restore", 409, "not_deleted");
7266
+ }
7267
+ const last = await latestEvent(agentId);
7268
+ if (last?.event !== "deleted") {
7269
+ throw new AgentHistoryError("No deleted agent with this id", 404, "not_found");
7270
+ }
7271
+ const row = JSON.parse(last.snapshot_json);
7272
+ const name = input.newName?.trim() || String(row.name);
7273
+ row.name = name;
7274
+ row.lastUpdatedAt = new Date().toISOString();
7275
+ const taken = await getDbClient2().get("SELECT id FROM agents WHERE name = ?", [name]);
7276
+ if (taken) {
7277
+ throw new AgentHistoryError(`Another agent is named "${name}". Pass newName.`, 409, "name_taken");
7278
+ }
7279
+ const columns = (await getDbClient2().query("SELECT name FROM pragma_table_info('agents')")).map((c) => c.name).filter((c) => (c in row));
7280
+ await getDbClient2().run(`INSERT INTO agents (${columns.map((c) => `"${c}"`).join(", ")}) VALUES (${columns.map(() => "?").join(", ")})`, columns.map((c) => row[c] ?? null));
7281
+ await installSystemDefaultSkillsForAgent2(agentId);
7282
+ const event = await appendEvent(agentId, "restored", actorRef, input.reason);
7283
+ return { agent: await getAgentById2(agentId), event };
7284
+ });
7285
+ }
7286
+ async function listAgentHistory(agentId) {
7287
+ const rows = await getDbClient2().query(`SELECT * FROM agent_history ${agentId ? "WHERE agent_id = ?" : ""}
7288
+ ORDER BY created_at DESC, rowid DESC LIMIT 500`, agentId ? [agentId] : []);
7289
+ return rows.map(rowToEvent);
7290
+ }
7291
+
7292
+ // src/http/agent-lifecycle.ts
7293
+ init_rbac();
7294
+ init_types5();
7295
+ init_secret_scrubber();
7296
+
7297
+ // src/http/operator-actor.ts
7298
+ init_users();
7299
+ init_api_key();
7300
+ init_request_auth_context();
7301
+ init_triggers();
7302
+ init_request_principal();
7303
+ init_utils2();
7304
+ function extractBearer(req) {
7305
+ const raw = req.headers.authorization;
7306
+ const header = Array.isArray(raw) ? raw[0] : raw;
7307
+ if (!header || !header.startsWith("Bearer "))
7308
+ return null;
7309
+ return header.slice(7);
7310
+ }
7311
+ function getOperatorActor(req, res) {
7312
+ if (rejectGuest(req, res))
7313
+ return null;
7314
+ const auth = getRequestAuth(req);
7315
+ const userId = authUserId(auth);
7316
+ if (userId) {
7317
+ const tokenId = auth?.kind === "user" ? auth.tokenId : undefined;
7318
+ return tokenId ? { kind: "user", id: userId, tokenId } : { kind: "user", id: userId };
7319
+ }
7320
+ if (isOperatorAuth(auth)) {
7321
+ return { kind: "operator", id: auth.fingerprint };
7322
+ }
7323
+ const rawKey = extractBearer(req);
7324
+ const swarmKey = getApiKey();
7325
+ if (!swarmKey) {
7326
+ return { kind: "operator", id: fingerprintApiKey("") };
7327
+ }
7328
+ if (!rawKey || !verifyTokenEquality(swarmKey, rawKey)) {
7329
+ jsonError(res, "Unauthorized", 401);
7330
+ return null;
7331
+ }
7332
+ return { kind: "operator", id: fingerprintApiKey(rawKey) };
7333
+ }
7334
+
7335
+ // src/http/agent-lifecycle.ts
7336
+ init_request_principal();
7337
+ init_route_def();
7338
+ init_utils2();
7339
+ var params = object2({ id: string2().min(1) });
7340
+ var reason = string2().trim().min(3).max(2000);
7341
+ var RefusalSchema = object2({
7342
+ error: string2(),
7343
+ code: string2(),
7344
+ blockers: array2(object2({ code: string2(), message: string2() }))
7345
+ });
7346
+ var RBAC = { permission: "agent.lifecycle.manage" };
7347
+ var DENIED = { description: "Operator or user credentials required" };
7348
+ var deleteRoute = route({
7349
+ method: "post",
7350
+ path: "/api/agents/{id}/delete",
7351
+ pattern: ["api", "agents", null, "delete"],
7352
+ summary: "Delete an agent into agent_history",
7353
+ description: "Appends the agent row to `agent_history`, revokes its session tokens, and deletes the row. Refused with 409 while the agent is the lead, an extension identity, not offline, pool-bound, holds open tasks or enabled schedules, or owns skills, MCP servers or inboxes.",
7354
+ tags: ["Agents"],
7355
+ params,
7356
+ body: object2({ reason }),
7357
+ responses: {
7358
+ 200: { description: "Agent deleted", schema: object2({ event: AgentHistoryEventSchema }) },
7359
+ 400: { description: "Validation error" },
7360
+ 403: DENIED,
7361
+ 404: { description: "Agent not found" },
7362
+ 409: { description: "A blocker refuses the delete", schema: RefusalSchema }
7363
+ },
7364
+ rbac: RBAC
7365
+ });
7366
+ var restoreRoute = route({
7367
+ method: "post",
7368
+ path: "/api/agents/{id}/restore",
7369
+ pattern: ["api", "agents", null, "restore"],
7370
+ summary: "Restore a deleted agent from agent_history",
7371
+ description: "Reinserts the latest deleted snapshot under the same id. Rows a cascading foreign key removed on delete do not come back.",
7372
+ tags: ["Agents"],
7373
+ params,
7374
+ body: object2({ reason, newName: string2().trim().min(1).optional() }),
7375
+ responses: {
7376
+ 200: {
7377
+ description: "Agent restored",
7378
+ schema: object2({ agent: AgentSchema, event: AgentHistoryEventSchema })
7379
+ },
7380
+ 400: { description: "Validation error" },
7381
+ 403: DENIED,
7382
+ 404: { description: "No deleted agent with this id" },
7383
+ 409: { description: "The agent exists, or its name is taken", schema: RefusalSchema }
7384
+ },
7385
+ rbac: RBAC
7386
+ });
7387
+ var historyRoute = route({
7388
+ method: "get",
7389
+ path: "/api/agent-history",
7390
+ pattern: ["api", "agent-history"],
7391
+ summary: "List agent delete and restore events",
7392
+ description: "Newest first, at most 500. Filter by `agentId`.",
7393
+ tags: ["Agents"],
7394
+ query: object2({ agentId: string2().min(1).optional() }),
7395
+ responses: {
7396
+ 200: {
7397
+ description: "Events",
7398
+ schema: object2({ events: array2(AgentHistoryEventSchema) })
7399
+ },
7400
+ 403: DENIED
7401
+ },
7402
+ rbac: RBAC
7403
+ });
7404
+ async function handleAgentLifecycle(req, res, pathSegments, queryParams, myAgentId) {
7405
+ const matched = [deleteRoute, restoreRoute, historyRoute].find((r) => r.match(req.method, pathSegments));
7406
+ if (!matched)
7407
+ return false;
7408
+ const decision = can({
7409
+ principal: await agentFirstPrincipal(req, myAgentId),
7410
+ verb: "agent.lifecycle.manage",
7411
+ resource: matched === historyRoute ? { kind: "none" } : { kind: "agent", agentId: pathSegments[2] },
7412
+ source: "http"
7413
+ });
7414
+ if (!decision.allow) {
7415
+ jsonError(res, scrubSecrets(decision.reason), 403);
7416
+ return true;
7417
+ }
7418
+ if (matched === historyRoute) {
7419
+ const parsed = await historyRoute.parse(req, res, pathSegments, queryParams);
7420
+ if (!parsed)
7421
+ return true;
7422
+ historyRoute.respond(res, 200, { events: await listAgentHistory(parsed.query.agentId) });
7423
+ return true;
7424
+ }
7425
+ const operator = getOperatorActor(req, res);
7426
+ if (!operator)
7427
+ return true;
7428
+ const actorRef = operator.kind === "user" ? `user:${operator.id}` : operator.id;
7429
+ try {
7430
+ if (matched === deleteRoute) {
7431
+ const parsed = await deleteRoute.parse(req, res, pathSegments, queryParams);
7432
+ if (!parsed)
7433
+ return true;
7434
+ const event = await deleteAgentToHistory(parsed.params.id, parsed.body.reason, actorRef);
7435
+ deleteRoute.respond(res, 200, { event });
7436
+ return true;
7437
+ }
7438
+ const parsed = await restoreRoute.parse(req, res, pathSegments, queryParams);
7439
+ if (!parsed)
7440
+ return true;
7441
+ restoreRoute.respond(res, 200, await restoreAgentFromHistory(parsed.params.id, parsed.body, actorRef));
7442
+ return true;
7443
+ } catch (error) {
7444
+ if (!(error instanceof AgentHistoryError))
7445
+ throw error;
7446
+ if (error.status === 404) {
7447
+ jsonError(res, error.message, 404);
7448
+ return true;
7449
+ }
7450
+ const body = { error: error.message, code: error.code, blockers: error.blockers };
7451
+ if (matched === restoreRoute)
7452
+ restoreRoute.respond(res, 409, body);
7453
+ else
7454
+ deleteRoute.respond(res, 409, body);
7455
+ return true;
7456
+ }
7457
+ }
7458
+
7092
7459
  // src/http/agentfs-proxy.ts
7093
7460
  init_api_key();
7094
7461
  init_constants3();
@@ -7525,7 +7892,10 @@ var registerAgent = route({
7525
7892
  description: "Agent created. Response includes `enabledCapabilities` (see 200).",
7526
7893
  schema: RegisterAgentResponseSchema
7527
7894
  },
7528
- 400: { description: "Validation error" }
7895
+ 400: { description: "Validation error" },
7896
+ 410: {
7897
+ description: "An operator deleted this agent id (`agent_deleted`); the worker must stop"
7898
+ }
7529
7899
  }
7530
7900
  });
7531
7901
  var setAgentHarnessProviderRoute = route({
@@ -7979,6 +8349,8 @@ async function handleAgentRegister(req, res, pathSegments, myAgentId) {
7979
8349
  }
7980
8350
  return { agent: await getAgentById2(agentId), created: false };
7981
8351
  }
8352
+ if (await isAgentDeleted2(agentId))
8353
+ return null;
7982
8354
  const agent = await createAgent2({
7983
8355
  id: agentId,
7984
8356
  name: parsed.body.name,
@@ -8005,6 +8377,10 @@ async function handleAgentRegister(req, res, pathSegments, myAgentId) {
8005
8377
  }
8006
8378
  return { agent, created: true };
8007
8379
  });
8380
+ if (!result) {
8381
+ jsonError(res, "agent_deleted", 410);
8382
+ return true;
8383
+ }
8008
8384
  if (parsed.body.harnessCliVersion !== undefined) {
8009
8385
  await setAgentHarnessCliVersion(agentId, parsed.body.harnessCliVersion.trim() || null);
8010
8386
  }
@@ -11622,7 +11998,7 @@ async function handleAssets(req, res, pathSegments, queryParams, myAgentId) {
11622
11998
  if (!ensureOperator(req, res))
11623
11999
  return true;
11624
12000
  try {
11625
- const actor = await resolveHttpAuditUserId(req, myAgentId);
12001
+ const actor = await resolveHttpRequesterUserId(req, myAgentId);
11626
12002
  const key = parsed.body.key ? await authorizeAssetKeyWrite(parsed.body.key, actor) : undefined;
11627
12003
  const mapping = await upsertAssetKeyMapping2({
11628
12004
  providerId: parsed.body.providerId,
@@ -11705,13 +12081,14 @@ async function handleAssets(req, res, pathSegments, queryParams, myAgentId) {
11705
12081
  }
11706
12082
  }
11707
12083
  try {
11708
- const actor = await resolveHttpAuditUserId(req, myAgentId);
12084
+ const actor = await resolveHttpRequesterUserId(req, myAgentId);
11709
12085
  const key = await authorizeAssetKeyWrite(parsed.body.key, actor);
11710
12086
  const moved = await moveAssetKey2({
11711
12087
  entityType: parsed.params.entityType,
11712
12088
  id: parsed.params.id,
11713
12089
  key,
11714
12090
  changedBy: actor ?? undefined,
12091
+ changedByAgentId: myAgentId,
11715
12092
  descendantTaskIds
11716
12093
  });
11717
12094
  if (!moved) {
@@ -14268,7 +14645,7 @@ async function handleComb(req, res, pathSegments, queryParams, myAgentId) {
14268
14645
  try {
14269
14646
  const result = await sendReviewBatch({
14270
14647
  ...parsed.body,
14271
- requestedByUserId: await resolveHttpAuditUserId(req, myAgentId)
14648
+ requestedByUserId: await resolveHttpRequesterUserId(req, myAgentId)
14272
14649
  });
14273
14650
  reviewBatchRoute.respond(res, result.taskId === null ? 200 : 201, result);
14274
14651
  } catch (error) {
@@ -14970,6 +15347,7 @@ declare module "swarm-extension" {
14970
15347
  agentId: string | undefined;
14971
15348
  runtimeInstanceId: string | undefined;
14972
15349
  sourceTaskId: string | undefined;
15350
+ auditSourceTaskId: string | undefined;
14973
15351
  contextKey: string | undefined;
14974
15352
  callOrigin: "mcp" | "native" | "extension" | "script-sdk";
14975
15353
  harness?: string | undefined;
@@ -18011,7 +18389,7 @@ var patchRoute = route({
18011
18389
  },
18012
18390
  rbac: { permission: "extension.write" }
18013
18391
  });
18014
- var deleteRoute = route({
18392
+ var deleteRoute2 = route({
18015
18393
  method: "delete",
18016
18394
  path: "/api/extensions/{id}",
18017
18395
  pattern: ["api", "extensions", null],
@@ -18356,8 +18734,8 @@ async function handleExtensions(req, res, pathSegments, queryParams, agentId) {
18356
18734
  patchRoute.respond(res, 200, { extension: redactExtension(extension) });
18357
18735
  return true;
18358
18736
  }
18359
- if (deleteRoute.match(req.method, pathSegments)) {
18360
- const parsed = await deleteRoute.parse(req, res, pathSegments, queryParams);
18737
+ if (deleteRoute2.match(req.method, pathSegments)) {
18738
+ const parsed = await deleteRoute2.parse(req, res, pathSegments, queryParams);
18361
18739
  if (!parsed)
18362
18740
  return true;
18363
18741
  const stored = await getExtensionById(parsed.params.id);
@@ -18384,7 +18762,7 @@ async function handleExtensions(req, res, pathSegments, queryParams, agentId) {
18384
18762
  respondLifecycleError(res, error);
18385
18763
  return true;
18386
18764
  }
18387
- deleteRoute.respond(res, 200, { deleted: true, assets });
18765
+ deleteRoute2.respond(res, 200, { deleted: true, assets });
18388
18766
  return true;
18389
18767
  }
18390
18768
  if (enableRoute.match(req.method, pathSegments)) {
@@ -18498,7 +18876,7 @@ var putFavorite = route({
18498
18876
  row: UserFavoriteSchema.nullable()
18499
18877
  })
18500
18878
  },
18501
- 400: { description: "Invalid asset key for a key favorite" },
18879
+ 400: { description: "Invalid asset key for a key or hidden-key favorite" },
18502
18880
  401: { description: "No authenticated principal context" }
18503
18881
  }
18504
18882
  });
@@ -18534,7 +18912,7 @@ async function handleFavorites(req, res, pathSegments, queryParams, myAgentId) {
18534
18912
  return true;
18535
18913
  }
18536
18914
  let itemId = parsed.body.itemId;
18537
- if (parsed.body.itemType === "key") {
18915
+ if (parsed.body.itemType === "key" || parsed.body.itemType === "hidden-key") {
18538
18916
  try {
18539
18917
  itemId = normalizeAssetKey(itemId);
18540
18918
  } catch (error) {
@@ -18858,6 +19236,7 @@ init_zod();
18858
19236
  // src/be/agent-fs-user-keys.ts
18859
19237
  init_secret_scrubber();
18860
19238
  init_rbac_roles();
19239
+ init_agent_fs_provision();
18861
19240
  init_users();
18862
19241
 
18863
19242
  class AgentFsKeyValidationError extends Error {
@@ -19003,6 +19382,7 @@ ${block}`, new Date().toISOString(), taskId]);
19003
19382
 
19004
19383
  // src/http/fs.ts
19005
19384
  init_rbac_roles();
19385
+ init_agent_fs_provision();
19006
19386
  init_task_attachment_store();
19007
19387
  init_users();
19008
19388
  init_config3();
@@ -19225,7 +19605,9 @@ var inviteMemberRoute = route({
19225
19605
  schema: agentFsInviteStateSchema
19226
19606
  },
19227
19607
  400: { description: "Invalid body" },
19228
- 403: { description: "A non-admin user token named an email other than its own" },
19608
+ 403: {
19609
+ description: "The caller is not the operator key or a user, or a non-admin user token named an email other than its own"
19610
+ },
19229
19611
  500: { description: "Provisioning or invite failed" }
19230
19612
  },
19231
19613
  auth: { apiKey: true },
@@ -19329,8 +19711,13 @@ var deleteTaskFileRoute = route({
19329
19711
  rbac: { permission: "task.fs.mutate" }
19330
19712
  });
19331
19713
  async function resolveInvite(req, body) {
19332
- const user = authUser(getRequestAuth(req));
19333
- if (!user || !isRbacEnabled())
19714
+ const auth = getRequestAuth(req);
19715
+ if (auth?.kind === "operator")
19716
+ return body;
19717
+ const user = authUser(auth);
19718
+ if (!user)
19719
+ return { denied: "Only the operator key or a user token can invite to the shared drive" };
19720
+ if (!isRbacEnabled())
19334
19721
  return body;
19335
19722
  const grant = await getUserGrant2(user.id);
19336
19723
  if (grant.grantsAll)
@@ -24539,7 +24926,7 @@ function unauthorized2(res) {
24539
24926
  res.end(JSON.stringify({ error: "Unauthorized" }));
24540
24927
  return true;
24541
24928
  }
24542
- function extractBearer(req) {
24929
+ function extractBearer2(req) {
24543
24930
  const header = req.headers.authorization;
24544
24931
  if (!header?.startsWith("Bearer "))
24545
24932
  return null;
@@ -24547,7 +24934,7 @@ function extractBearer(req) {
24547
24934
  return token.startsWith("aswt_") ? token : null;
24548
24935
  }
24549
24936
  async function resolveActiveUser(req) {
24550
- const token = extractBearer(req);
24937
+ const token = extractBearer2(req);
24551
24938
  if (!token)
24552
24939
  return null;
24553
24940
  const resolved = await resolveUserToken(token);
@@ -27985,6 +28372,462 @@ async function handleOAuthLocks(req, res, pathSegments, queryParams) {
27985
28372
  return false;
27986
28373
  }
27987
28374
 
28375
+ // src/http/object-webhooks.ts
28376
+ init_zod();
28377
+ init_object_webhooks();
28378
+ init_triggers();
28379
+ init_route_def();
28380
+ init_utils2();
28381
+ var MAX_BODY_BYTES = 64 * 1024;
28382
+ var objectWebhook = route({
28383
+ method: "post",
28384
+ path: "/api/objects/agent-fs-webhook/{id}",
28385
+ pattern: ["api", "objects", "agent-fs-webhook", null],
28386
+ summary: "Receive agent-fs file.changed events that keep primitive objects in sync",
28387
+ tags: ["Webhooks"],
28388
+ params: object2({ id: string2().describe("Receiver id the swarm registered with agent-fs") }),
28389
+ auth: { apiKey: false },
28390
+ rbac: {
28391
+ ungated: "provider webhook: authenticated by the per-drive Standard Webhooks HMAC secret the swarm registered with agent-fs, not a swarm principal"
28392
+ },
28393
+ responses: {
28394
+ 200: {
28395
+ description: "Event applied or ignored",
28396
+ schema: object2({
28397
+ action: _enum2(["updated", "tombstoned", "restored", "moved", "ignored"]),
28398
+ path: string2(),
28399
+ id: string2().optional(),
28400
+ reason: string2().optional()
28401
+ })
28402
+ },
28403
+ 400: { description: "Body is not a valid event" },
28404
+ 401: { description: "Unknown receiver, missing headers or invalid signature" },
28405
+ 413: { description: "Body exceeds 64 KiB" },
28406
+ 503: { description: "agent-fs could not be read; agent-fs retries the delivery" }
28407
+ }
28408
+ });
28409
+ var header2 = (req, name) => {
28410
+ const value = req.headers[name];
28411
+ return Array.isArray(value) ? value[0] : value;
28412
+ };
28413
+ async function handleObjectWebhooks(req, res, pathSegments) {
28414
+ if (!objectWebhook.match(req.method, pathSegments))
28415
+ return false;
28416
+ if (enforceContentLengthCap(req, res, MAX_BODY_BYTES) === BODY_TOO_LARGE)
28417
+ return true;
28418
+ const chunks = [];
28419
+ let received = 0;
28420
+ for await (const chunk of req) {
28421
+ received += chunk.byteLength;
28422
+ if (received > MAX_BODY_BYTES) {
28423
+ jsonError(res, `Payload too large (max ${MAX_BODY_BYTES} bytes)`, 413);
28424
+ req.resume();
28425
+ return true;
28426
+ }
28427
+ chunks.push(chunk);
28428
+ }
28429
+ const rawBody = Buffer.concat(chunks).toString("utf-8");
28430
+ const id = header2(req, "webhook-id");
28431
+ const timestamp = header2(req, "webhook-timestamp");
28432
+ const signature = header2(req, "webhook-signature");
28433
+ const hook = await objectWebhookSecret2(pathSegments[3] ?? "");
28434
+ const key = hook ? decodeStandardWebhookSecret(hook.secret) : null;
28435
+ if (!hook || !key || !id || !timestamp || !signature || !verifyStandardWebhookSignature(key, rawBody, { id, timestamp, signature })) {
28436
+ jsonError(res, "Invalid webhook signature", 401);
28437
+ return true;
28438
+ }
28439
+ let envelope;
28440
+ try {
28441
+ envelope = JSON.parse(rawBody);
28442
+ } catch {
28443
+ jsonError(res, "Invalid JSON body", 400);
28444
+ return true;
28445
+ }
28446
+ const outcome = await handleObjectWebhookEvent2(hook, envelope);
28447
+ if (outcome.status === 200) {
28448
+ objectWebhook.respond(res, 200, outcome.result);
28449
+ } else {
28450
+ jsonError(res, outcome.error, outcome.status);
28451
+ }
28452
+ return true;
28453
+ }
28454
+
28455
+ // src/http/objects.ts
28456
+ init_zod();
28457
+
28458
+ // src/be/primitives/object-embed.ts
28459
+ init_provider();
28460
+ init_constants3();
28461
+ init_agent_fs_identity();
28462
+ init_db4();
28463
+ init_elements();
28464
+ init_objects();
28465
+ init_service();
28466
+ init_write_object();
28467
+
28468
+ class ObjectEmbedError extends Error {
28469
+ status;
28470
+ version;
28471
+ constructor(status, message, version) {
28472
+ super(message);
28473
+ this.status = status;
28474
+ this.version = version;
28475
+ }
28476
+ }
28477
+ var versionOf = (value) => value && Number.isFinite(Number(value)) ? Number(value) : null;
28478
+ async function sharedDrive() {
28479
+ const value = async (key) => (await getSwarmConfigs2({ scope: "global", key }))[0]?.value?.trim() || process.env[key]?.trim();
28480
+ const orgId = await value("AGENT_FS_DEFAULT_ORG_ID") || await value("AGENT_FS_SHARED_ORG_ID");
28481
+ const driveId = await value("AGENT_FS_DEFAULT_DRIVE_ID");
28482
+ return orgId && driveId ? { orgId, driveId } : null;
28483
+ }
28484
+ async function open(id) {
28485
+ const row = await getDbClient2().get("SELECT * FROM primitive_objects WHERE id = ?", [id]);
28486
+ if (!row)
28487
+ throw new ObjectEmbedError(404, `no object with id '${id}'`);
28488
+ const shared = await sharedDrive();
28489
+ if (!shared || shared.orgId !== row.orgId || shared.driveId !== row.driveId) {
28490
+ throw new ObjectEmbedError(403, "this object is not on the swarm's shared agent-fs drive");
28491
+ }
28492
+ if (row.deletedAt)
28493
+ throw new ObjectEmbedError(404, `object '${id}' was deleted on agent-fs`);
28494
+ const client = row.ownerAgentId ? await agentFsClientFor(row.ownerAgentId) : undefined;
28495
+ if (!client || !row.ownerAgentId) {
28496
+ throw new ObjectEmbedError(503, "owner agent has no agent-fs key");
28497
+ }
28498
+ if (client.identity.orgId !== row.orgId || client.identity.driveId !== row.driveId) {
28499
+ throw new ObjectEmbedError(503, "owner agent's default agent-fs drive is not the object's drive");
28500
+ }
28501
+ const scope = { taskId: "", name: "", key: row.path, orgId: row.orgId, driveId: row.driveId };
28502
+ return { row, owner: row.ownerAgentId, provider: client.provider, scope };
28503
+ }
28504
+ var withLink = (row) => ({ ...row, link: buildAgentFsLiveUrl(row) });
28505
+ async function driveWatched(orgId, driveId) {
28506
+ const hook = await getDbClient2().get("SELECT status FROM agent_fs_object_webhooks WHERE orgId = ? AND driveId = ?", [orgId, driveId]);
28507
+ return hook?.status === "active";
28508
+ }
28509
+ async function recordEditor(id, userId) {
28510
+ await getDbClient2().run("UPDATE primitive_objects SET updated_by = ? WHERE id = ?", [userId, id]);
28511
+ }
28512
+ function asEmbedError(error) {
28513
+ if (!(error instanceof ObjectsError))
28514
+ return error;
28515
+ const status = error.message.startsWith("concurrent writers") ? 409 : 400;
28516
+ return new ObjectEmbedError(status, error.message);
28517
+ }
28518
+ async function readObject(id, knownVersion) {
28519
+ const { row, provider, scope } = await open(id);
28520
+ if (knownVersion !== undefined) {
28521
+ if (row.fileVersion === knownVersion && await driveWatched(row.orgId, row.driveId)) {
28522
+ return { object: withLink(row), version: knownVersion, unchanged: true };
28523
+ }
28524
+ let current = null;
28525
+ try {
28526
+ current = await provider.currentVersion(scope);
28527
+ } catch (error) {
28528
+ if (error instanceof FilesError && error.code === "Unauthorized")
28529
+ throw error;
28530
+ }
28531
+ if (current !== null && current === knownVersion) {
28532
+ return { object: withLink(row), version: current, unchanged: true };
28533
+ }
28534
+ }
28535
+ let response;
28536
+ try {
28537
+ response = await provider.download(scope);
28538
+ } catch (error) {
28539
+ if (error instanceof FilesError && error.code === "NotFound") {
28540
+ throw new ObjectEmbedError(404, `the file for object '${id}' is missing on agent-fs`);
28541
+ }
28542
+ throw error;
28543
+ }
28544
+ const version = versionOf(response.headers.get("x-agent-fs-version")) ?? row.fileVersion;
28545
+ const text = await response.text();
28546
+ let content = text;
28547
+ try {
28548
+ content = JSON.parse(text);
28549
+ } catch {}
28550
+ return { object: withLink({ ...row, fileVersion: version }), version, unchanged: false, content };
28551
+ }
28552
+ async function saveBoardContent(input) {
28553
+ const { row, provider, scope } = await open(input.id);
28554
+ if (row.kind !== "board") {
28555
+ throw new ObjectEmbedError(400, `object ${row.id} is a ${row.kind}; only a board takes a full save`);
28556
+ }
28557
+ let scene;
28558
+ try {
28559
+ scene = parseScene(input.content, row.path);
28560
+ } catch (error) {
28561
+ throw asEmbedError(error);
28562
+ }
28563
+ if (scene.type !== undefined && scene.type !== "excalidraw") {
28564
+ throw new ObjectEmbedError(400, "content is not an Excalidraw scene (type must be 'excalidraw')");
28565
+ }
28566
+ const doc = PRIMITIVE_KINDS.board?.withId(scene, row.id) ?? scene;
28567
+ const swarm = doc.swarm;
28568
+ if (swarm.title === undefined && row.title)
28569
+ swarm.title = row.title;
28570
+ const body = JSON.stringify(doc, null, 2);
28571
+ if (Buffer.byteLength(body) > MAX_OBJECT_BYTES) {
28572
+ throw new ObjectEmbedError(413, `the board would exceed ${MAX_OBJECT_BYTES} bytes; nothing written`);
28573
+ }
28574
+ let written;
28575
+ try {
28576
+ written = await provider.upload(scope, body, {
28577
+ contentType: "application/json",
28578
+ ifMatch: String(input.ifMatch),
28579
+ message: `edit via ${input.actor.via} by ${input.actor.name ?? "operator"}`
28580
+ });
28581
+ } catch (error) {
28582
+ if (!(error instanceof FilesError && error.code === "Conflict"))
28583
+ throw error;
28584
+ const current = await provider.currentVersion(scope).catch(() => null);
28585
+ throw new ObjectEmbedError(409, `the board changed on agent-fs since version ${input.ifMatch}; reload it`, current);
28586
+ }
28587
+ const version = versionOf(written.version);
28588
+ await recordObjectVersion(row.id, version);
28589
+ await recordEditor(row.id, input.actor.userId);
28590
+ return { object: withLink({ ...row, fileVersion: version }), version };
28591
+ }
28592
+ async function applySheetOp(input) {
28593
+ const { row, owner } = await open(input.id);
28594
+ if (row.kind !== "sheet") {
28595
+ throw new ObjectEmbedError(400, `object ${row.id} is a ${row.kind}, not a sheet`);
28596
+ }
28597
+ const target = { agentId: owner, id: row.id };
28598
+ const { op } = input;
28599
+ let result;
28600
+ try {
28601
+ if (op.op === "setRange") {
28602
+ result = await setSheetRange({ ...target, range: op.range, values: op.values });
28603
+ } else if (op.op === "clearRange") {
28604
+ result = await clearSheetRange({ ...target, range: op.range });
28605
+ } else {
28606
+ result = await appendSheetRows({ ...target, tab: op.tab, rows: op.rows });
28607
+ }
28608
+ } catch (error) {
28609
+ throw asEmbedError(error);
28610
+ }
28611
+ await recordEditor(row.id, input.actor.userId);
28612
+ return { op: op.op, ...result };
28613
+ }
28614
+
28615
+ // src/http/objects.ts
28616
+ init_write_object();
28617
+ init_users();
28618
+ init_rbac();
28619
+ init_request_auth_context();
28620
+ init_favorite_owner();
28621
+ init_request_principal();
28622
+ init_route_def();
28623
+ init_utils2();
28624
+ var ObjectSchema = object2({
28625
+ id: string2(),
28626
+ kind: string2(),
28627
+ orgId: string2(),
28628
+ driveId: string2(),
28629
+ path: string2(),
28630
+ title: string2().nullable(),
28631
+ fileVersion: number2().nullable(),
28632
+ ownerAgentId: string2().nullable(),
28633
+ createdAt: string2(),
28634
+ updatedAt: string2(),
28635
+ link: string2().nullable()
28636
+ });
28637
+ var params2 = object2({ id: string2().uuid().describe("Object id (`swarm.id` in the file)") });
28638
+ var CellSchema = union3([number2(), string2(), boolean(), _null()]);
28639
+ var CellRowsSchema = array2(array2(CellSchema));
28640
+ var objectErrors = {
28641
+ 400: { description: "Invalid input, or the object is not the kind this route edits" },
28642
+ 403: {
28643
+ description: "Permission denied, a page guest, a read-only page session, or an object off the shared drive"
28644
+ },
28645
+ 404: { description: "No such object, or its file is gone" },
28646
+ 503: { description: "The owner agent has no agent-fs key on the object's drive" }
28647
+ };
28648
+ var getObjectRoute = route({
28649
+ method: "get",
28650
+ path: "/api/objects/{id}",
28651
+ pattern: ["api", "objects", null],
28652
+ summary: "Read a board or sheet on the shared drive, or confirm it is unchanged",
28653
+ tags: ["Objects"],
28654
+ params: params2,
28655
+ query: object2({
28656
+ knownVersion: exports_coerce.number().int().min(0).optional().describe("The version the caller holds. A match answers `unchanged: true` with no content")
28657
+ }),
28658
+ rbac: { permission: "objects.read" },
28659
+ responses: {
28660
+ 200: {
28661
+ description: "The object with its content, or `unchanged: true` with no content",
28662
+ schema: object2({
28663
+ object: ObjectSchema,
28664
+ version: number2().nullable(),
28665
+ unchanged: boolean(),
28666
+ content: unknown().optional()
28667
+ })
28668
+ },
28669
+ ...objectErrors
28670
+ }
28671
+ });
28672
+ var putContentRoute = route({
28673
+ method: "put",
28674
+ path: "/api/objects/{id}/content",
28675
+ pattern: ["api", "objects", null, "content"],
28676
+ summary: "Save a board's full Excalidraw scene, guarded by its agent-fs version",
28677
+ tags: ["Objects"],
28678
+ params: params2,
28679
+ body: object2({
28680
+ content: record2(string2(), unknown()).describe("The Excalidraw scene"),
28681
+ ifMatch: number2().int().min(0).describe("The version the scene was edited from")
28682
+ }),
28683
+ maxBodyBytes: MAX_OBJECT_BYTES + 256 * 1024,
28684
+ rbac: { permission: "objects.write" },
28685
+ responses: {
28686
+ 200: {
28687
+ description: "Saved",
28688
+ schema: object2({ object: ObjectSchema, version: number2().nullable() })
28689
+ },
28690
+ ...objectErrors,
28691
+ 409: { description: "The board changed since `ifMatch`; the body carries its `version`" },
28692
+ 413: { description: "The scene exceeds 5 MiB" }
28693
+ }
28694
+ });
28695
+ var sheetOpsRoute = route({
28696
+ method: "post",
28697
+ path: "/api/objects/{id}/sheet-ops",
28698
+ pattern: ["api", "objects", null, "sheet-ops"],
28699
+ summary: "Patch sheet cells; the server recalculates and merges concurrent edits",
28700
+ tags: ["Objects"],
28701
+ params: params2,
28702
+ body: discriminatedUnion("op", [
28703
+ object2({ op: literal2("setRange"), range: string2().min(1), values: CellRowsSchema }),
28704
+ object2({ op: literal2("clearRange"), range: string2().min(1) }),
28705
+ object2({ op: literal2("appendRows"), tab: string2().min(1), rows: CellRowsSchema })
28706
+ ]),
28707
+ maxBodyBytes: 2 * 1024 * 1024,
28708
+ rbac: { permission: "objects.write" },
28709
+ responses: {
28710
+ 200: {
28711
+ description: "Applied: the range written and the new version",
28712
+ schema: object2({
28713
+ op: _enum2(["setRange", "clearRange", "appendRows"]),
28714
+ range: string2(),
28715
+ version: number2(),
28716
+ changed: number2().optional(),
28717
+ recalculated: number2().optional(),
28718
+ cleared: number2().optional()
28719
+ })
28720
+ },
28721
+ ...objectErrors,
28722
+ 409: { description: "Other writers changed the sheet on every retry; try again" }
28723
+ }
28724
+ });
28725
+ var publicObject = (o) => ({
28726
+ id: o.id,
28727
+ kind: o.kind,
28728
+ orgId: o.orgId,
28729
+ driveId: o.driveId,
28730
+ path: o.path,
28731
+ title: o.title,
28732
+ fileVersion: o.fileVersion,
28733
+ ownerAgentId: o.ownerAgentId,
28734
+ createdAt: o.createdAt,
28735
+ updatedAt: o.updatedAt,
28736
+ link: o.link
28737
+ });
28738
+ async function authorize(req, res, myAgentId, verb) {
28739
+ const auth = getRequestAuth(req);
28740
+ if (auth?.kind === "guest" || auth?.kind === "controller") {
28741
+ jsonError(res, "sign in to the swarm to view this object", 403);
28742
+ return null;
28743
+ }
28744
+ const principal = await resolveRequestPrincipal(req, myAgentId, {
28745
+ unauthenticatedFallback: "operator"
28746
+ });
28747
+ const decision = principal ? can({ principal, verb, resource: { kind: "none" }, source: "http" }) : { allow: false, reason: "no authenticated principal" };
28748
+ if (!decision.allow) {
28749
+ jsonError(res, decision.reason, 403);
28750
+ return null;
28751
+ }
28752
+ const via = auth?.page ? "page" : "app";
28753
+ if (verb === "objects.write" && auth?.page && principal?.kind !== "user") {
28754
+ jsonError(res, "this page session is read-only; sign in to the swarm to edit", 403);
28755
+ return null;
28756
+ }
28757
+ let user = principal?.kind === "user" ? authUser(auth) : undefined;
28758
+ if (!user && isOperatorAuth(auth) && !auth.page && !myAgentId) {
28759
+ const pickedId = dashboardUserIdHeader(req);
28760
+ const picked = pickedId ? await findUserById(pickedId) : null;
28761
+ if (picked?.status === "active" && !picked.mergedIntoUserId)
28762
+ user = picked;
28763
+ }
28764
+ return { via, userId: user?.id ?? null, name: user?.name ?? null };
28765
+ }
28766
+ function respondError(res, error) {
28767
+ if (!(error instanceof ObjectEmbedError))
28768
+ return false;
28769
+ if (error.status === 409 && error.version !== undefined) {
28770
+ json(res, { error: error.message, version: error.version }, 409);
28771
+ } else {
28772
+ jsonError(res, error.message, error.status);
28773
+ }
28774
+ return true;
28775
+ }
28776
+ async function handleObjects(req, res, pathSegments, queryParams, myAgentId) {
28777
+ if (getObjectRoute.match(req.method, pathSegments)) {
28778
+ const parsed = await getObjectRoute.parse(req, res, pathSegments, queryParams);
28779
+ if (!parsed)
28780
+ return true;
28781
+ if (!await authorize(req, res, myAgentId, "objects.read"))
28782
+ return true;
28783
+ try {
28784
+ const read = await readObject(parsed.params.id, parsed.query.knownVersion);
28785
+ getObjectRoute.respond(res, 200, { ...read, object: publicObject(read.object) });
28786
+ } catch (error) {
28787
+ if (!respondError(res, error))
28788
+ throw error;
28789
+ }
28790
+ return true;
28791
+ }
28792
+ if (putContentRoute.match(req.method, pathSegments)) {
28793
+ const parsed = await putContentRoute.parse(req, res, pathSegments, queryParams);
28794
+ if (!parsed)
28795
+ return true;
28796
+ const actor = await authorize(req, res, myAgentId, "objects.write");
28797
+ if (!actor)
28798
+ return true;
28799
+ try {
28800
+ const saved = await saveBoardContent({
28801
+ id: parsed.params.id,
28802
+ content: parsed.body.content,
28803
+ ifMatch: parsed.body.ifMatch,
28804
+ actor
28805
+ });
28806
+ putContentRoute.respond(res, 200, { ...saved, object: publicObject(saved.object) });
28807
+ } catch (error) {
28808
+ if (!respondError(res, error))
28809
+ throw error;
28810
+ }
28811
+ return true;
28812
+ }
28813
+ if (sheetOpsRoute.match(req.method, pathSegments)) {
28814
+ const parsed = await sheetOpsRoute.parse(req, res, pathSegments, queryParams);
28815
+ if (!parsed)
28816
+ return true;
28817
+ const actor = await authorize(req, res, myAgentId, "objects.write");
28818
+ if (!actor)
28819
+ return true;
28820
+ try {
28821
+ sheetOpsRoute.respond(res, 200, await applySheetOp({ id: parsed.params.id, op: parsed.body, actor }));
28822
+ } catch (error) {
28823
+ if (!respondError(res, error))
28824
+ throw error;
28825
+ }
28826
+ return true;
28827
+ }
28828
+ return false;
28829
+ }
28830
+
27988
28831
  // src/http/onboarding.ts
27989
28832
  init_openai2();
27990
28833
  init_automation_preflight();
@@ -29180,6 +30023,7 @@ init_task_citations2();
29180
30023
  init_task_ui_spec();
29181
30024
  init_users();
29182
30025
  init_rbac();
30026
+ init_session_mirror();
29183
30027
  init_context_key();
29184
30028
  init_errors2();
29185
30029
  init_sibling_awareness();
@@ -30115,7 +30959,7 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
30115
30959
  const parsed = await createTask.parse(req, res, pathSegments, queryParams);
30116
30960
  if (!parsed)
30117
30961
  return true;
30118
- const trustedUserId = await resolveHttpAuditUserId(req, myAgentId);
30962
+ const trustedUserId = await resolveHttpRequesterUserId(req, myAgentId);
30119
30963
  const requestedByUserId = await resolveTaskRequester(req, myAgentId, parsed.body.requestedByUserId, trustedUserId);
30120
30964
  let defaultAgentId = parsed.body.agentId || undefined;
30121
30965
  if (!defaultAgentId) {
@@ -30226,6 +31070,9 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
30226
31070
  parentTaskId: task.parentTaskId
30227
31071
  }
30228
31072
  });
31073
+ if (principal.kind === "user" || principal.kind === "operator") {
31074
+ getDbClient2().afterCommit(() => mirrorSessionPrompt(task));
31075
+ }
30229
31076
  createTask.respond(res, 201, task);
30230
31077
  } catch (error) {
30231
31078
  if (error instanceof TaskRoutingAuthorizationError) {
@@ -30274,6 +31121,9 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
30274
31121
  jsonError(res, "Task not found", 404);
30275
31122
  return true;
30276
31123
  }
31124
+ if (existingTask.status === "draft") {
31125
+ getDbClient2().afterCommit(() => mirrorSessionPrompt(promoted));
31126
+ }
30277
31127
  promoteDraftTaskRoute.respond(res, 200, promoted);
30278
31128
  return true;
30279
31129
  }
@@ -30391,7 +31241,7 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
30391
31241
  jsonError(res, "Forbidden: caller cannot steer this task", 403);
30392
31242
  return true;
30393
31243
  }
30394
- const trustedUserId = await await resolveHttpAuditUserId(req, myAgentId);
31244
+ const trustedUserId = await await resolveHttpRequesterUserId(req, myAgentId);
30395
31245
  let requestedByUserId = trustedUserId ?? undefined;
30396
31246
  if (process.env.TRUST_BODY_REQUESTED_BY_USER_ID !== "false" && !requestedByUserId && parsed.body.requestedByUserId) {
30397
31247
  requestedByUserId = (await findUserById(parsed.body.requestedByUserId))?.id;
@@ -31514,7 +32364,7 @@ async function handlePages(req, res, pathSegments, queryParams, myAgentId) {
31514
32364
  passwordHash = await Bun.password.hash(parsed.body.password, "bcrypt");
31515
32365
  }
31516
32366
  try {
31517
- const key = parsed.body.key ? await authorizeAssetKeyWrite(parsed.body.key, await resolveHttpAuditUserId(req, myAgentId)) : undefined;
32367
+ const key = parsed.body.key ? await authorizeAssetKeyWrite(parsed.body.key, await resolveHttpRequesterUserId(req, myAgentId)) : undefined;
31518
32368
  const page = await createPage2({
31519
32369
  key,
31520
32370
  agentId: myAgentId,
@@ -31718,7 +32568,7 @@ async function handlePages(req, res, pathSegments, queryParams, myAgentId) {
31718
32568
  let key;
31719
32569
  if (parsed.body.key !== undefined) {
31720
32570
  try {
31721
- key = await authorizeAssetKeyWrite(parsed.body.key, await resolveHttpAuditUserId(req, myAgentId));
32571
+ key = await authorizeAssetKeyWrite(parsed.body.key, await resolveHttpRequesterUserId(req, myAgentId));
31722
32572
  } catch (error) {
31723
32573
  if (error instanceof AssetKeyAuthorizationError) {
31724
32574
  jsonError(res, error.message, error.statusCode);
@@ -34639,6 +35489,7 @@ var pollTriggers = route({
34639
35489
  404: { description: "Agent not found" }
34640
35490
  }
34641
35491
  });
35492
+ var NEEDS_WRITE = Symbol("poll-needs-write");
34642
35493
  var CHANNEL_ACTIVITY_INTERVAL_MS = 60000;
34643
35494
  var lastChannelActivityCheckAt = 0;
34644
35495
  async function attachmentsForTrigger(taskId) {
@@ -34751,19 +35602,29 @@ async function handlePoll(req, res, pathSegments, queryParams, myAgentId) {
34751
35602
  let runtimeDraining = false;
34752
35603
  let result;
34753
35604
  try {
34754
- result = await getDbClient2().transaction(async () => {
35605
+ const pollBody = async (probe) => {
34755
35606
  const agent = await getAgentById2(myAgentId);
34756
35607
  if (!agent) {
34757
35608
  return { error: "Agent not found", status: 404 };
34758
35609
  }
34759
35610
  if (modelTierOverrides) {
34760
- await setAgentModelTierOverrides(agent.id, modelTierOverrides);
35611
+ if (!probe)
35612
+ await setAgentModelTierOverrides(agent.id, modelTierOverrides);
35613
+ else if (await modelTierOverridesDiffer(agent.id, modelTierOverrides))
35614
+ return NEEDS_WRITE;
34761
35615
  }
34762
35616
  if (isExtensionAgent2(agent)) {
34763
35617
  return { trigger: null };
34764
35618
  }
34765
- if (isMultiRuntimeEnabled() && !(runtimeInstanceId && await touchRuntimeInstance(runtimeInstanceId, agent.id))) {
34766
- return { trigger: null };
35619
+ if (isMultiRuntimeEnabled()) {
35620
+ if (!runtimeInstanceId)
35621
+ return { trigger: null };
35622
+ if (probe) {
35623
+ if (!await isRuntimeInstanceFresh(runtimeInstanceId, agent.id))
35624
+ return NEEDS_WRITE;
35625
+ } else if (!await touchRuntimeInstance(runtimeInstanceId, agent.id)) {
35626
+ return { trigger: null };
35627
+ }
34767
35628
  }
34768
35629
  if (isMultiRuntimeEnabled() && runtimeInstanceId && (await getRuntimeInstanceById(runtimeInstanceId))?.draining) {
34769
35630
  runtimeDraining = true;
@@ -34775,6 +35636,8 @@ async function handlePoll(req, res, pathSegments, queryParams, myAgentId) {
34775
35636
  const offeredTasks = await hasCapacity2(myAgentId) ? await getOfferedTasksForAgent2(myAgentId) : [];
34776
35637
  const firstOfferedTask = offeredTasks[0];
34777
35638
  if (firstOfferedTask) {
35639
+ if (probe)
35640
+ return NEEDS_WRITE;
34778
35641
  const claimedTask = await claimOfferedTask2(firstOfferedTask.id, myAgentId);
34779
35642
  if (claimedTask) {
34780
35643
  await recordRuntimeTask(claimedTask.id);
@@ -34792,7 +35655,10 @@ async function handlePoll(req, res, pathSegments, queryParams, myAgentId) {
34792
35655
  }
34793
35656
  }
34794
35657
  if (await hasCapacity2(myAgentId)) {
34795
- const pendingTask = await getPendingTaskForAgent2(myAgentId);
35658
+ const pendingProbe = probe ? { skipLogDue: false } : undefined;
35659
+ const pendingTask = await getPendingTaskForAgent2(myAgentId, pendingProbe);
35660
+ if (pendingProbe && (pendingTask || pendingProbe.skipLogDue))
35661
+ return NEEDS_WRITE;
34796
35662
  if (pendingTask) {
34797
35663
  const admission = await canClaim(myAgentId, new Date, pendingTask.requestedByUserId);
34798
35664
  if (!admission.allowed) {
@@ -34882,8 +35748,10 @@ async function handlePoll(req, res, pathSegments, queryParams, myAgentId) {
34882
35748
  };
34883
35749
  }
34884
35750
  }
34885
- const claimedChannels = hasCapability("messaging") ? await claimMentions2(myAgentId) : [];
35751
+ const claimedChannels = hasCapability("messaging") ? await claimMentions2(myAgentId, { dryRun: probe }) : [];
34886
35752
  if (claimedChannels.length > 0) {
35753
+ if (probe)
35754
+ return NEEDS_WRITE;
34887
35755
  return {
34888
35756
  trigger: {
34889
35757
  type: "unread_mentions",
@@ -34913,6 +35781,8 @@ async function handlePoll(req, res, pathSegments, queryParams, myAgentId) {
34913
35781
  };
34914
35782
  const unassignedIds = await getUnassignedTaskIdsForAgent2(myAgentId, 5, async (task) => await poolTaskRunsOnHarness(task, harness) && (!task.profile || await passesProfileCheck(task.profile, task.vcsRepo)));
34915
35783
  if (unassignedIds.length > 0) {
35784
+ if (probe)
35785
+ return NEEDS_WRITE;
34916
35786
  const candidateId = unassignedIds[0];
34917
35787
  const candidateTask = await getTaskById2(candidateId);
34918
35788
  const admission = await canClaim(myAgentId, new Date, candidateTask?.requestedByUserId);
@@ -34992,7 +35862,9 @@ async function handlePoll(req, res, pathSegments, queryParams, myAgentId) {
34992
35862
  }
34993
35863
  }
34994
35864
  return { trigger: null };
34995
- });
35865
+ };
35866
+ const probed = await getDbClient2().transaction(() => pollBody(true), { readOnly: true });
35867
+ result = probed === NEEDS_WRITE ? await getDbClient2().transaction(() => pollBody(false)) : probed;
34996
35868
  } catch (error) {
34997
35869
  console.error("[/api/poll] Database error:", error);
34998
35870
  jsonError(res, `Database error occurred while polling for triggers: ${error instanceof Error ? error.message : String(error)}`, 500);
@@ -36084,7 +36956,7 @@ var createRepo = route({
36084
36956
  201: { description: "Repo created", schema: SwarmRepoSchema },
36085
36957
  400: { description: "Validation error", schema: object2({ error: string2() }) },
36086
36958
  403: {
36087
- description: "Only the lead, the operator or a user can turn allowMerge on",
36959
+ description: "Only the lead, the operator or a user can turn allowMerge on or set a mergePolicy",
36088
36960
  schema: object2({ error: string2() })
36089
36961
  },
36090
36962
  409: { description: "Duplicate repo", schema: object2({ error: string2() }) }
@@ -36110,7 +36982,7 @@ var updateRepo = route({
36110
36982
  responses: {
36111
36983
  200: { description: "Repo updated", schema: SwarmRepoSchema },
36112
36984
  403: {
36113
- description: "Only the lead, the operator or a user can change allowMerge",
36985
+ description: "Only the lead, the operator or a user can change allowMerge or mergePolicy",
36114
36986
  schema: object2({ error: string2() })
36115
36987
  },
36116
36988
  404: { description: "Repo not found", schema: object2({ error: string2() }) },
@@ -36169,7 +37041,7 @@ async function handleRepos(req, res, pathSegments, queryParams, myAgentId) {
36169
37041
  const parsed = await createRepo.parse(req, res, pathSegments, queryParams);
36170
37042
  if (!parsed)
36171
37043
  return true;
36172
- if (changesAllowMerge(null, parsed.body.guidelines)) {
37044
+ if (changesMergePolicy(null, parsed.body.guidelines)) {
36173
37045
  const refusal = await allowMergeRefusal(req, myAgentId);
36174
37046
  if (refusal) {
36175
37047
  jsonError(res, refusal, 403);
@@ -40081,7 +40953,7 @@ async function handleSchedules(req, res, pathSegments, queryParams, myAgentId) {
40081
40953
  return true;
40082
40954
  }
40083
40955
  try {
40084
- const trustedUserId = await resolveHttpAuditUserId(req, myAgentId);
40956
+ const trustedUserId = await resolveHttpRequesterUserId(req, myAgentId);
40085
40957
  let key;
40086
40958
  try {
40087
40959
  key = body.key ? await authorizeAssetKeyWrite(body.key, trustedUserId) : undefined;
@@ -40131,7 +41003,8 @@ async function handleSchedules(req, res, pathSegments, queryParams, myAgentId) {
40131
41003
  params: body.params,
40132
41004
  requiredParams: body.requiredParams,
40133
41005
  requires: body.requires,
40134
- createdBy: await resolveHttpAuditUserId(req, myAgentId) ?? undefined
41006
+ createdByAgentId: myAgentId,
41007
+ createdBy: trustedUserId ?? undefined
40135
41008
  });
40136
41009
  createSchedule.respond(res, 201, schedule);
40137
41010
  } catch (error) {
@@ -40204,7 +41077,7 @@ async function handleSchedules(req, res, pathSegments, queryParams, myAgentId) {
40204
41077
  const body = parsed.body;
40205
41078
  if (parsed.body.key !== undefined) {
40206
41079
  try {
40207
- body.key = await authorizeAssetKeyWrite(parsed.body.key, await resolveHttpAuditUserId(req, myAgentId));
41080
+ body.key = await authorizeAssetKeyWrite(parsed.body.key, await resolveHttpRequesterUserId(req, myAgentId));
40208
41081
  } catch (error) {
40209
41082
  if (error instanceof AssetKeyAuthorizationError) {
40210
41083
  jsonError(res, error.message, error.statusCode);
@@ -40362,9 +41235,8 @@ async function handleSchedules(req, res, pathSegments, queryParams, myAgentId) {
40362
41235
  }
40363
41236
  }
40364
41237
  }
40365
- const updatedBy = await resolveHttpAuditUserId(req, myAgentId);
40366
- if (updatedBy !== null)
40367
- body.updatedBy = updatedBy;
41238
+ body.updatedBy = await resolveHttpAuditUserId(req, myAgentId);
41239
+ body.updatedByAgentId = myAgentId ?? null;
40368
41240
  let schedule;
40369
41241
  try {
40370
41242
  schedule = await updateScheduledTask2(parsed.params.id, body);
@@ -42271,7 +43143,7 @@ async function handleScriptConnections(req, res, pathSegments, queryParams, agen
42271
43143
  label,
42272
43144
  flow: "generic",
42273
43145
  ...parsed.body?.finalRedirect ? { finalRedirect: parsed.body.finalRedirect } : {},
42274
- userId: await resolveHttpAuditUserId(req, agentId)
43146
+ userId: await resolveHttpRequesterUserId(req, agentId)
42275
43147
  });
42276
43148
  authorizeUrlRoute2.respond(res, 200, {
42277
43149
  authorizeUrl: result.url,
@@ -43409,7 +44281,7 @@ var searchRoute = route({
43409
44281
  },
43410
44282
  rbac: { permission: "script.search" }
43411
44283
  });
43412
- var deleteRoute2 = route({
44284
+ var deleteRoute3 = route({
43413
44285
  method: "delete",
43414
44286
  path: "/api/scripts/{name}",
43415
44287
  pattern: ["api", "scripts", null],
@@ -43765,6 +44637,7 @@ async function handleScripts(req, res, pathSegments, queryParams, agentId) {
43765
44637
  if (!agent)
43766
44638
  return true;
43767
44639
  const runtimeInstanceId = ((h) => Array.isArray(h) ? h[0] : h)(req.headers["x-runtime-instance-id"]);
44640
+ const sourceTaskId = ((h) => Array.isArray(h) ? h[0] : h)(req.headers["x-source-task-id"]);
43768
44641
  const secretRefusal = parsed.body.source ? refuseSourceWithSecrets(parsed.body.source) : null;
43769
44642
  if (secretRefusal) {
43770
44643
  json(res, secretRefusal, 400);
@@ -43805,6 +44678,7 @@ async function handleScripts(req, res, pathSegments, queryParams, agentId) {
43805
44678
  executor,
43806
44679
  agentId: agent.id,
43807
44680
  runtimeInstanceId,
44681
+ sourceTaskId,
43808
44682
  egressSecrets: credentials.egressSecrets,
43809
44683
  failedBindings: credentials.failedBindings,
43810
44684
  userConfig: credentials.userConfig,
@@ -43855,7 +44729,8 @@ async function handleScripts(req, res, pathSegments, queryParams, agentId) {
43855
44729
  agentId: agent.id,
43856
44730
  isScratch: true,
43857
44731
  typeChecked: false,
43858
- changeReason: "Auto-saved successful inline run"
44732
+ changeReason: "Auto-saved successful inline run",
44733
+ createdBy: await resolveHttpAuditUserId(req, agent.id)
43859
44734
  });
43860
44735
  autoSaved = { slug, reason: "successful_inline_run" };
43861
44736
  }
@@ -43936,6 +44811,9 @@ async function handleScripts(req, res, pathSegments, queryParams, agentId) {
43936
44811
  fsMode: script.fsMode,
43937
44812
  executor: script.executor,
43938
44813
  createdByAgentId: script.createdByAgentId,
44814
+ updatedByAgentId: script.updatedByAgentId,
44815
+ createdBy: script.createdBy,
44816
+ updatedBy: script.updatedBy,
43939
44817
  createdAt: script.createdAt,
43940
44818
  updatedAt: script.updatedAt
43941
44819
  }));
@@ -44000,8 +44878,8 @@ async function handleScripts(req, res, pathSegments, queryParams, agentId) {
44000
44878
  });
44001
44879
  return true;
44002
44880
  }
44003
- if (deleteRoute2.match(req.method, pathSegments)) {
44004
- const parsed = await deleteRoute2.parse(req, res, pathSegments, queryParams);
44881
+ if (deleteRoute3.match(req.method, pathSegments)) {
44882
+ const parsed = await deleteRoute3.parse(req, res, pathSegments, queryParams);
44005
44883
  if (!parsed)
44006
44884
  return true;
44007
44885
  const agent = await requireAgent2(res, agentId);
@@ -44040,7 +44918,7 @@ async function handleScripts(req, res, pathSegments, queryParams, agentId) {
44040
44918
  }, 409);
44041
44919
  return true;
44042
44920
  }
44043
- deleteRoute2.respond(res, 200, { deleted: outcome.deleted });
44921
+ deleteRoute3.respond(res, 200, { deleted: outcome.deleted });
44044
44922
  return true;
44045
44923
  }
44046
44924
  if (createScriptApiRoute.match(req.method, pathSegments)) {
@@ -44751,6 +45629,7 @@ var SessionTreeResponseSchema = object2({
44751
45629
  labels: record2(string2(), string2()).optional(),
44752
45630
  groups: array2(SessionTreeGroupSchema),
44753
45631
  inbox: SessionSectionCountsSchema,
45632
+ working: SessionSectionCountsSchema.describe("Inbox sessions with a task running and nothing for the person to answer. They list under Working, not Inbox."),
44754
45633
  later: SessionSectionCountsSchema,
44755
45634
  done: SessionSectionCountsSchema,
44756
45635
  noGroup: SessionSectionCountsSchema,
@@ -44860,7 +45739,8 @@ var mintAgentTokenRoute = route({
44860
45739
  },
44861
45740
  403: { description: "Operator or user credentials required" },
44862
45741
  404: { description: "Agent not found and no name given" },
44863
- 409: { description: "Agent already holds an active token" }
45742
+ 409: { description: "Agent already holds an active token" },
45743
+ 410: { description: "An operator deleted this agent id (`agent_deleted`); restore it first" }
44864
45744
  },
44865
45745
  rbac: { permission: "agent.token.manage" }
44866
45746
  });
@@ -44977,8 +45857,14 @@ async function handleAgentTokens(req, res, pathSegments, queryParams) {
44977
45857
  }).catch((error) => {
44978
45858
  if (error instanceof AgentTokenExistsError)
44979
45859
  return { status: 409 };
45860
+ if (error instanceof AgentDeletedError2)
45861
+ return { status: 410 };
44980
45862
  throw error;
44981
45863
  });
45864
+ if (result.status === 410) {
45865
+ jsonError(res, "agent_deleted", 410);
45866
+ return true;
45867
+ }
44982
45868
  if (result.status === 404) {
44983
45869
  jsonError(res, "Agent not found; pass name to create it", 404);
44984
45870
  return true;
@@ -45033,8 +45919,9 @@ var listSessions = route({
45033
45919
  contextKeyPrefix: string2().min(1).optional(),
45034
45920
  keyPrefix: SessionKeyFilterSchema.optional(),
45035
45921
  groupKey: SessionKeyFilterSchema.optional(),
45922
+ ids: string2().optional(),
45036
45923
  noGroup: _enum2(["true", "false"]).transform((v) => v === "true").optional(),
45037
- triage: _enum2(["inbox", "later", "done", "unread"]).optional(),
45924
+ triage: _enum2(["inbox", "working", "later", "done", "unread"]).optional(),
45038
45925
  status: _enum2(["running", "failed", "needs"]).optional(),
45039
45926
  withUserId: string2().min(1).optional(),
45040
45927
  fields: _enum2(["full", "slim"]).optional(),
@@ -45079,19 +45966,21 @@ var triageSessionListRoute = route({
45079
45966
  path: "/api/session-triage",
45080
45967
  pattern: ["api", "session-triage"],
45081
45968
  summary: "Triage every session of one sidebar list",
45082
- description: "The bulk bar's 'Select all N': Done, back to the Inbox, read, or unread for every session that one sessions v2 list shows the caller (the `GET /api/sessions?scope=tree` filters). Needs a picked user.",
45969
+ description: "The bulk bar's 'Select all N': Done, back to the Inbox, read, or unread for every session that one sessions v2 list shows the caller (the `GET /api/sessions?scope=tree` filters), minus `exceptIds`. Needs a picked user.",
45083
45970
  tags: ["Sessions"],
45084
45971
  body: object2({
45085
45972
  action: _enum2(["done", "inbox", "read", "unread"]),
45086
- triage: _enum2(["inbox", "later", "done"]).optional(),
45973
+ triage: _enum2(["inbox", "working", "later", "done"]).optional(),
45087
45974
  noGroup: boolean().optional(),
45088
45975
  groupKey: SessionKeyFilterSchema.optional(),
45976
+ keyPrefix: SessionKeyFilterSchema.refine((key) => sourceOfKey(key) !== null, {
45977
+ message: "keyPrefix must be a source group"
45978
+ }).optional(),
45089
45979
  show: SessionShowSchema,
45090
45980
  hideSource: array2(string2().min(1)).max(32).optional(),
45091
- showSource: array2(string2().min(1)).max(32).optional()
45092
- }).refine((body) => [body.triage, body.noGroup, body.groupKey].filter(Boolean).length === 1, {
45093
- message: "Name exactly one list: triage, noGroup, or groupKey"
45094
- }),
45981
+ showSource: array2(string2().min(1)).max(32).optional(),
45982
+ exceptIds: array2(string2().min(1)).max(500).optional()
45983
+ }).refine((body) => [body.triage, body.noGroup, body.groupKey, body.keyPrefix].filter(Boolean).length === 1, { message: "Name exactly one list: triage, noGroup, groupKey, or keyPrefix" }),
45095
45984
  responses: {
45096
45985
  200: {
45097
45986
  description: "The number of sessions written",
@@ -45153,7 +46042,7 @@ var moveSessionPrefix = route({
45153
46042
  });
45154
46043
  async function withSessionMove(req, res, myAgentId, destination, run) {
45155
46044
  try {
45156
- const changedBy = await resolveHttpAuditUserId(req, myAgentId);
46045
+ const changedBy = await resolveHttpRequesterUserId(req, myAgentId);
45157
46046
  const actor = await resolveSessionActor2(req, myAgentId);
45158
46047
  const key = destination === null ? null : await authorizeAssetKeyWrite(destination, changedBy);
45159
46048
  await assertAssetKeyMovesAllowed2();
@@ -45391,6 +46280,7 @@ async function handleSessions(req, res, pathSegments, queryParams, myAgentId) {
45391
46280
  contextKeyPrefix: parsed.query.contextKeyPrefix,
45392
46281
  keyPrefix: parsed.query.keyPrefix,
45393
46282
  groupKey: parsed.query.groupKey,
46283
+ rootIds: parsed.query.ids?.split(",").map((id) => id.trim()).filter(Boolean).slice(0, 200),
45394
46284
  noGroup: parsed.query.noGroup,
45395
46285
  triage: parsed.query.triage,
45396
46286
  status: parsed.query.status,
@@ -45451,8 +46341,8 @@ async function handleSessions(req, res, pathSegments, queryParams, myAgentId) {
45451
46341
  jsonError(res, "Pick a user to triage sessions", 400);
45452
46342
  return true;
45453
46343
  }
45454
- const { action, show, ...list } = parsed.body;
45455
- const updated = await triageSessionList(actor.userId, { ...list, mine: show !== "all" }, action, actor.readAll);
46344
+ const { action, show, exceptIds, ...list } = parsed.body;
46345
+ const updated = await triageSessionList(actor.userId, { ...list, exceptRootIds: exceptIds, mine: show !== "all" }, action, actor.readAll);
45456
46346
  triageSessionListRoute.respond(res, 200, { updated });
45457
46347
  return true;
45458
46348
  }
@@ -45670,6 +46560,7 @@ async function handleSessions(req, res, pathSegments, queryParams, myAgentId) {
45670
46560
 
45671
46561
  // src/http/skills.ts
45672
46562
  init_zod();
46563
+ init_audit_user();
45673
46564
  init_db4();
45674
46565
  init_skill_parser();
45675
46566
 
@@ -46489,7 +47380,9 @@ async function handleSkills(req, res, pathSegments, queryParams, myAgentId) {
46489
47380
  sourceRepo: parsed.body.sourceRepo,
46490
47381
  sourcePath: parsed.body.sourcePath,
46491
47382
  sourceBranch: branch,
46492
- isComplex: parsed.body.isComplex ?? false
47383
+ isComplex: parsed.body.isComplex ?? false,
47384
+ createdByAgentId: myAgentId ?? null,
47385
+ createdBy: await resolveHttpAuditUserId(req, myAgentId)
46493
47386
  });
46494
47387
  installRemoteRoute.respond(res, 201, { skill });
46495
47388
  } catch (err) {
@@ -46507,6 +47400,7 @@ async function handleSkills(req, res, pathSegments, queryParams, myAgentId) {
46507
47400
  })() : await listSkills2({ type: "remote" });
46508
47401
  let updated = 0;
46509
47402
  const errors = [];
47403
+ const actor = await resolveHttpAuditActor(req, myAgentId);
46510
47404
  for (const skill of remoteSkills) {
46511
47405
  if (skill.isComplex || !skill.sourceRepo)
46512
47406
  continue;
@@ -46535,7 +47429,9 @@ async function handleSkills(req, res, pathSegments, queryParams, myAgentId) {
46535
47429
  disableModelInvocation: pm.disableModelInvocation,
46536
47430
  userInvocable: pm.userInvocable,
46537
47431
  sourceHash: newHash,
46538
- lastFetchedAt: now
47432
+ lastFetchedAt: now,
47433
+ updatedBy: actor.userId,
47434
+ updatedByAgentId: actor.agentId
46539
47435
  });
46540
47436
  updated++;
46541
47437
  } else {
@@ -46652,6 +47548,7 @@ async function handleSkills(req, res, pathSegments, queryParams, myAgentId) {
46652
47548
  }
46653
47549
  try {
46654
47550
  const files = await upsertSkillFiles2(parsed.params.id, parsed.body.files);
47551
+ await setSkillUpdatedBy2(parsed.params.id, await resolveHttpAuditActor(req, myAgentId));
46655
47552
  const updatedSkill = await getSkillById2(parsed.params.id);
46656
47553
  bulkUpsertSkillFilesRoute.respond(res, 200, {
46657
47554
  files,
@@ -46702,6 +47599,7 @@ async function handleSkills(req, res, pathSegments, queryParams, myAgentId) {
46702
47599
  path: decodeSkillFilePath(pathSegments),
46703
47600
  ...parsed.body
46704
47601
  });
47602
+ await setSkillUpdatedBy2(parsed.params.id, await resolveHttpAuditActor(req, myAgentId));
46705
47603
  const updatedSkill = await getSkillById2(parsed.params.id);
46706
47604
  upsertSkillFileRoute.respond(res, 200, { file, skill: updatedSkill });
46707
47605
  } catch (err) {
@@ -46728,6 +47626,7 @@ async function handleSkills(req, res, pathSegments, queryParams, myAgentId) {
46728
47626
  jsonError(res, "Skill file not found", 404);
46729
47627
  return true;
46730
47628
  }
47629
+ await setSkillUpdatedBy2(parsed.params.id, await resolveHttpAuditActor(req, myAgentId));
46731
47630
  const updatedSkill = await getSkillById2(parsed.params.id);
46732
47631
  deleteSkillFileRoute.respond(res, 200, { success: true, skill: updatedSkill });
46733
47632
  } catch (err) {
@@ -46767,7 +47666,9 @@ async function handleSkills(req, res, pathSegments, queryParams, myAgentId) {
46767
47666
  agent: pm.agent,
46768
47667
  disableModelInvocation: pm.disableModelInvocation,
46769
47668
  userInvocable: pm.userInvocable,
46770
- systemDefault: parsed.body.systemDefault
47669
+ systemDefault: parsed.body.systemDefault,
47670
+ createdByAgentId: myAgentId ?? null,
47671
+ createdBy: await resolveHttpAuditUserId(req, myAgentId)
46771
47672
  });
46772
47673
  createSkillRoute.respond(res, 201, { skill });
46773
47674
  } catch (err) {
@@ -46826,6 +47727,9 @@ async function handleSkills(req, res, pathSegments, queryParams, myAgentId) {
46826
47727
  updates.disableModelInvocation = pm.disableModelInvocation;
46827
47728
  updates.userInvocable = pm.userInvocable;
46828
47729
  }
47730
+ const actor = await resolveHttpAuditActor(req, myAgentId);
47731
+ updates.updatedBy = actor.userId;
47732
+ updates.updatedByAgentId = actor.agentId;
46829
47733
  const skill = await updateSkill2(parsed.params.id, updates);
46830
47734
  if (!skill) {
46831
47735
  jsonError(res, "Skill not found", 404);
@@ -46889,7 +47793,7 @@ var slackEventsRoute = route({
46889
47793
  }
46890
47794
  });
46891
47795
  var SLACK_EVENTS_MAX_BODY_BYTES = 1024 * 1024;
46892
- function header2(req, name) {
47796
+ function header3(req, name) {
46893
47797
  const value = req.headers[name];
46894
47798
  return Array.isArray(value) ? value[0] : value;
46895
47799
  }
@@ -46929,11 +47833,11 @@ async function handleSlackEvents(req, res, pathSegments) {
46929
47833
  return true;
46930
47834
  const result = await receiver.handle({
46931
47835
  rawBody: Buffer.concat(chunks),
46932
- signature: header2(req, "x-slack-signature"),
46933
- timestamp: header2(req, "x-slack-request-timestamp"),
46934
- contentType: header2(req, "content-type"),
46935
- retryNum: header2(req, "x-slack-retry-num"),
46936
- retryReason: header2(req, "x-slack-retry-reason"),
47836
+ signature: header3(req, "x-slack-signature"),
47837
+ timestamp: header3(req, "x-slack-request-timestamp"),
47838
+ contentType: header3(req, "content-type"),
47839
+ retryNum: header3(req, "x-slack-retry-num"),
47840
+ retryReason: header3(req, "x-slack-retry-reason"),
46937
47841
  signingSecret: process.env.SLACK_SIGNING_SECRET
46938
47842
  });
46939
47843
  res.writeHead(result.status, {
@@ -47526,11 +48430,27 @@ var toolHookRoute = route({
47526
48430
  400: { description: "Invalid body or missing X-Agent-ID header" }
47527
48431
  }
47528
48432
  });
47529
- function header3(req, name) {
48433
+ var toolHookStatusRoute = route({
48434
+ method: "get",
48435
+ path: "/api/tool-hooks/status",
48436
+ pattern: ["api", "tool-hooks", "status"],
48437
+ summary: "Whether any enabled extension takes harness-native tool calls",
48438
+ description: "Worker shims read this before each native tool call and skip `POST /api/tool-hooks` while " + "`native` is false, so a swarm with no native-tool extension pays no per-call round trip. " + "Shims cache the answer for a short time.",
48439
+ tags: ["Extensions"],
48440
+ auth: { apiKey: true },
48441
+ responses: {
48442
+ 200: { description: "Native tool hook status", schema: object2({ native: boolean() }) }
48443
+ }
48444
+ });
48445
+ function header4(req, name) {
47530
48446
  const raw = req.headers[name];
47531
48447
  return Array.isArray(raw) ? raw[0] : raw;
47532
48448
  }
47533
48449
  async function handleToolHooks(req, res, pathSegments, queryParams, myAgentId) {
48450
+ if (toolHookStatusRoute.match(req.method, pathSegments)) {
48451
+ toolHookStatusRoute.respond(res, 200, { native: hasNativeToolHandlers2() });
48452
+ return true;
48453
+ }
47534
48454
  if (!toolHookRoute.match(req.method, pathSegments))
47535
48455
  return false;
47536
48456
  if (!myAgentId) {
@@ -47541,12 +48461,14 @@ async function handleToolHooks(req, res, pathSegments, queryParams, myAgentId) {
47541
48461
  if (!parsed)
47542
48462
  return true;
47543
48463
  const body = scrubObject(parsed.body);
48464
+ const sourceTaskId = header4(req, "x-source-task-id");
47544
48465
  const requestInfo = {
47545
48466
  sessionId: undefined,
47546
48467
  agentId: myAgentId,
47547
- runtimeInstanceId: header3(req, "x-runtime-instance-id"),
47548
- sourceTaskId: header3(req, "x-source-task-id"),
47549
- contextKey: header3(req, "x-context-key"),
48468
+ runtimeInstanceId: header4(req, "x-runtime-instance-id"),
48469
+ sourceTaskId,
48470
+ auditSourceTaskId: sourceTaskId ?? header4(req, "x-audit-source-task-id"),
48471
+ contextKey: header4(req, "x-context-key"),
47550
48472
  callOrigin: "native",
47551
48473
  harness: body.harness
47552
48474
  };
@@ -47610,7 +48532,7 @@ async function ensureTrackerAuthorizeAdmin(req, res, providerName) {
47610
48532
  const allowed = await ensureHttpPermission(req, res, "oauth-authorization.manage", `Only the lead can start the ${providerName} OAuth flow.`, agentId);
47611
48533
  if (!allowed)
47612
48534
  return null;
47613
- return { userId: await resolveHttpAuditUserId(req, agentId) };
48535
+ return { userId: await resolveHttpRequesterUserId(req, agentId) };
47614
48536
  }
47615
48537
 
47616
48538
  // src/http/trackers/jira.ts
@@ -48334,45 +49256,6 @@ init_rbac_roles();
48334
49256
  init_users();
48335
49257
  init_rbac();
48336
49258
  init_types5();
48337
-
48338
- // src/http/operator-actor.ts
48339
- init_users();
48340
- init_api_key();
48341
- init_request_auth_context();
48342
- init_request_principal();
48343
- init_utils2();
48344
- function extractBearer2(req) {
48345
- const raw = req.headers.authorization;
48346
- const header = Array.isArray(raw) ? raw[0] : raw;
48347
- if (!header || !header.startsWith("Bearer "))
48348
- return null;
48349
- return header.slice(7);
48350
- }
48351
- function getOperatorActor(req, res) {
48352
- if (rejectGuest(req, res))
48353
- return null;
48354
- const auth = getRequestAuth(req);
48355
- const userId = authUserId(auth);
48356
- if (userId) {
48357
- const tokenId = auth?.kind === "user" ? auth.tokenId : undefined;
48358
- return tokenId ? { kind: "user", id: userId, tokenId } : { kind: "user", id: userId };
48359
- }
48360
- if (isOperatorAuth(auth)) {
48361
- return { kind: "operator", id: auth.fingerprint };
48362
- }
48363
- const rawKey = extractBearer2(req);
48364
- const swarmKey = getApiKey();
48365
- if (!swarmKey) {
48366
- return { kind: "operator", id: fingerprintApiKey("") };
48367
- }
48368
- if (!rawKey || rawKey !== swarmKey) {
48369
- jsonError(res, "Unauthorized", 401);
48370
- return null;
48371
- }
48372
- return { kind: "operator", id: fingerprintApiKey(rawKey) };
48373
- }
48374
-
48375
- // src/http/user-roles.ts
48376
49259
  init_request_principal();
48377
49260
  init_route_def();
48378
49261
  init_utils2();
@@ -48512,6 +49395,7 @@ async function handleUserRoles(req, res, pathSegments, queryParams) {
48512
49395
  init_zod();
48513
49396
  init_db4();
48514
49397
  init_rbac_roles();
49398
+ init_unmapped_identities();
48515
49399
  init_users();
48516
49400
  init_rbac();
48517
49401
  init_types5();
@@ -48580,7 +49464,12 @@ var UnmappedIdentitySchema = object2({
48580
49464
  lastSeenAt: string2().nullable(),
48581
49465
  count: number2(),
48582
49466
  sampleEventType: string2().nullable(),
48583
- sampleContext: unknown().nullable()
49467
+ sampleContext: unknown().nullable(),
49468
+ dismissedAt: string2().optional(),
49469
+ dismissedBy: string2().optional()
49470
+ });
49471
+ var UnmappedIdentityRefsSchema = object2({
49472
+ identities: array2(object2({ kind: string2().min(1), externalId: string2().min(1) })).min(1).max(500)
48584
49473
  });
48585
49474
  var whoamiRoute = route({
48586
49475
  method: "get",
@@ -48662,7 +49551,9 @@ var listUnmapped = route({
48662
49551
  tags: ["Users"],
48663
49552
  query: object2({
48664
49553
  kind: string2().optional(),
48665
- limit: exports_coerce.number().int().min(1).max(1000).optional()
49554
+ limit: exports_coerce.number().int().min(1).max(1000).optional(),
49555
+ dismissed: _enum2(["true", "false"]).optional(),
49556
+ includeBots: _enum2(["true", "false"]).optional()
48666
49557
  }),
48667
49558
  responses: {
48668
49559
  200: {
@@ -48702,6 +49593,45 @@ var resolveUnmapped = route({
48702
49593
  },
48703
49594
  auth: { apiKey: true }
48704
49595
  });
49596
+ var DISMISS_RBAC = {
49597
+ ungated: "same posture as POST /api/users/unmapped/{kind}/{externalId}/resolve: bearer auth, guests rejected; it links and trusts nothing"
49598
+ };
49599
+ var dismissUnmapped = route({
49600
+ method: "post",
49601
+ path: "/api/users/unmapped/dismiss",
49602
+ pattern: ["api", "users", "unmapped", "dismiss"],
49603
+ summary: "Dismiss unmapped identities: hide them from triage and stop recording them. Links nothing.",
49604
+ tags: ["Users"],
49605
+ body: UnmappedIdentityRefsSchema,
49606
+ responses: {
49607
+ 200: {
49608
+ description: "Identities moved to the ignore list",
49609
+ schema: object2({ dismissed: number2() })
49610
+ },
49611
+ 400: { description: "Validation error" },
49612
+ 401: { description: "Unauthorized" }
49613
+ },
49614
+ auth: { apiKey: true },
49615
+ rbac: DISMISS_RBAC
49616
+ });
49617
+ var restoreUnmapped = route({
49618
+ method: "post",
49619
+ path: "/api/users/unmapped/restore",
49620
+ pattern: ["api", "users", "unmapped", "restore"],
49621
+ summary: "Undo a dismissal: return identities to the triage queue",
49622
+ tags: ["Users"],
49623
+ body: UnmappedIdentityRefsSchema,
49624
+ responses: {
49625
+ 200: {
49626
+ description: "Count of identities taken off the ignore list",
49627
+ schema: object2({ restored: number2() })
49628
+ },
49629
+ 400: { description: "Validation error" },
49630
+ 401: { description: "Unauthorized" }
49631
+ },
49632
+ auth: { apiKey: true },
49633
+ rbac: DISMISS_RBAC
49634
+ });
48705
49635
  var getUserRoute = route({
48706
49636
  method: "get",
48707
49637
  path: "/api/users/{id}",
@@ -49144,6 +50074,30 @@ async function collectUnmappedForKind(kind, limit) {
49144
50074
  }
49145
50075
  return Array.from(byId.values());
49146
50076
  }
50077
+ async function collectDismissedForKind(kind, limit) {
50078
+ const rows = await listKv2(dismissedNamespace(kind), { limit, offset: 0 });
50079
+ return rows.map((row) => {
50080
+ const saved = row.value ?? {};
50081
+ const meta = saved.meta ?? {};
50082
+ return {
50083
+ kind,
50084
+ externalId: row.key,
50085
+ lastSeenAt: typeof meta.lastSeenAt === "string" ? meta.lastSeenAt : null,
50086
+ count: Number(saved.count ?? 0),
50087
+ sampleEventType: typeof meta.sampleEventType === "string" ? meta.sampleEventType : null,
50088
+ sampleContext: meta.sampleContext ?? null,
50089
+ dismissedAt: saved.dismissedAt,
50090
+ dismissedBy: saved.dismissedBy
50091
+ };
50092
+ });
50093
+ }
50094
+ function uniqueIdentities(identities) {
50095
+ const seen = new Map;
50096
+ for (const identity of identities) {
50097
+ seen.set(`${identity.kind}\x00${identity.externalId}`, identity);
50098
+ }
50099
+ return [...seen.values()];
50100
+ }
49147
50101
  var DEFAULT_CONNECTOR_CONNECT_URL = "https://mcp.agent-swarm.dev/connections";
49148
50102
  function getConnectorConnectUrl() {
49149
50103
  const raw = process.env.CONNECTOR_CONNECT_URL?.trim() || DEFAULT_CONNECTOR_CONNECT_URL;
@@ -49268,7 +50222,10 @@ async function handleUsers(req, res, pathSegments, queryParams) {
49268
50222
  return true;
49269
50223
  const limit = parsed.query.limit ?? 100;
49270
50224
  const kinds = parsed.query.kind ? [parsed.query.kind] : UNMAPPED_KINDS;
49271
- const rows = (await Promise.all(kinds.map((k) => collectUnmappedForKind(k, limit)))).flat();
50225
+ const collect = parsed.query.dismissed === "true" ? collectDismissedForKind : collectUnmappedForKind;
50226
+ const includeBots = parsed.query.includeBots === "true";
50227
+ const dismissedKeys = parsed.query.dismissed === "true" ? new Set : new Set((await Promise.all(kinds.map((k) => collectDismissedForKind(k, 1000)))).flat().map((row) => `${row.kind}\x00${row.externalId}`));
50228
+ const rows = (await Promise.all(kinds.map((k) => collect(k, limit)))).flat().filter((row) => includeBots || !row.externalId.endsWith("[bot]")).filter((row) => !dismissedKeys.has(`${row.kind}\x00${row.externalId}`));
49272
50229
  rows.sort((a, b) => {
49273
50230
  if (b.count !== a.count)
49274
50231
  return b.count - a.count;
@@ -49279,6 +50236,34 @@ async function handleUsers(req, res, pathSegments, queryParams) {
49279
50236
  listUnmapped.respond(res, 200, { unmapped: rows.slice(0, limit) });
49280
50237
  return true;
49281
50238
  }
50239
+ if (dismissUnmapped.match(req.method, pathSegments)) {
50240
+ const parsed = await dismissUnmapped.parse(req, res, pathSegments, queryParams);
50241
+ if (!parsed)
50242
+ return true;
50243
+ const actor = getOperatorActor(req, res);
50244
+ if (!actor)
50245
+ return true;
50246
+ const identities = uniqueIdentities(parsed.body.identities);
50247
+ for (const { kind, externalId } of identities) {
50248
+ await dismissUnmappedIdentity(kind, externalId, `${actor.kind}:${actor.id}`);
50249
+ }
50250
+ dismissUnmapped.respond(res, 200, { dismissed: identities.length });
50251
+ return true;
50252
+ }
50253
+ if (restoreUnmapped.match(req.method, pathSegments)) {
50254
+ const parsed = await restoreUnmapped.parse(req, res, pathSegments, queryParams);
50255
+ if (!parsed)
50256
+ return true;
50257
+ if (!getOperatorActor(req, res))
50258
+ return true;
50259
+ let restored = 0;
50260
+ for (const { kind, externalId } of uniqueIdentities(parsed.body.identities)) {
50261
+ if (await restoreUnmappedIdentity(kind, externalId))
50262
+ restored++;
50263
+ }
50264
+ restoreUnmapped.respond(res, 200, { restored });
50265
+ return true;
50266
+ }
49282
50267
  if (resolveUnmapped.match(req.method, pathSegments)) {
49283
50268
  const parsed = await resolveUnmapped.parse(req, res, pathSegments, queryParams);
49284
50269
  if (!parsed)
@@ -50948,6 +51933,7 @@ async function handleWebhooks(req, res, pathSegments) {
50948
51933
  // src/http/workflow-events.ts
50949
51934
  init_zod();
50950
51935
  init_db4();
51936
+ init_event_waits();
50951
51937
  init_event_bus();
50952
51938
  init_route_def();
50953
51939
  init_utils2();
@@ -50973,6 +51959,7 @@ var runScopedSignalRoute = route({
50973
51959
  })
50974
51960
  },
50975
51961
  404: { description: "Workflow run not found" },
51962
+ 403: { description: "Event name is reserved for provider webhooks" },
50976
51963
  400: { description: "Validation error" }
50977
51964
  },
50978
51965
  auth: { apiKey: true }
@@ -50996,15 +51983,21 @@ var globalSignalRoute = route({
50996
51983
  name: string2()
50997
51984
  })
50998
51985
  },
51986
+ 403: { description: "Event name is reserved for provider webhooks" },
50999
51987
  400: { description: "Validation error" }
51000
51988
  },
51001
51989
  auth: { apiKey: true }
51002
51990
  });
51991
+ var RESERVED_EVENT_MESSAGE = "Event name is reserved for provider webhooks";
51003
51992
  async function handleWorkflowEvents(req, res, pathSegments, queryParams) {
51004
51993
  if (runScopedSignalRoute.match(req.method, pathSegments)) {
51005
51994
  const parsed = await runScopedSignalRoute.parse(req, res, pathSegments, queryParams);
51006
51995
  if (!parsed)
51007
51996
  return true;
51997
+ if (isReservedProviderEvent(parsed.body.name)) {
51998
+ jsonError(res, RESERVED_EVENT_MESSAGE, 403);
51999
+ return true;
52000
+ }
51008
52001
  const run = await getWorkflowRun2(parsed.params.runId);
51009
52002
  if (!run) {
51010
52003
  jsonError(res, "Workflow run not found", 404);
@@ -51023,6 +52016,10 @@ async function handleWorkflowEvents(req, res, pathSegments, queryParams) {
51023
52016
  const parsed = await globalSignalRoute.parse(req, res, pathSegments, queryParams);
51024
52017
  if (!parsed)
51025
52018
  return true;
52019
+ if (isReservedProviderEvent(parsed.body.name)) {
52020
+ jsonError(res, RESERVED_EVENT_MESSAGE, 403);
52021
+ return true;
52022
+ }
51026
52023
  workflowEventBus2.emit(parsed.body.name, parsed.body.payload ?? {});
51027
52024
  globalSignalRoute.respond(res, 200, { ok: true, name: parsed.body.name });
51028
52025
  return true;
@@ -51041,6 +52038,7 @@ init_types5();
51041
52038
  init_workflows();
51042
52039
  init_definition2();
51043
52040
  init_engine();
52041
+ init_input();
51044
52042
  init_json_schema_validator();
51045
52043
  init_model_validation();
51046
52044
  init_patch_definition();
@@ -51139,6 +52137,7 @@ var createWorkflowRoute = route({
51139
52137
  responses: {
51140
52138
  201: { description: "Workflow created", schema: WorkflowSaveResponseSchema },
51141
52139
  400: { description: "Invalid definition, or a malformed Idempotency-Key" },
52140
+ 403: { description: "Env var or secret input requires config.read.secrets" },
51142
52141
  409: { description: "Idempotency-Key was already used for a different request" },
51143
52142
  410: { description: "The workflow created under this Idempotency-Key was deleted" }
51144
52143
  }
@@ -51190,6 +52189,7 @@ var updateWorkflowRoute = route({
51190
52189
  schema: WorkflowSaveResponseSchema
51191
52190
  },
51192
52191
  400: { description: "Invalid definition" },
52192
+ 403: { description: "Env var or secret input requires config.read.secrets" },
51193
52193
  404: { description: "Workflow not found" }
51194
52194
  }
51195
52195
  });
@@ -51207,6 +52207,7 @@ var patchWorkflowRoute = route({
51207
52207
  schema: WorkflowSaveResponseSchema
51208
52208
  },
51209
52209
  400: { description: "Invalid patch or resulting definition" },
52210
+ 403: { description: "Stored env var or secret input requires config.read.secrets" },
51210
52211
  404: { description: "Workflow not found" }
51211
52212
  }
51212
52213
  });
@@ -51224,6 +52225,7 @@ var patchWorkflowNodeRoute = route({
51224
52225
  schema: WorkflowSaveResponseSchema
51225
52226
  },
51226
52227
  400: { description: "Invalid patch or resulting definition" },
52228
+ 403: { description: "Stored env var or secret input requires config.read.secrets" },
51227
52229
  404: { description: "Workflow or node not found" }
51228
52230
  }
51229
52231
  });
@@ -51595,7 +52597,12 @@ async function handleWorkflows(req, res, pathSegments, queryParams, myAgentId) {
51595
52597
  jsonError(res, `Invalid definition: ${modelErrors.join("; ")}`, 400);
51596
52598
  return true;
51597
52599
  }
51598
- const trustedUserId = await resolveHttpAuditUserId(req, myAgentId);
52600
+ const refKeys = serverRefInputKeys(parsed.body.input, parsed.body.params);
52601
+ if (refKeys.length > 0 && await requestSecretReadScope(req) !== "all") {
52602
+ jsonError(res, serverRefInputDeniedMessage(refKeys), 403);
52603
+ return true;
52604
+ }
52605
+ const trustedUserId = await resolveHttpRequesterUserId(req, myAgentId);
51599
52606
  let key;
51600
52607
  try {
51601
52608
  key = parsed.body.key ? await authorizeAssetKeyWrite(parsed.body.key, trustedUserId) : undefined;
@@ -51683,6 +52690,7 @@ async function handleWorkflows(req, res, pathSegments, queryParams, myAgentId) {
51683
52690
  registry: getExecutorRegistry2(),
51684
52691
  snapshotAgentId: myAgentId,
51685
52692
  snapshotOptional: true,
52693
+ serverRefInputAllowed: await requestSecretReadScope(req) === "all",
51686
52694
  updates: { updatedBy: updatedBy0 }
51687
52695
  });
51688
52696
  if (!result.ok) {
@@ -51691,6 +52699,10 @@ async function handleWorkflows(req, res, pathSegments, queryParams, myAgentId) {
51691
52699
  res.end();
51692
52700
  return true;
51693
52701
  }
52702
+ if (result.reason === "forbidden") {
52703
+ jsonError(res, result.errors.join("; "), 403);
52704
+ return true;
52705
+ }
51694
52706
  if (result.reason === "patch") {
51695
52707
  jsonError(res, result.errors.join("; "), 404);
51696
52708
  return true;
@@ -51710,7 +52722,7 @@ async function handleWorkflows(req, res, pathSegments, queryParams, myAgentId) {
51710
52722
  const updateArgs = {};
51711
52723
  if (parsed.body.key !== undefined) {
51712
52724
  try {
51713
- updateArgs.key = await authorizeAssetKeyWrite(parsed.body.key, updatedBy1);
52725
+ updateArgs.key = await authorizeAssetKeyWrite(parsed.body.key, await resolveHttpRequesterUserId(req, myAgentId));
51714
52726
  } catch (error) {
51715
52727
  if (error instanceof AssetKeyAuthorizationError) {
51716
52728
  jsonError(res, error.message, error.statusCode);
@@ -51738,6 +52750,7 @@ async function handleWorkflows(req, res, pathSegments, queryParams, myAgentId) {
51738
52750
  registry: getExecutorRegistry2(),
51739
52751
  snapshotAgentId: myAgentId,
51740
52752
  snapshotOptional: true,
52753
+ serverRefInputAllowed: await requestSecretReadScope(req) === "all",
51741
52754
  updates: updateArgs
51742
52755
  });
51743
52756
  if (!result.ok) {
@@ -51746,6 +52759,10 @@ async function handleWorkflows(req, res, pathSegments, queryParams, myAgentId) {
51746
52759
  res.end();
51747
52760
  return true;
51748
52761
  }
52762
+ if (result.reason === "forbidden") {
52763
+ jsonError(res, result.errors.join("; "), 403);
52764
+ return true;
52765
+ }
51749
52766
  jsonError(res, result.reason === "patch" ? result.errors.join("; ") : `Invalid definition: ${result.errors.join("; ")}`, 400);
51750
52767
  return true;
51751
52768
  }
@@ -51784,11 +52801,16 @@ async function handleWorkflows(req, res, pathSegments, queryParams, myAgentId) {
51784
52801
  return true;
51785
52802
  }
51786
52803
  }
52804
+ const refKeys = body.input !== undefined || body.params !== undefined || body.definition ? serverRefInputKeys(body.input !== undefined ? body.input : existing.input, body.params !== undefined ? body.params : existing.params) : [];
52805
+ if (refKeys.length > 0 && await requestSecretReadScope(req) !== "all") {
52806
+ jsonError(res, serverRefInputDeniedMessage(refKeys), 403);
52807
+ return true;
52808
+ }
51787
52809
  const updatedBy2 = await resolveHttpAuditUserId(req, myAgentId) ?? undefined;
51788
52810
  let key;
51789
52811
  if (body.key !== undefined) {
51790
52812
  try {
51791
- key = await authorizeAssetKeyWrite(body.key, updatedBy2);
52813
+ key = await authorizeAssetKeyWrite(body.key, await resolveHttpRequesterUserId(req, myAgentId));
51792
52814
  } catch (error) {
51793
52815
  if (error instanceof AssetKeyAuthorizationError) {
51794
52816
  jsonError(res, error.message, error.statusCode);
@@ -51898,7 +52920,7 @@ async function handleWorkflows(req, res, pathSegments, queryParams, myAgentId) {
51898
52920
  runId = await startWorkflowExecution2(workflow, body, getExecutorRegistry2(), {
51899
52921
  triggerType: "api",
51900
52922
  triggeredByAgentId: myAgentId,
51901
- requestedByUserId: await resolveHttpAuditUserId(req, myAgentId) ?? undefined,
52923
+ requestedByUserId: await resolveHttpRequesterUserId(req, myAgentId) ?? undefined,
51902
52924
  detach: parsed.query.wait === "false",
51903
52925
  accept: claim ? async (run) => {
51904
52926
  const response = { runId: run.runId, skipped: run.skipped };
@@ -52029,7 +53051,7 @@ init_utils2();
52029
53051
  import { timingSafeEqual as timingSafeEqual3 } from "node:crypto";
52030
53052
  var DEFAULT_TIMEOUT_MS = 60000;
52031
53053
  var TIMEOUT_HEADER = "x-swarm-timeout-ms";
52032
- var MAX_BODY_BYTES = 1 * 1024 * 1024;
53054
+ var MAX_BODY_BYTES2 = 1 * 1024 * 1024;
52033
53055
  var XScriptErrorSchema = object2({
52034
53056
  type: string2(),
52035
53057
  message: string2(),
@@ -52133,7 +53155,7 @@ async function handleX(req, res, pathSegments) {
52133
53155
  return true;
52134
53156
  }
52135
53157
  }
52136
- if (enforceContentLengthCap(req, res, MAX_BODY_BYTES) === BODY_TOO_LARGE)
53158
+ if (enforceContentLengthCap(req, res, MAX_BODY_BYTES2) === BODY_TOO_LARGE)
52137
53159
  return true;
52138
53160
  let args;
52139
53161
  try {
@@ -52341,6 +53363,9 @@ var httpServer = createHttpServer(async (req, res) => {
52341
53363
  () => handleSessionData(req, res, pathSegments, queryParams, myAgentId),
52342
53364
  () => handleTrackers(req, res, pathSegments),
52343
53365
  () => handleWebhooks(req, res, pathSegments),
53366
+ () => handleObjectWebhooks(req, res, pathSegments),
53367
+ () => handleObjects(req, res, pathSegments, queryParams, myAgentId),
53368
+ () => handleAgentLifecycle(req, res, pathSegments, queryParams, myAgentId),
52344
53369
  () => handleAgentsRest(req, res, pathSegments, queryParams, myAgentId),
52345
53370
  () => handleBudgets(req, res, pathSegments, queryParams, myAgentId),
52346
53371
  () => handleContext(req, res, pathSegments, queryParams, myAgentId),
@@ -52441,7 +53466,7 @@ var httpServer = createHttpServer(async (req, res) => {
52441
53466
  });
52442
53467
  });
52443
53468
  var detachRealtime = attachRealtimeTransport(httpServer);
52444
- var { attachControllerTransport } = await import("./controllers-connect-w3qbpbt1.js");
53469
+ var { attachControllerTransport } = await import("./controllers-connect-0gg13mzp.js");
52445
53470
  var detachControllers = attachControllerTransport(httpServer);
52446
53471
  var stopWorkerNudges = startWorkerNudgeListener();
52447
53472
  var taskAutoTitles = startTaskAutoTitleListener();
@@ -52472,7 +53497,7 @@ async function shutdown() {
52472
53497
  sessionsProcessed: getServerSessionsProcessed()
52473
53498
  });
52474
53499
  if (hasCapability("scheduling")) {
52475
- const { stopScheduler } = await import("./index-1f6m47mq.js");
53500
+ const { stopScheduler } = await import("./index-dz4q23ag.js");
52476
53501
  stopScheduler();
52477
53502
  }
52478
53503
  stopHeartbeat2();
@@ -52484,7 +53509,7 @@ async function shutdown() {
52484
53509
  await stopSlackApp2();
52485
53510
  await stopChatSdk();
52486
53511
  if (!isEnvFlagEnabled("OAUTH_KEEPALIVE_DISABLE", false)) {
52487
- const { stopOAuthKeepalive } = await import("./keepalive-jmf6pn8c.js");
53512
+ const { stopOAuthKeepalive } = await import("./keepalive-d6z12s04.js");
52488
53513
  await stopOAuthKeepalive();
52489
53514
  }
52490
53515
  stopOAuthPendingGc();
@@ -52574,21 +53599,21 @@ try {
52574
53599
  console.warn("[startup] CAPABILITIES upgrade seed failed (non-fatal):", err);
52575
53600
  }
52576
53601
  try {
52577
- const { ensurePricingSeeded } = await import("./boot-seeds-kb3dxjex.js");
53602
+ const { ensurePricingSeeded } = await import("./boot-seeds-vb2dcrrb.js");
52578
53603
  ensurePricingSeeded();
52579
- const { startPricingRefreshLoop } = await import("./pricing-refresh-4j8dzvxg.js");
53604
+ const { startPricingRefreshLoop } = await import("./pricing-refresh-cf25x38j.js");
52580
53605
  startPricingRefreshLoop();
52581
53606
  } catch (err) {
52582
53607
  console.error("[startup] Failed to seed pricing rows:", err);
52583
53608
  }
52584
53609
  try {
52585
- const { ensureModelProfilesSeeded } = await import("./boot-seeds-kb3dxjex.js");
53610
+ const { ensureModelProfilesSeeded } = await import("./boot-seeds-vb2dcrrb.js");
52586
53611
  await ensureModelProfilesSeeded();
52587
53612
  } catch (err) {
52588
53613
  console.error("[startup] Failed to seed model profiles:", err);
52589
53614
  }
52590
53615
  try {
52591
- const { ensureRbacSeeded } = await import("./boot-seeds-kb3dxjex.js");
53616
+ const { ensureRbacSeeded } = await import("./boot-seeds-vb2dcrrb.js");
52592
53617
  ensureRbacSeeded();
52593
53618
  } catch (err) {
52594
53619
  console.error("[startup] Failed to sync RBAC seed rows:", err);
@@ -52596,13 +53621,13 @@ try {
52596
53621
  throw err;
52597
53622
  }
52598
53623
  try {
52599
- const { runAllSeeders } = await import("./index-e42j998x.js");
53624
+ const { runAllSeeders } = await import("./index-w216g9y9.js");
52600
53625
  await runAllSeeders({ scriptEmbeddingMode: "skip" });
52601
53626
  } catch (err) {
52602
53627
  console.error("[startup] Failed to seed built-in entities:", err);
52603
53628
  }
52604
53629
  try {
52605
- const { runImports } = await import("./index-akbgsdhh.js");
53630
+ const { runImports } = await import("./index-52tgbhrw.js");
52606
53631
  await runImports();
52607
53632
  } catch (err) {
52608
53633
  console.error("[startup] File import failed:", scrubSecrets(err instanceof Error ? err.message : String(err)));
@@ -52653,9 +53678,12 @@ httpServer.listen(port, async () => {
52653
53678
  startChatSdk().catch((err) => {
52654
53679
  console.error("[chat-sdk] Failed to start, continuing without Chat SDK:", scrubSecrets(err instanceof Error ? err.message : String(err)));
52655
53680
  });
52656
- import("./agent-fs-provision-v6enh76w.js").then(({ syncAgentFsOrgSwarmUrl }) => syncAgentFsOrgSwarmUrl(getConfiguredAppUrls()[0])).catch((err) => {
53681
+ import("./agent-fs-provision-jqshb33y.js").then(({ syncAgentFsOrgSwarmUrl }) => syncAgentFsOrgSwarmUrl(getConfiguredAppUrls()[0])).catch((err) => {
52657
53682
  console.warn("[agent-fs] Failed to set the org swarm URL:", scrubSecrets(err instanceof Error ? err.message : String(err)));
52658
53683
  });
53684
+ import("./object-webhooks-6rdagg0r.js").then(({ ensureObjectWebhooksForKnownDrives }) => ensureObjectWebhooksForKnownDrives()).catch((err) => {
53685
+ console.warn("[objects] agent-fs webhook boot check failed:", scrubSecrets(err instanceof Error ? err.message : String(err)));
53686
+ });
52659
53687
  startQueueStallAlarm();
52660
53688
  initGitHub();
52661
53689
  initGitLab();
@@ -52669,25 +53697,25 @@ httpServer.listen(port, async () => {
52669
53697
  await initWorkflows2();
52670
53698
  await startScriptRunSupervisor(getMcpBaseUrl());
52671
53699
  if (hasCapability("scheduling")) {
52672
- const { startScheduler } = await import("./index-1f6m47mq.js");
52673
- const { getExecutorRegistry } = await import("./index-tnkd410q.js");
53700
+ const { startScheduler } = await import("./index-dz4q23ag.js");
53701
+ const { getExecutorRegistry } = await import("./index-0mcxjdsa.js");
52674
53702
  const intervalMs = Number(process.env.SCHEDULER_INTERVAL_MS) || 1e4;
52675
53703
  startScheduler(getExecutorRegistry(), intervalMs, {
52676
53704
  runId: globalState.__runId
52677
53705
  });
52678
53706
  }
52679
53707
  if (!isEnvFlagEnabled("HEARTBEAT_DISABLE", false)) {
52680
- const { parseHeartbeatIntervalMs, startHeartbeat } = await import("./index-1p1mpqda.js");
53708
+ const { parseHeartbeatIntervalMs, startHeartbeat } = await import("./index-s175jckx.js");
52681
53709
  startHeartbeat(parseHeartbeatIntervalMs(process.env.HEARTBEAT_INTERVAL_MS));
52682
53710
  }
52683
53711
  startPoolRouting();
52684
53712
  startRuntimeSupervisor();
52685
53713
  if (!isEnvFlagEnabled("OAUTH_KEEPALIVE_DISABLE", false)) {
52686
- const { startOAuthKeepalive } = await import("./keepalive-jmf6pn8c.js");
53714
+ const { startOAuthKeepalive } = await import("./keepalive-d6z12s04.js");
52687
53715
  startOAuthKeepalive();
52688
53716
  }
52689
53717
  if (!isEnvFlagEnabled("OAUTH_REFRESH_SWEEP_DISABLE", false)) {
52690
- const { startOAuthRefreshSweep } = await import("./oauth-refresh-sweep-ywgf8tbr.js");
53718
+ const { startOAuthRefreshSweep } = await import("./oauth-refresh-sweep-t1xjetbh.js");
52691
53719
  startOAuthRefreshSweep();
52692
53720
  }
52693
53721
  startOAuthPendingGc();
@@ -52697,22 +53725,22 @@ httpServer.listen(port, async () => {
52697
53725
  startSavingsRollup(savingsRollupSql);
52698
53726
  startHumanFreeDrain();
52699
53727
  startTaskSearchBackfill();
52700
- import("./embedding-space-z6ptw3jk.js").then(({ runEmbeddingMaintenance, setDeploymentEnvReader }) => {
53728
+ import("./embedding-space-3n6mhhmy.js").then(({ runEmbeddingMaintenance, setDeploymentEnvReader }) => {
52701
53729
  setDeploymentEnvReader(getDeploymentEnvValue2);
52702
53730
  return runEmbeddingMaintenance({ backfill: true });
52703
53731
  }).catch((err) => {
52704
53732
  console.error("[embedding-space] startup maintenance failed (non-fatal):", err);
52705
53733
  });
52706
- import("./boot-args-schema-d7fme4q1.js").then(({ runBootArgsSchemaBackfill }) => runBootArgsSchemaBackfill()).catch((err) => {
53734
+ import("./boot-args-schema-xzfp2feg.js").then(({ runBootArgsSchemaBackfill }) => runBootArgsSchemaBackfill()).catch((err) => {
52707
53735
  console.error("[boot-args-schema] startup backfill failed (non-fatal):", err);
52708
53736
  });
52709
- import("./boot-scrub-sweep-52h7yntp.js").then(({ runBootScrubSweep }) => runBootScrubSweep()).catch((err) => {
53737
+ import("./boot-scrub-sweep-scrqhw48.js").then(({ runBootScrubSweep }) => runBootScrubSweep()).catch((err) => {
52710
53738
  console.error("[boot-scrub-sweep] startup scrub failed (non-fatal):", err);
52711
53739
  });
52712
- import("./user-merge-jobs-mvheb3ed.js").then(({ resumeUserMergeJobs }) => resumeUserMergeJobs()).catch((err) => {
53740
+ import("./user-merge-jobs-kcmwvrc6.js").then(({ resumeUserMergeJobs }) => resumeUserMergeJobs()).catch((err) => {
52713
53741
  console.error("[user-merge] startup resume failed (non-fatal):", err);
52714
53742
  });
52715
- import("./session-source-backfill-ax6qxv20.js").then(({ runSessionSourceBackfill }) => runSessionSourceBackfill()).catch((err) => {
53743
+ import("./session-source-backfill-3w2st4m2.js").then(({ runSessionSourceBackfill }) => runSessionSourceBackfill()).catch((err) => {
52716
53744
  console.error("[session-source-backfill] startup run failed (non-fatal):", err);
52717
53745
  });
52718
53746
  }).on("error", (err) => {