@desplega.ai/agent-swarm 2.12.0 → 2.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (417) hide show
  1. package/dist/acp-adapter-xtj40wd8.js +17 -0
  2. package/dist/{acp-targets-311gcyvw.js → acp-targets-n7vm5atw.js} +10 -9
  3. package/dist/{actions-c4chgxp6.js → actions-hq6wp9xv.js} +28 -27
  4. package/dist/{agent-fs-provision-0b9awm5n.js → agent-fs-provision-y0qc1rdd.js} +4 -4
  5. package/dist/{amp-adapter-r0veq6x5.js → amp-adapter-1qqs6h91.js} +3 -3
  6. package/dist/{app-hn5fftf5.js → app-7m4z44rv.js} +10 -8
  7. package/dist/{approval-notifications-3g6yc8nv.js → approval-notifications-8sr41gjx.js} +11 -10
  8. package/dist/{assistant-cpjgpjvp.js → assistant-hkczwfv6.js} +29 -28
  9. package/dist/{boot-args-schema-hce1av1h.js → boot-args-schema-8025snev.js} +1 -1
  10. package/dist/{boot-reembed-bztbxc4z.js → boot-reembed-15m87nr1.js} +5 -2
  11. package/dist/{boot-reembed-d7xcym0j.js → boot-reembed-4bbpxjh1.js} +1 -1
  12. package/dist/{boot-scrub-sweep-mkmm16gk.js → boot-scrub-sweep-eajr97e9.js} +2 -2
  13. package/dist/{boot-seeds-arrkbe8t.js → boot-seeds-9cwy39jx.js} +4 -4
  14. package/dist/{boxd-68n75y1s.js → boxd-hr8rsxzq.js} +1 -1
  15. package/dist/{claude-adapter-ykpyr5p8.js → claude-adapter-g61wa4rt.js} +9 -8
  16. package/dist/{claude-managed-adapter-ssg6z4bt.js → claude-managed-adapter-znkk0prm.js} +4 -4
  17. package/dist/{claude-managed-setup-trd59v7b.js → claude-managed-setup-f1wndkr2.js} +7 -7
  18. package/dist/{claude-sdk-session-yjcze0j1.js → claude-sdk-session-687xzf21.js} +20763 -19380
  19. package/dist/{cli-ya3kf4gs.js → cli-04103ryh.js} +1 -1
  20. package/dist/{cli-55tc8cj4.js → cli-0a336ze7.js} +5 -5
  21. package/dist/{cli-q8tc22bj.js → cli-0fx95c06.js} +5 -5
  22. package/dist/{cli-mq2fbgva.js → cli-0m77n7ej.js} +3 -3
  23. package/dist/{cli-7yn42w6m.js → cli-0xwb7zpt.js} +2 -2
  24. package/dist/{cli-mcymtvwn.js → cli-13t0smbk.js} +1000 -28
  25. package/dist/{cli-c7j31hq9.js → cli-1b5axkt1.js} +4 -4
  26. package/dist/{cli-yegz2g06.js → cli-1carhg8g.js} +4 -4
  27. package/dist/{cli-j5gtytvg.js → cli-1dr5at77.js} +15 -12
  28. package/dist/cli-2v4xxnx2.js +148 -0
  29. package/dist/{cli-sv2r3bw8.js → cli-32xndx6b.js} +7 -7
  30. package/dist/{cli-h70a2mxy.js → cli-3m8vqehw.js} +53 -13
  31. package/dist/{cli-ercwc8xn.js → cli-3mf04tkh.js} +1 -1
  32. package/dist/{cli-52nfye5j.js → cli-3zyme1wt.js} +24 -16
  33. package/dist/{cli-s6zk31gr.js → cli-43dsqhcp.js} +4 -4
  34. package/dist/{cli-b93d81yg.js → cli-4h90xaet.js} +2 -2
  35. package/dist/{cli-5tg94mdw.js → cli-4mj5g29m.js} +9 -12
  36. package/dist/{cli-47hz21se.js → cli-4tbvndmm.js} +4 -5
  37. package/dist/{cli-r0mz92by.js → cli-50whymxq.js} +2 -2
  38. package/dist/{cli-js10kdk7.js → cli-5basv0e7.js} +19 -5
  39. package/dist/{cli-krbcr00p.js → cli-5v6b2am8.js} +59 -5
  40. package/dist/{cli-en6dmkxd.js → cli-6r1dwegd.js} +3 -3
  41. package/dist/{cli-9qe5y107.js → cli-7ewre3dm.js} +15 -6
  42. package/dist/{cli-n3qe7tyr.js → cli-84xtgbn6.js} +35 -2
  43. package/dist/{cli-xm34qj8m.js → cli-8cmjkbvj.js} +2 -2
  44. package/dist/{cli-2m6yaq6b.js → cli-8fj8yfmk.js} +1 -1
  45. package/dist/{cli-nja15knq.js → cli-8rbkw18r.js} +3 -3
  46. package/dist/{cli-x05p2d05.js → cli-9tevdxyf.js} +1 -1
  47. package/dist/{cli-hhc47ack.js → cli-9xx36trj.js} +4 -4
  48. package/dist/{cli-39qm0rtm.js → cli-a8ts6x1n.js} +29 -150
  49. package/dist/{cli-bp6k9acz.js → cli-aebswqmz.js} +18 -18
  50. package/dist/{cli-ex1y88j3.js → cli-at67kvnp.js} +1 -1
  51. package/dist/{cli-q2dywc8h.js → cli-bjmq14k9.js} +4 -4
  52. package/dist/{cli-v9ya390t.js → cli-byxsctca.js} +12 -12
  53. package/dist/{cli-bz97ff9n.js → cli-c0tyzt73.js} +152 -12
  54. package/dist/{cli-fyaq4zdv.js → cli-c8kqmzzf.js} +9 -9
  55. package/dist/{cli-t75xngj1.js → cli-cd9acnvd.js} +12 -12
  56. package/dist/{cli-eqq0hwvx.js → cli-cmgdptmx.js} +3 -3
  57. package/dist/{cli-r14ac1y0.js → cli-cn6fpa1p.js} +1 -1
  58. package/dist/{cli-0k1a0sde.js → cli-cp0m07wb.js} +10 -10
  59. package/dist/{cli-3p288654.js → cli-cpkxh68d.js} +2 -2
  60. package/dist/{cli-fxd1mwtr.js → cli-cqxwjb93.js} +2 -2
  61. package/dist/{cli-8hp56wat.js → cli-d2epqm0y.js} +1 -1
  62. package/dist/{cli-73q4g5nx.js → cli-dd57p1gd.js} +21 -21
  63. package/dist/{cli-5z0g0e8v.js → cli-f8rcvf2x.js} +49 -13
  64. package/dist/{cli-wvjqaqcp.js → cli-fn8aj7gb.js} +1330 -249
  65. package/dist/{cli-bpje8n65.js → cli-fp65jdp2.js} +31 -6
  66. package/dist/{cli-0pp1yjg2.js → cli-gedf48yw.js} +11 -11
  67. package/dist/{cli-m5qtmrbc.js → cli-gq6qhmrr.js} +2 -2
  68. package/dist/{cli-5x03v6en.js → cli-grcc2h2g.js} +8 -8
  69. package/dist/{cli-01tvvtad.js → cli-h03j6je3.js} +4 -4
  70. package/dist/{cli-mbwmqb5w.js → cli-h0ewec3d.js} +1 -1
  71. package/dist/{cli-12vek61e.js → cli-h9bejmkf.js} +535 -146
  72. package/dist/{cli-gfy6hbd9.js → cli-hs3mqswp.js} +18 -11
  73. package/dist/{cli-tdk7jtka.js → cli-hv3820ez.js} +1 -1
  74. package/dist/{cli-pqfecppn.js → cli-je587f74.js} +1 -1
  75. package/dist/{cli-cjqyse9q.js → cli-jhtvt7gn.js} +3 -3
  76. package/dist/{cli-dkvtfgn4.js → cli-mmw2sjaf.js} +76 -17
  77. package/dist/{cli-2z2c4k6q.js → cli-mwxez0pz.js} +22 -0
  78. package/dist/{cli-yfpc6qy9.js → cli-nk8swfpx.js} +47 -16
  79. package/dist/{cli-eq4kew31.js → cli-p7g7wd9n.js} +26 -13
  80. package/dist/{cli-bhgrhedp.js → cli-q8aq48v1.js} +1 -1
  81. package/dist/{cli-dd2k2mcd.js → cli-qn79645p.js} +1 -1
  82. package/dist/{cli-ma9ys8rt.js → cli-qx1dwrr5.js} +7 -4
  83. package/dist/{cli-tm60vtax.js → cli-rfejbpe1.js} +1 -1
  84. package/dist/{cli-agjbj5x0.js → cli-s6fhqbz1.js} +38 -20
  85. package/dist/{cli-kwr5qv5g.js → cli-sfajkbd7.js} +2 -2
  86. package/dist/{cli-9y4tgrkf.js → cli-skd2c4ej.js} +2 -1
  87. package/dist/{cli-e8n0hdzd.js → cli-snypfjgj.js} +1 -1
  88. package/dist/{cli-n8f0fs3c.js → cli-t25rq8mg.js} +11 -11
  89. package/dist/{cli-72yms3ey.js → cli-t90k0phh.js} +201 -21
  90. package/dist/{cli-xf4z5bdn.js → cli-tzzas8rb.js} +4 -4
  91. package/dist/{cli-rtmqzat7.js → cli-vdfngx2g.js} +2 -2
  92. package/dist/{cli-9w8712tq.js → cli-vr4eyq6p.js} +43 -14
  93. package/dist/{cli-z4f346g5.js → cli-vx9acp12.js} +1 -1
  94. package/dist/{cli-2amwhyv2.js → cli-w24f3j49.js} +13 -11
  95. package/dist/cli-w41bvvms.js +148 -0
  96. package/dist/{cli-04zc3f7b.js → cli-w6c6dj91.js} +1 -1
  97. package/dist/{cli-fy4gb74g.js → cli-x5yb8zc8.js} +2 -2
  98. package/dist/{cli-2tw284hj.js → cli-xhkek467.js} +3 -3
  99. package/dist/{cli-5r95eqbh.js → cli-y260hgep.js} +1 -1
  100. package/dist/{cli-hbvgzjq4.js → cli-y6qqbpwc.js} +3 -3
  101. package/dist/{cli-7wy8gbwb.js → cli-ya1cj689.js} +1 -1
  102. package/dist/{cli-1htmtqc2.js → cli-yeh3g1q6.js} +620 -95
  103. package/dist/{cli-0vcqcwfn.js → cli-yfvhvw8m.js} +2 -0
  104. package/dist/{cli-k5jx8jya.js → cli-z6m6xzxt.js} +2 -2
  105. package/dist/{cli-pe3yxedk.js → cli-zaate0rd.js} +3 -3
  106. package/dist/{cli-n85m2wkq.js → cli-zkbz8m2q.js} +3 -2
  107. package/dist/{cli-e3ahxq5y.js → cli-zvpkrgsc.js} +6 -6
  108. package/dist/cli.js +30 -28
  109. package/dist/{codex-adapter-wc6e4wct.js → codex-adapter-ysfg6ty3.js} +8 -8
  110. package/dist/{codex-hook-aqtj17yr.js → codex-hook-c0nvm30r.js} +73 -2
  111. package/dist/{codex-login-1ven7yje.js → codex-login-ven5cz5j.js} +1 -1
  112. package/dist/{codex-session-runner-ppfgjd97.js → codex-session-runner-823scr6g.js} +9 -9
  113. package/dist/{commands-tsv2vx5b.js → commands-5rbm07fz.js} +3 -3
  114. package/dist/{controller-ye4sdwsy.js → controller-wn3vd217.js} +4 -4
  115. package/dist/{controllers-connect-zn4dg69h.js → controllers-connect-34jzhfft.js} +29 -28
  116. package/dist/core-kdehq26g.js +42 -0
  117. package/dist/{cursor-adapter-q2g9vwts.js → cursor-adapter-w1681kp1.js} +2 -2
  118. package/dist/{db-g111qn9j.js → db-6bkgbfwk.js} +3 -3
  119. package/dist/{db-3r1fyr2n.js → db-hcj16x7z.js} +4 -2
  120. package/dist/{devin-adapter-t8d86q9x.js → devin-adapter-fs90ab4v.js} +1 -1
  121. package/dist/{dispatcher-4q8s0mx8.js → dispatcher-jgjqrfzv.js} +28 -25
  122. package/dist/{docker-1b41eysj.js → docker-1h33jvh9.js} +2 -2
  123. package/dist/{dsh-adapter-mmcw1z5s.js → dsh-adapter-g9yqv09y.js} +2 -2
  124. package/dist/{e2b-xm60c8ad.js → e2b-jnk0yeva.js} +2 -2
  125. package/dist/{e2b-ew8c5j5v.js → e2b-y7e5kmzf.js} +2 -2
  126. package/dist/{easter-egg-3d-04ke6hcp.js → easter-egg-3d-w17nsny6.js} +1 -1
  127. package/dist/{embedding-space-kcdn52vz.js → embedding-space-v06fwy7b.js} +6 -6
  128. package/dist/{embeddings-jnzcd91a.js → embeddings-g50dxea4.js} +1 -1
  129. package/dist/{event-bus-v4ywhc2p.js → event-bus-08t2b4y2.js} +1 -1
  130. package/dist/{execute-74amghty.js → execute-1n36haw1.js} +1 -1
  131. package/dist/{external-channel-v9zgxnxz.js → external-channel-43tv8pg6.js} +2 -2
  132. package/dist/fx-adapter-bvh05t4a.js +20 -0
  133. package/dist/grok-adapter-my5j8mdf.js +20 -0
  134. package/dist/handlers-wyymeeqh.js +41 -0
  135. package/dist/heartbeat-sf3nk937.js +50 -0
  136. package/dist/{hook-p5reemds.js → hook-dqph1e05.js} +77 -18
  137. package/dist/{hook-k1h73zd7.js → hook-m1m9dm6w.js} +6 -5
  138. package/dist/{http-ms1z5xxy.js → http-w0th1cz9.js} +888 -226
  139. package/dist/index-22khdtby.js +44 -0
  140. package/dist/{index-76zzxtzf.js → index-c0e8en64.js} +1 -1
  141. package/dist/{index-620y7jzq.js → index-e8pz8qdg.js} +3 -3
  142. package/dist/{index-8p0j4h4j.js → index-ez823q84.js} +94 -89
  143. package/dist/{index-fbkqhvvj.js → index-ffba0z8q.js} +217 -165
  144. package/dist/{index-gjn6qfgn.js → index-gkpfgpg7.js} +1 -1
  145. package/dist/{index-4k7m5dgj.js → index-k8ajc0g0.js} +143 -103
  146. package/dist/index-np0582ac.js +40 -0
  147. package/dist/{index-kn63q1gr.js → index-pb03vans.js} +33 -32
  148. package/dist/index-vgkrj1jt.js +39 -0
  149. package/dist/{index-pe3d8jfy.js → index-whysn1wf.js} +1 -1
  150. package/dist/{index-0h6qd4p1.js → index-y4vd4mhn.js} +3 -4
  151. package/dist/{k8s-fy8hbhkg.js → k8s-8326q0rq.js} +2 -2
  152. package/dist/{keepalive-031js8jz.js → keepalive-2v06q2e8.js} +5 -4
  153. package/dist/lead-55z813ng.js +79 -0
  154. package/dist/{maintenance-sq9v3qx9.js → maintenance-vx7vjhhy.js} +1 -1
  155. package/dist/{oauth-refresh-sweep-zqmnyvs8.js → oauth-refresh-sweep-g06k4bza.js} +4 -3
  156. package/dist/{object-webhooks-r24wwb5y.js → object-webhooks-3dzdq4fm.js} +7 -7
  157. package/dist/{onboard-p25yhh7t.js → onboard-232pazny.js} +4 -4
  158. package/dist/{opencode-adapter-wcjc4zdk.js → opencode-adapter-t0paqbh8.js} +8 -7
  159. package/dist/{otel-impl-ff1gf20m.js → otel-impl-kmpkyp4y.js} +2 -2
  160. package/dist/{pending-hxj5yatb.js → pending-x0z3vx1x.js} +27 -26
  161. package/dist/{pi-mono-adapter-vkp4zz7p.js → pi-mono-adapter-7pmypn6d.js} +93 -22
  162. package/dist/{pricing-refresh-9w7gx41w.js → pricing-refresh-ytjmtyd7.js} +2 -2
  163. package/dist/{rbac-roles-84aw10nz.js → rbac-roles-fgm5mxr2.js} +3 -3
  164. package/dist/{rbac-roles-hz74vckp.js → rbac-roles-xyaxekh3.js} +7 -4
  165. package/dist/{registry-eeyx1201.js → registry-zv0zvxsx.js} +1 -1
  166. package/dist/{render-v2-nrdkg9gf.js → render-v2-ws972g4r.js} +12 -8
  167. package/dist/{resume-s6ey36rh.js → resume-m6mjzhkp.js} +13 -12
  168. package/dist/{runtime-x0b4pyam.js → runtime-zzpc0c8a.js} +1 -1
  169. package/dist/{session-access-xv49tk14.js → session-access-vp35xs91.js} +5 -4
  170. package/dist/{session-source-backfill-r5j988ah.js → session-source-backfill-p73e8zbe.js} +3 -3
  171. package/dist/{setup-mj0krk1p.js → setup-r4kd7rxg.js} +1 -1
  172. package/dist/thread-buffer-cm2nzq6t.js +42 -0
  173. package/dist/{tree-visibility-cbrsfaar.js → tree-visibility-07h2tbs2.js} +2 -2
  174. package/dist/{user-merge-jobs-f9d8nwnw.js → user-merge-jobs-96vg9rpe.js} +3 -3
  175. package/dist/{virtual-modules-ns0ryw05.js → virtual-modules-vgn3f2x4.js} +3 -3
  176. package/dist/{work-objects-pydhzast.js → work-objects-74hbcx3e.js} +31 -29
  177. package/dist/worker-5pn2vzx6.js +79 -0
  178. package/dist/{worker-follow-up-9z2xec5e.js → worker-follow-up-ezavwn5d.js} +26 -25
  179. package/dist/{x-3dtaf2r9.js → x-asbrnafg.js} +2 -2
  180. package/dist/xlsx-9acfmxr1.js +31534 -0
  181. package/openapi.json +2816 -1464
  182. package/package.json +13 -11
  183. package/src/agentmail/handlers.ts +26 -19
  184. package/src/apps/catalog.generated.json +757 -0
  185. package/src/apps/definition.ts +24 -7
  186. package/src/apps/page-validator.ts +225 -3
  187. package/src/apps/row-store.ts +37 -14
  188. package/src/azure-devops/handlers.ts +2 -0
  189. package/src/be/audit-user.ts +46 -6
  190. package/src/be/db/kv-windows.ts +22 -0
  191. package/src/be/db/session-moves.ts +3 -3
  192. package/src/be/db/session-tree.ts +52 -5
  193. package/src/be/db/skill-audit.ts +17 -0
  194. package/src/be/db/tasks/write.ts +18 -3
  195. package/src/be/db.ts +152 -33
  196. package/src/be/extensions/assets.ts +11 -7
  197. package/src/be/mcp-proxy.ts +5 -4
  198. package/src/be/memory/demotion-evidence.ts +2 -2
  199. package/src/be/memory/providers/sqlite-store.ts +151 -18
  200. package/src/be/memory/search-read-worker.ts +60 -0
  201. package/src/be/memory/search-reader.ts +223 -0
  202. package/src/be/migrations/337_favorites_session_hidden_key.sql +39 -0
  203. package/src/be/migrations/338_audit_agent_columns.sql +30 -0
  204. package/src/be/migrations/339_deferred_event_waits.sql +26 -0
  205. package/src/be/migrations/340_api_key_spend_cap.sql +5 -0
  206. package/src/be/model-tier-resolution.ts +18 -1
  207. package/src/be/multi-runtime.ts +17 -0
  208. package/src/be/primitives/object-embed.ts +250 -0
  209. package/src/be/primitives/objects.ts +29 -9
  210. package/src/be/primitives/sheets/service.ts +138 -6
  211. package/src/be/primitives/sheets/xlsx.ts +367 -0
  212. package/src/be/rbac-roles.ts +3 -0
  213. package/src/be/repo-checked-update.ts +4 -4
  214. package/src/be/repo-merge-policy.ts +26 -9
  215. package/src/be/schedules/validate.ts +26 -0
  216. package/src/be/scripts/boot-reembed.ts +6 -0
  217. package/src/be/scripts/db.ts +17 -5
  218. package/src/be/scripts/embeddings.ts +6 -0
  219. package/src/be/scripts/typecheck.ts +43 -2
  220. package/src/be/seed/schedules-seeder.ts +9 -1
  221. package/src/be/seed/workflows-seeder.ts +9 -1
  222. package/src/be/seed-scripts/index.ts +2 -0
  223. package/src/be/seed-skills/index.ts +12 -0
  224. package/src/be/swarm-config-guard.ts +5 -0
  225. package/src/be/unmapped-identities.ts +95 -1
  226. package/src/bitbucket/handlers.ts +2 -0
  227. package/src/commands/credential-outcome-report.ts +5 -2
  228. package/src/commands/onboard/agent-fs-version.ts +1 -1
  229. package/src/commands/provider-credentials.ts +19 -0
  230. package/src/commands/provider-error-class.ts +4 -1
  231. package/src/commands/rate-limit-outcome.ts +48 -3
  232. package/src/commands/runner.ts +113 -55
  233. package/src/commands/worktree-reaper.ts +600 -0
  234. package/src/event-waits/github.ts +43 -0
  235. package/src/event-waits/index.ts +29 -0
  236. package/src/event-waits/types.ts +51 -0
  237. package/src/extensions/contract-types.generated.ts +1 -1
  238. package/src/extensions/dispatcher.ts +9 -0
  239. package/src/fs/agent-fs-provider.ts +4 -1
  240. package/src/github/handlers.ts +3 -1
  241. package/src/github/pull-request-state.ts +34 -0
  242. package/src/gitlab/handlers.ts +12 -7
  243. package/src/hooks/codex-hook.ts +99 -1
  244. package/src/hooks/hook.ts +85 -11
  245. package/src/hooks/native-tool-hooks.ts +245 -0
  246. package/src/http/agents.ts +4 -0
  247. package/src/http/all-routes.ts +1 -0
  248. package/src/http/api-keys.ts +27 -3
  249. package/src/http/assets.ts +4 -3
  250. package/src/http/comb.ts +2 -2
  251. package/src/http/favorite-owner.ts +2 -2
  252. package/src/http/favorites.ts +3 -2
  253. package/src/http/fs.ts +13 -4
  254. package/src/http/index.ts +2 -0
  255. package/src/http/mcp-bridge.ts +4 -0
  256. package/src/http/objects.ts +265 -0
  257. package/src/http/pages-public.ts +40 -4
  258. package/src/http/pages.ts +3 -3
  259. package/src/http/poll.ts +43 -12
  260. package/src/http/pool-keys.ts +21 -2
  261. package/src/http/repos.ts +7 -6
  262. package/src/http/schedules.ts +38 -9
  263. package/src/http/script-connections.ts +14 -6
  264. package/src/http/script-runs.ts +12 -3
  265. package/src/http/scripts.ts +9 -0
  266. package/src/http/sessions.ts +30 -12
  267. package/src/http/skills.ts +17 -0
  268. package/src/http/task-requester.ts +2 -2
  269. package/src/http/tasks.ts +18 -12
  270. package/src/http/tool-hooks.ts +24 -2
  271. package/src/http/trackers/authorize-gate.ts +2 -2
  272. package/src/http/users.ts +136 -1
  273. package/src/http/workflow-events.ts +13 -0
  274. package/src/http/workflows.ts +21 -11
  275. package/src/linear/sync.ts +3 -1
  276. package/src/mcp-client/http-client.ts +3 -1
  277. package/src/oauth/identity-capture.ts +6 -1
  278. package/src/oauth/mcp-wrapper.ts +10 -3
  279. package/src/oauth/wrapper.ts +15 -3
  280. package/src/prompts/base-prompt.ts +35 -13
  281. package/src/prompts/session-templates.ts +26 -0
  282. package/src/providers/acp-targets.ts +2 -2
  283. package/src/providers/amp-adapter.ts +1 -1
  284. package/src/providers/dsh-adapter.ts +1 -1
  285. package/src/providers/opencode-adapter.ts +1 -0
  286. package/src/providers/opencode-swarm-plugin.ts +50 -1
  287. package/src/providers/pi-mono-adapter.ts +143 -11
  288. package/src/providers/pi-mono-extension.ts +69 -0
  289. package/src/providers/runtime-dependencies.ts +1 -1
  290. package/src/rbac/legacy-policy.ts +5 -0
  291. package/src/rbac/permissions.ts +16 -1
  292. package/src/scheduler/deferred-task-waits.ts +170 -13
  293. package/src/scripts-runtime/executors/types.ts +5 -0
  294. package/src/scripts-runtime/loader.ts +8 -0
  295. package/src/scripts-runtime/mcp-client.ts +4 -0
  296. package/src/scripts-runtime/sdk-allowlist.ts +14 -1
  297. package/src/scripts-runtime/swarm-config.ts +8 -0
  298. package/src/scripts-runtime/swarm-sdk.ts +4 -0
  299. package/src/scripts-runtime/types/stdlib.d.ts +47 -4
  300. package/src/scripts-runtime/types/swarm-extension.d.ts +8 -7
  301. package/src/scripts-runtime/types/swarm-sdk.d.ts +47 -4
  302. package/src/server.ts +4 -0
  303. package/src/slack/enrich.ts +94 -31
  304. package/src/slack/handlers.test.ts +55 -2
  305. package/src/slack/handlers.ts +38 -3
  306. package/src/slack/render-v2.ts +19 -0
  307. package/src/slack/session-mirror.ts +208 -0
  308. package/src/slack/thread-participants.ts +0 -5
  309. package/src/slack/watcher.ts +3 -0
  310. package/src/slack/work-objects.test.ts +2 -1
  311. package/src/slack/work-objects.ts +7 -2
  312. package/src/tests/agentmail-filters.test.ts +4 -3
  313. package/src/tests/agents-list-model-display.test.ts +23 -0
  314. package/src/tests/apps-spike2.test.ts +35 -0
  315. package/src/tests/audit-agent-person.test.ts +825 -0
  316. package/src/tests/audit-updated-by.test.ts +19 -12
  317. package/src/tests/base-prompt.test.ts +1 -0
  318. package/src/tests/claude-hook-output.test.ts +107 -2
  319. package/src/tests/claude-managed-setup.test.ts +1 -1
  320. package/src/tests/codex-adapter.test.ts +6 -6
  321. package/src/tests/codex-gpt6-release.test.ts +4 -4
  322. package/src/tests/db-task-read-contract.test.ts +1 -0
  323. package/src/tests/db-task-write-contract.test.ts +1 -0
  324. package/src/tests/deploy-guard.test.ts +24 -0
  325. package/src/tests/dsh-adapter.test.ts +1 -1
  326. package/src/tests/ensure-token.test.ts +2 -2
  327. package/src/tests/entrypoint-repo-autoclone-args.test.ts +202 -0
  328. package/src/tests/extensions-catalog.test.ts +33 -25
  329. package/src/tests/fake-dns.ts +47 -0
  330. package/src/tests/fixtures/base-prompt-baseline.json +12 -12
  331. package/src/tests/fixtures/sheets/eocd-count-mismatch.xlsx +0 -0
  332. package/src/tests/fixtures/sheets/rich-budget.xlsx +0 -0
  333. package/src/tests/fixtures/sheets/tracker-export.xlsx +0 -0
  334. package/src/tests/kv-storage.test.ts +3 -0
  335. package/src/tests/latest-model-report.test.ts +138 -0
  336. package/src/tests/mcp-oauth-dcr-reuse.test.ts +5 -2
  337. package/src/tests/mcp-oauth-ensure-token.test.ts +3 -2
  338. package/src/tests/mcp-oauth-manual-client.test.ts +6 -1
  339. package/src/tests/mcp-oauth-wrapper.test.ts +20 -4
  340. package/src/tests/mcp-outbound-fetch-guard.test.ts +169 -0
  341. package/src/tests/mcp-server-ssrf.test.ts +2 -0
  342. package/src/tests/memory-search-reader.test.ts +258 -0
  343. package/src/tests/memory-search-stall.test.ts +202 -20
  344. package/src/tests/model-control.test.ts +4 -4
  345. package/src/tests/model-tier-resolution.test.ts +2 -2
  346. package/src/tests/multi-runtime-registration.test.ts +8 -2
  347. package/src/tests/native-tool-hooks.test.ts +188 -0
  348. package/src/tests/oauth-connection-fetch-guard.test.ts +162 -0
  349. package/src/tests/oauth-token-endpoint-fetch-guard.test.ts +121 -0
  350. package/src/tests/oauth-wrapper.test.ts +1 -2
  351. package/src/tests/opencode-swarm-plugin.test.ts +6 -1
  352. package/src/tests/pages-head-v2.test.ts +2 -1
  353. package/src/tests/pi-provider-runtime-keys.test.ts +163 -0
  354. package/src/tests/poll-probe-readonly.test.ts +108 -0
  355. package/src/tests/primitives-sheets-xlsx.test.ts +549 -0
  356. package/src/tests/prompt-template-session.test.ts +3 -2
  357. package/src/tests/rbac-roles.test.ts +3 -0
  358. package/src/tests/script-connections-http.test.ts +8 -3
  359. package/src/tests/script-connections.test.ts +6 -0
  360. package/src/tests/seed-model-profiles.test.ts +1 -1
  361. package/src/tests/sessions-tree.test.ts +10 -2
  362. package/src/tests/slack-thread-participants.test.ts +77 -4
  363. package/src/tests/spend-cap-credentials.test.ts +34 -0
  364. package/src/tests/spend-cap-outcome.test.ts +67 -0
  365. package/src/tests/subscription-first.test.ts +119 -0
  366. package/src/tests/tool-registrar-no-input.test.ts +1 -0
  367. package/src/tests/worktree-reaper.test.ts +424 -0
  368. package/src/tools/defer-task.ts +154 -12
  369. package/src/tools/get-task-details.ts +247 -5
  370. package/src/tools/objects.ts +10 -5
  371. package/src/tools/repos/update-repo.ts +6 -6
  372. package/src/tools/schedules/create-schedule.ts +1 -0
  373. package/src/tools/schedules/list-schedules.ts +3 -0
  374. package/src/tools/schedules/patch-schedule.ts +38 -4
  375. package/src/tools/schedules/update-schedule.ts +40 -5
  376. package/src/tools/sheets.ts +66 -0
  377. package/src/tools/skills/skill-create.ts +6 -0
  378. package/src/tools/skills/skill-install-remote.ts +6 -0
  379. package/src/tools/skills/skill-sync-remote.ts +9 -0
  380. package/src/tools/skills/skill-update.ts +9 -1
  381. package/src/tools/tool-config.ts +3 -1
  382. package/src/tools/utils.ts +15 -0
  383. package/src/tools/workflows/create-workflow.ts +9 -4
  384. package/src/tools/workflows/patch-workflow-node.ts +1 -1
  385. package/src/tools/workflows/patch-workflow.ts +5 -2
  386. package/src/tools/workflows/update-workflow.ts +13 -7
  387. package/src/types.ts +96 -12
  388. package/src/utils/credentials.ts +36 -1
  389. package/src/utils/egress-guard.ts +40 -10
  390. package/src/utils/error-tracker.ts +17 -0
  391. package/src/workflows/input.ts +12 -5
  392. package/src/workflows/patch-definition.ts +13 -5
  393. package/src/workflows/triggers.ts +11 -6
  394. package/src/workflows/version.ts +7 -1
  395. package/templates/skills/apps/SKILL.md +191 -2
  396. package/templates/skills/apps/content.md +191 -2
  397. package/templates/skills/boards-and-sheets/config.json +14 -0
  398. package/templates/skills/boards-and-sheets/content.md +174 -0
  399. package/templates/skills/pages/content.md +11 -0
  400. package/templates/skills/swarm-docs/content.md +11 -0
  401. package/templates/skills/swarm-scripts/SKILL.md +1 -0
  402. package/templates/skills/swarm-scripts/content.md +1 -0
  403. package/templates/workflows/ralph-loop/content.md +6 -6
  404. package/dist/acp-adapter-11m13kx4.js +0 -16
  405. package/dist/cli-pr0eze3x.js +0 -149
  406. package/dist/core-dxcy02sc.js +0 -41
  407. package/dist/fx-adapter-0ar6pqm3.js +0 -19
  408. package/dist/grok-adapter-t6m74fb1.js +0 -19
  409. package/dist/handlers-9kwcrc4k.js +0 -38
  410. package/dist/heartbeat-p8pk1msj.js +0 -49
  411. package/dist/index-23cdfzr6.js +0 -39
  412. package/dist/index-g7kkjs5b.js +0 -38
  413. package/dist/index-stk36pa5.js +0 -43
  414. package/dist/lead-mfggjtfk.js +0 -77
  415. package/dist/thread-buffer-temgaqsy.js +0 -41
  416. package/dist/worker-efcemc22.js +0 -77
  417. /package/dist/{cli-cah298e5.js → cli-m4ejz4nj.js} +0 -0
@@ -10,6 +10,7 @@ import {
10
10
  assertUrlSafe,
11
11
  EgressDeniedError,
12
12
  createGuardedFetch,
13
+ createSsrfGuardedFetch,
13
14
  init_egress_guard,
14
15
  init_credential_broker,
15
16
  encryptSecret,
@@ -237,6 +238,7 @@ import {
237
238
  init_harness_model_support,
238
239
  sanitizeModelTierOverrides,
239
240
  parseModelTierOverridesHeader,
241
+ modelTierOverridesDiffer,
240
242
  setAgentModelTierOverrides,
241
243
  previewModelTiers,
242
244
  recordClaimModelResolution,
@@ -350,6 +352,7 @@ import {
350
352
  getScriptRunExecutionArgs2,
351
353
  getScriptRunFollowUpGuard2,
352
354
  setScriptRunFollowUpGuard2,
355
+ setSkillUpdatedBy2,
353
356
  updateTaskVcs2,
354
357
  upsertAssetKeyMapping2,
355
358
  listAssetSummaries2,
@@ -554,7 +557,7 @@ import {
554
557
  countScriptRunJournalSteps2,
555
558
  countScriptRunJournalAgentTaskSteps2,
556
559
  init_db4
557
- } from "./cli-12vek61e.js";
560
+ } from "./cli-h9bejmkf.js";
558
561
  import {
559
562
  PRIMARY_ROLE_NAMES2,
560
563
  OperatorGrantedTargetError2,
@@ -568,7 +571,7 @@ import {
568
571
  assertNotLastAdmin2,
569
572
  setUserRoles2,
570
573
  init_rbac_roles
571
- } from "./cli-ma9ys8rt.js";
574
+ } from "./cli-qx1dwrr5.js";
572
575
  import {
573
576
  MAX_MODEL_GROUP_MEMBERS,
574
577
  listModelGroups,
@@ -578,19 +581,19 @@ import {
578
581
  modelGroupReferences,
579
582
  deleteModelGroup,
580
583
  init_model_groups
581
- } from "./cli-nja15knq.js";
584
+ } from "./cli-8rbkw18r.js";
582
585
  import {
583
586
  requestModelCatalogRefresh2,
584
587
  init_pricing_refresh
585
- } from "./cli-b93d81yg.js";
588
+ } from "./cli-4h90xaet.js";
586
589
  import {
587
590
  workflowEventBus2,
588
591
  init_event_bus
589
- } from "./cli-z4f346g5.js";
590
- import"./cli-fxd1mwtr.js";
591
- import"./cli-04zc3f7b.js";
592
- import"./cli-9w8712tq.js";
593
- import"./cli-47hz21se.js";
592
+ } from "./cli-vx9acp12.js";
593
+ import"./cli-cqxwjb93.js";
594
+ import"./cli-w6c6dj91.js";
595
+ import"./cli-vr4eyq6p.js";
596
+ import"./cli-4tbvndmm.js";
594
597
  import {
595
598
  require_dist4,
596
599
  getSlackConnectionState,
@@ -621,12 +624,14 @@ import {
621
624
  callSlackWithRetry2,
622
625
  slackErrorCode2,
623
626
  init_render_v2,
627
+ mirrorSessionPrompt,
628
+ init_session_mirror,
624
629
  getSlackApp2,
625
630
  getSlackHttpReceiver2,
626
631
  startSlackApp2,
627
632
  stopSlackApp2,
628
633
  init_app4
629
- } from "./cli-72yms3ey.js";
634
+ } from "./cli-t90k0phh.js";
630
635
  import {
631
636
  AGENT_MAX_TASKS_CONFIG_KEY,
632
637
  reconcileAgentMaxTasksPolicy,
@@ -636,6 +641,7 @@ import {
636
641
  upsertRuntimeInstance,
637
642
  getRuntimeInstanceById,
638
643
  touchRuntimeInstance,
644
+ isRuntimeInstanceFresh,
639
645
  listRuntimeInstancesForAgent,
640
646
  setRuntimeCredentialReady,
641
647
  reconcileAgentStatusFromRuntimes,
@@ -654,12 +660,12 @@ import {
654
660
  dispatchApprovalNotifications2,
655
661
  createApprovalFollowUpTask2,
656
662
  init_approval_notifications
657
- } from "./cli-gfy6hbd9.js";
663
+ } from "./cli-hs3mqswp.js";
658
664
  import {
659
665
  retryFailedRun2,
660
666
  cancelWorkflowRun2,
661
667
  init_resume
662
- } from "./cli-e3ahxq5y.js";
668
+ } from "./cli-zvpkrgsc.js";
663
669
  import {
664
670
  safeParse,
665
671
  getObjectShape,
@@ -725,6 +731,13 @@ import {
725
731
  getExecutorRegistry2,
726
732
  initWorkflows2,
727
733
  init_workflows,
734
+ isGitHubEnabled,
735
+ initGitHub,
736
+ verifyWebhookSignature,
737
+ getWorkerInstallationToken,
738
+ init_app,
739
+ isReservedProviderEvent,
740
+ init_event_waits,
728
741
  stripSiblingBlock,
729
742
  init_sibling_block,
730
743
  createTaskWithSiblingAwareness,
@@ -781,12 +794,16 @@ import {
781
794
  loadEnabledExtensions,
782
795
  stopExtensionRuntime,
783
796
  init_lifecycle,
797
+ hasNativeToolHandlers2,
784
798
  dispatchPre2,
785
799
  dispatchPost2,
786
800
  init_dispatcher,
787
801
  resolveIdentity,
788
802
  renderIdentity,
789
803
  init_identity,
804
+ dismissedNamespace,
805
+ dismissUnmappedIdentity,
806
+ restoreUnmappedIdentity,
790
807
  recordUnmappedIdentity,
791
808
  init_unmapped_identities,
792
809
  MAX_TASK_ATTACHMENT_BYTES,
@@ -845,11 +862,6 @@ import {
845
862
  handlePullRequestCommentCreated,
846
863
  handlePullRequestClosed,
847
864
  init_bitbucket,
848
- isGitHubEnabled,
849
- initGitHub,
850
- verifyWebhookSignature,
851
- getWorkerInstallationToken,
852
- init_app,
853
865
  handlePullRequest,
854
866
  handleIssue,
855
867
  handleComment,
@@ -950,6 +962,10 @@ import {
950
962
  init_task_requester,
951
963
  handleApps,
952
964
  init_apps,
965
+ parseScene,
966
+ init_elements,
967
+ MAX_OBJECT_BYTES,
968
+ init_write_object,
953
969
  cancelApprovalRequest,
954
970
  init_approval_cancel,
955
971
  getUserCommsPrefs,
@@ -1045,7 +1061,7 @@ import {
1045
1061
  getKapsoNumberMapping,
1046
1062
  markKapsoMessageSeen,
1047
1063
  init_config2,
1048
- changesAllowMerge,
1064
+ changesMergePolicy,
1049
1065
  init_repo_merge_policy,
1050
1066
  updateSwarmRepoChecked,
1051
1067
  init_repo_checked_update,
@@ -1088,6 +1104,7 @@ import {
1088
1104
  init_events,
1089
1105
  mergeScheduleTiming,
1090
1106
  validateRecurringTiming,
1107
+ changesScheduleTarget,
1091
1108
  init_validate,
1092
1109
  followUpThreadForSourceTask,
1093
1110
  evaluateFollowUpRedelegation,
@@ -1096,6 +1113,10 @@ import {
1096
1113
  sendTaskOutputSchema,
1097
1114
  sendTaskHandler,
1098
1115
  init_send_task,
1116
+ setSheetRange,
1117
+ appendSheetRows,
1118
+ clearSheetRange,
1119
+ init_service,
1099
1120
  steerTaskUserInputSchema,
1100
1121
  steerTaskOutputSchema,
1101
1122
  steerTaskHandler,
@@ -1136,11 +1157,11 @@ import {
1136
1157
  getEnabledCapabilities,
1137
1158
  createServer,
1138
1159
  init_server
1139
- } from "./cli-wvjqaqcp.js";
1160
+ } from "./cli-fn8aj7gb.js";
1140
1161
  import {
1141
1162
  getFileStorageProvider2,
1142
1163
  init_registry2
1143
- } from "./cli-5r95eqbh.js";
1164
+ } from "./cli-y260hgep.js";
1144
1165
  import {
1145
1166
  RuntimePoolError2,
1146
1167
  mintControllerToken,
@@ -1162,7 +1183,7 @@ import {
1162
1183
  resolvePoolDelivery2,
1163
1184
  createPoolAgent2,
1164
1185
  init_db2
1165
- } from "./cli-q8tc22bj.js";
1186
+ } from "./cli-0fx95c06.js";
1166
1187
  import {
1167
1188
  duplicateGuardedQueryKey,
1168
1189
  warnIfCorsAllowsAnyOrigin,
@@ -1187,16 +1208,10 @@ import {
1187
1208
  deriveApiBaseUrl,
1188
1209
  httpServerSemconvAttributes,
1189
1210
  init_utils2,
1190
- hasSessionAccess,
1191
- getSessionRoot,
1192
- getSessionRoots,
1193
- sessionAccessForRoot,
1194
- listActiveSessionShares,
1195
- toSessionSharesState,
1196
- setSessionShares,
1197
- init_session_shares,
1198
1211
  resolveTaskAuditUserId,
1212
+ resolveHttpRequesterUserId,
1199
1213
  resolveHttpAuditUserId,
1214
+ resolveHttpAuditActor,
1200
1215
  init_audit_user,
1201
1216
  dashboardUserIdHeader,
1202
1217
  resolveHttpFavoriteOwner,
@@ -1219,7 +1234,7 @@ import {
1219
1234
  describeRequestRoute,
1220
1235
  route,
1221
1236
  init_route_def
1222
- } from "./cli-39qm0rtm.js";
1237
+ } from "./cli-a8ts6x1n.js";
1223
1238
  import {
1224
1239
  startPoolRouting,
1225
1240
  stopPoolRouting,
@@ -1232,28 +1247,29 @@ import {
1232
1247
  checkHeartbeatChecklist2,
1233
1248
  runHeartbeatSweep2,
1234
1249
  stopHeartbeat2
1235
- } from "./cli-bp6k9acz.js";
1236
- import"./cli-r0mz92by.js";
1250
+ } from "./cli-aebswqmz.js";
1251
+ import"./cli-50whymxq.js";
1237
1252
  import {
1238
1253
  runtimeSupervisorStatus,
1239
1254
  startRuntimeSupervisor,
1240
1255
  stopRuntimeSupervisor
1241
- } from "./cli-v9ya390t.js";
1256
+ } from "./cli-byxsctca.js";
1242
1257
  import {
1243
1258
  TASK_TITLE_TIMEOUT_MS,
1244
1259
  generateTaskTitle
1245
- } from "./cli-eqq0hwvx.js";
1260
+ } from "./cli-cmgdptmx.js";
1246
1261
  import"./cli-ns59dc6r.js";
1247
1262
  import {
1248
1263
  ACP_TARGET_IDS
1249
- } from "./cli-tdk7jtka.js";
1264
+ } from "./cli-hv3820ez.js";
1250
1265
  import {
1251
1266
  reasoningCapability,
1252
1267
  supportedReasoningLevels
1253
- } from "./cli-rtmqzat7.js";
1268
+ } from "./cli-vdfngx2g.js";
1254
1269
  import {
1255
- MAX_RATE_LIMIT_RESET_MS
1256
- } from "./cli-n85m2wkq.js";
1270
+ MAX_RATE_LIMIT_RESET_MS,
1271
+ MAX_SPEND_CAP_HOLD_MS
1272
+ } from "./cli-zkbz8m2q.js";
1257
1273
  import {
1258
1274
  isLeadChannelMonitoringEnabled,
1259
1275
  ORG_IDENTITY_KEYS,
@@ -1263,7 +1279,7 @@ import {
1263
1279
  isUnknownModelError,
1264
1280
  checkProviderPoolKey,
1265
1281
  writeSkillsToFilesystem
1266
- } from "./cli-xf4z5bdn.js";
1282
+ } from "./cli-tzzas8rb.js";
1267
1283
  import {
1268
1284
  AgentFsRequestError2,
1269
1285
  resolveAgentFsSharedContext2,
@@ -1274,16 +1290,16 @@ import {
1274
1290
  agentFsRequest2,
1275
1291
  resolveApiUrl2,
1276
1292
  init_agent_fs_provision
1277
- } from "./cli-01tvvtad.js";
1293
+ } from "./cli-h03j6je3.js";
1278
1294
  import {
1279
1295
  Anthropic
1280
- } from "./cli-cah298e5.js";
1296
+ } from "./cli-m4ejz4nj.js";
1281
1297
  import {
1282
1298
  objectWebhookSecret2,
1283
1299
  handleObjectWebhookEvent2,
1284
1300
  init_object_webhooks
1285
- } from "./cli-55tc8cj4.js";
1286
- import"./cli-yegz2g06.js";
1301
+ } from "./cli-0a336ze7.js";
1302
+ import"./cli-1carhg8g.js";
1287
1303
  import {
1288
1304
  createUserMergeJob2,
1289
1305
  getUserMergeJob2,
@@ -1292,7 +1308,7 @@ import {
1292
1308
  findFailedUserMergeJob2,
1293
1309
  requeueUserMergeJob2,
1294
1310
  runUserMergeJobs2
1295
- } from "./cli-en6dmkxd.js";
1311
+ } from "./cli-6r1dwegd.js";
1296
1312
  import {
1297
1313
  isCodexOAuthConfigKey
1298
1314
  } from "./cli-j4bwnpkm.js";
@@ -1303,7 +1319,7 @@ import {
1303
1319
  import {
1304
1320
  runTaskUiAction,
1305
1321
  init_actions
1306
- } from "./cli-cjqyse9q.js";
1322
+ } from "./cli-jhtvt7gn.js";
1307
1323
  import {
1308
1324
  RATING_MODEL_MAX_LENGTH,
1309
1325
  REFERENCES_SOURCE_MAX_LENGTH,
@@ -1398,7 +1414,7 @@ import {
1398
1414
  init_typecheck,
1399
1415
  parseSkillContent,
1400
1416
  init_skill_parser
1401
- } from "./cli-mcymtvwn.js";
1417
+ } from "./cli-13t0smbk.js";
1402
1418
  import {
1403
1419
  signalProcessGroup,
1404
1420
  detachedProcessGroup,
@@ -1415,9 +1431,17 @@ import {
1415
1431
  forceRefreshAuthorizationOrThrow,
1416
1432
  forceRefreshTokenOrThrow,
1417
1433
  init_ensure_token
1418
- } from "./cli-9qe5y107.js";
1419
- import"./cli-52nfye5j.js";
1420
- import"./cli-hbvgzjq4.js";
1434
+ } from "./cli-7ewre3dm.js";
1435
+ import {
1436
+ PRIMITIVE_KINDS,
1437
+ ObjectsError,
1438
+ recordObjectVersion,
1439
+ init_objects
1440
+ } from "./cli-3zyme1wt.js";
1441
+ import {
1442
+ agentFsClientFor,
1443
+ init_agent_fs_identity
1444
+ } from "./cli-y6qqbpwc.js";
1421
1445
  import {
1422
1446
  FilesError,
1423
1447
  normalizeFilesError,
@@ -1425,8 +1449,8 @@ import {
1425
1449
  agentFsRequestTimeoutMs,
1426
1450
  AgentFsProvider,
1427
1451
  init_agent_fs_provider
1428
- } from "./cli-9y4tgrkf.js";
1429
- import"./cli-r14ac1y0.js";
1452
+ } from "./cli-skd2c4ej.js";
1453
+ import"./cli-cn6fpa1p.js";
1430
1454
  import {
1431
1455
  automationIntegrationFixUrl,
1432
1456
  preflightAutomation,
@@ -1448,7 +1472,7 @@ import {
1448
1472
  definitionNodeIds,
1449
1473
  validateDefinition,
1450
1474
  init_definition2
1451
- } from "./cli-j5gtytvg.js";
1475
+ } from "./cli-1dr5at77.js";
1452
1476
  import {
1453
1477
  _fetchHolder,
1454
1478
  CLIENT_ID,
@@ -1464,7 +1488,7 @@ import {
1464
1488
  loadAllCodexOAuthSlots,
1465
1489
  getValidCodexOAuth,
1466
1490
  init_storage
1467
- } from "./cli-2m6yaq6b.js";
1491
+ } from "./cli-8fj8yfmk.js";
1468
1492
  import {
1469
1493
  isMultiRuntimeEnabled,
1470
1494
  init_multi_runtime2
@@ -1476,11 +1500,21 @@ import {
1476
1500
  import {
1477
1501
  createRuntimeProvider,
1478
1502
  init_runtime_providers
1479
- } from "./cli-s6zk31gr.js";
1503
+ } from "./cli-43dsqhcp.js";
1480
1504
  import {
1481
1505
  require_content_type
1482
1506
  } from "./cli-1jx0srjt.js";
1483
- import"./cli-n3qe7tyr.js";
1507
+ import"./cli-84xtgbn6.js";
1508
+ import {
1509
+ hasSessionAccess,
1510
+ getSessionRoot,
1511
+ getSessionRoots,
1512
+ sessionAccessForRoot,
1513
+ listActiveSessionShares,
1514
+ toSessionSharesState,
1515
+ setSessionShares,
1516
+ init_session_shares
1517
+ } from "./cli-w41bvvms.js";
1484
1518
  import {
1485
1519
  isInvalidClientError,
1486
1520
  publicEndpointSsrfOptions,
@@ -1498,7 +1532,7 @@ import {
1498
1532
  revokeMcpToken,
1499
1533
  computeExpiresAt,
1500
1534
  init_mcp_wrapper
1501
- } from "./cli-bz97ff9n.js";
1535
+ } from "./cli-c0tyzt73.js";
1502
1536
  import"./cli-v41kn3cd.js";
1503
1537
  import {
1504
1538
  setBedrockProviderModule,
@@ -1538,7 +1572,11 @@ import {
1538
1572
  revokeAllAgentSessionTokens,
1539
1573
  fingerprintApiKey,
1540
1574
  init_users
1541
- } from "./cli-k5jx8jya.js";
1575
+ } from "./cli-z6m6xzxt.js";
1576
+ import {
1577
+ CORE_TOOLS,
1578
+ init_tool_config
1579
+ } from "./cli-yfvhvw8m.js";
1542
1580
  import {
1543
1581
  MAX_PROVIDER_QUOTA_ENTRIES,
1544
1582
  ProviderQuotaCapacityError,
@@ -1547,11 +1585,64 @@ import {
1547
1585
  providerAccountTelemetrySchema,
1548
1586
  rateLimitReplacementSchema,
1549
1587
  init_provider_account_telemetry
1550
- } from "./cli-7wy8gbwb.js";
1588
+ } from "./cli-ya1cj689.js";
1589
+ import {
1590
+ CODEX_AUTH_FAILURE_BENCH_THRESHOLD,
1591
+ CODEX_AUTH_WATCH_NAMESPACE,
1592
+ codexAuthBenchMarkerKey,
1593
+ init_codex_auth_failure
1594
+ } from "./cli-fw2w0kva.js";
1551
1595
  import {
1552
1596
  resolveGitHubHost,
1553
1597
  init_github_host
1554
1598
  } from "./cli-9ttx00s3.js";
1599
+ import {
1600
+ IDENTITY_FIELD_BUDGETS,
1601
+ IdentityFieldBudgetError,
1602
+ init_identity_field_budget
1603
+ } from "./cli-s6fhqbz1.js";
1604
+ import {
1605
+ getSlackConfiguration,
1606
+ init_config4
1607
+ } from "./cli-eetzmsy5.js";
1608
+ import {
1609
+ isSteeringEnabled2,
1610
+ init_steering_enabled
1611
+ } from "./cli-4sydckyj.js";
1612
+ import {
1613
+ SUBSCRIPTION_PLANS_CHECKED_AT,
1614
+ SUBSCRIPTION_PLANS,
1615
+ isSubscriptionPlanId,
1616
+ init_subscription_plans
1617
+ } from "./cli-nh7x3133.js";
1618
+ import {
1619
+ MODEL_SCOPED_WINDOWS,
1620
+ KEY_WIDE_WINDOWS,
1621
+ modelFamilyOf,
1622
+ isModelScopedWindow,
1623
+ activeModelBlocks,
1624
+ init_model_rate_limit_windows,
1625
+ CREDENTIAL_POOL_VARS,
1626
+ PROVIDER_CREDENTIAL_VARS,
1627
+ getModelAwareCredentialVars,
1628
+ splitCredentialPool,
1629
+ selectCredential,
1630
+ init_credentials2
1631
+ } from "./cli-5basv0e7.js";
1632
+ import {
1633
+ getOpenRouterAttributionHeaders,
1634
+ init_openrouter_base_url
1635
+ } from "./cli-dfyv0jdy.js";
1636
+ import {
1637
+ interpolate,
1638
+ init_template2,
1639
+ getTemplateDefinition,
1640
+ getAllTemplateDefinitions,
1641
+ init_registry3,
1642
+ resolveTemplate,
1643
+ init_resolver,
1644
+ init_session_templates
1645
+ } from "./cli-mwxez0pz.js";
1555
1646
  import {
1556
1647
  ASSET_KEY_MAX_LENGTH,
1557
1648
  AssetKeyError,
@@ -1725,64 +1816,7 @@ import {
1725
1816
  KvKeySchema,
1726
1817
  KvEntrySchema,
1727
1818
  init_types5
1728
- } from "./cli-5z0g0e8v.js";
1729
- import {
1730
- CORE_TOOLS,
1731
- init_tool_config
1732
- } from "./cli-0vcqcwfn.js";
1733
- import {
1734
- CODEX_AUTH_FAILURE_BENCH_THRESHOLD,
1735
- CODEX_AUTH_WATCH_NAMESPACE,
1736
- codexAuthBenchMarkerKey,
1737
- init_codex_auth_failure
1738
- } from "./cli-fw2w0kva.js";
1739
- import {
1740
- IDENTITY_FIELD_BUDGETS,
1741
- IdentityFieldBudgetError,
1742
- init_identity_field_budget
1743
- } from "./cli-agjbj5x0.js";
1744
- import {
1745
- isSteeringEnabled2,
1746
- init_steering_enabled
1747
- } from "./cli-4sydckyj.js";
1748
- import {
1749
- getSlackConfiguration,
1750
- init_config4
1751
- } from "./cli-eetzmsy5.js";
1752
- import {
1753
- SUBSCRIPTION_PLANS_CHECKED_AT,
1754
- SUBSCRIPTION_PLANS,
1755
- isSubscriptionPlanId,
1756
- init_subscription_plans
1757
- } from "./cli-nh7x3133.js";
1758
- import {
1759
- MODEL_SCOPED_WINDOWS,
1760
- KEY_WIDE_WINDOWS,
1761
- modelFamilyOf,
1762
- isModelScopedWindow,
1763
- activeModelBlocks,
1764
- init_model_rate_limit_windows,
1765
- CREDENTIAL_POOL_VARS,
1766
- PROVIDER_CREDENTIAL_VARS,
1767
- getModelAwareCredentialVars,
1768
- splitCredentialPool,
1769
- selectCredential,
1770
- init_credentials2
1771
- } from "./cli-js10kdk7.js";
1772
- import {
1773
- getOpenRouterAttributionHeaders,
1774
- init_openrouter_base_url
1775
- } from "./cli-dfyv0jdy.js";
1776
- import {
1777
- interpolate,
1778
- init_template2,
1779
- getTemplateDefinition,
1780
- getAllTemplateDefinitions,
1781
- init_registry3,
1782
- resolveTemplate,
1783
- init_resolver,
1784
- init_session_templates
1785
- } from "./cli-2z2c4k6q.js";
1819
+ } from "./cli-f8rcvf2x.js";
1786
1820
  import {
1787
1821
  init_zod
1788
1822
  } from "./cli-96234j5w.js";
@@ -1823,6 +1857,7 @@ import {
1823
1857
  getPublicMcpBaseUrl,
1824
1858
  getAgentFsLiveUrl,
1825
1859
  agentFsFileRoute,
1860
+ buildAgentFsLiveUrl,
1826
1861
  isCombEnabled,
1827
1862
  isAgentFsProxyEnabled,
1828
1863
  init_constants3
@@ -1835,7 +1870,7 @@ import {
1835
1870
  import {
1836
1871
  init_package,
1837
1872
  package_default
1838
- } from "./cli-2amwhyv2.js";
1873
+ } from "./cli-w24f3j49.js";
1839
1874
  import {
1840
1875
  realtimeBus,
1841
1876
  init_bus
@@ -1851,7 +1886,7 @@ import {
1851
1886
  registerVolatileSecret,
1852
1887
  registerEnvSecrets,
1853
1888
  init_secret_scrubber
1854
- } from "./cli-bpje8n65.js";
1889
+ } from "./cli-fp65jdp2.js";
1855
1890
  import {
1856
1891
  __toESM
1857
1892
  } from "./cli-242037k3.js";
@@ -8745,6 +8780,7 @@ async function handleAgentsRest(req, res, pathSegments, queryParams, myAgentId)
8745
8780
  if (model !== undefined || profile === null) {
8746
8781
  await deleteSwarmConfigByKey2("agent", parsed.params.id, MODEL_PROFILE_CONFIG_KEY);
8747
8782
  } else if (profile !== undefined) {
8783
+ await deleteSwarmConfigByKey2("agent", parsed.params.id, "MODEL_OVERRIDE");
8748
8784
  await upsertSwarmConfig2({
8749
8785
  scope: "agent",
8750
8786
  scopeId: parsed.params.id,
@@ -9362,6 +9398,11 @@ var reportUsage = route({
9362
9398
  },
9363
9399
  auth: { apiKey: true }
9364
9400
  });
9401
+ var SpendCapSchema = object2({
9402
+ limitUsd: number2().nullable(),
9403
+ spendUsd: number2().nullable(),
9404
+ resetsAt: string2().datetime().nullable()
9405
+ });
9365
9406
  var reportRateLimit = route({
9366
9407
  method: "post",
9367
9408
  path: "/api/keys/report-rate-limit",
@@ -9374,7 +9415,8 @@ var reportRateLimit = route({
9374
9415
  keyIndex: number2().int().min(0),
9375
9416
  rateLimitedUntil: string2().datetime(),
9376
9417
  scope: string2().optional(),
9377
- scopeId: string2().optional()
9418
+ scopeId: string2().optional(),
9419
+ spendCap: SpendCapSchema.optional()
9378
9420
  }),
9379
9421
  responses: {
9380
9422
  200: { description: "Key marked as rate-limited", schema: successMessageSchema },
@@ -9593,6 +9635,7 @@ var getAvailable = route({
9593
9635
  modelBlockedIndices: array2(number2().int()).optional(),
9594
9636
  earliestModelResetAt: string2().nullable().optional(),
9595
9637
  seatBlockedIndices: array2(number2().int()).optional(),
9638
+ spendCappedIndices: array2(number2().int()),
9596
9639
  authFailureFence: number2().int()
9597
9640
  })
9598
9641
  },
@@ -9610,6 +9653,7 @@ var ApiKeyStatusSchema = object2({
9610
9653
  scopeId: string2().nullable(),
9611
9654
  status: string2(),
9612
9655
  rateLimitedUntil: string2().nullable(),
9656
+ spendCap: SpendCapSchema.nullable(),
9613
9657
  lastUsedAt: string2().nullable(),
9614
9658
  lastRateLimitAt: string2().nullable(),
9615
9659
  totalUsageCount: number2().int(),
@@ -9867,12 +9911,14 @@ async function handleApiKeys(req, res, pathSegments, queryParams) {
9867
9911
  const parsed = await reportRateLimit.parse(req, res, pathSegments, queryParams);
9868
9912
  if (!parsed)
9869
9913
  return true;
9870
- const { keyType, keySuffix, keyIndex, rateLimitedUntil, scope, scopeId } = parsed.body;
9914
+ const { keyType, keySuffix, keyIndex, scope, scopeId, spendCap } = parsed.body;
9915
+ const holdUntilMs = Date.now() + (spendCap ? MAX_SPEND_CAP_HOLD_MS : MAX_RATE_LIMIT_RESET_MS);
9916
+ const rateLimitedUntil = new Date(Math.min(Date.parse(parsed.body.rateLimitedUntil), holdUntilMs)).toISOString();
9871
9917
  try {
9872
- await markKeyRateLimited2(keyType, keySuffix, keyIndex, rateLimitedUntil, scope, scopeId ?? null);
9918
+ await markKeyRateLimited2(keyType, keySuffix, keyIndex, rateLimitedUntil, scope, scopeId ?? null, spendCap ?? null);
9873
9919
  reportRateLimit.respond(res, 200, {
9874
9920
  success: true,
9875
- message: `Key ...${keySuffix} marked as rate-limited until ${rateLimitedUntil}`
9921
+ message: `Key ...${keySuffix} marked as ${spendCap ? "spend-capped" : "rate-limited"} until ${rateLimitedUntil}`
9876
9922
  });
9877
9923
  } catch (err) {
9878
9924
  jsonError(res, err instanceof Error ? err.message : "Failed to mark rate limit", 500);
@@ -9957,6 +10003,7 @@ async function handleApiKeys(req, res, pathSegments, queryParams) {
9957
10003
  success: true,
9958
10004
  availableIndices: result.availableIndices,
9959
10005
  rejectedIndices: result.rejectedIndices,
10006
+ spendCappedIndices: result.spendCappedIndices,
9960
10007
  totalKeys,
9961
10008
  authFailureFence: result.authFailureFence,
9962
10009
  ...model !== undefined ? {
@@ -11966,7 +12013,7 @@ async function handleAssets(req, res, pathSegments, queryParams, myAgentId) {
11966
12013
  if (!ensureOperator(req, res))
11967
12014
  return true;
11968
12015
  try {
11969
- const actor = await resolveHttpAuditUserId(req, myAgentId);
12016
+ const actor = await resolveHttpRequesterUserId(req, myAgentId);
11970
12017
  const key = parsed.body.key ? await authorizeAssetKeyWrite(parsed.body.key, actor) : undefined;
11971
12018
  const mapping = await upsertAssetKeyMapping2({
11972
12019
  providerId: parsed.body.providerId,
@@ -12049,13 +12096,14 @@ async function handleAssets(req, res, pathSegments, queryParams, myAgentId) {
12049
12096
  }
12050
12097
  }
12051
12098
  try {
12052
- const actor = await resolveHttpAuditUserId(req, myAgentId);
12099
+ const actor = await resolveHttpRequesterUserId(req, myAgentId);
12053
12100
  const key = await authorizeAssetKeyWrite(parsed.body.key, actor);
12054
12101
  const moved = await moveAssetKey2({
12055
12102
  entityType: parsed.params.entityType,
12056
12103
  id: parsed.params.id,
12057
12104
  key,
12058
12105
  changedBy: actor ?? undefined,
12106
+ changedByAgentId: myAgentId,
12059
12107
  descendantTaskIds
12060
12108
  });
12061
12109
  if (!moved) {
@@ -14612,7 +14660,7 @@ async function handleComb(req, res, pathSegments, queryParams, myAgentId) {
14612
14660
  try {
14613
14661
  const result = await sendReviewBatch({
14614
14662
  ...parsed.body,
14615
- requestedByUserId: await resolveHttpAuditUserId(req, myAgentId)
14663
+ requestedByUserId: await resolveHttpRequesterUserId(req, myAgentId)
14616
14664
  });
14617
14665
  reviewBatchRoute.respond(res, result.taskId === null ? 200 : 201, result);
14618
14666
  } catch (error) {
@@ -15081,13 +15129,13 @@ declare module "swarm-extension" {
15081
15129
  sourceAgentId?: string | undefined;
15082
15130
  role?: string | undefined;
15083
15131
  harnessProvider?:
15132
+ | "codex"
15084
15133
  | "pi"
15134
+ | "opencode"
15085
15135
  | "claude"
15086
15136
  | "claude-managed"
15087
- | "codex"
15088
15137
  | "grok"
15089
15138
  | "fx"
15090
- | "opencode"
15091
15139
  | "dsh"
15092
15140
  | "cursor"
15093
15141
  | "amp"
@@ -15249,13 +15297,13 @@ declare module "swarm-extension" {
15249
15297
  requestedByUserId?: string | undefined;
15250
15298
  swarmVersion?: string | undefined;
15251
15299
  provider?:
15300
+ | "codex"
15252
15301
  | "pi"
15302
+ | "opencode"
15253
15303
  | "claude"
15254
15304
  | "claude-managed"
15255
- | "codex"
15256
15305
  | "grok"
15257
15306
  | "fx"
15258
- | "opencode"
15259
15307
  | "dsh"
15260
15308
  | "cursor"
15261
15309
  | "amp"
@@ -15272,13 +15320,13 @@ declare module "swarm-extension" {
15272
15320
  sourceAgentId?: string | undefined;
15273
15321
  role?: string | undefined;
15274
15322
  harnessProvider?:
15323
+ | "codex"
15275
15324
  | "pi"
15325
+ | "opencode"
15276
15326
  | "claude"
15277
15327
  | "claude-managed"
15278
- | "codex"
15279
15328
  | "grok"
15280
15329
  | "fx"
15281
- | "opencode"
15282
15330
  | "dsh"
15283
15331
  | "cursor"
15284
15332
  | "amp"
@@ -15314,8 +15362,9 @@ declare module "swarm-extension" {
15314
15362
  agentId: string | undefined;
15315
15363
  runtimeInstanceId: string | undefined;
15316
15364
  sourceTaskId: string | undefined;
15365
+ auditSourceTaskId: string | undefined;
15317
15366
  contextKey: string | undefined;
15318
- callOrigin: "mcp" | "native" | "extension" | "script-sdk";
15367
+ callOrigin: "native" | "mcp" | "extension" | "script-sdk";
15319
15368
  harness?: string | undefined;
15320
15369
  };
15321
15370
 
@@ -18842,7 +18891,7 @@ var putFavorite = route({
18842
18891
  row: UserFavoriteSchema.nullable()
18843
18892
  })
18844
18893
  },
18845
- 400: { description: "Invalid asset key for a key favorite" },
18894
+ 400: { description: "Invalid asset key for a key or hidden-key favorite" },
18846
18895
  401: { description: "No authenticated principal context" }
18847
18896
  }
18848
18897
  });
@@ -18878,7 +18927,7 @@ async function handleFavorites(req, res, pathSegments, queryParams, myAgentId) {
18878
18927
  return true;
18879
18928
  }
18880
18929
  let itemId = parsed.body.itemId;
18881
- if (parsed.body.itemType === "key") {
18930
+ if (parsed.body.itemType === "key" || parsed.body.itemType === "hidden-key") {
18882
18931
  try {
18883
18932
  itemId = normalizeAssetKey(itemId);
18884
18933
  } catch (error) {
@@ -19571,7 +19620,9 @@ var inviteMemberRoute = route({
19571
19620
  schema: agentFsInviteStateSchema
19572
19621
  },
19573
19622
  400: { description: "Invalid body" },
19574
- 403: { description: "A non-admin user token named an email other than its own" },
19623
+ 403: {
19624
+ description: "The caller is not the operator key or a user, or a non-admin user token named an email other than its own"
19625
+ },
19575
19626
  500: { description: "Provisioning or invite failed" }
19576
19627
  },
19577
19628
  auth: { apiKey: true },
@@ -19675,8 +19726,13 @@ var deleteTaskFileRoute = route({
19675
19726
  rbac: { permission: "task.fs.mutate" }
19676
19727
  });
19677
19728
  async function resolveInvite(req, body) {
19678
- const user = authUser(getRequestAuth(req));
19679
- if (!user || !isRbacEnabled())
19729
+ const auth = getRequestAuth(req);
19730
+ if (auth?.kind === "operator")
19731
+ return body;
19732
+ const user = authUser(auth);
19733
+ if (!user)
19734
+ return { denied: "Only the operator key or a user token can invite to the shared drive" };
19735
+ if (!isRbacEnabled())
19680
19736
  return body;
19681
19737
  const grant = await getUserGrant2(user.id);
19682
19738
  if (grant.grantsAll)
@@ -27892,8 +27948,10 @@ async function revokeLinearToken(accessToken) {
27892
27948
  init_ensure_token();
27893
27949
 
27894
27950
  // src/oauth/identity-capture.ts
27951
+ init_egress_guard();
27895
27952
  init_secret_scrubber();
27896
27953
  init_app_validation();
27954
+ init_mcp_wrapper();
27897
27955
  var IDENTITY_FETCH_TIMEOUT_MS = 5000;
27898
27956
  function pickString(value) {
27899
27957
  return typeof value === "string" && value.length > 0 ? value : null;
@@ -27935,7 +27993,8 @@ async function captureIdentity(input) {
27935
27993
  const controller = new AbortController;
27936
27994
  const timer = setTimeout(() => controller.abort(), IDENTITY_FETCH_TIMEOUT_MS);
27937
27995
  try {
27938
- const response = await fetch(input.userinfoUrl, {
27996
+ const guardedFetch = createSsrfGuardedFetch(publicEndpointSsrfOptions());
27997
+ const response = await guardedFetch(input.userinfoUrl, {
27939
27998
  headers: {
27940
27999
  authorization: `Bearer ${input.accessToken}`,
27941
28000
  accept: "application/json"
@@ -28411,6 +28470,382 @@ async function handleObjectWebhooks(req, res, pathSegments) {
28411
28470
  return true;
28412
28471
  }
28413
28472
 
28473
+ // src/http/objects.ts
28474
+ init_zod();
28475
+
28476
+ // src/be/primitives/object-embed.ts
28477
+ init_provider();
28478
+ init_constants3();
28479
+ init_agent_fs_identity();
28480
+ init_db4();
28481
+ init_elements();
28482
+ init_objects();
28483
+ init_service();
28484
+ init_write_object();
28485
+
28486
+ class ObjectEmbedError extends Error {
28487
+ status;
28488
+ version;
28489
+ constructor(status, message, version) {
28490
+ super(message);
28491
+ this.status = status;
28492
+ this.version = version;
28493
+ }
28494
+ }
28495
+ var versionOf = (value) => value && Number.isFinite(Number(value)) ? Number(value) : null;
28496
+ async function sharedDrive() {
28497
+ const value = async (key) => (await getSwarmConfigs2({ scope: "global", key }))[0]?.value?.trim() || process.env[key]?.trim();
28498
+ const orgId = await value("AGENT_FS_DEFAULT_ORG_ID") || await value("AGENT_FS_SHARED_ORG_ID");
28499
+ const driveId = await value("AGENT_FS_DEFAULT_DRIVE_ID");
28500
+ return orgId && driveId ? { orgId, driveId } : null;
28501
+ }
28502
+ async function open(id) {
28503
+ const row = await getDbClient2().get("SELECT * FROM primitive_objects WHERE id = ?", [id]);
28504
+ if (!row)
28505
+ throw new ObjectEmbedError(404, `no object with id '${id}'`);
28506
+ const shared = await sharedDrive();
28507
+ if (!shared || shared.orgId !== row.orgId || shared.driveId !== row.driveId) {
28508
+ throw new ObjectEmbedError(403, "this object is not on the swarm's shared agent-fs drive");
28509
+ }
28510
+ if (row.deletedAt)
28511
+ throw new ObjectEmbedError(404, `object '${id}' was deleted on agent-fs`);
28512
+ const client = row.ownerAgentId ? await agentFsClientFor(row.ownerAgentId) : undefined;
28513
+ if (!client || !row.ownerAgentId) {
28514
+ throw new ObjectEmbedError(503, "owner agent has no agent-fs key");
28515
+ }
28516
+ if (client.identity.orgId !== row.orgId || client.identity.driveId !== row.driveId) {
28517
+ throw new ObjectEmbedError(503, "owner agent's default agent-fs drive is not the object's drive");
28518
+ }
28519
+ const scope = { taskId: "", name: "", key: row.path, orgId: row.orgId, driveId: row.driveId };
28520
+ return { row, owner: row.ownerAgentId, provider: client.provider, scope };
28521
+ }
28522
+ var withLink = (row) => ({ ...row, link: buildAgentFsLiveUrl(row) });
28523
+ async function driveWatched(orgId, driveId) {
28524
+ const hook = await getDbClient2().get("SELECT status FROM agent_fs_object_webhooks WHERE orgId = ? AND driveId = ?", [orgId, driveId]);
28525
+ return hook?.status === "active";
28526
+ }
28527
+ async function recordEditor(id, userId) {
28528
+ await getDbClient2().run("UPDATE primitive_objects SET updated_by = ? WHERE id = ?", [userId, id]);
28529
+ }
28530
+ function asEmbedError(error) {
28531
+ if (!(error instanceof ObjectsError))
28532
+ return error;
28533
+ const status = error.message.startsWith("concurrent writers") ? 409 : 400;
28534
+ return new ObjectEmbedError(status, error.message);
28535
+ }
28536
+ async function readObject(id, knownVersion) {
28537
+ const { row, provider, scope } = await open(id);
28538
+ if (knownVersion !== undefined) {
28539
+ if (row.fileVersion === knownVersion && await driveWatched(row.orgId, row.driveId)) {
28540
+ return { object: withLink(row), version: knownVersion, unchanged: true };
28541
+ }
28542
+ let current = null;
28543
+ try {
28544
+ current = await provider.currentVersion(scope);
28545
+ } catch (error) {
28546
+ if (error instanceof FilesError && error.code === "Unauthorized")
28547
+ throw error;
28548
+ }
28549
+ if (current !== null && current === knownVersion) {
28550
+ return { object: withLink(row), version: current, unchanged: true };
28551
+ }
28552
+ }
28553
+ let response;
28554
+ try {
28555
+ response = await provider.download(scope);
28556
+ } catch (error) {
28557
+ if (error instanceof FilesError && error.code === "NotFound") {
28558
+ throw new ObjectEmbedError(404, `the file for object '${id}' is missing on agent-fs`);
28559
+ }
28560
+ throw error;
28561
+ }
28562
+ const version = versionOf(response.headers.get("x-agent-fs-version")) ?? row.fileVersion;
28563
+ const text = await response.text();
28564
+ let content = text;
28565
+ try {
28566
+ content = JSON.parse(text);
28567
+ } catch {}
28568
+ return { object: withLink({ ...row, fileVersion: version }), version, unchanged: false, content };
28569
+ }
28570
+ async function saveBoardContent(input) {
28571
+ const { row, provider, scope } = await open(input.id);
28572
+ if (row.kind !== "board") {
28573
+ throw new ObjectEmbedError(400, `object ${row.id} is a ${row.kind}; only a board takes a full save`);
28574
+ }
28575
+ let scene;
28576
+ try {
28577
+ scene = parseScene(input.content, row.path);
28578
+ } catch (error) {
28579
+ throw asEmbedError(error);
28580
+ }
28581
+ if (scene.type !== undefined && scene.type !== "excalidraw") {
28582
+ throw new ObjectEmbedError(400, "content is not an Excalidraw scene (type must be 'excalidraw')");
28583
+ }
28584
+ const doc = PRIMITIVE_KINDS.board?.withId(scene, row.id) ?? scene;
28585
+ const swarm = doc.swarm;
28586
+ if (swarm.title === undefined && row.title)
28587
+ swarm.title = row.title;
28588
+ const body = JSON.stringify(doc, null, 2);
28589
+ if (Buffer.byteLength(body) > MAX_OBJECT_BYTES) {
28590
+ throw new ObjectEmbedError(413, `the board would exceed ${MAX_OBJECT_BYTES} bytes; nothing written`);
28591
+ }
28592
+ let written;
28593
+ try {
28594
+ written = await provider.upload(scope, body, {
28595
+ contentType: "application/json",
28596
+ ifMatch: String(input.ifMatch),
28597
+ message: `edit via ${input.actor.via} by ${input.actor.name ?? "operator"}`
28598
+ });
28599
+ } catch (error) {
28600
+ if (!(error instanceof FilesError && error.code === "Conflict"))
28601
+ throw error;
28602
+ const current = await provider.currentVersion(scope).catch(() => null);
28603
+ throw new ObjectEmbedError(409, `the board changed on agent-fs since version ${input.ifMatch}; reload it`, current);
28604
+ }
28605
+ const version = versionOf(written.version);
28606
+ await recordObjectVersion(row.id, version);
28607
+ await recordEditor(row.id, input.actor.userId);
28608
+ return { object: withLink({ ...row, fileVersion: version }), version };
28609
+ }
28610
+ async function applySheetOp(input) {
28611
+ const { row, owner } = await open(input.id);
28612
+ if (row.kind !== "sheet") {
28613
+ throw new ObjectEmbedError(400, `object ${row.id} is a ${row.kind}, not a sheet`);
28614
+ }
28615
+ const target = { agentId: owner, id: row.id };
28616
+ const { op } = input;
28617
+ let result;
28618
+ try {
28619
+ if (op.op === "setRange") {
28620
+ result = await setSheetRange({ ...target, range: op.range, values: op.values });
28621
+ } else if (op.op === "clearRange") {
28622
+ result = await clearSheetRange({ ...target, range: op.range });
28623
+ } else {
28624
+ result = await appendSheetRows({ ...target, tab: op.tab, rows: op.rows });
28625
+ }
28626
+ } catch (error) {
28627
+ throw asEmbedError(error);
28628
+ }
28629
+ await recordEditor(row.id, input.actor.userId);
28630
+ return { op: op.op, ...result };
28631
+ }
28632
+
28633
+ // src/http/objects.ts
28634
+ init_write_object();
28635
+ init_users();
28636
+ init_rbac();
28637
+ init_request_auth_context();
28638
+ init_favorite_owner();
28639
+ init_request_principal();
28640
+ init_route_def();
28641
+ init_utils2();
28642
+ var ObjectSchema = object2({
28643
+ id: string2(),
28644
+ kind: string2(),
28645
+ orgId: string2(),
28646
+ driveId: string2(),
28647
+ path: string2(),
28648
+ title: string2().nullable(),
28649
+ fileVersion: number2().nullable(),
28650
+ ownerAgentId: string2().nullable(),
28651
+ createdAt: string2(),
28652
+ updatedAt: string2(),
28653
+ link: string2().nullable()
28654
+ });
28655
+ var params2 = object2({ id: string2().uuid().describe("Object id (`swarm.id` in the file)") });
28656
+ var CellSchema = union3([number2(), string2(), boolean(), _null()]);
28657
+ var CellRowsSchema = array2(array2(CellSchema));
28658
+ var objectErrors = {
28659
+ 400: { description: "Invalid input, or the object is not the kind this route edits" },
28660
+ 403: {
28661
+ description: "Permission denied, a page guest, a read-only page session, or an object off the shared drive"
28662
+ },
28663
+ 404: { description: "No such object, or its file is gone" },
28664
+ 503: { description: "The owner agent has no agent-fs key on the object's drive" }
28665
+ };
28666
+ var getObjectRoute = route({
28667
+ method: "get",
28668
+ path: "/api/objects/{id}",
28669
+ pattern: ["api", "objects", null],
28670
+ summary: "Read a board or sheet on the shared drive, or confirm it is unchanged",
28671
+ tags: ["Objects"],
28672
+ params: params2,
28673
+ query: object2({
28674
+ knownVersion: exports_coerce.number().int().min(0).optional().describe("The version the caller holds. A match answers `unchanged: true` with no content")
28675
+ }),
28676
+ rbac: { permission: "objects.read" },
28677
+ responses: {
28678
+ 200: {
28679
+ description: "The object with its content, or `unchanged: true` with no content",
28680
+ schema: object2({
28681
+ object: ObjectSchema,
28682
+ version: number2().nullable(),
28683
+ unchanged: boolean(),
28684
+ content: unknown().optional()
28685
+ })
28686
+ },
28687
+ ...objectErrors
28688
+ }
28689
+ });
28690
+ var putContentRoute = route({
28691
+ method: "put",
28692
+ path: "/api/objects/{id}/content",
28693
+ pattern: ["api", "objects", null, "content"],
28694
+ summary: "Save a board's full Excalidraw scene, guarded by its agent-fs version",
28695
+ tags: ["Objects"],
28696
+ params: params2,
28697
+ body: object2({
28698
+ content: record2(string2(), unknown()).describe("The Excalidraw scene"),
28699
+ ifMatch: number2().int().min(0).describe("The version the scene was edited from")
28700
+ }),
28701
+ maxBodyBytes: MAX_OBJECT_BYTES + 256 * 1024,
28702
+ rbac: { permission: "objects.write" },
28703
+ responses: {
28704
+ 200: {
28705
+ description: "Saved",
28706
+ schema: object2({ object: ObjectSchema, version: number2().nullable() })
28707
+ },
28708
+ ...objectErrors,
28709
+ 409: { description: "The board changed since `ifMatch`; the body carries its `version`" },
28710
+ 413: { description: "The scene exceeds 5 MiB" }
28711
+ }
28712
+ });
28713
+ var sheetOpsRoute = route({
28714
+ method: "post",
28715
+ path: "/api/objects/{id}/sheet-ops",
28716
+ pattern: ["api", "objects", null, "sheet-ops"],
28717
+ summary: "Patch sheet cells; the server recalculates and merges concurrent edits",
28718
+ tags: ["Objects"],
28719
+ params: params2,
28720
+ body: discriminatedUnion("op", [
28721
+ object2({ op: literal2("setRange"), range: string2().min(1), values: CellRowsSchema }),
28722
+ object2({ op: literal2("clearRange"), range: string2().min(1) }),
28723
+ object2({ op: literal2("appendRows"), tab: string2().min(1), rows: CellRowsSchema })
28724
+ ]),
28725
+ maxBodyBytes: 2 * 1024 * 1024,
28726
+ rbac: { permission: "objects.write" },
28727
+ responses: {
28728
+ 200: {
28729
+ description: "Applied: the range written and the new version",
28730
+ schema: object2({
28731
+ op: _enum2(["setRange", "clearRange", "appendRows"]),
28732
+ range: string2(),
28733
+ version: number2(),
28734
+ changed: number2().optional(),
28735
+ recalculated: number2().optional(),
28736
+ cleared: number2().optional()
28737
+ })
28738
+ },
28739
+ ...objectErrors,
28740
+ 409: { description: "Other writers changed the sheet on every retry; try again" }
28741
+ }
28742
+ });
28743
+ var publicObject = (o) => ({
28744
+ id: o.id,
28745
+ kind: o.kind,
28746
+ orgId: o.orgId,
28747
+ driveId: o.driveId,
28748
+ path: o.path,
28749
+ title: o.title,
28750
+ fileVersion: o.fileVersion,
28751
+ ownerAgentId: o.ownerAgentId,
28752
+ createdAt: o.createdAt,
28753
+ updatedAt: o.updatedAt,
28754
+ link: o.link
28755
+ });
28756
+ async function authorize(req, res, myAgentId, verb) {
28757
+ const auth = getRequestAuth(req);
28758
+ if (auth?.kind === "guest" || auth?.kind === "controller") {
28759
+ jsonError(res, "sign in to the swarm to view this object", 403);
28760
+ return null;
28761
+ }
28762
+ const principal = await resolveRequestPrincipal(req, myAgentId, {
28763
+ unauthenticatedFallback: "operator"
28764
+ });
28765
+ const decision = principal ? can({ principal, verb, resource: { kind: "none" }, source: "http" }) : { allow: false, reason: "no authenticated principal" };
28766
+ if (!decision.allow) {
28767
+ jsonError(res, decision.reason, 403);
28768
+ return null;
28769
+ }
28770
+ const via = auth?.page ? "page" : "app";
28771
+ if (verb === "objects.write" && auth?.page && principal?.kind !== "user") {
28772
+ jsonError(res, "this page session is read-only; sign in to the swarm to edit", 403);
28773
+ return null;
28774
+ }
28775
+ let user = principal?.kind === "user" ? authUser(auth) : undefined;
28776
+ if (!user && isOperatorAuth(auth) && !auth.page && !myAgentId) {
28777
+ const pickedId = dashboardUserIdHeader(req);
28778
+ const picked = pickedId ? await findUserById(pickedId) : null;
28779
+ if (picked?.status === "active" && !picked.mergedIntoUserId)
28780
+ user = picked;
28781
+ }
28782
+ return { via, userId: user?.id ?? null, name: user?.name ?? null };
28783
+ }
28784
+ function respondError(res, error) {
28785
+ if (!(error instanceof ObjectEmbedError))
28786
+ return false;
28787
+ if (error.status === 409 && error.version !== undefined) {
28788
+ json(res, { error: error.message, version: error.version }, 409);
28789
+ } else {
28790
+ jsonError(res, error.message, error.status);
28791
+ }
28792
+ return true;
28793
+ }
28794
+ async function handleObjects(req, res, pathSegments, queryParams, myAgentId) {
28795
+ if (getObjectRoute.match(req.method, pathSegments)) {
28796
+ const parsed = await getObjectRoute.parse(req, res, pathSegments, queryParams);
28797
+ if (!parsed)
28798
+ return true;
28799
+ if (!await authorize(req, res, myAgentId, "objects.read"))
28800
+ return true;
28801
+ try {
28802
+ const read = await readObject(parsed.params.id, parsed.query.knownVersion);
28803
+ getObjectRoute.respond(res, 200, { ...read, object: publicObject(read.object) });
28804
+ } catch (error) {
28805
+ if (!respondError(res, error))
28806
+ throw error;
28807
+ }
28808
+ return true;
28809
+ }
28810
+ if (putContentRoute.match(req.method, pathSegments)) {
28811
+ const parsed = await putContentRoute.parse(req, res, pathSegments, queryParams);
28812
+ if (!parsed)
28813
+ return true;
28814
+ const actor = await authorize(req, res, myAgentId, "objects.write");
28815
+ if (!actor)
28816
+ return true;
28817
+ try {
28818
+ const saved = await saveBoardContent({
28819
+ id: parsed.params.id,
28820
+ content: parsed.body.content,
28821
+ ifMatch: parsed.body.ifMatch,
28822
+ actor
28823
+ });
28824
+ putContentRoute.respond(res, 200, { ...saved, object: publicObject(saved.object) });
28825
+ } catch (error) {
28826
+ if (!respondError(res, error))
28827
+ throw error;
28828
+ }
28829
+ return true;
28830
+ }
28831
+ if (sheetOpsRoute.match(req.method, pathSegments)) {
28832
+ const parsed = await sheetOpsRoute.parse(req, res, pathSegments, queryParams);
28833
+ if (!parsed)
28834
+ return true;
28835
+ const actor = await authorize(req, res, myAgentId, "objects.write");
28836
+ if (!actor)
28837
+ return true;
28838
+ try {
28839
+ sheetOpsRoute.respond(res, 200, await applySheetOp({ id: parsed.params.id, op: parsed.body, actor }));
28840
+ } catch (error) {
28841
+ if (!respondError(res, error))
28842
+ throw error;
28843
+ }
28844
+ return true;
28845
+ }
28846
+ return false;
28847
+ }
28848
+
28414
28849
  // src/http/onboarding.ts
28415
28850
  init_openai2();
28416
28851
  init_automation_preflight();
@@ -29604,8 +30039,8 @@ init_session_shares();
29604
30039
  init_steering2();
29605
30040
  init_task_citations2();
29606
30041
  init_task_ui_spec();
29607
- init_users();
29608
30042
  init_rbac();
30043
+ init_session_mirror();
29609
30044
  init_context_key();
29610
30045
  init_errors2();
29611
30046
  init_sibling_awareness();
@@ -30541,7 +30976,7 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
30541
30976
  const parsed = await createTask.parse(req, res, pathSegments, queryParams);
30542
30977
  if (!parsed)
30543
30978
  return true;
30544
- const trustedUserId = await resolveHttpAuditUserId(req, myAgentId);
30979
+ const trustedUserId = await resolveHttpRequesterUserId(req, myAgentId);
30545
30980
  const requestedByUserId = await resolveTaskRequester(req, myAgentId, parsed.body.requestedByUserId, trustedUserId);
30546
30981
  let defaultAgentId = parsed.body.agentId || undefined;
30547
30982
  if (!defaultAgentId) {
@@ -30652,6 +31087,9 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
30652
31087
  parentTaskId: task.parentTaskId
30653
31088
  }
30654
31089
  });
31090
+ if (principal.kind === "user" || principal.kind === "operator") {
31091
+ getDbClient2().afterCommit(() => mirrorSessionPrompt(task));
31092
+ }
30655
31093
  createTask.respond(res, 201, task);
30656
31094
  } catch (error) {
30657
31095
  if (error instanceof TaskRoutingAuthorizationError) {
@@ -30700,6 +31138,9 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
30700
31138
  jsonError(res, "Task not found", 404);
30701
31139
  return true;
30702
31140
  }
31141
+ if (existingTask.status === "draft") {
31142
+ getDbClient2().afterCommit(() => mirrorSessionPrompt(promoted));
31143
+ }
30703
31144
  promoteDraftTaskRoute.respond(res, 200, promoted);
30704
31145
  return true;
30705
31146
  }
@@ -30817,11 +31258,7 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
30817
31258
  jsonError(res, "Forbidden: caller cannot steer this task", 403);
30818
31259
  return true;
30819
31260
  }
30820
- const trustedUserId = await await resolveHttpAuditUserId(req, myAgentId);
30821
- let requestedByUserId = trustedUserId ?? undefined;
30822
- if (process.env.TRUST_BODY_REQUESTED_BY_USER_ID !== "false" && !requestedByUserId && parsed.body.requestedByUserId) {
30823
- requestedByUserId = (await findUserById(parsed.body.requestedByUserId))?.id;
30824
- }
31261
+ const requestedByUserId = await resolveTaskRequester(req, myAgentId, parsed.body.requestedByUserId);
30825
31262
  try {
30826
31263
  const auth = getRequestAuth(req);
30827
31264
  const createdByAgentId = !auth && myAgentId && await getAgentById2(myAgentId) ? myAgentId : undefined;
@@ -31940,7 +32377,7 @@ async function handlePages(req, res, pathSegments, queryParams, myAgentId) {
31940
32377
  passwordHash = await Bun.password.hash(parsed.body.password, "bcrypt");
31941
32378
  }
31942
32379
  try {
31943
- const key = parsed.body.key ? await authorizeAssetKeyWrite(parsed.body.key, await resolveHttpAuditUserId(req, myAgentId)) : undefined;
32380
+ const key = parsed.body.key ? await authorizeAssetKeyWrite(parsed.body.key, await resolveHttpRequesterUserId(req, myAgentId)) : undefined;
31944
32381
  const page = await createPage2({
31945
32382
  key,
31946
32383
  agentId: myAgentId,
@@ -32144,7 +32581,7 @@ async function handlePages(req, res, pathSegments, queryParams, myAgentId) {
32144
32581
  let key;
32145
32582
  if (parsed.body.key !== undefined) {
32146
32583
  try {
32147
- key = await authorizeAssetKeyWrite(parsed.body.key, await resolveHttpAuditUserId(req, myAgentId));
32584
+ key = await authorizeAssetKeyWrite(parsed.body.key, await resolveHttpRequesterUserId(req, myAgentId));
32148
32585
  } catch (error) {
32149
32586
  if (error instanceof AssetKeyAuthorizationError) {
32150
32587
  jsonError(res, error.message, error.statusCode);
@@ -34615,16 +35052,35 @@ function getPageFrameAncestors() {
34615
35052
  cachedFrameAncestors = { raw, origins };
34616
35053
  return origins;
34617
35054
  }
35055
+ function embedOrigins(appUrls) {
35056
+ const origins = new Set;
35057
+ for (const value of appUrls) {
35058
+ try {
35059
+ const url = new URL(value);
35060
+ if (url.protocol === "https:" || url.protocol === "http:")
35061
+ origins.add(url.origin);
35062
+ } catch {}
35063
+ }
35064
+ return Array.from(origins, (origin) => ` ${origin}`).join("");
35065
+ }
35066
+ function pageViewer(payload) {
35067
+ if (payload?.uid)
35068
+ return "user";
35069
+ if (payload?.op)
35070
+ return "operator";
35071
+ return "guest";
35072
+ }
34618
35073
  function buildCsp(page) {
34619
35074
  const configured = getConfiguredAppUrls();
34620
35075
  const devFallbacks = getLocalDevAppOrigins();
34621
35076
  const embedders = page.authMode === "public" ? getPageFrameAncestors() : [];
34622
35077
  const ancestors = Array.from(new Set([...configured, ...devFallbacks, ...embedders]));
35078
+ const appOrigins = embedOrigins(configured);
34623
35079
  return [
34624
35080
  "default-src 'self'",
34625
- "script-src 'self' 'unsafe-inline' 'unsafe-eval' https://cdn.tailwindcss.com https://cdn.jsdelivr.net https://unpkg.com",
34626
- "style-src 'self' 'unsafe-inline' https://fonts.googleapis.com https://cdn.tailwindcss.com https://cdn.jsdelivr.net https://unpkg.com",
34627
- "font-src 'self' https://fonts.gstatic.com data:",
35081
+ `script-src 'self' 'unsafe-inline' 'unsafe-eval' https://cdn.tailwindcss.com https://cdn.jsdelivr.net https://unpkg.com${appOrigins}`,
35082
+ `style-src 'self' 'unsafe-inline' https://fonts.googleapis.com https://cdn.tailwindcss.com https://cdn.jsdelivr.net https://unpkg.com${appOrigins}`,
35083
+ `font-src 'self' https://fonts.gstatic.com data:${appOrigins}`,
34628
35084
  "img-src 'self' data: https:",
34629
35085
  "media-src 'self' data: https: blob:",
34630
35086
  "connect-src 'self'",
@@ -34819,7 +35275,7 @@ async function handlePagesPublic(req, res, pathSegments, queryParams) {
34819
35275
  }
34820
35276
  const feedback = isPageFeedbackRequested(queryParams);
34821
35277
  const html = injectBrowserSdk(page.body, {
34822
- head: pageHead(page, queryParams, wantsPrint),
35278
+ head: `${pageHead(page, queryParams, wantsPrint)}<meta name="swarm-viewer" content="${pageViewer(cookiePayload)}">`,
34823
35279
  headFirst: feedback ? feedbackKeyGuardScript() : "",
34824
35280
  standardsMode: page.designVersion !== 1
34825
35281
  }) + (wantsPrint ? PRINT_AUTOTRIGGER_SCRIPT : "") + (feedback ? feedbackOverlayScripts(page.id) : "");
@@ -35065,6 +35521,7 @@ var pollTriggers = route({
35065
35521
  404: { description: "Agent not found" }
35066
35522
  }
35067
35523
  });
35524
+ var NEEDS_WRITE = Symbol("poll-needs-write");
35068
35525
  var CHANNEL_ACTIVITY_INTERVAL_MS = 60000;
35069
35526
  var lastChannelActivityCheckAt = 0;
35070
35527
  async function attachmentsForTrigger(taskId) {
@@ -35177,19 +35634,29 @@ async function handlePoll(req, res, pathSegments, queryParams, myAgentId) {
35177
35634
  let runtimeDraining = false;
35178
35635
  let result;
35179
35636
  try {
35180
- result = await getDbClient2().transaction(async () => {
35637
+ const pollBody = async (probe) => {
35181
35638
  const agent = await getAgentById2(myAgentId);
35182
35639
  if (!agent) {
35183
35640
  return { error: "Agent not found", status: 404 };
35184
35641
  }
35185
35642
  if (modelTierOverrides) {
35186
- await setAgentModelTierOverrides(agent.id, modelTierOverrides);
35643
+ if (!probe)
35644
+ await setAgentModelTierOverrides(agent.id, modelTierOverrides);
35645
+ else if (await modelTierOverridesDiffer(agent.id, modelTierOverrides))
35646
+ return NEEDS_WRITE;
35187
35647
  }
35188
35648
  if (isExtensionAgent2(agent)) {
35189
35649
  return { trigger: null };
35190
35650
  }
35191
- if (isMultiRuntimeEnabled() && !(runtimeInstanceId && await touchRuntimeInstance(runtimeInstanceId, agent.id))) {
35192
- return { trigger: null };
35651
+ if (isMultiRuntimeEnabled()) {
35652
+ if (!runtimeInstanceId)
35653
+ return { trigger: null };
35654
+ if (probe) {
35655
+ if (!await isRuntimeInstanceFresh(runtimeInstanceId, agent.id))
35656
+ return NEEDS_WRITE;
35657
+ } else if (!await touchRuntimeInstance(runtimeInstanceId, agent.id)) {
35658
+ return { trigger: null };
35659
+ }
35193
35660
  }
35194
35661
  if (isMultiRuntimeEnabled() && runtimeInstanceId && (await getRuntimeInstanceById(runtimeInstanceId))?.draining) {
35195
35662
  runtimeDraining = true;
@@ -35201,6 +35668,8 @@ async function handlePoll(req, res, pathSegments, queryParams, myAgentId) {
35201
35668
  const offeredTasks = await hasCapacity2(myAgentId) ? await getOfferedTasksForAgent2(myAgentId) : [];
35202
35669
  const firstOfferedTask = offeredTasks[0];
35203
35670
  if (firstOfferedTask) {
35671
+ if (probe)
35672
+ return NEEDS_WRITE;
35204
35673
  const claimedTask = await claimOfferedTask2(firstOfferedTask.id, myAgentId);
35205
35674
  if (claimedTask) {
35206
35675
  await recordRuntimeTask(claimedTask.id);
@@ -35218,7 +35687,10 @@ async function handlePoll(req, res, pathSegments, queryParams, myAgentId) {
35218
35687
  }
35219
35688
  }
35220
35689
  if (await hasCapacity2(myAgentId)) {
35221
- const pendingTask = await getPendingTaskForAgent2(myAgentId);
35690
+ const pendingProbe = probe ? { skipLogDue: false } : undefined;
35691
+ const pendingTask = await getPendingTaskForAgent2(myAgentId, pendingProbe);
35692
+ if (pendingProbe && (pendingTask || pendingProbe.skipLogDue))
35693
+ return NEEDS_WRITE;
35222
35694
  if (pendingTask) {
35223
35695
  const admission = await canClaim(myAgentId, new Date, pendingTask.requestedByUserId);
35224
35696
  if (!admission.allowed) {
@@ -35308,8 +35780,10 @@ async function handlePoll(req, res, pathSegments, queryParams, myAgentId) {
35308
35780
  };
35309
35781
  }
35310
35782
  }
35311
- const claimedChannels = hasCapability("messaging") ? await claimMentions2(myAgentId) : [];
35783
+ const claimedChannels = hasCapability("messaging") ? await claimMentions2(myAgentId, { dryRun: probe }) : [];
35312
35784
  if (claimedChannels.length > 0) {
35785
+ if (probe)
35786
+ return NEEDS_WRITE;
35313
35787
  return {
35314
35788
  trigger: {
35315
35789
  type: "unread_mentions",
@@ -35339,6 +35813,8 @@ async function handlePoll(req, res, pathSegments, queryParams, myAgentId) {
35339
35813
  };
35340
35814
  const unassignedIds = await getUnassignedTaskIdsForAgent2(myAgentId, 5, async (task) => await poolTaskRunsOnHarness(task, harness) && (!task.profile || await passesProfileCheck(task.profile, task.vcsRepo)));
35341
35815
  if (unassignedIds.length > 0) {
35816
+ if (probe)
35817
+ return NEEDS_WRITE;
35342
35818
  const candidateId = unassignedIds[0];
35343
35819
  const candidateTask = await getTaskById2(candidateId);
35344
35820
  const admission = await canClaim(myAgentId, new Date, candidateTask?.requestedByUserId);
@@ -35418,7 +35894,9 @@ async function handlePoll(req, res, pathSegments, queryParams, myAgentId) {
35418
35894
  }
35419
35895
  }
35420
35896
  return { trigger: null };
35421
- });
35897
+ };
35898
+ const probed = await getDbClient2().transaction(() => pollBody(true), { readOnly: true });
35899
+ result = probed === NEEDS_WRITE ? await getDbClient2().transaction(() => pollBody(false)) : probed;
35422
35900
  } catch (error) {
35423
35901
  console.error("[/api/poll] Database error:", error);
35424
35902
  jsonError(res, `Database error occurred while polling for triggers: ${error instanceof Error ? error.message : String(error)}`, 500);
@@ -35493,14 +35971,21 @@ init_secret_scrubber();
35493
35971
  init_core();
35494
35972
  init_route_def();
35495
35973
  init_utils2();
35496
- var PoolKeyStatusSchema = _enum2(["ok", "rejected", "rate_limited", "unchecked"]);
35974
+ var PoolKeyStatusSchema = _enum2([
35975
+ "ok",
35976
+ "rejected",
35977
+ "rate_limited",
35978
+ "spend_capped",
35979
+ "unchecked"
35980
+ ]);
35497
35981
  var PoolKeySchema = object2({
35498
35982
  index: number2().int().min(0),
35499
35983
  suffix: string2(),
35500
35984
  status: PoolKeyStatusSchema,
35501
35985
  error: string2().nullable(),
35502
35986
  checkedAt: string2().nullable(),
35503
- rateLimitedUntil: string2().nullable()
35987
+ rateLimitedUntil: string2().nullable(),
35988
+ spendCap: SpendCapSchema.nullable()
35504
35989
  });
35505
35990
  var PoolKeysResponseSchema = object2({
35506
35991
  key: string2(),
@@ -35595,13 +36080,15 @@ async function poolResponse(key) {
35595
36080
  const row = statuses.find((status) => status.keySuffix === suffix);
35596
36081
  const rejected = !!row?.lastValidationFailedAt;
35597
36082
  const limited = row?.status === "rate_limited" && !!row.rateLimitedUntil && Date.parse(row.rateLimitedUntil) > Date.now();
36083
+ const spendCap = limited ? row?.spendCap ?? null : null;
35598
36084
  return {
35599
36085
  index,
35600
36086
  suffix,
35601
- status: rejected ? "rejected" : limited ? "rate_limited" : row ? "ok" : "unchecked",
36087
+ status: rejected ? "rejected" : spendCap ? "spend_capped" : limited ? "rate_limited" : row ? "ok" : "unchecked",
35602
36088
  error: rejected ? scrubSecrets(row?.lastValidationError) || null : null,
35603
36089
  checkedAt: rejected ? row.lastValidationFailedAt : row?.updatedAt ?? null,
35604
- rateLimitedUntil: row?.rateLimitedUntil ?? null
36090
+ rateLimitedUntil: row?.rateLimitedUntil ?? null,
36091
+ spendCap
35605
36092
  };
35606
36093
  })
35607
36094
  };
@@ -36510,7 +36997,7 @@ var createRepo = route({
36510
36997
  201: { description: "Repo created", schema: SwarmRepoSchema },
36511
36998
  400: { description: "Validation error", schema: object2({ error: string2() }) },
36512
36999
  403: {
36513
- description: "Only the lead, the operator or a user can turn allowMerge on",
37000
+ description: "Only the lead, the operator or a user can turn allowMerge on or set a mergePolicy",
36514
37001
  schema: object2({ error: string2() })
36515
37002
  },
36516
37003
  409: { description: "Duplicate repo", schema: object2({ error: string2() }) }
@@ -36536,7 +37023,7 @@ var updateRepo = route({
36536
37023
  responses: {
36537
37024
  200: { description: "Repo updated", schema: SwarmRepoSchema },
36538
37025
  403: {
36539
- description: "Only the lead, the operator or a user can change allowMerge",
37026
+ description: "Only the lead, the operator or a user can change allowMerge or mergePolicy",
36540
37027
  schema: object2({ error: string2() })
36541
37028
  },
36542
37029
  404: { description: "Repo not found", schema: object2({ error: string2() }) },
@@ -36595,7 +37082,7 @@ async function handleRepos(req, res, pathSegments, queryParams, myAgentId) {
36595
37082
  const parsed = await createRepo.parse(req, res, pathSegments, queryParams);
36596
37083
  if (!parsed)
36597
37084
  return true;
36598
- if (changesAllowMerge(null, parsed.body.guidelines)) {
37085
+ if (changesMergePolicy(null, parsed.body.guidelines)) {
36599
37086
  const refusal = await allowMergeRefusal(req, myAgentId);
36600
37087
  if (refusal) {
36601
37088
  jsonError(res, refusal, 403);
@@ -40338,7 +40825,7 @@ var updateSchedule = route({
40338
40825
  responses: {
40339
40826
  200: { description: "Schedule updated", schema: ScheduledTaskSchema.nullable() },
40340
40827
  400: { description: "Validation error" },
40341
- 403: { description: "Deferral owned by another agent" },
40828
+ 403: { description: "Deferral or target owned by another agent" },
40342
40829
  404: { description: "Schedule not found" },
40343
40830
  409: { description: "Duplicate name" }
40344
40831
  }
@@ -40355,7 +40842,7 @@ var patchSchedule = route({
40355
40842
  responses: {
40356
40843
  200: { description: "Schedule patched", schema: ScheduledTaskSchema.nullable() },
40357
40844
  400: { description: "Validation error" },
40358
- 403: { description: "Deferral owned by another agent" },
40845
+ 403: { description: "Deferral or target owned by another agent" },
40359
40846
  404: { description: "Schedule not found" },
40360
40847
  409: { description: "Duplicate name" }
40361
40848
  },
@@ -40507,7 +40994,7 @@ async function handleSchedules(req, res, pathSegments, queryParams, myAgentId) {
40507
40994
  return true;
40508
40995
  }
40509
40996
  try {
40510
- const trustedUserId = await resolveHttpAuditUserId(req, myAgentId);
40997
+ const trustedUserId = await resolveHttpRequesterUserId(req, myAgentId);
40511
40998
  let key;
40512
40999
  try {
40513
41000
  key = body.key ? await authorizeAssetKeyWrite(body.key, trustedUserId) : undefined;
@@ -40557,7 +41044,8 @@ async function handleSchedules(req, res, pathSegments, queryParams, myAgentId) {
40557
41044
  params: body.params,
40558
41045
  requiredParams: body.requiredParams,
40559
41046
  requires: body.requires,
40560
- createdBy: await resolveHttpAuditUserId(req, myAgentId) ?? undefined
41047
+ createdByAgentId: myAgentId,
41048
+ createdBy: trustedUserId ?? undefined
40561
41049
  });
40562
41050
  createSchedule.respond(res, 201, schedule);
40563
41051
  } catch (error) {
@@ -40630,7 +41118,7 @@ async function handleSchedules(req, res, pathSegments, queryParams, myAgentId) {
40630
41118
  const body = parsed.body;
40631
41119
  if (parsed.body.key !== undefined) {
40632
41120
  try {
40633
- body.key = await authorizeAssetKeyWrite(parsed.body.key, await resolveHttpAuditUserId(req, myAgentId));
41121
+ body.key = await authorizeAssetKeyWrite(parsed.body.key, await resolveHttpRequesterUserId(req, myAgentId));
40634
41122
  } catch (error) {
40635
41123
  if (error instanceof AssetKeyAuthorizationError) {
40636
41124
  jsonError(res, error.message, error.statusCode);
@@ -40658,6 +41146,18 @@ async function handleSchedules(req, res, pathSegments, queryParams, myAgentId) {
40658
41146
  return true;
40659
41147
  }
40660
41148
  }
41149
+ if (changesScheduleTarget(existing, parsed.body)) {
41150
+ const principal = await agentFirstPrincipal(req, myAgentId);
41151
+ if (principal.kind === "agent" && !can({
41152
+ principal,
41153
+ verb: "schedule.target.update.any",
41154
+ resource: { kind: "owned", ownerAgentId: existing.createdByAgentId },
41155
+ source: "http"
41156
+ }).allow) {
41157
+ jsonError(res, `Schedule "${existing.name}" runs as the agent that created it. Only that agent or a lead can change its targetType, taskTemplate, workflowId, scriptName, scriptArgs or params.`, 403);
41158
+ return true;
41159
+ }
41160
+ }
40661
41161
  const agentChanged = parsed.body.targetAgentId !== undefined && parsed.body.targetAgentId !== existing.targetAgentId;
40662
41162
  const profileUpdate = await scheduleProfileUpdate(existing, parsed.body);
40663
41163
  if (profileUpdate.error !== undefined) {
@@ -40788,9 +41288,8 @@ async function handleSchedules(req, res, pathSegments, queryParams, myAgentId) {
40788
41288
  }
40789
41289
  }
40790
41290
  }
40791
- const updatedBy = await resolveHttpAuditUserId(req, myAgentId);
40792
- if (updatedBy !== null)
40793
- body.updatedBy = updatedBy;
41291
+ body.updatedBy = await resolveHttpAuditUserId(req, myAgentId);
41292
+ body.updatedByAgentId = myAgentId ?? null;
40794
41293
  let schedule;
40795
41294
  try {
40796
41295
  schedule = await updateScheduledTask2(parsed.params.id, body);
@@ -40989,6 +41488,7 @@ init_presets2();
40989
41488
  init_wrapper();
40990
41489
  init_credential_broker();
40991
41490
  init_telemetry();
41491
+ init_egress_guard();
40992
41492
  init_scoped_resource();
40993
41493
  init_secret_scrubber();
40994
41494
  init_route_def();
@@ -41996,7 +42496,7 @@ async function attemptRemoteRevocation(app, accessToken) {
41996
42496
  const controller = new AbortController;
41997
42497
  const timeout = setTimeout(() => controller.abort(), 5000);
41998
42498
  try {
41999
- await fetch(revocationUrl, {
42499
+ await createSsrfGuardedFetch(publicEndpointSsrfOptions())(revocationUrl, {
42000
42500
  method: "POST",
42001
42501
  headers,
42002
42502
  body: body.toString(),
@@ -42022,9 +42522,10 @@ function oauthDiscoveryUrls(inputUrl) {
42022
42522
  }
42023
42523
  async function fetchJsonMetadata(url, signal) {
42024
42524
  let current = assertUrlSafe(url, publicEndpointSsrfOptions());
42525
+ const guardedFetch = createSsrfGuardedFetch(publicEndpointSsrfOptions());
42025
42526
  let response = null;
42026
42527
  for (let hop = 0;hop <= 5; hop += 1) {
42027
- response = await fetch(current, {
42528
+ response = await guardedFetch(current, {
42028
42529
  headers: { accept: "application/json" },
42029
42530
  signal,
42030
42531
  redirect: "manual"
@@ -42096,7 +42597,7 @@ async function discoverOAuthApp(url) {
42096
42597
  function isUrlSafetyError(error) {
42097
42598
  if (!(error instanceof Error))
42098
42599
  return false;
42099
- return error.message.startsWith("Refusing ") || error.message.startsWith("Invalid URL:") || error.message.startsWith("Missing hostname:");
42600
+ return error instanceof EgressDeniedError || error.message.startsWith("Refusing ") || error.message.startsWith("Invalid URL:") || error.message.startsWith("Missing hostname:");
42100
42601
  }
42101
42602
  function stringFromCatalogEntry(entry, keys) {
42102
42603
  for (const key of keys) {
@@ -42697,7 +43198,7 @@ async function handleScriptConnections(req, res, pathSegments, queryParams, agen
42697
43198
  label,
42698
43199
  flow: "generic",
42699
43200
  ...parsed.body?.finalRedirect ? { finalRedirect: parsed.body.finalRedirect } : {},
42700
- userId: await resolveHttpAuditUserId(req, agentId)
43201
+ userId: await resolveHttpRequesterUserId(req, agentId)
42701
43202
  });
42702
43203
  authorizeUrlRoute2.respond(res, 200, {
42703
43204
  authorizeUrl: result.url,
@@ -42971,6 +43472,7 @@ init_constants3();
42971
43472
  init_secret_scrubber();
42972
43473
  init_raw_llm();
42973
43474
  init_route_def();
43475
+ init_task_requester();
42974
43476
  init_utils2();
42975
43477
  var DEFAULT_SCRIPT_RUN_CONCURRENCY_CAP = 10;
42976
43478
  var runIdParamsSchema = object2({ runId: string2().uuid() });
@@ -43306,6 +43808,7 @@ async function handleScriptRuns(req, res, pathSegments, queryParams, agentId) {
43306
43808
  }
43307
43809
  const cap = scriptRunConcurrencyCap();
43308
43810
  const sourceTaskId = await resolveRunSourceTaskId(req, agent.id);
43811
+ const requestedByUserId = parsed.body.requestedByUserId ? await resolveTaskRequester(req, agent.id, parsed.body.requestedByUserId) : undefined;
43309
43812
  const creation = await getDbClient2().transaction(async () => {
43310
43813
  if (await countActiveScriptRuns2() >= cap)
43311
43814
  return null;
@@ -43316,9 +43819,9 @@ async function handleScriptRuns(req, res, pathSegments, queryParams, agentId) {
43316
43819
  args: parsed.body.args ?? null,
43317
43820
  scriptName: parsed.body.scriptName,
43318
43821
  idempotencyKey: parsed.body.idempotencyKey,
43319
- requestedByUserId: parsed.body.requestedByUserId,
43822
+ requestedByUserId,
43320
43823
  sourceTaskId,
43321
- createdBy: parsed.body.requestedByUserId
43824
+ createdBy: requestedByUserId
43322
43825
  });
43323
43826
  });
43324
43827
  if (!creation) {
@@ -43540,6 +44043,7 @@ async function handleScriptRuns(req, res, pathSegments, queryParams, agentId) {
43540
44043
  return true;
43541
44044
  }
43542
44045
  const followUpThread = await followUpThreadForSourceTask(run.sourceTaskId);
44046
+ const stepRequester = parsed.body.requestedByUserId ? await resolveTaskRequester(req, agentId, parsed.body.requestedByUserId, null) : undefined;
43543
44047
  let dispatched;
43544
44048
  try {
43545
44049
  dispatched = await getDbClient2().transaction(async () => {
@@ -43590,7 +44094,7 @@ async function handleScriptRuns(req, res, pathSegments, queryParams, agentId) {
43590
44094
  vcsRepo: parsed.body.vcsRepo,
43591
44095
  model: parsed.body.model,
43592
44096
  parentTaskId: parsed.body.parentTaskId,
43593
- requestedByUserId: parsed.body.requestedByUserId ?? run.requestedByUserId,
44097
+ requestedByUserId: stepRequester ?? run.requestedByUserId,
43594
44098
  outputSchema: parsed.body.outputSchema,
43595
44099
  contextKey
43596
44100
  });
@@ -44191,6 +44695,7 @@ async function handleScripts(req, res, pathSegments, queryParams, agentId) {
44191
44695
  if (!agent)
44192
44696
  return true;
44193
44697
  const runtimeInstanceId = ((h) => Array.isArray(h) ? h[0] : h)(req.headers["x-runtime-instance-id"]);
44698
+ const sourceTaskId = ((h) => Array.isArray(h) ? h[0] : h)(req.headers["x-source-task-id"]);
44194
44699
  const secretRefusal = parsed.body.source ? refuseSourceWithSecrets(parsed.body.source) : null;
44195
44700
  if (secretRefusal) {
44196
44701
  json(res, secretRefusal, 400);
@@ -44231,6 +44736,7 @@ async function handleScripts(req, res, pathSegments, queryParams, agentId) {
44231
44736
  executor,
44232
44737
  agentId: agent.id,
44233
44738
  runtimeInstanceId,
44739
+ sourceTaskId,
44234
44740
  egressSecrets: credentials.egressSecrets,
44235
44741
  failedBindings: credentials.failedBindings,
44236
44742
  userConfig: credentials.userConfig,
@@ -44281,7 +44787,8 @@ async function handleScripts(req, res, pathSegments, queryParams, agentId) {
44281
44787
  agentId: agent.id,
44282
44788
  isScratch: true,
44283
44789
  typeChecked: false,
44284
- changeReason: "Auto-saved successful inline run"
44790
+ changeReason: "Auto-saved successful inline run",
44791
+ createdBy: await resolveHttpAuditUserId(req, agent.id)
44285
44792
  });
44286
44793
  autoSaved = { slug, reason: "successful_inline_run" };
44287
44794
  }
@@ -44362,6 +44869,9 @@ async function handleScripts(req, res, pathSegments, queryParams, agentId) {
44362
44869
  fsMode: script.fsMode,
44363
44870
  executor: script.executor,
44364
44871
  createdByAgentId: script.createdByAgentId,
44872
+ updatedByAgentId: script.updatedByAgentId,
44873
+ createdBy: script.createdBy,
44874
+ updatedBy: script.updatedBy,
44365
44875
  createdAt: script.createdAt,
44366
44876
  updatedAt: script.updatedAt
44367
44877
  }));
@@ -45177,6 +45687,7 @@ var SessionTreeResponseSchema = object2({
45177
45687
  labels: record2(string2(), string2()).optional(),
45178
45688
  groups: array2(SessionTreeGroupSchema),
45179
45689
  inbox: SessionSectionCountsSchema,
45690
+ working: SessionSectionCountsSchema.describe("Inbox sessions with a task running and nothing for the person to answer. They list under Working, not Inbox."),
45180
45691
  later: SessionSectionCountsSchema,
45181
45692
  done: SessionSectionCountsSchema,
45182
45693
  noGroup: SessionSectionCountsSchema,
@@ -45466,8 +45977,9 @@ var listSessions = route({
45466
45977
  contextKeyPrefix: string2().min(1).optional(),
45467
45978
  keyPrefix: SessionKeyFilterSchema.optional(),
45468
45979
  groupKey: SessionKeyFilterSchema.optional(),
45980
+ ids: string2().optional(),
45469
45981
  noGroup: _enum2(["true", "false"]).transform((v) => v === "true").optional(),
45470
- triage: _enum2(["inbox", "later", "done", "unread"]).optional(),
45982
+ triage: _enum2(["inbox", "working", "later", "done", "unread"]).optional(),
45471
45983
  status: _enum2(["running", "failed", "needs"]).optional(),
45472
45984
  withUserId: string2().min(1).optional(),
45473
45985
  fields: _enum2(["full", "slim"]).optional(),
@@ -45512,19 +46024,21 @@ var triageSessionListRoute = route({
45512
46024
  path: "/api/session-triage",
45513
46025
  pattern: ["api", "session-triage"],
45514
46026
  summary: "Triage every session of one sidebar list",
45515
- 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.",
46027
+ 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.",
45516
46028
  tags: ["Sessions"],
45517
46029
  body: object2({
45518
46030
  action: _enum2(["done", "inbox", "read", "unread"]),
45519
- triage: _enum2(["inbox", "later", "done"]).optional(),
46031
+ triage: _enum2(["inbox", "working", "later", "done"]).optional(),
45520
46032
  noGroup: boolean().optional(),
45521
46033
  groupKey: SessionKeyFilterSchema.optional(),
46034
+ keyPrefix: SessionKeyFilterSchema.refine((key) => sourceOfKey(key) !== null, {
46035
+ message: "keyPrefix must be a source group"
46036
+ }).optional(),
45522
46037
  show: SessionShowSchema,
45523
46038
  hideSource: array2(string2().min(1)).max(32).optional(),
45524
- showSource: array2(string2().min(1)).max(32).optional()
45525
- }).refine((body) => [body.triage, body.noGroup, body.groupKey].filter(Boolean).length === 1, {
45526
- message: "Name exactly one list: triage, noGroup, or groupKey"
45527
- }),
46039
+ showSource: array2(string2().min(1)).max(32).optional(),
46040
+ exceptIds: array2(string2().min(1)).max(500).optional()
46041
+ }).refine((body) => [body.triage, body.noGroup, body.groupKey, body.keyPrefix].filter(Boolean).length === 1, { message: "Name exactly one list: triage, noGroup, groupKey, or keyPrefix" }),
45528
46042
  responses: {
45529
46043
  200: {
45530
46044
  description: "The number of sessions written",
@@ -45586,7 +46100,7 @@ var moveSessionPrefix = route({
45586
46100
  });
45587
46101
  async function withSessionMove(req, res, myAgentId, destination, run) {
45588
46102
  try {
45589
- const changedBy = await resolveHttpAuditUserId(req, myAgentId);
46103
+ const changedBy = await resolveHttpRequesterUserId(req, myAgentId);
45590
46104
  const actor = await resolveSessionActor2(req, myAgentId);
45591
46105
  const key = destination === null ? null : await authorizeAssetKeyWrite(destination, changedBy);
45592
46106
  await assertAssetKeyMovesAllowed2();
@@ -45824,6 +46338,7 @@ async function handleSessions(req, res, pathSegments, queryParams, myAgentId) {
45824
46338
  contextKeyPrefix: parsed.query.contextKeyPrefix,
45825
46339
  keyPrefix: parsed.query.keyPrefix,
45826
46340
  groupKey: parsed.query.groupKey,
46341
+ rootIds: parsed.query.ids?.split(",").map((id) => id.trim()).filter(Boolean).slice(0, 200),
45827
46342
  noGroup: parsed.query.noGroup,
45828
46343
  triage: parsed.query.triage,
45829
46344
  status: parsed.query.status,
@@ -45884,8 +46399,8 @@ async function handleSessions(req, res, pathSegments, queryParams, myAgentId) {
45884
46399
  jsonError(res, "Pick a user to triage sessions", 400);
45885
46400
  return true;
45886
46401
  }
45887
- const { action, show, ...list } = parsed.body;
45888
- const updated = await triageSessionList(actor.userId, { ...list, mine: show !== "all" }, action, actor.readAll);
46402
+ const { action, show, exceptIds, ...list } = parsed.body;
46403
+ const updated = await triageSessionList(actor.userId, { ...list, exceptRootIds: exceptIds, mine: show !== "all" }, action, actor.readAll);
45889
46404
  triageSessionListRoute.respond(res, 200, { updated });
45890
46405
  return true;
45891
46406
  }
@@ -46103,6 +46618,7 @@ async function handleSessions(req, res, pathSegments, queryParams, myAgentId) {
46103
46618
 
46104
46619
  // src/http/skills.ts
46105
46620
  init_zod();
46621
+ init_audit_user();
46106
46622
  init_db4();
46107
46623
  init_skill_parser();
46108
46624
 
@@ -46922,7 +47438,9 @@ async function handleSkills(req, res, pathSegments, queryParams, myAgentId) {
46922
47438
  sourceRepo: parsed.body.sourceRepo,
46923
47439
  sourcePath: parsed.body.sourcePath,
46924
47440
  sourceBranch: branch,
46925
- isComplex: parsed.body.isComplex ?? false
47441
+ isComplex: parsed.body.isComplex ?? false,
47442
+ createdByAgentId: myAgentId ?? null,
47443
+ createdBy: await resolveHttpAuditUserId(req, myAgentId)
46926
47444
  });
46927
47445
  installRemoteRoute.respond(res, 201, { skill });
46928
47446
  } catch (err) {
@@ -46940,6 +47458,7 @@ async function handleSkills(req, res, pathSegments, queryParams, myAgentId) {
46940
47458
  })() : await listSkills2({ type: "remote" });
46941
47459
  let updated = 0;
46942
47460
  const errors = [];
47461
+ const actor = await resolveHttpAuditActor(req, myAgentId);
46943
47462
  for (const skill of remoteSkills) {
46944
47463
  if (skill.isComplex || !skill.sourceRepo)
46945
47464
  continue;
@@ -46968,7 +47487,9 @@ async function handleSkills(req, res, pathSegments, queryParams, myAgentId) {
46968
47487
  disableModelInvocation: pm.disableModelInvocation,
46969
47488
  userInvocable: pm.userInvocable,
46970
47489
  sourceHash: newHash,
46971
- lastFetchedAt: now
47490
+ lastFetchedAt: now,
47491
+ updatedBy: actor.userId,
47492
+ updatedByAgentId: actor.agentId
46972
47493
  });
46973
47494
  updated++;
46974
47495
  } else {
@@ -47085,6 +47606,7 @@ async function handleSkills(req, res, pathSegments, queryParams, myAgentId) {
47085
47606
  }
47086
47607
  try {
47087
47608
  const files = await upsertSkillFiles2(parsed.params.id, parsed.body.files);
47609
+ await setSkillUpdatedBy2(parsed.params.id, await resolveHttpAuditActor(req, myAgentId));
47088
47610
  const updatedSkill = await getSkillById2(parsed.params.id);
47089
47611
  bulkUpsertSkillFilesRoute.respond(res, 200, {
47090
47612
  files,
@@ -47135,6 +47657,7 @@ async function handleSkills(req, res, pathSegments, queryParams, myAgentId) {
47135
47657
  path: decodeSkillFilePath(pathSegments),
47136
47658
  ...parsed.body
47137
47659
  });
47660
+ await setSkillUpdatedBy2(parsed.params.id, await resolveHttpAuditActor(req, myAgentId));
47138
47661
  const updatedSkill = await getSkillById2(parsed.params.id);
47139
47662
  upsertSkillFileRoute.respond(res, 200, { file, skill: updatedSkill });
47140
47663
  } catch (err) {
@@ -47161,6 +47684,7 @@ async function handleSkills(req, res, pathSegments, queryParams, myAgentId) {
47161
47684
  jsonError(res, "Skill file not found", 404);
47162
47685
  return true;
47163
47686
  }
47687
+ await setSkillUpdatedBy2(parsed.params.id, await resolveHttpAuditActor(req, myAgentId));
47164
47688
  const updatedSkill = await getSkillById2(parsed.params.id);
47165
47689
  deleteSkillFileRoute.respond(res, 200, { success: true, skill: updatedSkill });
47166
47690
  } catch (err) {
@@ -47200,7 +47724,9 @@ async function handleSkills(req, res, pathSegments, queryParams, myAgentId) {
47200
47724
  agent: pm.agent,
47201
47725
  disableModelInvocation: pm.disableModelInvocation,
47202
47726
  userInvocable: pm.userInvocable,
47203
- systemDefault: parsed.body.systemDefault
47727
+ systemDefault: parsed.body.systemDefault,
47728
+ createdByAgentId: myAgentId ?? null,
47729
+ createdBy: await resolveHttpAuditUserId(req, myAgentId)
47204
47730
  });
47205
47731
  createSkillRoute.respond(res, 201, { skill });
47206
47732
  } catch (err) {
@@ -47259,6 +47785,9 @@ async function handleSkills(req, res, pathSegments, queryParams, myAgentId) {
47259
47785
  updates.disableModelInvocation = pm.disableModelInvocation;
47260
47786
  updates.userInvocable = pm.userInvocable;
47261
47787
  }
47788
+ const actor = await resolveHttpAuditActor(req, myAgentId);
47789
+ updates.updatedBy = actor.userId;
47790
+ updates.updatedByAgentId = actor.agentId;
47262
47791
  const skill = await updateSkill2(parsed.params.id, updates);
47263
47792
  if (!skill) {
47264
47793
  jsonError(res, "Skill not found", 404);
@@ -47959,11 +48488,27 @@ var toolHookRoute = route({
47959
48488
  400: { description: "Invalid body or missing X-Agent-ID header" }
47960
48489
  }
47961
48490
  });
48491
+ var toolHookStatusRoute = route({
48492
+ method: "get",
48493
+ path: "/api/tool-hooks/status",
48494
+ pattern: ["api", "tool-hooks", "status"],
48495
+ summary: "Whether any enabled extension takes harness-native tool calls",
48496
+ 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.",
48497
+ tags: ["Extensions"],
48498
+ auth: { apiKey: true },
48499
+ responses: {
48500
+ 200: { description: "Native tool hook status", schema: object2({ native: boolean() }) }
48501
+ }
48502
+ });
47962
48503
  function header4(req, name) {
47963
48504
  const raw = req.headers[name];
47964
48505
  return Array.isArray(raw) ? raw[0] : raw;
47965
48506
  }
47966
48507
  async function handleToolHooks(req, res, pathSegments, queryParams, myAgentId) {
48508
+ if (toolHookStatusRoute.match(req.method, pathSegments)) {
48509
+ toolHookStatusRoute.respond(res, 200, { native: hasNativeToolHandlers2() });
48510
+ return true;
48511
+ }
47967
48512
  if (!toolHookRoute.match(req.method, pathSegments))
47968
48513
  return false;
47969
48514
  if (!myAgentId) {
@@ -47974,11 +48519,13 @@ async function handleToolHooks(req, res, pathSegments, queryParams, myAgentId) {
47974
48519
  if (!parsed)
47975
48520
  return true;
47976
48521
  const body = scrubObject(parsed.body);
48522
+ const sourceTaskId = header4(req, "x-source-task-id");
47977
48523
  const requestInfo = {
47978
48524
  sessionId: undefined,
47979
48525
  agentId: myAgentId,
47980
48526
  runtimeInstanceId: header4(req, "x-runtime-instance-id"),
47981
- sourceTaskId: header4(req, "x-source-task-id"),
48527
+ sourceTaskId,
48528
+ auditSourceTaskId: sourceTaskId ?? header4(req, "x-audit-source-task-id"),
47982
48529
  contextKey: header4(req, "x-context-key"),
47983
48530
  callOrigin: "native",
47984
48531
  harness: body.harness
@@ -48043,7 +48590,7 @@ async function ensureTrackerAuthorizeAdmin(req, res, providerName) {
48043
48590
  const allowed = await ensureHttpPermission(req, res, "oauth-authorization.manage", `Only the lead can start the ${providerName} OAuth flow.`, agentId);
48044
48591
  if (!allowed)
48045
48592
  return null;
48046
- return { userId: await resolveHttpAuditUserId(req, agentId) };
48593
+ return { userId: await resolveHttpRequesterUserId(req, agentId) };
48047
48594
  }
48048
48595
 
48049
48596
  // src/http/trackers/jira.ts
@@ -48906,6 +49453,7 @@ async function handleUserRoles(req, res, pathSegments, queryParams) {
48906
49453
  init_zod();
48907
49454
  init_db4();
48908
49455
  init_rbac_roles();
49456
+ init_unmapped_identities();
48909
49457
  init_users();
48910
49458
  init_rbac();
48911
49459
  init_types5();
@@ -48974,7 +49522,12 @@ var UnmappedIdentitySchema = object2({
48974
49522
  lastSeenAt: string2().nullable(),
48975
49523
  count: number2(),
48976
49524
  sampleEventType: string2().nullable(),
48977
- sampleContext: unknown().nullable()
49525
+ sampleContext: unknown().nullable(),
49526
+ dismissedAt: string2().optional(),
49527
+ dismissedBy: string2().optional()
49528
+ });
49529
+ var UnmappedIdentityRefsSchema = object2({
49530
+ identities: array2(object2({ kind: string2().min(1), externalId: string2().min(1) })).min(1).max(500)
48978
49531
  });
48979
49532
  var whoamiRoute = route({
48980
49533
  method: "get",
@@ -49056,7 +49609,9 @@ var listUnmapped = route({
49056
49609
  tags: ["Users"],
49057
49610
  query: object2({
49058
49611
  kind: string2().optional(),
49059
- limit: exports_coerce.number().int().min(1).max(1000).optional()
49612
+ limit: exports_coerce.number().int().min(1).max(1000).optional(),
49613
+ dismissed: _enum2(["true", "false"]).optional(),
49614
+ includeBots: _enum2(["true", "false"]).optional()
49060
49615
  }),
49061
49616
  responses: {
49062
49617
  200: {
@@ -49096,6 +49651,45 @@ var resolveUnmapped = route({
49096
49651
  },
49097
49652
  auth: { apiKey: true }
49098
49653
  });
49654
+ var DISMISS_RBAC = {
49655
+ ungated: "same posture as POST /api/users/unmapped/{kind}/{externalId}/resolve: bearer auth, guests rejected; it links and trusts nothing"
49656
+ };
49657
+ var dismissUnmapped = route({
49658
+ method: "post",
49659
+ path: "/api/users/unmapped/dismiss",
49660
+ pattern: ["api", "users", "unmapped", "dismiss"],
49661
+ summary: "Dismiss unmapped identities: hide them from triage and stop recording them. Links nothing.",
49662
+ tags: ["Users"],
49663
+ body: UnmappedIdentityRefsSchema,
49664
+ responses: {
49665
+ 200: {
49666
+ description: "Identities moved to the ignore list",
49667
+ schema: object2({ dismissed: number2() })
49668
+ },
49669
+ 400: { description: "Validation error" },
49670
+ 401: { description: "Unauthorized" }
49671
+ },
49672
+ auth: { apiKey: true },
49673
+ rbac: DISMISS_RBAC
49674
+ });
49675
+ var restoreUnmapped = route({
49676
+ method: "post",
49677
+ path: "/api/users/unmapped/restore",
49678
+ pattern: ["api", "users", "unmapped", "restore"],
49679
+ summary: "Undo a dismissal: return identities to the triage queue",
49680
+ tags: ["Users"],
49681
+ body: UnmappedIdentityRefsSchema,
49682
+ responses: {
49683
+ 200: {
49684
+ description: "Count of identities taken off the ignore list",
49685
+ schema: object2({ restored: number2() })
49686
+ },
49687
+ 400: { description: "Validation error" },
49688
+ 401: { description: "Unauthorized" }
49689
+ },
49690
+ auth: { apiKey: true },
49691
+ rbac: DISMISS_RBAC
49692
+ });
49099
49693
  var getUserRoute = route({
49100
49694
  method: "get",
49101
49695
  path: "/api/users/{id}",
@@ -49538,6 +50132,30 @@ async function collectUnmappedForKind(kind, limit) {
49538
50132
  }
49539
50133
  return Array.from(byId.values());
49540
50134
  }
50135
+ async function collectDismissedForKind(kind, limit) {
50136
+ const rows = await listKv2(dismissedNamespace(kind), { limit, offset: 0 });
50137
+ return rows.map((row) => {
50138
+ const saved = row.value ?? {};
50139
+ const meta = saved.meta ?? {};
50140
+ return {
50141
+ kind,
50142
+ externalId: row.key,
50143
+ lastSeenAt: typeof meta.lastSeenAt === "string" ? meta.lastSeenAt : null,
50144
+ count: Number(saved.count ?? 0),
50145
+ sampleEventType: typeof meta.sampleEventType === "string" ? meta.sampleEventType : null,
50146
+ sampleContext: meta.sampleContext ?? null,
50147
+ dismissedAt: saved.dismissedAt,
50148
+ dismissedBy: saved.dismissedBy
50149
+ };
50150
+ });
50151
+ }
50152
+ function uniqueIdentities(identities) {
50153
+ const seen = new Map;
50154
+ for (const identity of identities) {
50155
+ seen.set(`${identity.kind}\x00${identity.externalId}`, identity);
50156
+ }
50157
+ return [...seen.values()];
50158
+ }
49541
50159
  var DEFAULT_CONNECTOR_CONNECT_URL = "https://mcp.agent-swarm.dev/connections";
49542
50160
  function getConnectorConnectUrl() {
49543
50161
  const raw = process.env.CONNECTOR_CONNECT_URL?.trim() || DEFAULT_CONNECTOR_CONNECT_URL;
@@ -49662,7 +50280,10 @@ async function handleUsers(req, res, pathSegments, queryParams) {
49662
50280
  return true;
49663
50281
  const limit = parsed.query.limit ?? 100;
49664
50282
  const kinds = parsed.query.kind ? [parsed.query.kind] : UNMAPPED_KINDS;
49665
- const rows = (await Promise.all(kinds.map((k) => collectUnmappedForKind(k, limit)))).flat();
50283
+ const collect = parsed.query.dismissed === "true" ? collectDismissedForKind : collectUnmappedForKind;
50284
+ const includeBots = parsed.query.includeBots === "true";
50285
+ 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}`));
50286
+ 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}`));
49666
50287
  rows.sort((a, b) => {
49667
50288
  if (b.count !== a.count)
49668
50289
  return b.count - a.count;
@@ -49673,6 +50294,34 @@ async function handleUsers(req, res, pathSegments, queryParams) {
49673
50294
  listUnmapped.respond(res, 200, { unmapped: rows.slice(0, limit) });
49674
50295
  return true;
49675
50296
  }
50297
+ if (dismissUnmapped.match(req.method, pathSegments)) {
50298
+ const parsed = await dismissUnmapped.parse(req, res, pathSegments, queryParams);
50299
+ if (!parsed)
50300
+ return true;
50301
+ const actor = getOperatorActor(req, res);
50302
+ if (!actor)
50303
+ return true;
50304
+ const identities = uniqueIdentities(parsed.body.identities);
50305
+ for (const { kind, externalId } of identities) {
50306
+ await dismissUnmappedIdentity(kind, externalId, `${actor.kind}:${actor.id}`);
50307
+ }
50308
+ dismissUnmapped.respond(res, 200, { dismissed: identities.length });
50309
+ return true;
50310
+ }
50311
+ if (restoreUnmapped.match(req.method, pathSegments)) {
50312
+ const parsed = await restoreUnmapped.parse(req, res, pathSegments, queryParams);
50313
+ if (!parsed)
50314
+ return true;
50315
+ if (!getOperatorActor(req, res))
50316
+ return true;
50317
+ let restored = 0;
50318
+ for (const { kind, externalId } of uniqueIdentities(parsed.body.identities)) {
50319
+ if (await restoreUnmappedIdentity(kind, externalId))
50320
+ restored++;
50321
+ }
50322
+ restoreUnmapped.respond(res, 200, { restored });
50323
+ return true;
50324
+ }
49676
50325
  if (resolveUnmapped.match(req.method, pathSegments)) {
49677
50326
  const parsed = await resolveUnmapped.parse(req, res, pathSegments, queryParams);
49678
50327
  if (!parsed)
@@ -51342,6 +51991,7 @@ async function handleWebhooks(req, res, pathSegments) {
51342
51991
  // src/http/workflow-events.ts
51343
51992
  init_zod();
51344
51993
  init_db4();
51994
+ init_event_waits();
51345
51995
  init_event_bus();
51346
51996
  init_route_def();
51347
51997
  init_utils2();
@@ -51367,6 +52017,7 @@ var runScopedSignalRoute = route({
51367
52017
  })
51368
52018
  },
51369
52019
  404: { description: "Workflow run not found" },
52020
+ 403: { description: "Event name is reserved for provider webhooks" },
51370
52021
  400: { description: "Validation error" }
51371
52022
  },
51372
52023
  auth: { apiKey: true }
@@ -51390,15 +52041,21 @@ var globalSignalRoute = route({
51390
52041
  name: string2()
51391
52042
  })
51392
52043
  },
52044
+ 403: { description: "Event name is reserved for provider webhooks" },
51393
52045
  400: { description: "Validation error" }
51394
52046
  },
51395
52047
  auth: { apiKey: true }
51396
52048
  });
52049
+ var RESERVED_EVENT_MESSAGE = "Event name is reserved for provider webhooks";
51397
52050
  async function handleWorkflowEvents(req, res, pathSegments, queryParams) {
51398
52051
  if (runScopedSignalRoute.match(req.method, pathSegments)) {
51399
52052
  const parsed = await runScopedSignalRoute.parse(req, res, pathSegments, queryParams);
51400
52053
  if (!parsed)
51401
52054
  return true;
52055
+ if (isReservedProviderEvent(parsed.body.name)) {
52056
+ jsonError(res, RESERVED_EVENT_MESSAGE, 403);
52057
+ return true;
52058
+ }
51402
52059
  const run = await getWorkflowRun2(parsed.params.runId);
51403
52060
  if (!run) {
51404
52061
  jsonError(res, "Workflow run not found", 404);
@@ -51417,6 +52074,10 @@ async function handleWorkflowEvents(req, res, pathSegments, queryParams) {
51417
52074
  const parsed = await globalSignalRoute.parse(req, res, pathSegments, queryParams);
51418
52075
  if (!parsed)
51419
52076
  return true;
52077
+ if (isReservedProviderEvent(parsed.body.name)) {
52078
+ jsonError(res, RESERVED_EVENT_MESSAGE, 403);
52079
+ return true;
52080
+ }
51420
52081
  workflowEventBus2.emit(parsed.body.name, parsed.body.payload ?? {});
51421
52082
  globalSignalRoute.respond(res, 200, { ok: true, name: parsed.body.name });
51422
52083
  return true;
@@ -51994,12 +52655,12 @@ async function handleWorkflows(req, res, pathSegments, queryParams, myAgentId) {
51994
52655
  jsonError(res, `Invalid definition: ${modelErrors.join("; ")}`, 400);
51995
52656
  return true;
51996
52657
  }
51997
- const refKeys = serverRefInputKeys(parsed.body.input);
52658
+ const refKeys = serverRefInputKeys(parsed.body.input, parsed.body.params);
51998
52659
  if (refKeys.length > 0 && await requestSecretReadScope(req) !== "all") {
51999
52660
  jsonError(res, serverRefInputDeniedMessage(refKeys), 403);
52000
52661
  return true;
52001
52662
  }
52002
- const trustedUserId = await resolveHttpAuditUserId(req, myAgentId);
52663
+ const trustedUserId = await resolveHttpRequesterUserId(req, myAgentId);
52003
52664
  let key;
52004
52665
  try {
52005
52666
  key = parsed.body.key ? await authorizeAssetKeyWrite(parsed.body.key, trustedUserId) : undefined;
@@ -52119,7 +52780,7 @@ async function handleWorkflows(req, res, pathSegments, queryParams, myAgentId) {
52119
52780
  const updateArgs = {};
52120
52781
  if (parsed.body.key !== undefined) {
52121
52782
  try {
52122
- updateArgs.key = await authorizeAssetKeyWrite(parsed.body.key, updatedBy1);
52783
+ updateArgs.key = await authorizeAssetKeyWrite(parsed.body.key, await resolveHttpRequesterUserId(req, myAgentId));
52123
52784
  } catch (error) {
52124
52785
  if (error instanceof AssetKeyAuthorizationError) {
52125
52786
  jsonError(res, error.message, error.statusCode);
@@ -52198,7 +52859,7 @@ async function handleWorkflows(req, res, pathSegments, queryParams, myAgentId) {
52198
52859
  return true;
52199
52860
  }
52200
52861
  }
52201
- const refKeys = serverRefInputKeys(body.input !== undefined ? body.input : body.definition ? existing.input : undefined);
52862
+ 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) : [];
52202
52863
  if (refKeys.length > 0 && await requestSecretReadScope(req) !== "all") {
52203
52864
  jsonError(res, serverRefInputDeniedMessage(refKeys), 403);
52204
52865
  return true;
@@ -52207,7 +52868,7 @@ async function handleWorkflows(req, res, pathSegments, queryParams, myAgentId) {
52207
52868
  let key;
52208
52869
  if (body.key !== undefined) {
52209
52870
  try {
52210
- key = await authorizeAssetKeyWrite(body.key, updatedBy2);
52871
+ key = await authorizeAssetKeyWrite(body.key, await resolveHttpRequesterUserId(req, myAgentId));
52211
52872
  } catch (error) {
52212
52873
  if (error instanceof AssetKeyAuthorizationError) {
52213
52874
  jsonError(res, error.message, error.statusCode);
@@ -52317,7 +52978,7 @@ async function handleWorkflows(req, res, pathSegments, queryParams, myAgentId) {
52317
52978
  runId = await startWorkflowExecution2(workflow, body, getExecutorRegistry2(), {
52318
52979
  triggerType: "api",
52319
52980
  triggeredByAgentId: myAgentId,
52320
- requestedByUserId: await resolveHttpAuditUserId(req, myAgentId) ?? undefined,
52981
+ requestedByUserId: await resolveHttpRequesterUserId(req, myAgentId) ?? undefined,
52321
52982
  detach: parsed.query.wait === "false",
52322
52983
  accept: claim ? async (run) => {
52323
52984
  const response = { runId: run.runId, skipped: run.skipped };
@@ -52761,6 +53422,7 @@ var httpServer = createHttpServer(async (req, res) => {
52761
53422
  () => handleTrackers(req, res, pathSegments),
52762
53423
  () => handleWebhooks(req, res, pathSegments),
52763
53424
  () => handleObjectWebhooks(req, res, pathSegments),
53425
+ () => handleObjects(req, res, pathSegments, queryParams, myAgentId),
52764
53426
  () => handleAgentLifecycle(req, res, pathSegments, queryParams, myAgentId),
52765
53427
  () => handleAgentsRest(req, res, pathSegments, queryParams, myAgentId),
52766
53428
  () => handleBudgets(req, res, pathSegments, queryParams, myAgentId),
@@ -52862,7 +53524,7 @@ var httpServer = createHttpServer(async (req, res) => {
52862
53524
  });
52863
53525
  });
52864
53526
  var detachRealtime = attachRealtimeTransport(httpServer);
52865
- var { attachControllerTransport } = await import("./controllers-connect-zn4dg69h.js");
53527
+ var { attachControllerTransport } = await import("./controllers-connect-34jzhfft.js");
52866
53528
  var detachControllers = attachControllerTransport(httpServer);
52867
53529
  var stopWorkerNudges = startWorkerNudgeListener();
52868
53530
  var taskAutoTitles = startTaskAutoTitleListener();
@@ -52893,7 +53555,7 @@ async function shutdown() {
52893
53555
  sessionsProcessed: getServerSessionsProcessed()
52894
53556
  });
52895
53557
  if (hasCapability("scheduling")) {
52896
- const { stopScheduler } = await import("./index-23cdfzr6.js");
53558
+ const { stopScheduler } = await import("./index-np0582ac.js");
52897
53559
  stopScheduler();
52898
53560
  }
52899
53561
  stopHeartbeat2();
@@ -52905,7 +53567,7 @@ async function shutdown() {
52905
53567
  await stopSlackApp2();
52906
53568
  await stopChatSdk();
52907
53569
  if (!isEnvFlagEnabled("OAUTH_KEEPALIVE_DISABLE", false)) {
52908
- const { stopOAuthKeepalive } = await import("./keepalive-031js8jz.js");
53570
+ const { stopOAuthKeepalive } = await import("./keepalive-2v06q2e8.js");
52909
53571
  await stopOAuthKeepalive();
52910
53572
  }
52911
53573
  stopOAuthPendingGc();
@@ -52995,21 +53657,21 @@ try {
52995
53657
  console.warn("[startup] CAPABILITIES upgrade seed failed (non-fatal):", err);
52996
53658
  }
52997
53659
  try {
52998
- const { ensurePricingSeeded } = await import("./boot-seeds-arrkbe8t.js");
53660
+ const { ensurePricingSeeded } = await import("./boot-seeds-9cwy39jx.js");
52999
53661
  ensurePricingSeeded();
53000
- const { startPricingRefreshLoop } = await import("./pricing-refresh-9w7gx41w.js");
53662
+ const { startPricingRefreshLoop } = await import("./pricing-refresh-ytjmtyd7.js");
53001
53663
  startPricingRefreshLoop();
53002
53664
  } catch (err) {
53003
53665
  console.error("[startup] Failed to seed pricing rows:", err);
53004
53666
  }
53005
53667
  try {
53006
- const { ensureModelProfilesSeeded } = await import("./boot-seeds-arrkbe8t.js");
53668
+ const { ensureModelProfilesSeeded } = await import("./boot-seeds-9cwy39jx.js");
53007
53669
  await ensureModelProfilesSeeded();
53008
53670
  } catch (err) {
53009
53671
  console.error("[startup] Failed to seed model profiles:", err);
53010
53672
  }
53011
53673
  try {
53012
- const { ensureRbacSeeded } = await import("./boot-seeds-arrkbe8t.js");
53674
+ const { ensureRbacSeeded } = await import("./boot-seeds-9cwy39jx.js");
53013
53675
  ensureRbacSeeded();
53014
53676
  } catch (err) {
53015
53677
  console.error("[startup] Failed to sync RBAC seed rows:", err);
@@ -53017,13 +53679,13 @@ try {
53017
53679
  throw err;
53018
53680
  }
53019
53681
  try {
53020
- const { runAllSeeders } = await import("./index-fbkqhvvj.js");
53682
+ const { runAllSeeders } = await import("./index-ffba0z8q.js");
53021
53683
  await runAllSeeders({ scriptEmbeddingMode: "skip" });
53022
53684
  } catch (err) {
53023
53685
  console.error("[startup] Failed to seed built-in entities:", err);
53024
53686
  }
53025
53687
  try {
53026
- const { runImports } = await import("./index-kn63q1gr.js");
53688
+ const { runImports } = await import("./index-pb03vans.js");
53027
53689
  await runImports();
53028
53690
  } catch (err) {
53029
53691
  console.error("[startup] File import failed:", scrubSecrets(err instanceof Error ? err.message : String(err)));
@@ -53074,10 +53736,10 @@ httpServer.listen(port, async () => {
53074
53736
  startChatSdk().catch((err) => {
53075
53737
  console.error("[chat-sdk] Failed to start, continuing without Chat SDK:", scrubSecrets(err instanceof Error ? err.message : String(err)));
53076
53738
  });
53077
- import("./agent-fs-provision-0b9awm5n.js").then(({ syncAgentFsOrgSwarmUrl }) => syncAgentFsOrgSwarmUrl(getConfiguredAppUrls()[0])).catch((err) => {
53739
+ import("./agent-fs-provision-y0qc1rdd.js").then(({ syncAgentFsOrgSwarmUrl }) => syncAgentFsOrgSwarmUrl(getConfiguredAppUrls()[0])).catch((err) => {
53078
53740
  console.warn("[agent-fs] Failed to set the org swarm URL:", scrubSecrets(err instanceof Error ? err.message : String(err)));
53079
53741
  });
53080
- import("./object-webhooks-r24wwb5y.js").then(({ ensureObjectWebhooksForKnownDrives }) => ensureObjectWebhooksForKnownDrives()).catch((err) => {
53742
+ import("./object-webhooks-3dzdq4fm.js").then(({ ensureObjectWebhooksForKnownDrives }) => ensureObjectWebhooksForKnownDrives()).catch((err) => {
53081
53743
  console.warn("[objects] agent-fs webhook boot check failed:", scrubSecrets(err instanceof Error ? err.message : String(err)));
53082
53744
  });
53083
53745
  startQueueStallAlarm();
@@ -53093,25 +53755,25 @@ httpServer.listen(port, async () => {
53093
53755
  await initWorkflows2();
53094
53756
  await startScriptRunSupervisor(getMcpBaseUrl());
53095
53757
  if (hasCapability("scheduling")) {
53096
- const { startScheduler } = await import("./index-23cdfzr6.js");
53097
- const { getExecutorRegistry } = await import("./index-stk36pa5.js");
53758
+ const { startScheduler } = await import("./index-np0582ac.js");
53759
+ const { getExecutorRegistry } = await import("./index-22khdtby.js");
53098
53760
  const intervalMs = Number(process.env.SCHEDULER_INTERVAL_MS) || 1e4;
53099
53761
  startScheduler(getExecutorRegistry(), intervalMs, {
53100
53762
  runId: globalState.__runId
53101
53763
  });
53102
53764
  }
53103
53765
  if (!isEnvFlagEnabled("HEARTBEAT_DISABLE", false)) {
53104
- const { parseHeartbeatIntervalMs, startHeartbeat } = await import("./index-g7kkjs5b.js");
53766
+ const { parseHeartbeatIntervalMs, startHeartbeat } = await import("./index-vgkrj1jt.js");
53105
53767
  startHeartbeat(parseHeartbeatIntervalMs(process.env.HEARTBEAT_INTERVAL_MS));
53106
53768
  }
53107
53769
  startPoolRouting();
53108
53770
  startRuntimeSupervisor();
53109
53771
  if (!isEnvFlagEnabled("OAUTH_KEEPALIVE_DISABLE", false)) {
53110
- const { startOAuthKeepalive } = await import("./keepalive-031js8jz.js");
53772
+ const { startOAuthKeepalive } = await import("./keepalive-2v06q2e8.js");
53111
53773
  startOAuthKeepalive();
53112
53774
  }
53113
53775
  if (!isEnvFlagEnabled("OAUTH_REFRESH_SWEEP_DISABLE", false)) {
53114
- const { startOAuthRefreshSweep } = await import("./oauth-refresh-sweep-zqmnyvs8.js");
53776
+ const { startOAuthRefreshSweep } = await import("./oauth-refresh-sweep-g06k4bza.js");
53115
53777
  startOAuthRefreshSweep();
53116
53778
  }
53117
53779
  startOAuthPendingGc();
@@ -53121,22 +53783,22 @@ httpServer.listen(port, async () => {
53121
53783
  startSavingsRollup(savingsRollupSql);
53122
53784
  startHumanFreeDrain();
53123
53785
  startTaskSearchBackfill();
53124
- import("./embedding-space-kcdn52vz.js").then(({ runEmbeddingMaintenance, setDeploymentEnvReader }) => {
53786
+ import("./embedding-space-v06fwy7b.js").then(({ runEmbeddingMaintenance, setDeploymentEnvReader }) => {
53125
53787
  setDeploymentEnvReader(getDeploymentEnvValue2);
53126
53788
  return runEmbeddingMaintenance({ backfill: true });
53127
53789
  }).catch((err) => {
53128
53790
  console.error("[embedding-space] startup maintenance failed (non-fatal):", err);
53129
53791
  });
53130
- import("./boot-args-schema-hce1av1h.js").then(({ runBootArgsSchemaBackfill }) => runBootArgsSchemaBackfill()).catch((err) => {
53792
+ import("./boot-args-schema-8025snev.js").then(({ runBootArgsSchemaBackfill }) => runBootArgsSchemaBackfill()).catch((err) => {
53131
53793
  console.error("[boot-args-schema] startup backfill failed (non-fatal):", err);
53132
53794
  });
53133
- import("./boot-scrub-sweep-mkmm16gk.js").then(({ runBootScrubSweep }) => runBootScrubSweep()).catch((err) => {
53795
+ import("./boot-scrub-sweep-eajr97e9.js").then(({ runBootScrubSweep }) => runBootScrubSweep()).catch((err) => {
53134
53796
  console.error("[boot-scrub-sweep] startup scrub failed (non-fatal):", err);
53135
53797
  });
53136
- import("./user-merge-jobs-f9d8nwnw.js").then(({ resumeUserMergeJobs }) => resumeUserMergeJobs()).catch((err) => {
53798
+ import("./user-merge-jobs-96vg9rpe.js").then(({ resumeUserMergeJobs }) => resumeUserMergeJobs()).catch((err) => {
53137
53799
  console.error("[user-merge] startup resume failed (non-fatal):", err);
53138
53800
  });
53139
- import("./session-source-backfill-r5j988ah.js").then(({ runSessionSourceBackfill }) => runSessionSourceBackfill()).catch((err) => {
53801
+ import("./session-source-backfill-p73e8zbe.js").then(({ runSessionSourceBackfill }) => runSessionSourceBackfill()).catch((err) => {
53140
53802
  console.error("[session-source-backfill] startup run failed (non-fatal):", err);
53141
53803
  });
53142
53804
  }).on("error", (err) => {