@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
@@ -2,7 +2,7 @@ import {
2
2
  CONTEXT_FORMULA,
3
3
  getContextWindowSize,
4
4
  clampContextPercent
5
- } from "./cli-jhp7w1fy.js";
5
+ } from "./cli-a5ebc95n.js";
6
6
  import {
7
7
  swarmRuntimeInstanceId
8
8
  } from "./cli-7a91w22y.js";
@@ -17,11 +17,11 @@ import {
17
17
  import {
18
18
  reasoningCapability,
19
19
  applyReasoningEffort
20
- } from "./cli-p22zdvnt.js";
20
+ } from "./cli-bn0rewsy.js";
21
21
  import {
22
22
  DEFAULT_MODEL_TIER_MAP,
23
23
  init_types
24
- } from "./cli-yv0vgscc.js";
24
+ } from "./cli-fpmsqq59.js";
25
25
  import {
26
26
  getOpenRouterBaseUrl,
27
27
  getOpenRouterAttributionHeaders,
@@ -31,7 +31,7 @@ import {
31
31
  scrubSecrets,
32
32
  registerVolatileSecret,
33
33
  init_secret_scrubber
34
- } from "./cli-4mkvwgzr.js";
34
+ } from "./cli-xf234ws8.js";
35
35
 
36
36
  // src/providers/dsh-adapter.ts
37
37
  init_types();
@@ -2,11 +2,11 @@ import {
2
2
  runtimeCatalogSection,
3
3
  runtimeCatalogModel,
4
4
  init_runtime_model_catalog
5
- } from "./cli-fb6t92v8.js";
5
+ } from "./cli-6x9ma5w5.js";
6
6
  import {
7
7
  buildClaudeShortnameMap,
8
8
  init_src2
9
- } from "./cli-x3en6ct3.js";
9
+ } from "./cli-nwyw3zhg.js";
10
10
 
11
11
  // src/utils/context-window.ts
12
12
  init_src2();
@@ -7,7 +7,7 @@ var package_default;
7
7
  var init_package = __esm(() => {
8
8
  package_default = {
9
9
  name: "@desplega.ai/agent-swarm",
10
- version: "2.3.0",
10
+ version: "2.4.1",
11
11
  description: "agent-swarm.dev — an open-source operating system for AI work: a lead agent breaks goals into tasks, routes them to specialized workers such as Claude Code or Codex, runs each worker in an isolated container, and preserves shared memory, tools, schedules, and review gates so delegated work compounds across sessions.",
12
12
  keywords: [
13
13
  "agent-swarm.dev",
@@ -207,7 +207,7 @@ var init_package = __esm(() => {
207
207
  dependencies: {
208
208
  "@agentclientprotocol/sdk": "1.9.0",
209
209
  "@ai-sdk/openai": "^3.0.41",
210
- "@anthropic-ai/claude-agent-sdk": "0.3.302",
210
+ "@anthropic-ai/claude-agent-sdk": "0.3.303",
211
211
  "@anthropic-ai/sdk": "^0.135.0",
212
212
  "@asteasolutions/zod-to-openapi": "^8.0.0",
213
213
  "@aws-sdk/client-bedrock": "3.1048.0",
@@ -4,7 +4,7 @@ import {
4
4
  CONTROLLER_COMMAND_TIMEOUT_MS,
5
5
  RuntimeHandleSchema,
6
6
  ControllerStatusResultSchema
7
- } from "./cli-d43xqzbe.js";
7
+ } from "./cli-hqhzg1qq.js";
8
8
  import {
9
9
  getDbClient2,
10
10
  isRuntimePoolsEnabled,
@@ -21,7 +21,7 @@ import {
21
21
  upsertSwarmConfig2,
22
22
  getResolvedConfig2,
23
23
  init_db3
24
- } from "./cli-re4wkbzx.js";
24
+ } from "./cli-rqqsfz30.js";
25
25
  import {
26
26
  runtimeStaleThresholdMinutes,
27
27
  getRuntimeInstanceById,
@@ -31,10 +31,8 @@ import {
31
31
  listRuntimeInstancesForPool,
32
32
  createWorkerTaskFollowUp,
33
33
  canClaim
34
- } from "./cli-8qsx817b.js";
34
+ } from "./cli-kr2pmfqx.js";
35
35
  import {
36
- mintRuntimeToken,
37
- init_users,
38
36
  getRuntimeController2,
39
37
  getRuntimeControllerTarget2,
40
38
  checkE2bControllerConfig2,
@@ -44,11 +42,11 @@ import {
44
42
  getPoolForAgent2,
45
43
  resolvePoolDelivery2,
46
44
  init_db
47
- } from "./cli-hz64bcnj.js";
45
+ } from "./cli-bn5kevnf.js";
48
46
  import {
49
47
  workflowEventBus2,
50
48
  init_event_bus
51
- } from "./cli-ptkpaqfy.js";
49
+ } from "./cli-wt645v7q.js";
52
50
  import {
53
51
  isMultiRuntimeEnabled
54
52
  } from "./cli-7a91w22y.js";
@@ -59,12 +57,16 @@ import {
59
57
  canProvisionKind,
60
58
  createRuntimeProvider,
61
59
  init_runtime_providers
62
- } from "./cli-wk8ccrz6.js";
60
+ } from "./cli-pw7v69vp.js";
61
+ import {
62
+ mintRuntimeToken,
63
+ init_users
64
+ } from "./cli-fz9kewbh.js";
63
65
  import {
64
66
  TERMINAL_TASK_STATUSES,
65
67
  isTerminalTaskStatus,
66
68
  init_types
67
- } from "./cli-yv0vgscc.js";
69
+ } from "./cli-fpmsqq59.js";
68
70
  import {
69
71
  init_zod
70
72
  } from "./cli-4chz1hye.js";
@@ -84,7 +86,7 @@ import {
84
86
  import {
85
87
  buildImageTemplate,
86
88
  init_dispatch
87
- } from "./cli-7gh7020n.js";
89
+ } from "./cli-1dmcq2eh.js";
88
90
  import {
89
91
  RUNTIME_LABELS,
90
92
  init_types2
@@ -93,7 +95,7 @@ import {
93
95
  scrubSecrets,
94
96
  registerVolatileSecret,
95
97
  init_secret_scrubber
96
- } from "./cli-4mkvwgzr.js";
98
+ } from "./cli-xf234ws8.js";
97
99
 
98
100
  // src/be/runtime-pools/supervisor.ts
99
101
  init_runtime_providers();
@@ -520,7 +522,7 @@ async function recoverSessions(runtimeId, reason) {
520
522
  }
521
523
  if (!sessions.length)
522
524
  return;
523
- const { remediateTaskForDeadRuntime } = await import("./heartbeat-h1w1ktce.js");
525
+ const { remediateTaskForDeadRuntime } = await import("./heartbeat-tww6yx1w.js");
524
526
  for (const session of sessions) {
525
527
  try {
526
528
  const task = await getTaskById2(session.taskId);
@@ -2,7 +2,7 @@ import {
2
2
  runtimeCatalogSection,
3
3
  runtimeCatalogModel,
4
4
  init_runtime_model_catalog
5
- } from "./cli-fb6t92v8.js";
5
+ } from "./cli-6x9ma5w5.js";
6
6
  import {
7
7
  dshCatalogRef,
8
8
  grokCatalogRef,
@@ -10,7 +10,7 @@ import {
10
10
  reasoningLevelsFor,
11
11
  claudeCatalogModelId,
12
12
  init_src2
13
- } from "./cli-x3en6ct3.js";
13
+ } from "./cli-nwyw3zhg.js";
14
14
 
15
15
  // src/providers/reasoning-effort.ts
16
16
  init_src2();
@@ -80,7 +80,7 @@ var ANTHROPIC_BUDGET_TOKENS_BY_LEVEL = {
80
80
  function buildOpencodeReasoningOptions(providerId, level) {
81
81
  if (providerId === "anthropic") {
82
82
  if (level === "max")
83
- return { reasoningEffort: level };
83
+ return { effort: level };
84
84
  return { thinking: { type: "enabled", budgetTokens: ANTHROPIC_BUDGET_TOKENS_BY_LEVEL[level] } };
85
85
  }
86
86
  if (providerId === "openrouter") {
@@ -4,25 +4,28 @@ import {
4
4
  getEncryptionKey,
5
5
  init_crypto,
6
6
  getDbClient2,
7
- scheduleOrgDomainRecompute,
8
- init_telemetry_identity,
9
7
  rowToAgent,
10
8
  createAgent2,
11
9
  getAgentById2,
12
10
  getAllAgents2,
13
11
  init_agents,
14
- validateRuntimeTokenTtlHours,
15
12
  validateControllerTokenTtlDays,
16
13
  init_swarm_config_guard,
17
14
  registerStoredSecret,
18
15
  init_secret_registry,
19
16
  upsertSwarmConfig2,
20
17
  init_db3
21
- } from "./cli-re4wkbzx.js";
18
+ } from "./cli-rqqsfz30.js";
22
19
  import {
23
20
  createRuntimeProvider,
24
21
  init_runtime_providers
25
- } from "./cli-wk8ccrz6.js";
22
+ } from "./cli-pw7v69vp.js";
23
+ import {
24
+ closeSessionTokenConnections,
25
+ init_session_token_connections,
26
+ insertSessionToken,
27
+ init_users
28
+ } from "./cli-fz9kewbh.js";
26
29
  import {
27
30
  RuntimeControllerCreateSchema,
28
31
  RuntimeControllerUpdateSchema,
@@ -30,382 +33,17 @@ import {
30
33
  RuntimePoolUpdateSchema,
31
34
  RuntimePoolCreateAgentSchema,
32
35
  init_types
33
- } from "./cli-yv0vgscc.js";
36
+ } from "./cli-fpmsqq59.js";
34
37
  import {
35
38
  scrubSecrets,
36
39
  registerVolatileSecret,
37
40
  unregisterVolatileSecret,
38
41
  init_secret_scrubber
39
- } from "./cli-4mkvwgzr.js";
42
+ } from "./cli-xf234ws8.js";
40
43
  import {
41
44
  __esm
42
45
  } from "./cli-242037k3.js";
43
46
 
44
- // src/utils/session-token-connections.ts
45
- function registerSessionTokenConnection(tokenId, close) {
46
- let callbacks = connections.get(tokenId);
47
- if (!callbacks) {
48
- callbacks = new Set;
49
- connections.set(tokenId, callbacks);
50
- }
51
- callbacks.add(close);
52
- return () => {
53
- callbacks.delete(close);
54
- if (callbacks.size === 0)
55
- connections.delete(tokenId);
56
- };
57
- }
58
- function closeSessionTokenConnections(tokenIds) {
59
- for (const tokenId of tokenIds) {
60
- for (const close of connections.get(tokenId) ?? [])
61
- close();
62
- }
63
- }
64
- var connections;
65
- var init_session_token_connections = __esm(() => {
66
- connections = new Map;
67
- });
68
-
69
- // src/be/users.ts
70
- import { createHash, randomBytes, randomUUID } from "node:crypto";
71
- function actorString(actor) {
72
- return `${actor.kind}:${actor.id}`;
73
- }
74
- function rowToUser(row) {
75
- return {
76
- id: row.id,
77
- name: row.name,
78
- email: row.email ?? undefined,
79
- role: row.role ?? undefined,
80
- notes: row.notes ?? undefined,
81
- emailAliases: row.emailAliases ? JSON.parse(row.emailAliases) : [],
82
- preferredChannel: row.preferredChannel ?? "slack",
83
- timezone: row.timezone ?? undefined,
84
- metadata: row.metadata ? JSON.parse(row.metadata) : undefined,
85
- dailyBudgetUsd: row.dailyBudgetUsd ?? null,
86
- status: row.status ?? "active",
87
- createdAt: row.createdAt,
88
- lastUpdatedAt: row.lastUpdatedAt
89
- };
90
- }
91
- async function findUserById(id) {
92
- const row = await getDbClient2().get("SELECT * FROM users WHERE id = ?", [id]);
93
- return row ? rowToUser(row) : null;
94
- }
95
- async function findUserByExternalId(kind, externalId) {
96
- const row = await getDbClient2().get(`SELECT u.* FROM users u
97
- INNER JOIN user_external_ids x ON x.userId = u.id
98
- WHERE x.kind = ? AND x.externalId = ?`, [kind, externalId]);
99
- return row ? rowToUser(row) : null;
100
- }
101
- async function findUserByEmail(email) {
102
- const lower = email.toLowerCase();
103
- const db = getDbClient2();
104
- const primary = await db.get("SELECT * FROM users WHERE LOWER(email) = LOWER(?)", [
105
- email
106
- ]);
107
- if (primary)
108
- return rowToUser(primary);
109
- const aliasRows = await db.query("SELECT * FROM users WHERE emailAliases IS NOT NULL AND emailAliases != '[]'");
110
- for (const r of aliasRows) {
111
- const aliases = r.emailAliases ? JSON.parse(r.emailAliases) : [];
112
- if (aliases.some((a) => a.toLowerCase() === lower)) {
113
- return rowToUser(r);
114
- }
115
- }
116
- return null;
117
- }
118
- async function findUsersByName(name) {
119
- const trimmed = name.trim();
120
- if (!trimmed)
121
- return [];
122
- const client = getDbClient2();
123
- const exact = await client.query("SELECT * FROM users WHERE LOWER(name) = LOWER(?)", [
124
- trimmed
125
- ]);
126
- if (exact.length > 0)
127
- return exact.map(rowToUser);
128
- const firstToken = trimmed.split(/\s+/)[0] ?? trimmed;
129
- const prefixed = await client.query("SELECT * FROM users WHERE LOWER(name) LIKE LOWER(?) || '%'", [firstToken]);
130
- return prefixed.map(rowToUser);
131
- }
132
- async function getUserIdentities(userId) {
133
- return getDbClient2().query("SELECT kind, externalId FROM user_external_ids WHERE userId = ? ORDER BY kind, externalId", [userId]);
134
- }
135
- function rowToEvent(row) {
136
- return {
137
- id: row.id,
138
- userId: row.userId,
139
- eventType: row.eventType,
140
- actor: row.actor,
141
- before: row.beforeJson == null ? null : JSON.parse(row.beforeJson),
142
- after: row.afterJson == null ? null : JSON.parse(row.afterJson),
143
- createdAt: row.createdAt
144
- };
145
- }
146
- async function listUserEvents(userId, opts = {}) {
147
- const limit = Math.max(1, Math.min(opts.limit ?? 50, 200));
148
- const before = opts.before;
149
- const client = getDbClient2();
150
- if (before) {
151
- const rows = await client.query(`SELECT id, userId, eventType, actor, beforeJson, afterJson, createdAt
152
- FROM user_identity_events
153
- WHERE userId = ? AND createdAt < ?
154
- ORDER BY createdAt DESC, rowid DESC
155
- LIMIT ?`, [userId, before, limit]);
156
- return rows.map(rowToEvent);
157
- }
158
- const rows = await client.query(`SELECT id, userId, eventType, actor, beforeJson, afterJson, createdAt
159
- FROM user_identity_events
160
- WHERE userId = ?
161
- ORDER BY createdAt DESC, rowid DESC
162
- LIMIT ?`, [userId, limit]);
163
- return rows.map(rowToEvent);
164
- }
165
- async function listUserTokens(userId) {
166
- return getDbClient2().query(`SELECT id, userId, label, tokenPreview, createdAt, lastUsedAt, revokedAt
167
- FROM user_tokens
168
- WHERE userId = ?
169
- ORDER BY createdAt DESC`, [userId]);
170
- }
171
- async function recordIdentityEvent(userId, eventType, actor, before, after) {
172
- await getDbClient2().run(`INSERT INTO user_identity_events (id, userId, eventType, actor, beforeJson, afterJson, createdAt)
173
- VALUES (?, ?, ?, ?, ?, ?, ?)`, [
174
- randomUUID().replace(/-/g, ""),
175
- userId,
176
- eventType,
177
- actorString(actor),
178
- before == null ? null : JSON.stringify(before),
179
- after == null ? null : JSON.stringify(after),
180
- new Date().toISOString()
181
- ]);
182
- }
183
- async function findOrCreateUserByEmail(email, hints, actor) {
184
- const existing = await findUserByEmail(email);
185
- if (existing) {
186
- await recordIdentityEvent(existing.id, "auto_merge", actor, null, { email, hints });
187
- return { user: existing, created: false };
188
- }
189
- const id = randomUUID().replace(/-/g, "");
190
- const now = new Date().toISOString();
191
- const name = hints.name?.trim() || email.split("@")[0] || email;
192
- const created = await getDbClient2().transaction(async (tx) => {
193
- await tx.run(`INSERT INTO users (id, name, email, role, notes, emailAliases, preferredChannel, timezone, createdAt, lastUpdatedAt, status)
194
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'active')`, [
195
- id,
196
- name,
197
- email,
198
- hints.role ?? null,
199
- hints.notes ?? null,
200
- "[]",
201
- hints.preferredChannel ?? "slack",
202
- null,
203
- now,
204
- now
205
- ]);
206
- const row = await tx.get("SELECT * FROM users WHERE id = ?", [id]);
207
- if (!row)
208
- throw new Error("Failed to create user");
209
- await recordIdentityEvent(id, "identity_added", actor, null, { email, name });
210
- return rowToUser(row);
211
- });
212
- getDbClient2().afterCommit(scheduleOrgDomainRecompute);
213
- return { user: created, created: true };
214
- }
215
- async function linkIdentity(userId, kind, externalId, actor) {
216
- await getDbClient2().transaction(async (tx) => {
217
- await tx.run("INSERT INTO user_external_ids (userId, kind, externalId) VALUES (?, ?, ?)", [
218
- userId,
219
- kind,
220
- externalId
221
- ]);
222
- await recordIdentityEvent(userId, "identity_added", actor, null, { kind, externalId });
223
- });
224
- }
225
- async function unlinkIdentity(userId, kind, externalId, actor) {
226
- await getDbClient2().transaction(async (tx) => {
227
- await tx.run("DELETE FROM user_external_ids WHERE userId = ? AND kind = ? AND externalId = ?", [
228
- userId,
229
- kind,
230
- externalId
231
- ]);
232
- await recordIdentityEvent(userId, "identity_removed", actor, { kind, externalId }, null);
233
- });
234
- }
235
- function base62(bytes) {
236
- const alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
237
- let out = "";
238
- for (const b of bytes) {
239
- out += alphabet[b % 62];
240
- }
241
- return out;
242
- }
243
- function sha256Hex(input) {
244
- return createHash("sha256").update(input).digest("hex");
245
- }
246
- async function mintToken(userId, label, actor, options = {}) {
247
- const plaintext = `${TOKEN_PREFIX}${base62(randomBytes(24))}`;
248
- const tokenId = randomUUID().replace(/-/g, "");
249
- const hash = sha256Hex(plaintext);
250
- const preview = plaintext.slice(-4);
251
- const now = new Date().toISOString();
252
- await getDbClient2().transaction(async (tx) => {
253
- await tx.run(`INSERT INTO user_tokens (id, userId, label, tokenHash, tokenPreview, createdAt)
254
- VALUES (?, ?, ?, ?, ?, ?)`, [tokenId, userId, label, hash, preview, now]);
255
- await recordIdentityEvent(userId, "token_minted", actor, null, {
256
- tokenId,
257
- label,
258
- preview,
259
- ...options.source ? { source: options.source } : {}
260
- });
261
- });
262
- return { tokenId, plaintext };
263
- }
264
- async function revokeToken(tokenId, actor) {
265
- await getDbClient2().transaction(async (tx) => {
266
- const row = await tx.get("SELECT userId, label, tokenPreview FROM user_tokens WHERE id = ?", [tokenId]);
267
- if (!row) {
268
- throw new Error(`Token not found: ${tokenId}`);
269
- }
270
- await tx.run("UPDATE user_tokens SET revokedAt = ? WHERE id = ?", [
271
- new Date().toISOString(),
272
- tokenId
273
- ]);
274
- await recordIdentityEvent(row.userId, "token_revoked", actor, { tokenId, label: row.label, preview: row.tokenPreview }, null);
275
- });
276
- }
277
- async function resolveUserByToken(plaintext) {
278
- const hash = sha256Hex(plaintext);
279
- const client = getDbClient2();
280
- const row = await client.get("SELECT id, userId, revokedAt FROM user_tokens WHERE tokenHash = ?", [hash]);
281
- if (!row || row.revokedAt !== null)
282
- return null;
283
- try {
284
- await client.run("UPDATE user_tokens SET lastUsedAt = ? WHERE id = ?", [
285
- new Date().toISOString(),
286
- row.id
287
- ]);
288
- } catch {}
289
- return findUserById(row.userId);
290
- }
291
- async function mintSessionToken(agentId, taskId, ttlMs, parent) {
292
- if (parent) {
293
- return await getDbClient2().transaction(async (client) => {
294
- const row = await client.get(`SELECT expiresAt FROM session_tokens WHERE id = ? AND agentId = ? AND runtimeId = ?
295
- AND revokedAt IS NULL AND expiresAt > ?`, [parent.tokenId, agentId, parent.runtimeId, new Date().toISOString()]);
296
- if (!row)
297
- throw new InvalidRuntimeTokenError;
298
- return await insertSessionToken(agentId, taskId, null, ttlMs, parent.runtimeId, row.expiresAt);
299
- });
300
- }
301
- return await insertSessionToken(agentId, taskId, null, ttlMs);
302
- }
303
- function runtimeTokenTtlMs() {
304
- const hours = process.env.RUNTIME_TOKEN_TTL_HOURS ?? "168";
305
- return (validateRuntimeTokenTtlHours(hours) === null ? Number(hours) : 168) * 60 * 60 * 1000;
306
- }
307
- async function mintRuntimeToken(agentId, runtimeId, ttlMs = runtimeTokenTtlMs()) {
308
- return await insertSessionToken(agentId, null, runtimeId, ttlMs);
309
- }
310
- async function insertSessionToken(agentId, taskId, runtimeId, ttlMs, parentRuntimeId = null, expiresAtCeiling, controllerId = null) {
311
- const plaintext = `${SESSION_TOKEN_PREFIX}${base62(randomBytes(24))}`;
312
- const tokenId = randomUUID().replace(/-/g, "");
313
- const hash = sha256Hex(plaintext);
314
- const preview = plaintext.slice(-4);
315
- const now = new Date;
316
- const expiresAt = new Date(Math.min(now.getTime() + ttlMs, expiresAtCeiling ? Date.parse(expiresAtCeiling) : Infinity)).toISOString();
317
- await getDbClient2().run(`INSERT INTO session_tokens
318
- (id, tokenHash, tokenPreview, agentId, taskId, runtimeId, parentRuntimeId, expiresAt, createdAt, controllerId)
319
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
320
- tokenId,
321
- hash,
322
- preview,
323
- agentId,
324
- taskId,
325
- runtimeId,
326
- parentRuntimeId,
327
- expiresAt,
328
- now.toISOString(),
329
- controllerId
330
- ]);
331
- return { tokenId, plaintext };
332
- }
333
- async function revokeSessionToken(tokenId) {
334
- await getDbClient2().transaction(async (client) => {
335
- const row = await client.get("SELECT runtimeId FROM session_tokens WHERE id = ?", [tokenId]);
336
- if (row?.runtimeId) {
337
- await revokeRuntimeTokensForRuntime(row.runtimeId);
338
- } else {
339
- await client.run("UPDATE session_tokens SET revokedAt = ? WHERE id = ? AND revokedAt IS NULL", [new Date().toISOString(), tokenId]);
340
- getDbClient2().afterCommit(() => closeSessionTokenConnections([tokenId]));
341
- }
342
- });
343
- }
344
- async function revokeRuntimeTokensForRuntime(runtimeId) {
345
- await getDbClient2().transaction(async (client) => {
346
- const rows = await client.query("SELECT id FROM session_tokens WHERE runtimeId = ? OR parentRuntimeId = ?", [runtimeId, runtimeId]);
347
- await client.run(`UPDATE session_tokens SET revokedAt = ?
348
- WHERE (runtimeId = ? OR parentRuntimeId = ?) AND revokedAt IS NULL`, [new Date().toISOString(), runtimeId, runtimeId]);
349
- getDbClient2().afterCommit(() => {
350
- unregisterVolatileSecret(`runtime:${runtimeId}`);
351
- closeSessionTokenConnections(rows.map((row) => row.id));
352
- });
353
- });
354
- }
355
- async function resolveSessionToken(plaintext, options = {}) {
356
- if (!plaintext.startsWith(SESSION_TOKEN_PREFIX))
357
- return null;
358
- const hash = sha256Hex(plaintext);
359
- const client = getDbClient2();
360
- const row = await client.get(`SELECT s.id, s.agentId, s.taskId, s.runtimeId, s.controllerId, s.expiresAt, s.revokedAt,
361
- c.placement FROM session_tokens s LEFT JOIN runtime_controllers c ON c.id = s.controllerId
362
- WHERE s.tokenHash = ?`, [hash]);
363
- if (!row || row.revokedAt !== null)
364
- return null;
365
- if (new Date(row.expiresAt) <= new Date)
366
- return null;
367
- if (row.controllerId !== null) {
368
- return row.placement === "remote" ? {
369
- kind: "controller",
370
- controllerId: row.controllerId,
371
- tokenId: row.id,
372
- expiresAt: row.expiresAt
373
- } : null;
374
- }
375
- if (options.touch !== false) {
376
- try {
377
- await client.run("UPDATE session_tokens SET lastUsedAt = ? WHERE id = ?", [
378
- new Date().toISOString(),
379
- row.id
380
- ]);
381
- } catch {}
382
- }
383
- return {
384
- kind: "agent",
385
- tokenId: row.id,
386
- agentId: row.agentId,
387
- taskId: row.taskId,
388
- runtimeId: row.runtimeId,
389
- expiresAt: row.expiresAt
390
- };
391
- }
392
- function fingerprintApiKey(rawKey) {
393
- return `op:${sha256Hex(rawKey).slice(0, 16)}`;
394
- }
395
- var TOKEN_PREFIX = "aswt_", SESSION_TOKEN_PREFIX = "aseph_", InvalidRuntimeTokenError;
396
- var init_users = __esm(() => {
397
- init_telemetry_identity();
398
- init_secret_scrubber();
399
- init_session_token_connections();
400
- init_db3();
401
- init_swarm_config_guard();
402
- InvalidRuntimeTokenError = class InvalidRuntimeTokenError extends Error {
403
- constructor() {
404
- super("Runtime token is no longer valid");
405
- }
406
- };
407
- });
408
-
409
47
  // src/be/runtime-pools/errors.ts
410
48
  var RuntimePoolError2;
411
49
  var init_errors = __esm(() => {
@@ -829,4 +467,4 @@ var init_db = __esm(() => {
829
467
  init_errors();
830
468
  });
831
469
 
832
- export { RuntimePoolError2, registerSessionTokenConnection, init_session_token_connections, findUserById, findUserByExternalId, findUserByEmail, findUsersByName, getUserIdentities, listUserEvents, listUserTokens, recordIdentityEvent, findOrCreateUserByEmail, linkIdentity, unlinkIdentity, mintToken, revokeToken, resolveUserByToken, InvalidRuntimeTokenError, mintSessionToken, mintRuntimeToken, revokeSessionToken, revokeRuntimeTokensForRuntime, resolveSessionToken, fingerprintApiKey, init_users, mintControllerToken, init_tokens, listRuntimeControllers2, getRuntimeController2, getRuntimeControllerTarget2, checkE2bControllerConfig2, createRuntimeController2, updateRuntimeController2, deleteRuntimeController2, listRuntimePools2, getRuntimePool2, createRuntimePool2, updateRuntimePool2, deleteRuntimePool2, bindAgentToPool2, listAgentsForPool2, getPoolForAgent2, resolvePoolDelivery2, createPoolAgent2, loadRuntimeControllerSecrets2, init_db };
470
+ export { RuntimePoolError2, mintControllerToken, init_tokens, listRuntimeControllers2, getRuntimeController2, getRuntimeControllerTarget2, checkE2bControllerConfig2, createRuntimeController2, updateRuntimeController2, deleteRuntimeController2, listRuntimePools2, getRuntimePool2, createRuntimePool2, updateRuntimePool2, deleteRuntimePool2, bindAgentToPool2, listAgentsForPool2, getPoolForAgent2, resolvePoolDelivery2, createPoolAgent2, loadRuntimeControllerSecrets2, init_db };
@@ -34,7 +34,7 @@ import {
34
34
  stream4,
35
35
  streamSimple2,
36
36
  completeSimple
37
- } from "./cli-8cvvytad.js";
37
+ } from "./cli-8nyhf7za.js";
38
38
  import {
39
39
  parseStreamingJson
40
40
  } from "./cli-kvzgak7c.js";
@@ -54114,7 +54114,7 @@ function loadAllHighlightLanguages() {
54114
54114
  if (!allLanguagesPromise) {
54115
54115
  allLanguagesPromise = new Promise((resolve) => {
54116
54116
  setImmediate(() => {
54117
- import("./index-wgsw9xcz.js").then((m)=>__toESM(m.default,1)).then(() => resolve(), () => {
54117
+ import("./index-g6tbb6ve.js").then((m)=>__toESM(m.default,1)).then(() => resolve(), () => {
54118
54118
  resolve();
54119
54119
  });
54120
54120
  });
@@ -60228,7 +60228,7 @@ function getCreateJiti() {
60228
60228
  }
60229
60229
  var virtualModulesPromise;
60230
60230
  function getVirtualModules() {
60231
- virtualModulesPromise ??= import("./virtual-modules-wzk6jf3a.js").then((module) => module.VIRTUAL_MODULES);
60231
+ virtualModulesPromise ??= import("./virtual-modules-4r3zkc20.js").then((module) => module.VIRTUAL_MODULES);
60232
60232
  return virtualModulesPromise;
60233
60233
  }
60234
60234
  var _aliases = null;
@@ -79942,7 +79942,7 @@ function parseCodemodeSource(input) {
79942
79942
  }
79943
79943
 
79944
79944
  // node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/execute.lazy.js
79945
- var loadCodemodeExecutor = () => import("./execute-bcqc69a5.js");
79945
+ var loadCodemodeExecutor = () => import("./execute-t4e6m3rw.js");
79946
79946
 
79947
79947
  // node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/renderer.js
79948
79948
  var CODE_PREVIEW_LINES = 10;
@@ -81098,7 +81098,7 @@ function createMcpResourceToolDefinitions(options) {
81098
81098
  }
81099
81099
 
81100
81100
  // node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/runtime.lazy.js
81101
- var loadMcpRuntime = () => import("./runtime-ar8310ba.js");
81101
+ var loadMcpRuntime = () => import("./runtime-xe3aqy4x.js");
81102
81102
 
81103
81103
  // node_modules/@earendil-works/pi-coding-agent/dist/utils/clipboard.js
81104
81104
  import { randomUUID as randomUUID3 } from "node:crypto";
@@ -86218,7 +86218,7 @@ var builtInExtensions = [
86218
86218
  ];
86219
86219
 
86220
86220
  // node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/cli.lazy.js
86221
- var loadMcpCommand = () => import("./cli-azs9bhc5.js");
86221
+ var loadMcpCommand = () => import("./cli-j4rqdf2n.js");
86222
86222
 
86223
86223
  // node_modules/@earendil-works/pi-coding-agent/dist/migrations.js
86224
86224
  import { existsSync as existsSync23, mkdirSync as mkdirSync11, readdirSync as readdirSync10, readFileSync as readFileSync17, renameSync as renameSync2, rmSync as rmSync3, writeFileSync as writeFileSync11 } from "fs";
@@ -88745,7 +88745,7 @@ function playEasterEgg3d(tui, egg) {
88745
88745
  if (tui.hasOverlay())
88746
88746
  return true;
88747
88747
  const screen = tui.getScreenLines();
88748
- import("./easter-egg-3d-6hg2r942.js").then((module) => module.playEasterEgg3d(tui, screen, egg), () => {});
88748
+ import("./easter-egg-3d-5cgynaja.js").then((module) => module.playEasterEgg3d(tui, screen, egg), () => {});
88749
88749
  return true;
88750
88750
  }
88751
88751
  function playPiLogo3d(tui, column, row) {