@desplega.ai/agent-swarm 1.165.0 → 1.167.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (296) hide show
  1. package/dist/acp-adapter-zpvy6321.js +34 -0
  2. package/dist/{actions-jna0b3wm.js → actions-fq2zrwtf.js} +30 -34
  3. package/dist/{amp-adapter-0eve81pz.js → amp-adapter-5gbk7501.js} +7 -7
  4. package/dist/{anthropic-messages-hst62ws9.js → anthropic-messages-13yn502s.js} +4 -4
  5. package/dist/{app-75hm5cfa.js → app-nctetn1e.js} +11 -11
  6. package/dist/{assistant-yzd51j33.js → assistant-0aq8gjvj.js} +31 -35
  7. package/dist/{azure-openai-responses-mh8tvf78.js → azure-openai-responses-9st34pfz.js} +5 -5
  8. package/dist/{boot-reembed-z158xq32.js → boot-reembed-1ze5853n.js} +14 -16
  9. package/dist/{boot-reembed-2ex2mcsh.js → boot-reembed-fmp5ww69.js} +15 -16
  10. package/dist/boot-scrub-sweep-cbp8xd4e.js +212 -0
  11. package/dist/{boot-seeds-2bmnh18p.js → boot-seeds-22tx8a53.js} +13 -12
  12. package/dist/{claude-adapter-jbj1mycz.js → claude-adapter-0jhgeh1d.js} +25 -25
  13. package/dist/{claude-managed-adapter-17ggz09t.js → claude-managed-adapter-tzwxy803.js} +5 -5
  14. package/dist/{claude-managed-setup-ptm1nzm2.js → claude-managed-setup-nrhfx5b0.js} +5 -5
  15. package/dist/{claude-sdk-session-9re1g7r2.js → claude-sdk-session-wh77rh83.js} +2632 -2614
  16. package/dist/{cli-zsh093hk.js → cli-014vns2y.js} +63 -1
  17. package/dist/{cli-qvfk83fy.js → cli-13xwcqvj.js} +2 -2
  18. package/dist/{cli-8gpbwy09.js → cli-1yrcfa5s.js} +5 -5
  19. package/dist/{cli-xtgtyafv.js → cli-577bxkf6.js} +212 -451
  20. package/dist/{cli-ma3zvh39.js → cli-5qkcdv8c.js} +6118 -5874
  21. package/dist/{cli-cwxhbf43.js → cli-5t5my0h8.js} +85 -2
  22. package/dist/{cli-zvckv750.js → cli-69egj654.js} +2 -2
  23. package/dist/{cli-9xb89xca.js → cli-6bpvv8h4.js} +9 -9
  24. package/dist/{cli-90v942q1.js → cli-6qxmjpem.js} +8 -8
  25. package/dist/{cli-9866bd07.js → cli-6vfz44sr.js} +1 -1
  26. package/dist/{cli-32bca7nr.js → cli-7avy4v8w.js} +1 -1
  27. package/dist/{cli-xb3c6aat.js → cli-7mhy3ths.js} +21 -18
  28. package/dist/{cli-q38n4bq0.js → cli-95zs84qw.js} +3 -3
  29. package/dist/cli-a35hzdve.js +33 -0
  30. package/dist/{cli-x3x0qwky.js → cli-bxqez1p0.js} +51 -23
  31. package/dist/{cli-prt9emct.js → cli-c2tpw9ck.js} +3 -3
  32. package/dist/{cli-0n4fasz0.js → cli-c8r99akr.js} +16 -16
  33. package/dist/{cli-5anb0ev3.js → cli-cexctgn5.js} +89 -26
  34. package/dist/{cli-bns5c8k9.js → cli-cf2vgn9d.js} +105 -91
  35. package/dist/{cli-ng97fjq7.js → cli-cmxkbzzs.js} +33 -7
  36. package/dist/{cli-nexwh8zg.js → cli-g7k7zbcz.js} +12 -5
  37. package/dist/{cli-mmzwwptd.js → cli-hf5s9pgf.js} +1 -1
  38. package/dist/{cli-nvvfd8bq.js → cli-jbzbr36n.js} +4091 -3793
  39. package/dist/{cli-zn2v3t8v.js → cli-jvmtxqtc.js} +27 -15
  40. package/dist/{cli-pkke6geq.js → cli-km4x66j0.js} +83 -65
  41. package/dist/cli-kw0jcfje.js +516 -0
  42. package/dist/{cli-28smfvbn.js → cli-m7vmeepg.js} +32 -19
  43. package/dist/{cli-hpryr6em.js → cli-mb75wpxf.js} +1 -1
  44. package/dist/{cli-qdv8kgz7.js → cli-mkdsy1nq.js} +14018 -3333
  45. package/dist/{cli-b0f70z24.js → cli-mn8qkd8v.js} +1 -1
  46. package/dist/{cli-420bdgw0.js → cli-mv2520nm.js} +1 -1
  47. package/dist/{cli-n9ehc28t.js → cli-mxry91sa.js} +31 -10
  48. package/dist/{cli-wfajtmf7.js → cli-mxvnnv5q.js} +596 -13
  49. package/dist/cli-nkqjj42q.js +104 -0
  50. package/dist/{cli-e7t4snpa.js → cli-p8rt8spp.js} +5 -5
  51. package/dist/{cli-gh5yqzpe.js → cli-pkj1w46r.js} +12 -7
  52. package/dist/cli-q1vnz8wv.js +96 -0
  53. package/dist/{cli-fj86xr3c.js → cli-qd97v6z2.js} +2 -2
  54. package/dist/{cli-ba66wyhy.js → cli-qzmzwegq.js} +60 -20
  55. package/dist/{cli-5b2fjjzh.js → cli-r7eeddkq.js} +14 -9
  56. package/dist/{cli-8ssjez7e.js → cli-rhy7z1rp.js} +22 -11
  57. package/dist/{cli-4mevd1hf.js → cli-s9y81s7j.js} +5 -5
  58. package/dist/{cli-59jn5twa.js → cli-tc5zec7v.js} +7 -7
  59. package/dist/{cli-ttbsse3f.js → cli-tmhsxhb8.js} +1 -1
  60. package/dist/{cli-k6xx3pve.js → cli-tx2zvn23.js} +4 -4
  61. package/dist/{cli-pjxnr1jn.js → cli-ty4bzkqr.js} +5 -5
  62. package/dist/{cli-nfygw434.js → cli-v1pwxreq.js} +55 -52
  63. package/dist/{cli-ftry7975.js → cli-v1w7pbd8.js} +3 -2
  64. package/dist/{cli-10zmp1p7.js → cli-vr5avem2.js} +27 -32
  65. package/dist/{cli-bzr0ftht.js → cli-wnb9b2g3.js} +19 -0
  66. package/dist/cli-wt7ccy4r.js +2654 -0
  67. package/dist/{cli-50eg13rj.js → cli-wydz3feg.js} +549 -321
  68. package/dist/{cli-krqm5f11.js → cli-xezn9nkh.js} +16 -13
  69. package/dist/{cli-8kt0bmgx.js → cli-xf713zz0.js} +2 -2
  70. package/dist/{cli-x7afk5wm.js → cli-xvc3q9br.js} +1 -1
  71. package/dist/{cli-9s3h836g.js → cli-xvdgasgy.js} +1 -1
  72. package/dist/{cli-j0pdrmwg.js → cli-y0kjpfm9.js} +3 -3
  73. package/dist/{cli-6zcfw0x7.js → cli-y195hv1a.js} +1 -1
  74. package/dist/{cli-amwhs8h2.js → cli-ykt8f7va.js} +22 -9
  75. package/dist/{cli-1kzfvd1z.js → cli-ymmc1zxg.js} +15 -11
  76. package/dist/{cli-xnzrzets.js → cli-ypgba1a8.js} +2 -2
  77. package/dist/{cli-bdv39kgj.js → cli-z1dqhc9y.js} +31 -20
  78. package/dist/{cli-fw6vdcq5.js → cli-zp67qg5x.js} +34 -1
  79. package/dist/{cli-qbksc292.js → cli-zy39d433.js} +2 -0
  80. package/dist/cli.js +36 -32
  81. package/dist/{cloudflare-workers-ai-system-one-tt484t61.js → cloudflare-workers-ai-system-one-sta45jf9.js} +7 -5
  82. package/dist/{codex-adapter-3qnxshje.js → codex-adapter-cgesnjkr.js} +20 -20
  83. package/dist/{codex-login-brkxhhdg.js → codex-login-g1cyt5zm.js} +2 -2
  84. package/dist/{codex-session-runner-612wnapp.js → codex-session-runner-8kd7ddhr.js} +20 -20
  85. package/dist/{commands-2ybfcxkj.js → commands-h6zaaxym.js} +11 -10
  86. package/dist/{cursor-adapter-p3jgdehv.js → cursor-adapter-v8mm6bp5.js} +7 -7
  87. package/dist/{db-f4ans0jj.js → db-qg3myn53.js} +13 -10
  88. package/dist/{devin-adapter-dhzt01ff.js → devin-adapter-bffjj5n4.js} +2 -2
  89. package/dist/{dispatcher-pk182apd.js → dispatcher-7vnwj9qw.js} +28 -32
  90. package/dist/{dsh-adapter-7twaeps1.js → dsh-adapter-tz6hfp5r.js} +7 -7
  91. package/dist/{e2b-y8t3jzyz.js → e2b-nd50eccg.js} +1 -1
  92. package/dist/{easter-egg-3d-mtpnw06s.js → easter-egg-3d-66zxervv.js} +2 -2
  93. package/dist/{event-bus-w7ac4n3c.js → event-bus-vnfthafg.js} +2 -2
  94. package/dist/{execute-s4ccjq3n.js → execute-h4jgevyw.js} +61 -11
  95. package/dist/{google-generative-ai-d6nphg3q.js → google-generative-ai-b8zxrpax.js} +5 -5
  96. package/dist/{google-vertex-cpshkref.js → google-vertex-nrdd697t.js} +5 -5
  97. package/dist/grok-adapter-jdt2dz2s.js +39 -0
  98. package/dist/{handlers-g2wnr4t9.js → handlers-2qtkpncr.js} +31 -35
  99. package/dist/{hook-f7jt9vnm.js → hook-51yfcgsv.js} +48 -39
  100. package/dist/{hook-bbdpnkb4.js → hook-qnbdgwvd.js} +15 -17
  101. package/dist/{http-w40q4w94.js → http-jsmtag08.js} +536 -231
  102. package/dist/{index-056j5kzn.js → index-2t9kesn1.js} +13 -12
  103. package/dist/{index-cj1r9q83.js → index-bt8wkv1w.js} +29 -33
  104. package/dist/{index-7n70jwbb.js → index-cx1sb9bq.js} +42 -35
  105. package/dist/{index-9bfssf54.js → index-ekywyv2v.js} +28 -32
  106. package/dist/{index-fdk1t4d6.js → index-n0rxa4ca.js} +11962 -9900
  107. package/dist/{index-k8xc083e.js → index-t4g06w93.js} +28 -32
  108. package/dist/{keepalive-1tj10tf4.js → keepalive-4aezx4bj.js} +16 -12
  109. package/dist/{lead-st0bg7v4.js → lead-r44bkpm5.js} +52 -56
  110. package/dist/{llama-cpp-classify-tgj35k8d.js → llama-cpp-classify-6erb7wwv.js} +3 -1
  111. package/dist/{maintenance-nz71zats.js → maintenance-grz5jrzh.js} +12 -13
  112. package/dist/{mistral-conversations-8445ddjn.js → mistral-conversations-059y51zt.js} +4 -4
  113. package/dist/{node-f0ykebbv.js → node-qm9eb6z0.js} +25 -7
  114. package/dist/{oauth-refresh-sweep-aefzwvvq.js → oauth-refresh-sweep-wm4ctjfj.js} +15 -11
  115. package/dist/{onboard-kgpr9mbn.js → onboard-v60zgqf0.js} +2 -2
  116. package/dist/{openai-codex-responses-9ynm88zy.js → openai-codex-responses-jzxkta9b.js} +8 -7
  117. package/dist/{openai-completions-nhqwjmaw.js → openai-completions-663yncfq.js} +4 -4
  118. package/dist/openai-decisions-vj9nkpf8.js +162 -0
  119. package/dist/{openai-responses-xx1c4kgm.js → openai-responses-m3g43rrt.js} +5 -5
  120. package/dist/{opencode-adapter-0c8e70dk.js → opencode-adapter-yjyqynzf.js} +8 -8
  121. package/dist/{openrouter-images-8yx3487g.js → openrouter-images-kr60n6b9.js} +1 -1
  122. package/dist/{otel-impl-x8zp4y5a.js → otel-impl-ghh4dyf8.js} +2 -2
  123. package/dist/{pi-messages-vxdt8v7j.js → pi-messages-xszk613n.js} +1 -1
  124. package/dist/{pi-mono-adapter-t280ah5c.js → pi-mono-adapter-0eg8kw2c.js} +69 -52
  125. package/dist/{pricing-refresh-9e0q7cwk.js → pricing-refresh-mjrqvnvw.js} +12 -11
  126. package/dist/{rbac-roles-790j3ga8.js → rbac-roles-axv4d74x.js} +11 -10
  127. package/dist/{rbac-roles-kcp6zge2.js → rbac-roles-fd5tskj9.js} +11 -10
  128. package/dist/{render-v2-tch4nefj.js → render-v2-k50j33qd.js} +11 -11
  129. package/dist/{runtime-v2t1r79e.js → runtime-h9ha1mq6.js} +4 -4
  130. package/dist/{setup-rcm303ns.js → setup-4syh0pd2.js} +2 -2
  131. package/dist/{typesafe-system-one-datfr82p.js → typesafe-system-one-e988vty7.js} +7 -5
  132. package/dist/{virtual-modules-wm8mxdxx.js → virtual-modules-ftr9kwe8.js} +11 -11
  133. package/dist/{work-objects-ctg7t70w.js → work-objects-jcdbg8rr.js} +32 -36
  134. package/dist/{worker-5dp0xm55.js → worker-x8j8c9sx.js} +52 -56
  135. package/dist/{x-v3yw66zs.js → x-ma4gnfgy.js} +2 -2
  136. package/openapi.json +5 -2
  137. package/package.json +15 -11
  138. package/src/be/automation-preflight.ts +9 -4
  139. package/src/be/boot-scrub-sweep.ts +302 -0
  140. package/src/be/crypto/key-bootstrap.ts +1 -1
  141. package/src/be/db/approvals.ts +15 -1
  142. package/src/be/db/codex-oauth-device-flows.ts +40 -0
  143. package/src/be/db/config-secrets.ts +31 -0
  144. package/src/be/db/runtime.ts +4 -0
  145. package/src/be/db/script-runs.ts +15 -0
  146. package/src/be/db/tasks/write.ts +1 -1
  147. package/src/be/db-queries/mcp-oauth.ts +5 -0
  148. package/src/be/db-queries/oauth.ts +77 -0
  149. package/src/be/db.ts +162 -59
  150. package/src/be/events.ts +17 -1
  151. package/src/be/memory/index-content.ts +2 -2
  152. package/src/be/memory/providers/openai-embedding.ts +7 -2
  153. package/src/be/memory/providers/sqlite-store.ts +63 -11
  154. package/src/be/memory/raters/llm-summarizer.ts +7 -2
  155. package/src/be/memory/types.ts +14 -0
  156. package/src/be/migrations/201_workflow_replay_columns.sql +10 -0
  157. package/src/be/migrations/202_codex_oauth_device_flows.sql +24 -0
  158. package/src/be/modelsdev-cache.json +61 -0
  159. package/src/be/scripts/db.ts +28 -4
  160. package/src/be/scripts/source-secrets.ts +37 -0
  161. package/src/be/scrub-json.ts +32 -0
  162. package/src/be/sealed-json.ts +59 -0
  163. package/src/be/secret-registry.ts +131 -0
  164. package/src/be/seed-pricing.ts +84 -53
  165. package/src/be/swarm-config-guard.ts +13 -0
  166. package/src/be/workflow-replay.ts +77 -0
  167. package/src/commands/provider-credentials.ts +28 -5
  168. package/src/commands/runner.ts +7 -12
  169. package/src/heartbeat/heartbeat.ts +91 -19
  170. package/src/hooks/hook.ts +72 -27
  171. package/src/http/codex-oauth-device.ts +8 -10
  172. package/src/http/db-query-bounded.ts +3 -0
  173. package/src/http/db-query-shared.ts +107 -15
  174. package/src/http/db-query.ts +10 -2
  175. package/src/http/index.ts +23 -6
  176. package/src/http/mcp.ts +5 -0
  177. package/src/http/onboarding.ts +2 -0
  178. package/src/http/script-runs.ts +9 -1
  179. package/src/http/scripts.ts +15 -0
  180. package/src/http/workflows.ts +3 -2
  181. package/src/oauth/mcp-wrapper.ts +1 -1
  182. package/src/providers/acp-adapter.ts +25 -11
  183. package/src/providers/acp-target-catalog.ts +35 -1
  184. package/src/providers/acp-targets.ts +78 -7
  185. package/src/providers/amp-adapter.ts +1 -1
  186. package/src/providers/claude-adapter.ts +26 -0
  187. package/src/providers/codex-adapter.ts +30 -3
  188. package/src/providers/codex-oauth/auth-json.ts +21 -4
  189. package/src/providers/codex-oauth/types.ts +2 -0
  190. package/src/providers/cursor-adapter.ts +1 -1
  191. package/src/providers/dsh-adapter.ts +10 -1
  192. package/src/providers/grok-adapter.ts +18 -2
  193. package/src/providers/opencode-adapter.ts +21 -5
  194. package/src/providers/pi-mono-extension.ts +56 -25
  195. package/src/providers/pricing-sources.md +2 -0
  196. package/src/script-workflows/supervisor.ts +11 -2
  197. package/src/scripts-runtime/eval-harness.ts +2 -12
  198. package/src/scripts-runtime/executors/quickjs-bundle.ts +152 -0
  199. package/src/scripts-runtime/executors/quickjs-prelude.ts +285 -0
  200. package/src/scripts-runtime/executors/quickjs-runner.ts +580 -0
  201. package/src/scripts-runtime/executors/quickjs-worker.ts +81 -0
  202. package/src/scripts-runtime/executors/quickjs.ts +196 -0
  203. package/src/scripts-runtime/executors/registry.ts +2 -0
  204. package/src/scripts-runtime/executors/sourcemap.ts +79 -0
  205. package/src/scripts-runtime/script-error-hints.ts +14 -0
  206. package/src/server.ts +66 -4
  207. package/src/tests/acp-adapter.test.ts +277 -12
  208. package/src/tests/boot-scrub-sweep.test.ts +390 -0
  209. package/src/tests/check-text-columns.test.ts +145 -0
  210. package/src/tests/ci-unit-test-report.test.ts +73 -0
  211. package/src/tests/claude-default-route.test.ts +75 -0
  212. package/src/tests/claude-hook-output.test.ts +233 -0
  213. package/src/tests/claude-sdk-process.fixture.ts +13 -2
  214. package/src/tests/codex-adapter-pool-auth-revalidate.test.ts +4 -2
  215. package/src/tests/codex-adapter.test.ts +166 -26
  216. package/src/tests/codex-oauth-auth-timestamps.test.ts +76 -0
  217. package/src/tests/codex-oauth-device.test.ts +23 -37
  218. package/src/tests/codex-oauth.test.ts +4 -1
  219. package/src/tests/context-window.test.ts +2 -2
  220. package/src/tests/credential-check.test.ts +51 -1
  221. package/src/tests/db-query-denylist.test.ts +202 -0
  222. package/src/tests/db-task-read-contract.test.ts +1 -0
  223. package/src/tests/db-task-write-contract.test.ts +1 -0
  224. package/src/tests/dsh-adapter.test.ts +23 -1
  225. package/src/tests/enabled-tools.test.ts +269 -0
  226. package/src/tests/entrypoint-acp-target-binary.test.ts +31 -1
  227. package/src/tests/entrypoint-codex-oauth-seed.test.ts +12 -0
  228. package/src/tests/events-scrub.test.ts +88 -0
  229. package/src/tests/fixtures/secret-corpus.ts +320 -0
  230. package/src/tests/grok-adapter.test.ts +13 -0
  231. package/src/tests/haiku-5-5-pricing.test.ts +38 -0
  232. package/src/tests/heartbeat-checklist.test.ts +158 -1
  233. package/src/tests/onboarding.test.ts +44 -0
  234. package/src/tests/opencode-adapter.test.ts +66 -3
  235. package/src/tests/opencode-plugin.test.ts +37 -0
  236. package/src/tests/openrouter-attribution-call-sites.test.ts +204 -0
  237. package/src/tests/openrouter-base-url.test.ts +30 -39
  238. package/src/tests/pi-mono-extension.test.ts +161 -2
  239. package/src/tests/pricing-refresh.test.ts +70 -1
  240. package/src/tests/reasoning-effort.test.ts +3 -1
  241. package/src/tests/script-connections.test.ts +5 -0
  242. package/src/tests/script-executor-conformance.test.ts +3 -0
  243. package/src/tests/script-executor-quickjs.test.ts +442 -0
  244. package/src/tests/script-executor-registry.test.ts +6 -1
  245. package/src/tests/script-runs-http.test.ts +88 -1
  246. package/src/tests/script-runs-scrub.test.ts +275 -0
  247. package/src/tests/scripts-http.test.ts +82 -1
  248. package/src/tests/scrubbed-text-12e.test.ts +289 -0
  249. package/src/tests/sealed-key-guard.test.ts +166 -0
  250. package/src/tests/secret-canary-sweep.test.ts +958 -0
  251. package/src/tests/secret-registry.test.ts +355 -0
  252. package/src/tests/secret-rules.test.ts +230 -0
  253. package/src/tests/secret-scrubber.test.ts +3 -2
  254. package/src/tests/telemetry-trigger.test.ts +12 -1
  255. package/src/tests/workflow-llm.test.ts +14 -0
  256. package/src/tests/workflow-replay.test.ts +518 -0
  257. package/src/tests/workflow-scrub.test.ts +242 -0
  258. package/src/tests/workflow-system-one-decision-providers.test.ts +33 -0
  259. package/src/tools/db-query.ts +1 -1
  260. package/src/tools/inject-learning.ts +1 -1
  261. package/src/tools/request-human-input.ts +7 -2
  262. package/src/tools/workflows/get-workflow-run.ts +3 -2
  263. package/src/types.ts +1 -1
  264. package/src/utils/enabled-tools.ts +27 -0
  265. package/src/utils/internal-ai/complete-structured.ts +11 -3
  266. package/src/utils/openrouter-base-url.ts +23 -0
  267. package/src/utils/secret-rules.generated.ts +2055 -0
  268. package/src/utils/secret-scrubber.ts +363 -29
  269. package/src/workflows/engine.ts +39 -4
  270. package/src/workflows/executors/raw-llm.ts +1 -0
  271. package/src/workflows/executors/system-one-decision.ts +2 -0
  272. package/src/workflows/executors/validate.ts +1 -0
  273. package/src/workflows/executors/workflow-llm.ts +9 -2
  274. package/src/workflows/recovery.ts +10 -1
  275. package/src/workflows/resume.ts +62 -3
  276. package/src/workflows/retry-poller.ts +3 -0
  277. package/templates/skills/agent-browser/SKILL.md +2 -0
  278. package/templates/skills/agent-browser/content.md +2 -0
  279. package/templates/skills/code-quality/content.md +1 -0
  280. package/templates/skills/heartbeat-runbook/content.md +1 -1
  281. package/templates/skills/work-on-task/SKILL.md +4 -0
  282. package/templates/skills/work-on-task/content.md +4 -0
  283. package/templates/skills/workflow-iterate/content.md +9 -0
  284. package/dist/acp-adapter-w6zws6me.js +0 -23
  285. package/dist/boot-scrub-logs-246yn076.js +0 -99
  286. package/dist/cli-3a4m1aws.js +0 -572
  287. package/dist/cli-3dpj7atn.js +0 -11
  288. package/dist/cli-a87b04k8.js +0 -951
  289. package/dist/cli-cvk6yzw5.js +0 -40
  290. package/dist/cli-gvcgmx69.js +0 -183
  291. package/dist/cli-h1spv8v4.js +0 -427
  292. package/dist/cli-jqt9hrnz.js +0 -168
  293. package/dist/cli-yhmwmv0g.js +0 -9281
  294. package/dist/grok-adapter-yt9pab3k.js +0 -29
  295. package/src/be/boot-scrub-logs.ts +0 -132
  296. package/dist/{codex-hook-d2rkvf39.js → codex-hook-15dgc4cb.js} +1 -1
@@ -10,7 +10,7 @@ import {
10
10
  } from "./cli-efnd2kce.js";
11
11
  import {
12
12
  ACP_TARGET_IDS
13
- } from "./cli-fw6vdcq5.js";
13
+ } from "./cli-zp67qg5x.js";
14
14
  import {
15
15
  isCodexOAuthConfigKey
16
16
  } from "./cli-bqjfjex4.js";
@@ -23,11 +23,11 @@ import {
23
23
  } from "./cli-2pdaysab.js";
24
24
  import {
25
25
  reasoningCapability
26
- } from "./cli-ttbsse3f.js";
26
+ } from "./cli-tmhsxhb8.js";
27
27
  import {
28
28
  ensureAgentFsCredentialsForAgent,
29
29
  inviteEmailToSharedOrg
30
- } from "./cli-prt9emct.js";
30
+ } from "./cli-c2tpw9ck.js";
31
31
  import {
32
32
  DEFAULT_CONNECTOR_CODE_LABEL,
33
33
  checkHeartbeatChecklist,
@@ -35,10 +35,10 @@ import {
35
35
  exchangeConnectorCode,
36
36
  runHeartbeatSweep,
37
37
  stopHeartbeat
38
- } from "./cli-ba66wyhy.js";
38
+ } from "./cli-qzmzwegq.js";
39
39
  import {
40
40
  Anthropic
41
- } from "./cli-ma3zvh39.js";
41
+ } from "./cli-5qkcdv8c.js";
42
42
  import {
43
43
  AGENT_MAX_TASKS_CONFIG_KEY,
44
44
  ALL_CAPABILITIES,
@@ -335,13 +335,13 @@ import {
335
335
  workflowModelErrors,
336
336
  workflowSaveWarnings,
337
337
  writeUnhandledError
338
- } from "./cli-50eg13rj.js";
339
- import"./cli-x7afk5wm.js";
338
+ } from "./cli-wydz3feg.js";
339
+ import"./cli-xvc3q9br.js";
340
340
  import {
341
341
  AMP_ESTIMATE_MODELS,
342
342
  ampBillsCacheWrites,
343
343
  resolveAmpModel
344
- } from "./cli-420bdgw0.js";
344
+ } from "./cli-mv2520nm.js";
345
345
  import {
346
346
  RATING_MODEL_MAX_LENGTH,
347
347
  REFERENCES_SOURCE_MAX_LENGTH,
@@ -350,16 +350,16 @@ import {
350
350
  import {
351
351
  isMultiRuntimeEnabled
352
352
  } from "./cli-re8z5p8p.js";
353
- import"./cli-k6xx3pve.js";
353
+ import"./cli-tx2zvn23.js";
354
354
  import {
355
355
  deleteModelCatalogOverlay,
356
356
  loadModelsCatalog,
357
357
  requestModelCatalogRefresh,
358
358
  upsertModelCatalogOverlay
359
- } from "./cli-e7t4snpa.js";
359
+ } from "./cli-p8rt8spp.js";
360
360
  import {
361
361
  normalizeModelKey
362
- } from "./cli-nfygw434.js";
362
+ } from "./cli-v1pwxreq.js";
363
363
  import {
364
364
  ConnectionAuthInputSchema,
365
365
  MAX_SCRIPT_WALL_CLOCK_MS,
@@ -381,11 +381,8 @@ import {
381
381
  connectionAuthSummary,
382
382
  consumeMcpOAuthPending,
383
383
  createApprovalFollowUpTask,
384
- createScriptApi,
385
384
  definitionNodeIds,
386
385
  deleteMcpOAuthToken,
387
- deleteScript,
388
- deleteScriptApi,
389
386
  discoverAuthorizationServerMetadata,
390
387
  discoverProtectedResourceMetadata,
391
388
  ensureMcpToken,
@@ -400,13 +397,9 @@ import {
400
397
  getCredentialBindingById,
401
398
  getMcpOAuthToken,
402
399
  getOAuthBindingTokenStatus,
403
- getScript,
404
- getScriptApiById,
405
400
  getScriptApiConnectionDescriptors,
406
- getScriptApiSecret,
407
401
  getScriptApiTypes,
408
402
  getScriptAppTypes,
409
- getScriptById,
410
403
  getScriptConnectionById,
411
404
  getScriptMcpConnectionDescriptors,
412
405
  getScriptMcpTypes,
@@ -415,27 +408,21 @@ import {
415
408
  isInvalidClientError,
416
409
  listAppRecords,
417
410
  listRelationalCredentialBindings,
418
- listScriptApisForScript,
419
411
  listScriptConnections,
420
412
  listScriptConnectionsAsync,
421
- listScriptVersions,
422
- listScripts,
423
413
  listVendoredOpenapiEntries,
424
414
  markMcpOAuthTokenStatus,
425
415
  normalizeTokenEndpointAuthMethod,
426
416
  oauthAppToProviderConfig,
427
417
  publicEndpointSsrfOptions,
428
418
  readStreamCapped,
429
- recordScriptApiUsage,
430
419
  refreshMcpToken,
431
420
  refreshScriptConnection,
432
421
  registerClient,
433
422
  require_dist,
434
423
  require_typescript,
435
424
  resolveAdvertisedTokenEndpointAuthMethod,
436
- restoreScratchScriptLastUsedIfUnchanged,
437
425
  revokeMcpToken,
438
- rotateScriptApiSecret,
439
426
  runScript,
440
427
  sandboxSpawnEnv,
441
428
  scriptSdkTypesWithGeneratedApis,
@@ -443,28 +430,18 @@ import {
443
430
  selectDcrTokenEndpointAuthMethod,
444
431
  setMcpServerAuthMethod,
445
432
  setScriptConnectionEnabled,
446
- touchScratchScriptLastUsed,
447
433
  typecheckScript,
448
434
  typecheckWithAmbient,
449
- updateScriptApi,
450
435
  upsertCredentialBinding,
451
436
  upsertMcpOAuthToken,
452
- upsertScriptByName,
453
437
  upsertScriptConnection,
454
438
  validateDefinition
455
- } from "./cli-xtgtyafv.js";
439
+ } from "./cli-577bxkf6.js";
456
440
  import"./cli-epan13p1.js";
457
441
  import {
458
442
  getApiKey
459
443
  } from "./cli-f14fvzag.js";
460
- import {
461
- detachedProcessGroup,
462
- forceTerminateProcessGroup,
463
- registerProcessGroup,
464
- signalProcessGroup,
465
- terminateProcessGroup
466
- } from "./cli-zt3w1cn1.js";
467
- import"./cli-xb3c6aat.js";
444
+ import"./cli-7mhy3ths.js";
468
445
  import {
469
446
  CLIENT_ID,
470
447
  MAX_CODEX_OAUTH_SLOT,
@@ -475,11 +452,24 @@ import {
475
452
  getAccountId,
476
453
  getValidCodexOAuth,
477
454
  loadAllCodexOAuthSlots
478
- } from "./cli-ftry7975.js";
479
- import"./cli-3dpj7atn.js";
480
- import"./cli-2x0e561b.js";
481
- import"./cli-pkke6geq.js";
455
+ } from "./cli-v1w7pbd8.js";
456
+ import {
457
+ detachedProcessGroup,
458
+ forceTerminateProcessGroup,
459
+ registerProcessGroup,
460
+ signalProcessGroup,
461
+ terminateProcessGroup
462
+ } from "./cli-zt3w1cn1.js";
463
+ import"./cli-km4x66j0.js";
482
464
  import"./cli-rb9m6rpe.js";
465
+ import"./cli-2x0e561b.js";
466
+ import {
467
+ buildAuthorizationUrl,
468
+ exchangeAuthorizationCode,
469
+ forceRefreshAuthorizationOrThrow,
470
+ forceRefreshTokenOrThrow,
471
+ oauthAppRowToProviderConfig
472
+ } from "./cli-kw0jcfje.js";
483
473
  import {
484
474
  AgentFsProvider,
485
475
  FilesError,
@@ -487,47 +477,6 @@ import {
487
477
  getFileStorageProvider,
488
478
  normalizeFilesError
489
479
  } from "./cli-mzfth0bp.js";
490
- import {
491
- searchScripts
492
- } from "./cli-jqt9hrnz.js";
493
- import {
494
- CANDIDATE_SET_MULTIPLIER,
495
- EMBEDDING_DIMENSIONS,
496
- MEMORY_KEY_MAX_LENGTH,
497
- OpenAI,
498
- getEmbeddingProvider,
499
- getMemoryStore,
500
- init_constants as init_constants2,
501
- init_key_paths,
502
- init_openai,
503
- init_reranker,
504
- rerank
505
- } from "./cli-yhmwmv0g.js";
506
- import"./cli-wfajtmf7.js";
507
- import {
508
- acquireOAuthRefreshLock,
509
- buildAuthorizationUrl,
510
- consumeOAuthPending,
511
- createOAuthApp,
512
- deleteAuthorizationById,
513
- deleteAuthorizationsForApp,
514
- deleteOAuthTokens,
515
- exchangeAuthorizationCode,
516
- forceRefreshAuthorizationOrThrow,
517
- forceRefreshTokenOrThrow,
518
- gcOAuthPending,
519
- getAuthorizationById,
520
- getDefaultAuthorizationIdForProvider,
521
- getOAuthApp,
522
- getOAuthAppById,
523
- getOAuthTokens,
524
- listAuthorizationsForApp,
525
- oauthAppRowToProviderConfig,
526
- releaseOAuthRefreshLock,
527
- updateAuthorizationIdentity,
528
- updateOAuthAppById,
529
- upsertAuthorization
530
- } from "./cli-a87b04k8.js";
531
480
  import"./cli-fad8m16k.js";
532
481
  import"./cli-bsakbbkm.js";
533
482
  import"./cli-zxg80zs9.js";
@@ -546,34 +495,34 @@ import {
546
495
  recordDbRetentionStatement,
547
496
  recordDbRetentionSweep,
548
497
  recordSessionCost,
498
+ require_content_type,
549
499
  startSlackApp,
550
500
  startSpan,
551
501
  stopSlackApp,
552
502
  withRemoteContext,
553
503
  withSpan,
554
504
  withSpanContext
555
- } from "./cli-0n4fasz0.js";
505
+ } from "./cli-c8r99akr.js";
556
506
  import"./cli-q51yprfq.js";
557
507
  import"./cli-3er6gcsn.js";
558
- import"./cli-cvk6yzw5.js";
559
508
  import"./cli-yatxqynm.js";
560
509
  import {
561
510
  bedrockProviderModule
562
- } from "./cli-ng97fjq7.js";
511
+ } from "./cli-cmxkbzzs.js";
563
512
  import"./cli-yn0a417a.js";
564
513
  import"./cli-cgj4hc12.js";
565
514
  import"./cli-txgcknmy.js";
566
515
  import"./cli-6map995v.js";
567
- import"./cli-8kt0bmgx.js";
516
+ import"./cli-xf713zz0.js";
568
517
  import"./cli-y2apkfe2.js";
569
518
  import"./cli-7kyk9jr3.js";
570
519
  import {
571
520
  setBedrockProviderModule
572
- } from "./cli-b0f70z24.js";
573
- import"./cli-nexwh8zg.js";
521
+ } from "./cli-mn8qkd8v.js";
522
+ import"./cli-g7k7zbcz.js";
574
523
  import"./cli-btbzvq95.js";
575
524
  import"./cli-1m2e086m.js";
576
- import"./cli-bzr0ftht.js";
525
+ import"./cli-wnb9b2g3.js";
577
526
  import"./cli-bd957dgb.js";
578
527
  import {
579
528
  import_websocket,
@@ -583,7 +532,7 @@ import"./cli-pzxba7gw.js";
583
532
  import {
584
533
  getUserGrant,
585
534
  init_rbac_roles
586
- } from "./cli-xnzrzets.js";
535
+ } from "./cli-ypgba1a8.js";
587
536
  import {
588
537
  LEGACY_RULES,
589
538
  can,
@@ -595,19 +544,24 @@ import {
595
544
  } from "./cli-rfphkzh5.js";
596
545
  import {
597
546
  API_DRAINING_HEADER,
547
+ CANDIDATE_SET_MULTIPLIER,
598
548
  CODEX_AUTH_WATCH_NAMESPACE,
599
549
  CredentialBindingSchema,
600
550
  DB_RETENTION_TUNING_BOUNDS,
551
+ EMBEDDING_DIMENSIONS,
601
552
  EXTENSION_AGENT_ROLE,
602
553
  ExtensionAgentAssignmentError,
603
554
  HeartbeatExpiryError,
604
555
  KvTypeCollisionError,
605
556
  MAX_DB_RETENTION_DAYS,
557
+ MEMORY_KEY_MAX_LENGTH,
606
558
  NOT_EXTENSION_AGENT_SQL,
559
+ OpenAI,
607
560
  ReservedAgentRoleError,
608
561
  SteeringRequestError,
609
562
  _resolveIntegrationProvider,
610
563
  _resolveIntegrationType,
564
+ acquireOAuthRefreshLock,
611
565
  agentContextKey,
612
566
  auditAssetKeys,
613
567
  backfillSupersedeTaskResumeTaskId,
@@ -626,6 +580,7 @@ import {
626
580
  completeTask,
627
581
  computeContentHash,
628
582
  configureOrgDomainPersistence,
583
+ consumeOAuthPending,
629
584
  countActiveScriptRuns,
630
585
  countAllMetrics,
631
586
  countAllPages,
@@ -642,8 +597,10 @@ import {
642
597
  createLogEntry,
643
598
  createMcpServer,
644
599
  createMetric,
600
+ createOAuthApp,
645
601
  createPage,
646
602
  createScheduledTask,
603
+ createScriptApi,
647
604
  createScriptRun,
648
605
  createSessionCost,
649
606
  createSessionLogs,
@@ -655,14 +612,19 @@ import {
655
612
  decryptSecret,
656
613
  deleteActiveSession,
657
614
  deleteActiveSessionById,
615
+ deleteAuthorizationById,
616
+ deleteAuthorizationsForApp,
658
617
  deleteBudget,
659
618
  deleteKv,
660
619
  deleteMcpServer,
661
620
  deleteMetric,
621
+ deleteOAuthTokens,
662
622
  deletePage,
663
623
  deletePricingRow,
664
624
  deletePromptTemplate,
665
625
  deleteScheduledTask,
626
+ deleteScript,
627
+ deleteScriptApi,
666
628
  deleteSkill,
667
629
  deleteSkillFile,
668
630
  deleteSwarmConfig,
@@ -679,6 +641,7 @@ import {
679
641
  encryptSecret,
680
642
  extensionAgentAssignmentError,
681
643
  failTask,
644
+ gcOAuthPending,
682
645
  getActivePricingRow,
683
646
  getActiveSessions,
684
647
  getAgentById,
@@ -699,6 +662,7 @@ import {
699
662
  getAllUsers,
700
663
  getApprovalRequestById,
701
664
  getAttributionByPerson,
665
+ getAuthorizationById,
702
666
  getAvailableKeyIndices,
703
667
  getBudget,
704
668
  getBudgets,
@@ -710,6 +674,8 @@ import {
710
674
  getDashboardCostSummary,
711
675
  getDb,
712
676
  getDbClient,
677
+ getDefaultAuthorizationIdForProvider,
678
+ getEmbeddingProvider,
713
679
  getEncryptionKey,
714
680
  getInboxSummary,
715
681
  getInstanceActivity,
@@ -723,9 +689,13 @@ import {
723
689
  getLogsByAgentId,
724
690
  getLogsByTaskId,
725
691
  getMcpServerById,
692
+ getMemoryStore,
726
693
  getMetric,
727
694
  getMetricVersion,
728
695
  getMetricVersions,
696
+ getOAuthApp,
697
+ getOAuthAppById,
698
+ getOAuthTokens,
729
699
  getOfferedTasksForAgent,
730
700
  getPage,
731
701
  getPageBySlug,
@@ -750,8 +720,13 @@ import {
750
720
  getScheduledTaskById,
751
721
  getScheduledTaskByName,
752
722
  getScheduledTasks,
723
+ getScript,
724
+ getScriptApiById,
725
+ getScriptApiSecret,
726
+ getScriptById,
753
727
  getScriptRun,
754
728
  getScriptRunByIdempotencyKey,
729
+ getScriptRunExecutionArgs,
755
730
  getScriptRunJournalStep,
756
731
  getServicesByAgentId,
757
732
  getSessionCostSummary,
@@ -793,16 +768,25 @@ import {
793
768
  init_api_drain,
794
769
  init_asset_key_audit,
795
770
  init_codex_auth_failure,
771
+ init_constants as init_constants2,
796
772
  init_context_key,
797
773
  init_credential_broker,
798
774
  init_crypto,
799
775
  init_date_utils,
800
776
  init_db,
777
+ init_db1 as init_db2,
801
778
  init_default_drift,
779
+ init_embeddings,
802
780
  init_heartbeat_expiry,
803
781
  init_human_free,
782
+ init_key_paths,
783
+ init_memory,
784
+ init_oauth,
785
+ init_openai,
804
786
  init_request_auth_context,
787
+ init_reranker,
805
788
  init_runtime,
789
+ init_secret_registry,
806
790
  init_steering,
807
791
  init_swarm_config_guard,
808
792
  init_task_tool_manifest,
@@ -828,6 +812,7 @@ import {
828
812
  listApprovalRequestSummaries,
829
813
  listApprovalRequests,
830
814
  listAssetSummaries,
815
+ listAuthorizationsForApp,
831
816
  listFavorites,
832
817
  listInboxState,
833
818
  listKv,
@@ -835,13 +820,17 @@ import {
835
820
  listMetricsByAgent,
836
821
  listPagesByAgent,
837
822
  listRecentSessions,
823
+ listScriptApisForScript,
838
824
  listScriptRunJournalSteps,
839
825
  listScriptRuns,
826
+ listScriptVersions,
827
+ listScripts,
840
828
  listSkillFileManifest,
841
829
  listSkills,
842
830
  listTaskTemplates,
843
831
  listWorkflowRunsPage,
844
832
  listWorkflows,
833
+ loadSecretRegistry,
845
834
  markKeyRateLimited,
846
835
  markSteeringDelivered,
847
836
  markSteeringHandled,
@@ -862,9 +851,12 @@ import {
862
851
  recordKeyRateLimitWindows,
863
852
  recordKeySeatMismatch,
864
853
  recordKeyUsage,
854
+ recordScriptApiUsage,
865
855
  recordTaskProviderIfUnset,
866
856
  refreshActiveSessionOnActivity,
857
+ releaseOAuthRefreshLock,
867
858
  requestSteering,
859
+ rerank,
868
860
  reservedKeyError,
869
861
  resetEmptyPollCount,
870
862
  resetOrphanedInProgressTasksForAgent,
@@ -872,7 +864,10 @@ import {
872
864
  resolveApprovalRequest,
873
865
  resolvePromptTemplate,
874
866
  resolveTriggerSurface,
867
+ restoreScratchScriptLastUsedIfUnchanged,
875
868
  resumeTask,
869
+ rotateScriptApiSecret,
870
+ searchScripts,
876
871
  searchSkills,
877
872
  selectTaskTools,
878
873
  setAgentHarnessProvider,
@@ -887,6 +882,7 @@ import {
887
882
  supersedeTask,
888
883
  sweepExpiredKv,
889
884
  telemetry,
885
+ touchScratchScriptLastUsed,
890
886
  uninstallMcpServer,
891
887
  uninstallSkill,
892
888
  updateActiveSessionProviderSessionId,
@@ -900,9 +896,12 @@ import {
900
896
  updateAgentProvider,
901
897
  updateAgentStatus,
902
898
  updateAgentStatusFromCapacity,
899
+ updateAuthorizationIdentity,
903
900
  updateMetric,
901
+ updateOAuthAppById,
904
902
  updatePage,
905
903
  updateScheduledTask,
904
+ updateScriptApi,
906
905
  updateScriptRun,
907
906
  updateScriptRunIfNotTerminal,
908
907
  updateScriptRunIfRunning,
@@ -913,18 +912,21 @@ import {
913
912
  updateTaskVcs,
914
913
  updateUser,
915
914
  upsertAssetKeyMapping,
915
+ upsertAuthorization,
916
916
  upsertBudget,
917
917
  upsertChannelActivityCursor,
918
918
  upsertInboxState,
919
919
  upsertKv,
920
920
  upsertPromptTemplate,
921
+ upsertScriptByName,
921
922
  upsertScriptRunJournalStep,
922
923
  upsertSkillFile,
923
924
  upsertSkillFiles,
924
925
  upsertSwarmConfig,
925
926
  validateConfigValue,
926
927
  withFavoriteFlags
927
- } from "./cli-qdv8kgz7.js";
928
+ } from "./cli-mkdsy1nq.js";
929
+ import"./cli-3qhyh31j.js";
928
930
  import {
929
931
  ActiveSessionSchema,
930
932
  AgentAcpStatusSchema,
@@ -1051,13 +1053,12 @@ import {
1051
1053
  isSafeBundlePath,
1052
1054
  isTerminalTaskStatus,
1053
1055
  splitLegacyModelAlias
1054
- } from "./cli-9s3h836g.js";
1055
- import"./cli-3qhyh31j.js";
1056
+ } from "./cli-xvdgasgy.js";
1056
1057
  import {
1057
1058
  IDENTITY_FIELD_BUDGETS,
1058
1059
  IdentityFieldBudgetError,
1059
1060
  init_identity_field_budget
1060
- } from "./cli-3a4m1aws.js";
1061
+ } from "./cli-mxvnnv5q.js";
1061
1062
  import {
1062
1063
  init_steering_enabled,
1063
1064
  isSteeringEnabled
@@ -1067,21 +1068,6 @@ import {
1067
1068
  getSlackConfiguration,
1068
1069
  init_config
1069
1070
  } from "./cli-dmtrxqhg.js";
1070
- import"./cli-tadfgd0t.js";
1071
- import {
1072
- MODEL_SCOPED_WINDOWS,
1073
- activeModelBlocks,
1074
- init_model_rate_limit_windows
1075
- } from "./cli-ywybs5as.js";
1076
- import {
1077
- MAX_PROFILE_FILE_LENGTH,
1078
- agentFsFileRoute,
1079
- getAppUrl,
1080
- getConfiguredAppUrls,
1081
- getMcpBaseUrl,
1082
- getPublicMcpBaseUrl,
1083
- init_constants
1084
- } from "./cli-gd4favx9.js";
1085
1071
  import"./cli-agamgm0p.js";
1086
1072
  import {
1087
1073
  getAllTemplateDefinitions,
@@ -1098,7 +1084,26 @@ import {
1098
1084
  init_subscription_plans,
1099
1085
  isSubscriptionPlanId
1100
1086
  } from "./cli-1a2j50m0.js";
1087
+ import"./cli-tadfgd0t.js";
1088
+ import {
1089
+ MODEL_SCOPED_WINDOWS,
1090
+ activeModelBlocks,
1091
+ init_model_rate_limit_windows
1092
+ } from "./cli-ywybs5as.js";
1101
1093
  import"./cli-f9w1semm.js";
1094
+ import {
1095
+ getOpenRouterAttributionHeaders,
1096
+ init_openrouter_base_url
1097
+ } from "./cli-a35hzdve.js";
1098
+ import {
1099
+ MAX_PROFILE_FILE_LENGTH,
1100
+ agentFsFileRoute,
1101
+ getAppUrl,
1102
+ getConfiguredAppUrls,
1103
+ getMcpBaseUrl,
1104
+ getPublicMcpBaseUrl,
1105
+ init_constants
1106
+ } from "./cli-gd4favx9.js";
1102
1107
  import {
1103
1108
  init_env_flag,
1104
1109
  isEnvFlagEnabled,
@@ -1107,7 +1112,7 @@ import {
1107
1112
  import {
1108
1113
  init_src,
1109
1114
  isAlias
1110
- } from "./cli-zsh093hk.js";
1115
+ } from "./cli-014vns2y.js";
1111
1116
  import {
1112
1117
  exports_zod,
1113
1118
  init_zod
@@ -1124,21 +1129,22 @@ import {
1124
1129
  import {
1125
1130
  init_package,
1126
1131
  package_default
1127
- } from "./cli-1kzfvd1z.js";
1132
+ } from "./cli-ymmc1zxg.js";
1128
1133
  import {
1129
1134
  init_event_bus,
1130
1135
  workflowEventBus
1131
- } from "./cli-hpryr6em.js";
1136
+ } from "./cli-mb75wpxf.js";
1132
1137
  import {
1133
1138
  init_bus,
1134
1139
  realtimeBus
1135
1140
  } from "./cli-zf8jjwex.js";
1136
1141
  import {
1142
+ findSecretsIn,
1137
1143
  init_secret_scrubber,
1138
1144
  registerVolatileSecret,
1139
1145
  scrubObject,
1140
1146
  scrubSecrets
1141
- } from "./cli-h1spv8v4.js";
1147
+ } from "./cli-wt7ccy4r.js";
1142
1148
  import {
1143
1149
  __require,
1144
1150
  __toESM
@@ -1193,13 +1199,13 @@ setBedrockProviderModule(bedrockProviderModule);
1193
1199
  import {
1194
1200
  createServer as createHttpServer
1195
1201
  } from "node:http";
1196
- init_db();
1202
+ init_db2();
1197
1203
 
1198
1204
  // src/be/db-retention.ts
1199
1205
  import { AsyncLocalStorage } from "node:async_hooks";
1200
1206
  init_env_flag();
1201
1207
  init_secret_scrubber();
1202
- init_db();
1208
+ init_db2();
1203
1209
  init_swarm_config_guard();
1204
1210
  var DAY_MS = 24 * 60 * 60 * 1000;
1205
1211
  var RETENTION_INTERVAL_MS = 60 * 60 * 1000;
@@ -1750,7 +1756,7 @@ function stopHumanFreeDrain() {
1750
1756
  }
1751
1757
 
1752
1758
  // src/be/scripts/retention.ts
1753
- init_db();
1759
+ init_db2();
1754
1760
  var SCRATCH_RETENTION_DAYS = 14;
1755
1761
  var SCRATCH_GC_INTERVAL_MS = 24 * 60 * 60 * 1000;
1756
1762
  var scratchGcTimer = null;
@@ -1857,8 +1863,11 @@ function stopScratchScriptGc() {
1857
1863
  scratchGcTimer = null;
1858
1864
  }
1859
1865
 
1866
+ // src/http/index.ts
1867
+ init_secret_registry();
1868
+
1860
1869
  // src/be/seed-capabilities.ts
1861
- init_db();
1870
+ init_db2();
1862
1871
  var LEGACY_ALWAYS_ON_DEFAULTS = [
1863
1872
  "core",
1864
1873
  "config",
@@ -1893,7 +1902,7 @@ async function seedLegacyCapabilitiesConfig() {
1893
1902
  }
1894
1903
 
1895
1904
  // src/queue-stall-alarm.ts
1896
- init_db();
1905
+ init_db2();
1897
1906
  init_secret_scrubber();
1898
1907
  var QUEUE_STALL_THRESHOLD_MS = 30 * 60 * 1000;
1899
1908
  var QUEUE_STALL_CHECK_INTERVAL_MS = 5 * 60 * 1000;
@@ -2054,7 +2063,7 @@ init_bus();
2054
2063
 
2055
2064
  // src/realtime/transport.ts
2056
2065
  init_zod();
2057
- init_db();
2066
+ init_db2();
2058
2067
  init_secret_scrubber();
2059
2068
  init_bus();
2060
2069
 
@@ -2471,7 +2480,8 @@ function connect(ws, auth) {
2471
2480
  }
2472
2481
 
2473
2482
  // src/script-workflows/supervisor.ts
2474
- init_db();
2483
+ init_db2();
2484
+ init_secret_scrubber();
2475
2485
 
2476
2486
  // src/script-workflows/executor.ts
2477
2487
  import { randomUUID } from "node:crypto";
@@ -3315,7 +3325,9 @@ async function startScriptRunProcess(run, baseUrl, apiKeyOverride) {
3315
3325
  if (process.env.SCRIPT_WORKFLOW_DEBUG === "true") {
3316
3326
  console.error(`[script-workflows] spawning ${run.id} auth override=${apiKeyOverride ? "yes" : "no"} len=${apiKey.length}`);
3317
3327
  }
3318
- const execution = await scriptExecutor.start({ run, baseUrl, apiKey });
3328
+ const sealedArgs = await getScriptRunExecutionArgs(run.id);
3329
+ const args = sealedArgs === undefined ? run.args : sealedArgs;
3330
+ const execution = await scriptExecutor.start({ run: { ...run, args }, baseUrl, apiKey });
3319
3331
  managed.set(run.id, { execution });
3320
3332
  await updateScriptRun(run.id, {
3321
3333
  status: "running",
@@ -3326,7 +3338,7 @@ async function startScriptRunProcess(run, baseUrl, apiKeyOverride) {
3326
3338
  const current = await getScriptRun(run.id);
3327
3339
  if (current && current.status === "running") {
3328
3340
  if (exitCode !== 0) {
3329
- console.error(`[script-workflows] run ${run.id} subprocess exited ${exitCode}: ${stderr.trim() || "(no stderr)"}`);
3341
+ console.error(scrubSecrets(`[script-workflows] run ${run.id} subprocess exited ${exitCode}: ${stderr.trim() || "(no stderr)"}`));
3330
3342
  }
3331
3343
  await updateScriptRunIfRunning(run.id, {
3332
3344
  status: exitCode === 0 ? "completed" : "failed",
@@ -3564,7 +3576,7 @@ init_secret_scrubber();
3564
3576
 
3565
3577
  // src/http/active-sessions.ts
3566
3578
  init_zod();
3567
- init_db();
3579
+ init_db2();
3568
3580
  init_types();
3569
3581
  var listActiveSessions = route({
3570
3582
  method: "get",
@@ -3767,7 +3779,7 @@ async function handleActiveSessions(req, res, pathSegments, queryParams, myAgent
3767
3779
  // src/http/agents.ts
3768
3780
  init_src();
3769
3781
  init_zod();
3770
- init_db();
3782
+ init_db2();
3771
3783
  init_telemetry();
3772
3784
  init_types();
3773
3785
  init_constants();
@@ -4847,7 +4859,7 @@ async function handleAgentsRest(req, res, pathSegments, queryParams, _myAgentId)
4847
4859
 
4848
4860
  // src/http/api-keys.ts
4849
4861
  init_zod();
4850
- init_db();
4862
+ init_db2();
4851
4863
  init_model_rate_limit_windows();
4852
4864
  init_subscription_plans();
4853
4865
 
@@ -5501,7 +5513,7 @@ async function handleApiKeys(req, res, pathSegments, queryParams) {
5501
5513
 
5502
5514
  // src/http/approval-requests.ts
5503
5515
  init_zod();
5504
- init_db();
5516
+ init_db2();
5505
5517
  init_rbac();
5506
5518
  init_request_auth_context();
5507
5519
  init_event_bus();
@@ -6066,13 +6078,14 @@ async function approvalQuorumMet(approvers, votes) {
6066
6078
  // src/http/assets.ts
6067
6079
  init_zod();
6068
6080
  init_asset_key_audit();
6081
+ init_db2();
6069
6082
  init_db();
6070
6083
  init_rbac();
6071
6084
  init_types();
6072
6085
  init_request_auth_context();
6073
6086
 
6074
6087
  // src/http/request-principal.ts
6075
- init_db();
6088
+ init_db2();
6076
6089
  init_request_auth_context();
6077
6090
  async function requestPrincipal(req, myAgentId) {
6078
6091
  const auth = getRequestAuth(req);
@@ -6406,7 +6419,7 @@ async function handleAssets(req, res, pathSegments, queryParams, myAgentId) {
6406
6419
 
6407
6420
  // src/http/budgets.ts
6408
6421
  init_zod();
6409
- init_db();
6422
+ init_db2();
6410
6423
  init_types();
6411
6424
  init_secret_scrubber();
6412
6425
  import { createHash } from "node:crypto";
@@ -6569,14 +6582,37 @@ async function handleBudgets(req, res, pathSegments, queryParams, _myAgentId) {
6569
6582
  // src/http/codex-oauth-device.ts
6570
6583
  init_zod();
6571
6584
  init_crypto();
6572
- init_db();
6585
+ init_db2();
6586
+
6587
+ // src/be/db/codex-oauth-device-flows.ts
6588
+ init_runtime();
6589
+ async function getCodexDeviceFlow(flowId) {
6590
+ const row = await getDbClient().get("SELECT state, expires_at FROM codex_oauth_device_flows WHERE flow_id = ?", [flowId]);
6591
+ if (!row)
6592
+ return null;
6593
+ if (row.expires_at <= Date.now()) {
6594
+ await getDbClient().run("DELETE FROM codex_oauth_device_flows WHERE flow_id = ?", [flowId]);
6595
+ return null;
6596
+ }
6597
+ return { state: row.state, expiresAt: row.expires_at };
6598
+ }
6599
+ async function upsertCodexDeviceFlow(input) {
6600
+ const now = Date.now();
6601
+ await getDbClient().run("DELETE FROM codex_oauth_device_flows WHERE expires_at <= ?", [now]);
6602
+ await getDbClient().run(`INSERT INTO codex_oauth_device_flows (flow_id, state, expires_at, created_at, updated_at)
6603
+ VALUES (?, ?, ?, ?, ?)
6604
+ ON CONFLICT(flow_id) DO UPDATE SET
6605
+ state = excluded.state,
6606
+ expires_at = excluded.expires_at,
6607
+ updated_at = excluded.updated_at`, [input.flowId, input.state, input.expiresAt, now, now]);
6608
+ }
6573
6609
 
6574
6610
  // src/be/onboarding.ts
6575
6611
  init_telemetry();
6576
6612
  init_types();
6577
6613
  init_request_auth_context();
6578
6614
  init_zod_openapi();
6579
- init_db();
6615
+ init_db2();
6580
6616
  init_swarm_config_guard();
6581
6617
  var ONBOARDING_CONFIG_KEY = "onboarding_state";
6582
6618
  var OnboardingStepIdSchema = exports_zod.enum([
@@ -7185,7 +7221,7 @@ init_secret_scrubber();
7185
7221
 
7186
7222
  // src/http/config.ts
7187
7223
  init_zod();
7188
- init_db();
7224
+ init_db2();
7189
7225
  init_rbac_roles();
7190
7226
  init_swarm_config_guard();
7191
7227
  init_rbac();
@@ -7568,7 +7604,6 @@ async function handleConfig(req, res, pathSegments, queryParams) {
7568
7604
  }
7569
7605
 
7570
7606
  // src/http/codex-oauth-device.ts
7571
- var FLOW_NAMESPACE = "codex-oauth-device";
7572
7607
  var FLOW_TTL_MS = 15 * 60 * 1000;
7573
7608
  var POLL_LEASE_MS = 45000;
7574
7609
  var FlowStateSchema = exports_external.object({
@@ -7628,11 +7663,11 @@ function registerFlowSecrets(state) {
7628
7663
  registerVolatileSecret(state.userCode, "codex-device-user-code");
7629
7664
  }
7630
7665
  async function readFlow(flowId) {
7631
- const entry = await getKv(FLOW_NAMESPACE, flowId);
7632
- if (!entry || typeof entry.value !== "string")
7666
+ const entry = await getCodexDeviceFlow(flowId);
7667
+ if (!entry)
7633
7668
  return null;
7634
7669
  try {
7635
- const plaintext = decryptSecret(entry.value, getEncryptionKey());
7670
+ const plaintext = decryptSecret(entry.state, getEncryptionKey());
7636
7671
  const parsed = FlowStateSchema.safeParse(JSON.parse(plaintext));
7637
7672
  if (!parsed.success)
7638
7673
  return null;
@@ -7643,11 +7678,9 @@ async function readFlow(flowId) {
7643
7678
  }
7644
7679
  }
7645
7680
  async function writeFlow(flowId, state) {
7646
- await upsertKv({
7647
- namespace: FLOW_NAMESPACE,
7648
- key: flowId,
7649
- value: encryptSecret(JSON.stringify(state), getEncryptionKey()),
7650
- valueType: "string",
7681
+ await upsertCodexDeviceFlow({
7682
+ flowId,
7683
+ state: encryptSecret(JSON.stringify(state), getEncryptionKey()),
7651
7684
  expiresAt: state.expiresAt
7652
7685
  });
7653
7686
  }
@@ -7857,7 +7890,7 @@ async function handleCodexOAuthDevice(req, res, pathSegments, queryParams) {
7857
7890
 
7858
7891
  // src/http/codex-oauth-keep-warm.ts
7859
7892
  init_zod();
7860
- init_db();
7893
+ init_db2();
7861
7894
  init_codex_auth_failure();
7862
7895
  init_constants();
7863
7896
  var KEEP_WARM_MAX_AGE_MS = 7 * 24 * 60 * 60 * 1000;
@@ -7931,7 +7964,7 @@ async function handleCodexOAuthKeepWarm(req, res, pathSegments) {
7931
7964
  init_zod();
7932
7965
 
7933
7966
  // src/comb/review-batch.ts
7934
- init_db();
7967
+ init_db2();
7935
7968
  init_resolver();
7936
7969
  init_constants();
7937
7970
  init_secret_scrubber();
@@ -8372,7 +8405,7 @@ async function handleComb(req, res, pathSegments, queryParams, myAgentId) {
8372
8405
 
8373
8406
  // src/http/context.ts
8374
8407
  init_zod();
8375
- init_db();
8408
+ init_db2();
8376
8409
  init_types();
8377
8410
  var PostContextResponseSchema = exports_external.object({
8378
8411
  ok: exports_external.literal(true),
@@ -8481,7 +8514,7 @@ async function handleContext(req, res, pathSegments, queryParams, myAgentId) {
8481
8514
 
8482
8515
  // src/http/ecosystem.ts
8483
8516
  init_zod();
8484
- init_db();
8517
+ init_db2();
8485
8518
  var EcosystemAppSchema = exports_external.object({
8486
8519
  name: exports_external.string(),
8487
8520
  script: exports_external.string(),
@@ -8731,7 +8764,7 @@ async function handleEvents(req, res, pathSegments, queryParams, _myAgentId) {
8731
8764
 
8732
8765
  // src/http/extensions.ts
8733
8766
  init_zod();
8734
- init_db();
8767
+ init_db2();
8735
8768
 
8736
8769
  // src/be/extensions/validate.ts
8737
8770
  init_bundle_path();
@@ -10773,7 +10806,7 @@ async function handleExtensions(req, res, pathSegments, queryParams, agentId) {
10773
10806
 
10774
10807
  // src/http/favorites.ts
10775
10808
  init_zod();
10776
- init_db();
10809
+ init_db2();
10777
10810
  init_types();
10778
10811
  var listFavorites2 = route({
10779
10812
  method: "get",
@@ -10873,7 +10906,7 @@ async function handleFavorites(req, res, pathSegments, queryParams, myAgentId) {
10873
10906
 
10874
10907
  // src/http/fs.ts
10875
10908
  init_zod();
10876
- init_db();
10909
+ init_db2();
10877
10910
  init_rbac();
10878
10911
  init_types();
10879
10912
 
@@ -11418,7 +11451,7 @@ async function handleHeartbeat(req, res, pathSegments) {
11418
11451
 
11419
11452
  // src/http/inbox-state.ts
11420
11453
  init_zod();
11421
- init_db();
11454
+ init_db2();
11422
11455
  init_types();
11423
11456
  var listState = route({
11424
11457
  method: "get",
@@ -11628,7 +11661,7 @@ function buildSlackManifest(name) {
11628
11661
  }
11629
11662
 
11630
11663
  // src/http/config-values.ts
11631
- init_db();
11664
+ init_db2();
11632
11665
  async function resolveConfigValue(key) {
11633
11666
  const configs = await getResolvedConfig();
11634
11667
  const variants = [key, key.toLowerCase(), key.toUpperCase()];
@@ -11761,7 +11794,7 @@ var handleIntegrations = createIntegrationsHandler();
11761
11794
 
11762
11795
  // src/http/kv.ts
11763
11796
  init_zod();
11764
- init_db();
11797
+ init_db2();
11765
11798
  init_rbac();
11766
11799
  init_context_key();
11767
11800
  init_types();
@@ -12930,6 +12963,85 @@ var getRequestListener = (fetchCallback, options = {}) => {
12930
12963
  };
12931
12964
  };
12932
12965
 
12966
+ // node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js
12967
+ var import_content_type = __toESM(require_content_type(), 1);
12968
+ function mediaTypeEssence(header2) {
12969
+ if (!header2) {
12970
+ return;
12971
+ }
12972
+ try {
12973
+ return import_content_type.default.parse(header2).type;
12974
+ } catch {
12975
+ const essence = (header2.split(";", 1)[0] ?? "").trim().toLowerCase();
12976
+ if (essence === "" || header2.slice(essence.length).includes(",")) {
12977
+ return;
12978
+ }
12979
+ return essence;
12980
+ }
12981
+ }
12982
+ function isJsonContentType(header2) {
12983
+ if (header2 === "application/json") {
12984
+ return true;
12985
+ }
12986
+ return mediaTypeEssence(header2) === "application/json";
12987
+ }
12988
+
12989
+ // node_modules/@modelcontextprotocol/sdk/dist/esm/server/requestBody.js
12990
+ var DEFAULT_MAX_REQUEST_BODY_SIZE = 4 * 1024 * 1024;
12991
+ var MAX_BATCH_SIZE2 = 100;
12992
+ function requestBodyTooLargeMessage(maxBytes) {
12993
+ return `Payload Too Large: Request body must not exceed ${maxBytes} bytes`;
12994
+ }
12995
+ function resolveMaxRequestBodySize(value) {
12996
+ if (value === undefined) {
12997
+ return DEFAULT_MAX_REQUEST_BODY_SIZE;
12998
+ }
12999
+ if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
13000
+ throw new RangeError(`maxRequestBodySize must be a positive number of bytes, got ${String(value)}`);
13001
+ }
13002
+ return value;
13003
+ }
13004
+ async function readRequestBody(request, maxBytes = DEFAULT_MAX_REQUEST_BODY_SIZE) {
13005
+ if (Number(request.headers.get("content-length")) > maxBytes) {
13006
+ return { tooLarge: true };
13007
+ }
13008
+ if (request.body === null) {
13009
+ return { tooLarge: false, text: "" };
13010
+ }
13011
+ const reader = request.body.getReader();
13012
+ const decoder = new TextDecoder;
13013
+ let received = 0;
13014
+ let text = "";
13015
+ try {
13016
+ for (;; ) {
13017
+ const { done, value } = await reader.read();
13018
+ if (done) {
13019
+ break;
13020
+ }
13021
+ received += value.byteLength;
13022
+ if (received > maxBytes) {
13023
+ return { tooLarge: true };
13024
+ }
13025
+ text += decoder.decode(value, { stream: true });
13026
+ }
13027
+ } finally {
13028
+ reader.releaseLock();
13029
+ }
13030
+ return { tooLarge: false, text: text + decoder.decode() };
13031
+ }
13032
+
13033
+ // node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.js
13034
+ var DEFAULT_SSE_KEEP_ALIVE_MS = 15000;
13035
+ var MAX_TIMER_DELAY_MS = 2 ** 31 - 1;
13036
+ function armSseKeepAlive(intervalMs, onTick) {
13037
+ if (!Number.isFinite(intervalMs) || intervalMs < 1) {
13038
+ return;
13039
+ }
13040
+ const timer = setInterval(onTick, Math.min(intervalMs, MAX_TIMER_DELAY_MS));
13041
+ timer.unref?.();
13042
+ return timer;
13043
+ }
13044
+
12933
13045
  // node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.js
12934
13046
  class WebStandardStreamableHTTPServerTransport {
12935
13047
  constructor(options = {}) {
@@ -12937,10 +13049,12 @@ class WebStandardStreamableHTTPServerTransport {
12937
13049
  this._hasHandledRequest = false;
12938
13050
  this._streamMapping = new Map;
12939
13051
  this._requestToStreamMapping = new Map;
13052
+ this._resumableStreams = new Set;
12940
13053
  this._requestResponseMap = new Map;
12941
13054
  this._initialized = false;
12942
13055
  this._enableJsonResponse = false;
12943
13056
  this._standaloneSseStreamId = "_GET_stream";
13057
+ this._closed = false;
12944
13058
  this.sessionIdGenerator = options.sessionIdGenerator;
12945
13059
  this._enableJsonResponse = options.enableJsonResponse ?? false;
12946
13060
  this._eventStore = options.eventStore;
@@ -12950,6 +13064,23 @@ class WebStandardStreamableHTTPServerTransport {
12950
13064
  this._allowedOrigins = options.allowedOrigins;
12951
13065
  this._enableDnsRebindingProtection = options.enableDnsRebindingProtection ?? false;
12952
13066
  this._retryInterval = options.retryInterval;
13067
+ this._keepAliveMs = options.keepAliveMs ?? DEFAULT_SSE_KEEP_ALIVE_MS;
13068
+ this._maxRequestBodySize = resolveMaxRequestBodySize(options.maxRequestBodySize);
13069
+ }
13070
+ startKeepAlive(controller, encoder) {
13071
+ if (this._closed)
13072
+ return;
13073
+ const timer = armSseKeepAlive(this._keepAliveMs, () => {
13074
+ try {
13075
+ controller.enqueue(encoder.encode(`: keepalive
13076
+
13077
+ `));
13078
+ } catch {
13079
+ if (timer !== undefined)
13080
+ clearInterval(timer);
13081
+ }
13082
+ });
13083
+ return timer;
12953
13084
  }
12954
13085
  async start() {
12955
13086
  if (this._started) {
@@ -12997,6 +13128,9 @@ class WebStandardStreamableHTTPServerTransport {
12997
13128
  return;
12998
13129
  }
12999
13130
  async handleRequest(req, options) {
13131
+ if (this._closed) {
13132
+ return this.createJsonErrorResponse(404, -32001, "Session not found");
13133
+ }
13000
13134
  if (!this.sessionIdGenerator && this._hasHandledRequest) {
13001
13135
  throw new Error("Stateless transport cannot be reused across requests. Create a new transport per request.");
13002
13136
  }
@@ -13036,6 +13170,7 @@ data:
13036
13170
  `;
13037
13171
  }
13038
13172
  controller.enqueue(encoder.encode(primingEvent));
13173
+ this._resumableStreams.add(streamId);
13039
13174
  }
13040
13175
  async handleGetRequest(req) {
13041
13176
  const acceptHeader = req.headers.get("accept");
@@ -13063,18 +13198,25 @@ data:
13063
13198
  }
13064
13199
  const encoder = new TextEncoder;
13065
13200
  let streamController;
13201
+ let keepAliveTimer = undefined;
13066
13202
  const readable = new ReadableStream({
13067
13203
  start: (controller) => {
13068
13204
  streamController = controller;
13069
13205
  },
13070
13206
  cancel: () => {
13071
- this._streamMapping.delete(this._standaloneSseStreamId);
13207
+ if (keepAliveTimer !== undefined) {
13208
+ clearInterval(keepAliveTimer);
13209
+ }
13210
+ if (this._streamMapping.get(this._standaloneSseStreamId)?.controller === streamController) {
13211
+ this._streamMapping.delete(this._standaloneSseStreamId);
13212
+ }
13072
13213
  }
13073
13214
  });
13074
13215
  const headers2 = {
13075
13216
  "Content-Type": "text/event-stream",
13076
13217
  "Cache-Control": "no-cache, no-transform",
13077
- Connection: "keep-alive"
13218
+ Connection: "keep-alive",
13219
+ "X-Accel-Buffering": "no"
13078
13220
  };
13079
13221
  if (this.sessionId !== undefined) {
13080
13222
  headers2["mcp-session-id"] = this.sessionId;
@@ -13083,12 +13225,16 @@ data:
13083
13225
  controller: streamController,
13084
13226
  encoder,
13085
13227
  cleanup: () => {
13228
+ if (keepAliveTimer !== undefined) {
13229
+ clearInterval(keepAliveTimer);
13230
+ }
13086
13231
  this._streamMapping.delete(this._standaloneSseStreamId);
13087
13232
  try {
13088
13233
  streamController.close();
13089
13234
  } catch {}
13090
13235
  }
13091
13236
  });
13237
+ keepAliveTimer = this.startKeepAlive(streamController, encoder);
13092
13238
  return new Response(readable, { headers: headers2 });
13093
13239
  }
13094
13240
  async replayEvents(lastEventId) {
@@ -13112,20 +13258,33 @@ data:
13112
13258
  const headers2 = {
13113
13259
  "Content-Type": "text/event-stream",
13114
13260
  "Cache-Control": "no-cache, no-transform",
13115
- Connection: "keep-alive"
13261
+ Connection: "keep-alive",
13262
+ "X-Accel-Buffering": "no"
13116
13263
  };
13117
13264
  if (this.sessionId !== undefined) {
13118
13265
  headers2["mcp-session-id"] = this.sessionId;
13119
13266
  }
13120
13267
  const encoder = new TextEncoder;
13121
13268
  let streamController;
13269
+ let keepAliveTimer = undefined;
13270
+ let replayedStreamId = undefined;
13271
+ let cancelled = false;
13122
13272
  const readable = new ReadableStream({
13123
13273
  start: (controller) => {
13124
13274
  streamController = controller;
13125
13275
  },
13126
- cancel: () => {}
13276
+ cancel: () => {
13277
+ cancelled = true;
13278
+ if (keepAliveTimer !== undefined) {
13279
+ clearInterval(keepAliveTimer);
13280
+ }
13281
+ if (replayedStreamId !== undefined && this._streamMapping.get(replayedStreamId)?.controller === streamController) {
13282
+ this._streamMapping.delete(replayedStreamId);
13283
+ }
13284
+ }
13127
13285
  });
13128
- const replayedStreamId = await this._eventStore.replayEventsAfter(lastEventId, {
13286
+ const replayedEventIds = new Set;
13287
+ replayedStreamId = await this._eventStore.replayEventsAfter(lastEventId, {
13129
13288
  send: async (eventId, message) => {
13130
13289
  const success = this.writeSSEEvent(streamController, encoder, message, eventId);
13131
13290
  if (!success) {
@@ -13133,19 +13292,34 @@ data:
13133
13292
  try {
13134
13293
  streamController.close();
13135
13294
  } catch {}
13295
+ } else {
13296
+ replayedEventIds.add(eventId);
13136
13297
  }
13137
13298
  }
13138
13299
  });
13300
+ if (this._closed || cancelled) {
13301
+ try {
13302
+ streamController.close();
13303
+ } catch {}
13304
+ return this.createJsonErrorResponse(404, -32001, "Session not found");
13305
+ }
13306
+ this._streamMapping.get(replayedStreamId)?.cleanup();
13139
13307
  this._streamMapping.set(replayedStreamId, {
13140
13308
  controller: streamController,
13141
13309
  encoder,
13310
+ replayedEventIds,
13142
13311
  cleanup: () => {
13312
+ if (keepAliveTimer !== undefined) {
13313
+ clearInterval(keepAliveTimer);
13314
+ }
13143
13315
  this._streamMapping.delete(replayedStreamId);
13144
13316
  try {
13145
13317
  streamController.close();
13146
13318
  } catch {}
13147
13319
  }
13148
13320
  });
13321
+ this._resumableStreams.add(replayedStreamId);
13322
+ keepAliveTimer = this.startKeepAlive(streamController, encoder);
13149
13323
  return new Response(readable, { headers: headers2 });
13150
13324
  } catch (error) {
13151
13325
  this.onerror?.(error);
@@ -13195,7 +13369,7 @@ data:
13195
13369
  return this.createJsonErrorResponse(406, -32000, "Not Acceptable: Client must accept both application/json and text/event-stream");
13196
13370
  }
13197
13371
  const ct = req.headers.get("content-type");
13198
- if (!ct || !ct.includes("application/json")) {
13372
+ if (!isJsonContentType(ct)) {
13199
13373
  this.onerror?.(new Error("Unsupported Media Type: Content-Type must be application/json"));
13200
13374
  return this.createJsonErrorResponse(415, -32000, "Unsupported Media Type: Content-Type must be application/json");
13201
13375
  }
@@ -13208,12 +13382,22 @@ data:
13208
13382
  rawMessage = options.parsedBody;
13209
13383
  } else {
13210
13384
  try {
13211
- rawMessage = await req.json();
13385
+ const body = await readRequestBody(req, this._maxRequestBodySize);
13386
+ if (body.tooLarge) {
13387
+ const message = requestBodyTooLargeMessage(this._maxRequestBodySize);
13388
+ this.onerror?.(new Error(message));
13389
+ return this.createJsonErrorResponse(413, -32000, message);
13390
+ }
13391
+ rawMessage = JSON.parse(body.text);
13212
13392
  } catch {
13213
13393
  this.onerror?.(new Error("Parse error: Invalid JSON"));
13214
13394
  return this.createJsonErrorResponse(400, -32700, "Parse error: Invalid JSON");
13215
13395
  }
13216
13396
  }
13397
+ if (Array.isArray(rawMessage) && rawMessage.length > MAX_BATCH_SIZE2) {
13398
+ this.onerror?.(new Error(`Invalid Request: Batch must not exceed ${MAX_BATCH_SIZE2} messages`));
13399
+ return this.createJsonErrorResponse(400, -32600, `Invalid Request: Batch must not exceed ${MAX_BATCH_SIZE2} messages`);
13400
+ }
13217
13401
  let messages;
13218
13402
  try {
13219
13403
  if (Array.isArray(rawMessage)) {
@@ -13225,6 +13409,9 @@ data:
13225
13409
  this.onerror?.(new Error("Parse error: Invalid JSON-RPC message"));
13226
13410
  return this.createJsonErrorResponse(400, -32700, "Parse error: Invalid JSON-RPC message");
13227
13411
  }
13412
+ if (this._closed) {
13413
+ return this.createJsonErrorResponse(404, -32001, "Session not found");
13414
+ }
13228
13415
  const isInitializationRequest = messages.some(isInitializeRequest);
13229
13416
  if (isInitializationRequest) {
13230
13417
  if (this._initialized && this.sessionId !== undefined) {
@@ -13251,6 +13438,9 @@ data:
13251
13438
  return protocolError2;
13252
13439
  }
13253
13440
  }
13441
+ if (this._closed) {
13442
+ return this.createJsonErrorResponse(404, -32001, "Session not found");
13443
+ }
13254
13444
  const hasRequests = messages.some(isJSONRPCRequest);
13255
13445
  if (!hasRequests) {
13256
13446
  for (const message of messages) {
@@ -13281,18 +13471,25 @@ data:
13281
13471
  }
13282
13472
  const encoder = new TextEncoder;
13283
13473
  let streamController;
13474
+ let keepAliveTimer = undefined;
13284
13475
  const readable = new ReadableStream({
13285
13476
  start: (controller) => {
13286
13477
  streamController = controller;
13287
13478
  },
13288
13479
  cancel: () => {
13289
- this._streamMapping.delete(streamId);
13480
+ if (keepAliveTimer !== undefined) {
13481
+ clearInterval(keepAliveTimer);
13482
+ }
13483
+ if (this._streamMapping.get(streamId)?.controller === streamController) {
13484
+ this._streamMapping.delete(streamId);
13485
+ }
13290
13486
  }
13291
13487
  });
13292
13488
  const headers2 = {
13293
13489
  "Content-Type": "text/event-stream",
13294
- "Cache-Control": "no-cache",
13295
- Connection: "keep-alive"
13490
+ "Cache-Control": "no-cache, no-transform",
13491
+ Connection: "keep-alive",
13492
+ "X-Accel-Buffering": "no"
13296
13493
  };
13297
13494
  if (this.sessionId !== undefined) {
13298
13495
  headers2["mcp-session-id"] = this.sessionId;
@@ -13303,6 +13500,9 @@ data:
13303
13500
  controller: streamController,
13304
13501
  encoder,
13305
13502
  cleanup: () => {
13503
+ if (keepAliveTimer !== undefined) {
13504
+ clearInterval(keepAliveTimer);
13505
+ }
13306
13506
  this._streamMapping.delete(streamId);
13307
13507
  try {
13308
13508
  streamController.close();
@@ -13312,19 +13512,33 @@ data:
13312
13512
  this._requestToStreamMapping.set(message.id, streamId);
13313
13513
  }
13314
13514
  }
13315
- await this.writePrimingEvent(streamController, encoder, streamId, clientProtocolVersion);
13316
- for (const message of messages) {
13317
- let closeSSEStream;
13318
- let closeStandaloneSSEStream;
13319
- if (isJSONRPCRequest(message) && this._eventStore && clientProtocolVersion >= "2025-11-25") {
13320
- closeSSEStream = () => {
13321
- this.closeSSEStream(message.id);
13322
- };
13323
- closeStandaloneSSEStream = () => {
13324
- this.closeStandaloneSSEStream();
13325
- };
13515
+ try {
13516
+ await this.writePrimingEvent(streamController, encoder, streamId, clientProtocolVersion);
13517
+ for (const message of messages) {
13518
+ let closeSSEStream;
13519
+ let closeStandaloneSSEStream;
13520
+ if (isJSONRPCRequest(message) && this._eventStore && clientProtocolVersion >= "2025-11-25") {
13521
+ closeSSEStream = () => {
13522
+ this.closeSSEStream(message.id);
13523
+ };
13524
+ closeStandaloneSSEStream = () => {
13525
+ this.closeStandaloneSSEStream();
13526
+ };
13527
+ }
13528
+ this.onmessage?.(message, { authInfo: options?.authInfo, requestInfo, closeSSEStream, closeStandaloneSSEStream });
13326
13529
  }
13327
- this.onmessage?.(message, { authInfo: options?.authInfo, requestInfo, closeSSEStream, closeStandaloneSSEStream });
13530
+ } catch (error) {
13531
+ this._streamMapping.get(streamId)?.cleanup();
13532
+ this._resumableStreams.delete(streamId);
13533
+ for (const message of messages) {
13534
+ if (isJSONRPCRequest(message)) {
13535
+ this._requestToStreamMapping.delete(message.id);
13536
+ }
13537
+ }
13538
+ throw error;
13539
+ }
13540
+ if (this._streamMapping.get(streamId)?.controller === streamController) {
13541
+ keepAliveTimer = this.startKeepAlive(streamController, encoder);
13328
13542
  }
13329
13543
  return new Response(readable, { status: 200, headers: headers2 });
13330
13544
  } catch (error) {
@@ -13341,9 +13555,12 @@ data:
13341
13555
  if (protocolError2) {
13342
13556
  return protocolError2;
13343
13557
  }
13344
- await Promise.resolve(this._onsessionclosed?.(this.sessionId));
13345
- await this.close();
13346
- return new Response(null, { status: 200 });
13558
+ try {
13559
+ await Promise.resolve(this._onsessionclosed?.(this.sessionId));
13560
+ return new Response(null, { status: 200 });
13561
+ } finally {
13562
+ await this.close();
13563
+ }
13347
13564
  }
13348
13565
  validateSession(req) {
13349
13566
  if (this.sessionIdGenerator === undefined) {
@@ -13373,11 +13590,16 @@ data:
13373
13590
  return;
13374
13591
  }
13375
13592
  async close() {
13593
+ if (this._closed) {
13594
+ return;
13595
+ }
13596
+ this._closed = true;
13376
13597
  this._streamMapping.forEach(({ cleanup }) => {
13377
13598
  cleanup();
13378
13599
  });
13379
13600
  this._streamMapping.clear();
13380
13601
  this._requestResponseMap.clear();
13602
+ this._resumableStreams.clear();
13381
13603
  this.onclose?.();
13382
13604
  }
13383
13605
  closeSSEStream(requestId) {
@@ -13412,7 +13634,7 @@ data:
13412
13634
  if (standaloneSse === undefined) {
13413
13635
  return;
13414
13636
  }
13415
- if (standaloneSse.controller && standaloneSse.encoder) {
13637
+ if (standaloneSse.controller && standaloneSse.encoder && (eventId === undefined || !standaloneSse.replayedEventIds?.has(eventId))) {
13416
13638
  this.writeSSEEvent(standaloneSse.controller, standaloneSse.encoder, message, eventId);
13417
13639
  }
13418
13640
  return;
@@ -13421,13 +13643,19 @@ data:
13421
13643
  if (!streamId) {
13422
13644
  throw new Error(`No connection established for request ID: ${String(requestId)}`);
13423
13645
  }
13424
- const stream = this._streamMapping.get(streamId);
13425
- if (!this._enableJsonResponse && stream?.controller && stream?.encoder) {
13646
+ let stream = this._streamMapping.get(streamId);
13647
+ if (!this._enableJsonResponse) {
13426
13648
  let eventId;
13427
13649
  if (this._eventStore) {
13428
13650
  eventId = await this._eventStore.storeEvent(streamId, message);
13651
+ stream = this._streamMapping.get(streamId);
13652
+ }
13653
+ if (stream?.controller && stream?.encoder && (eventId === undefined || !stream.replayedEventIds?.has(eventId))) {
13654
+ const written = this.writeSSEEvent(stream.controller, stream.encoder, message, eventId);
13655
+ if (written && eventId !== undefined) {
13656
+ this._resumableStreams.add(streamId);
13657
+ }
13429
13658
  }
13430
- this.writeSSEEvent(stream.controller, stream.encoder, message, eventId);
13431
13659
  }
13432
13660
  if (isJSONRPCResultResponse(message) || isJSONRPCErrorResponse(message)) {
13433
13661
  this._requestResponseMap.set(requestId, message);
@@ -13435,6 +13663,25 @@ data:
13435
13663
  const allResponsesReady = relatedIds.every((id) => this._requestResponseMap.has(id));
13436
13664
  if (allResponsesReady) {
13437
13665
  if (!stream) {
13666
+ if (this._closed) {
13667
+ for (const id of relatedIds) {
13668
+ this._requestResponseMap.delete(id);
13669
+ this._requestToStreamMapping.delete(id);
13670
+ }
13671
+ return;
13672
+ }
13673
+ if (!this._enableJsonResponse && this._eventStore && this._resumableStreams.has(streamId)) {
13674
+ for (const id of relatedIds) {
13675
+ this._requestResponseMap.delete(id);
13676
+ this._requestToStreamMapping.delete(id);
13677
+ }
13678
+ this._resumableStreams.delete(streamId);
13679
+ return;
13680
+ }
13681
+ for (const id of relatedIds) {
13682
+ this._requestResponseMap.delete(id);
13683
+ this._requestToStreamMapping.delete(id);
13684
+ }
13438
13685
  throw new Error(`No connection established for request ID: ${String(requestId)}`);
13439
13686
  }
13440
13687
  if (this._enableJsonResponse && stream.resolveJson) {
@@ -13457,6 +13704,7 @@ data:
13457
13704
  this._requestResponseMap.delete(id);
13458
13705
  this._requestToStreamMapping.delete(id);
13459
13706
  }
13707
+ this._resumableStreams.delete(streamId);
13460
13708
  }
13461
13709
  }
13462
13710
  }
@@ -13524,7 +13772,7 @@ class StreamableHTTPServerTransport {
13524
13772
  }
13525
13773
 
13526
13774
  // src/http/mcp.ts
13527
- init_db();
13775
+ init_db2();
13528
13776
  init_env_flag();
13529
13777
  init_request_auth_context();
13530
13778
  init_task_tool_manifest();
@@ -13691,6 +13939,7 @@ async function handleMcp(req, res, transports, sessionActivity = {}, sessionAgen
13691
13939
  }
13692
13940
  const server = await createServer({
13693
13941
  preloadedTools,
13942
+ enabledTools: configs.find((config) => config.key === "SWARM_ENABLED_TOOLS")?.value ?? process.env.SWARM_ENABLED_TOOLS,
13694
13943
  scriptsOnly: resolveScriptsOnlyMode({
13695
13944
  env: process.env.SCRIPTS_ONLY_MCP,
13696
13945
  configValue
@@ -13719,7 +13968,7 @@ async function handleMcp(req, res, transports, sessionActivity = {}, sessionAgen
13719
13968
 
13720
13969
  // src/http/mcp-oauth.ts
13721
13970
  init_zod();
13722
- init_db();
13971
+ init_db2();
13723
13972
  init_types();
13724
13973
  init_constants();
13725
13974
  init_env_flag();
@@ -14461,7 +14710,7 @@ async function handleMcpOAuth(req, res, pathSegments, queryParams) {
14461
14710
 
14462
14711
  // src/http/mcp-servers.ts
14463
14712
  init_zod();
14464
- init_db();
14713
+ init_db2();
14465
14714
  init_rbac_roles();
14466
14715
  init_rbac();
14467
14716
  init_types();
@@ -15162,11 +15411,12 @@ function closeIdleMcpUserTransports(transports, sessionUsers, sessionActivity, o
15162
15411
 
15163
15412
  // src/http/memory.ts
15164
15413
  init_zod();
15165
- init_db();
15414
+ init_db2();
15415
+ init_memory();
15166
15416
  init_constants2();
15167
15417
 
15168
15418
  // src/be/memory/edges-store.ts
15169
- init_db();
15419
+ init_db2();
15170
15420
  var USEFULNESS_FLOOR = 1;
15171
15421
  var USEFULNESS_CEILING = 2;
15172
15422
  async function listEdgesForAgent(agentId, memoryId) {
@@ -15202,7 +15452,7 @@ init_key_paths();
15202
15452
  init_reranker();
15203
15453
 
15204
15454
  // src/be/memory/retrieval-store.ts
15205
- init_db();
15455
+ init_db2();
15206
15456
  var RETRIEVAL_CONTENT_SNIPPET_CHARS = 500;
15207
15457
  var RETRIEVAL_LIST_LIMIT = 50;
15208
15458
  async function getRetrievalsForAgent(agentId, filter) {
@@ -15245,7 +15495,7 @@ async function hasRetrievalForTask(taskId, memoryId) {
15245
15495
  }
15246
15496
 
15247
15497
  // src/be/memory/usefulness-stats.ts
15248
- init_db();
15498
+ init_db2();
15249
15499
  async function getUsefulnessStats(options = {}) {
15250
15500
  const days = options.days ?? 30;
15251
15501
  const threshold = options.threshold ?? 0.6;
@@ -16644,7 +16894,7 @@ function stopMemoryGc() {
16644
16894
 
16645
16895
  // src/http/metrics.ts
16646
16896
  init_zod();
16647
- init_db();
16897
+ init_db2();
16648
16898
  init_types();
16649
16899
  var DEFAULT_METRIC_MAX_ROWS = 100;
16650
16900
  var HARD_METRIC_MAX_ROWS = 500;
@@ -17098,7 +17348,7 @@ async function handleMetrics(req, res, pathSegments, queryParams, myAgentId) {
17098
17348
 
17099
17349
  // src/http/models-catalog.ts
17100
17350
  init_zod();
17101
- init_db();
17351
+ init_db2();
17102
17352
  init_rbac();
17103
17353
  init_types();
17104
17354
  init_request_auth_context();
@@ -17410,9 +17660,11 @@ async function handleModelsCatalog(req, res, pathSegments, queryParams) {
17410
17660
 
17411
17661
  // src/http/oauth-callback.ts
17412
17662
  init_zod();
17413
- init_db();
17663
+ init_db2();
17664
+ init_oauth();
17414
17665
 
17415
17666
  // src/jira/oauth.ts
17667
+ init_oauth();
17416
17668
  var ACCESSIBLE_RESOURCES_URL = "https://api.atlassian.com/oauth/token/accessible-resources";
17417
17669
  async function getJiraOAuthConfig() {
17418
17670
  const app = await getOAuthApp("jira");
@@ -17453,7 +17705,8 @@ async function resolveAndStoreJiraCloudId(accessToken) {
17453
17705
  }
17454
17706
 
17455
17707
  // src/linear/oauth.ts
17456
- init_db();
17708
+ init_db2();
17709
+ init_oauth();
17457
17710
  var APP_USER_ID_NAMESPACE = "integration:linear:bot-app-user-id";
17458
17711
  async function getLinearOAuthConfig() {
17459
17712
  const app = await getOAuthApp("linear");
@@ -17880,6 +18133,7 @@ async function handleGenericOAuth(req, res, pathSegments, queryParams) {
17880
18133
 
17881
18134
  // src/http/oauth-locks.ts
17882
18135
  init_zod();
18136
+ init_oauth();
17883
18137
  var MAX_LOCK_TTL_MS = 5 * 60 * 1000;
17884
18138
  var LOCK_KEY_PATTERN = /^[a-zA-Z0-9._:-]{1,200}$/;
17885
18139
  var LockKeySchema = exports_external.object({ key: exports_external.string().regex(LOCK_KEY_PATTERN) });
@@ -17946,13 +18200,16 @@ async function handleOAuthLocks(req, res, pathSegments, queryParams) {
17946
18200
 
17947
18201
  // src/http/onboarding.ts
17948
18202
  init_openai();
17949
- init_db();
18203
+ init_db2();
18204
+ init_memory();
17950
18205
  init_constants2();
17951
18206
  init_types();
18207
+ init_openrouter_base_url();
17952
18208
 
17953
18209
  // src/http/status.ts
17954
18210
  init_zod();
17955
- init_db();
18211
+ init_db2();
18212
+ init_memory();
17956
18213
  init_config();
17957
18214
  init_telemetry();
17958
18215
  init_types();
@@ -18671,6 +18928,7 @@ async function handleMemoryProbe(body) {
18671
18928
  const client = new OpenAI({
18672
18929
  baseURL: endpoint.toString(),
18673
18930
  apiKey,
18931
+ defaultHeaders: getOpenRouterAttributionHeaders(endpoint.toString()),
18674
18932
  timeout: 15000,
18675
18933
  maxRetries: 0,
18676
18934
  fetchOptions: { redirect: "manual" }
@@ -18742,7 +19000,7 @@ async function handleOnboarding(req, res, pathSegments, queryParams) {
18742
19000
  }
18743
19001
 
18744
19002
  // src/http/page-proxy.ts
18745
- init_db();
19003
+ init_db2();
18746
19004
  route({
18747
19005
  method: "get",
18748
19006
  path: "/@swarm/api/{path}",
@@ -18931,7 +19189,7 @@ async function handlePageProxy(req, res) {
18931
19189
  // src/http/pages.ts
18932
19190
  init_zod();
18933
19191
  import { randomUUID as randomUUID4 } from "node:crypto";
18934
- init_db();
19192
+ init_db2();
18935
19193
  init_types();
18936
19194
  init_constants();
18937
19195
  init_request_auth_context();
@@ -19489,7 +19747,7 @@ async function handlePages(req, res, pathSegments, queryParams, myAgentId) {
19489
19747
 
19490
19748
  // src/http/pages-public.ts
19491
19749
  init_zod();
19492
- init_db();
19750
+ init_db2();
19493
19751
  init_types();
19494
19752
  init_constants();
19495
19753
  init_secret_scrubber();
@@ -19919,7 +20177,7 @@ async function bumpViewCount(pageId) {
19919
20177
 
19920
20178
  // src/http/poll.ts
19921
20179
  init_zod();
19922
- init_db();
20180
+ init_db2();
19923
20181
 
19924
20182
  // src/slack/channel-activity.ts
19925
20183
  var cachedBotUserId = null;
@@ -20484,7 +20742,7 @@ async function handlePoll(req, res, pathSegments, queryParams, myAgentId) {
20484
20742
 
20485
20743
  // src/http/pricing.ts
20486
20744
  init_zod();
20487
- init_db();
20745
+ init_db2();
20488
20746
  init_types();
20489
20747
  init_secret_scrubber();
20490
20748
  import { createHash as createHash2 } from "node:crypto";
@@ -20660,7 +20918,7 @@ async function handlePricing(req, res, pathSegments, queryParams, _myAgentId) {
20660
20918
 
20661
20919
  // src/http/prompt-templates.ts
20662
20920
  init_zod();
20663
- init_db();
20921
+ init_db2();
20664
20922
  init_default_drift();
20665
20923
  init_registry();
20666
20924
  init_resolver();
@@ -21155,7 +21413,7 @@ async function handleRealtimeAsset(req, res) {
21155
21413
 
21156
21414
  // src/http/repos.ts
21157
21415
  init_zod();
21158
- init_db();
21416
+ init_db2();
21159
21417
  init_rbac();
21160
21418
  init_telemetry();
21161
21419
  init_types();
@@ -21635,6 +21893,7 @@ async function handleRooms(req, res, pathSegments, queryParams) {
21635
21893
  // src/http/schedules.ts
21636
21894
  init_zod();
21637
21895
  var import_cron_parser = __toESM(require_dist(), 1);
21896
+ init_db2();
21638
21897
  init_db();
21639
21898
  init_types();
21640
21899
  var scheduleUpdateBodySchema = exports_external.object({
@@ -22223,7 +22482,7 @@ async function handleSchedules(req, res, pathSegments, queryParams, myAgentId) {
22223
22482
 
22224
22483
  // src/http/script-connection-proxy.ts
22225
22484
  init_zod();
22226
- init_db();
22485
+ init_db2();
22227
22486
  init_rbac();
22228
22487
  var McpToolCallResultSchema = exports_external.object({
22229
22488
  content: exports_external.array(exports_external.object({ type: exports_external.string(), text: exports_external.string().optional() })),
@@ -22332,7 +22591,8 @@ async function handleScriptConnectionProxy(req, res, pathSegments, queryParams,
22332
22591
  // src/http/script-connections.ts
22333
22592
  init_zod();
22334
22593
  init_date_utils();
22335
- init_db();
22594
+ init_db2();
22595
+ init_oauth();
22336
22596
  init_rbac();
22337
22597
  init_credential_broker();
22338
22598
  init_telemetry();
@@ -24227,7 +24487,25 @@ async function handleScriptConnections(req, res, pathSegments, queryParams, agen
24227
24487
 
24228
24488
  // src/http/script-runs.ts
24229
24489
  init_zod();
24230
- init_db();
24490
+ init_db2();
24491
+
24492
+ // src/be/scripts/source-secrets.ts
24493
+ init_secret_scrubber();
24494
+ function refuseSourceWithSecrets(source) {
24495
+ const { knownValues, gitleaksRules } = findSecretsIn(source);
24496
+ if (knownValues.length === 0 && gitleaksRules.length === 0)
24497
+ return null;
24498
+ const findings = [
24499
+ ...knownValues.map((id) => ({ kind: "registered-secret", id })),
24500
+ ...gitleaksRules.map((id) => ({ kind: "gitleaks-rule", id }))
24501
+ ];
24502
+ const named = findings.map((f) => f.kind === "registered-secret" ? `registered secret ${f.id}` : `gitleaks rule ${f.id}`).join(", ");
24503
+ return {
24504
+ error: "source_contains_secret",
24505
+ message: `Script source contains a secret (${named}); nothing was saved or run. Source is stored and shown verbatim, so read secrets at run time instead: a credential binding (ctx.api.<slug> / ctx.mcp.<slug>) or ctx.swarm.config.get("<KEY>").`,
24506
+ findings
24507
+ };
24508
+ }
24231
24509
 
24232
24510
  // src/script-workflows/label-lint.ts
24233
24511
  var import_typescript = __toESM(require_typescript(), 1);
@@ -24300,6 +24578,7 @@ function lintWorkflowLabels(source) {
24300
24578
  // src/http/script-runs.ts
24301
24579
  init_types();
24302
24580
  init_constants();
24581
+ init_secret_scrubber();
24303
24582
  var DEFAULT_SCRIPT_RUN_CONCURRENCY_CAP = 10;
24304
24583
  var runIdParamsSchema = exports_external.object({ runId: exports_external.string().uuid() });
24305
24584
  var idParamsSchema3 = exports_external.object({ id: exports_external.string().uuid() });
@@ -24575,6 +24854,11 @@ async function handleScriptRuns(req, res, pathSegments, queryParams, agentId) {
24575
24854
  const agent = await requireAgent(res, agentId);
24576
24855
  if (!agent)
24577
24856
  return true;
24857
+ const secretRefusal = refuseSourceWithSecrets(parsed.body.source);
24858
+ if (secretRefusal) {
24859
+ json(res, secretRefusal, 400);
24860
+ return true;
24861
+ }
24578
24862
  const lint = lintWorkflowLabels(parsed.body.source);
24579
24863
  if (!lint.ok) {
24580
24864
  json(res, {
@@ -24728,7 +25012,7 @@ async function handleScriptRuns(req, res, pathSegments, queryParams, agentId) {
24728
25012
  config: parsed.body.config ?? {},
24729
25013
  status: parsed.body.status,
24730
25014
  result: parsed.body.result,
24731
- error: parsed.body.error,
25015
+ error: parsed.body.error === undefined ? undefined : scrubSecrets(parsed.body.error),
24732
25016
  durationMs: parsed.body.durationMs
24733
25017
  });
24734
25018
  return assertRunWithinLimits(run.id);
@@ -24859,7 +25143,9 @@ async function handleScriptRuns(req, res, pathSegments, queryParams, agentId) {
24859
25143
 
24860
25144
  // src/http/scripts.ts
24861
25145
  init_zod();
25146
+ init_db2();
24862
25147
  init_db();
25148
+ init_embeddings();
24863
25149
  init_rbac();
24864
25150
  init_types();
24865
25151
  init_secret_scrubber();
@@ -25315,6 +25601,11 @@ async function handleScripts(req, res, pathSegments, queryParams, agentId) {
25315
25601
  return true;
25316
25602
  }
25317
25603
  }
25604
+ const secretRefusal = refuseSourceWithSecrets(parsed.body.source);
25605
+ if (secretRefusal) {
25606
+ json(res, secretRefusal, 400);
25607
+ return true;
25608
+ }
25318
25609
  const typecheck = await typecheckScript(parsed.body.source, { agentId: agent.id });
25319
25610
  if (!typecheck.ok) {
25320
25611
  json(res, {
@@ -25365,6 +25656,11 @@ async function handleScripts(req, res, pathSegments, queryParams, agentId) {
25365
25656
  if (!agent)
25366
25657
  return true;
25367
25658
  const runtimeInstanceId = ((h) => Array.isArray(h) ? h[0] : h)(req.headers["x-runtime-instance-id"]);
25659
+ const secretRefusal = parsed.body.source ? refuseSourceWithSecrets(parsed.body.source) : null;
25660
+ if (secretRefusal) {
25661
+ json(res, secretRefusal, 400);
25662
+ return true;
25663
+ }
25368
25664
  let source = parsed.body.source;
25369
25665
  let fsMode = parsed.body.fsMode;
25370
25666
  let namedScript = null;
@@ -25723,7 +26019,7 @@ async function handleScripts(req, res, pathSegments, queryParams, agentId) {
25723
26019
 
25724
26020
  // src/http/session-data.ts
25725
26021
  init_zod();
25726
- init_db();
26022
+ init_db2();
25727
26023
  init_types();
25728
26024
 
25729
26025
  // src/http/session-cost-recompute.ts
@@ -26260,7 +26556,7 @@ async function handleSessionData(req, res, pathSegments, queryParams, _myAgentId
26260
26556
 
26261
26557
  // src/http/sessions.ts
26262
26558
  init_zod();
26263
- init_db();
26559
+ init_db2();
26264
26560
  init_steering();
26265
26561
  init_types();
26266
26562
  init_request_auth_context();
@@ -26481,11 +26777,11 @@ async function handleSessions(req, res, pathSegments, queryParams) {
26481
26777
 
26482
26778
  // src/http/skills.ts
26483
26779
  init_zod();
26484
- init_db();
26780
+ init_db2();
26485
26781
 
26486
26782
  // src/be/skill-sync.ts
26487
26783
  import { homedir } from "node:os";
26488
- init_db();
26784
+ init_db2();
26489
26785
  async function syncSkillsToFilesystem(agentId, harnessType = "all", homeOverride) {
26490
26786
  const skills = await getAgentSkills(agentId);
26491
26787
  const home = homeOverride ?? homedir();
@@ -27257,7 +27553,7 @@ async function handleSkills(req, res, pathSegments, queryParams, myAgentId) {
27257
27553
 
27258
27554
  // src/http/stats.ts
27259
27555
  init_zod();
27260
- init_db();
27556
+ init_db2();
27261
27557
  init_steering();
27262
27558
  init_types();
27263
27559
  init_env_flag();
@@ -27520,7 +27816,7 @@ async function handleStats(req, res, pathSegments, queryParams, myAgentId) {
27520
27816
 
27521
27817
  // src/http/task-templates.ts
27522
27818
  init_zod();
27523
- init_db();
27819
+ init_db2();
27524
27820
  init_types();
27525
27821
  var listTemplates = route({
27526
27822
  method: "get",
@@ -27560,7 +27856,7 @@ async function handleTaskTemplates(req, res, pathSegments, queryParams) {
27560
27856
 
27561
27857
  // src/http/tasks.ts
27562
27858
  init_zod();
27563
- init_db();
27859
+ init_db2();
27564
27860
  init_steering();
27565
27861
  init_rbac();
27566
27862
  init_types();
@@ -28995,6 +29291,7 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
28995
29291
 
28996
29292
  // src/http/trackers/jira.ts
28997
29293
  init_zod();
29294
+ init_oauth();
28998
29295
  var MANUAL_WEBHOOK_INSTRUCTIONS = "See docs-site/.../integrations/jira.mdx for manual webhook registration steps.";
28999
29296
  var JiraWebhookIdEntrySchema = exports_external.object({
29000
29297
  id: exports_external.number().int(),
@@ -29370,6 +29667,7 @@ async function handleJiraTracker(req, res, pathSegments) {
29370
29667
 
29371
29668
  // src/http/trackers/linear.ts
29372
29669
  init_zod();
29670
+ init_oauth();
29373
29671
 
29374
29672
  // src/linear/webhook.ts
29375
29673
  import { createHmac, timingSafeEqual } from "node:crypto";
@@ -29680,7 +29978,7 @@ async function handleTrackers(req, res, pathSegments) {
29680
29978
 
29681
29979
  // src/http/users.ts
29682
29980
  init_zod();
29683
- init_db();
29981
+ init_db2();
29684
29982
  init_types();
29685
29983
  init_request_auth_context();
29686
29984
 
@@ -30740,7 +31038,7 @@ async function handleUsers(req, res, pathSegments, queryParams) {
30740
31038
  init_zod();
30741
31039
 
30742
31040
  // src/agentmail/inbound-archive.ts
30743
- init_db();
31041
+ init_db2();
30744
31042
  init_secret_scrubber();
30745
31043
  import { createHash as createHash3 } from "node:crypto";
30746
31044
  var INBOUND_ARCHIVE_NAMESPACE = "agentmail-inbound";
@@ -31503,7 +31801,7 @@ async function handleWebhooks(req, res, pathSegments) {
31503
31801
 
31504
31802
  // src/http/workflow-events.ts
31505
31803
  init_zod();
31506
- init_db();
31804
+ init_db2();
31507
31805
  init_event_bus();
31508
31806
  var runScopedSignalRoute = route({
31509
31807
  method: "post",
@@ -31586,7 +31884,7 @@ async function handleWorkflowEvents(req, res, pathSegments, queryParams) {
31586
31884
 
31587
31885
  // src/http/workflows.ts
31588
31886
  init_zod();
31589
- init_db();
31887
+ init_db2();
31590
31888
  init_types();
31591
31889
  var WorkflowWithFavoriteSchema = WorkflowSchema.extend({ favorite: exports_external.boolean() });
31592
31890
  var WorkflowSaveResponseSchema = WorkflowSchema.extend({
@@ -32311,13 +32609,13 @@ async function handleWorkflows(req, res, pathSegments, queryParams, myAgentId) {
32311
32609
  const parsed = await getWorkflowRunRoute.parse(req, res, pathSegments, queryParams);
32312
32610
  if (!parsed)
32313
32611
  return true;
32314
- const run = await getWorkflowRun(parsed.params.id);
32612
+ const run = await getWorkflowRun(parsed.params.id, "display");
32315
32613
  if (!run) {
32316
32614
  res.writeHead(404);
32317
32615
  res.end();
32318
32616
  return true;
32319
32617
  }
32320
- const steps = await getWorkflowRunStepsByRunId(parsed.params.id);
32618
+ const steps = await getWorkflowRunStepsByRunId(parsed.params.id, "display");
32321
32619
  getWorkflowRunRoute.respond(res, 200, { run, steps });
32322
32620
  return true;
32323
32621
  }
@@ -32352,8 +32650,9 @@ async function handleWorkflows(req, res, pathSegments, queryParams, myAgentId) {
32352
32650
 
32353
32651
  // src/http/x.ts
32354
32652
  init_zod();
32355
- init_db();
32653
+ init_db2();
32356
32654
  import { timingSafeEqual as timingSafeEqual2 } from "node:crypto";
32655
+ init_db();
32357
32656
  init_secret_scrubber();
32358
32657
  var DEFAULT_TIMEOUT_MS = 60000;
32359
32658
  var TIMEOUT_HEADER = "x-swarm-timeout-ms";
@@ -32771,7 +33070,7 @@ async function shutdown() {
32771
33070
  sessionsProcessed: getServerSessionsProcessed()
32772
33071
  });
32773
33072
  if (hasCapability("scheduling")) {
32774
- const { stopScheduler } = await import("./index-9bfssf54.js");
33073
+ const { stopScheduler } = await import("./index-ekywyv2v.js");
32775
33074
  stopScheduler();
32776
33075
  }
32777
33076
  stopHeartbeat();
@@ -32780,7 +33079,7 @@ async function shutdown() {
32780
33079
  await stopScriptRunSupervisor();
32781
33080
  await stopSlackApp();
32782
33081
  if (process.env.OAUTH_KEEPALIVE_DISABLE !== "true") {
32783
- const { stopOAuthKeepalive } = await import("./keepalive-1tj10tf4.js");
33082
+ const { stopOAuthKeepalive } = await import("./keepalive-4aezx4bj.js");
32784
33083
  await stopOAuthKeepalive();
32785
33084
  }
32786
33085
  stopOAuthPendingGc();
@@ -32843,21 +33142,27 @@ try {
32843
33142
  throw err;
32844
33143
  }
32845
33144
  warnIfCorsAllowsAnyOrigin();
33145
+ try {
33146
+ const loaded = await loadSecretRegistry();
33147
+ console.log(`[secret-registry] registered config=${loaded.config} oauth=${loaded.oauth} scriptApi=${loaded.scriptApi} failed=${loaded.failed}`);
33148
+ } catch (err) {
33149
+ console.error("[secret-registry] load failed (non-fatal):", scrubSecrets(err instanceof Error ? err.message : String(err)));
33150
+ }
32846
33151
  try {
32847
33152
  await seedLegacyCapabilitiesConfig();
32848
33153
  } catch (err) {
32849
33154
  console.warn("[startup] CAPABILITIES upgrade seed failed (non-fatal):", err);
32850
33155
  }
32851
33156
  try {
32852
- const { ensurePricingSeeded } = await import("./boot-seeds-2bmnh18p.js");
33157
+ const { ensurePricingSeeded } = await import("./boot-seeds-22tx8a53.js");
32853
33158
  ensurePricingSeeded();
32854
- const { startPricingRefreshLoop } = await import("./pricing-refresh-9e0q7cwk.js");
33159
+ const { startPricingRefreshLoop } = await import("./pricing-refresh-mjrqvnvw.js");
32855
33160
  startPricingRefreshLoop();
32856
33161
  } catch (err) {
32857
33162
  console.error("[startup] Failed to seed pricing rows:", err);
32858
33163
  }
32859
33164
  try {
32860
- const { ensureRbacSeeded } = await import("./boot-seeds-2bmnh18p.js");
33165
+ const { ensureRbacSeeded } = await import("./boot-seeds-22tx8a53.js");
32861
33166
  ensureRbacSeeded();
32862
33167
  } catch (err) {
32863
33168
  console.error("[startup] Failed to sync RBAC seed rows:", err);
@@ -32865,7 +33170,7 @@ try {
32865
33170
  throw err;
32866
33171
  }
32867
33172
  try {
32868
- const { runAllSeeders } = await import("./index-7n70jwbb.js");
33173
+ const { runAllSeeders } = await import("./index-cx1sb9bq.js");
32869
33174
  await runAllSeeders({ scriptEmbeddingMode: "skip" });
32870
33175
  } catch (err) {
32871
33176
  console.error("[startup] Failed to seed built-in entities:", err);
@@ -32925,38 +33230,38 @@ httpServer.listen(port, async () => {
32925
33230
  await initWorkflows();
32926
33231
  await startScriptRunSupervisor(getMcpBaseUrl());
32927
33232
  if (hasCapability("scheduling")) {
32928
- const { startScheduler } = await import("./index-9bfssf54.js");
32929
- const { getExecutorRegistry: getExecutorRegistry2 } = await import("./index-k8xc083e.js");
33233
+ const { startScheduler } = await import("./index-ekywyv2v.js");
33234
+ const { getExecutorRegistry: getExecutorRegistry2 } = await import("./index-t4g06w93.js");
32930
33235
  const intervalMs = Number(process.env.SCHEDULER_INTERVAL_MS) || 1e4;
32931
33236
  startScheduler(getExecutorRegistry2(), intervalMs, {
32932
33237
  runId: globalState.__runId
32933
33238
  });
32934
33239
  }
32935
33240
  if (!isEnvFlagEnabled("HEARTBEAT_DISABLE", false)) {
32936
- const { startHeartbeat } = await import("./index-cj1r9q83.js");
33241
+ const { startHeartbeat } = await import("./index-bt8wkv1w.js");
32937
33242
  const heartbeatMs = Number(process.env.HEARTBEAT_INTERVAL_MS) || 90000;
32938
33243
  startHeartbeat(heartbeatMs);
32939
33244
  }
32940
33245
  if (process.env.OAUTH_KEEPALIVE_DISABLE !== "true") {
32941
- const { startOAuthKeepalive } = await import("./keepalive-1tj10tf4.js");
33246
+ const { startOAuthKeepalive } = await import("./keepalive-4aezx4bj.js");
32942
33247
  startOAuthKeepalive();
32943
33248
  }
32944
33249
  if (process.env.OAUTH_REFRESH_SWEEP_DISABLE !== "true") {
32945
- const { startOAuthRefreshSweep } = await import("./oauth-refresh-sweep-aefzwvvq.js");
33250
+ const { startOAuthRefreshSweep } = await import("./oauth-refresh-sweep-wm4ctjfj.js");
32946
33251
  startOAuthRefreshSweep();
32947
33252
  }
32948
33253
  startOAuthPendingGc();
32949
33254
  await startMemoryGc();
32950
33255
  await startDbRetention();
32951
33256
  startHumanFreeDrain();
32952
- import("./boot-reembed-2ex2mcsh.js").then(({ runBootReembed }) => runBootReembed()).catch((err) => {
33257
+ import("./boot-reembed-fmp5ww69.js").then(({ runBootReembed }) => runBootReembed()).catch((err) => {
32953
33258
  console.error("[boot-reembed] startup backfill failed (non-fatal):", err);
32954
33259
  });
32955
- import("./boot-reembed-z158xq32.js").then(({ runBootReembedScripts }) => runBootReembedScripts()).catch((err) => {
33260
+ import("./boot-reembed-1ze5853n.js").then(({ runBootReembedScripts }) => runBootReembedScripts()).catch((err) => {
32956
33261
  console.error("[boot-reembed-scripts] startup backfill failed (non-fatal):", err);
32957
33262
  });
32958
- import("./boot-scrub-logs-246yn076.js").then(({ runBootScrubLogs }) => runBootScrubLogs()).catch((err) => {
32959
- console.error("[boot-scrub-logs] startup scrub failed (non-fatal):", err);
33263
+ import("./boot-scrub-sweep-cbp8xd4e.js").then(({ runBootScrubSweep }) => runBootScrubSweep()).catch((err) => {
33264
+ console.error("[boot-scrub-sweep] startup scrub failed (non-fatal):", err);
32960
33265
  });
32961
33266
  }).on("error", (err) => {
32962
33267
  console.error("HTTP Server Error:", err);