@desplega.ai/agent-swarm 1.164.1 → 1.166.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 (328) hide show
  1. package/README.md +1 -1
  2. package/dist/acp-adapter-yzfxn8vj.js +23 -0
  3. package/dist/{actions-hp2h32dx.js → actions-qz3m692w.js} +24 -28
  4. package/dist/{amp-adapter-zfd7djyx.js → amp-adapter-j1xbmsqz.js} +7 -7
  5. package/dist/{app-w2d26h4f.js → app-43vrdmv8.js} +9 -10
  6. package/dist/{assistant-45pc4en7.js → assistant-ertffmka.js} +25 -29
  7. package/dist/{boot-reembed-k1q2s4fc.js → boot-reembed-998jtpdg.js} +12 -15
  8. package/dist/{boot-reembed-6rhcpsjf.js → boot-reembed-s7k7c6v2.js} +13 -15
  9. package/dist/boot-scrub-sweep-nepsk4t1.js +211 -0
  10. package/dist/{boot-seeds-ex93edx7.js → boot-seeds-vvzs1zhk.js} +12 -12
  11. package/dist/{claude-adapter-hcxd0szm.js → claude-adapter-2zvmekrp.js} +15 -17
  12. package/dist/{claude-managed-adapter-fz7xps2r.js → claude-managed-adapter-s49wbk8t.js} +5 -5
  13. package/dist/{claude-managed-setup-xx6f15h9.js → claude-managed-setup-cvhqq8qn.js} +4 -4
  14. package/dist/{claude-sdk-session-6nb9raem.js → claude-sdk-session-kkbxtw5q.js} +2624 -2606
  15. package/dist/{cli-etbrt8x1.js → cli-0nhdwxd5.js} +4 -4
  16. package/dist/{cli-jeefgppq.js → cli-0qjcsxgz.js} +7 -7
  17. package/dist/{cli-6behs2bt.js → cli-32bca7nr.js} +1 -1
  18. package/dist/{cli-gt8v96qx.js → cli-3ddybbbx.js} +4 -4
  19. package/dist/{acp-adapter-rxvek4ym.js → cli-3qn4r334.js} +317 -35
  20. package/dist/{cli-1d3w4xm3.js → cli-4r1sjfc4.js} +14 -6
  21. package/dist/{cli-691f2rxm.js → cli-66zh26sp.js} +68 -16
  22. package/dist/{cli-et8wdyqh.js → cli-68r1j4sg.js} +9 -9
  23. package/dist/{cli-xb7kyanp.js → cli-8kgvmkak.js} +3 -3
  24. package/dist/{cli-fdpkw8vk.js → cli-8t229cmr.js} +8 -8
  25. package/dist/{cli-gc54qc0p.js → cli-aqcey741.js} +1 -1
  26. package/dist/{cli-4q4cmr4t.js → cli-cpfmqz3n.js} +8 -8
  27. package/dist/{cli-a9bw0xxt.js → cli-df56tqdw.js} +997 -408
  28. package/dist/{cli-n7h1kqpf.js → cli-dmtrxqhg.js} +6 -1
  29. package/dist/{cli-xfb7333f.js → cli-dw2q9f7g.js} +5 -5
  30. package/dist/{cli-4drstbb9.js → cli-ecknp7p1.js} +81 -23
  31. package/dist/{cli-v0pvvhfq.js → cli-efnd2kce.js} +36 -1
  32. package/dist/{cli-1wetf34q.js → cli-f2n17zhp.js} +1 -1
  33. package/dist/{cli-2c8eky5y.js → cli-feh3dkah.js} +1 -1
  34. package/dist/cli-fn697bnt.js +126 -0
  35. package/dist/{cli-v5pr2fgt.js → cli-gt8azyet.js} +3 -3
  36. package/dist/{cli-dbszf3rw.js → cli-h3x613ze.js} +4 -4
  37. package/dist/{cli-nwhb8y2e.js → cli-hf5s9pgf.js} +1 -1
  38. package/dist/cli-j2jbr8af.js +516 -0
  39. package/dist/{cli-agjzafns.js → cli-jhm6hzjn.js} +593 -10
  40. package/dist/{cli-j0tmc908.js → cli-jvj6a0cv.js} +484 -477
  41. package/dist/{cli-xxz89c2n.js → cli-mb75wpxf.js} +1 -1
  42. package/dist/{cli-07s39g1n.js → cli-mv2520nm.js} +1 -1
  43. package/dist/{cli-v90vfwyb.js → cli-mwegs4af.js} +5 -5
  44. package/dist/{cli-bz1gbac9.js → cli-p4ztb80h.js} +2 -2
  45. package/dist/{cli-1wd1n2ya.js → cli-rfphkzh5.js} +1 -1
  46. package/dist/{cli-976r1zqx.js → cli-rggdq8wq.js} +5 -5
  47. package/dist/{cli-3ajw5v5v.js → cli-rsy933yz.js} +6 -6
  48. package/dist/{cli-yj790e19.js → cli-tadfgd0t.js} +8 -1
  49. package/dist/{cli-cn53e7vc.js → cli-ttbsse3f.js} +6 -1
  50. package/dist/{cli-dyqsrqcf.js → cli-v2a8x45d.js} +4 -4
  51. package/dist/{cli-wbvnn6tk.js → cli-v6vv7dy8.js} +91 -9
  52. package/dist/{cli-z2ap2c0c.js → cli-vzc73wet.js} +90 -55
  53. package/dist/cli-wt7ccy4r.js +2654 -0
  54. package/dist/{cli-4cn19jvn.js → cli-x7kpr72a.js} +3 -3
  55. package/dist/{cli-003785v9.js → cli-xvc3q9br.js} +1 -1
  56. package/dist/{cli-v0e7jpr5.js → cli-xvdgasgy.js} +13 -4
  57. package/dist/{cli-asqeg4ve.js → cli-y59h2pk9.js} +2 -2
  58. package/dist/{cli-0wn3ypqv.js → cli-yshaazs1.js} +14121 -3478
  59. package/dist/{cli-wg8yjqtw.js → cli-ysnyhws9.js} +16 -3
  60. package/dist/cli-zp67qg5x.js +92 -0
  61. package/dist/{cli-g3qgrzck.js → cli-zsh093hk.js} +71 -3
  62. package/dist/{cli-ma3zvh39.js → cli-zy7vwsne.js} +6066 -5829
  63. package/dist/cli.js +79 -26
  64. package/dist/{codex-adapter-pcxdn10v.js → codex-adapter-dw1wxqt8.js} +10 -10
  65. package/dist/{codex-hook-b1fb7c2k.js → codex-hook-d2rkvf39.js} +1 -1
  66. package/dist/{codex-login-059nm145.js → codex-login-terbdsqq.js} +2 -2
  67. package/dist/{codex-session-runner-xzwwddp8.js → codex-session-runner-3cgb8y1g.js} +10 -10
  68. package/dist/{commands-98at8mkn.js → commands-mhxam6z2.js} +9 -9
  69. package/dist/{cursor-adapter-dkg6qnkp.js → cursor-adapter-2qda3st7.js} +6 -6
  70. package/dist/{db-01g8wtvw.js → db-sjks418k.js} +11 -9
  71. package/dist/{devin-adapter-qmttt2fz.js → devin-adapter-bffjj5n4.js} +2 -2
  72. package/dist/{dispatcher-nn2k1wxd.js → dispatcher-1es759rn.js} +22 -26
  73. package/dist/{dsh-adapter-w4d4vwdq.js → dsh-adapter-bek4cyw9.js} +6 -6
  74. package/dist/{e2b-9e4g2hvt.js → e2b-nd50eccg.js} +1 -1
  75. package/dist/{event-bus-z7v2t26e.js → event-bus-vnfthafg.js} +2 -2
  76. package/dist/grok-adapter-ar9cw9jg.js +29 -0
  77. package/dist/{handlers-b0kqsbg8.js → handlers-1gkbhktr.js} +25 -29
  78. package/dist/{hook-sap7v1aj.js → hook-ds2zxq9v.js} +16 -18
  79. package/dist/{hook-pz50gqep.js → hook-vxa3tcsy.js} +10 -12
  80. package/dist/{http-ncr8rmd0.js → http-3h21z9md.js} +679 -227
  81. package/dist/{index-c4aqcyz1.js → index-9b65j1m5.js} +11 -11
  82. package/dist/{index-r46s01nq.js → index-bn6cy8ps.js} +22 -26
  83. package/dist/{index-38kqdt3e.js → index-dkfxpkmm.js} +23 -27
  84. package/dist/{index-630kj5vd.js → index-f8xnqrye.js} +55 -43
  85. package/dist/{index-fdk1t4d6.js → index-n0rxa4ca.js} +11962 -9900
  86. package/dist/{index-9nrj7797.js → index-n99fycq7.js} +22 -26
  87. package/dist/{keepalive-31613r2h.js → keepalive-3xspa9jw.js} +14 -11
  88. package/dist/{lead-mx59tr5s.js → lead-6qphc124.js} +43 -43
  89. package/dist/{maintenance-55ff39ca.js → maintenance-0teem1bb.js} +10 -12
  90. package/dist/{node-f0ykebbv.js → node-9sg7ajby.js} +25 -7
  91. package/dist/{oauth-refresh-sweep-anma954w.js → oauth-refresh-sweep-sh9q25xp.js} +13 -10
  92. package/dist/{onboard-b2fy8ftb.js → onboard-54qmnqxe.js} +4 -3
  93. package/dist/{opencode-adapter-p1s92tmy.js → opencode-adapter-wjfa2wvd.js} +6 -6
  94. package/dist/{otel-impl-9brvt7xv.js → otel-impl-ycqzp2a1.js} +2 -2
  95. package/dist/{pi-mono-adapter-kz4rrwvd.js → pi-mono-adapter-e77e9zst.js} +6 -6
  96. package/dist/{pricing-refresh-7w8mbmva.js → pricing-refresh-atnkngqs.js} +10 -10
  97. package/dist/{rbac-roles-ejp7qwvb.js → rbac-roles-9pjphh9q.js} +10 -10
  98. package/dist/{rbac-roles-nhk4r7bc.js → rbac-roles-j78wdksm.js} +10 -10
  99. package/dist/{render-v2-2gzt8skq.js → render-v2-pxjs49fx.js} +9 -10
  100. package/dist/{setup-5et8t412.js → setup-ymej0xtx.js} +2 -2
  101. package/dist/{work-objects-tb0er7qa.js → work-objects-3nh4ymzb.js} +26 -30
  102. package/dist/{worker-62cv075d.js → worker-qa9fkz5s.js} +43 -43
  103. package/dist/{x-vbxb31jr.js → x-ma4gnfgy.js} +2 -2
  104. package/openapi.json +457 -31
  105. package/package.json +14 -6
  106. package/plugin/commands/create-pr.md +7 -1
  107. package/plugin/pi-skills/create-pr/SKILL.md +7 -1
  108. package/src/agentmail/app.ts +5 -4
  109. package/src/be/automation-preflight.ts +11 -9
  110. package/src/be/boot-scrub-sweep.ts +302 -0
  111. package/src/be/connector-codes.ts +81 -0
  112. package/src/be/crypto/key-bootstrap.ts +1 -1
  113. package/src/be/db/approvals.ts +15 -1
  114. package/src/be/db/codex-oauth-device-flows.ts +40 -0
  115. package/src/be/db/config-secrets.ts +31 -0
  116. package/src/be/db/runtime.ts +4 -0
  117. package/src/be/db/script-runs.ts +15 -0
  118. package/src/be/db/tasks/write.ts +1 -1
  119. package/src/be/db-queries/mcp-oauth.ts +5 -0
  120. package/src/be/db-queries/oauth.ts +77 -0
  121. package/src/be/db.ts +162 -59
  122. package/src/be/events.ts +17 -1
  123. package/src/be/memory/index-content.ts +2 -2
  124. package/src/be/memory/providers/sqlite-store.ts +63 -11
  125. package/src/be/memory/types.ts +14 -0
  126. package/src/be/migrations/197_connector_codes.sql +23 -0
  127. package/src/be/migrations/198_permission_audit_guest.sql +33 -0
  128. package/src/be/migrations/200_backfill_auto_memory_expiry.sql +20 -0
  129. package/src/be/migrations/201_workflow_replay_columns.sql +10 -0
  130. package/src/be/migrations/202_codex_oauth_device_flows.sql +24 -0
  131. package/src/be/model-tier-resolution.ts +2 -1
  132. package/src/be/model-validation.ts +1 -1
  133. package/src/be/pricing-normalize.ts +3 -0
  134. package/src/be/rbac-audit.ts +2 -1
  135. package/src/be/scripts/db.ts +28 -4
  136. package/src/be/scripts/source-secrets.ts +37 -0
  137. package/src/be/scripts/typecheck.ts +23 -2
  138. package/src/be/scrub-json.ts +32 -0
  139. package/src/be/sealed-json.ts +59 -0
  140. package/src/be/secret-registry.ts +131 -0
  141. package/src/be/seed-pricing.ts +14 -0
  142. package/src/be/users.ts +7 -1
  143. package/src/be/workflow-replay.ts +77 -0
  144. package/src/cli.tsx +7 -0
  145. package/src/commands/provider-credentials.ts +46 -8
  146. package/src/commands/runner.ts +2 -10
  147. package/src/extensions/contract-types.generated.ts +1 -1
  148. package/src/github/app.ts +4 -4
  149. package/src/heartbeat/heartbeat.ts +20 -8
  150. package/src/hooks/pr-body-guard.ts +1 -1
  151. package/src/http/agents.ts +1 -0
  152. package/src/http/approval-requests.ts +1 -0
  153. package/src/http/apps.ts +3 -0
  154. package/src/http/auth.ts +4 -1
  155. package/src/http/codex-oauth-device.ts +8 -10
  156. package/src/http/codex-oauth-keep-warm.ts +2 -2
  157. package/src/http/config-values.ts +59 -0
  158. package/src/http/config.ts +5 -0
  159. package/src/http/db-query-bounded.ts +3 -0
  160. package/src/http/db-query-shared.ts +107 -15
  161. package/src/http/db-query.ts +10 -2
  162. package/src/http/extensions.ts +1 -0
  163. package/src/http/index.ts +23 -6
  164. package/src/http/integrations.ts +1 -38
  165. package/src/http/ip-rate-limit.ts +82 -0
  166. package/src/http/kv.ts +38 -4
  167. package/src/http/mcp-servers.ts +1 -0
  168. package/src/http/memory.ts +9 -0
  169. package/src/http/models-catalog.ts +2 -0
  170. package/src/http/operator-actor.ts +4 -0
  171. package/src/http/page-proxy.ts +22 -0
  172. package/src/http/pages.ts +4 -2
  173. package/src/http/realtime.ts +1 -1
  174. package/src/http/request-principal.ts +14 -1
  175. package/src/http/script-connections.ts +8 -0
  176. package/src/http/script-runs.ts +12 -4
  177. package/src/http/scripts.ts +15 -0
  178. package/src/http/session-cost-recompute.ts +3 -2
  179. package/src/http/tasks.ts +9 -0
  180. package/src/http/users.ts +226 -0
  181. package/src/http/workflows.ts +3 -2
  182. package/src/http.ts +1 -0
  183. package/src/integrations/kapso/client.ts +3 -1
  184. package/src/jira/app.ts +2 -2
  185. package/src/kv-view.ts +324 -0
  186. package/src/linear/app.ts +2 -2
  187. package/src/oauth/mcp-wrapper.ts +1 -1
  188. package/src/prompts/memories.ts +42 -1
  189. package/src/providers/acp-adapter.ts +85 -24
  190. package/src/providers/acp-target-catalog.ts +54 -1
  191. package/src/providers/acp-targets.ts +358 -4
  192. package/src/providers/amp-adapter.ts +1 -1
  193. package/src/providers/cursor-adapter.ts +1 -1
  194. package/src/providers/grok-adapter.ts +186 -0
  195. package/src/providers/index.ts +5 -1
  196. package/src/providers/pricing-sources.md +6 -0
  197. package/src/providers/reasoning-effort.ts +17 -1
  198. package/src/providers/types.ts +2 -1
  199. package/src/rbac/can.ts +4 -3
  200. package/src/rbac/legacy-policy.ts +3 -3
  201. package/src/rbac/types.ts +6 -0
  202. package/src/script-workflows/supervisor.ts +11 -2
  203. package/src/scripts-runtime/eval-harness.ts +2 -12
  204. package/src/scripts-runtime/executors/quickjs-bundle.ts +152 -0
  205. package/src/scripts-runtime/executors/quickjs-prelude.ts +285 -0
  206. package/src/scripts-runtime/executors/quickjs-runner.ts +580 -0
  207. package/src/scripts-runtime/executors/quickjs-worker.ts +81 -0
  208. package/src/scripts-runtime/executors/quickjs.ts +196 -0
  209. package/src/scripts-runtime/executors/registry.ts +2 -0
  210. package/src/scripts-runtime/executors/sourcemap.ts +79 -0
  211. package/src/scripts-runtime/script-error-hints.ts +14 -0
  212. package/src/scripts-runtime/swarm-sdk.ts +9 -2
  213. package/src/scripts-runtime/types/stdlib.d.ts +27 -8
  214. package/src/scripts-runtime/types/swarm-extension.d.ts +3 -0
  215. package/src/scripts-runtime/types/swarm-sdk.d.ts +27 -8
  216. package/src/server-user.ts +2 -20
  217. package/src/server.ts +3 -1
  218. package/src/slack/app.ts +4 -0
  219. package/src/slack/config.ts +3 -1
  220. package/src/slack/egress-scrub.ts +87 -0
  221. package/src/tests/acp-adapter.test.ts +191 -2
  222. package/src/tests/boot-scrub-sweep.test.ts +390 -0
  223. package/src/tests/budget-user-scope.test.ts +7 -21
  224. package/src/tests/check-pr-body.test.ts +149 -6
  225. package/src/tests/check-text-columns.test.ts +145 -0
  226. package/src/tests/claude-adapter-binary.test.ts +1 -1
  227. package/src/tests/claude-sdk-process.fixture.ts +13 -2
  228. package/src/tests/codex-oauth-device.test.ts +23 -37
  229. package/src/tests/codex-oauth-keep-warm.test.ts +29 -0
  230. package/src/tests/console-scrub.test.ts +141 -0
  231. package/src/tests/credential-check.test.ts +90 -0
  232. package/src/tests/db-query-denylist.test.ts +202 -0
  233. package/src/tests/db-task-read-contract.test.ts +1 -0
  234. package/src/tests/db-task-write-contract.test.ts +1 -0
  235. package/src/tests/docs-index-footprint.test.js +3 -3
  236. package/src/tests/entrypoint-acp-target-binary.test.ts +44 -1
  237. package/src/tests/events-scrub.test.ts +88 -0
  238. package/src/tests/explicit-model-validation.test.ts +81 -0
  239. package/src/tests/extensions-pre-task.test.ts +33 -1
  240. package/src/tests/fixtures/grok/acp-updates-recorded.jsonl +53 -0
  241. package/src/tests/fixtures/grok/prompt-response-meta.json +36 -0
  242. package/src/tests/fixtures/secret-corpus.ts +320 -0
  243. package/src/tests/grok-adapter.test.ts +647 -0
  244. package/src/tests/heartbeat-checklist.test.ts +44 -0
  245. package/src/tests/integration-disable-flags.test.ts +156 -0
  246. package/src/tests/kv-http.test.ts +34 -0
  247. package/src/tests/kv-tool.test.ts +274 -1
  248. package/src/tests/kv-view.test.ts +147 -0
  249. package/src/tests/mcp-user-route.test.ts +257 -15
  250. package/src/tests/memory-injection-outcome.test.ts +143 -0
  251. package/src/tests/model-tier-resolution.test.ts +76 -3
  252. package/src/tests/page-guest-session.test.ts +424 -0
  253. package/src/tests/page-proxy.test.ts +1 -1
  254. package/src/tests/page-viewer-auth.test.ts +22 -1
  255. package/src/tests/pr-body-leaks.test.ts +157 -2
  256. package/src/tests/preload.ts +10 -0
  257. package/src/tests/provider-registration.test.ts +3 -1
  258. package/src/tests/rbac-audit.test.ts +32 -0
  259. package/src/tests/rbac-mcp-admission-e2e.test.ts +4 -62
  260. package/src/tests/script-connections.test.ts +9 -0
  261. package/src/tests/script-executor-conformance.test.ts +3 -0
  262. package/src/tests/script-executor-quickjs.test.ts +442 -0
  263. package/src/tests/script-executor-registry.test.ts +6 -1
  264. package/src/tests/script-runs-http.test.ts +126 -1
  265. package/src/tests/script-runs-scrub.test.ts +275 -0
  266. package/src/tests/scripts-http.test.ts +82 -1
  267. package/src/tests/scripts-mcp-e2e.test.ts +42 -6
  268. package/src/tests/scripts-runtime.test.ts +37 -0
  269. package/src/tests/scrubbed-text-12e.test.ts +289 -0
  270. package/src/tests/sealed-key-guard.test.ts +166 -0
  271. package/src/tests/secret-canary-sweep.test.ts +958 -0
  272. package/src/tests/secret-registry.test.ts +355 -0
  273. package/src/tests/secret-rules.test.ts +230 -0
  274. package/src/tests/secret-scrubber.test.ts +317 -1
  275. package/src/tests/session-costs-golden.test.ts +17 -0
  276. package/src/tests/slack-egress-scrub.test.ts +216 -0
  277. package/src/tests/swarm-tool-result-gate.test.ts +143 -30
  278. package/src/tests/task-tools-ctx.test.ts +3 -0
  279. package/src/tests/user-token-routes.test.ts +342 -3
  280. package/src/tests/workflow-replay.test.ts +518 -0
  281. package/src/tests/workflow-scrub.test.ts +242 -0
  282. package/src/tests/workflow-system-one-decision-providers.test.ts +737 -0
  283. package/src/tools/db-query.ts +1 -1
  284. package/src/tools/inject-learning.ts +1 -1
  285. package/src/tools/kv/kv-get.ts +136 -6
  286. package/src/tools/send-task.ts +61 -17
  287. package/src/tools/utils.ts +186 -43
  288. package/src/tools/workflows/get-workflow-run.ts +3 -2
  289. package/src/types.ts +16 -1
  290. package/src/utils/console-scrub-install.ts +5 -0
  291. package/src/utils/console-scrub.ts +57 -0
  292. package/src/utils/credentials.ts +8 -0
  293. package/src/utils/page-session.ts +6 -2
  294. package/src/utils/pr-body-leaks.ts +149 -10
  295. package/src/utils/request-auth-context.ts +2 -0
  296. package/src/utils/secret-rules.generated.ts +2055 -0
  297. package/src/utils/secret-scrubber.ts +662 -36
  298. package/src/workflows/engine.ts +39 -4
  299. package/src/workflows/executors/notify.ts +6 -1
  300. package/src/workflows/executors/system-one-decision.ts +31 -12
  301. package/src/workflows/executors/system-one-openai-wire.ts +168 -0
  302. package/src/workflows/executors/system-one-providers.ts +112 -11
  303. package/src/workflows/executors/system-one-wire.ts +79 -0
  304. package/src/workflows/recovery.ts +10 -1
  305. package/src/workflows/resume.ts +62 -3
  306. package/src/workflows/retry-poller.ts +3 -0
  307. package/templates/ai-toolbox.manifest.json +2 -2
  308. package/templates/skills/agent-browser/SKILL.md +5 -5
  309. package/templates/skills/agent-browser/config.json +1 -1
  310. package/templates/skills/agent-browser/content.md +4 -4
  311. package/templates/skills/artifacts/content.md +17 -7
  312. package/templates/skills/jira-interaction/config.json +1 -1
  313. package/templates/skills/jira-interaction/content.md +56 -205
  314. package/templates/skills/linear-interaction/config.json +1 -1
  315. package/templates/skills/linear-interaction/content.md +31 -50
  316. package/templates/skills/pages/content.md +8 -4
  317. package/templates/skills/qa/content.md +2 -2
  318. package/templates/skills/workflow-iterate/content.md +4 -4
  319. package/tsconfig.json +3 -3
  320. package/dist/boot-scrub-logs-t8xg7wd7.js +0 -99
  321. package/dist/cli-0a7r5331.js +0 -168
  322. package/dist/cli-93rxw9yd.js +0 -951
  323. package/dist/cli-cvk6yzw5.js +0 -40
  324. package/dist/cli-dgnj0zcc.js +0 -40
  325. package/dist/cli-qt5wzq6v.js +0 -256
  326. package/dist/cli-v7fqehqd.js +0 -9281
  327. package/dist/cli-vbr859rz.js +0 -572
  328. package/src/be/boot-scrub-logs.ts +0 -132
@@ -2,15 +2,15 @@ import {
2
2
  BROWSER_SDK_JS,
3
3
  SWARM_UI_JS
4
4
  } from "./cli-t1ze64h3.js";
5
- import {
6
- ACP_TARGET_IDS
7
- } from "./cli-dgnj0zcc.js";
8
5
  import {
9
6
  SIMILARITY_THRESHOLD,
10
7
  isUnknownModelError,
11
8
  memoryRelevance,
12
9
  writeSkillsToFilesystem
13
- } from "./cli-v0pvvhfq.js";
10
+ } from "./cli-efnd2kce.js";
11
+ import {
12
+ ACP_TARGET_IDS
13
+ } from "./cli-zp67qg5x.js";
14
14
  import {
15
15
  isCodexOAuthConfigKey
16
16
  } from "./cli-bqjfjex4.js";
@@ -23,19 +23,22 @@ import {
23
23
  } from "./cli-2pdaysab.js";
24
24
  import {
25
25
  reasoningCapability
26
- } from "./cli-cn53e7vc.js";
26
+ } from "./cli-ttbsse3f.js";
27
27
  import {
28
28
  ensureAgentFsCredentialsForAgent,
29
29
  inviteEmailToSharedOrg
30
- } from "./cli-v5pr2fgt.js";
30
+ } from "./cli-gt8azyet.js";
31
31
  import {
32
+ DEFAULT_CONNECTOR_CODE_LABEL,
32
33
  checkHeartbeatChecklist,
34
+ createConnectorCode,
35
+ exchangeConnectorCode,
33
36
  runHeartbeatSweep,
34
37
  stopHeartbeat
35
- } from "./cli-691f2rxm.js";
38
+ } from "./cli-66zh26sp.js";
36
39
  import {
37
40
  Anthropic
38
- } from "./cli-ma3zvh39.js";
41
+ } from "./cli-zy7vwsne.js";
39
42
  import {
40
43
  AGENT_MAX_TASKS_CONFIG_KEY,
41
44
  ALL_CAPABILITIES,
@@ -178,6 +181,7 @@ import {
178
181
  handleWorkflowRun,
179
182
  harnessModelErrorFor,
180
183
  hasCapability,
184
+ hasKvViewArgs,
181
185
  httpServerSemconvAttributes,
182
186
  hydrateOAuthAppFromPreset,
183
187
  indexMemoryContent,
@@ -263,6 +267,7 @@ import {
263
267
  resolveHttpFavoriteOwner,
264
268
  resolveHttpRequestAuth,
265
269
  resolveIdentity,
270
+ resolveKvView,
266
271
  resolveRoomNamespace,
267
272
  resolveScopedResourceId,
268
273
  resolveScriptsOnlyMode,
@@ -305,9 +310,6 @@ import {
305
310
  stopExtensionRuntime,
306
311
  stripSiblingBlock,
307
312
  sweepRooms,
308
- taskActionHandler,
309
- taskActionInputSchema,
310
- taskActionOutputSchema,
311
313
  toolErr,
312
314
  touchRuntimeInstance,
313
315
  triggerSchemaErrorResponse,
@@ -333,13 +335,13 @@ import {
333
335
  workflowModelErrors,
334
336
  workflowSaveWarnings,
335
337
  writeUnhandledError
336
- } from "./cli-a9bw0xxt.js";
337
- import"./cli-003785v9.js";
338
+ } from "./cli-df56tqdw.js";
339
+ import"./cli-xvc3q9br.js";
338
340
  import {
339
341
  AMP_ESTIMATE_MODELS,
340
342
  ampBillsCacheWrites,
341
343
  resolveAmpModel
342
- } from "./cli-07s39g1n.js";
344
+ } from "./cli-mv2520nm.js";
343
345
  import {
344
346
  RATING_MODEL_MAX_LENGTH,
345
347
  REFERENCES_SOURCE_MAX_LENGTH,
@@ -348,16 +350,16 @@ import {
348
350
  import {
349
351
  isMultiRuntimeEnabled
350
352
  } from "./cli-re8z5p8p.js";
351
- import"./cli-etbrt8x1.js";
353
+ import"./cli-0nhdwxd5.js";
352
354
  import {
353
355
  deleteModelCatalogOverlay,
354
356
  loadModelsCatalog,
355
357
  requestModelCatalogRefresh,
356
358
  upsertModelCatalogOverlay
357
- } from "./cli-976r1zqx.js";
359
+ } from "./cli-rggdq8wq.js";
358
360
  import {
359
361
  normalizeModelKey
360
- } from "./cli-wg8yjqtw.js";
362
+ } from "./cli-ysnyhws9.js";
361
363
  import {
362
364
  ConnectionAuthInputSchema,
363
365
  MAX_SCRIPT_WALL_CLOCK_MS,
@@ -379,11 +381,8 @@ import {
379
381
  connectionAuthSummary,
380
382
  consumeMcpOAuthPending,
381
383
  createApprovalFollowUpTask,
382
- createScriptApi,
383
384
  definitionNodeIds,
384
385
  deleteMcpOAuthToken,
385
- deleteScript,
386
- deleteScriptApi,
387
386
  discoverAuthorizationServerMetadata,
388
387
  discoverProtectedResourceMetadata,
389
388
  ensureMcpToken,
@@ -398,13 +397,9 @@ import {
398
397
  getCredentialBindingById,
399
398
  getMcpOAuthToken,
400
399
  getOAuthBindingTokenStatus,
401
- getScript,
402
- getScriptApiById,
403
400
  getScriptApiConnectionDescriptors,
404
- getScriptApiSecret,
405
401
  getScriptApiTypes,
406
402
  getScriptAppTypes,
407
- getScriptById,
408
403
  getScriptConnectionById,
409
404
  getScriptMcpConnectionDescriptors,
410
405
  getScriptMcpTypes,
@@ -413,27 +408,21 @@ import {
413
408
  isInvalidClientError,
414
409
  listAppRecords,
415
410
  listRelationalCredentialBindings,
416
- listScriptApisForScript,
417
411
  listScriptConnections,
418
412
  listScriptConnectionsAsync,
419
- listScriptVersions,
420
- listScripts,
421
413
  listVendoredOpenapiEntries,
422
414
  markMcpOAuthTokenStatus,
423
415
  normalizeTokenEndpointAuthMethod,
424
416
  oauthAppToProviderConfig,
425
417
  publicEndpointSsrfOptions,
426
418
  readStreamCapped,
427
- recordScriptApiUsage,
428
419
  refreshMcpToken,
429
420
  refreshScriptConnection,
430
421
  registerClient,
431
422
  require_dist,
432
423
  require_typescript,
433
424
  resolveAdvertisedTokenEndpointAuthMethod,
434
- restoreScratchScriptLastUsedIfUnchanged,
435
425
  revokeMcpToken,
436
- rotateScriptApiSecret,
437
426
  runScript,
438
427
  sandboxSpawnEnv,
439
428
  scriptSdkTypesWithGeneratedApis,
@@ -441,16 +430,13 @@ import {
441
430
  selectDcrTokenEndpointAuthMethod,
442
431
  setMcpServerAuthMethod,
443
432
  setScriptConnectionEnabled,
444
- touchScratchScriptLastUsed,
445
433
  typecheckScript,
446
434
  typecheckWithAmbient,
447
- updateScriptApi,
448
435
  upsertCredentialBinding,
449
436
  upsertMcpOAuthToken,
450
- upsertScriptByName,
451
437
  upsertScriptConnection,
452
438
  validateDefinition
453
- } from "./cli-j0tmc908.js";
439
+ } from "./cli-jvj6a0cv.js";
454
440
  import"./cli-epan13p1.js";
455
441
  import {
456
442
  getApiKey
@@ -462,7 +448,7 @@ import {
462
448
  signalProcessGroup,
463
449
  terminateProcessGroup
464
450
  } from "./cli-zt3w1cn1.js";
465
- import"./cli-1wetf34q.js";
451
+ import"./cli-f2n17zhp.js";
466
452
  import {
467
453
  CLIENT_ID,
468
454
  MAX_CODEX_OAUTH_SLOT,
@@ -473,7 +459,7 @@ import {
473
459
  getAccountId,
474
460
  getValidCodexOAuth,
475
461
  loadAllCodexOAuthSlots
476
- } from "./cli-2c8eky5y.js";
462
+ } from "./cli-feh3dkah.js";
477
463
  import"./cli-3dpj7atn.js";
478
464
  import"./cli-2x0e561b.js";
479
465
  import"./cli-pkke6geq.js";
@@ -486,46 +472,12 @@ import {
486
472
  normalizeFilesError
487
473
  } from "./cli-mzfth0bp.js";
488
474
  import {
489
- searchScripts
490
- } from "./cli-0a7r5331.js";
491
- import {
492
- CANDIDATE_SET_MULTIPLIER,
493
- EMBEDDING_DIMENSIONS,
494
- MEMORY_KEY_MAX_LENGTH,
495
- OpenAI,
496
- getEmbeddingProvider,
497
- getMemoryStore,
498
- init_constants as init_constants2,
499
- init_key_paths,
500
- init_openai,
501
- init_reranker,
502
- rerank
503
- } from "./cli-v7fqehqd.js";
504
- import"./cli-agjzafns.js";
505
- import {
506
- acquireOAuthRefreshLock,
507
475
  buildAuthorizationUrl,
508
- consumeOAuthPending,
509
- createOAuthApp,
510
- deleteAuthorizationById,
511
- deleteAuthorizationsForApp,
512
- deleteOAuthTokens,
513
476
  exchangeAuthorizationCode,
514
477
  forceRefreshAuthorizationOrThrow,
515
478
  forceRefreshTokenOrThrow,
516
- gcOAuthPending,
517
- getAuthorizationById,
518
- getDefaultAuthorizationIdForProvider,
519
- getOAuthApp,
520
- getOAuthAppById,
521
- getOAuthTokens,
522
- listAuthorizationsForApp,
523
- oauthAppRowToProviderConfig,
524
- releaseOAuthRefreshLock,
525
- updateAuthorizationIdentity,
526
- updateOAuthAppById,
527
- upsertAuthorization
528
- } from "./cli-93rxw9yd.js";
479
+ oauthAppRowToProviderConfig
480
+ } from "./cli-j2jbr8af.js";
529
481
  import"./cli-fad8m16k.js";
530
482
  import"./cli-bsakbbkm.js";
531
483
  import"./cli-zxg80zs9.js";
@@ -550,10 +502,9 @@ import {
550
502
  withRemoteContext,
551
503
  withSpan,
552
504
  withSpanContext
553
- } from "./cli-4drstbb9.js";
505
+ } from "./cli-ecknp7p1.js";
554
506
  import"./cli-q51yprfq.js";
555
507
  import"./cli-3er6gcsn.js";
556
- import"./cli-cvk6yzw5.js";
557
508
  import"./cli-yatxqynm.js";
558
509
  import {
559
510
  bedrockProviderModule
@@ -581,7 +532,7 @@ import"./cli-pzxba7gw.js";
581
532
  import {
582
533
  getUserGrant,
583
534
  init_rbac_roles
584
- } from "./cli-xb7kyanp.js";
535
+ } from "./cli-8kgvmkak.js";
585
536
  import {
586
537
  LEGACY_RULES,
587
538
  can,
@@ -590,22 +541,27 @@ import {
590
541
  init_rbac,
591
542
  isRbacEnabled,
592
543
  setAuditSink
593
- } from "./cli-1wd1n2ya.js";
544
+ } from "./cli-rfphkzh5.js";
594
545
  import {
595
546
  API_DRAINING_HEADER,
547
+ CANDIDATE_SET_MULTIPLIER,
596
548
  CODEX_AUTH_WATCH_NAMESPACE,
597
549
  CredentialBindingSchema,
598
550
  DB_RETENTION_TUNING_BOUNDS,
551
+ EMBEDDING_DIMENSIONS,
599
552
  EXTENSION_AGENT_ROLE,
600
553
  ExtensionAgentAssignmentError,
601
554
  HeartbeatExpiryError,
602
555
  KvTypeCollisionError,
603
556
  MAX_DB_RETENTION_DAYS,
557
+ MEMORY_KEY_MAX_LENGTH,
604
558
  NOT_EXTENSION_AGENT_SQL,
559
+ OpenAI,
605
560
  ReservedAgentRoleError,
606
561
  SteeringRequestError,
607
562
  _resolveIntegrationProvider,
608
563
  _resolveIntegrationType,
564
+ acquireOAuthRefreshLock,
609
565
  agentContextKey,
610
566
  auditAssetKeys,
611
567
  backfillSupersedeTaskResumeTaskId,
@@ -624,6 +580,7 @@ import {
624
580
  completeTask,
625
581
  computeContentHash,
626
582
  configureOrgDomainPersistence,
583
+ consumeOAuthPending,
627
584
  countActiveScriptRuns,
628
585
  countAllMetrics,
629
586
  countAllPages,
@@ -640,8 +597,10 @@ import {
640
597
  createLogEntry,
641
598
  createMcpServer,
642
599
  createMetric,
600
+ createOAuthApp,
643
601
  createPage,
644
602
  createScheduledTask,
603
+ createScriptApi,
645
604
  createScriptRun,
646
605
  createSessionCost,
647
606
  createSessionLogs,
@@ -653,14 +612,19 @@ import {
653
612
  decryptSecret,
654
613
  deleteActiveSession,
655
614
  deleteActiveSessionById,
615
+ deleteAuthorizationById,
616
+ deleteAuthorizationsForApp,
656
617
  deleteBudget,
657
618
  deleteKv,
658
619
  deleteMcpServer,
659
620
  deleteMetric,
621
+ deleteOAuthTokens,
660
622
  deletePage,
661
623
  deletePricingRow,
662
624
  deletePromptTemplate,
663
625
  deleteScheduledTask,
626
+ deleteScript,
627
+ deleteScriptApi,
664
628
  deleteSkill,
665
629
  deleteSkillFile,
666
630
  deleteSwarmConfig,
@@ -677,6 +641,7 @@ import {
677
641
  encryptSecret,
678
642
  extensionAgentAssignmentError,
679
643
  failTask,
644
+ gcOAuthPending,
680
645
  getActivePricingRow,
681
646
  getActiveSessions,
682
647
  getAgentById,
@@ -697,6 +662,7 @@ import {
697
662
  getAllUsers,
698
663
  getApprovalRequestById,
699
664
  getAttributionByPerson,
665
+ getAuthorizationById,
700
666
  getAvailableKeyIndices,
701
667
  getBudget,
702
668
  getBudgets,
@@ -708,6 +674,8 @@ import {
708
674
  getDashboardCostSummary,
709
675
  getDb,
710
676
  getDbClient,
677
+ getDefaultAuthorizationIdForProvider,
678
+ getEmbeddingProvider,
711
679
  getEncryptionKey,
712
680
  getInboxSummary,
713
681
  getInstanceActivity,
@@ -721,9 +689,13 @@ import {
721
689
  getLogsByAgentId,
722
690
  getLogsByTaskId,
723
691
  getMcpServerById,
692
+ getMemoryStore,
724
693
  getMetric,
725
694
  getMetricVersion,
726
695
  getMetricVersions,
696
+ getOAuthApp,
697
+ getOAuthAppById,
698
+ getOAuthTokens,
727
699
  getOfferedTasksForAgent,
728
700
  getPage,
729
701
  getPageBySlug,
@@ -748,8 +720,13 @@ import {
748
720
  getScheduledTaskById,
749
721
  getScheduledTaskByName,
750
722
  getScheduledTasks,
723
+ getScript,
724
+ getScriptApiById,
725
+ getScriptApiSecret,
726
+ getScriptById,
751
727
  getScriptRun,
752
728
  getScriptRunByIdempotencyKey,
729
+ getScriptRunExecutionArgs,
753
730
  getScriptRunJournalStep,
754
731
  getServicesByAgentId,
755
732
  getSessionCostSummary,
@@ -791,16 +768,25 @@ import {
791
768
  init_api_drain,
792
769
  init_asset_key_audit,
793
770
  init_codex_auth_failure,
771
+ init_constants as init_constants2,
794
772
  init_context_key,
795
773
  init_credential_broker,
796
774
  init_crypto,
797
775
  init_date_utils,
798
776
  init_db,
777
+ init_db1 as init_db2,
799
778
  init_default_drift,
779
+ init_embeddings,
800
780
  init_heartbeat_expiry,
801
781
  init_human_free,
782
+ init_key_paths,
783
+ init_memory,
784
+ init_oauth,
785
+ init_openai,
802
786
  init_request_auth_context,
787
+ init_reranker,
803
788
  init_runtime,
789
+ init_secret_registry,
804
790
  init_steering,
805
791
  init_swarm_config_guard,
806
792
  init_task_tool_manifest,
@@ -826,6 +812,7 @@ import {
826
812
  listApprovalRequestSummaries,
827
813
  listApprovalRequests,
828
814
  listAssetSummaries,
815
+ listAuthorizationsForApp,
829
816
  listFavorites,
830
817
  listInboxState,
831
818
  listKv,
@@ -833,13 +820,17 @@ import {
833
820
  listMetricsByAgent,
834
821
  listPagesByAgent,
835
822
  listRecentSessions,
823
+ listScriptApisForScript,
836
824
  listScriptRunJournalSteps,
837
825
  listScriptRuns,
826
+ listScriptVersions,
827
+ listScripts,
838
828
  listSkillFileManifest,
839
829
  listSkills,
840
830
  listTaskTemplates,
841
831
  listWorkflowRunsPage,
842
832
  listWorkflows,
833
+ loadSecretRegistry,
843
834
  markKeyRateLimited,
844
835
  markSteeringDelivered,
845
836
  markSteeringHandled,
@@ -860,9 +851,12 @@ import {
860
851
  recordKeyRateLimitWindows,
861
852
  recordKeySeatMismatch,
862
853
  recordKeyUsage,
854
+ recordScriptApiUsage,
863
855
  recordTaskProviderIfUnset,
864
856
  refreshActiveSessionOnActivity,
857
+ releaseOAuthRefreshLock,
865
858
  requestSteering,
859
+ rerank,
866
860
  reservedKeyError,
867
861
  resetEmptyPollCount,
868
862
  resetOrphanedInProgressTasksForAgent,
@@ -870,7 +864,10 @@ import {
870
864
  resolveApprovalRequest,
871
865
  resolvePromptTemplate,
872
866
  resolveTriggerSurface,
867
+ restoreScratchScriptLastUsedIfUnchanged,
873
868
  resumeTask,
869
+ rotateScriptApiSecret,
870
+ searchScripts,
874
871
  searchSkills,
875
872
  selectTaskTools,
876
873
  setAgentHarnessProvider,
@@ -885,6 +882,7 @@ import {
885
882
  supersedeTask,
886
883
  sweepExpiredKv,
887
884
  telemetry,
885
+ touchScratchScriptLastUsed,
888
886
  uninstallMcpServer,
889
887
  uninstallSkill,
890
888
  updateActiveSessionProviderSessionId,
@@ -898,9 +896,12 @@ import {
898
896
  updateAgentProvider,
899
897
  updateAgentStatus,
900
898
  updateAgentStatusFromCapacity,
899
+ updateAuthorizationIdentity,
901
900
  updateMetric,
901
+ updateOAuthAppById,
902
902
  updatePage,
903
903
  updateScheduledTask,
904
+ updateScriptApi,
904
905
  updateScriptRun,
905
906
  updateScriptRunIfNotTerminal,
906
907
  updateScriptRunIfRunning,
@@ -911,18 +912,20 @@ import {
911
912
  updateTaskVcs,
912
913
  updateUser,
913
914
  upsertAssetKeyMapping,
915
+ upsertAuthorization,
914
916
  upsertBudget,
915
917
  upsertChannelActivityCursor,
916
918
  upsertInboxState,
917
919
  upsertKv,
918
920
  upsertPromptTemplate,
921
+ upsertScriptByName,
919
922
  upsertScriptRunJournalStep,
920
923
  upsertSkillFile,
921
924
  upsertSkillFiles,
922
925
  upsertSwarmConfig,
923
926
  validateConfigValue,
924
927
  withFavoriteFlags
925
- } from "./cli-0wn3ypqv.js";
928
+ } from "./cli-yshaazs1.js";
926
929
  import {
927
930
  ActiveSessionSchema,
928
931
  AgentAcpStatusSchema,
@@ -1049,23 +1052,23 @@ import {
1049
1052
  isSafeBundlePath,
1050
1053
  isTerminalTaskStatus,
1051
1054
  splitLegacyModelAlias
1052
- } from "./cli-v0e7jpr5.js";
1055
+ } from "./cli-xvdgasgy.js";
1053
1056
  import"./cli-3qhyh31j.js";
1054
1057
  import {
1055
1058
  IDENTITY_FIELD_BUDGETS,
1056
1059
  IdentityFieldBudgetError,
1057
1060
  init_identity_field_budget
1058
- } from "./cli-vbr859rz.js";
1059
- import {
1060
- getSlackConfiguration,
1061
- init_config
1062
- } from "./cli-n7h1kqpf.js";
1061
+ } from "./cli-jhm6hzjn.js";
1063
1062
  import {
1064
1063
  init_steering_enabled,
1065
1064
  isSteeringEnabled
1066
1065
  } from "./cli-7mm2r1kp.js";
1067
1066
  import"./cli-g5erf0zt.js";
1068
- import"./cli-yj790e19.js";
1067
+ import {
1068
+ getSlackConfiguration,
1069
+ init_config
1070
+ } from "./cli-dmtrxqhg.js";
1071
+ import"./cli-tadfgd0t.js";
1069
1072
  import {
1070
1073
  MODEL_SCOPED_WINDOWS,
1071
1074
  activeModelBlocks,
@@ -1105,7 +1108,7 @@ import {
1105
1108
  import {
1106
1109
  init_src,
1107
1110
  isAlias
1108
- } from "./cli-g3qgrzck.js";
1111
+ } from "./cli-zsh093hk.js";
1109
1112
  import {
1110
1113
  exports_zod,
1111
1114
  init_zod
@@ -1122,26 +1125,69 @@ import {
1122
1125
  import {
1123
1126
  init_package,
1124
1127
  package_default
1125
- } from "./cli-1d3w4xm3.js";
1128
+ } from "./cli-4r1sjfc4.js";
1126
1129
  import {
1127
1130
  init_event_bus,
1128
1131
  workflowEventBus
1129
- } from "./cli-xxz89c2n.js";
1132
+ } from "./cli-mb75wpxf.js";
1130
1133
  import {
1131
1134
  init_bus,
1132
1135
  realtimeBus
1133
1136
  } from "./cli-zf8jjwex.js";
1134
1137
  import {
1138
+ findSecretsIn,
1135
1139
  init_secret_scrubber,
1136
1140
  registerVolatileSecret,
1137
1141
  scrubObject,
1138
1142
  scrubSecrets
1139
- } from "./cli-qt5wzq6v.js";
1143
+ } from "./cli-wt7ccy4r.js";
1140
1144
  import {
1141
1145
  __require,
1142
1146
  __toESM
1143
1147
  } from "./cli-bc05qbss.js";
1144
1148
 
1149
+ // src/utils/console-scrub.ts
1150
+ init_secret_scrubber();
1151
+ import { format } from "node:util";
1152
+ var METHODS = ["log", "info", "warn", "error", "debug"];
1153
+ var SCRUB_FAILED = "[console-scrub] failed to scrub log line";
1154
+ var NESTED_SUPPRESSED = "[console-scrub] suppressed a log line written while formatting another";
1155
+ var restore;
1156
+ function installConsoleScrub() {
1157
+ if (restore)
1158
+ return;
1159
+ const originals = new Map;
1160
+ let scrubbing = false;
1161
+ for (const method of METHODS) {
1162
+ const original = console[method];
1163
+ originals.set(method, original);
1164
+ console[method] = (...args) => {
1165
+ if (args.length === 0)
1166
+ return original.call(console);
1167
+ if (scrubbing)
1168
+ return original.call(console, NESTED_SUPPRESSED);
1169
+ scrubbing = true;
1170
+ let line;
1171
+ try {
1172
+ line = scrubSecrets(format(...args));
1173
+ } catch {
1174
+ line = SCRUB_FAILED;
1175
+ } finally {
1176
+ scrubbing = false;
1177
+ }
1178
+ original.call(console, line);
1179
+ };
1180
+ }
1181
+ restore = () => {
1182
+ for (const [method, original] of originals)
1183
+ console[method] = original;
1184
+ restore = undefined;
1185
+ };
1186
+ }
1187
+
1188
+ // src/utils/console-scrub-install.ts
1189
+ installConsoleScrub();
1190
+
1145
1191
  // src/utils/internal-ai/register-bedrock.ts
1146
1192
  setBedrockProviderModule(bedrockProviderModule);
1147
1193
 
@@ -1149,13 +1195,13 @@ setBedrockProviderModule(bedrockProviderModule);
1149
1195
  import {
1150
1196
  createServer as createHttpServer
1151
1197
  } from "node:http";
1152
- init_db();
1198
+ init_db2();
1153
1199
 
1154
1200
  // src/be/db-retention.ts
1155
1201
  import { AsyncLocalStorage } from "node:async_hooks";
1156
1202
  init_env_flag();
1157
1203
  init_secret_scrubber();
1158
- init_db();
1204
+ init_db2();
1159
1205
  init_swarm_config_guard();
1160
1206
  var DAY_MS = 24 * 60 * 60 * 1000;
1161
1207
  var RETENTION_INTERVAL_MS = 60 * 60 * 1000;
@@ -1706,7 +1752,7 @@ function stopHumanFreeDrain() {
1706
1752
  }
1707
1753
 
1708
1754
  // src/be/scripts/retention.ts
1709
- init_db();
1755
+ init_db2();
1710
1756
  var SCRATCH_RETENTION_DAYS = 14;
1711
1757
  var SCRATCH_GC_INTERVAL_MS = 24 * 60 * 60 * 1000;
1712
1758
  var scratchGcTimer = null;
@@ -1813,8 +1859,11 @@ function stopScratchScriptGc() {
1813
1859
  scratchGcTimer = null;
1814
1860
  }
1815
1861
 
1862
+ // src/http/index.ts
1863
+ init_secret_registry();
1864
+
1816
1865
  // src/be/seed-capabilities.ts
1817
- init_db();
1866
+ init_db2();
1818
1867
  var LEGACY_ALWAYS_ON_DEFAULTS = [
1819
1868
  "core",
1820
1869
  "config",
@@ -1849,7 +1898,7 @@ async function seedLegacyCapabilitiesConfig() {
1849
1898
  }
1850
1899
 
1851
1900
  // src/queue-stall-alarm.ts
1852
- init_db();
1901
+ init_db2();
1853
1902
  init_secret_scrubber();
1854
1903
  var QUEUE_STALL_THRESHOLD_MS = 30 * 60 * 1000;
1855
1904
  var QUEUE_STALL_CHECK_INTERVAL_MS = 5 * 60 * 1000;
@@ -2010,7 +2059,7 @@ init_bus();
2010
2059
 
2011
2060
  // src/realtime/transport.ts
2012
2061
  init_zod();
2013
- init_db();
2062
+ init_db2();
2014
2063
  init_secret_scrubber();
2015
2064
  init_bus();
2016
2065
 
@@ -2427,7 +2476,8 @@ function connect(ws, auth) {
2427
2476
  }
2428
2477
 
2429
2478
  // src/script-workflows/supervisor.ts
2430
- init_db();
2479
+ init_db2();
2480
+ init_secret_scrubber();
2431
2481
 
2432
2482
  // src/script-workflows/executor.ts
2433
2483
  import { randomUUID } from "node:crypto";
@@ -3271,7 +3321,9 @@ async function startScriptRunProcess(run, baseUrl, apiKeyOverride) {
3271
3321
  if (process.env.SCRIPT_WORKFLOW_DEBUG === "true") {
3272
3322
  console.error(`[script-workflows] spawning ${run.id} auth override=${apiKeyOverride ? "yes" : "no"} len=${apiKey.length}`);
3273
3323
  }
3274
- const execution = await scriptExecutor.start({ run, baseUrl, apiKey });
3324
+ const sealedArgs = await getScriptRunExecutionArgs(run.id);
3325
+ const args = sealedArgs === undefined ? run.args : sealedArgs;
3326
+ const execution = await scriptExecutor.start({ run: { ...run, args }, baseUrl, apiKey });
3275
3327
  managed.set(run.id, { execution });
3276
3328
  await updateScriptRun(run.id, {
3277
3329
  status: "running",
@@ -3282,7 +3334,7 @@ async function startScriptRunProcess(run, baseUrl, apiKeyOverride) {
3282
3334
  const current = await getScriptRun(run.id);
3283
3335
  if (current && current.status === "running") {
3284
3336
  if (exitCode !== 0) {
3285
- console.error(`[script-workflows] run ${run.id} subprocess exited ${exitCode}: ${stderr.trim() || "(no stderr)"}`);
3337
+ console.error(scrubSecrets(`[script-workflows] run ${run.id} subprocess exited ${exitCode}: ${stderr.trim() || "(no stderr)"}`));
3286
3338
  }
3287
3339
  await updateScriptRunIfRunning(run.id, {
3288
3340
  status: exitCode === 0 ? "completed" : "failed",
@@ -3520,7 +3572,7 @@ init_secret_scrubber();
3520
3572
 
3521
3573
  // src/http/active-sessions.ts
3522
3574
  init_zod();
3523
- init_db();
3575
+ init_db2();
3524
3576
  init_types();
3525
3577
  var listActiveSessions = route({
3526
3578
  method: "get",
@@ -3723,7 +3775,7 @@ async function handleActiveSessions(req, res, pathSegments, queryParams, myAgent
3723
3775
  // src/http/agents.ts
3724
3776
  init_src();
3725
3777
  init_zod();
3726
- init_db();
3778
+ init_db2();
3727
3779
  init_telemetry();
3728
3780
  init_types();
3729
3781
  init_constants();
@@ -3815,7 +3867,8 @@ var LocalHarnessProviderSchema = exports_external.enum([
3815
3867
  "acp",
3816
3868
  "dsh",
3817
3869
  "amp",
3818
- "cursor"
3870
+ "cursor",
3871
+ "grok"
3819
3872
  ]);
3820
3873
  var AcpRuntimeConfigSchema = exports_external.object({
3821
3874
  target: exports_external.enum(ACP_TARGET_IDS),
@@ -4802,7 +4855,7 @@ async function handleAgentsRest(req, res, pathSegments, queryParams, _myAgentId)
4802
4855
 
4803
4856
  // src/http/api-keys.ts
4804
4857
  init_zod();
4805
- init_db();
4858
+ init_db2();
4806
4859
  init_model_rate_limit_windows();
4807
4860
  init_subscription_plans();
4808
4861
 
@@ -5456,7 +5509,7 @@ async function handleApiKeys(req, res, pathSegments, queryParams) {
5456
5509
 
5457
5510
  // src/http/approval-requests.ts
5458
5511
  init_zod();
5459
- init_db();
5512
+ init_db2();
5460
5513
  init_rbac();
5461
5514
  init_request_auth_context();
5462
5515
  init_event_bus();
@@ -5932,6 +5985,8 @@ async function approvalCancelPrincipal(req) {
5932
5985
  }
5933
5986
  const rawAgentId = req.headers["x-agent-id"];
5934
5987
  const agentId = auth?.kind === "agent" ? auth.agentId : Array.isArray(rawAgentId) ? rawAgentId[0] : rawAgentId;
5988
+ if (auth?.kind === "guest")
5989
+ return { principal: { kind: "guest" }, resolvedBy: null };
5935
5990
  if (agentId) {
5936
5991
  const agent = await getAgentById(agentId);
5937
5992
  return {
@@ -6019,13 +6074,14 @@ async function approvalQuorumMet(approvers, votes) {
6019
6074
  // src/http/assets.ts
6020
6075
  init_zod();
6021
6076
  init_asset_key_audit();
6077
+ init_db2();
6022
6078
  init_db();
6023
6079
  init_rbac();
6024
6080
  init_types();
6025
6081
  init_request_auth_context();
6026
6082
 
6027
6083
  // src/http/request-principal.ts
6028
- init_db();
6084
+ init_db2();
6029
6085
  init_request_auth_context();
6030
6086
  async function requestPrincipal(req, myAgentId) {
6031
6087
  const auth = getRequestAuth(req);
@@ -6033,6 +6089,8 @@ async function requestPrincipal(req, myAgentId) {
6033
6089
  return { kind: "operator" };
6034
6090
  if (auth?.kind === "user")
6035
6091
  return { kind: "user", userId: auth.userId };
6092
+ if (auth?.kind === "guest")
6093
+ return { kind: "guest" };
6036
6094
  if (!myAgentId)
6037
6095
  return null;
6038
6096
  const agent = await getAgentById(myAgentId);
@@ -6042,12 +6100,20 @@ async function agentFirstPrincipal(req, myAgentId) {
6042
6100
  const auth = getRequestAuth(req);
6043
6101
  if (auth?.kind === "user")
6044
6102
  return { kind: "user", userId: auth.userId };
6103
+ if (auth?.kind === "guest")
6104
+ return { kind: "guest" };
6045
6105
  const agentId = auth?.kind === "agent" ? auth.agentId : myAgentId;
6046
6106
  if (!agentId)
6047
6107
  return { kind: "operator" };
6048
6108
  const agent = await getAgentById(agentId);
6049
6109
  return { kind: "agent", agentId, isLead: agent?.isLead === true };
6050
6110
  }
6111
+ function rejectGuest(req, res) {
6112
+ if (getRequestAuth(req)?.kind !== "guest")
6113
+ return false;
6114
+ jsonError(res, "Forbidden", 403);
6115
+ return true;
6116
+ }
6051
6117
 
6052
6118
  // src/http/assets.ts
6053
6119
  var AssetKeyAuditIssueSchema = exports_external.object({
@@ -6349,7 +6415,7 @@ async function handleAssets(req, res, pathSegments, queryParams, myAgentId) {
6349
6415
 
6350
6416
  // src/http/budgets.ts
6351
6417
  init_zod();
6352
- init_db();
6418
+ init_db2();
6353
6419
  init_types();
6354
6420
  init_secret_scrubber();
6355
6421
  import { createHash } from "node:crypto";
@@ -6512,14 +6578,37 @@ async function handleBudgets(req, res, pathSegments, queryParams, _myAgentId) {
6512
6578
  // src/http/codex-oauth-device.ts
6513
6579
  init_zod();
6514
6580
  init_crypto();
6515
- init_db();
6581
+ init_db2();
6582
+
6583
+ // src/be/db/codex-oauth-device-flows.ts
6584
+ init_runtime();
6585
+ async function getCodexDeviceFlow(flowId) {
6586
+ const row = await getDbClient().get("SELECT state, expires_at FROM codex_oauth_device_flows WHERE flow_id = ?", [flowId]);
6587
+ if (!row)
6588
+ return null;
6589
+ if (row.expires_at <= Date.now()) {
6590
+ await getDbClient().run("DELETE FROM codex_oauth_device_flows WHERE flow_id = ?", [flowId]);
6591
+ return null;
6592
+ }
6593
+ return { state: row.state, expiresAt: row.expires_at };
6594
+ }
6595
+ async function upsertCodexDeviceFlow(input) {
6596
+ const now = Date.now();
6597
+ await getDbClient().run("DELETE FROM codex_oauth_device_flows WHERE expires_at <= ?", [now]);
6598
+ await getDbClient().run(`INSERT INTO codex_oauth_device_flows (flow_id, state, expires_at, created_at, updated_at)
6599
+ VALUES (?, ?, ?, ?, ?)
6600
+ ON CONFLICT(flow_id) DO UPDATE SET
6601
+ state = excluded.state,
6602
+ expires_at = excluded.expires_at,
6603
+ updated_at = excluded.updated_at`, [input.flowId, input.state, input.expiresAt, now, now]);
6604
+ }
6516
6605
 
6517
6606
  // src/be/onboarding.ts
6518
6607
  init_telemetry();
6519
6608
  init_types();
6520
6609
  init_request_auth_context();
6521
6610
  init_zod_openapi();
6522
- init_db();
6611
+ init_db2();
6523
6612
  init_swarm_config_guard();
6524
6613
  var ONBOARDING_CONFIG_KEY = "onboarding_state";
6525
6614
  var OnboardingStepIdSchema = exports_zod.enum([
@@ -7128,7 +7217,7 @@ init_secret_scrubber();
7128
7217
 
7129
7218
  // src/http/config.ts
7130
7219
  init_zod();
7131
- init_db();
7220
+ init_db2();
7132
7221
  init_rbac_roles();
7133
7222
  init_swarm_config_guard();
7134
7223
  init_rbac();
@@ -7158,6 +7247,8 @@ async function requestMayReadSecrets(req) {
7158
7247
  source: "http"
7159
7248
  }).allow;
7160
7249
  }
7250
+ if (auth?.kind === "guest")
7251
+ return false;
7161
7252
  if (auth?.kind !== "user")
7162
7253
  return true;
7163
7254
  if (!isRbacEnabled())
@@ -7175,6 +7266,10 @@ async function ensureConfigAdmin(req, res, verb) {
7175
7266
  const auth = getRequestAuth(req);
7176
7267
  if (auth?.kind === "operator" || auth?.kind === "user")
7177
7268
  return true;
7269
+ if (auth?.kind === "guest") {
7270
+ jsonError(res, "Forbidden", 403);
7271
+ return false;
7272
+ }
7178
7273
  const agentId = auth?.kind === "agent" ? auth.agentId : singleHeader(req, "x-agent-id");
7179
7274
  const agent = agentId ? await getAgentById(agentId) : undefined;
7180
7275
  const decision = can({
@@ -7505,7 +7600,6 @@ async function handleConfig(req, res, pathSegments, queryParams) {
7505
7600
  }
7506
7601
 
7507
7602
  // src/http/codex-oauth-device.ts
7508
- var FLOW_NAMESPACE = "codex-oauth-device";
7509
7603
  var FLOW_TTL_MS = 15 * 60 * 1000;
7510
7604
  var POLL_LEASE_MS = 45000;
7511
7605
  var FlowStateSchema = exports_external.object({
@@ -7565,11 +7659,11 @@ function registerFlowSecrets(state) {
7565
7659
  registerVolatileSecret(state.userCode, "codex-device-user-code");
7566
7660
  }
7567
7661
  async function readFlow(flowId) {
7568
- const entry = await getKv(FLOW_NAMESPACE, flowId);
7569
- if (!entry || typeof entry.value !== "string")
7662
+ const entry = await getCodexDeviceFlow(flowId);
7663
+ if (!entry)
7570
7664
  return null;
7571
7665
  try {
7572
- const plaintext = decryptSecret(entry.value, getEncryptionKey());
7666
+ const plaintext = decryptSecret(entry.state, getEncryptionKey());
7573
7667
  const parsed = FlowStateSchema.safeParse(JSON.parse(plaintext));
7574
7668
  if (!parsed.success)
7575
7669
  return null;
@@ -7580,11 +7674,9 @@ async function readFlow(flowId) {
7580
7674
  }
7581
7675
  }
7582
7676
  async function writeFlow(flowId, state) {
7583
- await upsertKv({
7584
- namespace: FLOW_NAMESPACE,
7585
- key: flowId,
7586
- value: encryptSecret(JSON.stringify(state), getEncryptionKey()),
7587
- valueType: "string",
7677
+ await upsertCodexDeviceFlow({
7678
+ flowId,
7679
+ state: encryptSecret(JSON.stringify(state), getEncryptionKey()),
7588
7680
  expiresAt: state.expiresAt
7589
7681
  });
7590
7682
  }
@@ -7794,8 +7886,9 @@ async function handleCodexOAuthDevice(req, res, pathSegments, queryParams) {
7794
7886
 
7795
7887
  // src/http/codex-oauth-keep-warm.ts
7796
7888
  init_zod();
7797
- init_db();
7889
+ init_db2();
7798
7890
  init_codex_auth_failure();
7891
+ init_constants();
7799
7892
  var KEEP_WARM_MAX_AGE_MS = 7 * 24 * 60 * 60 * 1000;
7800
7893
  var slotOutcomeSchema = exports_external.discriminatedUnion("outcome", [
7801
7894
  exports_external.object({ slot: exports_external.number(), keySuffix: exports_external.string(), outcome: exports_external.literal("warm") }),
@@ -7829,7 +7922,7 @@ async function handleCodexOAuthKeepWarm(req, res, pathSegments) {
7829
7922
  const parsed = await keepWarmRoute.parse(req, res, pathSegments, new URLSearchParams);
7830
7923
  if (!parsed)
7831
7924
  return true;
7832
- const apiUrl = deriveApiBaseUrl(req);
7925
+ const apiUrl = getMcpBaseUrl();
7833
7926
  const apiKey = getApiKey();
7834
7927
  const slots = await loadAllCodexOAuthSlots(apiUrl, apiKey);
7835
7928
  const results = [];
@@ -7867,7 +7960,7 @@ async function handleCodexOAuthKeepWarm(req, res, pathSegments) {
7867
7960
  init_zod();
7868
7961
 
7869
7962
  // src/comb/review-batch.ts
7870
- init_db();
7963
+ init_db2();
7871
7964
  init_resolver();
7872
7965
  init_constants();
7873
7966
  init_secret_scrubber();
@@ -8308,7 +8401,7 @@ async function handleComb(req, res, pathSegments, queryParams, myAgentId) {
8308
8401
 
8309
8402
  // src/http/context.ts
8310
8403
  init_zod();
8311
- init_db();
8404
+ init_db2();
8312
8405
  init_types();
8313
8406
  var PostContextResponseSchema = exports_external.object({
8314
8407
  ok: exports_external.literal(true),
@@ -8417,7 +8510,7 @@ async function handleContext(req, res, pathSegments, queryParams, myAgentId) {
8417
8510
 
8418
8511
  // src/http/ecosystem.ts
8419
8512
  init_zod();
8420
- init_db();
8513
+ init_db2();
8421
8514
  var EcosystemAppSchema = exports_external.object({
8422
8515
  name: exports_external.string(),
8423
8516
  script: exports_external.string(),
@@ -8667,7 +8760,7 @@ async function handleEvents(req, res, pathSegments, queryParams, _myAgentId) {
8667
8760
 
8668
8761
  // src/http/extensions.ts
8669
8762
  init_zod();
8670
- init_db();
8763
+ init_db2();
8671
8764
 
8672
8765
  // src/be/extensions/validate.ts
8673
8766
  init_bundle_path();
@@ -8768,6 +8861,7 @@ declare module "swarm-extension" {
8768
8861
  | "dsh"
8769
8862
  | "amp"
8770
8863
  | "cursor"
8864
+ | "grok"
8771
8865
  | undefined;
8772
8866
  leadOnly?: boolean | undefined;
8773
8867
  }
@@ -8896,6 +8990,7 @@ declare module "swarm-extension" {
8896
8990
  | "dsh"
8897
8991
  | "amp"
8898
8992
  | "cursor"
8993
+ | "grok"
8899
8994
  | undefined;
8900
8995
  providerMeta?: Record<string, unknown> | undefined;
8901
8996
  harnessVariant?: string | undefined;
@@ -8917,6 +9012,7 @@ declare module "swarm-extension" {
8917
9012
  | "dsh"
8918
9013
  | "amp"
8919
9014
  | "cursor"
9015
+ | "grok"
8920
9016
  | undefined;
8921
9017
  leadOnly?: boolean | undefined;
8922
9018
  }
@@ -10377,6 +10473,8 @@ async function extensionPrincipal(req, callerAgentId) {
10377
10473
  return { kind: "operator" };
10378
10474
  if (auth?.kind === "user")
10379
10475
  return { kind: "user", userId: auth.userId };
10476
+ if (auth?.kind === "guest")
10477
+ return { kind: "guest" };
10380
10478
  return { kind: "agent", agentId: "", isLead: false };
10381
10479
  }
10382
10480
  function ownerOnlyAgentId(principal) {
@@ -10704,7 +10802,7 @@ async function handleExtensions(req, res, pathSegments, queryParams, agentId) {
10704
10802
 
10705
10803
  // src/http/favorites.ts
10706
10804
  init_zod();
10707
- init_db();
10805
+ init_db2();
10708
10806
  init_types();
10709
10807
  var listFavorites2 = route({
10710
10808
  method: "get",
@@ -10804,7 +10902,7 @@ async function handleFavorites(req, res, pathSegments, queryParams, myAgentId) {
10804
10902
 
10805
10903
  // src/http/fs.ts
10806
10904
  init_zod();
10807
- init_db();
10905
+ init_db2();
10808
10906
  init_rbac();
10809
10907
  init_types();
10810
10908
 
@@ -11349,7 +11447,7 @@ async function handleHeartbeat(req, res, pathSegments) {
11349
11447
 
11350
11448
  // src/http/inbox-state.ts
11351
11449
  init_zod();
11352
- init_db();
11450
+ init_db2();
11353
11451
  init_types();
11354
11452
  var listState = route({
11355
11453
  method: "get",
@@ -11433,7 +11531,6 @@ async function handleInboxState(req, res, pathSegments, queryParams) {
11433
11531
 
11434
11532
  // src/http/integrations.ts
11435
11533
  init_zod();
11436
- init_db();
11437
11534
  // slack-manifest.json
11438
11535
  var slack_manifest_default = {
11439
11536
  display_information: {
@@ -11559,6 +11656,33 @@ function buildSlackManifest(name) {
11559
11656
  return manifest;
11560
11657
  }
11561
11658
 
11659
+ // src/http/config-values.ts
11660
+ init_db2();
11661
+ async function resolveConfigValue(key) {
11662
+ const configs = await getResolvedConfig();
11663
+ const variants = [key, key.toLowerCase(), key.toUpperCase()];
11664
+ for (const variant of variants) {
11665
+ const row = configs.find((c) => c.key === variant);
11666
+ if (row && typeof row.value === "string" && row.value.length > 0) {
11667
+ return row.value;
11668
+ }
11669
+ }
11670
+ const envValue = process.env[key];
11671
+ if (envValue && envValue.length > 0)
11672
+ return envValue;
11673
+ return null;
11674
+ }
11675
+ async function resolveMcpBaseUrl() {
11676
+ const configured = await resolveConfigValue("PUBLIC_MCP_BASE_URL") ?? await resolveConfigValue("MCP_BASE_URL");
11677
+ const fallback = `http://localhost:${process.env.PORT || "3013"}`;
11678
+ return (configured || fallback).replace(/\/+$/, "");
11679
+ }
11680
+ async function resolveAppUrl() {
11681
+ const configured = await resolveConfigValue("APP_URL") ?? await resolveConfigValue("DASHBOARD_URL");
11682
+ const first = configured?.split(",").map((value) => value.trim().replace(/\/+$/, "")).find(Boolean);
11683
+ return first || null;
11684
+ }
11685
+
11562
11686
  // src/http/integrations.ts
11563
11687
  var ClaudeManagedTestResultSchema = exports_external.union([
11564
11688
  exports_external.object({
@@ -11614,25 +11738,6 @@ var slackManifestRoute = route({
11614
11738
  200: { description: "Slack app manifest", schema: SlackManifestSchema }
11615
11739
  }
11616
11740
  });
11617
- async function resolveConfigValue(key) {
11618
- const configs = await getResolvedConfig();
11619
- const variants = [key, key.toLowerCase(), key.toUpperCase()];
11620
- for (const variant of variants) {
11621
- const row = configs.find((c) => c.key === variant);
11622
- if (row && typeof row.value === "string" && row.value.length > 0) {
11623
- return row.value;
11624
- }
11625
- }
11626
- const envValue = process.env[key];
11627
- if (envValue && envValue.length > 0)
11628
- return envValue;
11629
- return null;
11630
- }
11631
- async function resolveMcpBaseUrl() {
11632
- const configured = await resolveConfigValue("PUBLIC_MCP_BASE_URL") ?? await resolveConfigValue("MCP_BASE_URL");
11633
- const fallback = `http://localhost:${process.env.PORT || "3013"}`;
11634
- return (configured || fallback).replace(/\/+$/, "");
11635
- }
11636
11741
  function createIntegrationsHandler(deps = {}) {
11637
11742
  const buildClient = deps.buildClient ?? ((apiKey) => new Anthropic({ apiKey }));
11638
11743
  return async function handleIntegrations(req, res, pathSegments, queryParams = new URLSearchParams) {
@@ -11685,7 +11790,7 @@ var handleIntegrations = createIntegrationsHandler();
11685
11790
 
11686
11791
  // src/http/kv.ts
11687
11792
  init_zod();
11688
- init_db();
11793
+ init_db2();
11689
11794
  init_rbac();
11690
11795
  init_context_key();
11691
11796
  init_types();
@@ -11704,10 +11809,24 @@ var kvListQuerySchema = exports_external.object({
11704
11809
  limit: exports_external.coerce.number().int().positive().max(MAX_KV_LIST_LIMIT).optional(),
11705
11810
  offset: exports_external.coerce.number().int().nonnegative().optional()
11706
11811
  });
11812
+ var kvGetQuerySchema = exports_external.object({
11813
+ path: exports_external.string().max(1024).optional(),
11814
+ offset: exports_external.coerce.number().int().nonnegative().optional(),
11815
+ limit: exports_external.coerce.number().int().positive().optional()
11816
+ });
11817
+ var kvViewSchema = exports_external.object({
11818
+ path: exports_external.string(),
11819
+ type: exports_external.enum(["object", "array", "string", "number", "boolean", "null"]),
11820
+ total: exports_external.number().int().nonnegative().optional(),
11821
+ offset: exports_external.number().int().nonnegative().optional(),
11822
+ returned: exports_external.number().int().nonnegative().optional(),
11823
+ nextOffset: exports_external.number().int().nonnegative().nullable().optional()
11824
+ });
11825
+ var kvEntryViewSchema = KvEntrySchema.extend({ view: kvViewSchema.optional() });
11707
11826
  var RESPONSES_GET = {
11708
- 200: { description: "KV entry", schema: KvEntrySchema },
11827
+ 200: { description: "KV entry (or a path/offset/limit view of it)", schema: kvEntryViewSchema },
11709
11828
  404: { description: "KV entry not found or expired" },
11710
- 400: { description: "Validation error or unresolvable namespace" }
11829
+ 400: { description: "Validation error, unresolvable namespace, or invalid view path" }
11711
11830
  };
11712
11831
  var RESPONSES_PUT = {
11713
11832
  200: { description: "KV entry stored", schema: KvEntrySchema },
@@ -11732,6 +11851,7 @@ var getKvHeader = route({
11732
11851
  summary: "Get a KV entry by key (namespace resolved from request headers)",
11733
11852
  tags: ["KV"],
11734
11853
  params: exports_external.object({ key: KvKeySchema }),
11854
+ query: kvGetQuerySchema,
11735
11855
  responses: RESPONSES_GET
11736
11856
  });
11737
11857
  var putKvHeader = route({
@@ -11787,6 +11907,7 @@ var getKvExplicit = route({
11787
11907
  summary: "Get a KV entry by explicit namespace + key",
11788
11908
  tags: ["KV"],
11789
11909
  params: exports_external.object({ namespace: KvNamespaceSchema, key: KvKeySchema }),
11910
+ query: kvGetQuerySchema,
11790
11911
  responses: RESPONSES_GET
11791
11912
  });
11792
11913
  var putKvExplicit = route({
@@ -11984,7 +12105,7 @@ async function handleKv(req, res, pathSegments, queryParams) {
11984
12105
  const key = decodeKvSegment(res, parsed.params.key, "key");
11985
12106
  if (!key)
11986
12107
  return true;
11987
- return sendGet(req, res, ns, key, getKvExplicit.respond);
12108
+ return sendGet(req, res, ns, key, parsed.query, getKvExplicit.respond);
11988
12109
  }
11989
12110
  if (putKvExplicit.match(req.method, pathSegments)) {
11990
12111
  if (enforceContentLengthCap(req, res, MAX_KV_BODY_BYTES) === BODY_TOO_LARGE)
@@ -12033,7 +12154,7 @@ async function handleKv(req, res, pathSegments, queryParams) {
12033
12154
  const key = decodeKvSegment(res, parsed.params.key, "key");
12034
12155
  if (!key)
12035
12156
  return true;
12036
- return sendGet(req, res, ns, key, getKvHeader.respond);
12157
+ return sendGet(req, res, ns, key, parsed.query, getKvHeader.respond);
12037
12158
  }
12038
12159
  if (putKvHeader.match(req.method, pathSegments)) {
12039
12160
  if (enforceContentLengthCap(req, res, MAX_KV_BODY_BYTES) === BODY_TOO_LARGE)
@@ -12144,7 +12265,7 @@ async function handleIncr(req, res, pathSegments, queryParams, explicit) {
12144
12265
  }
12145
12266
  return true;
12146
12267
  }
12147
- async function sendGet(req, res, namespace, key, respond) {
12268
+ async function sendGet(req, res, namespace, key, query, respond) {
12148
12269
  const authErr = authorizeRead(namespace, await buildAuthCtx(req));
12149
12270
  if (authErr) {
12150
12271
  jsonError(res, authErr.message, authErr.status);
@@ -12155,6 +12276,15 @@ async function sendGet(req, res, namespace, key, respond) {
12155
12276
  jsonError(res, "not found", 404);
12156
12277
  return true;
12157
12278
  }
12279
+ if (hasKvViewArgs(query)) {
12280
+ const view = resolveKvView(entry.value, query);
12281
+ if (!view.ok) {
12282
+ jsonError(res, view.error, 400);
12283
+ return true;
12284
+ }
12285
+ respond(res, 200, { ...entry, value: view.value, view: view.view });
12286
+ return true;
12287
+ }
12158
12288
  respond(res, 200, entry);
12159
12289
  return true;
12160
12290
  }
@@ -13423,7 +13553,7 @@ class StreamableHTTPServerTransport {
13423
13553
  }
13424
13554
 
13425
13555
  // src/http/mcp.ts
13426
- init_db();
13556
+ init_db2();
13427
13557
  init_env_flag();
13428
13558
  init_request_auth_context();
13429
13559
  init_task_tool_manifest();
@@ -13618,7 +13748,7 @@ async function handleMcp(req, res, transports, sessionActivity = {}, sessionAgen
13618
13748
 
13619
13749
  // src/http/mcp-oauth.ts
13620
13750
  init_zod();
13621
- init_db();
13751
+ init_db2();
13622
13752
  init_types();
13623
13753
  init_constants();
13624
13754
  init_env_flag();
@@ -14360,7 +14490,7 @@ async function handleMcpOAuth(req, res, pathSegments, queryParams) {
14360
14490
 
14361
14491
  // src/http/mcp-servers.ts
14362
14492
  init_zod();
14363
- init_db();
14493
+ init_db2();
14364
14494
  init_rbac_roles();
14365
14495
  init_rbac();
14366
14496
  init_types();
@@ -14558,6 +14688,8 @@ async function mcpServerPrincipal(req) {
14558
14688
  return { kind: "operator" };
14559
14689
  if (auth?.kind === "user")
14560
14690
  return { kind: "user", userId: auth.userId };
14691
+ if (auth?.kind === "guest")
14692
+ return { kind: "guest" };
14561
14693
  return { kind: "agent", agentId: "", isLead: false };
14562
14694
  }
14563
14695
  async function mcpServerPermissionRefusal(req, verb, resource) {
@@ -14885,7 +15017,7 @@ function createUserServer(user) {
14885
15017
  title: "Send a task",
14886
15018
  annotations: { destructiveHint: false },
14887
15019
  rbac: permission("task.create.own"),
14888
- description: "Creates an unassigned task requested by the authenticated user.",
15020
+ description: "Sends a task from the authenticated user to the online Lead.",
14889
15021
  inputSchema: userSendTaskInputSchema,
14890
15022
  outputSchema: sendTaskOutputSchema
14891
15023
  };
@@ -14894,11 +15026,11 @@ function createUserServer(user) {
14894
15026
  if (denied)
14895
15027
  return denied;
14896
15028
  return sendTaskHandler(userCtx(user, info.sessionId), {
15029
+ ...args,
14897
15030
  offerMode: false,
14898
15031
  leadOnly: false,
14899
15032
  allowDuplicate: false,
14900
- overrideSlackContext: false,
14901
- ...args
15033
+ overrideSlackContext: false
14902
15034
  });
14903
15035
  });
14904
15036
  const getTasksConfig = {
@@ -14957,19 +15089,6 @@ function createUserServer(user) {
14957
15089
  return steerTaskHandler(userCtx(user, info.sessionId), args);
14958
15090
  });
14959
15091
  }
14960
- const taskActionConfig = {
14961
- title: "Task Pool Action",
14962
- description: "Move one of your tasks to or from backlog.",
14963
- rbac: permission("task.action.own"),
14964
- inputSchema: taskActionInputSchema,
14965
- outputSchema: taskActionOutputSchema
14966
- };
14967
- registerTool("task-action", taskActionConfig, async (args, info, _meta) => {
14968
- const denied = await maybeDenyUserToolAdmission(user, "task-action", taskActionConfig);
14969
- if (denied)
14970
- return denied;
14971
- return taskActionHandler(userCtx(user, info.sessionId), args);
14972
- });
14973
15092
  return server;
14974
15093
  }
14975
15094
 
@@ -15072,11 +15191,12 @@ function closeIdleMcpUserTransports(transports, sessionUsers, sessionActivity, o
15072
15191
 
15073
15192
  // src/http/memory.ts
15074
15193
  init_zod();
15075
- init_db();
15194
+ init_db2();
15195
+ init_memory();
15076
15196
  init_constants2();
15077
15197
 
15078
15198
  // src/be/memory/edges-store.ts
15079
- init_db();
15199
+ init_db2();
15080
15200
  var USEFULNESS_FLOOR = 1;
15081
15201
  var USEFULNESS_CEILING = 2;
15082
15202
  async function listEdgesForAgent(agentId, memoryId) {
@@ -15112,7 +15232,7 @@ init_key_paths();
15112
15232
  init_reranker();
15113
15233
 
15114
15234
  // src/be/memory/retrieval-store.ts
15115
- init_db();
15235
+ init_db2();
15116
15236
  var RETRIEVAL_CONTENT_SNIPPET_CHARS = 500;
15117
15237
  var RETRIEVAL_LIST_LIMIT = 50;
15118
15238
  async function getRetrievalsForAgent(agentId, filter) {
@@ -15155,7 +15275,7 @@ async function hasRetrievalForTask(taskId, memoryId) {
15155
15275
  }
15156
15276
 
15157
15277
  // src/be/memory/usefulness-stats.ts
15158
- init_db();
15278
+ init_db2();
15159
15279
  async function getUsefulnessStats(options = {}) {
15160
15280
  const days = options.days ?? 30;
15161
15281
  const threshold = options.threshold ?? 0.6;
@@ -15371,7 +15491,9 @@ var MemorySearchResultItemSchema = exports_external.object({
15371
15491
  source: AgentMemorySourceSchema,
15372
15492
  scope: AgentMemoryScopeSchema,
15373
15493
  tags: exports_external.array(exports_external.string()),
15374
- accessCount: exports_external.number()
15494
+ accessCount: exports_external.number(),
15495
+ summary: exports_external.string().nullable().optional(),
15496
+ createdAt: exports_external.string().optional()
15375
15497
  });
15376
15498
  var searchMemory = route({
15377
15499
  method: "post",
@@ -15890,6 +16012,8 @@ async function ingestPrincipal(req, agentIdHeader) {
15890
16012
  const auth = getRequestAuth(req);
15891
16013
  if (auth?.kind === "user")
15892
16014
  return { kind: "user", userId: auth.userId };
16015
+ if (auth?.kind === "guest")
16016
+ return { kind: "guest" };
15893
16017
  const agentId = auth?.kind === "agent" ? auth.agentId : agentIdHeader;
15894
16018
  if (agentId) {
15895
16019
  const agent = await getAgentById(agentId);
@@ -15905,6 +16029,9 @@ function memoryListViewer(principal) {
15905
16029
  }
15906
16030
  async function handleMemory(req, res, pathSegments, callerAgentId) {
15907
16031
  const myAgentId = getRequestAuth(req)?.page?.executionAgentId ?? callerAgentId;
16032
+ if (pathSegments[0] === "api" && pathSegments[1] === "memory" && rejectGuest(req, res)) {
16033
+ return true;
16034
+ }
15908
16035
  if (indexMemory.match(req.method, pathSegments)) {
15909
16036
  const parsed = await indexMemory.parse(req, res, pathSegments, new URLSearchParams);
15910
16037
  if (!parsed)
@@ -16040,7 +16167,9 @@ async function handleMemory(req, res, pathSegments, callerAgentId) {
16040
16167
  source: r.source,
16041
16168
  scope: r.scope,
16042
16169
  tags: r.tags,
16043
- accessCount: (r.accessCount ?? 0) + (consumedIdSet.has(r.id) ? 1 : 0)
16170
+ accessCount: (r.accessCount ?? 0) + (consumedIdSet.has(r.id) ? 1 : 0),
16171
+ summary: r.summary,
16172
+ createdAt: r.createdAt
16044
16173
  }))
16045
16174
  });
16046
16175
  } catch (err) {
@@ -16545,7 +16674,7 @@ function stopMemoryGc() {
16545
16674
 
16546
16675
  // src/http/metrics.ts
16547
16676
  init_zod();
16548
- init_db();
16677
+ init_db2();
16549
16678
  init_types();
16550
16679
  var DEFAULT_METRIC_MAX_ROWS = 100;
16551
16680
  var HARD_METRIC_MAX_ROWS = 500;
@@ -16999,7 +17128,7 @@ async function handleMetrics(req, res, pathSegments, queryParams, myAgentId) {
16999
17128
 
17000
17129
  // src/http/models-catalog.ts
17001
17130
  init_zod();
17002
- init_db();
17131
+ init_db2();
17003
17132
  init_rbac();
17004
17133
  init_types();
17005
17134
  init_request_auth_context();
@@ -17205,6 +17334,8 @@ async function ensureCatalogWriter(req, res, verb = "models.catalog.write") {
17205
17334
  let principal;
17206
17335
  if (auth?.kind === "user") {
17207
17336
  principal = { kind: "user", userId: auth.userId };
17337
+ } else if (auth?.kind === "guest") {
17338
+ principal = { kind: "guest" };
17208
17339
  } else if (agentId) {
17209
17340
  const agent = await getAgentById(agentId);
17210
17341
  principal = { kind: "agent", agentId, isLead: agent?.isLead ?? false };
@@ -17309,9 +17440,11 @@ async function handleModelsCatalog(req, res, pathSegments, queryParams) {
17309
17440
 
17310
17441
  // src/http/oauth-callback.ts
17311
17442
  init_zod();
17312
- init_db();
17443
+ init_db2();
17444
+ init_oauth();
17313
17445
 
17314
17446
  // src/jira/oauth.ts
17447
+ init_oauth();
17315
17448
  var ACCESSIBLE_RESOURCES_URL = "https://api.atlassian.com/oauth/token/accessible-resources";
17316
17449
  async function getJiraOAuthConfig() {
17317
17450
  const app = await getOAuthApp("jira");
@@ -17352,7 +17485,8 @@ async function resolveAndStoreJiraCloudId(accessToken) {
17352
17485
  }
17353
17486
 
17354
17487
  // src/linear/oauth.ts
17355
- init_db();
17488
+ init_db2();
17489
+ init_oauth();
17356
17490
  var APP_USER_ID_NAMESPACE = "integration:linear:bot-app-user-id";
17357
17491
  async function getLinearOAuthConfig() {
17358
17492
  const app = await getOAuthApp("linear");
@@ -17779,6 +17913,7 @@ async function handleGenericOAuth(req, res, pathSegments, queryParams) {
17779
17913
 
17780
17914
  // src/http/oauth-locks.ts
17781
17915
  init_zod();
17916
+ init_oauth();
17782
17917
  var MAX_LOCK_TTL_MS = 5 * 60 * 1000;
17783
17918
  var LOCK_KEY_PATTERN = /^[a-zA-Z0-9._:-]{1,200}$/;
17784
17919
  var LockKeySchema = exports_external.object({ key: exports_external.string().regex(LOCK_KEY_PATTERN) });
@@ -17845,13 +17980,15 @@ async function handleOAuthLocks(req, res, pathSegments, queryParams) {
17845
17980
 
17846
17981
  // src/http/onboarding.ts
17847
17982
  init_openai();
17848
- init_db();
17983
+ init_db2();
17984
+ init_memory();
17849
17985
  init_constants2();
17850
17986
  init_types();
17851
17987
 
17852
17988
  // src/http/status.ts
17853
17989
  init_zod();
17854
- init_db();
17990
+ init_db2();
17991
+ init_memory();
17855
17992
  init_config();
17856
17993
  init_telemetry();
17857
17994
  init_types();
@@ -18641,7 +18778,7 @@ async function handleOnboarding(req, res, pathSegments, queryParams) {
18641
18778
  }
18642
18779
 
18643
18780
  // src/http/page-proxy.ts
18644
- init_db();
18781
+ init_db2();
18645
18782
  route({
18646
18783
  method: "get",
18647
18784
  path: "/@swarm/api/{path}",
@@ -18743,6 +18880,12 @@ function isSafeProxySuffix(suffix) {
18743
18880
  }
18744
18881
  return true;
18745
18882
  }
18883
+ function isGuestAllowedProxyPath(method, suffix, pageId) {
18884
+ const segments = suffix.split("/").map((seg) => decodeURIComponent(seg));
18885
+ if (segments[0] === "kv")
18886
+ return true;
18887
+ return method === "GET" && segments.length === 2 && segments[0] === "pages" && segments[1] === pageId;
18888
+ }
18746
18889
  async function handlePageProxy(req, res) {
18747
18890
  const url = req.url ?? "";
18748
18891
  if (!url.startsWith(PROXY_PREFIX))
@@ -18766,6 +18909,10 @@ async function handlePageProxy(req, res) {
18766
18909
  jsonError(res, "page session no longer valid", 401);
18767
18910
  return true;
18768
18911
  }
18912
+ if (!payload.uid && !payload.op && !isGuestAllowedProxyPath(method, suffix, page.id)) {
18913
+ jsonError(res, "forbidden", 403);
18914
+ return true;
18915
+ }
18769
18916
  const rewrittenPath = pathPart.replace(PROXY_PREFIX, "/api/");
18770
18917
  const port = process.env.PORT || "3013";
18771
18918
  const baseUrl = `http://127.0.0.1:${port}`;
@@ -18820,7 +18967,7 @@ async function handlePageProxy(req, res) {
18820
18967
  // src/http/pages.ts
18821
18968
  init_zod();
18822
18969
  import { randomUUID as randomUUID4 } from "node:crypto";
18823
- init_db();
18970
+ init_db2();
18824
18971
  init_types();
18825
18972
  init_constants();
18826
18973
  init_request_auth_context();
@@ -19250,7 +19397,10 @@ async function handlePages(req, res, pathSegments, queryParams, myAgentId) {
19250
19397
  }
19251
19398
  const favoriteScope = (await resolveHttpFavoriteOwner(req, myAgentId))?.scope;
19252
19399
  const [decorated] = await withFavoriteFlags([page], { favoriteScope, itemType: "page" });
19253
- getPageRoute.respond(res, 200, withShareUrls(decorated ?? page));
19400
+ const body = withShareUrls(decorated ?? page);
19401
+ if (getRequestAuth(req)?.kind === "guest")
19402
+ delete body.passwordHash;
19403
+ getPageRoute.respond(res, 200, body);
19254
19404
  return true;
19255
19405
  }
19256
19406
  if (updatePageRoute.match(req.method, pathSegments)) {
@@ -19359,7 +19509,7 @@ async function handlePages(req, res, pathSegments, queryParams, myAgentId) {
19359
19509
  return true;
19360
19510
  }
19361
19511
  const auth = getRequestAuth(req);
19362
- const identity = auth?.kind === "user" ? { uid: auth.userId, name: auth.user.name } : auth?.kind === "operator" ? { name: `guest-${randomUUID4().slice(0, 8)}` } : undefined;
19512
+ const identity = auth?.kind === "user" ? { uid: auth.userId, name: auth.user.name } : auth?.kind === "operator" ? { name: `guest-${randomUUID4().slice(0, 8)}`, op: true } : undefined;
19363
19513
  const cookie = await issuePageSessionCookie(page.id, {
19364
19514
  dev: isDevRequest(req),
19365
19515
  ...identity
@@ -19375,7 +19525,7 @@ async function handlePages(req, res, pathSegments, queryParams, myAgentId) {
19375
19525
 
19376
19526
  // src/http/pages-public.ts
19377
19527
  init_zod();
19378
- init_db();
19528
+ init_db2();
19379
19529
  init_types();
19380
19530
  init_constants();
19381
19531
  init_secret_scrubber();
@@ -19805,7 +19955,7 @@ async function bumpViewCount(pageId) {
19805
19955
 
19806
19956
  // src/http/poll.ts
19807
19957
  init_zod();
19808
- init_db();
19958
+ init_db2();
19809
19959
 
19810
19960
  // src/slack/channel-activity.ts
19811
19961
  var cachedBotUserId = null;
@@ -20370,7 +20520,7 @@ async function handlePoll(req, res, pathSegments, queryParams, myAgentId) {
20370
20520
 
20371
20521
  // src/http/pricing.ts
20372
20522
  init_zod();
20373
- init_db();
20523
+ init_db2();
20374
20524
  init_types();
20375
20525
  init_secret_scrubber();
20376
20526
  import { createHash as createHash2 } from "node:crypto";
@@ -20546,7 +20696,7 @@ async function handlePricing(req, res, pathSegments, queryParams, _myAgentId) {
20546
20696
 
20547
20697
  // src/http/prompt-templates.ts
20548
20698
  init_zod();
20549
- init_db();
20699
+ init_db2();
20550
20700
  init_default_drift();
20551
20701
  init_registry();
20552
20702
  init_resolver();
@@ -21011,7 +21161,7 @@ async function handleRealtimeTicket(req, res, pathSegments, queryParams) {
21011
21161
  if (!parsed)
21012
21162
  return true;
21013
21163
  const auth = getRequestAuth(req);
21014
- if (!auth || auth.kind === "agent") {
21164
+ if (!auth || auth.kind === "agent" || auth.kind === "guest") {
21015
21165
  jsonError(res, "Comb presence requires dashboard authentication", 403);
21016
21166
  return true;
21017
21167
  }
@@ -21041,7 +21191,7 @@ async function handleRealtimeAsset(req, res) {
21041
21191
 
21042
21192
  // src/http/repos.ts
21043
21193
  init_zod();
21044
- init_db();
21194
+ init_db2();
21045
21195
  init_rbac();
21046
21196
  init_telemetry();
21047
21197
  init_types();
@@ -21521,6 +21671,7 @@ async function handleRooms(req, res, pathSegments, queryParams) {
21521
21671
  // src/http/schedules.ts
21522
21672
  init_zod();
21523
21673
  var import_cron_parser = __toESM(require_dist(), 1);
21674
+ init_db2();
21524
21675
  init_db();
21525
21676
  init_types();
21526
21677
  var scheduleUpdateBodySchema = exports_external.object({
@@ -22109,7 +22260,7 @@ async function handleSchedules(req, res, pathSegments, queryParams, myAgentId) {
22109
22260
 
22110
22261
  // src/http/script-connection-proxy.ts
22111
22262
  init_zod();
22112
- init_db();
22263
+ init_db2();
22113
22264
  init_rbac();
22114
22265
  var McpToolCallResultSchema = exports_external.object({
22115
22266
  content: exports_external.array(exports_external.object({ type: exports_external.string(), text: exports_external.string().optional() })),
@@ -22218,7 +22369,8 @@ async function handleScriptConnectionProxy(req, res, pathSegments, queryParams,
22218
22369
  // src/http/script-connections.ts
22219
22370
  init_zod();
22220
22371
  init_date_utils();
22221
- init_db();
22372
+ init_db2();
22373
+ init_oauth();
22222
22374
  init_rbac();
22223
22375
  init_credential_broker();
22224
22376
  init_telemetry();
@@ -22942,6 +23094,10 @@ async function ensureConnectionAdmin(req, res, agentId) {
22942
23094
  const auth = getRequestAuth(req);
22943
23095
  if (auth?.kind === "operator" || auth?.kind === "user")
22944
23096
  return true;
23097
+ if (auth?.kind === "guest") {
23098
+ jsonError(res, "Forbidden", 403);
23099
+ return false;
23100
+ }
22945
23101
  const callerAgentId = agentId ?? singleHeader5(req, "x-agent-id");
22946
23102
  const agent = callerAgentId ? await getAgentById(callerAgentId) : undefined;
22947
23103
  const decision = can({
@@ -22964,6 +23120,10 @@ async function ensureVerbAdmin(req, res, agentId, verb, denyMessage) {
22964
23120
  const auth = getRequestAuth(req);
22965
23121
  if (auth?.kind === "operator" || auth?.kind === "user")
22966
23122
  return true;
23123
+ if (auth?.kind === "guest") {
23124
+ jsonError(res, "Forbidden", 403);
23125
+ return false;
23126
+ }
22967
23127
  const callerAgentId = agentId ?? singleHeader5(req, "x-agent-id");
22968
23128
  const agent = callerAgentId ? await getAgentById(callerAgentId) : undefined;
22969
23129
  const decision = can({
@@ -24105,7 +24265,25 @@ async function handleScriptConnections(req, res, pathSegments, queryParams, agen
24105
24265
 
24106
24266
  // src/http/script-runs.ts
24107
24267
  init_zod();
24108
- init_db();
24268
+ init_db2();
24269
+
24270
+ // src/be/scripts/source-secrets.ts
24271
+ init_secret_scrubber();
24272
+ function refuseSourceWithSecrets(source) {
24273
+ const { knownValues, gitleaksRules } = findSecretsIn(source);
24274
+ if (knownValues.length === 0 && gitleaksRules.length === 0)
24275
+ return null;
24276
+ const findings = [
24277
+ ...knownValues.map((id) => ({ kind: "registered-secret", id })),
24278
+ ...gitleaksRules.map((id) => ({ kind: "gitleaks-rule", id }))
24279
+ ];
24280
+ const named = findings.map((f) => f.kind === "registered-secret" ? `registered secret ${f.id}` : `gitleaks rule ${f.id}`).join(", ");
24281
+ return {
24282
+ error: "source_contains_secret",
24283
+ 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>").`,
24284
+ findings
24285
+ };
24286
+ }
24109
24287
 
24110
24288
  // src/script-workflows/label-lint.ts
24111
24289
  var import_typescript = __toESM(require_typescript(), 1);
@@ -24178,6 +24356,7 @@ function lintWorkflowLabels(source) {
24178
24356
  // src/http/script-runs.ts
24179
24357
  init_types();
24180
24358
  init_constants();
24359
+ init_secret_scrubber();
24181
24360
  var DEFAULT_SCRIPT_RUN_CONCURRENCY_CAP = 10;
24182
24361
  var runIdParamsSchema = exports_external.object({ runId: exports_external.string().uuid() });
24183
24362
  var idParamsSchema3 = exports_external.object({ id: exports_external.string().uuid() });
@@ -24453,6 +24632,11 @@ async function handleScriptRuns(req, res, pathSegments, queryParams, agentId) {
24453
24632
  const agent = await requireAgent(res, agentId);
24454
24633
  if (!agent)
24455
24634
  return true;
24635
+ const secretRefusal = refuseSourceWithSecrets(parsed.body.source);
24636
+ if (secretRefusal) {
24637
+ json(res, secretRefusal, 400);
24638
+ return true;
24639
+ }
24456
24640
  const lint = lintWorkflowLabels(parsed.body.source);
24457
24641
  if (!lint.ok) {
24458
24642
  json(res, {
@@ -24490,7 +24674,7 @@ async function handleScriptRuns(req, res, pathSegments, queryParams, agentId) {
24490
24674
  }
24491
24675
  const { run, existing } = creation;
24492
24676
  if (!existing && parsed.body.background) {
24493
- startScriptRunProcess(run, deriveApiBaseUrl(req), bearerToken(req)).catch(async (err) => {
24677
+ startScriptRunProcess(run, getMcpBaseUrl(), bearerToken(req)).catch(async (err) => {
24494
24678
  await updateScriptRun(run.id, {
24495
24679
  status: "failed",
24496
24680
  pid: null,
@@ -24606,7 +24790,7 @@ async function handleScriptRuns(req, res, pathSegments, queryParams, agentId) {
24606
24790
  config: parsed.body.config ?? {},
24607
24791
  status: parsed.body.status,
24608
24792
  result: parsed.body.result,
24609
- error: parsed.body.error,
24793
+ error: parsed.body.error === undefined ? undefined : scrubSecrets(parsed.body.error),
24610
24794
  durationMs: parsed.body.durationMs
24611
24795
  });
24612
24796
  return assertRunWithinLimits(run.id);
@@ -24737,7 +24921,9 @@ async function handleScriptRuns(req, res, pathSegments, queryParams, agentId) {
24737
24921
 
24738
24922
  // src/http/scripts.ts
24739
24923
  init_zod();
24924
+ init_db2();
24740
24925
  init_db();
24926
+ init_embeddings();
24741
24927
  init_rbac();
24742
24928
  init_types();
24743
24929
  init_secret_scrubber();
@@ -25193,6 +25379,11 @@ async function handleScripts(req, res, pathSegments, queryParams, agentId) {
25193
25379
  return true;
25194
25380
  }
25195
25381
  }
25382
+ const secretRefusal = refuseSourceWithSecrets(parsed.body.source);
25383
+ if (secretRefusal) {
25384
+ json(res, secretRefusal, 400);
25385
+ return true;
25386
+ }
25196
25387
  const typecheck = await typecheckScript(parsed.body.source, { agentId: agent.id });
25197
25388
  if (!typecheck.ok) {
25198
25389
  json(res, {
@@ -25243,6 +25434,11 @@ async function handleScripts(req, res, pathSegments, queryParams, agentId) {
25243
25434
  if (!agent)
25244
25435
  return true;
25245
25436
  const runtimeInstanceId = ((h) => Array.isArray(h) ? h[0] : h)(req.headers["x-runtime-instance-id"]);
25437
+ const secretRefusal = parsed.body.source ? refuseSourceWithSecrets(parsed.body.source) : null;
25438
+ if (secretRefusal) {
25439
+ json(res, secretRefusal, 400);
25440
+ return true;
25441
+ }
25246
25442
  let source = parsed.body.source;
25247
25443
  let fsMode = parsed.body.fsMode;
25248
25444
  let namedScript = null;
@@ -25601,7 +25797,7 @@ async function handleScripts(req, res, pathSegments, queryParams, agentId) {
25601
25797
 
25602
25798
  // src/http/session-data.ts
25603
25799
  init_zod();
25604
- init_db();
25800
+ init_db2();
25605
25801
  init_types();
25606
25802
 
25607
25803
  // src/http/session-cost-recompute.ts
@@ -25686,7 +25882,7 @@ async function recomputeSessionCost(input, lookupRate) {
25686
25882
  modelBreakdown
25687
25883
  };
25688
25884
  }
25689
- if (input.provider === "amp" && input.harnessCostUsd > 0) {
25885
+ if ((input.provider === "amp" || input.provider === "grok") && input.harnessCostUsd > 0) {
25690
25886
  const priced = await recomputeSessionCost({ ...input, harnessCostUsd: 0 }, lookupRate);
25691
25887
  return {
25692
25888
  totalCostUsd: input.harnessCostUsd,
@@ -26138,7 +26334,7 @@ async function handleSessionData(req, res, pathSegments, queryParams, _myAgentId
26138
26334
 
26139
26335
  // src/http/sessions.ts
26140
26336
  init_zod();
26141
- init_db();
26337
+ init_db2();
26142
26338
  init_steering();
26143
26339
  init_types();
26144
26340
  init_request_auth_context();
@@ -26359,11 +26555,11 @@ async function handleSessions(req, res, pathSegments, queryParams) {
26359
26555
 
26360
26556
  // src/http/skills.ts
26361
26557
  init_zod();
26362
- init_db();
26558
+ init_db2();
26363
26559
 
26364
26560
  // src/be/skill-sync.ts
26365
26561
  import { homedir } from "node:os";
26366
- init_db();
26562
+ init_db2();
26367
26563
  async function syncSkillsToFilesystem(agentId, harnessType = "all", homeOverride) {
26368
26564
  const skills = await getAgentSkills(agentId);
26369
26565
  const home = homeOverride ?? homedir();
@@ -27135,7 +27331,7 @@ async function handleSkills(req, res, pathSegments, queryParams, myAgentId) {
27135
27331
 
27136
27332
  // src/http/stats.ts
27137
27333
  init_zod();
27138
- init_db();
27334
+ init_db2();
27139
27335
  init_steering();
27140
27336
  init_types();
27141
27337
  init_env_flag();
@@ -27398,7 +27594,7 @@ async function handleStats(req, res, pathSegments, queryParams, myAgentId) {
27398
27594
 
27399
27595
  // src/http/task-templates.ts
27400
27596
  init_zod();
27401
- init_db();
27597
+ init_db2();
27402
27598
  init_types();
27403
27599
  var listTemplates = route({
27404
27600
  method: "get",
@@ -27438,7 +27634,7 @@ async function handleTaskTemplates(req, res, pathSegments, queryParams) {
27438
27634
 
27439
27635
  // src/http/tasks.ts
27440
27636
  init_zod();
27441
- init_db();
27637
+ init_db2();
27442
27638
  init_steering();
27443
27639
  init_rbac();
27444
27640
  init_types();
@@ -27979,6 +28175,8 @@ async function canSteerTask(req, myAgentId, task) {
27979
28175
  } else if (auth?.kind === "user") {
27980
28176
  principal = { kind: "user", userId: auth.userId };
27981
28177
  verb = "task.steer.own";
28178
+ } else if (auth?.kind === "guest") {
28179
+ return false;
27982
28180
  } else {
27983
28181
  if (!myAgentId)
27984
28182
  return false;
@@ -28004,6 +28202,8 @@ async function canActOnOwnTask(req, myAgentId, task) {
28004
28202
  principal = { kind: "operator" };
28005
28203
  } else if (auth?.kind === "user") {
28006
28204
  principal = { kind: "user", userId: auth.userId };
28205
+ } else if (auth?.kind === "guest") {
28206
+ return false;
28007
28207
  } else {
28008
28208
  if (!myAgentId)
28009
28209
  return false;
@@ -28018,6 +28218,8 @@ async function resolveTaskWritePrincipal(req, myAgentId) {
28018
28218
  const auth = getRequestAuth(req);
28019
28219
  if (auth?.kind === "user")
28020
28220
  return { kind: "user", userId: auth.userId };
28221
+ if (auth?.kind === "guest")
28222
+ return { kind: "guest" };
28021
28223
  const agentId = auth?.kind === "agent" ? auth.agentId : myAgentId;
28022
28224
  if (!agentId)
28023
28225
  return { kind: "operator" };
@@ -28025,6 +28227,9 @@ async function resolveTaskWritePrincipal(req, myAgentId) {
28025
28227
  return { kind: "agent", agentId, isLead: agent?.isLead === true };
28026
28228
  }
28027
28229
  async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
28230
+ if (pathSegments[0] === "api" && pathSegments[1] === "tasks" && rejectGuest(req, res)) {
28231
+ return true;
28232
+ }
28028
28233
  if (listTasks.match(req.method, pathSegments)) {
28029
28234
  const parsed = await listTasks.parse(req, res, pathSegments, queryParams);
28030
28235
  if (!parsed)
@@ -28864,6 +29069,7 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
28864
29069
 
28865
29070
  // src/http/trackers/jira.ts
28866
29071
  init_zod();
29072
+ init_oauth();
28867
29073
  var MANUAL_WEBHOOK_INSTRUCTIONS = "See docs-site/.../integrations/jira.mdx for manual webhook registration steps.";
28868
29074
  var JiraWebhookIdEntrySchema = exports_external.object({
28869
29075
  id: exports_external.number().int(),
@@ -29239,6 +29445,7 @@ async function handleJiraTracker(req, res, pathSegments) {
29239
29445
 
29240
29446
  // src/http/trackers/linear.ts
29241
29447
  init_zod();
29448
+ init_oauth();
29242
29449
 
29243
29450
  // src/linear/webhook.ts
29244
29451
  import { createHmac, timingSafeEqual } from "node:crypto";
@@ -29549,10 +29756,76 @@ async function handleTrackers(req, res, pathSegments) {
29549
29756
 
29550
29757
  // src/http/users.ts
29551
29758
  init_zod();
29552
- init_db();
29759
+ init_db2();
29553
29760
  init_types();
29554
29761
  init_request_auth_context();
29555
29762
 
29763
+ // src/http/ip-rate-limit.ts
29764
+ var PRUNE_THRESHOLD = 1e4;
29765
+ var PRUNE_INTERVAL_MS = 60000;
29766
+ var MAX_BUCKETS = 50000;
29767
+ function isPrivateAddress(address) {
29768
+ const ip = address.startsWith("::ffff:") ? address.slice(7) : address;
29769
+ if (ip === "::1" || ip.startsWith("127.") || ip.startsWith("10."))
29770
+ return true;
29771
+ if (ip.startsWith("192.168.") || ip.startsWith("169.254."))
29772
+ return true;
29773
+ const match = /^172\.(\d+)\./.exec(ip);
29774
+ if (match && Number(match[1]) >= 16 && Number(match[1]) <= 31)
29775
+ return true;
29776
+ const lower = ip.toLowerCase();
29777
+ return lower.startsWith("fc") || lower.startsWith("fd") || lower.startsWith("fe80:");
29778
+ }
29779
+ function clientIp(req) {
29780
+ const peer = req.socket.remoteAddress ?? "unknown";
29781
+ if (!isPrivateAddress(peer))
29782
+ return peer;
29783
+ const raw = req.headers["x-forwarded-for"];
29784
+ const header2 = Array.isArray(raw) ? raw[raw.length - 1] : raw;
29785
+ const hop = header2?.split(",").pop()?.trim();
29786
+ return hop || peer;
29787
+ }
29788
+ function createIpRateLimiter(options) {
29789
+ const buckets = new Map;
29790
+ let lastPruneAt = 0;
29791
+ function refill(bucket, now) {
29792
+ const elapsed = now - bucket.updatedAt;
29793
+ bucket.tokens = Math.min(options.capacity, bucket.tokens + elapsed * options.refillPerMs);
29794
+ bucket.updatedAt = now;
29795
+ }
29796
+ return {
29797
+ take(ip, now = Date.now()) {
29798
+ if (buckets.size > PRUNE_THRESHOLD && now - lastPruneAt >= PRUNE_INTERVAL_MS) {
29799
+ lastPruneAt = now;
29800
+ for (const [key, bucket2] of buckets) {
29801
+ refill(bucket2, now);
29802
+ if (bucket2.tokens >= options.capacity)
29803
+ buckets.delete(key);
29804
+ }
29805
+ }
29806
+ let bucket = buckets.get(ip);
29807
+ if (!bucket) {
29808
+ if (buckets.size >= MAX_BUCKETS) {
29809
+ const oldest = buckets.keys().next().value;
29810
+ if (oldest !== undefined)
29811
+ buckets.delete(oldest);
29812
+ }
29813
+ bucket = { tokens: options.capacity, updatedAt: now };
29814
+ buckets.set(ip, bucket);
29815
+ }
29816
+ refill(bucket, now);
29817
+ if (bucket.tokens < 1)
29818
+ return false;
29819
+ bucket.tokens -= 1;
29820
+ return true;
29821
+ },
29822
+ reset() {
29823
+ buckets.clear();
29824
+ lastPruneAt = 0;
29825
+ }
29826
+ };
29827
+ }
29828
+
29556
29829
  // src/http/operator-actor.ts
29557
29830
  init_request_auth_context();
29558
29831
  function extractBearer2(req) {
@@ -29570,6 +29843,10 @@ function getOperatorActor(req, res) {
29570
29843
  if (auth?.kind === "operator") {
29571
29844
  return { kind: "operator", id: auth.fingerprint };
29572
29845
  }
29846
+ if (auth?.kind === "guest") {
29847
+ jsonError(res, "Forbidden", 403);
29848
+ return null;
29849
+ }
29573
29850
  const rawKey = extractBearer2(req);
29574
29851
  const swarmKey = getApiKey();
29575
29852
  if (!swarmKey) {
@@ -29849,6 +30126,79 @@ var revokeUserMcpTokenRoute = route({
29849
30126
  },
29850
30127
  auth: { apiKey: true }
29851
30128
  });
30129
+ var createConnectorCodeRoute = route({
30130
+ method: "post",
30131
+ path: "/api/users/{id}/connector-codes",
30132
+ pattern: ["api", "users", null, "connector-codes"],
30133
+ summary: "Create a single-use connect code for the agent-swarm.dev ChatGPT connector",
30134
+ description: "Returns a 10-minute single-use code and the connector URL that carries it. The connector trades the code for an MCP token at POST /api/connector/exchange.",
30135
+ tags: ["Users"],
30136
+ params: exports_external.object({ id: exports_external.string() }),
30137
+ body: exports_external.object({
30138
+ label: exports_external.string().min(1).optional()
30139
+ }),
30140
+ responses: {
30141
+ 201: {
30142
+ description: "Connect code, its expiry and the connector URL",
30143
+ schema: exports_external.object({
30144
+ code: exports_external.string(),
30145
+ expiresAt: exports_external.string(),
30146
+ connectUrl: exports_external.string()
30147
+ })
30148
+ },
30149
+ 400: { description: "The public API origin or CONNECTOR_CONNECT_URL is not HTTPS" },
30150
+ 401: { description: "Unauthorized" },
30151
+ 404: { description: "User not found" }
30152
+ },
30153
+ auth: { apiKey: true },
30154
+ rbac: { ungated: "same posture as POST /api/users/{id}/mcp-tokens (operator-only admission)" }
30155
+ });
30156
+ var exchangeConnectorCodeRoute = route({
30157
+ method: "post",
30158
+ path: "/api/connector/exchange",
30159
+ pattern: ["api", "connector", "exchange"],
30160
+ summary: "Exchange a connect code for a user MCP token",
30161
+ description: "Unauthenticated: the single-use code is the credential. Rate limited per IP. Unknown, expired and used codes all return 404 code_invalid.",
30162
+ tags: ["Users"],
30163
+ body: exports_external.object({ code: exports_external.string().min(1).max(256) }),
30164
+ maxBodyBytes: 1024,
30165
+ responses: {
30166
+ 200: {
30167
+ description: "Minted MCP token for the code's user",
30168
+ schema: exports_external.object({
30169
+ token: exports_external.string(),
30170
+ userId: exports_external.string(),
30171
+ version: exports_external.string()
30172
+ })
30173
+ },
30174
+ 404: { description: "Code unknown, malformed, expired or already used" },
30175
+ 413: { description: "Request body too large" },
30176
+ 429: { description: "Rate limited" }
30177
+ },
30178
+ auth: { apiKey: false },
30179
+ rbac: {
30180
+ ungated: "the single-use code is the credential; the minted token carries the user's own grant and is admitted on use"
30181
+ }
30182
+ });
30183
+ var connectorDiscoveryRoute = route({
30184
+ method: "get",
30185
+ path: "/api/connector/discovery",
30186
+ pattern: ["api", "connector", "discovery"],
30187
+ summary: "Public origins the agent-swarm.dev connector needs to find this swarm's dashboard",
30188
+ description: "Unauthenticated. Lets the connector turn an API origin into the dashboard URL that serves /connect. appUrl is omitted when APP_URL is not set or is not https.",
30189
+ tags: ["Users"],
30190
+ responses: {
30191
+ 200: {
30192
+ description: "Public API origin, dashboard origin and connector connect URL",
30193
+ schema: exports_external.object({
30194
+ apiUrl: exports_external.string(),
30195
+ appUrl: exports_external.string().optional(),
30196
+ connectUrl: exports_external.string().nullable()
30197
+ })
30198
+ }
30199
+ },
30200
+ auth: { apiKey: false }
30201
+ });
29852
30202
  var mergeUsersRoute = route({
29853
30203
  method: "post",
29854
30204
  path: "/api/users/{id}/merge",
@@ -29974,6 +30324,30 @@ async function collectUnmappedForKind(kind, limit) {
29974
30324
  }
29975
30325
  return Array.from(byId.values());
29976
30326
  }
30327
+ var DEFAULT_CONNECTOR_CONNECT_URL = "https://mcp.agent-swarm.dev/connections";
30328
+ function getConnectorConnectUrl() {
30329
+ const raw = process.env.CONNECTOR_CONNECT_URL?.trim() || DEFAULT_CONNECTOR_CONNECT_URL;
30330
+ try {
30331
+ const url = new URL(raw);
30332
+ return url.protocol === "https:" ? url : null;
30333
+ } catch {
30334
+ return null;
30335
+ }
30336
+ }
30337
+ var LOOPBACK_HOSTS = new Set(["localhost", "127.0.0.1", "[::1]"]);
30338
+ function isConnectableSwarmOrigin(value) {
30339
+ try {
30340
+ const url = new URL(value);
30341
+ return url.protocol === "https:" || url.protocol === "http:" && LOOPBACK_HOSTS.has(url.hostname);
30342
+ } catch {
30343
+ return false;
30344
+ }
30345
+ }
30346
+ var CONNECTOR_CODE_PATTERN = /^[A-Za-z0-9_-]{43}$/;
30347
+ var connectorExchangeRateLimiter = createIpRateLimiter({
30348
+ capacity: 10,
30349
+ refillPerMs: 10 / 60000
30350
+ });
29977
30351
  async function handleUsers(req, res, pathSegments, queryParams) {
29978
30352
  if (whoamiRoute.match(req.method, pathSegments)) {
29979
30353
  const parsed = await whoamiRoute.parse(req, res, pathSegments, queryParams);
@@ -30116,6 +30490,77 @@ async function handleUsers(req, res, pathSegments, queryParams) {
30116
30490
  }
30117
30491
  return true;
30118
30492
  }
30493
+ if (createConnectorCodeRoute.match(req.method, pathSegments)) {
30494
+ const parsed = await createConnectorCodeRoute.parse(req, res, pathSegments, queryParams);
30495
+ if (!parsed)
30496
+ return true;
30497
+ const actor = getOperatorActor(req, res);
30498
+ if (!actor)
30499
+ return true;
30500
+ if (!await getUserById(parsed.params.id)) {
30501
+ jsonError(res, "User not found", 404);
30502
+ return true;
30503
+ }
30504
+ const swarmOrigin = await resolveMcpBaseUrl();
30505
+ if (!isConnectableSwarmOrigin(swarmOrigin)) {
30506
+ jsonError(res, `The public API origin (${swarmOrigin}) is not HTTPS. Set PUBLIC_MCP_BASE_URL to an https:// origin.`, 400);
30507
+ return true;
30508
+ }
30509
+ const connect2 = getConnectorConnectUrl();
30510
+ if (!connect2) {
30511
+ jsonError(res, "CONNECTOR_CONNECT_URL must be an https:// URL.", 400);
30512
+ return true;
30513
+ }
30514
+ try {
30515
+ const { code, expiresAt } = await createConnectorCode(parsed.params.id, parsed.body.label ?? DEFAULT_CONNECTOR_CODE_LABEL, actor);
30516
+ connect2.searchParams.set("swarm", swarmOrigin);
30517
+ connect2.searchParams.set("code", code);
30518
+ const connectUrl = connect2.toString();
30519
+ createConnectorCodeRoute.respond(res, 201, { code, expiresAt, connectUrl });
30520
+ } catch (err) {
30521
+ jsonError(res, err instanceof Error ? err.message : "Failed to create connector code", 500);
30522
+ }
30523
+ return true;
30524
+ }
30525
+ if (connectorDiscoveryRoute.match(req.method, pathSegments)) {
30526
+ const parsed = await connectorDiscoveryRoute.parse(req, res, pathSegments, queryParams);
30527
+ if (!parsed)
30528
+ return true;
30529
+ const resolvedAppUrl = await resolveAppUrl();
30530
+ const appUrl = resolvedAppUrl?.startsWith("https://") ? resolvedAppUrl : null;
30531
+ connectorDiscoveryRoute.respond(res, 200, {
30532
+ apiUrl: await resolveMcpBaseUrl(),
30533
+ ...appUrl ? { appUrl } : {},
30534
+ connectUrl: getConnectorConnectUrl()?.toString() ?? null
30535
+ });
30536
+ return true;
30537
+ }
30538
+ if (exchangeConnectorCodeRoute.match(req.method, pathSegments)) {
30539
+ if (!connectorExchangeRateLimiter.take(clientIp(req))) {
30540
+ res.setHeader("Retry-After", "6");
30541
+ jsonError(res, "rate_limited", 429);
30542
+ return true;
30543
+ }
30544
+ const parsed = await exchangeConnectorCodeRoute.parse(req, res, pathSegments, queryParams);
30545
+ if (!parsed)
30546
+ return true;
30547
+ if (!CONNECTOR_CODE_PATTERN.test(parsed.body.code)) {
30548
+ jsonError(res, "code_invalid", 404);
30549
+ return true;
30550
+ }
30551
+ try {
30552
+ const result = await exchangeConnectorCode(parsed.body.code);
30553
+ if (!result) {
30554
+ jsonError(res, "code_invalid", 404);
30555
+ return true;
30556
+ }
30557
+ const version = (await Bun.file("package.json").json()).version;
30558
+ exchangeConnectorCodeRoute.respond(res, 200, { ...result, version });
30559
+ } catch (err) {
30560
+ jsonError(res, err instanceof Error ? err.message : "Failed to exchange code", 500);
30561
+ }
30562
+ return true;
30563
+ }
30119
30564
  if (revokeUserMcpTokenRoute.match(req.method, pathSegments)) {
30120
30565
  const parsed = await revokeUserMcpTokenRoute.parse(req, res, pathSegments, queryParams);
30121
30566
  if (!parsed)
@@ -30371,7 +30816,7 @@ async function handleUsers(req, res, pathSegments, queryParams) {
30371
30816
  init_zod();
30372
30817
 
30373
30818
  // src/agentmail/inbound-archive.ts
30374
- init_db();
30819
+ init_db2();
30375
30820
  init_secret_scrubber();
30376
30821
  import { createHash as createHash3 } from "node:crypto";
30377
30822
  var INBOUND_ARCHIVE_NAMESPACE = "agentmail-inbound";
@@ -31134,7 +31579,7 @@ async function handleWebhooks(req, res, pathSegments) {
31134
31579
 
31135
31580
  // src/http/workflow-events.ts
31136
31581
  init_zod();
31137
- init_db();
31582
+ init_db2();
31138
31583
  init_event_bus();
31139
31584
  var runScopedSignalRoute = route({
31140
31585
  method: "post",
@@ -31217,7 +31662,7 @@ async function handleWorkflowEvents(req, res, pathSegments, queryParams) {
31217
31662
 
31218
31663
  // src/http/workflows.ts
31219
31664
  init_zod();
31220
- init_db();
31665
+ init_db2();
31221
31666
  init_types();
31222
31667
  var WorkflowWithFavoriteSchema = WorkflowSchema.extend({ favorite: exports_external.boolean() });
31223
31668
  var WorkflowSaveResponseSchema = WorkflowSchema.extend({
@@ -31942,13 +32387,13 @@ async function handleWorkflows(req, res, pathSegments, queryParams, myAgentId) {
31942
32387
  const parsed = await getWorkflowRunRoute.parse(req, res, pathSegments, queryParams);
31943
32388
  if (!parsed)
31944
32389
  return true;
31945
- const run = await getWorkflowRun(parsed.params.id);
32390
+ const run = await getWorkflowRun(parsed.params.id, "display");
31946
32391
  if (!run) {
31947
32392
  res.writeHead(404);
31948
32393
  res.end();
31949
32394
  return true;
31950
32395
  }
31951
- const steps = await getWorkflowRunStepsByRunId(parsed.params.id);
32396
+ const steps = await getWorkflowRunStepsByRunId(parsed.params.id, "display");
31952
32397
  getWorkflowRunRoute.respond(res, 200, { run, steps });
31953
32398
  return true;
31954
32399
  }
@@ -31983,8 +32428,9 @@ async function handleWorkflows(req, res, pathSegments, queryParams, myAgentId) {
31983
32428
 
31984
32429
  // src/http/x.ts
31985
32430
  init_zod();
31986
- init_db();
32431
+ init_db2();
31987
32432
  import { timingSafeEqual as timingSafeEqual2 } from "node:crypto";
32433
+ init_db();
31988
32434
  init_secret_scrubber();
31989
32435
  var DEFAULT_TIMEOUT_MS = 60000;
31990
32436
  var TIMEOUT_HEADER = "x-swarm-timeout-ms";
@@ -32402,7 +32848,7 @@ async function shutdown() {
32402
32848
  sessionsProcessed: getServerSessionsProcessed()
32403
32849
  });
32404
32850
  if (hasCapability("scheduling")) {
32405
- const { stopScheduler } = await import("./index-r46s01nq.js");
32851
+ const { stopScheduler } = await import("./index-bn6cy8ps.js");
32406
32852
  stopScheduler();
32407
32853
  }
32408
32854
  stopHeartbeat();
@@ -32411,7 +32857,7 @@ async function shutdown() {
32411
32857
  await stopScriptRunSupervisor();
32412
32858
  await stopSlackApp();
32413
32859
  if (process.env.OAUTH_KEEPALIVE_DISABLE !== "true") {
32414
- const { stopOAuthKeepalive } = await import("./keepalive-31613r2h.js");
32860
+ const { stopOAuthKeepalive } = await import("./keepalive-3xspa9jw.js");
32415
32861
  await stopOAuthKeepalive();
32416
32862
  }
32417
32863
  stopOAuthPendingGc();
@@ -32474,21 +32920,27 @@ try {
32474
32920
  throw err;
32475
32921
  }
32476
32922
  warnIfCorsAllowsAnyOrigin();
32923
+ try {
32924
+ const loaded = await loadSecretRegistry();
32925
+ console.log(`[secret-registry] registered config=${loaded.config} oauth=${loaded.oauth} scriptApi=${loaded.scriptApi} failed=${loaded.failed}`);
32926
+ } catch (err) {
32927
+ console.error("[secret-registry] load failed (non-fatal):", scrubSecrets(err instanceof Error ? err.message : String(err)));
32928
+ }
32477
32929
  try {
32478
32930
  await seedLegacyCapabilitiesConfig();
32479
32931
  } catch (err) {
32480
32932
  console.warn("[startup] CAPABILITIES upgrade seed failed (non-fatal):", err);
32481
32933
  }
32482
32934
  try {
32483
- const { ensurePricingSeeded } = await import("./boot-seeds-ex93edx7.js");
32935
+ const { ensurePricingSeeded } = await import("./boot-seeds-vvzs1zhk.js");
32484
32936
  ensurePricingSeeded();
32485
- const { startPricingRefreshLoop } = await import("./pricing-refresh-7w8mbmva.js");
32937
+ const { startPricingRefreshLoop } = await import("./pricing-refresh-atnkngqs.js");
32486
32938
  startPricingRefreshLoop();
32487
32939
  } catch (err) {
32488
32940
  console.error("[startup] Failed to seed pricing rows:", err);
32489
32941
  }
32490
32942
  try {
32491
- const { ensureRbacSeeded } = await import("./boot-seeds-ex93edx7.js");
32943
+ const { ensureRbacSeeded } = await import("./boot-seeds-vvzs1zhk.js");
32492
32944
  ensureRbacSeeded();
32493
32945
  } catch (err) {
32494
32946
  console.error("[startup] Failed to sync RBAC seed rows:", err);
@@ -32496,7 +32948,7 @@ try {
32496
32948
  throw err;
32497
32949
  }
32498
32950
  try {
32499
- const { runAllSeeders } = await import("./index-630kj5vd.js");
32951
+ const { runAllSeeders } = await import("./index-f8xnqrye.js");
32500
32952
  await runAllSeeders({ scriptEmbeddingMode: "skip" });
32501
32953
  } catch (err) {
32502
32954
  console.error("[startup] Failed to seed built-in entities:", err);
@@ -32556,38 +33008,38 @@ httpServer.listen(port, async () => {
32556
33008
  await initWorkflows();
32557
33009
  await startScriptRunSupervisor(getMcpBaseUrl());
32558
33010
  if (hasCapability("scheduling")) {
32559
- const { startScheduler } = await import("./index-r46s01nq.js");
32560
- const { getExecutorRegistry: getExecutorRegistry2 } = await import("./index-9nrj7797.js");
33011
+ const { startScheduler } = await import("./index-bn6cy8ps.js");
33012
+ const { getExecutorRegistry: getExecutorRegistry2 } = await import("./index-n99fycq7.js");
32561
33013
  const intervalMs = Number(process.env.SCHEDULER_INTERVAL_MS) || 1e4;
32562
33014
  startScheduler(getExecutorRegistry2(), intervalMs, {
32563
33015
  runId: globalState.__runId
32564
33016
  });
32565
33017
  }
32566
33018
  if (!isEnvFlagEnabled("HEARTBEAT_DISABLE", false)) {
32567
- const { startHeartbeat } = await import("./index-38kqdt3e.js");
33019
+ const { startHeartbeat } = await import("./index-dkfxpkmm.js");
32568
33020
  const heartbeatMs = Number(process.env.HEARTBEAT_INTERVAL_MS) || 90000;
32569
33021
  startHeartbeat(heartbeatMs);
32570
33022
  }
32571
33023
  if (process.env.OAUTH_KEEPALIVE_DISABLE !== "true") {
32572
- const { startOAuthKeepalive } = await import("./keepalive-31613r2h.js");
33024
+ const { startOAuthKeepalive } = await import("./keepalive-3xspa9jw.js");
32573
33025
  startOAuthKeepalive();
32574
33026
  }
32575
33027
  if (process.env.OAUTH_REFRESH_SWEEP_DISABLE !== "true") {
32576
- const { startOAuthRefreshSweep } = await import("./oauth-refresh-sweep-anma954w.js");
33028
+ const { startOAuthRefreshSweep } = await import("./oauth-refresh-sweep-sh9q25xp.js");
32577
33029
  startOAuthRefreshSweep();
32578
33030
  }
32579
33031
  startOAuthPendingGc();
32580
33032
  await startMemoryGc();
32581
33033
  await startDbRetention();
32582
33034
  startHumanFreeDrain();
32583
- import("./boot-reembed-6rhcpsjf.js").then(({ runBootReembed }) => runBootReembed()).catch((err) => {
33035
+ import("./boot-reembed-s7k7c6v2.js").then(({ runBootReembed }) => runBootReembed()).catch((err) => {
32584
33036
  console.error("[boot-reembed] startup backfill failed (non-fatal):", err);
32585
33037
  });
32586
- import("./boot-reembed-k1q2s4fc.js").then(({ runBootReembedScripts }) => runBootReembedScripts()).catch((err) => {
33038
+ import("./boot-reembed-998jtpdg.js").then(({ runBootReembedScripts }) => runBootReembedScripts()).catch((err) => {
32587
33039
  console.error("[boot-reembed-scripts] startup backfill failed (non-fatal):", err);
32588
33040
  });
32589
- import("./boot-scrub-logs-t8xg7wd7.js").then(({ runBootScrubLogs }) => runBootScrubLogs()).catch((err) => {
32590
- console.error("[boot-scrub-logs] startup scrub failed (non-fatal):", err);
33041
+ import("./boot-scrub-sweep-nepsk4t1.js").then(({ runBootScrubSweep }) => runBootScrubSweep()).catch((err) => {
33042
+ console.error("[boot-scrub-sweep] startup scrub failed (non-fatal):", err);
32591
33043
  });
32592
33044
  }).on("error", (err) => {
32593
33045
  console.error("HTTP Server Error:", err);