@desplega.ai/agent-swarm 2.3.0 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (332) hide show
  1. package/README.md +1 -0
  2. package/dist/{acp-adapter-v85a2bqy.js → acp-adapter-zvzr538d.js} +9 -9
  3. package/dist/{actions-zgcxfspj.js → actions-jhtqdw69.js} +21 -19
  4. package/dist/{amp-adapter-jw9xfz42.js → amp-adapter-bd84rhs2.js} +4 -4
  5. package/dist/{app-4e1s4675.js → app-kreq1gwg.js} +3 -3
  6. package/dist/{assistant-v238n9dk.js → assistant-3k22sbsq.js} +23 -21
  7. package/dist/{boot-reembed-p666cw5n.js → boot-reembed-e53x6b9v.js} +1 -1
  8. package/dist/{boot-reembed-w6pm64j4.js → boot-reembed-f6z923ny.js} +1 -1
  9. package/dist/{boot-scrub-sweep-jcyjagn3.js → boot-scrub-sweep-0538vsb7.js} +4 -4
  10. package/dist/{boot-seeds-gbedmamp.js → boot-seeds-6wxqkfk2.js} +4 -4
  11. package/dist/{claude-adapter-q7wspzt8.js → claude-adapter-gfts5044.js} +9 -9
  12. package/dist/{claude-managed-adapter-n7ahjyx6.js → claude-managed-adapter-h2y889ge.js} +3 -3
  13. package/dist/{claude-managed-setup-wza784fb.js → claude-managed-setup-h00hsgtz.js} +2 -2
  14. package/dist/{claude-sdk-session-yf400ptr.js → claude-sdk-session-56besmfz.js} +13 -13
  15. package/dist/{cli-65q70v2v.js → cli-0bh477zn.js} +33 -6
  16. package/dist/{cli-4ync7m60.js → cli-0ebey9hg.js} +1 -1
  17. package/dist/{cli-665j3feb.js → cli-0xk505e8.js} +1 -1
  18. package/dist/{cli-7gh7020n.js → cli-1dmcq2eh.js} +1 -1
  19. package/dist/{cli-gzvb3d4a.js → cli-1jx0srjt.js} +3 -3
  20. package/dist/{cli-zj4d6afs.js → cli-1pa3rz69.js} +21 -6
  21. package/dist/{cli-7ayprxp7.js → cli-2dfbv8qr.js} +8 -0
  22. package/dist/{cli-30m5q8mc.js → cli-3kh4kpqy.js} +6 -6
  23. package/dist/{cli-qrwp40st.js → cli-3p8fqcnh.js} +2 -2
  24. package/dist/{cli-y3dvz6ge.js → cli-3r448dqn.js} +3 -3
  25. package/dist/{cli-a17tzmn0.js → cli-3tnpj2bh.js} +7 -7
  26. package/dist/{cli-ea7chd26.js → cli-471qk6s2.js} +93 -46
  27. package/dist/{cli-a49vpbf3.js → cli-5kqnemen.js} +1 -1
  28. package/dist/{cli-0rh20bp3.js → cli-6ncjvx55.js} +3 -3
  29. package/dist/{cli-fb6t92v8.js → cli-6x9ma5w5.js} +1 -1
  30. package/dist/{cli-k28p6xh7.js → cli-7225gwj7.js} +2 -2
  31. package/dist/{cli-8cvvytad.js → cli-8nyhf7za.js} +3 -3
  32. package/dist/{cli-e09hj50q.js → cli-8wkb09q5.js} +11 -11
  33. package/dist/{cli-j0v75y13.js → cli-a0kcty51.js} +4 -4
  34. package/dist/{cli-zes4tsbb.js → cli-a4gvwttf.js} +4 -4
  35. package/dist/{cli-jhp7w1fy.js → cli-a5ebc95n.js} +2 -2
  36. package/dist/{cli-5d1m1qca.js → cli-ash6xxk7.js} +2 -2
  37. package/dist/{cli-fp4xbw07.js → cli-axh29tyr.js} +14 -12
  38. package/dist/{cli-p22zdvnt.js → cli-bn0rewsy.js} +3 -3
  39. package/dist/{cli-hz64bcnj.js → cli-bn5kevnf.js} +11 -373
  40. package/dist/{cli-8jtrekpy.js → cli-d2mb5s8a.js} +7 -7
  41. package/dist/{cli-c5sbmw1v.js → cli-d82btycs.js} +94 -15
  42. package/dist/{cli-vjfpshn3.js → cli-ejs3m1sx.js} +1 -1
  43. package/dist/{cli-yv0vgscc.js → cli-fpmsqq59.js} +18 -2
  44. package/dist/cli-fz9kewbh.js +382 -0
  45. package/dist/{cli-4s1kqrqg.js → cli-g0hgtz4p.js} +6 -6
  46. package/dist/{cli-hn3pftj2.js → cli-gf0kfg81.js} +7 -7
  47. package/dist/{cli-d43xqzbe.js → cli-hqhzg1qq.js} +2 -2
  48. package/dist/{cli-azs9bhc5.js → cli-j4rqdf2n.js} +2 -2
  49. package/dist/{cli-wtg6edvd.js → cli-jh0qcrga.js} +1 -1
  50. package/dist/{cli-kqypty34.js → cli-k9z4zd4p.js} +6 -5
  51. package/dist/{cli-jhmjwqcg.js → cli-kmqgmcnb.js} +47 -14
  52. package/dist/{cli-8qsx817b.js → cli-kr2pmfqx.js} +583 -769
  53. package/dist/{cli-4g629sgr.js → cli-m2qgh5sv.js} +20 -1
  54. package/dist/{cli-9e9kjqsj.js → cli-mfe7f7b5.js} +2 -2
  55. package/dist/{cli-x3en6ct3.js → cli-nwyw3zhg.js} +1 -1
  56. package/dist/{cli-6vcyw6v7.js → cli-nx462e4v.js} +5 -3
  57. package/dist/{cli-tr24eeny.js → cli-p0rakbrk.js} +9 -9
  58. package/dist/{cli-4hmaheb6.js → cli-p6argxh9.js} +9 -9
  59. package/dist/{cli-3avfh5az.js → cli-pemywhfq.js} +2 -2
  60. package/dist/{cli-etvn5ej2.js → cli-pnp2j5zg.js} +2 -2
  61. package/dist/{cli-wk8ccrz6.js → cli-pw7v69vp.js} +2 -2
  62. package/dist/{cli-ka01m5rb.js → cli-rdq7tzwm.js} +17 -14
  63. package/dist/{cli-re4wkbzx.js → cli-rqqsfz30.js} +677 -104
  64. package/dist/{cli-xgn4rwyv.js → cli-s48yvzb8.js} +4 -4
  65. package/dist/{cli-zv4vy2b0.js → cli-s95dknxh.js} +1 -1
  66. package/dist/{cli-g6p7c2my.js → cli-sjyetj21.js} +2 -2
  67. package/dist/{cli-rdr166ht.js → cli-smvcw9z5.js} +1 -1
  68. package/dist/{cli-fhvqt2fp.js → cli-sv5gb0yb.js} +1 -1
  69. package/dist/{cli-yv3n83x8.js → cli-syhq378v.js} +2 -2
  70. package/dist/{cli-q1812jbw.js → cli-tbhwrxpt.js} +9 -9
  71. package/dist/{cli-w7z94e6c.js → cli-tx00c0h6.js} +4 -2
  72. package/dist/{cli-dxwh4j32.js → cli-vy0fay6k.js} +46 -37
  73. package/dist/{cli-ptkpaqfy.js → cli-wt645v7q.js} +1 -1
  74. package/dist/{cli-ppapy34w.js → cli-wxbn3yfx.js} +2 -2
  75. package/dist/{cli-cby329ny.js → cli-x5mq1fyq.js} +3 -3
  76. package/dist/{cli-rc3r0bnh.js → cli-xbzvet96.js} +6 -6
  77. package/dist/{cli-4mkvwgzr.js → cli-xf234ws8.js} +1 -1
  78. package/dist/{cli-6p7ddg72.js → cli-xftrvxag.js} +5 -5
  79. package/dist/cli-z071fb95.js +848 -0
  80. package/dist/{cli-1v8w782f.js → cli-z1ew8vbq.js} +14 -7
  81. package/dist/{cli-9td5ss65.js → cli-zfg9enh9.js} +3 -3
  82. package/dist/{cli-yxqag76b.js → cli-zw88zjba.js} +1 -1
  83. package/dist/cli.js +19 -19
  84. package/dist/{codex-adapter-nhjj2veb.js → codex-adapter-p6rmm7vv.js} +6 -6
  85. package/dist/{codex-hook-x6tm6y5m.js → codex-hook-x7nejyrr.js} +8 -5
  86. package/dist/{codex-login-35p4sk85.js → codex-login-m819c41r.js} +1 -1
  87. package/dist/{codex-session-runner-6hggrjbx.js → codex-session-runner-8vd5t9t0.js} +7 -7
  88. package/dist/{commands-mrw1ph2w.js → commands-7ems2p13.js} +2 -2
  89. package/dist/{controller-pt1zam5w.js → controller-m263fg43.js} +4 -4
  90. package/dist/{controllers-connect-ymw5541d.js → controllers-connect-bg33ae53.js} +28 -24
  91. package/dist/{cursor-adapter-cf4zh5x0.js → cursor-adapter-cz6nm6mj.js} +3 -3
  92. package/dist/{db-hy80219q.js → db-w505dwa8.js} +2 -2
  93. package/dist/{db-hhpy6m4x.js → db-ys2rbdft.js} +3 -2
  94. package/dist/{devin-adapter-7egzmt0k.js → devin-adapter-zgqadvnm.js} +1 -1
  95. package/dist/{dispatcher-6pdjtkr1.js → dispatcher-0s0mckqr.js} +20 -18
  96. package/dist/{docker-njavd3fb.js → docker-fkgtr75t.js} +2 -2
  97. package/dist/{dsh-adapter-fbx06re2.js → dsh-adapter-3n3net33.js} +3 -3
  98. package/dist/{e2b-5r6a5jeb.js → e2b-7am6tmq6.js} +2 -2
  99. package/dist/{e2b-pw1nvtmh.js → e2b-thdcxtjd.js} +2 -2
  100. package/dist/{easter-egg-3d-6hg2r942.js → easter-egg-3d-5cgynaja.js} +1 -1
  101. package/dist/{event-bus-101fenkh.js → event-bus-9vpk8gmq.js} +1 -1
  102. package/dist/{execute-bcqc69a5.js → execute-t4e6m3rw.js} +1 -1
  103. package/dist/{external-channel-j6vb6ya1.js → external-channel-5b23fv8z.js} +2 -2
  104. package/dist/{google-generative-ai-phpmwxvg.js → google-generative-ai-bmq8gkf3.js} +1 -1
  105. package/dist/{google-vertex-es9ybgdy.js → google-vertex-b1rvp52s.js} +1 -1
  106. package/dist/{grok-adapter-1193sprp.js → grok-adapter-q9fghe5q.js} +10 -10
  107. package/dist/handlers-mqrym347.js +39 -0
  108. package/dist/{heartbeat-h1w1ktce.js → heartbeat-tww6yx1w.js} +23 -21
  109. package/dist/{hook-ejja4bpe.js → hook-dx0pkvar.js} +16 -9
  110. package/dist/{hook-skrbja18.js → hook-pvmh9b6m.js} +6 -6
  111. package/dist/{http-mzh41mfj.js → http-k2ejbt05.js} +975 -292
  112. package/dist/{index-6rmnn89d.js → index-2z710v4x.js} +10 -10
  113. package/dist/{index-xmmkyx82.js → index-dgz61nff.js} +20 -18
  114. package/dist/{index-wgsw9xcz.js → index-g6tbb6ve.js} +1 -1
  115. package/dist/index-h2ek08d6.js +40 -0
  116. package/dist/index-pqfwh9nn.js +41 -0
  117. package/dist/{index-epr2gnbw.js → index-x5aktmp8.js} +1 -1
  118. package/dist/{index-x0q2a4f9.js → index-ysd45kgc.js} +1 -1
  119. package/dist/{index-g909y089.js → index-zgvqzjsw.js} +8 -8
  120. package/dist/{keepalive-4djvbm2j.js → keepalive-nhvpw10z.js} +4 -4
  121. package/dist/lead-jb6sf69z.js +78 -0
  122. package/dist/{maintenance-f3xhnjsm.js → maintenance-agakc519.js} +1 -1
  123. package/dist/{oauth-refresh-sweep-fpd6x6rw.js → oauth-refresh-sweep-4dcbhtn0.js} +3 -3
  124. package/dist/{onboard-196tjgyn.js → onboard-4n2kwa4v.js} +3 -3
  125. package/dist/{opencode-adapter-eeesgfqk.js → opencode-adapter-3s7ax02e.js} +7 -7
  126. package/dist/{otel-impl-g8fh4c21.js → otel-impl-tfa12080.js} +2 -2
  127. package/dist/{pi-mono-adapter-zasp3ze3.js → pi-mono-adapter-ytp7gz8b.js} +24 -13
  128. package/dist/{pricing-refresh-sdcf5yaz.js → pricing-refresh-3cqx3f3x.js} +3 -3
  129. package/dist/{rbac-roles-bsp5657v.js → rbac-roles-9fae5rnv.js} +5 -3
  130. package/dist/{rbac-roles-2x4g1wb5.js → rbac-roles-y6zbfzve.js} +2 -2
  131. package/dist/{render-v2-0pyb39bb.js → render-v2-emawjvc4.js} +3 -3
  132. package/dist/{resume-a86tkj6r.js → resume-zhgts7h7.js} +10 -8
  133. package/dist/{runtime-ar8310ba.js → runtime-xe3aqy4x.js} +1 -1
  134. package/dist/session-access-cm823e06.js +25 -0
  135. package/dist/{setup-ypbzcapd.js → setup-tkp99w1e.js} +1 -1
  136. package/dist/{virtual-modules-wzk6jf3a.js → virtual-modules-4r3zkc20.js} +2 -2
  137. package/dist/{work-objects-yjp8de12.js → work-objects-f722h263.js} +23 -21
  138. package/dist/worker-p7f336rq.js +78 -0
  139. package/dist/{x-8ewt8gxn.js → x-y45mthwn.js} +2 -2
  140. package/openapi.json +1086 -305
  141. package/package.json +2 -2
  142. package/src/apps/action-caller.ts +6 -0
  143. package/src/apps/action-runner.ts +146 -0
  144. package/src/apps/row-store.ts +4 -2
  145. package/src/apps/script-types.ts +17 -4
  146. package/src/be/db/active-sessions.ts +5 -0
  147. package/src/be/db/session-visibility.ts +29 -0
  148. package/src/be/db/tasks/read.ts +61 -3
  149. package/src/be/db/tasks/write.ts +15 -6
  150. package/src/be/db.ts +106 -37
  151. package/src/be/events.ts +11 -0
  152. package/src/be/fleet-benchmark-stats.ts +10 -5
  153. package/src/be/migrations/230_session_shares.sql +23 -0
  154. package/src/be/models-catalog.ts +4 -0
  155. package/src/be/onboarding.ts +6 -0
  156. package/src/be/rbac-roles.ts +2 -0
  157. package/src/be/scripts/typecheck.ts +13 -0
  158. package/src/be/session-shares.ts +244 -0
  159. package/src/be/swarm-config-guard.ts +33 -3
  160. package/src/be/telemetry-enable.ts +1 -1
  161. package/src/commands/provider-credentials.ts +12 -2
  162. package/src/commands/runner.ts +14 -0
  163. package/src/heartbeat/heartbeat.ts +2 -2
  164. package/src/hooks/codex-hook.ts +6 -2
  165. package/src/hooks/hook.ts +7 -0
  166. package/src/hooks/pr-body-guard.ts +38 -11
  167. package/src/hooks/pr-room-guard.ts +88 -0
  168. package/src/http/active-sessions.ts +13 -2
  169. package/src/http/agents.ts +11 -3
  170. package/src/http/all-routes.ts +1 -0
  171. package/src/http/api-keys.ts +3 -1
  172. package/src/http/approval-requests.ts +2 -1
  173. package/src/http/apps.ts +118 -190
  174. package/src/http/config.ts +3 -0
  175. package/src/http/context.ts +2 -0
  176. package/src/http/core.ts +39 -2
  177. package/src/http/events.ts +6 -2
  178. package/src/http/favorite-owner.ts +1 -1
  179. package/src/http/fleet-benchmark.ts +79 -30
  180. package/src/http/fs.ts +38 -3
  181. package/src/http/global-config.ts +7 -0
  182. package/src/http/index.ts +3 -1
  183. package/src/http/memory.ts +3 -1
  184. package/src/http/ranking.ts +351 -0
  185. package/src/http/realtime.ts +26 -21
  186. package/src/http/route-def.ts +77 -11
  187. package/src/http/script-runs.ts +2 -1
  188. package/src/http/scripts.ts +8 -0
  189. package/src/http/session-access.ts +179 -0
  190. package/src/http/session-data.ts +10 -2
  191. package/src/http/sessions.ts +212 -12
  192. package/src/http/stats.ts +7 -3
  193. package/src/http/tasks.ts +85 -8
  194. package/src/http/telemetry-ui.ts +1 -1
  195. package/src/http/used-by.ts +64 -20
  196. package/src/http/users.ts +2 -2
  197. package/src/prompts/session-templates.ts +3 -1
  198. package/src/providers/amp-adapter.ts +1 -1
  199. package/src/providers/pi-mono-adapter.ts +15 -0
  200. package/src/providers/reasoning-effort.ts +2 -1
  201. package/src/providers/types.ts +2 -0
  202. package/src/ranking/telemetry-ranking.ts +119 -0
  203. package/src/ranking/usage.ts +57 -0
  204. package/src/rbac/admission.ts +22 -7
  205. package/src/rbac/legacy-policy.ts +2 -0
  206. package/src/rbac/permissions.ts +9 -0
  207. package/src/realtime/auth.ts +69 -0
  208. package/src/realtime/tickets.ts +4 -1
  209. package/src/realtime/transport.ts +77 -9
  210. package/src/scripts-runtime/sdk-allowlist.ts +7 -0
  211. package/src/scripts-runtime/types/stdlib.d.ts +31 -0
  212. package/src/scripts-runtime/types/swarm-sdk.d.ts +31 -0
  213. package/src/server.ts +4 -0
  214. package/src/slack/blocks.ts +18 -0
  215. package/src/slack/dm.ts +29 -0
  216. package/src/telemetry-context.ts +19 -1
  217. package/src/telemetry-contract/EVENTS.md +45 -8
  218. package/src/telemetry-contract/SOURCE.json +38 -4
  219. package/src/telemetry-contract/catalog.json +294 -5
  220. package/src/telemetry-contract/ranking/fixtures/expected.json +30 -0
  221. package/src/telemetry-contract/ranking/fixtures/invalid/bad-category.json +11 -0
  222. package/src/telemetry-contract/ranking/fixtures/invalid/bad-claim.json +11 -0
  223. package/src/telemetry-contract/ranking/fixtures/invalid/blank-description.json +11 -0
  224. package/src/telemetry-contract/ranking/fixtures/invalid/blank-name.json +11 -0
  225. package/src/telemetry-contract/ranking/fixtures/invalid/description-too-long.json +11 -0
  226. package/src/telemetry-contract/ranking/fixtures/invalid/domain-uppercase.json +11 -0
  227. package/src/telemetry-contract/ranking/fixtures/invalid/domain-with-scheme.json +11 -0
  228. package/src/telemetry-contract/ranking/fixtures/invalid/domain-with-www.json +11 -0
  229. package/src/telemetry-contract/ranking/fixtures/invalid/http-source-url.json +11 -0
  230. package/src/telemetry-contract/ranking/fixtures/invalid/missing-description.json +10 -0
  231. package/src/telemetry-contract/ranking/fixtures/invalid/missing-version.json +10 -0
  232. package/src/telemetry-contract/ranking/fixtures/invalid/name-not-string.json +11 -0
  233. package/src/telemetry-contract/ranking/fixtures/invalid/name-too-long.json +11 -0
  234. package/src/telemetry-contract/ranking/fixtures/invalid/not-object.json +1 -0
  235. package/src/telemetry-contract/ranking/fixtures/invalid/null.json +1 -0
  236. package/src/telemetry-contract/ranking/fixtures/invalid/other-with-subcategory.json +11 -0
  237. package/src/telemetry-contract/ranking/fixtures/invalid/oversize.json +1 -0
  238. package/src/telemetry-contract/ranking/fixtures/invalid/short-claim.json +11 -0
  239. package/src/telemetry-contract/ranking/fixtures/invalid/subcategory-other-category.json +11 -0
  240. package/src/telemetry-contract/ranking/fixtures/invalid/trailing-data.json +1 -0
  241. package/src/telemetry-contract/ranking/fixtures/invalid/unknown-field.json +12 -0
  242. package/src/telemetry-contract/ranking/fixtures/invalid/unsupported-version.json +11 -0
  243. package/src/telemetry-contract/ranking/fixtures/invalid/updated-at-not-date.json +11 -0
  244. package/src/telemetry-contract/ranking/fixtures/invalid/updated-at-offset.json +11 -0
  245. package/src/telemetry-contract/ranking/fixtures/invalid/wrong-case-field.json +11 -0
  246. package/src/telemetry-contract/ranking/fixtures/valid/category-without-subcategory.json +11 -0
  247. package/src/telemetry-contract/ranking/fixtures/valid/full.json +11 -0
  248. package/src/telemetry-contract/ranking/fixtures/valid/minimal.json +11 -0
  249. package/src/telemetry-contract/ranking/fixtures/valid/no-claim.json +10 -0
  250. package/src/telemetry-contract/ranking/fixtures/valid/padded-text.json +11 -0
  251. package/src/telemetry-contract/ranking/fixtures/valid/unicode-name.json +11 -0
  252. package/src/telemetry-contract/ranking/listing.v1.schema.json +61 -0
  253. package/src/telemetry-contract/ranking/taxonomy.json +8 -0
  254. package/src/telemetry-contract/ranking-taxonomy.gen.ts +11 -0
  255. package/src/telemetry-contract/types.gen.ts +963 -58
  256. package/src/telemetry-identity.ts +47 -9
  257. package/src/telemetry-snapshot.ts +9 -1
  258. package/src/telemetry-ui-events.ts +9 -2
  259. package/src/telemetry.ts +40 -5
  260. package/src/tests/app-action-run-tool.test.ts +178 -0
  261. package/src/tests/app-row-tools.test.ts +360 -0
  262. package/src/tests/apps-rbac.test.ts +189 -2
  263. package/src/tests/apps-script-types.test.ts +16 -3
  264. package/src/tests/credential-check.test.ts +38 -0
  265. package/src/tests/db-extraction-contract.test.ts +1 -0
  266. package/src/tests/db-task-read-contract.test.ts +1 -0
  267. package/src/tests/docs-index-footprint.test.js +2 -2
  268. package/src/tests/fleet-benchmark.test.ts +122 -2
  269. package/src/tests/http-users.test.ts +62 -1
  270. package/src/tests/model-catalog-table.test.ts +63 -0
  271. package/src/tests/model-profiles-api.test.ts +19 -7
  272. package/src/tests/models-catalog.test.ts +50 -0
  273. package/src/tests/onboarding.test.ts +21 -0
  274. package/src/tests/org-identity.test.ts +44 -0
  275. package/src/tests/org-website.test.ts +62 -0
  276. package/src/tests/pi-mono-adapter.test.ts +23 -0
  277. package/src/tests/pr-body-leaks.test.ts +4 -0
  278. package/src/tests/pr-room-guard.test.ts +242 -0
  279. package/src/tests/ranking-listing.test.ts +97 -0
  280. package/src/tests/ranking-route.test.ts +321 -0
  281. package/src/tests/ranking-usage.test.ts +50 -0
  282. package/src/tests/rbac-admission-e2e.test.ts +8 -0
  283. package/src/tests/rbac-admission.test.ts +38 -0
  284. package/src/tests/rbac-charact-http.test.ts +4 -3
  285. package/src/tests/rbac-engine.test.ts +2 -0
  286. package/src/tests/rbac-roles.test.ts +2 -0
  287. package/src/tests/realtime-room-surfaces.test.ts +3 -1
  288. package/src/tests/realtime-session-join-race.test.ts +142 -0
  289. package/src/tests/realtime-tickets.test.ts +24 -17
  290. package/src/tests/realtime-transport.test.ts +91 -0
  291. package/src/tests/reasoning-effort.test.ts +39 -3
  292. package/src/tests/runner-harness-telemetry-env.test.ts +56 -1
  293. package/src/tests/session-route-posture.test.ts +639 -0
  294. package/src/tests/session-sharing-routes.test.ts +282 -0
  295. package/src/tests/session-sharing.test.ts +526 -0
  296. package/src/tests/sessions-detail-batch.test.ts +7 -1
  297. package/src/tests/slack-tool-blocks.test.ts +101 -0
  298. package/src/tests/slack-update.test.ts +55 -0
  299. package/src/tests/slack-user-dm.test.ts +177 -0
  300. package/src/tests/swarm-tool-result-gate.test.ts +2 -4
  301. package/src/tests/telemetry-context.test.ts +128 -2
  302. package/src/tests/telemetry-ui-route.test.ts +123 -0
  303. package/src/tests/tool-annotations.test.ts +3 -2
  304. package/src/tests/used-by-route.test.ts +153 -9
  305. package/src/tests/workflow-agent-task-retry.test.ts +130 -4
  306. package/src/tests/workflow-wait-recovery.test.ts +116 -4
  307. package/src/tools/app-action-run.ts +63 -0
  308. package/src/tools/app-rows.ts +234 -0
  309. package/src/tools/model-catalog/index.ts +1 -1
  310. package/src/tools/slack-post.ts +18 -12
  311. package/src/tools/slack-read.ts +13 -1
  312. package/src/tools/slack-reply.ts +7 -10
  313. package/src/tools/slack-start-thread.ts +18 -11
  314. package/src/tools/slack-update.ts +2 -9
  315. package/src/tools/tool-config.ts +8 -0
  316. package/src/tools/utils.ts +1 -1
  317. package/src/tools/workflows/retry-workflow-run.ts +1 -1
  318. package/src/types.ts +52 -0
  319. package/src/utils/company-profile.ts +24 -0
  320. package/src/utils/org-identity.ts +33 -0
  321. package/src/utils/org-website.ts +58 -21
  322. package/src/workflows/recovery.ts +10 -22
  323. package/src/workflows/resume.ts +16 -0
  324. package/src/workflows/task-step-routing.ts +47 -7
  325. package/templates/skills/apps/SKILL.md +58 -2
  326. package/templates/skills/apps/content.md +58 -2
  327. package/dist/handlers-tb3xgjnm.js +0 -37
  328. package/dist/index-nyfcdpky.js +0 -39
  329. package/dist/index-vjn3wbzf.js +0 -38
  330. package/dist/lead-61kqp604.js +0 -76
  331. package/dist/worker-4ptnn1ge.js +0 -76
  332. package/dist/{cli-n5mrsg0f.js → cli-60cgh1rv.js} +3 -3
package/src/http/core.ts CHANGED
@@ -47,6 +47,14 @@ import { refreshSecretScrubberCache, registerSensitiveKeyName } from "../utils/s
47
47
  import { resolveHttpRequestAuth } from "./auth";
48
48
  import { generateOpenApiSpec, SCALAR_HTML } from "./openapi";
49
49
  import { findRoute, isPublicRoute, route, runtimeInstanceHeader } from "./route-def";
50
+ import {
51
+ canReadSession,
52
+ pathSessionDenial,
53
+ readableByFor,
54
+ resolveSessionActor,
55
+ SESSION_READ_DENIED,
56
+ userAgentIdentityDenial,
57
+ } from "./session-access";
50
58
  import {
51
59
  agentWithCapacity,
52
60
  duplicateGuardedQueryKey,
@@ -503,6 +511,15 @@ export async function handleCore(
503
511
  setRequestAuth(req, auth);
504
512
  }
505
513
 
514
+ // A user token never gains agent identity from X-Agent-ID, on /mcp, /api/poll
515
+ // or any worker-header route.
516
+ const routeDef = findRoute(req.method, pathSegments);
517
+ const agentIdentityDenial = await userAgentIdentityDenial(req, routeDef, pathSegments);
518
+ if (agentIdentityDenial) {
519
+ jsonError(res, agentIdentityDenial, 403);
520
+ return true;
521
+ }
522
+
506
523
  if (auth?.kind === "agent") {
507
524
  const query = parseQueryParams(req.url || "");
508
525
  const duplicate = duplicateGuardedQueryKey(query);
@@ -565,7 +582,7 @@ export async function handleCore(
565
582
  if (auth?.kind === "user" && isRbacEnabled()) {
566
583
  const grant = await getUserGrant(auth.userId);
567
584
  if (!grant.grantsAll) {
568
- const def = findRoute(req.method, pathSegments);
585
+ const def = routeDef;
569
586
  const decision = decideAdmission({
570
587
  method: req.method ?? "",
571
588
  rbac: def?.rbac,
@@ -585,6 +602,16 @@ export async function handleCore(
585
602
  }
586
603
  }
587
604
 
605
+ // Session access for every route keyed by a task or steering message, before
606
+ // its handler reads or changes anything (the route's `session` posture).
607
+ if (routeDef?.session) {
608
+ const sessionDenial = await pathSessionDenial(req, myAgentId, routeDef, pathSegments);
609
+ if (sessionDenial) {
610
+ jsonError(res, sessionDenial, 403);
611
+ return true;
612
+ }
613
+ }
614
+
588
615
  // POST /internal/reload-config — re-read swarm_config into process.env and re-init integrations
589
616
  if (req.method === "POST" && req.url === "/internal/reload-config") {
590
617
  try {
@@ -662,7 +689,14 @@ export async function handleCore(
662
689
  const queryParams = parseQueryParams(req.url || "");
663
690
  const taskId = queryParams.get("taskId");
664
691
 
692
+ // A user token naming an agent in X-Agent-ID still reads only its sessions.
693
+ const sessionActor = await resolveSessionActor(req, myAgentId);
665
694
  if (taskId) {
695
+ if (!(await canReadSession(req, myAgentId, taskId))) {
696
+ res.writeHead(403, { "Content-Type": "application/json" });
697
+ res.end(JSON.stringify({ error: SESSION_READ_DENIED }));
698
+ return true;
699
+ }
666
700
  // Check if specific task is cancelled
667
701
  const task = await getTaskById(taskId);
668
702
  if (task && task.status === "cancelled") {
@@ -687,7 +721,10 @@ export async function handleCore(
687
721
  }
688
722
 
689
723
  // No taskId - return all recently cancelled tasks for this agent
690
- const cancelledTasks = await getRecentlyCancelledTasksForAgent(myAgentId);
724
+ const cancelledTasks = await getRecentlyCancelledTasksForAgent(
725
+ myAgentId,
726
+ readableByFor(sessionActor),
727
+ );
691
728
  res.writeHead(200, { "Content-Type": "application/json" });
692
729
  res.end(JSON.stringify({ cancelled: cancelledTasks }));
693
730
  return true;
@@ -13,7 +13,8 @@ import {
13
13
  EventStatusSchema,
14
14
  SwarmEventSchema,
15
15
  } from "../types";
16
- import { route } from "./route-def";
16
+ import { bodyListTask, bodyTask, route } from "./route-def";
17
+ import { readableByFor, resolveSessionActor } from "./session-access";
17
18
  import { jsonError } from "./utils";
18
19
 
19
20
  // ─── Route Definitions ───────────────────────────────────────────────────────
@@ -36,6 +37,7 @@ const createEventRoute = route({
36
37
  method: "post",
37
38
  path: "/api/events",
38
39
  pattern: ["api", "events"],
40
+ session: bodyTask("taskId"),
39
41
  summary: "Store a single event",
40
42
  tags: ["Events"],
41
43
  body: eventBodySchema,
@@ -53,6 +55,7 @@ const createEventsBatchRoute = route({
53
55
  method: "post",
54
56
  path: "/api/events/batch",
55
57
  pattern: ["api", "events", "batch"],
58
+ session: bodyListTask("events", "taskId"),
56
59
  summary: "Store multiple events in a batch",
57
60
  tags: ["Events"],
58
61
  body: z.object({
@@ -153,7 +156,7 @@ export async function handleEvents(
153
156
  res: ServerResponse,
154
157
  pathSegments: string[],
155
158
  queryParams: URLSearchParams,
156
- _myAgentId: string | undefined,
159
+ myAgentId: string | undefined,
157
160
  ): Promise<boolean> {
158
161
  // Match batch BEFORE generic /api/events (POST)
159
162
  if (createEventsBatchRoute.match(req.method, pathSegments)) {
@@ -252,6 +255,7 @@ export async function handleEvents(
252
255
  limit: parsed.query.limit ?? 100,
253
256
  events: eventFilter,
254
257
  latestPerDataField: latestPerDataField ? { events: latestEvents, dataFields } : undefined,
258
+ readableBy: readableByFor(await resolveSessionActor(req, myAgentId)),
255
259
  });
256
260
  getEventsRoute.respond(
257
261
  res,
@@ -16,7 +16,7 @@ export type FavoriteOwner = {
16
16
  */
17
17
  export const DASHBOARD_USER_HEADER = "x-swarm-user-id";
18
18
 
19
- function dashboardUserIdHeader(req: IncomingMessage): string | null {
19
+ export function dashboardUserIdHeader(req: IncomingMessage): string | null {
20
20
  const raw = req.headers[DASHBOARD_USER_HEADER];
21
21
  const value = (Array.isArray(raw) ? raw[0] : raw)?.trim();
22
22
  return value ? value : null;
@@ -1,6 +1,5 @@
1
1
  import type { IncomingMessage, ServerResponse } from "node:http";
2
2
  import { z } from "zod";
3
- import { getSwarmConfigs } from "../be/db";
4
3
  import { getLocalFleetStats } from "../be/fleet-benchmark-stats";
5
4
  import {
6
5
  compareWithFleet,
@@ -12,6 +11,9 @@ import {
12
11
  localTasksPerWeek,
13
12
  } from "../fleet-benchmark";
14
13
  import { isTelemetryEnabled } from "../telemetry";
14
+ import { COMPANY_TEAM_SIZES, COMPANY_USE_CASES } from "../utils/company-profile";
15
+ import { normalizeOrgWebsite } from "../utils/org-website";
16
+ import { globalConfig } from "./global-config";
15
17
  import { rejectGuest } from "./request-principal";
16
18
  import { route } from "./route-def";
17
19
  import { telemetryProxyEndpoint } from "./used-by";
@@ -34,6 +36,14 @@ const FleetStateSchema = z.enum([
34
36
 
35
37
  const FleetBenchmarkResponseSchema = z.object({
36
38
  state: FleetStateSchema,
39
+ level: z.enum(["basic", "full"]),
40
+ peerGroup: z
41
+ .object({
42
+ teamSize: z.string().nullable(),
43
+ useCase: z.string().nullable(),
44
+ orgs: z.number().int(),
45
+ })
46
+ .nullable(),
37
47
  local: z
38
48
  .object({
39
49
  tasksPerWeek: z.number(),
@@ -67,7 +77,7 @@ const fleetBenchmark = route({
67
77
  pattern: ["api", "fleet-benchmark"],
68
78
  summary: "Compare this swarm with similar swarms",
69
79
  description:
70
- "Places this swarm's tasks per week and task success rate (last 30 days) in the fleet percentiles published by the telemetry proxy, against swarms with the same agent count when enough exist. Needs telemetry on and an organization name; otherwise `state` says what is missing and the proxy is not called. `unavailable` also covers an install whose first event the proxy saw cannot be established locally (until 30 days after the first accepted event). The fleet numbers are cached for a day.",
80
+ "Compares local task volume and success rate with fleet percentiles over the last 30 days. Comparisons require telemetry, an organization name, and a known proxy ingest date. A website, team size, and use case enable full comparisons with peer filters. The response includes the proxy's peer group when available. With telemetry off, it returns local DB counts without a proxy request. The fleet cache key includes the peer filters.",
71
81
  tags: ["Telemetry"],
72
82
  responses: {
73
83
  200: {
@@ -81,8 +91,12 @@ const fleetBenchmark = route({
81
91
 
82
92
  // ─── Caches ──────────────────────────────────────────────────────────────────
83
93
 
84
- let fleetCache: { value: FleetBenchmarks | null; until: number } | null = null;
85
- let localCache: { value: LocalFleetStats | null; until: number } | null = null;
94
+ let fleetCache: { key: string; value: ProxyFleetBenchmarks | null; until: number } | null = null;
95
+ let localCache: {
96
+ requireIngestAnchor: boolean;
97
+ value: LocalFleetStats | null;
98
+ until: number;
99
+ } | null = null;
86
100
 
87
101
  const ProxyMetricSchema = z.object({
88
102
  n: z.number(),
@@ -112,19 +126,34 @@ const ProxyFleetBenchmarksSchema = z.object({
112
126
  "2-5": ProxyBlockSchema.optional(),
113
127
  "6+": ProxyBlockSchema.optional(),
114
128
  }),
129
+ peer_group: z
130
+ .object({
131
+ team_size: z.string().nullable(),
132
+ use_case: z.string().nullable(),
133
+ orgs: z.number().int().nonnegative(),
134
+ })
135
+ .nullable()
136
+ .optional(),
115
137
  }) satisfies z.ZodType<FleetBenchmarks>;
116
138
 
139
+ type ProxyFleetBenchmarks = z.infer<typeof ProxyFleetBenchmarksSchema>;
140
+
117
141
  /** The proxy's fleet percentiles. The request carries no install ID. */
118
- async function fleetBenchmarks(now: number): Promise<FleetBenchmarks | null> {
119
- if (fleetCache && fleetCache.until > now) return fleetCache.value;
120
- let value: FleetBenchmarks | null = null;
142
+ async function fleetBenchmarks(
143
+ now: number,
144
+ peerGroup: { teamSize: string; useCase: string } | null,
145
+ ): Promise<ProxyFleetBenchmarks | null> {
146
+ const endpoint = new URL(await telemetryProxyEndpoint("/v1/fleet/benchmarks"));
147
+ endpoint.searchParams.set("window", "30d");
148
+ if (peerGroup) {
149
+ endpoint.searchParams.set("team_size", peerGroup.teamSize);
150
+ endpoint.searchParams.set("use_case", peerGroup.useCase);
151
+ }
152
+ const key = endpoint.toString();
153
+ if (fleetCache?.key === key && fleetCache.until > now) return fleetCache.value;
154
+ let value: ProxyFleetBenchmarks | null = null;
121
155
  try {
122
- const response = await fetch(
123
- `${await telemetryProxyEndpoint("/v1/fleet/benchmarks")}?window=30d`,
124
- {
125
- signal: AbortSignal.timeout(TIMEOUT_MS),
126
- },
127
- );
156
+ const response = await fetch(key, { signal: AbortSignal.timeout(TIMEOUT_MS) });
128
157
  if (response.ok) {
129
158
  const parsed = ProxyFleetBenchmarksSchema.safeParse(await response.json());
130
159
  if (parsed.success) value = parsed.data;
@@ -132,38 +161,46 @@ async function fleetBenchmarks(now: number): Promise<FleetBenchmarks | null> {
132
161
  } catch {
133
162
  // Unreachable proxy: the card says the comparison is unavailable.
134
163
  }
135
- fleetCache = { value, until: now + (value ? FLEET_TTL_MS : FLEET_FAILURE_TTL_MS) };
164
+ fleetCache = { key, value, until: now + (value ? FLEET_TTL_MS : FLEET_FAILURE_TTL_MS) };
136
165
  return value;
137
166
  }
138
167
 
139
- async function localStats(now: Date): Promise<LocalFleetStats | null> {
140
- if (localCache && localCache.until > now.getTime()) return localCache.value;
141
- const value = await getLocalFleetStats(now);
142
- localCache = { value, until: now.getTime() + LOCAL_TTL_MS };
168
+ async function localStats(now: Date, requireIngestAnchor = true): Promise<LocalFleetStats | null> {
169
+ if (localCache?.requireIngestAnchor === requireIngestAnchor && localCache.until > now.getTime())
170
+ return localCache.value;
171
+ const value = await getLocalFleetStats(now, { requireIngestAnchor });
172
+ localCache = { requireIngestAnchor, value, until: now.getTime() + LOCAL_TTL_MS };
143
173
  return value;
144
174
  }
145
175
 
146
- async function orgName(): Promise<string | undefined> {
147
- const stored = (
148
- await getSwarmConfigs({ scope: "global", key: "SWARM_ORG_NAME" })
149
- )?.[0]?.value?.trim();
150
- return stored || process.env.SWARM_ORG_NAME?.trim() || undefined;
151
- }
152
-
153
176
  export async function buildFleetBenchmarkResponse(
154
177
  now = new Date(),
155
178
  ): Promise<FleetBenchmarkResponse> {
179
+ const [name, website, teamSize, useCase] = await Promise.all([
180
+ globalConfig("SWARM_ORG_NAME"),
181
+ globalConfig("SWARM_ORG_WEBSITE"),
182
+ globalConfig("SWARM_ORG_TEAM_SIZE"),
183
+ globalConfig("SWARM_ORG_USE_CASE"),
184
+ ]);
185
+ const team = z.enum(COMPANY_TEAM_SIZES).safeParse(teamSize);
186
+ const use = z.enum(COMPANY_USE_CASES).safeParse(useCase);
187
+ const peerGroup =
188
+ normalizeOrgWebsite(website) && team.success && use.success
189
+ ? { teamSize: team.data, useCase: use.data }
190
+ : null;
156
191
  const empty = {
192
+ level: peerGroup ? ("full" as const) : ("basic" as const),
193
+ peerGroup: null,
157
194
  local: null,
158
195
  minFinishedTasks: FLEET_MIN_FINISHED_TASKS,
159
196
  generatedAt: null,
160
197
  comparisons: [],
161
198
  };
162
199
  // Telemetry off means no call to our proxy at all, not even an anonymous one.
163
- if (!isTelemetryEnabled()) return { state: "telemetry_off", ...empty };
164
- if (!(await orgName())) return { state: "no_org_name", ...empty };
200
+ const telemetryEnabled = isTelemetryEnabled();
201
+ if (telemetryEnabled && !name) return { state: "no_org_name", ...empty };
165
202
 
166
- const stats = await localStats(now);
203
+ const stats = await localStats(now, telemetryEnabled);
167
204
  // Where the proxy started counting this install is unknown: no comparison.
168
205
  if (!stats) return { state: "unavailable", ...empty };
169
206
  const finishedTasks = stats.tasksCompleted + stats.tasksFailed;
@@ -174,14 +211,26 @@ export async function buildFleetBenchmarkResponse(
174
211
  agents: stats.agents,
175
212
  bucket: fleetBucketFor(stats.agents),
176
213
  };
214
+ if (!telemetryEnabled) return { ...empty, state: "telemetry_off", local };
177
215
  if (finishedTasks < FLEET_MIN_FINISHED_TASKS)
178
216
  return { ...empty, state: "not_enough_tasks", local };
179
217
 
180
- const fleet = await fleetBenchmarks(now.getTime());
218
+ const fleet = await fleetBenchmarks(now.getTime(), peerGroup);
219
+ const responsePeerGroup =
220
+ peerGroup && fleet?.peer_group
221
+ ? {
222
+ teamSize: fleet.peer_group.team_size,
223
+ useCase: fleet.peer_group.use_case,
224
+ orgs: fleet.peer_group.orgs,
225
+ }
226
+ : null;
181
227
  const comparisons = fleet ? compareWithFleet(stats, fleet, now) : [];
182
- if (!fleet || comparisons.length === 0) return { ...empty, state: "unavailable", local };
228
+ if (!fleet || comparisons.length === 0)
229
+ return { ...empty, state: "unavailable", local, peerGroup: responsePeerGroup };
183
230
  return {
231
+ ...empty,
184
232
  state: "ready",
233
+ peerGroup: responsePeerGroup,
185
234
  local,
186
235
  minFinishedTasks: FLEET_MIN_FINISHED_TASKS,
187
236
  generatedAt: fleet.generatedAt,
package/src/http/fs.ts CHANGED
@@ -15,6 +15,7 @@ import { getCurrentRequestAuth } from "../utils/request-auth-context";
15
15
  import { scrubSecrets } from "../utils/secret-scrubber";
16
16
  import { requestPrincipal } from "./request-principal";
17
17
  import { route } from "./route-def";
18
+ import { canReadSession, SESSION_READ_DENIED } from "./session-access";
18
19
  import { BODY_TOO_LARGE, enforceContentLengthCap, jsonError } from "./utils";
19
20
 
20
21
  // Upload wall-clock past which the provider round-trip is worth a log line.
@@ -126,6 +127,7 @@ const listTaskFilesRoute = route({
126
127
  method: "get",
127
128
  path: "/api/fs/tasks/{taskId}/files",
128
129
  pattern: ["api", "fs", "tasks", null, "files"],
130
+ session: { taskParam: "taskId" },
129
131
  summary: "List task file attachments",
130
132
  tags: ["FS"],
131
133
  params: taskParams,
@@ -142,6 +144,7 @@ const uploadTaskFileRoute = route({
142
144
  method: "post",
143
145
  path: "/api/fs/tasks/{taskId}/files",
144
146
  pattern: ["api", "fs", "tasks", null, "files"],
147
+ session: { taskParam: "taskId" },
145
148
  summary: "Upload a binary task file attachment",
146
149
  description:
147
150
  "Accepts a raw binary request body. Pass the display/path name as the `name` query parameter.",
@@ -163,6 +166,7 @@ const getTaskFileRoute = route({
163
166
  method: "get",
164
167
  path: "/api/fs/tasks/{taskId}/files/{attachmentId}",
165
168
  pattern: ["api", "fs", "tasks", null, "files", null],
169
+ session: { taskParam: "taskId" },
166
170
  summary: "Get task file attachment metadata",
167
171
  tags: ["FS"],
168
172
  params: attachmentParams,
@@ -176,6 +180,7 @@ const downloadTaskFileRoute = route({
176
180
  method: "get",
177
181
  path: "/api/fs/tasks/{taskId}/files/{attachmentId}/raw",
178
182
  pattern: ["api", "fs", "tasks", null, "files", null, "raw"],
183
+ session: { taskParam: "taskId" },
179
184
  summary: "Download raw task file bytes",
180
185
  description: "Streams raw bytes. File content is not secret-scrubbed.",
181
186
  tags: ["FS"],
@@ -193,6 +198,7 @@ const signedUrlTaskFileRoute = route({
193
198
  method: "get",
194
199
  path: "/api/fs/tasks/{taskId}/files/{attachmentId}/signed-url",
195
200
  pattern: ["api", "fs", "tasks", null, "files", null, "signed-url"],
201
+ session: { taskParam: "taskId" },
196
202
  summary: "Create a provider signed GET URL for a task file",
197
203
  tags: ["FS"],
198
204
  params: attachmentParams,
@@ -208,6 +214,7 @@ const deleteTaskFileRoute = route({
208
214
  method: "delete",
209
215
  path: "/api/fs/tasks/{taskId}/files/{attachmentId}",
210
216
  pattern: ["api", "fs", "tasks", null, "files", null],
217
+ session: { taskParam: "taskId" },
211
218
  summary: "Delete a task file attachment",
212
219
  tags: ["FS"],
213
220
  params: attachmentParams,
@@ -263,7 +270,13 @@ export async function handleFs(
263
270
  if (downloadTaskFileRoute.match(req.method, pathSegments)) {
264
271
  const parsed = await downloadTaskFileRoute.parse(req, res, pathSegments, queryParams);
265
272
  if (!parsed) return true;
266
- const attachment = await findAttachment(parsed.params.taskId, parsed.params.attachmentId, res);
273
+ const attachment = await findAttachment(
274
+ req,
275
+ myAgentId,
276
+ parsed.params.taskId,
277
+ parsed.params.attachmentId,
278
+ res,
279
+ );
267
280
  if (!attachment) return true;
268
281
  return sendDownload(res, attachment);
269
282
  }
@@ -271,7 +284,13 @@ export async function handleFs(
271
284
  if (signedUrlTaskFileRoute.match(req.method, pathSegments)) {
272
285
  const parsed = await signedUrlTaskFileRoute.parse(req, res, pathSegments, queryParams);
273
286
  if (!parsed) return true;
274
- const attachment = await findAttachment(parsed.params.taskId, parsed.params.attachmentId, res);
287
+ const attachment = await findAttachment(
288
+ req,
289
+ myAgentId,
290
+ parsed.params.taskId,
291
+ parsed.params.attachmentId,
292
+ res,
293
+ );
275
294
  if (!attachment) return true;
276
295
  return sendSignedUrl(res, attachment, parsed.query.expiresIn);
277
296
  }
@@ -279,7 +298,13 @@ export async function handleFs(
279
298
  if (getTaskFileRoute.match(req.method, pathSegments)) {
280
299
  const parsed = await getTaskFileRoute.parse(req, res, pathSegments, queryParams);
281
300
  if (!parsed) return true;
282
- const attachment = await findAttachment(parsed.params.taskId, parsed.params.attachmentId, res);
301
+ const attachment = await findAttachment(
302
+ req,
303
+ myAgentId,
304
+ parsed.params.taskId,
305
+ parsed.params.attachmentId,
306
+ res,
307
+ );
283
308
  if (!attachment) return true;
284
309
  getTaskFileRoute.respond(res, 200, attachment);
285
310
  return true;
@@ -313,6 +338,10 @@ export async function handleFs(
313
338
  const parsed = await listTaskFilesRoute.parse(req, res, pathSegments, queryParams);
314
339
  if (!parsed) return true;
315
340
  if (!(await getTaskById(parsed.params.taskId))) return notFound(res, "Task not found");
341
+ if (!(await canReadSession(req, myAgentId, parsed.params.taskId))) {
342
+ jsonError(res, SESSION_READ_DENIED, 403);
343
+ return true;
344
+ }
316
345
  listTaskFilesRoute.respond(res, 200, {
317
346
  attachments: await getTaskAttachments(parsed.params.taskId),
318
347
  });
@@ -493,6 +522,8 @@ function backingProviderId(attachment: TaskAttachment): string | null {
493
522
  }
494
523
 
495
524
  async function findAttachment(
525
+ req: IncomingMessage,
526
+ myAgentId: string | undefined,
496
527
  taskId: string,
497
528
  attachmentId: string,
498
529
  res: ServerResponse,
@@ -501,6 +532,10 @@ async function findAttachment(
501
532
  notFound(res, "Task not found");
502
533
  return null;
503
534
  }
535
+ if (!(await canReadSession(req, myAgentId, taskId))) {
536
+ jsonError(res, SESSION_READ_DENIED, 403);
537
+ return null;
538
+ }
504
539
  const attachment = (await getTaskAttachments(taskId)).find((item) => item.id === attachmentId);
505
540
  if (!attachment) {
506
541
  notFound(res, "Attachment not found");
@@ -0,0 +1,7 @@
1
+ import { getSwarmConfigs } from "../be/db";
2
+
3
+ /** Stored values, including empty strings, override env values, as on config reload. */
4
+ export async function globalConfig(key: string): Promise<string | undefined> {
5
+ const stored = (await getSwarmConfigs({ scope: "global", key }))?.[0]?.value;
6
+ return (stored ?? process.env[key])?.trim() || undefined;
7
+ }
package/src/http/index.ts CHANGED
@@ -116,6 +116,7 @@ import { handlePagesPublic } from "./pages-public";
116
116
  import { handlePoll } from "./poll";
117
117
  import { handlePricing } from "./pricing";
118
118
  import { handlePromptTemplates } from "./prompt-templates";
119
+ import { handleRanking } from "./ranking";
119
120
  import { handleRealtimeAsset, handleRealtimeTicket } from "./realtime";
120
121
  import { handleRepos } from "./repos";
121
122
  import { handleRooms } from "./rooms";
@@ -403,10 +404,11 @@ const httpServer = createHttpServer(async (req, res) => {
403
404
  () => handleExtensions(req, res, pathSegments, queryParams, myAgentId),
404
405
  () => handleFavorites(req, res, pathSegments, queryParams, myAgentId),
405
406
  () => handleUsers(req, res, pathSegments, queryParams),
406
- () => handleSessions(req, res, pathSegments, queryParams),
407
+ () => handleSessions(req, res, pathSegments, queryParams, myAgentId),
407
408
  () => handleInboxState(req, res, pathSegments, queryParams),
408
409
  () => handleTelemetryUi(req, res, pathSegments, queryParams, myAgentId),
409
410
  () => handleUsedBy(req, res, pathSegments, queryParams, myAgentId),
411
+ () => handleRanking(req, res, pathSegments, queryParams),
410
412
  () => handleFleetBenchmark(req, res, pathSegments, queryParams),
411
413
  () => handleTaskTemplates(req, res, pathSegments, queryParams),
412
414
  () => handleMcp(req, res, transports, transportActivity, mcpSessionAgents),
@@ -44,7 +44,7 @@ import { AgentMemorySchema, AgentMemoryScopeSchema, AgentMemorySourceSchema } fr
44
44
  import { getRequestAuth } from "../utils/request-auth-context";
45
45
  import { scrubSecrets } from "../utils/secret-scrubber";
46
46
  import { rejectGuest } from "./request-principal";
47
- import { route } from "./route-def";
47
+ import { bodyTask, route } from "./route-def";
48
48
  import { jsonError, parseQueryParams } from "./utils";
49
49
 
50
50
  // ─── Response Schemas ────────────────────────────────────────────────────────
@@ -68,6 +68,7 @@ const indexMemory = route({
68
68
  method: "post",
69
69
  path: "/api/memory/index",
70
70
  pattern: ["api", "memory", "index"],
71
+ session: bodyTask("sourceTaskId"),
71
72
  summary: "Ingest content into memory system (async embedding)",
72
73
  tags: ["Memory"],
73
74
  // The gate only bites when the key that lands on the rows (here, `sourcePath`) sits under a
@@ -687,6 +688,7 @@ const rateMemory = route({
687
688
  method: "post",
688
689
  path: "/api/memory/rate",
689
690
  pattern: ["api", "memory", "rate"],
691
+ session: { none: "worker-only: it needs X-Agent-ID, which a user token cannot send" },
690
692
  summary: "Submit RatingEvents to update memory usefulness posteriors",
691
693
  tags: ["Memory"],
692
694
  auth: { apiKey: true, agentId: true },