@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,12 +2,12 @@ import {
2
2
  COMPOSIO_HTTP_METHODS,
3
3
  composioArgsFromParts,
4
4
  executeComposioRequest
5
- } from "./cli-003785v9.js";
5
+ } from "./cli-xvc3q9br.js";
6
6
  import {
7
7
  ampModelError,
8
8
  ampPinCatalogError,
9
9
  ampPinProviderError
10
- } from "./cli-07s39g1n.js";
10
+ } from "./cli-mv2520nm.js";
11
11
  import {
12
12
  LlmRater,
13
13
  REFERENCES_SOURCE_MAX_LENGTH,
@@ -20,7 +20,7 @@ import {
20
20
  import {
21
21
  ensurePricingSeeded,
22
22
  ensureRbacSeeded
23
- } from "./cli-etbrt8x1.js";
23
+ } from "./cli-0nhdwxd5.js";
24
24
  import {
25
25
  buildCatalogEntries,
26
26
  getCatalogGeneration,
@@ -30,10 +30,10 @@ import {
30
30
  requestModelCatalogRefresh,
31
31
  startPricingRefreshLoop,
32
32
  upsertModelCatalogOverlay
33
- } from "./cli-976r1zqx.js";
33
+ } from "./cli-rggdq8wq.js";
34
34
  import {
35
35
  loadModelsDevCache
36
- } from "./cli-wg8yjqtw.js";
36
+ } from "./cli-ysnyhws9.js";
37
37
  import {
38
38
  AppDefinitionSchema,
39
39
  AppElementsSchema,
@@ -64,7 +64,6 @@ import {
64
64
  decodeAppDefinition,
65
65
  definitionNodeIds,
66
66
  deleteApp,
67
- deleteScript,
68
67
  disableCredentialBinding,
69
68
  extractArgsJsonSchema,
70
69
  extractScriptSignature,
@@ -75,12 +74,9 @@ import {
75
74
  getOAuthBindingTokenStatus,
76
75
  getOAuthProviderConfig,
77
76
  getSavedScriptOwnerAgentId,
78
- getScript,
79
77
  getScriptApiConnectionDescriptors,
80
- getScriptById,
81
78
  getScriptConnectionById,
82
79
  getScriptMcpConnectionDescriptors,
83
- getScriptVersion,
84
80
  getSuccessors,
85
81
  isIso8601Date,
86
82
  listApps,
@@ -95,7 +91,6 @@ import {
95
91
  resolveSyncRunAs,
96
92
  resolveValidationPort,
97
93
  resolveWorkflowLlmConfig,
98
- restoreScratchScriptLastUsedIfUnchanged,
99
94
  runSavedScriptAsAgent,
100
95
  runScript,
101
96
  sandboxSpawnEnv,
@@ -103,17 +98,15 @@ import {
103
98
  snapshotCapped,
104
99
  systemOneRetryViolations,
105
100
  systemOneUnresolvedError,
106
- touchScratchScriptLastUsed,
107
101
  typecheckScript,
108
102
  updateApp,
109
103
  upgradeAppDefinition,
110
104
  upsertCredentialBinding,
111
- upsertScriptByName,
112
105
  upsertScriptConnection,
113
106
  validateDefinition,
114
107
  validateScriptImports,
115
108
  writeBareImportShim
116
- } from "./cli-j0tmc908.js";
109
+ } from "./cli-jvj6a0cv.js";
117
110
  import {
118
111
  getApiKey
119
112
  } from "./cli-f14fvzag.js";
@@ -127,46 +120,13 @@ import {
127
120
  getFileStorageProvider,
128
121
  providerPath
129
122
  } from "./cli-mzfth0bp.js";
130
- import {
131
- embedScript
132
- } from "./cli-0a7r5331.js";
133
- import {
134
- CANDIDATE_SET_MULTIPLIER,
135
- LONGTERM_ROOT,
136
- MEMORY_KEY_MAX_LENGTH,
137
- MEMORY_KEY_PATTERN,
138
- MEMORY_KEY_PATTERN_MESSAGE,
139
- computeScore,
140
- consolidatedKeyMessage,
141
- getEmbeddingProvider,
142
- getMemoryStore,
143
- init_constants as init_constants2,
144
- init_key_paths,
145
- init_reranker,
146
- init_sqlite_store,
147
- isConsolidatedKey,
148
- isGraphExpansionEnabled,
149
- isLongtermKey,
150
- longtermKeyError,
151
- rerank,
152
- resolveStoreKey,
153
- rowToCandidate
154
- } from "./cli-v7fqehqd.js";
155
123
  import {
156
124
  buildAuthorizationUrl,
157
- createOAuthApp,
158
125
  ensureAuthorizationTokenOrThrow,
159
126
  ensureToken,
160
127
  ensureTokenOrThrow,
161
- getAuthorizationById,
162
- getOAuthApp,
163
- getOAuthAppById,
164
- getOAuthAppIdByProvider,
165
- getOAuthTokens,
166
- listAuthorizationsForApp,
167
- onAuthorizationRefreshed,
168
- upsertOAuthApp
169
- } from "./cli-93rxw9yd.js";
128
+ onAuthorizationRefreshed
129
+ } from "./cli-j2jbr8af.js";
170
130
  import {
171
131
  ZodFirstPartyTypeKind,
172
132
  objectType
@@ -196,16 +156,11 @@ import {
196
156
  taskCitationWarnings,
197
157
  upsertTaskCitations,
198
158
  withSpan
199
- } from "./cli-4drstbb9.js";
200
- import {
201
- init_task_attachment_links,
202
- taskAttachmentDisplayUrl,
203
- taskAttachmentFetchCommand
204
- } from "./cli-cvk6yzw5.js";
159
+ } from "./cli-ecknp7p1.js";
205
160
  import {
206
161
  getUserGrant,
207
162
  init_rbac_roles
208
- } from "./cli-xb7kyanp.js";
163
+ } from "./cli-8kgvmkak.js";
209
164
  import {
210
165
  can,
211
166
  decideAdmission,
@@ -214,19 +169,26 @@ import {
214
169
  init_rbac,
215
170
  isRbacEnabled,
216
171
  revokeLeadEquivalence
217
- } from "./cli-1wd1n2ya.js";
172
+ } from "./cli-rfphkzh5.js";
218
173
  import {
219
174
  API_DRAIN_MAX_MS_LIMIT,
175
+ CANDIDATE_SET_MULTIPLIER,
220
176
  CredentialBindingSchema,
221
177
  EXTENSION_AGENT_ROLE,
222
178
  KvTypeCollisionError,
179
+ LONGTERM_ROOT,
223
180
  MAX_EMPTY_POLLS,
181
+ MEMORY_KEY_MAX_LENGTH,
182
+ MEMORY_KEY_PATTERN,
183
+ MEMORY_KEY_PATTERN_MESSAGE,
224
184
  SteeringRequestError,
185
+ WorkflowReplayStateError,
225
186
  acceptTask,
226
187
  agentContextKey,
227
188
  agentmailContextKey,
228
189
  azureDevOpsContextKey,
229
190
  beginRequestAuthScope,
191
+ breaksJsonValidity,
230
192
  buildJiraContextKey,
231
193
  buildRoutingAffinityFromAgent,
232
194
  cancelApprovalRequestById,
@@ -238,6 +200,8 @@ import {
238
200
  claimTask,
239
201
  completeTask,
240
202
  computeContentHash,
203
+ computeScore,
204
+ consolidatedKeyMessage,
241
205
  countKv,
242
206
  createAgent,
243
207
  createAgentMailInboxMapping,
@@ -248,6 +212,7 @@ import {
248
212
  createMcpServer,
249
213
  createMetric,
250
214
  createMetricVersion,
215
+ createOAuthApp,
251
216
  createPage,
252
217
  createPageVersion,
253
218
  createScheduledTask,
@@ -265,6 +230,7 @@ import {
265
230
  deletePage,
266
231
  deletePromptTemplate,
267
232
  deleteScheduledTask,
233
+ deleteScript,
268
234
  deleteService,
269
235
  deleteSkill,
270
236
  deleteSkillFile,
@@ -272,6 +238,7 @@ import {
272
238
  deleteUser,
273
239
  deleteWorkflow,
274
240
  detachTaskFromWorkflowRunStep,
241
+ embedScript,
275
242
  emitMcpServerConnectedTelemetry,
276
243
  exports_db,
277
244
  extensionAgentAssignmentError,
@@ -299,6 +266,7 @@ import {
299
266
  getAppVersion,
300
267
  getAppVersions,
301
268
  getApprovalRequestById,
269
+ getAuthorizationById,
302
270
  getBudget,
303
271
  getChannelById,
304
272
  getChannelByName,
@@ -315,6 +283,7 @@ import {
315
283
  getDependentTasks,
316
284
  getDueScheduledTasks,
317
285
  getDueWaitStates,
286
+ getEmbeddingProvider,
318
287
  getInProgressTasksByContextKey,
319
288
  getInboxMessageById,
320
289
  getInboxSummary,
@@ -328,10 +297,15 @@ import {
328
297
  getLogsByTaskIdChronological,
329
298
  getMcpServerById,
330
299
  getMcpServerByName,
300
+ getMemoryStore,
331
301
  getMentionsForAgent,
332
302
  getMetric,
333
303
  getMetricBySlug,
334
304
  getMetricVersions,
305
+ getOAuthApp,
306
+ getOAuthAppById,
307
+ getOAuthAppIdByProvider,
308
+ getOAuthTokens,
335
309
  getOfferedTasksForAgent,
336
310
  getPage,
337
311
  getPageBySlug,
@@ -349,6 +323,9 @@ import {
349
323
  getScheduledTaskById,
350
324
  getScheduledTaskByName,
351
325
  getScheduledTasks,
326
+ getScript,
327
+ getScriptById,
328
+ getScriptVersion,
352
329
  getServiceByAgentAndName,
353
330
  getServiceById,
354
331
  getSessionLogsByTaskId,
@@ -389,39 +366,54 @@ import {
389
366
  incrementEmptyPollCount,
390
367
  initDb,
391
368
  init_api_drain,
369
+ init_constants as init_constants2,
392
370
  init_context_key,
393
371
  init_credential_broker,
394
372
  init_date_utils,
395
373
  init_db,
374
+ init_db1 as init_db2,
396
375
  init_db_client,
376
+ init_embeddings,
377
+ init_key_paths,
378
+ init_memory,
397
379
  init_model_tier_keys,
380
+ init_oauth,
398
381
  init_request_auth_context,
382
+ init_reranker,
383
+ init_scrub_json,
399
384
  init_slack_routing,
385
+ init_sqlite_store,
400
386
  init_steering,
401
387
  init_swarm_config_guard,
402
388
  init_task_lifecycle_events,
403
389
  init_telemetry,
404
390
  init_telemetry_identity,
405
391
  init_templates1 as init_templates,
392
+ init_workflow_replay,
406
393
  insertTaskAttachment,
407
394
  installMcpServer,
408
395
  installSkill,
409
396
  internalConfigKeyError,
410
397
  isAgentEligibleForTask,
398
+ isConsolidatedKey,
411
399
  isExtensionAgent,
400
+ isGraphExpansionEnabled,
412
401
  isInTransaction,
413
402
  isInternalConfigKey,
414
403
  isLinearTrackerContextKey,
404
+ isLongtermKey,
415
405
  isReservedConfigKey,
416
406
  isSteeringEnabled,
417
407
  kvPrefixUpperBound,
418
408
  linearContextKey,
409
+ listAuthorizationsForApp,
419
410
  listCancelledApprovalRequestsForRun,
420
411
  listKv,
421
412
  listMcpServers,
422
413
  listSkills,
423
414
  listWorkflowRunsPage,
424
415
  listWorkflows,
416
+ longtermKeyError,
425
417
  markInboxMessageResponded,
426
418
  markSteeringHandled,
427
419
  markTaskSlackReplySent,
@@ -443,14 +435,19 @@ import {
443
435
  releaseMentionProcessing,
444
436
  releaseTask,
445
437
  requestSteering,
438
+ rerank,
446
439
  reservedKeyError,
447
440
  resetEmptyPollCount,
448
441
  resolveApprovalRequest,
449
442
  resolveSqliteVecExtensionPath,
443
+ resolveStoreKey,
450
444
  resolveWaitState,
445
+ restoreScratchScriptLastUsedIfUnchanged,
446
+ rowToCandidate,
451
447
  runWithoutRequestAuth,
452
448
  scheduleContextKey,
453
449
  scheduleOrgDomainRecompute,
450
+ scrubJsonValue,
454
451
  searchSkills,
455
452
  setBudgetRefusalFollowUpTaskId,
456
453
  setRequestAuth,
@@ -459,6 +456,7 @@ import {
459
456
  sweepExpiredKvPrefix,
460
457
  telemetry,
461
458
  tierConfigKey,
459
+ touchScratchScriptLastUsed,
462
460
  uninstallMcpServer,
463
461
  uninstallSkill,
464
462
  updateAgentMaxTasks,
@@ -480,13 +478,15 @@ import {
480
478
  updateWorkflowRun,
481
479
  updateWorkflowRunStep,
482
480
  upsertKv,
481
+ upsertOAuthApp,
483
482
  upsertPromptTemplate,
483
+ upsertScriptByName,
484
484
  upsertService,
485
485
  upsertSkillFiles,
486
486
  upsertSwarmConfig,
487
487
  validateConfigValue,
488
488
  workflowContextKey
489
- } from "./cli-0wn3ypqv.js";
489
+ } from "./cli-yshaazs1.js";
490
490
  import {
491
491
  $OpenAPIRegistry,
492
492
  $OpenApiGeneratorV31,
@@ -546,18 +546,21 @@ import {
546
546
  parseAssetKey,
547
547
  parseModelTier,
548
548
  splitLegacyModelAlias
549
- } from "./cli-v0e7jpr5.js";
549
+ } from "./cli-xvdgasgy.js";
550
550
  import {
551
551
  generateDefaultClaudeMd,
552
552
  generateDefaultIdentityMd,
553
553
  generateDefaultSoulMd,
554
- init_defaults
555
- } from "./cli-vbr859rz.js";
554
+ init_defaults,
555
+ init_task_attachment_links,
556
+ taskAttachmentDisplayUrl,
557
+ taskAttachmentFetchCommand
558
+ } from "./cli-jhm6hzjn.js";
556
559
  import {
557
560
  getSlackConfiguration,
558
561
  init_config,
559
562
  isSlackConfigured
560
- } from "./cli-n7h1kqpf.js";
563
+ } from "./cli-dmtrxqhg.js";
561
564
  import {
562
565
  MAX_PROFILE_FILE_LENGTH,
563
566
  getAgentFsDefaultDriveId,
@@ -594,10 +597,11 @@ import {
594
597
  harnessModelMismatch,
595
598
  init_src,
596
599
  isAlias,
600
+ isHarnessModelJudged,
597
601
  modelFamilyKey,
598
602
  parseAlias,
599
603
  resolveAlias
600
- } from "./cli-g3qgrzck.js";
604
+ } from "./cli-zsh093hk.js";
601
605
  import {
602
606
  exports_zod,
603
607
  init_zod
@@ -646,11 +650,11 @@ import {
646
650
  import {
647
651
  init_package,
648
652
  package_default
649
- } from "./cli-1d3w4xm3.js";
653
+ } from "./cli-4r1sjfc4.js";
650
654
  import {
651
655
  init_event_bus,
652
656
  workflowEventBus
653
- } from "./cli-xxz89c2n.js";
657
+ } from "./cli-mb75wpxf.js";
654
658
  import {
655
659
  init_bus,
656
660
  realtimeBus
@@ -663,7 +667,7 @@ import {
663
667
  registerVolatileSecret,
664
668
  scrubObject,
665
669
  scrubSecrets
666
- } from "./cli-qt5wzq6v.js";
670
+ } from "./cli-wt7ccy4r.js";
667
671
  import {
668
672
  __callDispose,
669
673
  __commonJS,
@@ -14386,7 +14390,7 @@ async function notifyAutomationPreflightFailure(preflight) {
14386
14390
  return;
14387
14391
  }
14388
14392
  try {
14389
- const { getSlackApp: getSlackApp2 } = await import("./app-w2d26h4f.js");
14393
+ const { getSlackApp: getSlackApp2 } = await import("./app-43vrdmv8.js");
14390
14394
  const app = getSlackApp2();
14391
14395
  if (!app) {
14392
14396
  console.warn("[Automation Preflight] Slack not available, cannot send notification");
@@ -14410,7 +14414,11 @@ Fix setup: ${getAppUrl()}${preflight.fixUrl}`),
14410
14414
 
14411
14415
  // src/be/automation-preflight.ts
14412
14416
  init_config();
14413
- init_db();
14417
+ init_env_flag();
14418
+ init_secret_scrubber();
14419
+ init_db2();
14420
+ init_oauth();
14421
+ init_scrub_json();
14414
14422
  var NEEDS_SETUP_PREFIX = "needs_setup:";
14415
14423
  function hasValue(value) {
14416
14424
  if (value == null)
@@ -14564,9 +14572,6 @@ function renderAutomationTokens(value, params) {
14564
14572
  }
14565
14573
  return render(value);
14566
14574
  }
14567
- function enabled(flag) {
14568
- return flag !== "true" && flag !== "1";
14569
- }
14570
14575
  function present(value) {
14571
14576
  return !!value?.trim();
14572
14577
  }
@@ -14592,7 +14597,7 @@ async function getAutomationSetupStates() {
14592
14597
  linear: linearTokens ? "verified" : "unverified",
14593
14598
  jira: jiraTokens && jiraCloudId ? "verified" : "unverified",
14594
14599
  gsc: gscConfigured ? "verified" : "unverified",
14595
- agentmail: enabled(process.env.AGENTMAIL_DISABLE) && present(process.env.AGENTMAIL_API_KEY) ? "verified" : "unverified",
14600
+ agentmail: !isEnvFlagEnabled("AGENTMAIL_DISABLE", false) && present(process.env.AGENTMAIL_API_KEY) ? "verified" : "unverified",
14596
14601
  agentfs: present(process.env.AGENT_FS_API_URL) && present(agentFsKey) && present(agentFsOrg) && present(process.env.AGENT_FS_DEFAULT_DRIVE_ID) ? "verified" : "unverified"
14597
14602
  };
14598
14603
  }
@@ -14624,16 +14629,17 @@ function utcDayBounds(now) {
14624
14629
  return { start: start.toISOString(), end: new Date(start.getTime() + 86400000).toISOString() };
14625
14630
  }
14626
14631
  async function recordSchedulePreflightFailure(scheduleId, failureReason, now = new Date) {
14632
+ const message = scrubSecrets(failureReason);
14627
14633
  return await getDbClient().transaction(async (tx) => {
14628
14634
  const row = await tx.get("SELECT lastErrorAt, lastErrorMessage FROM scheduled_tasks WHERE id = ?", [scheduleId]);
14629
14635
  if (!row)
14630
14636
  return false;
14631
- if (row.lastErrorMessage === failureReason && row.lastErrorAt?.slice(0, 10) === now.toISOString().slice(0, 10)) {
14637
+ if (row.lastErrorMessage === message && row.lastErrorAt?.slice(0, 10) === now.toISOString().slice(0, 10)) {
14632
14638
  return false;
14633
14639
  }
14634
14640
  await tx.run(`UPDATE scheduled_tasks
14635
14641
  SET lastErrorAt = ?, lastErrorMessage = ?, lastUpdatedAt = ?
14636
- WHERE id = ?`, [now.toISOString(), failureReason, now.toISOString(), scheduleId]);
14642
+ WHERE id = ?`, [now.toISOString(), message, now.toISOString(), scheduleId]);
14637
14643
  return true;
14638
14644
  });
14639
14645
  }
@@ -14657,8 +14663,8 @@ async function recordWorkflowPreflightFailure(input) {
14657
14663
  runId,
14658
14664
  input.workflowId,
14659
14665
  input.triggerType,
14660
- input.triggerData === undefined ? null : JSON.stringify(input.triggerData),
14661
- input.failureReason,
14666
+ input.triggerData === undefined ? null : scrubJsonValue(input.triggerData),
14667
+ scrubSecrets(input.failureReason),
14662
14668
  input.createdBy ?? null,
14663
14669
  timestamp,
14664
14670
  timestamp,
@@ -14669,11 +14675,12 @@ async function recordWorkflowPreflightFailure(input) {
14669
14675
  }
14670
14676
 
14671
14677
  // src/workflows/engine.ts
14672
- init_db();
14678
+ init_db2();
14679
+ init_workflow_replay();
14673
14680
  init_telemetry();
14674
14681
 
14675
14682
  // src/workflows/checkpoint.ts
14676
- init_db();
14683
+ init_db2();
14677
14684
  async function checkpointStep(runId, stepId, nodeId, result, ctx) {
14678
14685
  await getDbClient().transaction(async () => {
14679
14686
  await updateWorkflowRunStep(stepId, {
@@ -14760,10 +14767,10 @@ function calculateBackoff(policy, attempt) {
14760
14767
  }
14761
14768
 
14762
14769
  // src/workflows/completed-step-routing.ts
14763
- init_db();
14770
+ init_db2();
14764
14771
 
14765
14772
  // src/workflows/foreach-join.ts
14766
- init_db();
14773
+ init_db2();
14767
14774
  var FOREACH_TERMINAL_STEP_STATUSES = new Set([
14768
14775
  "completed",
14769
14776
  "failed",
@@ -14860,7 +14867,7 @@ async function loadCompletedStepRouting(def, runId, completedNodeIds) {
14860
14867
  }
14861
14868
 
14862
14869
  // src/workflows/cooldown.ts
14863
- init_db();
14870
+ init_db2();
14864
14871
  function cooldownToMs(cooldown) {
14865
14872
  let ms = 0;
14866
14873
  if (cooldown.hours)
@@ -14890,7 +14897,7 @@ async function shouldSkipCooldown(workflowId, cooldown) {
14890
14897
  }
14891
14898
 
14892
14899
  // src/workflows/input.ts
14893
- init_db();
14900
+ init_db2();
14894
14901
  init_secret_scrubber();
14895
14902
  async function resolveInputs(input) {
14896
14903
  const resolved = {};
@@ -15298,6 +15305,22 @@ async function startWorkflowExecution(workflow, triggerData, registry, options =
15298
15305
  }
15299
15306
  var activeWalks = new Map;
15300
15307
  var executingSteps = new Set;
15308
+ async function failRunOnUnreadableReplay(runId, err, stepId) {
15309
+ if (!(err instanceof WorkflowReplayStateError))
15310
+ return false;
15311
+ const finishedAt = new Date().toISOString();
15312
+ console.error(`[workflow] ${err.message}`);
15313
+ if (stepId) {
15314
+ await updateWorkflowRunStep(stepId, {
15315
+ status: "failed",
15316
+ error: err.message,
15317
+ finishedAt,
15318
+ nextRetryAt: null
15319
+ });
15320
+ }
15321
+ await updateWorkflowRun(runId, { status: "failed", error: err.message, finishedAt });
15322
+ return true;
15323
+ }
15301
15324
  function isWorkflowRunActive(runId) {
15302
15325
  return activeWalks.has(runId);
15303
15326
  }
@@ -15319,6 +15342,9 @@ async function walkGraph(def, runId, ctx, startNodes, registry, workflowId, secr
15319
15342
  const release = holdWorkflowRun(runId);
15320
15343
  try {
15321
15344
  await walkGraphOwned(def, runId, ctx, startNodes, registry, workflowId, secretKeys, options);
15345
+ } catch (err) {
15346
+ if (!await failRunOnUnreadableReplay(runId, err))
15347
+ throw err;
15322
15348
  } finally {
15323
15349
  release();
15324
15350
  }
@@ -15374,10 +15400,10 @@ async function walkGraphOwned(def, runId, ctx, startNodes, registry, workflowId,
15374
15400
  });
15375
15401
  return;
15376
15402
  }
15377
- const results = await Promise.all(pendingNodes.map((node) => executeStep(def, runId, ctx, node, registry, workflowId, secretKeys, options).catch((_err) => ({
15378
- outcome: "failed",
15379
- successors: []
15380
- }))));
15403
+ const results = await Promise.all(pendingNodes.map((node) => executeStep(def, runId, ctx, node, registry, workflowId, secretKeys, options).catch(async (err) => {
15404
+ await failRunOnUnreadableReplay(runId, err);
15405
+ return { outcome: "failed", successors: [] };
15406
+ })));
15381
15407
  const nextBatch = new Map;
15382
15408
  let hasWaiting = false;
15383
15409
  for (let i = 0;i < results.length; i++) {
@@ -15591,6 +15617,11 @@ async function executeStep(def, runId, ctx, node, registry, workflowId, secretKe
15591
15617
  }
15592
15618
  try {
15593
15619
  return await runClaimedStep(def, runId, ctx, node, registry, dedup.existingStep, dedup.stepId, workflowId, options);
15620
+ } catch (err) {
15621
+ if (await failRunOnUnreadableReplay(runId, err, dedup.stepId)) {
15622
+ return { outcome: "failed", successors: [] };
15623
+ }
15624
+ throw err;
15594
15625
  } finally {
15595
15626
  executingSteps.delete(dedup.stepId);
15596
15627
  }
@@ -15878,7 +15909,7 @@ function timeoutPromise(ms) {
15878
15909
  init_event_bus();
15879
15910
 
15880
15911
  // src/workflows/recovery.ts
15881
- init_db();
15912
+ init_db2();
15882
15913
 
15883
15914
  // src/workflows/approval-resolution.ts
15884
15915
  function shapeApprovalResolution(registry, definition, nodeId, parkedOutput, approval) {
@@ -15902,7 +15933,7 @@ function shapeApprovalResolution(registry, definition, nodeId, parkedOutput, app
15902
15933
  var FAILED_TASK_OUTPUT_PREFIX = "[FAILED:";
15903
15934
 
15904
15935
  // src/workflows/resume.ts
15905
- init_db();
15936
+ init_db2();
15906
15937
  init_secret_scrubber();
15907
15938
  init_event_bus();
15908
15939
 
@@ -16183,7 +16214,7 @@ function computeNextPort(mode, status) {
16183
16214
  }
16184
16215
 
16185
16216
  // src/workflows/task-step-routing.ts
16186
- init_db();
16217
+ init_db2();
16187
16218
  init_types();
16188
16219
  async function isTaskBoundToStep(taskId, stepId) {
16189
16220
  const task = await getTaskById(taskId);
@@ -16337,7 +16368,18 @@ function setupWorkflowResumeListener(eventBus, registry) {
16337
16368
  eventBus.off("approval.resolved", onApprovalResolved);
16338
16369
  };
16339
16370
  }
16371
+ async function failClosedOnUnreadableReplay(runId, stepId, resume) {
16372
+ try {
16373
+ await resume();
16374
+ } catch (err) {
16375
+ if (!await failRunOnUnreadableReplay(runId, err, stepId))
16376
+ throw err;
16377
+ }
16378
+ }
16340
16379
  async function resumeFromTaskCompletion(event, registry) {
16380
+ await failClosedOnUnreadableReplay(event.workflowRunId, event.workflowRunStepId, () => resumeFromTaskCompletionUnguarded(event, registry));
16381
+ }
16382
+ async function resumeFromTaskCompletionUnguarded(event, registry) {
16341
16383
  const run = await getWorkflowRun(event.workflowRunId);
16342
16384
  if (!run || run.status !== "waiting" && run.status !== "running")
16343
16385
  return;
@@ -16392,6 +16434,9 @@ async function finalizeOrWait(runId) {
16392
16434
  });
16393
16435
  }
16394
16436
  async function handleTaskFailure(event, reason, registry, options) {
16437
+ await failClosedOnUnreadableReplay(event.workflowRunId, event.workflowRunStepId, () => handleTaskFailureUnguarded(event, reason, registry, options));
16438
+ }
16439
+ async function handleTaskFailureUnguarded(event, reason, registry, options) {
16395
16440
  const run = await getWorkflowRun(event.workflowRunId);
16396
16441
  if (!run || run.status !== "waiting" && run.status !== "running")
16397
16442
  return;
@@ -16534,6 +16579,9 @@ async function cancelWorkflowRun(runId, reason) {
16534
16579
  await postApprovalCancellationUpdates(cancelledApprovals, applied ? cancelReason : latestRun?.error ?? cancelReason);
16535
16580
  }
16536
16581
  async function resumeFromApprovalResolution(event, registry) {
16582
+ await failClosedOnUnreadableReplay(event.workflowRunId, event.workflowRunStepId, () => resumeFromApprovalResolutionUnguarded(event, registry));
16583
+ }
16584
+ async function resumeFromApprovalResolutionUnguarded(event, registry) {
16537
16585
  const run = await getWorkflowRun(event.workflowRunId);
16538
16586
  if (!run || run.status !== "waiting" && run.status !== "running")
16539
16587
  return;
@@ -16543,11 +16591,11 @@ async function resumeFromApprovalResolution(event, registry) {
16543
16591
  const workflow = await getWorkflow(run.workflowId);
16544
16592
  if (!workflow)
16545
16593
  return;
16546
- const ctx = run.context ?? {};
16547
16594
  if (event.status === "cancelled") {
16548
16595
  console.warn(`[workflows] approval ${event.requestId} is cancelled; step ${event.workflowRunStepId} stays waiting for the run cancel path`);
16549
16596
  return;
16550
16597
  }
16598
+ const ctx = run.context ?? {};
16551
16599
  const { output: stepOutput, nextPort } = shapeApprovalResolution(registry, workflow.definition, step.nodeId, step.output, { requestId: event.requestId, status: event.status, responses: event.responses });
16552
16600
  const routing = await checkpointPortStepAndResolveSuccessors(workflow.definition, run.id, step.id, step.nodeId, stepOutput, nextPort, ctx);
16553
16601
  if (!routing.claimed)
@@ -16566,6 +16614,9 @@ async function resumeWaitState(waitId, status, payload, registry) {
16566
16614
  if (!result.updated || !result.row)
16567
16615
  return;
16568
16616
  const waitRow = result.row;
16617
+ await failClosedOnUnreadableReplay(waitRow.workflowRunId, waitRow.workflowRunStepId, () => resumeClaimedWait(waitRow, status, cappedPayload, registry));
16618
+ }
16619
+ async function resumeClaimedWait(waitRow, status, cappedPayload, registry) {
16569
16620
  const run = await getWorkflowRun(waitRow.workflowRunId);
16570
16621
  if (!run || run.status !== "waiting" && run.status !== "running")
16571
16622
  return;
@@ -16750,6 +16801,8 @@ async function recoverRunningRuns(registry) {
16750
16801
  }
16751
16802
  recovered++;
16752
16803
  } catch (err) {
16804
+ if (await failRunOnUnreadableReplay(runId, err))
16805
+ continue;
16753
16806
  console.error(`[workflows] Failed to recover running run ${runId}:`, err);
16754
16807
  }
16755
16808
  }
@@ -16835,6 +16888,8 @@ async function recoverWaitingRuns(registry) {
16835
16888
  }
16836
16889
  recovered++;
16837
16890
  } catch (err) {
16891
+ if (await failRunOnUnreadableReplay(stuck.runId, err))
16892
+ continue;
16838
16893
  console.error(`[workflows] Failed to recover waiting run ${stuck.runId}:`, err);
16839
16894
  }
16840
16895
  }
@@ -16889,6 +16944,8 @@ async function recoverApprovalWaitingRuns(registry) {
16889
16944
  }
16890
16945
  recovered++;
16891
16946
  } catch (err) {
16947
+ if (await failRunOnUnreadableReplay(stuck.runId, err))
16948
+ continue;
16892
16949
  console.error(`[workflows] Failed to recover approval-waiting run ${stuck.runId}:`, err);
16893
16950
  }
16894
16951
  }
@@ -16912,6 +16969,8 @@ async function recoverWaitStates(registry) {
16912
16969
  await resumeWaitState(stuck.waitId, resumeStatus, payload, registry);
16913
16970
  recovered++;
16914
16971
  } catch (err) {
16972
+ if (await failRunOnUnreadableReplay(stuck.runId, err))
16973
+ continue;
16915
16974
  console.error(`[workflows] Failed to recover wait-state ${stuck.waitId}:`, err);
16916
16975
  }
16917
16976
  }
@@ -16929,7 +16988,7 @@ async function getRunIdsByStatus(status) {
16929
16988
  return rows.map((r) => r.id);
16930
16989
  }
16931
16990
  // src/workflows/retry-poller.ts
16932
- init_db();
16991
+ init_db2();
16933
16992
  var pollerTimeout = null;
16934
16993
  function startRetryPoller(registry, intervalMs = 5000) {
16935
16994
  if (pollerTimeout !== null)
@@ -17018,11 +17077,15 @@ function startRetryPoller(registry, intervalMs = 5000) {
17018
17077
  }
17019
17078
  }
17020
17079
  } catch (err) {
17080
+ if (await failRunOnUnreadableReplay(run.id, err, step.id))
17081
+ continue;
17021
17082
  const errorMsg = err instanceof Error ? err.message : String(err);
17022
17083
  const retryPolicy = node.retry || executor.retryPolicy;
17023
17084
  await checkpointStepFailure(run.id, step.id, errorMsg, step.retryCount, retryPolicy);
17024
17085
  }
17025
17086
  } catch (err) {
17087
+ if (await failRunOnUnreadableReplay(step.runId, err, step.id))
17088
+ continue;
17026
17089
  console.error(`[workflows] Retry failed for step ${step.id}:`, err);
17027
17090
  } finally {
17028
17091
  release?.();
@@ -17130,7 +17193,7 @@ function replaceStringPlaceholders(template, variables) {
17130
17193
  });
17131
17194
  }
17132
17195
  // src/workflows/triggers.ts
17133
- init_db();
17196
+ init_db2();
17134
17197
  import crypto2 from "node:crypto";
17135
17198
  var DEFAULT_HMAC_HEADER = "X-Hub-Signature-256";
17136
17199
  var FALLBACK_HMAC_HEADERS = ["x-hub-signature-256", "x-signature", "x-webhook-signature"];
@@ -17398,7 +17461,7 @@ class WebhookError extends Error {
17398
17461
  }
17399
17462
  }
17400
17463
  // src/workflows/version.ts
17401
- init_db();
17464
+ init_db2();
17402
17465
  async function snapshotWorkflow(workflowId, changedByAgentId) {
17403
17466
  const workflow = await getWorkflow(workflowId);
17404
17467
  if (!workflow) {
@@ -17444,7 +17507,7 @@ async function snapshotAndUpdateWorkflow(workflowId, updates, opts = {}) {
17444
17507
  });
17445
17508
  }
17446
17509
  // src/workflows/wait-poller.ts
17447
- init_db();
17510
+ init_db2();
17448
17511
  var pollerTimeout2 = null;
17449
17512
  function startWaitPoller(registry, intervalMs = 5000) {
17450
17513
  if (pollerTimeout2 !== null)
@@ -17475,7 +17538,7 @@ function stopWaitPoller() {
17475
17538
  }
17476
17539
 
17477
17540
  // src/workflows/index.ts
17478
- init_db();
17541
+ init_db2();
17479
17542
  init_secret_scrubber();
17480
17543
  init_event_bus();
17481
17544
 
@@ -17487,18 +17550,18 @@ init_zod();
17487
17550
 
17488
17551
  // src/be/model-validation.ts
17489
17552
  init_src();
17490
- init_db();
17553
+ init_db2();
17491
17554
 
17492
17555
  // src/be/model-tier-resolution.ts
17493
17556
  init_src();
17494
17557
  init_zod();
17495
17558
  init_types();
17496
- init_db();
17559
+ init_db2();
17497
17560
 
17498
17561
  // src/be/harness-model-support.ts
17499
17562
  init_src();
17500
17563
  init_secret_scrubber();
17501
- init_db();
17564
+ init_db2();
17502
17565
  var CLI_PINNED_HARNESSES = new Set(["claude", "codex"]);
17503
17566
  async function getHarnessModelSupport(harness, cliVersion, modelId) {
17504
17567
  const row = await getDbClient().get("SELECT status FROM harness_model_support WHERE harness = ? AND cliVersion = ? AND modelId = ?", [harness, cliVersion, modelId]);
@@ -17741,7 +17804,7 @@ function harnessMismatchReason(model, harness) {
17741
17804
  }
17742
17805
  async function resolveTaskModel(input) {
17743
17806
  const harness = input.harnessProvider ?? null;
17744
- const judged = harness !== null && harnessCatalogSection(harness) !== null;
17807
+ const judged = harness !== null && isHarnessModelJudged(harness);
17745
17808
  const sections = judged ? (await loadResolutionCatalog()).catalog : {};
17746
17809
  for (const candidate of taskModelCandidates(input)) {
17747
17810
  let resolution = null;
@@ -18006,19 +18069,20 @@ ${issues.join(`
18006
18069
 
18007
18070
  // src/scheduler/scheduler.ts
18008
18071
  var import_cron_parser = __toESM(require_dist2(), 1);
18072
+ init_db2();
18009
18073
  init_db();
18010
18074
  init_telemetry();
18011
18075
 
18012
18076
  // src/scheduler/deferred-task-waits.ts
18013
- init_db();
18077
+ init_db2();
18014
18078
  init_event_bus();
18015
18079
 
18016
18080
  // src/scheduler/schedule-task.ts
18017
- init_db();
18081
+ init_db2();
18018
18082
  init_context_key();
18019
18083
 
18020
18084
  // src/tasks/sibling-awareness.ts
18021
- init_db();
18085
+ init_db2();
18022
18086
 
18023
18087
  // src/tasks/errors.ts
18024
18088
  class TaskCreationBlockedError extends Error {
@@ -18778,7 +18842,9 @@ async function runScheduleNow(scheduleId) {
18778
18842
  }
18779
18843
 
18780
18844
  // src/be/extensions/assets.ts
18845
+ init_db2();
18781
18846
  init_db();
18847
+ init_embeddings();
18782
18848
 
18783
18849
  // src/be/skill-parser.ts
18784
18850
  function parseSkillContent(content) {
@@ -19437,7 +19503,7 @@ async function removeAssets(extensionId) {
19437
19503
  }
19438
19504
 
19439
19505
  // src/be/extensions/db.ts
19440
- init_db();
19506
+ init_db2();
19441
19507
 
19442
19508
  class ExtensionOwnershipError extends Error {
19443
19509
  }
@@ -24242,7 +24308,7 @@ var EMPTY_COMPLETION_RESULT = {
24242
24308
 
24243
24309
  // src/server.ts
24244
24310
  init_package();
24245
- init_db();
24311
+ init_db2();
24246
24312
  init_steering();
24247
24313
 
24248
24314
  // src/github/task-reactions.ts
@@ -24253,14 +24319,14 @@ init_secret_scrubber();
24253
24319
  init_secret_scrubber();
24254
24320
 
24255
24321
  // src/github/app.ts
24322
+ init_env_flag();
24256
24323
  var initialized = false;
24257
24324
  var webhookSecret = null;
24258
24325
  var appId = null;
24259
24326
  var privateKey = null;
24260
24327
  var tokenCache = new Map;
24261
24328
  function isGitHubEnabled() {
24262
- const githubDisable = process.env.GITHUB_DISABLE;
24263
- if (githubDisable === "true" || githubDisable === "1") {
24329
+ if (isEnvFlagEnabled("GITHUB_DISABLE", false)) {
24264
24330
  return false;
24265
24331
  }
24266
24332
  return !!process.env.GITHUB_WEBHOOK_SECRET;
@@ -24278,8 +24344,7 @@ function initGitHub() {
24278
24344
  return isGitHubEnabled();
24279
24345
  }
24280
24346
  initialized = true;
24281
- const githubDisable = process.env.GITHUB_DISABLE;
24282
- if (githubDisable === "true" || githubDisable === "1") {
24347
+ if (isEnvFlagEnabled("GITHUB_DISABLE", false)) {
24283
24348
  console.log("[GitHub] Disabled via GITHUB_DISABLE");
24284
24349
  return false;
24285
24350
  }
@@ -24547,12 +24612,12 @@ function registerGithubTaskReactions() {
24547
24612
  }
24548
24613
 
24549
24614
  // src/agentmail/app.ts
24615
+ init_env_flag();
24550
24616
  var import_svix = __toESM(require_dist5(), 1);
24551
24617
  var initialized2 = false;
24552
24618
  var webhookSecret2 = null;
24553
24619
  function isAgentMailEnabled() {
24554
- const disabled = process.env.AGENTMAIL_DISABLE;
24555
- if (disabled === "true" || disabled === "1") {
24620
+ if (isEnvFlagEnabled("AGENTMAIL_DISABLE", false)) {
24556
24621
  return false;
24557
24622
  }
24558
24623
  return !!process.env.AGENTMAIL_WEBHOOK_SECRET;
@@ -24567,8 +24632,8 @@ function initAgentMail() {
24567
24632
  return isAgentMailEnabled();
24568
24633
  }
24569
24634
  initialized2 = true;
24570
- const disabled = process.env.AGENTMAIL_DISABLE;
24571
- if (disabled === "true" || disabled === "1") {
24635
+ const disabled = isEnvFlagEnabled("AGENTMAIL_DISABLE", false);
24636
+ if (disabled) {
24572
24637
  console.log("[AgentMail] Disabled via AGENTMAIL_DISABLE");
24573
24638
  return false;
24574
24639
  }
@@ -24595,11 +24660,11 @@ function verifyAgentMailWebhook(rawBody, headers) {
24595
24660
  }
24596
24661
  }
24597
24662
  // src/agentmail/handlers.ts
24598
- init_db();
24663
+ init_db2();
24599
24664
 
24600
24665
  // src/be/users.ts
24601
24666
  init_telemetry_identity();
24602
- init_db();
24667
+ init_db2();
24603
24668
  import { createHash, randomBytes, randomUUID } from "node:crypto";
24604
24669
  function actorString(actor) {
24605
24670
  return `${actor.kind}:${actor.id}`;
@@ -24777,7 +24842,7 @@ function base62(bytes) {
24777
24842
  function sha256Hex(input) {
24778
24843
  return createHash("sha256").update(input).digest("hex");
24779
24844
  }
24780
- async function mintToken(userId, label, actor) {
24845
+ async function mintToken(userId, label, actor, options = {}) {
24781
24846
  const plaintext = `${TOKEN_PREFIX}${base62(randomBytes(24))}`;
24782
24847
  const tokenId = randomUUID().replace(/-/g, "");
24783
24848
  const hash = sha256Hex(plaintext);
@@ -24786,7 +24851,12 @@ async function mintToken(userId, label, actor) {
24786
24851
  await getDbClient().transaction(async (tx) => {
24787
24852
  await tx.run(`INSERT INTO user_tokens (id, userId, label, tokenHash, tokenPreview, createdAt)
24788
24853
  VALUES (?, ?, ?, ?, ?, ?)`, [tokenId, userId, label, hash, preview, now]);
24789
- await recordIdentityEvent(userId, "token_minted", actor, null, { tokenId, label, preview });
24854
+ await recordIdentityEvent(userId, "token_minted", actor, null, {
24855
+ tokenId,
24856
+ label,
24857
+ preview,
24858
+ ...options.source ? { source: options.source } : {}
24859
+ });
24790
24860
  });
24791
24861
  return { tokenId, plaintext };
24792
24862
  }
@@ -24971,7 +25041,7 @@ function envEnabled(flag) {
24971
25041
  return process.env[flag] === "true";
24972
25042
  }
24973
25043
  function createIngressBuffer(opts) {
24974
- const enabled2 = envEnabled(opts.envFlag);
25044
+ const enabled = envEnabled(opts.envFlag);
24975
25045
  const timeoutMs = opts.timeoutMs ?? 1e4;
24976
25046
  const buffer = createAdditiveBuffer({
24977
25047
  timeoutMs,
@@ -24981,9 +25051,9 @@ function createIngressBuffer(opts) {
24981
25051
  }
24982
25052
  });
24983
25053
  return {
24984
- enabled: enabled2,
25054
+ enabled,
24985
25055
  maybeBuffer(contextKey, siblingInFlight, payload) {
24986
- if (!enabled2)
25056
+ if (!enabled)
24987
25057
  return false;
24988
25058
  if (!contextKey)
24989
25059
  return false;
@@ -25511,7 +25581,7 @@ async function likeAzureDevOpsComment(ref, threadId, commentId) {
25511
25581
  }
25512
25582
  }
25513
25583
  // src/azure-devops/handlers.ts
25514
- init_db();
25584
+ init_db2();
25515
25585
  init_resolver();
25516
25586
  init_context_key();
25517
25587
 
@@ -25905,10 +25975,10 @@ _Note: There's an active task (${existingTask.id}) for this PR #${pr.pullRequest
25905
25975
  return { created: true, taskId: task.id };
25906
25976
  }
25907
25977
  // src/http/core.ts
25908
- init_db();
25978
+ init_db2();
25909
25979
 
25910
25980
  // src/be/multi-runtime.ts
25911
- init_db();
25981
+ init_db2();
25912
25982
  var AGENT_MAX_TASKS_CONFIG_KEY = "AGENT_MAX_TASKS";
25913
25983
  function parseAgentMaxTasksValue(raw) {
25914
25984
  const str = raw.trim();
@@ -26091,7 +26161,7 @@ async function expireStaleRuntimeInstances() {
26091
26161
 
26092
26162
  // src/be/rbac-audit.ts
26093
26163
  init_env_flag();
26094
- init_db();
26164
+ init_db2();
26095
26165
  import { AsyncLocalStorage } from "node:async_hooks";
26096
26166
  var FLUSH_INTERVAL_MS = 2000;
26097
26167
  var FLUSH_MAX_ROWS = 200;
@@ -26112,6 +26182,7 @@ function principalIdOf(principal) {
26112
26182
  case "user":
26113
26183
  return principal.userId;
26114
26184
  case "operator":
26185
+ case "guest":
26115
26186
  return null;
26116
26187
  }
26117
26188
  }
@@ -26275,7 +26346,7 @@ function stopAuditGc() {
26275
26346
  // src/http/core.ts
26276
26347
  init_rbac_roles();
26277
26348
  // src/github/handlers.ts
26278
- init_db();
26349
+ init_db2();
26279
26350
  init_resolver();
26280
26351
  init_context_key();
26281
26352
 
@@ -27625,7 +27696,7 @@ function resetGitLab() {
27625
27696
  gitlabUrl = "https://gitlab.com";
27626
27697
  }
27627
27698
  // src/gitlab/handlers.ts
27628
- init_db();
27699
+ init_db2();
27629
27700
  init_resolver();
27630
27701
  init_context_key();
27631
27702
 
@@ -28228,11 +28299,13 @@ function extractMentions(adf) {
28228
28299
  return ids;
28229
28300
  }
28230
28301
  // src/jira/app.ts
28302
+ init_oauth();
28231
28303
  init_constants();
28304
+ init_env_flag();
28232
28305
 
28233
28306
  // src/be/db-queries/tracker.ts
28234
28307
  init_date_utils();
28235
- init_db();
28308
+ init_db2();
28236
28309
  function normalizeTrackerSync(row) {
28237
28310
  return {
28238
28311
  ...row,
@@ -28376,8 +28449,12 @@ async function createTrackerAgentMapping(data) {
28376
28449
  init_secret_scrubber();
28377
28450
  init_event_bus();
28378
28451
 
28452
+ // src/jira/client.ts
28453
+ init_oauth();
28454
+
28379
28455
  // src/jira/metadata.ts
28380
- init_db();
28456
+ init_db2();
28457
+ init_oauth();
28381
28458
  async function getJiraMetadata() {
28382
28459
  const app = await getOAuthApp("jira");
28383
28460
  if (!app)
@@ -28670,10 +28747,11 @@ Original issue: {{issue_key}} — {{issue_summary}}`,
28670
28747
  });
28671
28748
 
28672
28749
  // src/jira/sync.ts
28673
- init_db();
28750
+ init_db2();
28751
+ init_oauth();
28674
28752
 
28675
28753
  // src/be/unmapped-identities.ts
28676
- init_db();
28754
+ init_db2();
28677
28755
  var TTL_MS = 30 * 24 * 60 * 60 * 1000;
28678
28756
  function namespace(kind) {
28679
28757
  return `integration:unmapped:${kind}`;
@@ -29092,7 +29170,7 @@ async function notifySlack(text) {
29092
29170
  return;
29093
29171
  }
29094
29172
  try {
29095
- const { getSlackApp: getSlackApp2 } = await import("./app-w2d26h4f.js");
29173
+ const { getSlackApp: getSlackApp2 } = await import("./app-43vrdmv8.js");
29096
29174
  const app = getSlackApp2();
29097
29175
  if (!app) {
29098
29176
  console.warn("[Jira webhook keepalive] Slack not available, cannot send notification");
@@ -29163,7 +29241,7 @@ async function deleteJiraWebhook(webhookId) {
29163
29241
  console.log(`[Jira webhook keepalive] Deleted webhook id=${webhookId}`);
29164
29242
  }
29165
29243
  async function overwriteWebhookIds(next) {
29166
- const { getDbClient: getDbClient2 } = await import("./db-01g8wtvw.js");
29244
+ const { getDbClient: getDbClient2 } = await import("./db-sjks418k.js");
29167
29245
  await getDbClient2().transaction(async (tx) => {
29168
29246
  const row = await tx.get("SELECT metadata FROM oauth_apps WHERE provider = 'jira'");
29169
29247
  if (!row) {
@@ -29272,11 +29350,10 @@ function stopJiraWebhookKeepalive() {
29272
29350
  // src/jira/app.ts
29273
29351
  var initialized5 = false;
29274
29352
  function isJiraEnabled() {
29275
- const disabled = process.env.JIRA_DISABLE;
29276
- if (disabled === "true" || disabled === "1")
29353
+ if (isEnvFlagEnabled("JIRA_DISABLE", false))
29277
29354
  return false;
29278
- const enabled2 = process.env.JIRA_ENABLED;
29279
- if (enabled2 === "false" || enabled2 === "0")
29355
+ const enabled = process.env.JIRA_ENABLED;
29356
+ if (enabled === "false" || enabled === "0")
29280
29357
  return false;
29281
29358
  return !!process.env.JIRA_CLIENT_ID;
29282
29359
  }
@@ -29404,7 +29481,9 @@ async function dispatchAndRecord(event, body, deliveryId) {
29404
29481
  }
29405
29482
  }
29406
29483
  // src/linear/app.ts
29484
+ init_oauth();
29407
29485
  init_constants();
29486
+ init_env_flag();
29408
29487
 
29409
29488
  // node_modules/@linear/sdk/dist/chunk-DPPnyiuk.mjs
29410
29489
  var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
@@ -100881,6 +100960,7 @@ var LinearClient = class extends LinearSdk {
100881
100960
  };
100882
100961
 
100883
100962
  // src/linear/client.ts
100963
+ init_oauth();
100884
100964
  var linearClient = null;
100885
100965
  async function getLinearClient() {
100886
100966
  const tokens = await getOAuthTokens("linear");
@@ -100900,7 +100980,8 @@ init_secret_scrubber();
100900
100980
  init_event_bus();
100901
100981
 
100902
100982
  // src/linear/sync.ts
100903
- init_db();
100983
+ init_db2();
100984
+ init_oauth();
100904
100985
  init_resolver();
100905
100986
  init_context_key();
100906
100987
  init_types();
@@ -101833,11 +101914,10 @@ function shouldSkipForLoopPrevention2(sync) {
101833
101914
  var initialized6 = false;
101834
101915
  var unsubscribeRefresh = null;
101835
101916
  function isLinearEnabled() {
101836
- const disabled = process.env.LINEAR_DISABLE;
101837
- if (disabled === "true" || disabled === "1")
101917
+ if (isEnvFlagEnabled("LINEAR_DISABLE", false))
101838
101918
  return false;
101839
- const enabled2 = process.env.LINEAR_ENABLED;
101840
- if (enabled2 === "false" || enabled2 === "0")
101919
+ const enabled = process.env.LINEAR_ENABLED;
101920
+ if (enabled === "false" || enabled === "0")
101841
101921
  return false;
101842
101922
  return !!process.env.LINEAR_CLIENT_ID;
101843
101923
  }
@@ -102051,7 +102131,7 @@ async function getFileInfo(client, fileId) {
102051
102131
  }
102052
102132
  }
102053
102133
  // src/slack/router.ts
102054
- init_db();
102134
+ init_db2();
102055
102135
  init_env_flag();
102056
102136
  function hasOtherUserMention(text, botUserId) {
102057
102137
  const mentions = text.match(/<@([A-Z0-9]+)>/g) ?? [];
@@ -102116,7 +102196,7 @@ init_request_auth_context();
102116
102196
  init_secret_scrubber();
102117
102197
 
102118
102198
  // src/http/auth.ts
102119
- init_db();
102199
+ init_db2();
102120
102200
 
102121
102201
  // src/utils/page-session.ts
102122
102202
  import { createHmac, randomBytes as randomBytes2, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
@@ -102239,6 +102319,8 @@ async function verifyPageSession(token) {
102239
102319
  return null;
102240
102320
  }
102241
102321
  const candidate = payload;
102322
+ if (candidate.op !== undefined && candidate.op !== true)
102323
+ return null;
102242
102324
  if (candidate.uid !== undefined && typeof candidate.uid !== "string")
102243
102325
  return null;
102244
102326
  if (candidate.name !== undefined && typeof candidate.name !== "string")
@@ -102271,7 +102353,8 @@ async function issuePageSessionCookie(pageId, opts) {
102271
102353
  pageId,
102272
102354
  exp,
102273
102355
  ...opts.uid ? { uid: opts.uid } : {},
102274
- ...opts.name ? { name: opts.name } : {}
102356
+ ...opts.name ? { name: opts.name } : {},
102357
+ ...opts.op ? { op: true } : {}
102275
102358
  });
102276
102359
  const attrs = [
102277
102360
  `page_session=${token}`,
@@ -102324,7 +102407,10 @@ async function resolveHttpRequestAuth(req, apiKey) {
102324
102407
  return null;
102325
102408
  return { kind: "user", userId: user.id, user, page };
102326
102409
  }
102327
- return { kind: "operator", fingerprint: fingerprintApiKey(bearer), page };
102410
+ if (payload.op) {
102411
+ return { kind: "operator", fingerprint: fingerprintApiKey(bearer), page };
102412
+ }
102413
+ return { kind: "guest", page };
102328
102414
  }
102329
102415
  return { kind: "operator", fingerprint: fingerprintApiKey(bearer) };
102330
102416
  }
@@ -102356,7 +102442,7 @@ init_zod();
102356
102442
  init_secret_scrubber();
102357
102443
 
102358
102444
  // src/http/utils.ts
102359
- init_db();
102445
+ init_db2();
102360
102446
  init_env_flag();
102361
102447
  init_secret_scrubber();
102362
102448
  var DEFAULT_ALLOWED_ORIGINS = [
@@ -102960,7 +103046,7 @@ async function reloadGlobalConfigsAndIntegrations() {
102960
103046
  return runWithoutRequestAuth(() => reloadGlobalConfigsAndIntegrationsInner());
102961
103047
  }
102962
103048
  async function reloadGlobalConfigsAndIntegrationsInner() {
102963
- const { getEmbeddingProvider: getEmbeddingProvider2, resetEmbeddingProvider } = await import("./index-c4aqcyz1.js");
103049
+ const { getEmbeddingProvider: getEmbeddingProvider2, resetEmbeddingProvider } = await import("./index-9b65j1m5.js");
102964
103050
  const wasEmbeddingsConfigured = getEmbeddingProvider2().isConfigured();
102965
103051
  const updated = await loadGlobalConfigsIntoEnv(true);
102966
103052
  await stopSlackApp();
@@ -102973,10 +103059,10 @@ async function reloadGlobalConfigsAndIntegrationsInner() {
102973
103059
  integrations.push("embeddings");
102974
103060
  }
102975
103061
  if (!wasEmbeddingsConfigured && isEmbeddingsConfigured) {
102976
- import("./boot-reembed-6rhcpsjf.js").then(({ runBootReembed }) => runBootReembed()).catch((err) => {
103062
+ import("./boot-reembed-s7k7c6v2.js").then(({ runBootReembed }) => runBootReembed()).catch((err) => {
102977
103063
  console.error("[config-reload] memory backfill failed (non-fatal):", err);
102978
103064
  });
102979
- import("./boot-reembed-k1q2s4fc.js").then(({ runBootReembedScripts }) => runBootReembedScripts()).catch((err) => {
103065
+ import("./boot-reembed-998jtpdg.js").then(({ runBootReembedScripts }) => runBootReembedScripts()).catch((err) => {
102980
103066
  console.error("[config-reload] script backfill failed (non-fatal):", err);
102981
103067
  });
102982
103068
  }
@@ -103307,14 +103393,14 @@ init_config();
103307
103393
 
103308
103394
  // src/tools/accept-steer.ts
103309
103395
  init_zod();
103310
- init_db();
103396
+ init_db2();
103311
103397
 
103312
103398
  // src/tools/task-tool-ctx.ts
103313
103399
  init_rbac();
103314
103400
 
103315
103401
  // src/tools/utils.ts
103316
103402
  init_zod();
103317
- init_db();
103403
+ init_db2();
103318
103404
 
103319
103405
  // src/kv-overflow.ts
103320
103406
  var MCP_OVERFLOW_NAMESPACE = "mcp:overflow";
@@ -103331,6 +103417,234 @@ function mcpOverflowAuthError(namespace2, agentId) {
103331
103417
  return "access to another agent's MCP overflow namespace is forbidden";
103332
103418
  }
103333
103419
 
103420
+ // src/kv-view.ts
103421
+ var KV_PATH_MAX_CHARS = 1024;
103422
+ var KV_SHAPE_PATH_BUDGET_BYTES = 2048;
103423
+ function pathBytes(path2) {
103424
+ return Buffer.byteLength(JSON.stringify(path2), "utf8");
103425
+ }
103426
+ function hasKvViewArgs(args) {
103427
+ return args.path !== undefined || args.offset !== undefined || args.limit !== undefined;
103428
+ }
103429
+ function kvViewType(value) {
103430
+ if (value === null || value === undefined)
103431
+ return "null";
103432
+ if (Array.isArray(value))
103433
+ return "array";
103434
+ switch (typeof value) {
103435
+ case "object":
103436
+ return "object";
103437
+ case "string":
103438
+ return "string";
103439
+ case "number":
103440
+ case "bigint":
103441
+ return "number";
103442
+ case "boolean":
103443
+ return "boolean";
103444
+ default:
103445
+ return "null";
103446
+ }
103447
+ }
103448
+ function kvViewRoot(value) {
103449
+ if (typeof value !== "string")
103450
+ return { root: value, json: true };
103451
+ try {
103452
+ const parsed = JSON.parse(value);
103453
+ if (parsed !== null && typeof parsed === "object")
103454
+ return { root: parsed, json: true };
103455
+ } catch {}
103456
+ return { root: value, json: false };
103457
+ }
103458
+ function itemCount(value) {
103459
+ if (Array.isArray(value))
103460
+ return value.length;
103461
+ if (typeof value === "string")
103462
+ return value.length;
103463
+ if (value !== null && typeof value === "object")
103464
+ return Object.keys(value).length;
103465
+ return;
103466
+ }
103467
+ function splitKvPath(path2) {
103468
+ const segments = [];
103469
+ let current = "";
103470
+ for (let i = 0;i < path2.length; i++) {
103471
+ const char = path2[i];
103472
+ if (char === "\\" && i + 1 < path2.length) {
103473
+ current += path2[++i];
103474
+ } else if (char === ".") {
103475
+ segments.push(current);
103476
+ current = "";
103477
+ } else {
103478
+ current += char;
103479
+ }
103480
+ }
103481
+ segments.push(current);
103482
+ return segments;
103483
+ }
103484
+ function joinKvPath(segments) {
103485
+ return segments.map((key) => key.replace(/[\\.]/g, "\\$&")).join(".");
103486
+ }
103487
+ function resolvePath(root, path2) {
103488
+ if (path2 === "")
103489
+ return { ok: true, value: root };
103490
+ const segments = splitKvPath(path2);
103491
+ if (segments.some((segment) => segment === "")) {
103492
+ return {
103493
+ ok: false,
103494
+ error: `path "${path2}" has an empty segment; use dot paths like "data.rows"`
103495
+ };
103496
+ }
103497
+ let current = root;
103498
+ for (let i = 0;i < segments.length; i++) {
103499
+ const segment = segments[i];
103500
+ const at = joinKvPath(segments.slice(0, i)) || "(root)";
103501
+ if (Array.isArray(current)) {
103502
+ const index = /^\d+$/.test(segment) ? Number(segment) : Number.NaN;
103503
+ if (!(index < current.length)) {
103504
+ return {
103505
+ ok: false,
103506
+ error: `path "${path2}" not found: "${at}" is an array of ${current.length}; "${segment}" is not a valid index`
103507
+ };
103508
+ }
103509
+ current = current[index];
103510
+ } else if (current !== null && typeof current === "object") {
103511
+ if (!Object.hasOwn(current, segment)) {
103512
+ return { ok: false, error: `path "${path2}" not found: no key "${segment}" under "${at}"` };
103513
+ }
103514
+ current = current[segment];
103515
+ } else {
103516
+ return {
103517
+ ok: false,
103518
+ error: `path "${path2}" not found: "${at}" is a ${kvViewType(current)}, it has no "${segment}"`
103519
+ };
103520
+ }
103521
+ }
103522
+ return { ok: true, value: current };
103523
+ }
103524
+ function resolveKvTarget(value, path2) {
103525
+ const { root, json: json2 } = kvViewRoot(value);
103526
+ if (path2 !== "" && !json2) {
103527
+ return {
103528
+ ok: false,
103529
+ error: `path "${path2}" needs a JSON value; this entry is a plain string (use offset/limit alone to page its characters)`
103530
+ };
103531
+ }
103532
+ return resolvePath(root, path2);
103533
+ }
103534
+ function sliceKvTarget(target, offset, limit) {
103535
+ const total = itemCount(target);
103536
+ if (total === undefined)
103537
+ return;
103538
+ const start = Math.min(offset, total);
103539
+ const end = limit === undefined ? total : Math.min(total, start + limit);
103540
+ let value;
103541
+ let returned = end - start;
103542
+ if (Array.isArray(target)) {
103543
+ value = target.slice(start, end);
103544
+ } else if (typeof target === "string") {
103545
+ const lastCode = target.charCodeAt(end - 1);
103546
+ const splitsPair = end > start && end < total && lastCode >= 55296 && lastCode <= 56319;
103547
+ const safeEnd = splitsPair ? end - 1 > start ? end - 1 : end + 1 : end;
103548
+ value = target.slice(start, safeEnd);
103549
+ returned = safeEnd - start;
103550
+ } else {
103551
+ value = Object.fromEntries(Object.entries(target).slice(start, end));
103552
+ }
103553
+ const reached = start + returned;
103554
+ return { value, total, returned, nextOffset: reached < total ? reached : null };
103555
+ }
103556
+ function resolveKvView(value, args) {
103557
+ const path2 = args.path ?? "";
103558
+ const resolved = resolveKvTarget(value, path2);
103559
+ if (!resolved.ok)
103560
+ return resolved;
103561
+ const type = kvViewType(resolved.value);
103562
+ const offset = args.offset ?? 0;
103563
+ const sliced = sliceKvTarget(resolved.value, offset, args.limit);
103564
+ if (!sliced) {
103565
+ if (args.offset !== undefined || args.limit !== undefined) {
103566
+ return {
103567
+ ok: false,
103568
+ error: `offset/limit page arrays, objects, and strings; "${path2 || "(root)"}" is a ${type}`
103569
+ };
103570
+ }
103571
+ return { ok: true, value: resolved.value, view: { path: path2, type } };
103572
+ }
103573
+ return {
103574
+ ok: true,
103575
+ value: sliced.value,
103576
+ view: {
103577
+ path: path2,
103578
+ type,
103579
+ total: sliced.total,
103580
+ offset,
103581
+ returned: sliced.returned,
103582
+ nextOffset: sliced.nextOffset
103583
+ }
103584
+ };
103585
+ }
103586
+ function shapeEntry(segments, value, ancestors) {
103587
+ const items = itemCount(value);
103588
+ return {
103589
+ path: joinKvPath(segments),
103590
+ type: kvViewType(value),
103591
+ bytes: Buffer.byteLength(JSON.stringify(value) ?? "", "utf8"),
103592
+ ...items !== undefined ? { items } : {},
103593
+ value,
103594
+ segments,
103595
+ ancestors
103596
+ };
103597
+ }
103598
+ function childEntries(node) {
103599
+ const { value, segments, ancestors } = node;
103600
+ if (value === null || typeof value !== "object" || Array.isArray(value))
103601
+ return [];
103602
+ return Object.entries(value).map(([key, child]) => shapeEntry([...segments, key], child, [...ancestors, value]));
103603
+ }
103604
+ function addressable(node, budget) {
103605
+ for (let depth = node.segments.length;depth > 0; depth--) {
103606
+ const segments = node.segments.slice(0, depth);
103607
+ if (segments.includes(""))
103608
+ continue;
103609
+ const path2 = joinKvPath(segments);
103610
+ if (path2.length > KV_PATH_MAX_CHARS || pathBytes(path2) > budget)
103611
+ continue;
103612
+ if (depth === node.segments.length)
103613
+ return node;
103614
+ return shapeEntry(segments, node.ancestors[depth], node.ancestors.slice(0, depth));
103615
+ }
103616
+ return shapeEntry([], node.ancestors[0] ?? node.value, []);
103617
+ }
103618
+ function summarizeKvShape(root, maxEntries = 8, maxPathBytes = KV_SHAPE_PATH_BUDGET_BYTES) {
103619
+ const rootBytes = Buffer.byteLength(JSON.stringify(root) ?? "", "utf8");
103620
+ let entries = childEntries({ value: root, segments: [], ancestors: [] });
103621
+ for (let step = 0;step < 8; step++) {
103622
+ const candidate = entries.filter((entry) => entry.type === "object" && (entry.items ?? 0) > 0).sort((a, b) => b.bytes - a.bytes)[0];
103623
+ if (!candidate || candidate.bytes * 4 < rootBytes)
103624
+ break;
103625
+ entries = entries.filter((entry) => entry !== candidate).concat(childEntries(candidate));
103626
+ }
103627
+ const sorted = entries.sort((a, b) => b.bytes - a.bytes);
103628
+ const significant = sorted.filter((entry) => entry.bytes * 100 >= rootBytes);
103629
+ const shape = [];
103630
+ let budget = maxPathBytes;
103631
+ for (const entry of significant.length > 0 ? significant : sorted) {
103632
+ if (shape.length >= maxEntries)
103633
+ break;
103634
+ const {
103635
+ value: _value,
103636
+ segments: _segments,
103637
+ ancestors: _ancestors,
103638
+ ...node
103639
+ } = addressable(entry, budget);
103640
+ if (shape.some((seen) => seen.path === node.path))
103641
+ continue;
103642
+ shape.push(node);
103643
+ budget -= pathBytes(node.path);
103644
+ }
103645
+ return shape;
103646
+ }
103647
+
103334
103648
  // src/tools/utils.ts
103335
103649
  init_secret_scrubber();
103336
103650
  var scriptSdkRequestOrigins = new WeakSet;
@@ -103413,7 +103727,13 @@ var swarmToolTruncationSchema = looseObject({
103413
103727
  fullValueAt: string(),
103414
103728
  originalBytes: number(),
103415
103729
  limitBytes: number(),
103416
- retrieval: string()
103730
+ retrieval: string(),
103731
+ shape: array(looseObject({
103732
+ path: string().optional(),
103733
+ type: string().optional(),
103734
+ bytes: number().optional(),
103735
+ items: number().optional()
103736
+ })).optional()
103417
103737
  });
103418
103738
  var swarmToolEnvelopeShape = {
103419
103739
  success: boolean(),
@@ -103521,12 +103841,12 @@ var NUDGES = {
103521
103841
  if (!entry)
103522
103842
  return;
103523
103843
  const rendered = typeof entry.value === "string" ? entry.value : JSON.stringify(entry.value) ?? "";
103524
- return rendered.length > MCP_RESULT_WIRE_LIMIT_BYTES ? "Large value — your harness may truncate this result; to filter or aggregate it, process it in a script via ctx.swarm.kv_get instead." : undefined;
103844
+ return rendered.length > MCP_RESULT_WIRE_LIMIT_BYTES ? "Large value — your harness may truncate this result; re-call kv-get with path/offset/limit for a bounded slice, or process it in a script via ctx.swarm.kv_get." : undefined;
103525
103845
  }
103526
103846
  };
103527
103847
  var MCP_RESULT_WIRE_LIMIT_BYTES = 1e4;
103528
103848
  var MCP_OVERFLOW_TTL_MS = 24 * 60 * 60 * 1000;
103529
- var MCP_PROSE_PREVIEW_CHARS = 1200;
103849
+ var MCP_PROSE_PREVIEW_FLOOR_CHARS = 1200;
103530
103850
  var scrubMiddleware = (result) => result.allowSecretEgress ? result : scrubObject(result);
103531
103851
  var nudgeMiddleware = (result, ctx) => {
103532
103852
  if (result.nudge)
@@ -103537,7 +103857,12 @@ var nudgeMiddleware = (result, ctx) => {
103537
103857
  function composeWireResult(r) {
103538
103858
  const normalizedDetails = r.details?.trim() || undefined;
103539
103859
  const dataFallback = !normalizedDetails && r.data && Object.keys(r.data).length > 0 ? JSON.stringify(r.data, null, 2) : undefined;
103540
- const text = [r.message, r.nudge, normalizedDetails ?? dataFallback].filter((part) => Boolean(part?.trim())).join(`
103860
+ const text = [
103861
+ r.message,
103862
+ r.nudge,
103863
+ normalizedDetails ?? dataFallback,
103864
+ r.truncation ? renderTruncationPointer(r.truncation) : undefined
103865
+ ].filter((part) => Boolean(part?.trim())).join(`
103541
103866
 
103542
103867
  `);
103543
103868
  const structuredContent = {
@@ -103545,7 +103870,7 @@ function composeWireResult(r) {
103545
103870
  success: r.ok,
103546
103871
  message: r.message
103547
103872
  };
103548
- if (normalizedDetails)
103873
+ if (normalizedDetails && !r.omitStructuredDetails)
103549
103874
  structuredContent.details = normalizedDetails;
103550
103875
  if (r.nudge)
103551
103876
  structuredContent.nudge = r.nudge;
@@ -103557,13 +103882,65 @@ function composeWireResult(r) {
103557
103882
  isError: !r.ok
103558
103883
  };
103559
103884
  }
103885
+ function renderTruncationPointer(t) {
103886
+ const shape = t.shape?.length ? `
103887
+ Shape: ${renderShape(t.shape)}` : "";
103888
+ return `Full value: ${t.fullValueAt} (${t.originalBytes} bytes)${shape}
103889
+ Retrieval: ${t.retrieval}`;
103890
+ }
103891
+ function wireChannelBytes(wire) {
103892
+ const text = (wire.content ?? []).map((block) => block.type === "text" ? block.text ?? "" : "").join("");
103893
+ return Math.max(Buffer.byteLength(text, "utf8"), Buffer.byteLength(JSON.stringify(wire.structuredContent ?? {}), "utf8"));
103894
+ }
103895
+ function swarmToolResultBytes(r) {
103896
+ return wireChannelBytes(composeWireResult(r));
103897
+ }
103898
+ function fitsWireLimit(r) {
103899
+ return swarmToolResultBytes(r) <= MCP_RESULT_WIRE_LIMIT_BYTES;
103900
+ }
103901
+ function safePrefix(source, chars) {
103902
+ const end = Math.min(chars, source.length);
103903
+ const code = source.charCodeAt(end - 1);
103904
+ return code >= 55296 && code <= 56319 ? source.slice(0, end - 1) : source.slice(0, end);
103905
+ }
103906
+ function previewWithMarker(source, chars) {
103907
+ const preview = safePrefix(source, chars);
103908
+ const omitted = source.length - preview.length;
103909
+ return omitted > 0 ? `${preview}
103910
+ … [truncated ${omitted} chars]` : preview;
103911
+ }
103912
+ function fillPreviewToBudget(source, render) {
103913
+ let low = 0;
103914
+ let high = source.length;
103915
+ while (low < high) {
103916
+ const mid = Math.ceil((low + high) / 2);
103917
+ if (fitsWireLimit(render(previewWithMarker(source, mid))))
103918
+ low = mid;
103919
+ else
103920
+ high = mid - 1;
103921
+ }
103922
+ return render(previewWithMarker(source, low));
103923
+ }
103560
103924
  function overflowKey(toolName, value) {
103561
103925
  const safeToolName = toolName.replace(/[^a-zA-Z0-9._-]/g, "-").slice(0, 80);
103562
103926
  const hash = new Bun.CryptoHasher("sha256").update(value).digest("hex");
103563
103927
  return `v1/${safeToolName}/${hash}`;
103564
103928
  }
103565
- function overflowRetrieval(namespace2, key) {
103566
- return `kv-get(${JSON.stringify({ namespace: namespace2, key })}) returns the full value ` + `(your harness may truncate it); to filter or aggregate it instead, ` + `process it in a script via ctx.swarm.kv_get.`;
103929
+ function overflowRetrieval(namespace2, key, shape) {
103930
+ const target = shape.find((entry) => entry.type === "array") ?? shape.find((entry) => entry.type === "object" || entry.type === "string") ?? (shape[0] && { path: joinKvPath(splitKvPath(shape[0].path).slice(0, -1)) });
103931
+ if (!target) {
103932
+ return `kv-get(${JSON.stringify({ namespace: namespace2, key })}) returns the full value ` + `(your harness may truncate it); in a script, ctx.swarm.kv_get keeps it out of your context.`;
103933
+ }
103934
+ return `kv-get(${JSON.stringify({ namespace: namespace2, key, path: target.path, offset: 0 })}) returns a ` + `bounded page (nextOffset pages on; any Shape path works; no path = the full value). ` + `ctx.swarm.kv_get takes the same args in a script.`;
103935
+ }
103936
+ function formatBytes(bytes) {
103937
+ return bytes >= 1024 ? `${(bytes / 1024).toFixed(1)}KB` : `${bytes}B`;
103938
+ }
103939
+ function renderShape(shape) {
103940
+ return shape.map((entry) => {
103941
+ const count = entry.items === undefined ? "" : entry.type === "array" ? `[${entry.items}]` : entry.type === "object" ? `{${entry.items} keys}` : ` ${entry.items} chars`;
103942
+ return `${entry.path} ${entry.type}${count} ${formatBytes(entry.bytes)}`;
103943
+ }).join("; ");
103567
103944
  }
103568
103945
  function canonicalOverflowPayload(toolName, result) {
103569
103946
  const safe = result.allowSecretEgress ? scrubObject(result) : result;
@@ -103644,23 +104021,20 @@ function arrayTruncationMessage(message, targets) {
103644
104021
  return message;
103645
104022
  return `${message} Returned ${summaries.join(", ")} in this bounded response.`;
103646
104023
  }
103647
- function arrayPreservingOverflowResult(result, data, targets, truncation, pointer) {
103648
- const normalizedDetails = result.details?.trim() || undefined;
103649
- const details = normalizedDetails ? `${normalizedDetails.slice(0, MCP_PROSE_PREVIEW_CHARS)}
103650
- … [truncated ${Math.max(normalizedDetails.length - MCP_PROSE_PREVIEW_CHARS, 0)} chars]
103651
- ${pointer}` : `JSON payload truncated in place:
103652
- ${JSON.stringify(data, null, 2)}
103653
- ${pointer}`;
104024
+ function arrayPreservingOverflowResult(result, data, targets, truncation, detailsPreview) {
104025
+ const details = detailsPreview ?? `JSON payload truncated in place:
104026
+ ${JSON.stringify(data, null, 2)}`;
103654
104027
  return {
103655
104028
  ok: result.ok,
103656
104029
  message: arrayTruncationMessage(result.message, targets),
103657
104030
  details,
103658
104031
  data,
103659
104032
  nudge: result.nudge,
103660
- truncation
104033
+ truncation,
104034
+ omitStructuredDetails: true
103661
104035
  };
103662
104036
  }
103663
- function truncateArraysInPlace(result, truncation, pointer) {
104037
+ function truncateArraysInPlace(result, truncation) {
103664
104038
  if (!result.data)
103665
104039
  return;
103666
104040
  const data = cloneResultData(result.data);
@@ -103669,8 +104043,11 @@ function truncateArraysInPlace(result, truncation, pointer) {
103669
104043
  if (targets.length === 0)
103670
104044
  return;
103671
104045
  targets.sort((a, b) => Buffer.byteLength(JSON.stringify(b.originalItems), "utf8") - Buffer.byteLength(JSON.stringify(a.originalItems), "utf8"));
103672
- const render = () => arrayPreservingOverflowResult(result, data, targets, truncation, pointer);
103673
- const fits = () => Buffer.byteLength(JSON.stringify(composeWireResult(render())), "utf8") <= MCP_RESULT_WIRE_LIMIT_BYTES;
104046
+ const prose = result.details?.trim() || undefined;
104047
+ const renderWith = (preview) => arrayPreservingOverflowResult(result, data, targets, truncation, preview);
104048
+ const render = () => renderWith(prose ? previewWithMarker(prose, MCP_PROSE_PREVIEW_FLOOR_CHARS) : undefined);
104049
+ const fits = () => fitsWireLimit(render());
104050
+ const finish = () => prose ? fillPreviewToBudget(prose, renderWith) : render();
103674
104051
  for (const target of targets) {
103675
104052
  setArrayLength(target, 0);
103676
104053
  if (!fits())
@@ -103686,10 +104063,10 @@ function truncateArraysInPlace(result, truncation, pointer) {
103686
104063
  high = mid - 1;
103687
104064
  }
103688
104065
  setArrayLength(target, low);
103689
- return render();
104066
+ return finish();
103690
104067
  }
103691
104068
  if (fits())
103692
- return render();
104069
+ return finish();
103693
104070
  pruneBranchesWithoutArrays(data);
103694
104071
  if (!fits())
103695
104072
  return;
@@ -103706,27 +104083,31 @@ function truncateArraysInPlace(result, truncation, pointer) {
103706
104083
  }
103707
104084
  setArrayLength(target, low);
103708
104085
  }
103709
- return render();
104086
+ return finish();
103710
104087
  }
103711
104088
  var ctxControlMiddleware = async (result, ctx) => {
103712
104089
  if (ctx.callOrigin === "script-sdk" || ctx.callOrigin === "extension")
103713
104090
  return result;
103714
104091
  if (CTX_CONTROL_EXEMPT_TOOLS.has(ctx.toolName))
103715
104092
  return result;
103716
- const fullWire = composeWireResult(result);
103717
- const fullWireJson = JSON.stringify(fullWire);
103718
- const fullWireBytes = Buffer.byteLength(fullWireJson, "utf8");
104093
+ const fullWireBytes = swarmToolResultBytes(result);
103719
104094
  if (fullWireBytes <= MCP_RESULT_WIRE_LIMIT_BYTES) {
103720
104095
  return result;
103721
104096
  }
104097
+ if (result.details?.trim() && result.data && Object.keys(result.data).length > 0) {
104098
+ const deduped = { ...result, omitStructuredDetails: true };
104099
+ if (fitsWireLimit(deduped))
104100
+ return deduped;
104101
+ }
104102
+ const storedValue = canonicalOverflowPayload(ctx.toolName, result);
104103
+ const shape = summarizeKvShape(JSON.parse(storedValue));
103722
104104
  let fullValueAt;
103723
104105
  let retrieval;
103724
104106
  if (ctx.agentId) {
103725
- const storedValue = canonicalOverflowPayload(ctx.toolName, result);
103726
104107
  const key = overflowKey(ctx.toolName, storedValue);
103727
104108
  const namespace2 = mcpOverflowNamespace(ctx.agentId);
103728
104109
  fullValueAt = `kv://${namespace2}/${key}`;
103729
- retrieval = overflowRetrieval(namespace2, key);
104110
+ retrieval = overflowRetrieval(namespace2, key, shape);
103730
104111
  const expiresAt = Date.now() + MCP_OVERFLOW_TTL_MS;
103731
104112
  await sweepExpiredKvPrefix(MCP_OVERFLOW_NAMESPACE);
103732
104113
  await upsertKv({
@@ -103745,26 +104126,27 @@ var ctxControlMiddleware = async (result, ctx) => {
103745
104126
  fullValueAt,
103746
104127
  originalBytes: fullWireBytes,
103747
104128
  limitBytes: MCP_RESULT_WIRE_LIMIT_BYTES,
103748
- retrieval
104129
+ retrieval,
104130
+ ...shape.length > 0 ? { shape } : {}
103749
104131
  };
103750
- const pointer = `Full value: ${fullValueAt}
103751
- Retrieval: ${retrieval}
103752
- ` + `Truncation: ${JSON.stringify(truncation)}`;
103753
- const arrayPreservingResult = truncateArraysInPlace(result, truncation, pointer);
104132
+ const arrayPreservingResult = truncateArraysInPlace(result, truncation);
103754
104133
  if (arrayPreservingResult)
103755
104134
  return arrayPreservingResult;
103756
- const normalizedDetails = result.details?.trim() || undefined;
103757
- const details = normalizedDetails ? `${normalizedDetails.slice(0, MCP_PROSE_PREVIEW_CHARS)}
103758
- … [truncated ${Math.max(normalizedDetails.length - MCP_PROSE_PREVIEW_CHARS, 0)} chars]
103759
- ${pointer}` : `JSON payload omitted because the composed result exceeded ${MCP_RESULT_WIRE_LIMIT_BYTES} bytes.
103760
- ${pointer}`;
103761
- return {
104135
+ const spilled = (details) => ({
103762
104136
  ok: result.ok,
103763
104137
  message: result.message,
103764
104138
  details,
103765
104139
  nudge: result.nudge,
103766
104140
  truncation
103767
- };
104141
+ });
104142
+ const prose = result.details?.trim() || undefined;
104143
+ if (prose)
104144
+ return fillPreviewToBudget(prose, spilled);
104145
+ const json2 = result.data ? JSON.stringify(result.data, null, 2) : "";
104146
+ if (!json2)
104147
+ return spilled("Payload omitted.");
104148
+ return fillPreviewToBudget(json2, (preview) => spilled(`JSON payload head:
104149
+ ${preview}`));
103768
104150
  };
103769
104151
  var FINALIZE_PIPELINE = [
103770
104152
  scrubMiddleware,
@@ -103798,7 +104180,7 @@ function setPreloadedTools(server, names) {
103798
104180
  async function applyPreToolCall(name, args, requestInfo, inputSchema) {
103799
104181
  if (requestInfo.callOrigin !== "mcp")
103800
104182
  return { args };
103801
- const dispatcher = await import("./dispatcher-nn2k1wxd.js");
104183
+ const dispatcher = await import("./dispatcher-1es759rn.js");
103802
104184
  const result = await dispatcher.dispatchPre("pre.tool.call", { tool: name, args, requestInfo }, inputSchema ? {
103803
104185
  validateModify: async (data) => {
103804
104186
  const schema = normalizeObjectSchema(inputSchema) ?? inputSchema;
@@ -104012,15 +104394,15 @@ var registerAcceptSteerTool = (server) => {
104012
104394
  init_zod();
104013
104395
 
104014
104396
  // src/apps/version.ts
104015
- init_db();
104397
+ init_db2();
104016
104398
 
104017
104399
  // src/apps/schema-migrate.ts
104018
104400
  init_zod();
104019
- init_db();
104401
+ init_db2();
104020
104402
  init_secret_scrubber();
104021
104403
 
104022
104404
  // src/apps/row-store.ts
104023
- init_db();
104405
+ init_db2();
104024
104406
  init_db_client();
104025
104407
  class AppRowValidationError extends Error {
104026
104408
  issues;
@@ -104399,6 +104781,7 @@ function purgeAppRows(appId2, models, afterPurge) {
104399
104781
 
104400
104782
  // src/apps/sync.ts
104401
104783
  init_zod();
104784
+ init_db2();
104402
104785
  init_db();
104403
104786
  init_types();
104404
104787
  init_secret_scrubber();
@@ -105809,12 +106192,12 @@ async function rollbackApp(input) {
105809
106192
  }
105810
106193
 
105811
106194
  // src/tools/app-diff.ts
105812
- init_db();
106195
+ init_db2();
105813
106196
  init_rbac();
105814
106197
 
105815
106198
  // src/tools/context-diff.ts
105816
106199
  init_zod();
105817
- init_db();
106200
+ init_db2();
105818
106201
  init_rbac();
105819
106202
  import { tmpdir } from "node:os";
105820
106203
  import { join } from "node:path";
@@ -105996,13 +106379,13 @@ var registerAppDiffTool = (server) => {
105996
106379
 
105997
106380
  // src/tools/app-get.ts
105998
106381
  init_zod();
105999
- init_db();
106382
+ init_db2();
106000
106383
 
106001
106384
  // src/http/apps.ts
106002
106385
  init_zod();
106003
106386
 
106004
106387
  // src/apps/user-config.ts
106005
- init_db();
106388
+ init_db2();
106006
106389
  var USER_CONFIG_THEME_KEY = "$theme";
106007
106390
  var RESERVED_KEY_PATTERNS = {
106008
106391
  [USER_CONFIG_THEME_KEY]: /^[a-z][a-z0-9-]{0,39}$/
@@ -106084,6 +106467,7 @@ async function upsertAppUserConfigValues(appId2, scope, values) {
106084
106467
 
106085
106468
  // src/http/apps.ts
106086
106469
  init_key();
106470
+ init_db2();
106087
106471
  init_db();
106088
106472
  init_resolver();
106089
106473
  init_rbac();
@@ -106093,7 +106477,7 @@ init_secret_scrubber();
106093
106477
 
106094
106478
  // src/be/audit-user.ts
106095
106479
  init_request_auth_context();
106096
- init_db();
106480
+ init_db2();
106097
106481
  async function resolveTaskAuditUserId(sourceTaskId, callerAgentId) {
106098
106482
  if (!callerAgentId)
106099
106483
  return null;
@@ -106635,6 +107019,9 @@ async function authorizeApp(req, res, myAgentId, verb, resource) {
106635
107019
  } else if (auth?.kind === "user") {
106636
107020
  principal = { kind: "user", userId: auth.userId };
106637
107021
  actor = `user:${auth.userId}`;
107022
+ } else if (auth?.kind === "guest") {
107023
+ principal = { kind: "guest" };
107024
+ actor = "guest";
106638
107025
  } else {
106639
107026
  const agent = myAgentId ? await getAgentById(myAgentId) : null;
106640
107027
  principal = { kind: "agent", agentId: myAgentId ?? "", isLead: agent?.isLead ?? false };
@@ -107641,7 +108028,7 @@ var registerAppQueryTool = (server) => {
107641
108028
 
107642
108029
  // src/tools/app-history.ts
107643
108030
  init_zod();
107644
- init_db();
108031
+ init_db2();
107645
108032
  init_rbac();
107646
108033
  function escapeTableCell2(value) {
107647
108034
  return String(value ?? "—").replaceAll("\\", "\\\\").replaceAll("|", "\\|").replace(/\r\n|\r|\n/g, "<br>");
@@ -107746,7 +108133,7 @@ var registerAppListTool = (server) => {
107746
108133
 
107747
108134
  // src/tools/app-patch.ts
107748
108135
  init_zod();
107749
- init_db();
108136
+ init_db2();
107750
108137
  init_rbac();
107751
108138
  var registerAppPatchTool = (server) => {
107752
108139
  createToolRegistrar(server)("app-patch", {
@@ -107867,7 +108254,7 @@ var registerAppPatchTool = (server) => {
107867
108254
  };
107868
108255
  // src/tools/app-rollback.ts
107869
108256
  init_zod();
107870
- init_db();
108257
+ init_db2();
107871
108258
  init_rbac();
107872
108259
  var registerAppRollbackTool = (server) => {
107873
108260
  createToolRegistrar(server)("app-rollback", {
@@ -107947,7 +108334,7 @@ var registerAppRollbackTool = (server) => {
107947
108334
 
107948
108335
  // src/tools/app-sync.ts
107949
108336
  init_zod();
107950
- init_db();
108337
+ init_db2();
107951
108338
  init_rbac();
107952
108339
  function cell(value) {
107953
108340
  return String(value ?? "—").replaceAll("\\", "\\\\").replaceAll("|", "\\|").replace(/\r\n|\r|\n/g, "<br>");
@@ -108034,7 +108421,7 @@ var registerAppSyncTool = (server) => {
108034
108421
 
108035
108422
  // src/tools/app-upsert.ts
108036
108423
  init_zod();
108037
- init_db();
108424
+ init_db2();
108038
108425
  init_rbac();
108039
108426
  var registerAppUpsertTool = (server) => {
108040
108427
  createToolRegistrar(server)("app-upsert", {
@@ -108178,10 +108565,10 @@ var registerAppUpsertTool = (server) => {
108178
108565
 
108179
108566
  // src/tools/cancel-approval-request.ts
108180
108567
  init_zod();
108181
- init_db();
108568
+ init_db2();
108182
108569
 
108183
108570
  // src/workflows/approval-cancel.ts
108184
- init_db();
108571
+ init_db2();
108185
108572
  init_rbac();
108186
108573
  var LIVE_RUN_STATUSES = new Set(["running", "waiting"]);
108187
108574
  async function cancelApprovalRequest(input) {
@@ -108321,12 +108708,12 @@ var registerCancelApprovalRequestTool = (server) => {
108321
108708
 
108322
108709
  // src/tools/cancel-task.ts
108323
108710
  init_zod();
108324
- init_db();
108711
+ init_db2();
108325
108712
  init_rbac();
108326
108713
 
108327
108714
  // src/tools/get-task-details.ts
108328
108715
  init_zod();
108329
- init_db();
108716
+ init_db2();
108330
108717
  init_types();
108331
108718
 
108332
108719
  // src/utils/requester-comms.ts
@@ -108639,7 +109026,7 @@ var registerCancelTaskTool = (server) => {
108639
109026
 
108640
109027
  // src/tools/context-history.ts
108641
109028
  init_zod();
108642
- init_db();
109029
+ init_db2();
108643
109030
  init_rbac();
108644
109031
  var registerContextHistoryTool = (server) => {
108645
109032
  createToolRegistrar(server)("context-history", {
@@ -108715,7 +109102,7 @@ var registerContextHistoryTool = (server) => {
108715
109102
 
108716
109103
  // src/tools/create-channel.ts
108717
109104
  init_zod();
108718
- init_db();
109105
+ init_db2();
108719
109106
  init_types();
108720
109107
  var ChannelOutputSchema = looseObject({
108721
109108
  id: string().optional(),
@@ -108772,16 +109159,17 @@ var registerCreateChannelTool = (server) => {
108772
109159
 
108773
109160
  // src/tools/create-metric.ts
108774
109161
  init_zod();
108775
- init_db();
109162
+ init_db2();
108776
109163
 
108777
109164
  // src/http/db-query.ts
108778
109165
  init_zod();
109166
+ init_secret_scrubber();
108779
109167
 
108780
109168
  // src/http/db-query-bounded.ts
108781
- init_db();
109169
+ init_db2();
108782
109170
 
108783
109171
  // src/http/db-query-shared.ts
108784
- init_db();
109172
+ init_db2();
108785
109173
  init_env_flag();
108786
109174
  import { Database } from "bun:sqlite";
108787
109175
  class DbQueryTimeoutError extends Error {
@@ -108806,19 +109194,91 @@ function assertSingleStatement(sql) {
108806
109194
  throw new Error("Only one SQL statement is allowed");
108807
109195
  }
108808
109196
  }
108809
- function executeReadOnlyQuery(sql, params = [], maxRows) {
108810
- assertSingleStatement(sql);
109197
+ var DB_QUERY_DENIED_TABLES = new Set([
109198
+ "oauth_authorizations",
109199
+ "oauth_apps",
109200
+ "oauth_pending",
109201
+ "user_tokens",
109202
+ "session_tokens",
109203
+ "script_apis",
109204
+ "codex_oauth_device_flows"
109205
+ ]);
109206
+
109207
+ class DbQueryDeniedTableError extends Error {
109208
+ tables;
109209
+ constructor(tables) {
109210
+ super(`db-query cannot read ${tables.join(", ")}: ${tables.length === 1 ? "this table holds" : "these tables hold"} credentials. ` + "Use the dedicated OAuth, token or config tools instead.");
109211
+ this.tables = tables;
109212
+ this.name = "DbQueryDeniedTableError";
109213
+ }
109214
+ }
109215
+ var CURSOR_OPEN_OPCODES = new Set(["OpenRead", "ReopenIdx", "OpenWrite"]);
109216
+ function openReadOnlyReader() {
108811
109217
  const database = getDb();
108812
109218
  const reader = !database.filename || database.filename === ":memory:" ? Database.deserialize(database.serialize(), { readonly: true }) : new Database(database.filename, { readonly: true });
109219
+ const vecExtensionPath = resolveSqliteVecExtensionPath();
109220
+ if (vecExtensionPath) {
109221
+ try {
109222
+ reader.loadExtension(vecExtensionPath);
109223
+ } catch {}
109224
+ }
109225
+ return reader;
109226
+ }
109227
+ function assertNoDeniedTables(sql, reader) {
109228
+ const statement = stripTrailingSemicolon(sql);
109229
+ if (/^explain\b/i.test(stripLeadingComments(statement)))
109230
+ return;
109231
+ const db = reader ?? openReadOnlyReader();
108813
109232
  try {
108814
109233
  let __stack = [];
108815
109234
  try {
108816
- const vecExtensionPath = resolveSqliteVecExtensionPath();
108817
- if (vecExtensionPath) {
108818
- try {
108819
- reader.loadExtension(vecExtensionPath);
108820
- } catch {}
109235
+ const rootPages = new Map;
109236
+ for (const row of db.query("SELECT rootpage, tbl_name FROM main.sqlite_master WHERE rootpage > 0").all()) {
109237
+ rootPages.set(row.rootpage, row.tbl_name.toLowerCase());
109238
+ }
109239
+ const program = __using(__stack, db.prepare(`EXPLAIN ${statement}`), 0);
109240
+ const denied = new Set;
109241
+ for (const op of program.all()) {
109242
+ if (!CURSOR_OPEN_OPCODES.has(op.opcode) || op.p3 !== 0)
109243
+ continue;
109244
+ const table = rootPages.get(op.p2);
109245
+ if (table && DB_QUERY_DENIED_TABLES.has(table))
109246
+ denied.add(table);
108821
109247
  }
109248
+ if (denied.size > 0)
109249
+ throw new DbQueryDeniedTableError([...denied].sort());
109250
+ } catch (_catch) {
109251
+ var _err = _catch, _hasErr = 1;
109252
+ } finally {
109253
+ __callDispose(__stack, _err, _hasErr);
109254
+ }
109255
+ } finally {
109256
+ if (!reader)
109257
+ db.close();
109258
+ }
109259
+ }
109260
+ function stripLeadingComments(sql) {
109261
+ let rest = sql.trimStart();
109262
+ for (;; ) {
109263
+ if (rest.startsWith("--")) {
109264
+ const end = rest.indexOf(`
109265
+ `);
109266
+ rest = end === -1 ? "" : rest.slice(end + 1).trimStart();
109267
+ } else if (rest.startsWith("/*")) {
109268
+ const end = rest.indexOf("*/");
109269
+ rest = end === -1 ? "" : rest.slice(end + 2).trimStart();
109270
+ } else {
109271
+ return rest;
109272
+ }
109273
+ }
109274
+ }
109275
+ function executeReadOnlyQuery(sql, params = [], maxRows) {
109276
+ assertSingleStatement(sql);
109277
+ const reader = openReadOnlyReader();
109278
+ try {
109279
+ let __stack = [];
109280
+ try {
109281
+ assertNoDeniedTables(sql, reader);
108822
109282
  const stmt = __using(__stack, reader.prepare(sql), 0);
108823
109283
  if (stmt.columnNames.length === 0) {
108824
109284
  throw new Error("Only read-only queries are allowed");
@@ -108967,6 +109427,7 @@ function releaseBoundedQuerySlot() {
108967
109427
  }
108968
109428
  async function executeReadOnlyQueryBounded(sql, params = [], budgetMs, maxRows) {
108969
109429
  assertSingleStatement(sql);
109430
+ assertNoDeniedTables(sql);
108970
109431
  acquireBoundedQuerySlot();
108971
109432
  try {
108972
109433
  return await runBoundedQueryChild(sql, params, budgetMs, maxRows);
@@ -109090,7 +109551,9 @@ var dbQueryRoute = route({
109090
109551
  rowLimit: exports_external.number().nullable()
109091
109552
  })
109092
109553
  },
109093
- 400: { description: "Invalid or disallowed SQL" },
109554
+ 400: {
109555
+ description: "Invalid or disallowed SQL, including queries that read credential tables"
109556
+ },
109094
109557
  408: { description: "Query exceeded its wall-clock budget and was terminated" },
109095
109558
  429: { description: "Too many concurrent bounded db-query executions; retry shortly" }
109096
109559
  },
@@ -109105,7 +109568,7 @@ async function handleDbQuery(req, res, pathSegments, queryParams) {
109105
109568
  return true;
109106
109569
  try {
109107
109570
  const result = await executeReadOnlyQueryGated(resolveDbQuerySql(parsed.body), parsed.body.params, getDbQueryHttpBudgetMs(), getDbQueryHttpMaxRows());
109108
- dbQueryRoute.respond(res, 200, result);
109571
+ dbQueryRoute.respond(res, 200, scrubObject(result));
109109
109572
  } catch (err) {
109110
109573
  if (err instanceof DbQueryConcurrencyCapError) {
109111
109574
  res.setHeader("Retry-After", "1");
@@ -109123,7 +109586,7 @@ async function handleDbQuery(req, res, pathSegments, queryParams) {
109123
109586
  }
109124
109587
 
109125
109588
  // src/metrics/version.ts
109126
- init_db();
109589
+ init_db2();
109127
109590
  async function snapshotMetric(metricId, changedByAgentId) {
109128
109591
  const metric = await getMetric(metricId);
109129
109592
  if (!metric) {
@@ -109273,10 +109736,10 @@ async function authorizeAssetKeyWrite(input, trustedUserId) {
109273
109736
  }
109274
109737
 
109275
109738
  // src/tools/create-page.ts
109276
- init_db();
109739
+ init_db2();
109277
109740
 
109278
109741
  // src/pages/version.ts
109279
- init_db();
109742
+ init_db2();
109280
109743
  async function snapshotPage(pageId, changedByAgentId) {
109281
109744
  const page = await getPage(pageId);
109282
109745
  if (!page) {
@@ -109436,7 +109899,8 @@ var registerCreatePageTool = (server) => {
109436
109899
 
109437
109900
  // src/tools/credential-bindings/tool.ts
109438
109901
  init_zod();
109439
- init_db();
109902
+ init_db2();
109903
+ init_oauth();
109440
109904
 
109441
109905
  // src/oauth/app-validation.ts
109442
109906
  function assertOAuthAppUrlsSafe(input) {
@@ -109991,7 +110455,7 @@ var DbQueryToolInputSchema = object({
109991
110455
  var registerDbQueryTool = (server) => {
109992
110456
  createToolRegistrar(server)("db-query", {
109993
110457
  title: "Execute database query",
109994
- description: "Execute a read-only SQL query against the swarm database (SQLite). Available to all authenticated agents — be aware results may include secrets (oauth_tokens, configs). Runs in a short-lived child process with a wall-clock budget by default (fails gracefully with a timeout or a 429-style concurrency error rather than freezing); results capped at a default row count (operator-configurable via `DB_QUERY_MCP_MAX_ROWS`) regardless of how many the query matched. See the sql parameter's description for which tables are unsafe to read whole, and the db-query-guidance skill for config knobs.",
110458
+ description: "Execute a read-only SQL query against the swarm database (SQLite). Available to all authenticated agents. Queries that read credential tables (OAuth authorizations, apps and pending flows, user and session tokens, script API bearers, Codex device-login state) are rejected, and secret-shaped values in results are redacted. Runs in a short-lived child process with a wall-clock budget by default (fails gracefully with a timeout or a 429-style concurrency error rather than freezing); results capped at a default row count (operator-configurable via `DB_QUERY_MCP_MAX_ROWS`) regardless of how many the query matched. See the sql parameter's description for which tables are unsafe to read whole, and the db-query-guidance skill for config knobs.",
109995
110459
  annotations: { readOnlyHint: true },
109996
110460
  inputSchema: DbQueryToolInputSchema,
109997
110461
  outputSchema: swarmToolOutputSchema({
@@ -110031,13 +110495,14 @@ ${result.total} rows in ${result.elapsed}ms`;
110031
110495
 
110032
110496
  // src/tools/defer-task.ts
110033
110497
  init_zod();
110034
- init_db();
110498
+ init_db2();
110035
110499
 
110036
110500
  // src/tasks/task-terminal-effects.ts
110037
- init_db();
110501
+ init_db2();
110502
+ init_memory();
110038
110503
 
110039
110504
  // src/be/memory/raters/retrieval.ts
110040
- init_db();
110505
+ init_db2();
110041
110506
  function dedupeMemoryDocumentIds(memories) {
110042
110507
  const documents = new Map;
110043
110508
  for (const memory of memories) {
@@ -110188,7 +110653,7 @@ function getRaterWeightMultiplier(name) {
110188
110653
  }
110189
110654
 
110190
110655
  // src/be/memory/raters/store.ts
110191
- init_db();
110656
+ init_db2();
110192
110657
  class ExplicitSelfDuplicateError extends Error {
110193
110658
  event;
110194
110659
  constructor(message, event) {
@@ -110389,7 +110854,7 @@ var shouldPersistTaskCompletionMemory = shouldPersistAutomaticTaskMemory;
110389
110854
 
110390
110855
  // src/tasks/worker-follow-up.ts
110391
110856
  init_zod();
110392
- init_db();
110857
+ init_db2();
110393
110858
  init_resolver();
110394
110859
  init_types();
110395
110860
  init_env_flag();
@@ -110853,7 +111318,7 @@ ${taskContent}`,
110853
111318
  }
110854
111319
 
110855
111320
  // src/tasks/terminal-result-guard.ts
110856
- init_db();
111321
+ init_db2();
110857
111322
  init_types();
110858
111323
  init_secret_scrubber();
110859
111324
  function getTaskOutputValidationError(outputSchema, output) {
@@ -111210,7 +111675,7 @@ Deferred until ${nextRunAt} (schedule ${schedule.id}). Pending: ${note}${checksB
111210
111675
 
111211
111676
  // src/tools/delete-channel.ts
111212
111677
  init_zod();
111213
- init_db();
111678
+ init_db2();
111214
111679
  init_rbac();
111215
111680
  var GENERAL_CHANNEL_ID = "00000000-0000-4000-8000-000000000001";
111216
111681
  var registerDeleteChannelTool = (server) => {
@@ -111288,7 +111753,7 @@ var registerDeleteChannelTool = (server) => {
111288
111753
 
111289
111754
  // src/tools/delete-page.ts
111290
111755
  init_zod();
111291
- init_db();
111756
+ init_db2();
111292
111757
  init_rbac();
111293
111758
  var DeletedPageSchema = looseObject({
111294
111759
  id: string().optional(),
@@ -111813,7 +112278,7 @@ var registerExtensionListTool = (server) => {
111813
112278
 
111814
112279
  // src/tools/get-metrics.ts
111815
112280
  init_zod();
111816
- init_db();
112281
+ init_db2();
111817
112282
  var CountByStatusSchema = record(string(), number());
111818
112283
  var registerGetMetricsTool = (server) => {
111819
112284
  createToolRegistrar(server)("get-metrics", {
@@ -111856,7 +112321,7 @@ var registerGetMetricsTool = (server) => {
111856
112321
 
111857
112322
  // src/tools/get-swarm.ts
111858
112323
  init_zod();
111859
- init_db();
112324
+ init_db2();
111860
112325
  init_types();
111861
112326
  var agentOutputShape = looseObject({
111862
112327
  id: string().optional(),
@@ -111909,7 +112374,7 @@ var registerGetSwarmTool = (server) => {
111909
112374
 
111910
112375
  // src/tools/get-tasks.ts
111911
112376
  init_zod();
111912
- init_db();
112377
+ init_db2();
111913
112378
  init_types();
111914
112379
  var TaskSummarySchema = looseObject({
111915
112380
  id: string().optional(),
@@ -112067,7 +112532,8 @@ var registerGetTasksTool = (server) => {
112067
112532
 
112068
112533
  // src/tools/inject-learning.ts
112069
112534
  init_zod();
112070
- init_db();
112535
+ init_db2();
112536
+ init_memory();
112071
112537
  init_rbac();
112072
112538
  var LearningCategoryEnum = _enum([
112073
112539
  "mistake-pattern",
@@ -112124,7 +112590,7 @@ ${learning}`;
112124
112590
  });
112125
112591
  try {
112126
112592
  const provider = getEmbeddingProvider();
112127
- const embedding = await provider.embed(content);
112593
+ const embedding = await provider.embed(memory.content);
112128
112594
  if (embedding) {
112129
112595
  await store.updateEmbedding(memory.id, embedding, provider.name);
112130
112596
  }
@@ -112138,7 +112604,7 @@ ${learning}`;
112138
112604
 
112139
112605
  // src/tools/join-swarm.ts
112140
112606
  init_zod();
112141
- init_db();
112607
+ init_db2();
112142
112608
  init_defaults();
112143
112609
  init_types();
112144
112610
  var agentOutputShape2 = looseObject({
@@ -112244,11 +112710,11 @@ var registerJoinSwarmTool = (server) => {
112244
112710
 
112245
112711
  // src/tools/kv/kv-delete.ts
112246
112712
  init_zod();
112247
- init_db();
112713
+ init_db2();
112248
112714
  init_types();
112249
112715
 
112250
112716
  // src/tools/kv/kv-write-auth.ts
112251
- init_db();
112717
+ init_db2();
112252
112718
 
112253
112719
  // src/kv-reserved-namespaces.ts
112254
112720
  var RESERVED_FAMILIES = new Map([
@@ -112296,7 +112762,7 @@ async function kvWriteAuthError(namespace2, info, key) {
112296
112762
  }
112297
112763
 
112298
112764
  // src/tools/kv/resolve-namespace.ts
112299
- init_db();
112765
+ init_db2();
112300
112766
  init_context_key();
112301
112767
  async function resolveNamespace(explicit, info) {
112302
112768
  if (explicit && explicit.length > 0) {
@@ -112357,7 +112823,7 @@ var registerKvDeleteTool = (server) => {
112357
112823
  };
112358
112824
  // src/tools/kv/kv-get.ts
112359
112825
  init_zod();
112360
- init_db();
112826
+ init_db2();
112361
112827
  init_types();
112362
112828
 
112363
112829
  // src/tools/kv/kv-read-auth.ts
@@ -112380,21 +112846,89 @@ function renderKvEntry(entry) {
112380
112846
  const expiry = entry.expiresAt ? ` (expires ${new Date(entry.expiresAt).toISOString()})` : "";
112381
112847
  return `value (${entry.valueType}): ${valueText}${expiry}`;
112382
112848
  }
112849
+ var kvViewOutputSchema = looseObject({
112850
+ path: string().optional(),
112851
+ type: string().optional(),
112852
+ total: number().optional(),
112853
+ offset: number().optional(),
112854
+ returned: number().optional(),
112855
+ nextOffset: number().nullable().optional()
112856
+ });
112857
+ function describeView(view) {
112858
+ const target = view.path ? `"${view.path}"` : "the value";
112859
+ if (view.total === undefined)
112860
+ return `${target} (${view.type})`;
112861
+ const unit = view.type === "array" ? "items" : view.type === "object" ? "keys" : "chars (JSON-encoded)";
112862
+ const offset = view.offset ?? 0;
112863
+ return `${target} ${unit} ${offset}..${offset + (view.returned ?? 0)} of ${view.total}`;
112864
+ }
112865
+ function boundedView(entry, agentId, args) {
112866
+ const { namespace: namespace2, key } = entry;
112867
+ const failed = (error) => toolErr(error, { data: { yourAgentId: agentId, namespace: namespace2 } });
112868
+ const checked = resolveKvView(entry.value, args);
112869
+ if (!checked.ok)
112870
+ return failed(checked.error);
112871
+ const target = resolveKvTarget(entry.value, args.path ?? "");
112872
+ if (!target.ok)
112873
+ return failed(target.error);
112874
+ const { value: _value, ...meta2 } = entry;
112875
+ const render = (value, view) => toolOk(`Read ${describeView(view)} from "${key}" in "${namespace2}".`, {
112876
+ details: JSON.stringify(value),
112877
+ data: { yourAgentId: agentId, namespace: namespace2, entry: meta2, view }
112878
+ });
112879
+ const baseView = checked.view;
112880
+ if (baseView.total === undefined)
112881
+ return render(checked.value, baseView);
112882
+ const offset = baseView.offset ?? 0;
112883
+ const wanted = Math.min(args.limit ?? baseView.total, Math.max(0, baseView.total - offset));
112884
+ const firstKey = baseView.type === "array" ? String(offset) : baseView.type === "object" ? Object.keys(target.value)[offset] : undefined;
112885
+ const firstPath = firstKey === undefined || firstKey === "" ? undefined : `${baseView.path ? `${baseView.path}.` : ""}${joinKvPath([firstKey])}`;
112886
+ const narrowTo = firstPath !== undefined && firstPath.length <= KV_PATH_MAX_CHARS;
112887
+ const page = (count) => {
112888
+ const sliced = sliceKvTarget(target.value, offset, count);
112889
+ const result = render(sliced?.value, {
112890
+ ...baseView,
112891
+ returned: sliced?.returned ?? 0,
112892
+ nextOffset: sliced?.nextOffset ?? null
112893
+ });
112894
+ if (count >= wanted)
112895
+ return result;
112896
+ const note = count === 0 && narrowTo ? ` The entry at offset ${offset} alone exceeds the ${MCP_RESULT_WIRE_LIMIT_BYTES}-byte cap; narrow the path to "${firstPath}".` : ` Page shrunk to fit the ${MCP_RESULT_WIRE_LIMIT_BYTES}-byte cap; continue at view.nextOffset.`;
112897
+ return { ...result, message: `${result.message}${note}` };
112898
+ };
112899
+ const fits = (count) => swarmToolResultBytes(page(count)) <= MCP_RESULT_WIRE_LIMIT_BYTES;
112900
+ if (fits(wanted))
112901
+ return page(wanted);
112902
+ let low = 0;
112903
+ let high = wanted;
112904
+ while (low < high) {
112905
+ const mid = Math.ceil((low + high) / 2);
112906
+ if (fits(mid))
112907
+ low = mid;
112908
+ else
112909
+ high = mid - 1;
112910
+ }
112911
+ return page(low);
112912
+ }
112383
112913
  var registerKvGetTool = (server) => {
112384
112914
  createToolRegistrar(server)("kv-get", {
112385
112915
  title: "KV Get",
112386
- description: "Read a key from the swarm KV store. Returns the entry or null if missing/expired. Namespace defaults to your current context (Slack thread / PR / Linear issue when invoked from a task; otherwise your agent scratchpad).",
112916
+ description: "Read a key from the swarm KV store. Returns the entry or null if missing/expired. Namespace defaults to your current context (Slack thread / PR / Linear issue when invoked from a task; otherwise your agent scratchpad). Without path/offset/limit the whole value comes back unbounded. With any of them you get a bounded view (≤10KB per channel): `path` is a dot path into a JSON value (string entries holding JSON, such as spilled tool results, count as JSON; numeric segments index arrays, e.g. `outcome.data.rows` or `rows.3`; escape a dot inside a key as `\\.`), and `offset`/`limit` page the array items, object keys, or string characters found there. The result's `view.nextOffset` says where the next page starts.",
112387
112917
  annotations: { readOnlyHint: true },
112388
112918
  inputSchema: object({
112389
112919
  key: KvKeySchema.describe("KV key (≤512 chars, [a-zA-Z0-9._:/-])."),
112390
- namespace: KvNamespaceSchema.optional().describe("Optional explicit namespace. Defaults to the caller's contextKey.")
112920
+ namespace: KvNamespaceSchema.optional().describe("Optional explicit namespace. Defaults to the caller's contextKey."),
112921
+ path: string().max(KV_PATH_MAX_CHARS).optional().describe('Dot path into the JSON value, e.g. "outcome.data.rows" or "rows.3". "" is the whole value. A dot inside a key is escaped as "\\.".'),
112922
+ offset: number().int().nonnegative().optional().describe("First array item / object key / string char to return. Default 0."),
112923
+ limit: number().int().positive().optional().describe("Max items / keys / chars to return; the page also shrinks to fit the cap.")
112391
112924
  }),
112392
112925
  outputSchema: swarmToolOutputSchema({
112393
112926
  yourAgentId: string().optional(),
112394
112927
  namespace: string().optional(),
112395
- entry: kvEntryOutputSchema.nullable().optional()
112928
+ entry: kvEntryOutputSchema.nullable().optional(),
112929
+ view: kvViewOutputSchema.optional()
112396
112930
  })
112397
- }, async ({ key, namespace: namespace2 }, requestInfo) => {
112931
+ }, async ({ key, namespace: namespace2, path: path2, offset, limit }, requestInfo) => {
112398
112932
  const resolved = await resolveNamespace(namespace2, requestInfo);
112399
112933
  if ("error" in resolved) {
112400
112934
  return toolErr(resolved.error, { data: { yourAgentId: requestInfo.agentId } });
@@ -112406,6 +112940,9 @@ var registerKvGetTool = (server) => {
112406
112940
  });
112407
112941
  }
112408
112942
  const entry = await getKv(resolved.namespace, key);
112943
+ if (entry && hasKvViewArgs({ path: path2, offset, limit })) {
112944
+ return boundedView(entry, requestInfo.agentId, { path: path2, offset, limit });
112945
+ }
112409
112946
  return toolOk(entry ? `Found "${key}" in "${resolved.namespace}".` : `No entry for "${key}" in "${resolved.namespace}".`, {
112410
112947
  details: entry ? renderKvEntry(entry) : undefined,
112411
112948
  data: {
@@ -112418,7 +112955,7 @@ var registerKvGetTool = (server) => {
112418
112955
  };
112419
112956
  // src/tools/kv/kv-incr.ts
112420
112957
  init_zod();
112421
- init_db();
112958
+ init_db2();
112422
112959
  init_types();
112423
112960
  var kvEntryOutputSchema2 = looseObject({
112424
112961
  namespace: string().optional(),
@@ -112475,7 +113012,7 @@ var registerKvIncrTool = (server) => {
112475
113012
  };
112476
113013
  // src/tools/kv/kv-list.ts
112477
113014
  init_zod();
112478
- init_db();
113015
+ init_db2();
112479
113016
  init_types();
112480
113017
  var MAX_KV_LIST_LIMIT = 1000;
112481
113018
  var kvEntryOutputSchema3 = looseObject({
@@ -112545,7 +113082,7 @@ var registerKvListTool = (server) => {
112545
113082
  };
112546
113083
  // src/tools/kv/kv-set.ts
112547
113084
  init_zod();
112548
- init_db();
113085
+ init_db2();
112549
113086
  init_types();
112550
113087
  var MAX_KV_BODY_BYTES = 2 * 1024 * 1024;
112551
113088
  var kvEntryOutputSchema4 = looseObject({
@@ -112646,7 +113183,7 @@ var registerKvSetTool = (server) => {
112646
113183
  };
112647
113184
  // src/tools/list-channels.ts
112648
113185
  init_zod();
112649
- init_db();
113186
+ init_db2();
112650
113187
  init_types();
112651
113188
  var ChannelOutputSchema2 = looseObject({
112652
113189
  id: string().optional(),
@@ -112680,7 +113217,7 @@ var registerListChannelsTool = (server) => {
112680
113217
 
112681
113218
  // src/tools/list-services.ts
112682
113219
  init_zod();
112683
- init_db();
113220
+ init_db2();
112684
113221
  init_types();
112685
113222
  var serviceWithAgentNameOutputShape = looseObject({
112686
113223
  id: string().optional(),
@@ -112758,7 +113295,7 @@ var registerListServicesTool = (server) => {
112758
113295
 
112759
113296
  // src/tools/manage-user.ts
112760
113297
  init_zod();
112761
- init_db();
113298
+ init_db2();
112762
113299
  init_rbac();
112763
113300
  var userOutputShape = looseObject({
112764
113301
  id: string().optional(),
@@ -112973,7 +113510,7 @@ var registerManageUserTool = (server) => {
112973
113510
 
112974
113511
  // src/tools/mcp-servers/mcp-server-create.ts
112975
113512
  init_zod();
112976
- init_db();
113513
+ init_db2();
112977
113514
  init_rbac();
112978
113515
  var registerMcpServerCreateTool = (server) => {
112979
113516
  createToolRegistrar(server)("mcp-server-create", {
@@ -113078,7 +113615,7 @@ var registerMcpServerCreateTool = (server) => {
113078
113615
  };
113079
113616
  // src/tools/mcp-servers/mcp-server-delete.ts
113080
113617
  init_zod();
113081
- init_db();
113618
+ init_db2();
113082
113619
  init_rbac();
113083
113620
  var registerMcpServerDeleteTool = (server) => {
113084
113621
  createToolRegistrar(server)("mcp-server-delete", {
@@ -113123,7 +113660,7 @@ var registerMcpServerDeleteTool = (server) => {
113123
113660
  };
113124
113661
  // src/tools/mcp-servers/mcp-server-get.ts
113125
113662
  init_zod();
113126
- init_db();
113663
+ init_db2();
113127
113664
  var registerMcpServerGetTool = (server) => {
113128
113665
  createToolRegistrar(server)("mcp-server-get", {
113129
113666
  title: "Get MCP Server",
@@ -113160,7 +113697,7 @@ var registerMcpServerGetTool = (server) => {
113160
113697
  };
113161
113698
  // src/tools/mcp-servers/mcp-server-install.ts
113162
113699
  init_zod();
113163
- init_db();
113700
+ init_db2();
113164
113701
  init_rbac();
113165
113702
  var registerMcpServerInstallTool = (server) => {
113166
113703
  createToolRegistrar(server)("mcp-server-install", {
@@ -113218,15 +113755,15 @@ var registerMcpServerInstallTool = (server) => {
113218
113755
  };
113219
113756
  // src/tools/mcp-servers/mcp-server-list.ts
113220
113757
  init_zod();
113221
- init_db();
113758
+ init_db2();
113222
113759
  function renderServerLines(servers) {
113223
113760
  if (servers.length === 0)
113224
113761
  return;
113225
113762
  return servers.map((entry) => {
113226
113763
  const s = entry;
113227
- const enabled2 = s.isEnabled === false ? "disabled" : "enabled";
113764
+ const enabled = s.isEnabled === false ? "disabled" : "enabled";
113228
113765
  const status = typeof s.status === "string" && s.status ? `, status=${s.status}` : "";
113229
- return `- ${String(s.name ?? "?")} (${String(s.transport ?? "?")}, ${enabled2}${status})`;
113766
+ return `- ${String(s.name ?? "?")} (${String(s.transport ?? "?")}, ${enabled}${status})`;
113230
113767
  }).join(`
113231
113768
  `);
113232
113769
  }
@@ -113267,7 +113804,7 @@ var registerMcpServerListTool = (server) => {
113267
113804
  };
113268
113805
  // src/tools/mcp-servers/mcp-server-uninstall.ts
113269
113806
  init_zod();
113270
- init_db();
113807
+ init_db2();
113271
113808
  init_rbac();
113272
113809
  var registerMcpServerUninstallTool = (server) => {
113273
113810
  createToolRegistrar(server)("mcp-server-uninstall", {
@@ -113311,10 +113848,10 @@ var registerMcpServerUninstallTool = (server) => {
113311
113848
  };
113312
113849
  // src/tools/mcp-servers/mcp-server-update.ts
113313
113850
  init_zod();
113314
- init_db();
113851
+ init_db2();
113315
113852
 
113316
113853
  // src/be/mcp-server-checked-update.ts
113317
- init_db();
113854
+ init_db2();
113318
113855
  async function updateMcpServerChecked(id, updates, check) {
113319
113856
  return await getDbClient().transaction(async () => {
113320
113857
  const existing = await getMcpServerById(id);
@@ -113437,7 +113974,8 @@ var registerMcpServerUpdateTool = (server) => {
113437
113974
  };
113438
113975
  // src/tools/memory-delete.ts
113439
113976
  init_zod();
113440
- init_db();
113977
+ init_db2();
113978
+ init_memory();
113441
113979
  init_rbac();
113442
113980
  var registerMemoryDeleteTool = (server) => {
113443
113981
  createToolRegistrar(server)("memory-delete", {
@@ -113483,7 +114021,8 @@ var registerMemoryDeleteTool = (server) => {
113483
114021
 
113484
114022
  // src/tools/memory-edit.ts
113485
114023
  init_zod();
113486
- init_db();
114024
+ init_db2();
114025
+ init_memory();
113487
114026
 
113488
114027
  // src/be/memory/key-guard.ts
113489
114028
  init_rbac();
@@ -113533,7 +114072,7 @@ function assertKeyWritable(key, origin, writer) {
113533
114072
  init_key_paths();
113534
114073
 
113535
114074
  // src/be/memory/link-resolver.ts
113536
- init_db();
114075
+ init_db2();
113537
114076
  init_constants();
113538
114077
  var WIKILINK_RE = /\[\[([^\]]+)\]\]/g;
113539
114078
  var PR_HASH_RE = /(?:^|[\s(])#(\d{1,5})(?=[\s,.)!?]|$)/gm;
@@ -113890,7 +114429,8 @@ var registerMemoryEditTool = (server) => {
113890
114429
 
113891
114430
  // src/tools/memory-get.ts
113892
114431
  init_zod();
113893
- init_db();
114432
+ init_db2();
114433
+ init_memory();
113894
114434
 
113895
114435
  // src/be/memory/access.ts
113896
114436
  function canReadMemory(memory, agentId) {
@@ -113898,7 +114438,7 @@ function canReadMemory(memory, agentId) {
113898
114438
  }
113899
114439
 
113900
114440
  // src/be/memory/links-store.ts
113901
- init_db();
114441
+ init_db2();
113902
114442
  function redactedTargetId(sourceText) {
113903
114443
  const wikilink = /^\[\[(.+)\]\]$/.exec(sourceText ?? "");
113904
114444
  return wikilink?.[1] ?? "";
@@ -114188,11 +114728,12 @@ var registerMemoryRateTool = (server) => {
114188
114728
 
114189
114729
  // src/tools/memory-search.ts
114190
114730
  init_zod();
114191
- init_db();
114731
+ init_db2();
114732
+ init_memory();
114192
114733
  init_constants2();
114193
114734
 
114194
114735
  // src/be/memory/graph-expansion.ts
114195
- init_db();
114736
+ init_db2();
114196
114737
  init_constants2();
114197
114738
  init_sqlite_store();
114198
114739
  init_reranker();
@@ -114438,7 +114979,7 @@ var registerMemorySearchTool = (server) => {
114438
114979
 
114439
114980
  // src/tools/memory-store.ts
114440
114981
  init_zod();
114441
- init_db();
114982
+ init_db2();
114442
114983
 
114443
114984
  // src/be/chunking.ts
114444
114985
  var MAX_CHUNK_SIZE = 2000;
@@ -114588,6 +115129,7 @@ function addOverlap(chunks, _originalText) {
114588
115129
  }
114589
115130
 
114590
115131
  // src/be/memory/index-content.ts
115132
+ init_memory();
114591
115133
  init_secret_scrubber();
114592
115134
  async function indexMemoryContent(params) {
114593
115135
  const { agentId, content, name, scope, source, sourceTaskId, sourcePath, tags } = params;
@@ -114620,7 +115162,7 @@ async function indexMemoryContent(params) {
114620
115162
  intent: "re-index memory source path",
114621
115163
  changedByAgentId: agentId
114622
115164
  });
114623
- const embedding = await provider.embed(contentChunks[0].content);
115165
+ const embedding = await provider.embed(result.memory.content);
114624
115166
  if (embedding)
114625
115167
  await store.updateEmbedding(result.memory.id, embedding, provider.name);
114626
115168
  try {
@@ -114660,7 +115202,7 @@ async function indexMemoryContent(params) {
114660
115202
  }
114661
115203
  (async () => {
114662
115204
  try {
114663
- const embeddings = await provider.embedBatch(contentChunks.map((c) => c.content));
115205
+ const embeddings = await provider.embedBatch(memories.map((m) => m.content));
114664
115206
  for (let i = 0;i < embeddings.length; i++) {
114665
115207
  if (embeddings[i]) {
114666
115208
  await store.updateEmbedding(memories[i].id, embeddings[i], provider.name);
@@ -114752,7 +115294,7 @@ var registerMemoryStoreTool = (server) => {
114752
115294
 
114753
115295
  // src/tools/model-catalog/index.ts
114754
115296
  init_zod();
114755
- init_db();
115297
+ init_db2();
114756
115298
  init_rbac();
114757
115299
  async function denyUnlessCatalogWriter(agentId) {
114758
115300
  const agent = await getAgentById(agentId);
@@ -114853,7 +115395,7 @@ var registerModelCatalogOverlayUpsertTool = (server) => {
114853
115395
 
114854
115396
  // src/tools/my-agent-info.ts
114855
115397
  init_zod();
114856
- init_db();
115398
+ init_db2();
114857
115399
  init_types();
114858
115400
  var agentOutputShape3 = looseObject({
114859
115401
  id: string().optional(),
@@ -114908,6 +115450,7 @@ var registerMyAgentInfoTool = (server) => {
114908
115450
 
114909
115451
  // src/tools/oauth-access-token.ts
114910
115452
  init_zod();
115453
+ init_oauth();
114911
115454
  init_secret_scrubber();
114912
115455
  function assertTokenUsable(provider, expiresAt, minValidityMs) {
114913
115456
  const expiresAtMs = Date.parse(expiresAt);
@@ -115031,7 +115574,7 @@ init_zod();
115031
115574
  // src/be/api-drain.ts
115032
115575
  init_api_drain();
115033
115576
  init_secret_scrubber();
115034
- init_db();
115577
+ init_db2();
115035
115578
  var DEFAULT_API_DRAIN_MAX_MS = 0;
115036
115579
  var DRAIN_CHECK_INTERVAL_MS = 500;
115037
115580
  var LIVE_WORKER_WINDOW_MS = 30000;
@@ -115129,7 +115672,7 @@ function describe2(err) {
115129
115672
  }
115130
115673
 
115131
115674
  // src/tools/poll-task.ts
115132
- init_db();
115675
+ init_db2();
115133
115676
  var DEFAULT_POLL_INTERVAL_MS = 2000;
115134
115677
  var MAX_POLL_DURATION_MS = 1 * 60 * 1000;
115135
115678
  var registerPollTaskTool = (server) => {
@@ -115297,7 +115840,7 @@ var registerPollTaskTool = (server) => {
115297
115840
 
115298
115841
  // src/tools/post-message.ts
115299
115842
  init_zod();
115300
- init_db();
115843
+ init_db2();
115301
115844
  var PostedMessageSchema = looseObject({
115302
115845
  id: string().optional(),
115303
115846
  channelId: string().optional(),
@@ -115356,7 +115899,7 @@ var registerPostMessageTool = (server) => {
115356
115899
 
115357
115900
  // src/tools/prompt-templates/delete.ts
115358
115901
  init_zod();
115359
- init_db();
115902
+ init_db2();
115360
115903
  var registerDeletePromptTemplateTool = (server) => {
115361
115904
  createToolRegistrar(server)("delete-prompt-template", {
115362
115905
  title: "Delete Prompt Template",
@@ -115399,7 +115942,7 @@ var registerDeletePromptTemplateTool = (server) => {
115399
115942
  };
115400
115943
  // src/tools/prompt-templates/get.ts
115401
115944
  init_zod();
115402
- init_db();
115945
+ init_db2();
115403
115946
  init_registry();
115404
115947
  var promptTemplateOutputShape = looseObject({
115405
115948
  id: string().optional(),
@@ -115479,7 +116022,7 @@ History: ${history.length} version(s)`,
115479
116022
  };
115480
116023
  // src/tools/prompt-templates/list.ts
115481
116024
  init_zod();
115482
- init_db();
116025
+ init_db2();
115483
116026
  init_types();
115484
116027
  var promptTemplateOutputShape2 = looseObject({
115485
116028
  id: string().optional(),
@@ -115584,7 +116127,7 @@ Unresolved variables: ${unresolved.join(", ")}` : ""}`,
115584
116127
  };
115585
116128
  // src/tools/prompt-templates/set.ts
115586
116129
  init_zod();
115587
- init_db();
116130
+ init_db2();
115588
116131
  init_types();
115589
116132
  var promptTemplateOutputShape3 = looseObject({
115590
116133
  id: string().optional(),
@@ -115651,7 +116194,7 @@ var registerSetPromptTemplateTool = (server) => {
115651
116194
  };
115652
116195
  // src/tools/read-messages.ts
115653
116196
  init_zod();
115654
- init_db();
116197
+ init_db2();
115655
116198
  var ChannelMessageOutputSchema = looseObject({
115656
116199
  id: string().optional(),
115657
116200
  channelId: string().optional(),
@@ -115776,7 +116319,7 @@ var registerReadMessagesTool = (server) => {
115776
116319
 
115777
116320
  // src/tools/register-agentmail-inbox.ts
115778
116321
  init_zod();
115779
- init_db();
116322
+ init_db2();
115780
116323
  var registerRegisterAgentmailInboxTool = (server) => {
115781
116324
  createToolRegistrar(server)("register-agentmail-inbox", {
115782
116325
  title: "Register AgentMail Inbox",
@@ -115849,9 +116392,10 @@ ${mappings.map((m) => ` - ${m.inboxId} (${m.inboxEmail ?? "no email"})`).join(`
115849
116392
 
115850
116393
  // src/tools/register-kapso-number.ts
115851
116394
  init_zod();
115852
- init_db();
116395
+ init_db2();
115853
116396
 
115854
116397
  // src/integrations/kapso/client.ts
116398
+ init_secret_scrubber();
115855
116399
  var SESSION_WINDOW_ERROR_CODES = new Set([131047, 131051, 470]);
115856
116400
  function extractMetaError(raw) {
115857
116401
  if (raw && typeof raw === "object" && "error" in raw) {
@@ -115885,7 +116429,7 @@ async function sendKapsoText(params) {
115885
116429
  recipient_type: "individual",
115886
116430
  to: params.to,
115887
116431
  type: "text",
115888
- text: { preview_url: params.previewUrl ?? false, body: params.body }
116432
+ text: { preview_url: params.previewUrl ?? false, body: scrubSecrets(params.body) }
115889
116433
  };
115890
116434
  if (params.contextMessageId) {
115891
116435
  payload.context = { message_id: params.contextMessageId };
@@ -116021,7 +116565,7 @@ async function registerKapsoWebhook(params) {
116021
116565
  }
116022
116566
 
116023
116567
  // src/integrations/kapso/config.ts
116024
- init_db();
116568
+ init_db2();
116025
116569
  var KAPSO_NUMBERS_NAMESPACE = "integrations:kapso:numbers";
116026
116570
  var KAPSO_DEDUPE_NAMESPACE = "integrations:kapso:dedupe";
116027
116571
  var KAPSO_DEDUPE_TTL_MS = 24 * 60 * 60 * 1000;
@@ -116203,7 +116747,7 @@ var registerUnregisterKapsoNumberTool = (server) => {
116203
116747
 
116204
116748
  // src/tools/register-service.ts
116205
116749
  init_zod();
116206
- init_db();
116750
+ init_db2();
116207
116751
  import path2 from "node:path";
116208
116752
  init_types();
116209
116753
  var serviceOutputShape = looseObject({
@@ -116334,7 +116878,7 @@ var registerRegisterServiceTool = (server) => {
116334
116878
 
116335
116879
  // src/tools/repos/get-repos.ts
116336
116880
  init_zod();
116337
- init_db();
116881
+ init_db2();
116338
116882
  var swarmRepoOutputShape = looseObject({
116339
116883
  id: string().optional(),
116340
116884
  url: string().optional(),
@@ -116378,10 +116922,10 @@ var registerGetReposTool = (server) => {
116378
116922
  };
116379
116923
  // src/tools/repos/update-repo.ts
116380
116924
  init_zod();
116381
- init_db();
116925
+ init_db2();
116382
116926
 
116383
116927
  // src/be/repo-checked-update.ts
116384
- init_db();
116928
+ init_db2();
116385
116929
 
116386
116930
  // src/be/repo-merge-policy.ts
116387
116931
  function changesAllowMerge(current, incoming) {
@@ -116473,7 +117017,7 @@ var registerUpdateRepoTool = (server) => {
116473
117017
  };
116474
117018
  // src/tools/request-human-input.ts
116475
117019
  init_zod();
116476
- init_db();
117020
+ init_db2();
116477
117021
  init_constants();
116478
117022
  var QuestionSchema = object({
116479
117023
  id: string().describe("Unique ID for the question (used as key in responses)"),
@@ -116634,7 +117178,7 @@ var registerResolveUserTool = (server) => {
116634
117178
  init_zod();
116635
117179
 
116636
117180
  // src/realtime/auth.ts
116637
- init_db();
117181
+ init_db2();
116638
117182
  init_rbac_roles();
116639
117183
 
116640
117184
  // src/comb/config.ts
@@ -122496,7 +123040,7 @@ var removeAwarenessStates = (awareness, clients, origin) => {
122496
123040
  };
122497
123041
 
122498
123042
  // src/realtime/rooms.ts
122499
- init_db();
123043
+ init_db2();
122500
123044
  init_secret_scrubber();
122501
123045
  init_bus();
122502
123046
  var ROOM_KEY_PREFIX = "_room/";
@@ -123063,6 +123607,7 @@ var registerRoomDecodeTool = (server) => {
123063
123607
  // src/tools/schedules/create-schedule.ts
123064
123608
  init_zod();
123065
123609
  var import_cron_parser2 = __toESM(require_dist2(), 1);
123610
+ init_db2();
123066
123611
  init_db();
123067
123612
  init_types();
123068
123613
  var createScheduleInputSchema = object({
@@ -123146,7 +123691,7 @@ var registerCreateScheduleTool = (server) => {
123146
123691
  priority,
123147
123692
  targetAgentId,
123148
123693
  timezone,
123149
- enabled: enabled2,
123694
+ enabled,
123150
123695
  model,
123151
123696
  modelTier,
123152
123697
  allowCustomModel
@@ -123227,7 +123772,7 @@ var registerCreateScheduleTool = (server) => {
123227
123772
  return toolErr(modelError);
123228
123773
  try {
123229
123774
  let nextRunAt;
123230
- if (enabled2 === false) {
123775
+ if (enabled === false) {
123231
123776
  nextRunAt = undefined;
123232
123777
  } else if (isOneTime) {
123233
123778
  nextRunAt = delayMs ? new Date(Date.now() + delayMs).toISOString() : runAt;
@@ -123257,7 +123802,7 @@ var registerCreateScheduleTool = (server) => {
123257
123802
  priority,
123258
123803
  targetAgentId,
123259
123804
  timezone,
123260
- enabled: enabled2,
123805
+ enabled,
123261
123806
  nextRunAt,
123262
123807
  createdByAgentId: requestInfo.agentId,
123263
123808
  model: normalizedModel.model,
@@ -123279,13 +123824,15 @@ var registerCreateScheduleTool = (server) => {
123279
123824
  };
123280
123825
  // src/tools/schedules/delete-schedule.ts
123281
123826
  init_zod();
123282
- init_db();
123827
+ init_db2();
123283
123828
 
123284
123829
  // src/be/events.ts
123285
- init_db();
123830
+ init_secret_scrubber();
123831
+ init_db2();
123832
+ init_scrub_json();
123286
123833
 
123287
123834
  // src/be/memory/key-browser.ts
123288
- init_db();
123835
+ init_db2();
123289
123836
  var MEMORY_KEYS_DEFAULT_PREFIX = "/longterm/";
123290
123837
  var MEMORY_KEYS_MAX_LIMIT = 2000;
123291
123838
  function estimateTokens(chars) {
@@ -123518,6 +124065,13 @@ function rowToSwarmEvent(row) {
123518
124065
  var INSERT_EVENT_SQL = `INSERT INTO events (id, category, event, status, source, agentId, taskId,
123519
124066
  sessionId, parentEventId, numericValue, durationMs, data, createdAt)
123520
124067
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))`;
124068
+ function serializeEventData(data) {
124069
+ const raw = JSON.stringify(data);
124070
+ const scrubbed = scrubSecrets(raw);
124071
+ if (!breaksJsonValidity(raw, scrubbed))
124072
+ return scrubbed;
124073
+ return JSON.stringify(scrubObject(data));
124074
+ }
123521
124075
  async function insertEvent(db, id2, input) {
123522
124076
  await db.run(INSERT_EVENT_SQL, [
123523
124077
  id2,
@@ -123531,7 +124085,7 @@ async function insertEvent(db, id2, input) {
123531
124085
  input.parentEventId ?? null,
123532
124086
  input.numericValue ?? null,
123533
124087
  input.durationMs ?? null,
123534
- input.data ? JSON.stringify(input.data) : null
124088
+ input.data ? serializeEventData(input.data) : null
123535
124089
  ]);
123536
124090
  await recordSkillInvocation(db, input, id2);
123537
124091
  }
@@ -123740,7 +124294,7 @@ var registerDeleteScheduleTool = (server) => {
123740
124294
  };
123741
124295
  // src/tools/schedules/list-schedules.ts
123742
124296
  init_zod();
123743
- init_db();
124297
+ init_db2();
123744
124298
  init_types();
123745
124299
  var scheduleRowShape = {
123746
124300
  id: string().optional(),
@@ -123790,7 +124344,7 @@ var registerListSchedulesTool = (server) => {
123790
124344
  count: number().optional()
123791
124345
  })
123792
124346
  }, async ({
123793
- enabled: enabled2,
124347
+ enabled,
123794
124348
  name,
123795
124349
  key,
123796
124350
  keyPrefix,
@@ -123807,7 +124361,7 @@ var registerListSchedulesTool = (server) => {
123807
124361
  }
123808
124362
  try {
123809
124363
  const filters = {
123810
- enabled: enabled2,
124364
+ enabled,
123811
124365
  name,
123812
124366
  key,
123813
124367
  keyPrefix,
@@ -123842,7 +124396,7 @@ var registerListSchedulesTool = (server) => {
123842
124396
  // src/tools/schedules/patch-schedule.ts
123843
124397
  init_zod();
123844
124398
  var import_cron_parser3 = __toESM(require_dist2(), 1);
123845
- init_db();
124399
+ init_db2();
123846
124400
 
123847
124401
  // src/be/schedules/validate.ts
123848
124402
  function mergeScheduleTiming(existing, patch) {
@@ -123859,6 +124413,7 @@ function validateRecurringTiming(merged) {
123859
124413
  }
123860
124414
 
123861
124415
  // src/tools/schedules/patch-schedule.ts
124416
+ init_db();
123862
124417
  init_types();
123863
124418
  var patchScheduleInputSchema = object({
123864
124419
  key: AssetKeySchema.optional().describe("Move to a logical namespace."),
@@ -123939,7 +124494,7 @@ var registerPatchScheduleTool = (server) => {
123939
124494
  priority,
123940
124495
  targetAgentId,
123941
124496
  timezone,
123942
- enabled: enabled2,
124497
+ enabled,
123943
124498
  model,
123944
124499
  modelTier,
123945
124500
  allowCustomModel
@@ -124036,8 +124591,8 @@ var registerPatchScheduleTool = (server) => {
124036
124591
  updateData.targetAgentId = targetAgentId;
124037
124592
  if (timezone !== undefined)
124038
124593
  updateData.timezone = timezone;
124039
- if (enabled2 !== undefined)
124040
- updateData.enabled = enabled2;
124594
+ if (enabled !== undefined)
124595
+ updateData.enabled = enabled;
124041
124596
  const agentChanged = targetAgentId !== undefined && targetAgentId !== schedule.targetAgentId;
124042
124597
  if (model !== undefined || modelTier !== undefined) {
124043
124598
  const normalizedModel = splitLegacyModelAlias({ model, modelTier });
@@ -124065,7 +124620,7 @@ var registerPatchScheduleTool = (server) => {
124065
124620
  return toolErr(modelError);
124066
124621
  }
124067
124622
  if (schedule.scheduleType === "one_time") {
124068
- if (enabled2 === false) {
124623
+ if (enabled === false) {
124069
124624
  updateData.nextRunAt = null;
124070
124625
  }
124071
124626
  } else {
@@ -124077,15 +124632,15 @@ var registerPatchScheduleTool = (server) => {
124077
124632
  if (timingError) {
124078
124633
  return toolErr("At least one of intervalMs or cronExpression must be set for recurring schedules.");
124079
124634
  }
124080
- const needsNextRunRecalc = cronExpression !== undefined || intervalMs !== undefined || timezone !== undefined || enabled2 === true && !schedule.enabled;
124081
- if (needsNextRunRecalc && enabled2 !== false) {
124635
+ const needsNextRunRecalc = cronExpression !== undefined || intervalMs !== undefined || timezone !== undefined || enabled === true && !schedule.enabled;
124636
+ if (needsNextRunRecalc && enabled !== false) {
124082
124637
  const mergedTimezone = timezone !== undefined ? timezone : schedule.timezone;
124083
124638
  updateData.nextRunAt = calculateNextRun({
124084
124639
  cronExpression: timing.mergedCron,
124085
124640
  intervalMs: timing.mergedInterval,
124086
124641
  timezone: mergedTimezone
124087
124642
  }, new Date);
124088
- } else if (enabled2 === false) {
124643
+ } else if (enabled === false) {
124089
124644
  updateData.nextRunAt = null;
124090
124645
  }
124091
124646
  }
@@ -124109,7 +124664,7 @@ var registerPatchScheduleTool = (server) => {
124109
124664
  };
124110
124665
  // src/tools/schedules/run-schedule-now.ts
124111
124666
  init_zod();
124112
- init_db();
124667
+ init_db2();
124113
124668
  var registerRunScheduleNowTool = (server) => {
124114
124669
  createToolRegistrar(server)("run-schedule-now", {
124115
124670
  title: "Run Schedule Now",
@@ -124168,6 +124723,7 @@ var registerRunScheduleNowTool = (server) => {
124168
124723
  // src/tools/schedules/update-schedule.ts
124169
124724
  init_zod();
124170
124725
  var import_cron_parser4 = __toESM(require_dist2(), 1);
124726
+ init_db2();
124171
124727
  init_db();
124172
124728
  init_types();
124173
124729
  var updateScheduleInputSchema = object({
@@ -124249,7 +124805,7 @@ var registerUpdateScheduleTool = (server) => {
124249
124805
  priority,
124250
124806
  targetAgentId,
124251
124807
  timezone,
124252
- enabled: enabled2,
124808
+ enabled,
124253
124809
  model,
124254
124810
  modelTier,
124255
124811
  allowCustomModel
@@ -124346,8 +124902,8 @@ var registerUpdateScheduleTool = (server) => {
124346
124902
  updateData.targetAgentId = targetAgentId;
124347
124903
  if (timezone !== undefined)
124348
124904
  updateData.timezone = timezone;
124349
- if (enabled2 !== undefined)
124350
- updateData.enabled = enabled2;
124905
+ if (enabled !== undefined)
124906
+ updateData.enabled = enabled;
124351
124907
  const agentChanged = targetAgentId !== undefined && targetAgentId !== schedule.targetAgentId;
124352
124908
  if (model !== undefined || modelTier !== undefined) {
124353
124909
  const normalizedModel = splitLegacyModelAlias({ model, modelTier });
@@ -124375,7 +124931,7 @@ var registerUpdateScheduleTool = (server) => {
124375
124931
  return toolErr(modelError);
124376
124932
  }
124377
124933
  if (schedule.scheduleType === "one_time") {
124378
- if (enabled2 === false) {
124934
+ if (enabled === false) {
124379
124935
  updateData.nextRunAt = null;
124380
124936
  }
124381
124937
  } else {
@@ -124387,15 +124943,15 @@ var registerUpdateScheduleTool = (server) => {
124387
124943
  if (timingError) {
124388
124944
  return toolErr("At least one of intervalMs or cronExpression must be set for recurring schedules.");
124389
124945
  }
124390
- const needsNextRunRecalc = cronExpression !== undefined || intervalMs !== undefined || timezone !== undefined || enabled2 === true && !schedule.enabled;
124391
- if (needsNextRunRecalc && enabled2 !== false) {
124946
+ const needsNextRunRecalc = cronExpression !== undefined || intervalMs !== undefined || timezone !== undefined || enabled === true && !schedule.enabled;
124947
+ if (needsNextRunRecalc && enabled !== false) {
124392
124948
  const mergedTimezone = timezone !== undefined ? timezone : schedule.timezone;
124393
124949
  updateData.nextRunAt = calculateNextRun({
124394
124950
  cronExpression: timing.mergedCron,
124395
124951
  intervalMs: timing.mergedInterval,
124396
124952
  timezone: mergedTimezone
124397
124953
  }, new Date);
124398
- } else if (enabled2 === false) {
124954
+ } else if (enabled === false) {
124399
124955
  updateData.nextRunAt = null;
124400
124956
  }
124401
124957
  }
@@ -124419,7 +124975,7 @@ var registerUpdateScheduleTool = (server) => {
124419
124975
  };
124420
124976
  // src/tools/script-apis.ts
124421
124977
  init_zod();
124422
- init_db();
124978
+ init_db2();
124423
124979
  init_rbac();
124424
124980
  init_secret_scrubber();
124425
124981
  var scriptApisInputSchema = object({
@@ -124592,7 +125148,7 @@ var registerScriptApisTool = (server) => {
124592
125148
 
124593
125149
  // src/tools/script-connections/tool.ts
124594
125150
  init_zod();
124595
- init_db();
125151
+ init_db2();
124596
125152
  init_rbac();
124597
125153
  var scriptConnectionsInputSchema = object({
124598
125154
  action: _enum(["list", "upsert-openapi", "upsert-mcp", "upsert-graphql", "refresh", "disable"]).describe("List, create/update, refresh, or disable a script connection."),
@@ -125168,12 +125724,12 @@ var registerScriptUpsertTool = (server) => {
125168
125724
 
125169
125725
  // src/tools/send-task.ts
125170
125726
  init_zod();
125171
- init_db();
125727
+ init_db2();
125172
125728
  init_rbac();
125173
125729
  init_slack_routing();
125174
125730
 
125175
125731
  // src/tools/task-dedup.ts
125176
- init_db();
125732
+ init_db2();
125177
125733
  function jaccardSimilarity(a, b) {
125178
125734
  const tokenize = (s) => new Set(s.toLowerCase().replace(/[^\w\s]/g, " ").split(/\s+/).filter((w) => w.length > 0));
125179
125735
  const wordsA = tokenize(a);
@@ -125334,10 +125890,22 @@ async function sendTaskHandler(ctx, {
125334
125890
  followUpConfig,
125335
125891
  outputSchema
125336
125892
  }) {
125337
- if (agentId !== undefined && routingReason === undefined) {
125893
+ const userLead = ctx.kind === "user" ? await getLeadAgent() : null;
125894
+ if (ctx.kind === "user" && (!userLead || userLead.status === "offline")) {
125895
+ return toolErr("No online Lead is available. Start or register a Lead before sending a task.");
125896
+ }
125897
+ const requestedAgentId = ctx.kind === "user" ? userLead.id : agentId;
125898
+ const requestedRoutingReason = ctx.kind === "user" ? "skill" : routingReason;
125899
+ const requestedRoutingNote = ctx.kind === "user" ? "User MCP ingress assigns new work to the Lead for delegation." : routingNote;
125900
+ const requestedOfferMode = ctx.kind === "user" ? false : offerMode;
125901
+ const requestedLeadOnly = ctx.kind === "user" ? false : leadOnly;
125902
+ const requestedCapabilities = ctx.kind === "user" ? undefined : requiredCapabilities;
125903
+ const requestedAllowDuplicate = ctx.kind === "user" ? false : allowDuplicate;
125904
+ const requestedOverrideSlackContext = ctx.kind === "user" ? false : overrideSlackContext;
125905
+ if (requestedAgentId !== undefined && requestedRoutingReason === undefined) {
125338
125906
  return toolErr("routingReason is required when agentId is supplied.");
125339
125907
  }
125340
- if (agentId !== undefined && (routingNote?.trim().length ?? 0) < 10) {
125908
+ if (requestedAgentId !== undefined && (requestedRoutingNote?.trim().length ?? 0) < 10) {
125341
125909
  return toolErr("routingNote is required when agentId is supplied (at least 10 characters after trim).");
125342
125910
  }
125343
125911
  if (ctx.kind === "owner" && !ctx.agentId) {
@@ -125368,7 +125936,7 @@ async function sendTaskHandler(ctx, {
125368
125936
  data: { yourAgentId: creatorAgentId }
125369
125937
  });
125370
125938
  }
125371
- if (ctx.kind === "owner" && agentId === ctx.agentId) {
125939
+ if (ctx.kind === "owner" && requestedAgentId === ctx.agentId) {
125372
125940
  return toolErr("Cannot send a task to yourself, are you drunk?", {
125373
125941
  data: { yourAgentId: ctx.agentId }
125374
125942
  });
@@ -125382,8 +125950,8 @@ async function sendTaskHandler(ctx, {
125382
125950
  data: { yourAgentId: creatorAgentId }
125383
125951
  });
125384
125952
  }
125385
- const effectiveLeadOnly = leadOnly || effectiveParentTask?.routingAffinity?.leadOnly === true;
125386
- if (!overrideSlackContext) {
125953
+ const effectiveLeadOnly = ctx.kind === "user" ? false : requestedLeadOnly || effectiveParentTask?.routingAffinity?.leadOnly === true;
125954
+ if (!requestedOverrideSlackContext) {
125387
125955
  const inheritedContextKey = effectiveParentTask?.contextKey;
125388
125956
  const routingCheck = checkSlackRoutingCoherence({
125389
125957
  explicit: { channelId: slackChannelId, threadTs: slackThreadTs, userId: slackUserId },
@@ -125406,8 +125974,8 @@ async function sendTaskHandler(ctx, {
125406
125974
  const message = error instanceof AssetKeyAuthorizationError ? error.message : error instanceof Error ? error.message : String(error);
125407
125975
  return toolErr(message, { data: { yourAgentId: creatorAgentId } });
125408
125976
  }
125409
- let effectiveAgentId = agentId;
125410
- if (effectiveParentTaskId && !agentId) {
125977
+ let effectiveAgentId = requestedAgentId;
125978
+ if (effectiveParentTaskId && !requestedAgentId) {
125411
125979
  if (effectiveParentTask?.agentId) {
125412
125980
  effectiveAgentId = effectiveParentTask.agentId;
125413
125981
  }
@@ -125419,13 +125987,13 @@ async function sendTaskHandler(ctx, {
125419
125987
  });
125420
125988
  if (modelError)
125421
125989
  return toolErr(modelError, { data: { yourAgentId: creatorAgentId } });
125422
- const effectiveRoutingReason = agentId !== undefined ? routingReason : effectiveAgentId ? "continuity" : undefined;
125423
- const effectiveRoutingNote = effectiveRoutingReason ? routingNote : undefined;
125424
- const effectiveRoutingSource = agentId !== undefined ? "declared" : effectiveAgentId ? "engine_default" : undefined;
125990
+ const effectiveRoutingReason = requestedAgentId !== undefined ? requestedRoutingReason : effectiveAgentId ? "continuity" : undefined;
125991
+ const effectiveRoutingNote = effectiveRoutingReason ? requestedRoutingNote : undefined;
125992
+ const effectiveRoutingSource = ctx.kind === "user" ? "engine_default" : requestedAgentId !== undefined ? "declared" : effectiveAgentId ? "engine_default" : undefined;
125425
125993
  const requestedTaskOptions = {
125426
125994
  key: assetKey,
125427
- agentId: offerMode ? undefined : effectiveAgentId,
125428
- offeredTo: offerMode ? effectiveAgentId : undefined,
125995
+ agentId: requestedOfferMode ? undefined : effectiveAgentId,
125996
+ offeredTo: requestedOfferMode ? effectiveAgentId : undefined,
125429
125997
  creatorAgentId,
125430
125998
  requestedByUserId,
125431
125999
  source: "mcp",
@@ -125443,14 +126011,14 @@ async function sendTaskHandler(ctx, {
125443
126011
  slackChannelId,
125444
126012
  slackThreadTs,
125445
126013
  slackUserId,
125446
- overrideSlackContext,
126014
+ overrideSlackContext: requestedOverrideSlackContext,
125447
126015
  followUpConfig,
125448
126016
  inheritParentFollowUpConfig: taskType === "resume",
125449
126017
  outputSchema,
125450
126018
  routingReason: effectiveRoutingReason,
125451
126019
  routingSource: effectiveRoutingSource,
125452
126020
  routingNote: effectiveRoutingNote,
125453
- routingAffinity: effectiveLeadOnly || requiredCapabilities?.length ? { leadOnly: effectiveLeadOnly, capabilities: requiredCapabilities ?? [] } : undefined
126021
+ routingAffinity: effectiveLeadOnly || requestedCapabilities?.length ? { leadOnly: effectiveLeadOnly, capabilities: requestedCapabilities ?? [] } : undefined
125454
126022
  };
125455
126023
  const preCreate = await applyPreTaskCreate({
125456
126024
  description: task,
@@ -125467,6 +126035,9 @@ async function sendTaskHandler(ctx, {
125467
126035
  }
125468
126036
  const taskDescription = preCreate.description;
125469
126037
  const taskOptions = preCreate.options;
126038
+ if (ctx.kind === "user" && (taskOptions.agentId !== userLead.id || taskOptions.offeredTo !== undefined)) {
126039
+ return toolErr("A pre.task.create extension cannot change the user task's Lead assignment.");
126040
+ }
125470
126041
  const evaluateDedupGuards = async () => {
125471
126042
  const existingTrackerWork = await findExistingLinearTrackerContextWork(effectiveParentTask?.contextKey, effectiveParentTask?.id);
125472
126043
  if (existingTrackerWork) {
@@ -125474,7 +126045,7 @@ async function sendTaskHandler(ctx, {
125474
126045
  console.log(`[send-task] ${msg}`);
125475
126046
  return { ok: false, message: msg, task: existingTrackerWork.task };
125476
126047
  }
125477
- if (!allowDuplicate && creatorAgentId) {
126048
+ if (!requestedAllowDuplicate && creatorAgentId) {
125478
126049
  const duplicate = await findDuplicateTask({
125479
126050
  taskDescription,
125480
126051
  creatorAgentId: taskOptions.creatorAgentId ?? creatorAgentId,
@@ -125541,6 +126112,12 @@ async function sendTaskHandler(ctx, {
125541
126112
  message: `Agent with ID "${targetAgentId}" not found.`
125542
126113
  };
125543
126114
  }
126115
+ if (ctx.kind === "user" && (!agent.isLead || agent.status === "offline")) {
126116
+ return {
126117
+ success: false,
126118
+ message: "The Lead is no longer online. No task was created."
126119
+ };
126120
+ }
125544
126121
  if (isExtensionAgent(agent)) {
125545
126122
  return { success: false, message: extensionAgentAssignmentError(agent) };
125546
126123
  }
@@ -125550,7 +126127,7 @@ async function sendTaskHandler(ctx, {
125550
126127
  message: `Lead-only task requires a Lead agent; "${agent.name}" is not a Lead.`
125551
126128
  };
125552
126129
  }
125553
- if (!taskOptions.offeredTo && !await hasCapacity(targetAgentId)) {
126130
+ if (ctx.kind !== "user" && !taskOptions.offeredTo && !await hasCapacity(targetAgentId)) {
125554
126131
  const activeCount = await getActiveTaskCount(targetAgentId);
125555
126132
  return {
125556
126133
  success: false,
@@ -125601,7 +126178,7 @@ var registerSendTaskTool = (server) => {
125601
126178
 
125602
126179
  // src/tools/skills/skill-create.ts
125603
126180
  init_zod();
125604
- init_db();
126181
+ init_db2();
125605
126182
  init_rbac();
125606
126183
  var registerSkillCreateTool = (server) => {
125607
126184
  createToolRegistrar(server)("skill-create", {
@@ -125670,7 +126247,7 @@ var registerSkillCreateTool = (server) => {
125670
126247
  };
125671
126248
  // src/tools/skills/skill-delete.ts
125672
126249
  init_zod();
125673
- init_db();
126250
+ init_db2();
125674
126251
  init_rbac();
125675
126252
  var SYSTEM_DEFAULT_SKILL_LOCKED_MESSAGE = "This skill is system-managed and cannot be edited from the UI; it is re-seeded on each start. Fork it under a new name to customize.";
125676
126253
  var registerSkillDeleteTool = (server) => {
@@ -125720,7 +126297,7 @@ var registerSkillDeleteTool = (server) => {
125720
126297
  };
125721
126298
  // src/tools/skills/skill-get.ts
125722
126299
  init_zod();
125723
- init_db();
126300
+ init_db2();
125724
126301
  var registerSkillGetTool = (server) => {
125725
126302
  createToolRegistrar(server)("skill-get", {
125726
126303
  title: "Get Skill",
@@ -125759,7 +126336,7 @@ ${skill.content}`,
125759
126336
  };
125760
126337
  // src/tools/skills/skill-get-file.ts
125761
126338
  init_zod();
125762
- init_db();
126339
+ init_db2();
125763
126340
  var registerSkillGetFileTool = (server) => {
125764
126341
  createToolRegistrar(server)("skill-get-file", {
125765
126342
  title: "Get Skill File",
@@ -125798,7 +126375,7 @@ ${file.content}`,
125798
126375
  };
125799
126376
  // src/tools/skills/skill-install.ts
125800
126377
  init_zod();
125801
- init_db();
126378
+ init_db2();
125802
126379
  init_rbac();
125803
126380
  var registerSkillInstallTool = (server) => {
125804
126381
  createToolRegistrar(server)("skill-install", {
@@ -125857,7 +126434,7 @@ var registerSkillInstallTool = (server) => {
125857
126434
  };
125858
126435
  // src/tools/skills/skill-install-remote.ts
125859
126436
  init_zod();
125860
- init_db();
126437
+ init_db2();
125861
126438
  init_rbac();
125862
126439
  var registerSkillInstallRemoteTool = (server) => {
125863
126440
  createToolRegistrar(server)("skill-install-remote", {
@@ -125955,7 +126532,7 @@ var registerSkillInstallRemoteTool = (server) => {
125955
126532
  };
125956
126533
  // src/tools/skills/skill-list.ts
125957
126534
  init_zod();
125958
- init_db();
126535
+ init_db2();
125959
126536
  function renderSkillList(skills) {
125960
126537
  if (skills.length === 0)
125961
126538
  return;
@@ -126005,7 +126582,7 @@ var registerSkillListTool = (server) => {
126005
126582
  };
126006
126583
  // src/tools/skills/skill-publish.ts
126007
126584
  init_zod();
126008
- init_db();
126585
+ init_db2();
126009
126586
  var registerSkillPublishTool = (server) => {
126010
126587
  createToolRegistrar(server)("skill-publish", {
126011
126588
  title: "Publish Skill",
@@ -126077,7 +126654,7 @@ To reject: close this task with a rejection reason.`;
126077
126654
  };
126078
126655
  // src/tools/skills/skill-search.ts
126079
126656
  init_zod();
126080
- init_db();
126657
+ init_db2();
126081
126658
  function renderSkillList2(skills) {
126082
126659
  if (skills.length === 0)
126083
126660
  return;
@@ -126112,7 +126689,7 @@ var registerSkillSearchTool = (server) => {
126112
126689
  };
126113
126690
  // src/tools/skills/skill-sync-remote.ts
126114
126691
  init_zod();
126115
- init_db();
126692
+ init_db2();
126116
126693
  function contentHash(content) {
126117
126694
  const hash = new Bun.CryptoHasher("sha256").update(content).digest("hex");
126118
126695
  return hash;
@@ -126204,7 +126781,7 @@ var registerSkillSyncRemoteTool = (server) => {
126204
126781
  };
126205
126782
  // src/tools/skills/skill-uninstall.ts
126206
126783
  init_zod();
126207
- init_db();
126784
+ init_db2();
126208
126785
  init_rbac();
126209
126786
  var registerSkillUninstallTool = (server) => {
126210
126787
  createToolRegistrar(server)("skill-uninstall", {
@@ -126248,7 +126825,7 @@ var registerSkillUninstallTool = (server) => {
126248
126825
  };
126249
126826
  // src/tools/skills/skill-update.ts
126250
126827
  init_zod();
126251
- init_db();
126828
+ init_db2();
126252
126829
  init_rbac();
126253
126830
  var SYSTEM_DEFAULT_SKILL_LOCKED_MESSAGE2 = "This skill is system-managed and cannot be edited from the UI; it is re-seeded on each start. Fork it under a new name to customize.";
126254
126831
  var registerSkillUpdateTool = (server) => {
@@ -126352,7 +126929,7 @@ var registerSkillUpdateTool = (server) => {
126352
126929
  };
126353
126930
  // src/tools/slack-archive-channel.ts
126354
126931
  init_zod();
126355
- init_db();
126932
+ init_db2();
126356
126933
  init_rbac();
126357
126934
 
126358
126935
  // src/slack/channel-join.ts
@@ -126530,7 +127107,7 @@ var registerSlackArchiveChannelTool = (server) => {
126530
127107
 
126531
127108
  // src/tools/slack-create-channel.ts
126532
127109
  init_zod();
126533
- init_db();
127110
+ init_db2();
126534
127111
  init_rbac();
126535
127112
  var registerSlackCreateChannelTool = (server) => {
126536
127113
  createToolRegistrar(server)("slack-create-channel", {
@@ -126586,7 +127163,7 @@ var registerSlackCreateChannelTool = (server) => {
126586
127163
 
126587
127164
  // src/tools/slack-delete.ts
126588
127165
  init_zod();
126589
- init_db();
127166
+ init_db2();
126590
127167
  init_rbac();
126591
127168
 
126592
127169
  // src/slack/message-text.ts
@@ -126804,17 +127381,17 @@ var registerSlackDeleteTool = (server) => {
126804
127381
 
126805
127382
  // src/tools/slack-download-file.ts
126806
127383
  init_zod();
126807
- init_db();
127384
+ init_db2();
126808
127385
 
126809
127386
  // src/slack/inbound-files.ts
126810
- init_db();
127387
+ init_db2();
126811
127388
  import { mkdtemp, rm } from "node:fs/promises";
126812
127389
  import { tmpdir as tmpdir2 } from "node:os";
126813
127390
  import { join as join2 } from "node:path";
126814
127391
 
126815
127392
  // src/be/task-attachment-store.ts
126816
127393
  init_secret_scrubber();
126817
- init_db();
127394
+ init_db2();
126818
127395
  var MAX_TASK_ATTACHMENT_BYTES = 50 * 1024 * 1024;
126819
127396
  async function recordTaskAttachmentUpload(input) {
126820
127397
  const { provider, scope, uploaded, contentType } = input;
@@ -127281,7 +127858,7 @@ ${fetchCommand}`,
127281
127858
 
127282
127859
  // src/tools/slack-invite-to-channel.ts
127283
127860
  init_zod();
127284
- init_db();
127861
+ init_db2();
127285
127862
  init_rbac();
127286
127863
  var registerSlackInviteToChannelTool = (server) => {
127287
127864
  createToolRegistrar(server)("slack-invite-to-channel", {
@@ -127336,7 +127913,7 @@ var registerSlackInviteToChannelTool = (server) => {
127336
127913
 
127337
127914
  // src/tools/slack-list-channels.ts
127338
127915
  init_zod();
127339
- init_db();
127916
+ init_db2();
127340
127917
  var SlackChannelSchema = looseObject({
127341
127918
  id: string().optional(),
127342
127919
  name: string().optional(),
@@ -127431,7 +128008,7 @@ var registerSlackListChannelsTool = (server) => {
127431
128008
 
127432
128009
  // src/tools/slack-post.ts
127433
128010
  init_zod();
127434
- init_db();
128011
+ init_db2();
127435
128012
  init_rbac();
127436
128013
  var registerSlackPostTool = (server) => {
127437
128014
  createToolRegistrar(server)("slack-post", {
@@ -127535,7 +128112,7 @@ var registerSlackPostTool = (server) => {
127535
128112
 
127536
128113
  // src/tools/slack-read.ts
127537
128114
  init_zod();
127538
- init_db();
128115
+ init_db2();
127539
128116
  init_rbac();
127540
128117
  var AUTO_DOWNLOAD_DIR = "/app/shared/downloads/slack";
127541
128118
  var SlackFileSchema = looseObject({
@@ -127765,7 +128342,7 @@ ${fileList}`;
127765
128342
 
127766
128343
  // src/tools/slack-reply.ts
127767
128344
  init_zod();
127768
- init_db();
128345
+ init_db2();
127769
128346
  var registerSlackReplyTool = (server) => {
127770
128347
  createToolRegistrar(server)("slack-reply", {
127771
128348
  title: "Reply to Slack thread",
@@ -127905,7 +128482,7 @@ var registerSlackReplyTool = (server) => {
127905
128482
 
127906
128483
  // src/tools/slack-start-thread.ts
127907
128484
  init_zod();
127908
- init_db();
128485
+ init_db2();
127909
128486
  init_rbac();
127910
128487
  var registerSlackStartThreadTool = (server) => {
127911
128488
  createToolRegistrar(server)("slack-start-thread", {
@@ -127994,7 +128571,7 @@ var registerSlackStartThreadTool = (server) => {
127994
128571
 
127995
128572
  // src/tools/slack-update.ts
127996
128573
  init_zod();
127997
- init_db();
128574
+ init_db2();
127998
128575
  init_rbac();
127999
128576
  var registerSlackUpdateTool = (server) => {
128000
128577
  createToolRegistrar(server)("slack-update", {
@@ -128081,7 +128658,7 @@ var registerSlackUpdateTool = (server) => {
128081
128658
 
128082
128659
  // src/tools/slack-upload-file.ts
128083
128660
  init_zod();
128084
- init_db();
128661
+ init_db2();
128085
128662
  init_rbac();
128086
128663
  var WORKSPACE_DIR = "/workspace";
128087
128664
  function resolveTaskUploadThreadTs(task) {
@@ -128273,7 +128850,7 @@ ${triedPathsList}
128273
128850
 
128274
128851
  // src/tools/steer-task.ts
128275
128852
  init_zod();
128276
- init_db();
128853
+ init_db2();
128277
128854
  init_steering();
128278
128855
  init_rbac();
128279
128856
  init_types();
@@ -128370,7 +128947,7 @@ var registerSteerTaskTool = (server) => {
128370
128947
 
128371
128948
  // src/tools/store-progress.ts
128372
128949
  init_zod();
128373
- init_db();
128950
+ init_db2();
128374
128951
  init_rbac();
128375
128952
  init_types();
128376
128953
  init_secret_scrubber();
@@ -128728,7 +129305,7 @@ This check refuses once per task; the next completion is accepted and unfixed ci
128728
129305
 
128729
129306
  // src/tools/swarm-config/delete-config.ts
128730
129307
  init_zod();
128731
- init_db();
129308
+ init_db2();
128732
129309
  init_swarm_config_guard();
128733
129310
  init_rbac();
128734
129311
  var registerDeleteConfigTool = (server) => {
@@ -128800,7 +129377,7 @@ var registerDeleteConfigTool = (server) => {
128800
129377
  };
128801
129378
  // src/tools/swarm-config/get-config.ts
128802
129379
  init_zod();
128803
- init_db();
129380
+ init_db2();
128804
129381
  init_swarm_config_guard();
128805
129382
  init_rbac();
128806
129383
  init_types();
@@ -128891,7 +129468,7 @@ var registerGetConfigTool = (server) => {
128891
129468
  };
128892
129469
  // src/tools/swarm-config/list-config.ts
128893
129470
  init_zod();
128894
- init_db();
129471
+ init_db2();
128895
129472
  init_swarm_config_guard();
128896
129473
  init_rbac();
128897
129474
  init_types();
@@ -128982,7 +129559,7 @@ var registerListConfigTool = (server) => {
128982
129559
  };
128983
129560
  // src/tools/swarm-config/set-config.ts
128984
129561
  init_zod();
128985
- init_db();
129562
+ init_db2();
128986
129563
  init_swarm_config_guard();
128987
129564
  init_rbac();
128988
129565
  init_types();
@@ -129160,7 +129737,7 @@ init_zod();
129160
129737
 
129161
129738
  // src/be/budget-admission.ts
129162
129739
  init_env_flag();
129163
- init_db();
129740
+ init_db2();
129164
129741
  var killSwitchWarned = false;
129165
129742
  function dateUtcFrom(now) {
129166
129743
  return now.toISOString().slice(0, 10);
@@ -129226,7 +129803,7 @@ async function canClaim(agentId, nowUtc, requestedByUserId) {
129226
129803
  // src/be/budget-refusal-notify.ts
129227
129804
  init_resolver();
129228
129805
  init_secret_scrubber();
129229
- init_db();
129806
+ init_db2();
129230
129807
  function formatSpendSummary(ctx) {
129231
129808
  const fmt = (n) => n === undefined ? "?" : `$${n.toFixed(2)}`;
129232
129809
  if (ctx.cause === "agent") {
@@ -129277,7 +129854,7 @@ async function emitBudgetRefusalSideEffects(ctx, inserted) {
129277
129854
  console.warn(`[budget-refusal-notify] Failed to create follow-up task for budget refusal (task=${ctx.task.id.slice(0, 8)}): ${err}`);
129278
129855
  }
129279
129856
  }
129280
- import("./event-bus-z7v2t26e.js").then(({ workflowEventBus: workflowEventBus2 }) => {
129857
+ import("./event-bus-vnfthafg.js").then(({ workflowEventBus: workflowEventBus2 }) => {
129281
129858
  workflowEventBus2.emit("task.budget_refused", {
129282
129859
  taskId: ctx.task.id,
129283
129860
  agentId: ctx.agentId,
@@ -129294,7 +129871,7 @@ async function emitBudgetRefusalSideEffects(ctx, inserted) {
129294
129871
  }
129295
129872
 
129296
129873
  // src/tools/task-action.ts
129297
- init_db();
129874
+ init_db2();
129298
129875
  init_types();
129299
129876
  var TaskActionSchema = _enum([
129300
129877
  "create",
@@ -129833,6 +130410,7 @@ var registerTrackerMapAgentTool = (server) => {
129833
130410
  };
129834
130411
  // src/tools/tracker/tracker-status.ts
129835
130412
  init_zod();
130413
+ init_oauth();
129836
130414
  var registerTrackerStatusTool = (server) => {
129837
130415
  createToolRegistrar(server)("tracker-status", {
129838
130416
  title: "Tracker Status",
@@ -129919,7 +130497,7 @@ var registerTrackerUnlinkTool = (server) => {
129919
130497
  };
129920
130498
  // src/tools/unregister-service.ts
129921
130499
  init_zod();
129922
- init_db();
130500
+ init_db2();
129923
130501
  var registerUnregisterServiceTool = (server) => {
129924
130502
  createToolRegistrar(server)("unregister-service", {
129925
130503
  title: "Unregister Service",
@@ -129974,7 +130552,7 @@ var registerUnregisterServiceTool = (server) => {
129974
130552
 
129975
130553
  // src/tools/update-profile.ts
129976
130554
  init_zod();
129977
- init_db();
130555
+ init_db2();
129978
130556
  init_rbac();
129979
130557
  import { mkdtemp as mkdtemp2, rm as rm2 } from "node:fs/promises";
129980
130558
  import { tmpdir as tmpdir3 } from "node:os";
@@ -130225,7 +130803,7 @@ ${setupScript}
130225
130803
 
130226
130804
  // src/tools/update-service-status.ts
130227
130805
  init_zod();
130228
- init_db();
130806
+ init_db2();
130229
130807
  init_types();
130230
130808
  var serviceOutputShape2 = looseObject({
130231
130809
  id: string().optional(),
@@ -130395,7 +130973,7 @@ var registerCancelWorkflowRunTool = (server) => {
130395
130973
  };
130396
130974
  // src/tools/workflows/create-workflow.ts
130397
130975
  init_zod();
130398
- init_db();
130976
+ init_db2();
130399
130977
  init_types();
130400
130978
 
130401
130979
  // src/workflows/model-validation.ts
@@ -130522,7 +131100,7 @@ var registerCreateWorkflowTool = (server) => {
130522
131100
  };
130523
131101
  // src/tools/workflows/delete-workflow.ts
130524
131102
  init_zod();
130525
- init_db();
131103
+ init_db2();
130526
131104
  var registerDeleteWorkflowTool = (server) => {
130527
131105
  createToolRegistrar(server)("delete-workflow", {
130528
131106
  title: "Delete Workflow",
@@ -130546,7 +131124,7 @@ var registerDeleteWorkflowTool = (server) => {
130546
131124
  };
130547
131125
  // src/tools/workflows/get-workflow.ts
130548
131126
  init_zod();
130549
- init_db();
131127
+ init_db2();
130550
131128
  var registerGetWorkflowTool = (server) => {
130551
131129
  createToolRegistrar(server)("get-workflow", {
130552
131130
  title: "Get Workflow",
@@ -130577,7 +131155,7 @@ var registerGetWorkflowTool = (server) => {
130577
131155
  };
130578
131156
  // src/tools/workflows/get-workflow-run.ts
130579
131157
  init_zod();
130580
- init_db();
131158
+ init_db2();
130581
131159
  var STEP_VALUE_CAP = 400;
130582
131160
  function stepValuePreview(value) {
130583
131161
  if (value === undefined || value === null)
@@ -130617,11 +131195,11 @@ var registerGetWorkflowRunTool = (server) => {
130617
131195
  })
130618
131196
  }, async ({ id: id2 }) => {
130619
131197
  try {
130620
- const run = await getWorkflowRun(id2);
131198
+ const run = await getWorkflowRun(id2, "display");
130621
131199
  if (!run) {
130622
131200
  return toolErr(`Workflow run not found: ${id2}`, { data: { steps: [] } });
130623
131201
  }
130624
- const steps = await getWorkflowRunStepsByRunId(id2);
131202
+ const steps = await getWorkflowRunStepsByRunId(id2, "display");
130625
131203
  return toolOk(`Run ${id2} status: ${run.status}.`, {
130626
131204
  details: renderSteps(steps),
130627
131205
  data: { run, steps }
@@ -130633,7 +131211,7 @@ var registerGetWorkflowRunTool = (server) => {
130633
131211
  };
130634
131212
  // src/tools/workflows/list-workflow-runs.ts
130635
131213
  init_zod();
130636
- init_db();
131214
+ init_db2();
130637
131215
  init_types();
130638
131216
  var DEFAULT_RUN_LIMIT = 20;
130639
131217
  var TRIGGER_DATA_SUMMARY_CAP = 400;
@@ -130717,7 +131295,7 @@ var registerListWorkflowRunsTool = (server) => {
130717
131295
  };
130718
131296
  // src/tools/workflows/list-workflows.ts
130719
131297
  init_zod();
130720
- init_db();
131298
+ init_db2();
130721
131299
  init_types();
130722
131300
  var registerListWorkflowsTool = (server) => {
130723
131301
  createToolRegistrar(server)("list-workflows", {
@@ -130735,9 +131313,9 @@ var registerListWorkflowsTool = (server) => {
130735
131313
  outputSchema: swarmToolOutputSchema({
130736
131314
  workflows: exports_external.array(exports_external.unknown()).optional()
130737
131315
  })
130738
- }, async ({ enabled: enabled2, key, keyPrefix, consecutiveErrorsMin, lastRunStatus, includeFull }) => {
131316
+ }, async ({ enabled, key, keyPrefix, consecutiveErrorsMin, lastRunStatus, includeFull }) => {
130739
131317
  try {
130740
- const filters = { enabled: enabled2, key, keyPrefix, consecutiveErrorsMin, lastRunStatus };
131318
+ const filters = { enabled, key, keyPrefix, consecutiveErrorsMin, lastRunStatus };
130741
131319
  const workflows = includeFull ? await listWorkflows(filters) : await listWorkflows(filters, { slim: true });
130742
131320
  return toolOk(`Found ${workflows.length} workflow(s).`, { data: { workflows } });
130743
131321
  } catch (err) {
@@ -130750,7 +131328,7 @@ init_zod();
130750
131328
  init_types();
130751
131329
 
130752
131330
  // src/workflows/patch-definition.ts
130753
- init_db();
131331
+ init_db2();
130754
131332
  async function patchWorkflowDefinition(options) {
130755
131333
  const { id: id2, patch, registry, snapshotAgentId, snapshotOptional, updates } = options;
130756
131334
  return await getDbClient().transaction(async () => {
@@ -130958,7 +131536,7 @@ var registerRetryWorkflowRunTool = (server) => {
130958
131536
  };
130959
131537
  // src/tools/workflows/trigger-workflow.ts
130960
131538
  init_zod();
130961
- init_db();
131539
+ init_db2();
130962
131540
  var registerTriggerWorkflowTool = (server) => {
130963
131541
  createToolRegistrar(server)("trigger-workflow", {
130964
131542
  title: "Trigger Workflow",
@@ -131025,7 +131603,7 @@ ${bulleted}${schemaBlock}`,
131025
131603
  };
131026
131604
  // src/tools/workflows/update-workflow.ts
131027
131605
  init_zod();
131028
- init_db();
131606
+ init_db2();
131029
131607
  init_types();
131030
131608
  var registerUpdateWorkflowTool = (server) => {
131031
131609
  createToolRegistrar(server)("update-workflow", {
@@ -131062,7 +131640,7 @@ var registerUpdateWorkflowTool = (server) => {
131062
131640
  input,
131063
131641
  dir,
131064
131642
  vcsRepo,
131065
- enabled: enabled2,
131643
+ enabled,
131066
131644
  triggerSchema
131067
131645
  }, requestInfo) => {
131068
131646
  try {
@@ -131094,7 +131672,7 @@ var registerUpdateWorkflowTool = (server) => {
131094
131672
  input: input === null ? null : input,
131095
131673
  dir: dir === null ? null : dir,
131096
131674
  vcsRepo: vcsRepo === null ? null : vcsRepo,
131097
- enabled: enabled2,
131675
+ enabled,
131098
131676
  triggerSchema: triggerSchema === null ? null : triggerSchema,
131099
131677
  updatedBy
131100
131678
  }, { changedByAgentId: requestInfo.agentId });
@@ -131914,8 +132492,17 @@ function bridgeRequestFor(name, args2) {
131914
132492
  };
131915
132493
  }
131916
132494
  case "kv_get":
131917
- case "kv_getOrNull":
131918
- return { method: "GET", path: kvPath(body) };
132495
+ case "kv_getOrNull": {
132496
+ const view = new URLSearchParams;
132497
+ if (typeof body.path === "string")
132498
+ view.set("path", body.path);
132499
+ if (typeof body.offset === "number")
132500
+ view.set("offset", String(body.offset));
132501
+ if (typeof body.limit === "number")
132502
+ view.set("limit", String(body.limit));
132503
+ const qs = view.toString();
132504
+ return { method: "GET", path: qs ? `${kvPath(body)}?${qs}` : kvPath(body) };
132505
+ }
131919
132506
  case "kv_set":
131920
132507
  return {
131921
132508
  method: "PUT",
@@ -132307,12 +132894,12 @@ function createSwarmSdk(config) {
132307
132894
  init_secret_scrubber();
132308
132895
 
132309
132896
  // src/extensions/lifecycle.ts
132310
- init_db();
132897
+ init_db2();
132311
132898
  init_types();
132312
132899
  init_secret_scrubber();
132313
132900
 
132314
132901
  // src/extensions/identity.ts
132315
- init_db();
132902
+ init_db2();
132316
132903
  function extensionAgentName(name) {
132317
132904
  return `ext:${name}`;
132318
132905
  }
@@ -132490,7 +133077,7 @@ async function loadExtension(input) {
132490
133077
  }
132491
133078
 
132492
133079
  // src/extensions/post-bridge.ts
132493
- init_db();
133080
+ init_db2();
132494
133081
  init_secret_scrubber();
132495
133082
  init_event_bus();
132496
133083
  var subscribed3 = false;
@@ -132831,7 +133418,7 @@ async function enableExtension(id2, opts = {}) {
132831
133418
  registerLoaded(loaded);
132832
133419
  try {
132833
133420
  await setAssetsEnabled(id2, true, opts.by);
132834
- const enabled2 = await setExtensionState(id2, {
133421
+ const enabled = await setExtensionState(id2, {
132835
133422
  enabled: true,
132836
133423
  status: "enabled",
132837
133424
  consecutiveFailures: 0,
@@ -132839,11 +133426,11 @@ async function enableExtension(id2, opts = {}) {
132839
133426
  agentId,
132840
133427
  updatedBy: opts.by
132841
133428
  });
132842
- if (!enabled2)
133429
+ if (!enabled)
132843
133430
  throw new ExtensionLifecycleError("Extension not found", 404);
132844
- loaded.record = enabled2;
132845
- attemptedFingerprints.set(id2, extensionFingerprint(enabled2));
132846
- return enabled2;
133431
+ loaded.record = enabled;
133432
+ attemptedFingerprints.set(id2, extensionFingerprint(enabled));
133433
+ return enabled;
132847
133434
  } catch (error) {
132848
133435
  await removeRegistered(id2);
132849
133436
  throw error;
@@ -133933,6 +134520,7 @@ function normalizeExistingTaskOutput(output) {
133933
134520
 
133934
134521
  // src/workflows/executors/notify.ts
133935
134522
  init_zod();
134523
+ init_secret_scrubber();
133936
134524
  var NotifyConfigSchema = exports_external.object({
133937
134525
  channel: exports_external.enum(["swarm", "slack", "email"]),
133938
134526
  target: exports_external.string().optional(),
@@ -133950,7 +134538,7 @@ class NotifyExecutor extends BaseExecutor {
133950
134538
  configSchema = NotifyConfigSchema;
133951
134539
  outputSchema = NotifyOutputSchema;
133952
134540
  async execute(config, context, _meta) {
133953
- const message = this.deps.interpolate(config.template, context);
134541
+ const message = scrubSecrets(this.deps.interpolate(config.template, context));
133954
134542
  switch (config.channel) {
133955
134543
  case "swarm": {
133956
134544
  if (!config.target) {
@@ -133973,7 +134561,7 @@ class NotifyExecutor extends BaseExecutor {
133973
134561
  }
133974
134562
  }
133975
134563
  case "slack": {
133976
- const { getSlackApp: getSlackApp2 } = await import("./app-w2d26h4f.js");
134564
+ const { getSlackApp: getSlackApp2 } = await import("./app-43vrdmv8.js");
133977
134565
  const app = getSlackApp2();
133978
134566
  if (!app) {
133979
134567
  return {
@@ -134040,7 +134628,7 @@ class PropertyMatchExecutor extends BaseExecutor {
134040
134628
  outputSchema = PropertyMatchOutputSchema;
134041
134629
  async execute(config, context, _meta) {
134042
134630
  const results = config.conditions.map((cond) => {
134043
- const actual = resolvePath(context, cond.field);
134631
+ const actual = resolvePath2(context, cond.field);
134044
134632
  const passed2 = evaluateCondition(cond.op, actual, cond.value);
134045
134633
  return { field: cond.field, op: cond.op, expected: cond.value, actual, passed: passed2 };
134046
134634
  });
@@ -134052,7 +134640,7 @@ class PropertyMatchExecutor extends BaseExecutor {
134052
134640
  };
134053
134641
  }
134054
134642
  }
134055
- function resolvePath(obj, path3) {
134643
+ function resolvePath2(obj, path3) {
134056
134644
  const keys2 = path3.split(".");
134057
134645
  let current = obj;
134058
134646
  for (const key of keys2) {
@@ -134326,6 +134914,7 @@ class ScriptExecutor extends BaseExecutor {
134326
134914
 
134327
134915
  // src/workflows/executors/swarm-script.ts
134328
134916
  init_zod();
134917
+ init_db();
134329
134918
  init_constants();
134330
134919
  init_template();
134331
134920
  var SWARM_SCRIPT_DEFAULT_TIMEOUT_MS = DEFAULT_SCRIPT_RESOURCES.wallClockMs;
@@ -134778,4 +135367,4 @@ async function initWorkflows() {
134778
135367
  logOpenWebhookTriggers();
134779
135368
  }
134780
135369
 
134781
- export { DEFAULT_NEGOTIATED_PROTOCOL_VERSION, SUPPORTED_PROTOCOL_VERSIONS, isJSONRPCRequest, isJSONRPCResultResponse, isJSONRPCErrorResponse, JSONRPCMessageSchema, isInitializeRequest, McpServer, isGitHubEnabled, initGitHub, verifyWebhookSignature, isAgentMailEnabled, initAgentMail, verifyAgentMailWebhook, findUserById, findUserByExternalId, getUserIdentities, listUserEvents, listUserTokens, recordIdentityEvent, findOrCreateUserByEmail, linkIdentity, unlinkIdentity, mintToken, revokeToken, resolveUserByToken, mintSessionToken, revokeSessionToken, fingerprintApiKey, resolveIdentity, renderIdentity, createAdditiveBuffer, listHarnessModelSupport, recordHarnessModelSupport, agentRanModel, getAgentHarnessCliVersion, setAgentHarnessCliVersion, sanitizeModelTierOverrides, parseModelTierOverridesHeader, setAgentModelTierOverrides, previewModelTiers, recordClaimModelResolution, harnessModelErrorFor, poolTaskRunsOnHarness, explicitModelError, explicitModelErrorForAgent, referencedBundlePaths, skillDirs, TaskCreationBlockedError, recordUnmappedIdentity, MAX_TASK_ATTACHMENT_BYTES, recordTaskAttachmentUpload, buildEffectiveText, bufferedFileFailures, fetchSlackFiles, createSlackTaskWithFiles, notifySlackFileFailures, hasOtherUserMention, broadcastMatches, routeMessage, extractTaskFromMessage, extractSlackMessageText, automationIntegrationFixUrl, preflightAutomation, getAutomationSetupStates, listEnabledAutomationPreflightInputs, validateJsonSchema, workflowSaveWarnings, TriggerSchemaError, startWorkflowExecution, setupWorkflowResumeListener, retryFailedRun, cancelWorkflowRun, resumeWaitState, initWaitBusSubscriptions, subscribeWaitToBus, recoverIncompleteRuns, startRetryPoller, stopRetryPoller, validateTemplateVariables, instantiateTemplate, handleWebhookTrigger, logOpenWebhookTriggers, handleEventTrigger, handleScheduleTrigger, verifyHmacSignature, WebhookError, snapshotWorkflow, snapshotAndUpdateWorkflow, startWaitPoller, stopWaitPoller, RawLlmConfigSchema, RawLlmOutputSchema, executeRawLlm, getExecutorRegistry, initWorkflows, dispatchScheduleTarget, calculateNextRun, startScheduler, stopScheduler, runScheduleNow, parseSkillContent, ExtensionAssetConflictError, ExtensionOwnershipError, getExtensionFiles, getExtensionById, getExtensionByName, listExtensions, listExtensionVersions, updateExtensionMeta, listExtensionRuns, SDK_ALLOWLIST, mcpToolNameForSdkMethod, mcpOverflowAuthError, toolErr, createToolRegistrar, warnIfCorsAllowsAnyOrigin, isOriginAllowedForCredentials, allowedCredentialRedirect, setCorsHeaders, parseQueryParams, getPathSegments, wireHttpSpanLifecycle, safeRequestUrlForLog, agentWithCapacity, parseBody, BODY_TOO_LARGE, enforceContentLengthCap, json, jsonError, writeUnhandledError, triggerSchemaErrorResponse, deriveApiBaseUrl, httpServerSemconvAttributes, runtimeInstanceHeader, describeRequestRoute, route, handleMcpBridge, Redacted, SCRIPT_SDK_RESPONSE_LIMIT_BYTES, readScriptSdkJsonResponse, ExtensionConfigError, ExtensionLifecycleError, setExtensionLoopbackBaseUrl, enableExtension, disableExtension, activateVersion, ExtensionAssetsInvalidError, installExtensionWithAssets, uninstallExtension, reloadExtension, loadEnabledExtensions, stopExtensionRuntime, ExtensionAbortedError, isRegistered, isExtensionAgentId, getExtensionBridgeToken, resolveBridgeCallOrigin, extensionIdForAgent, runContext, registerLoaded, unregister, listRegistered, dispatchPre, dispatchPost, stripSiblingBlock, createTaskWithSiblingAwareness, isInboxAllowed, isSenderAllowed, handleMessageReceived, isAzureDevOpsEnabled, initAzureDevOps, verifyAzureDevOpsWebhook, isAzureDevOpsUrl, canonicalAzureDevOpsRepoUrl, parseAzureDevOpsRepoUrl, createdPullRequestOf, commentedPayloadOf, handlePullRequestCreated, handlePullRequestCommented, AGENT_MAX_TASKS_CONFIG_KEY, reconcileAgentMaxTasksPolicy, resetAgentMaxTasksMirror, upsertSwarmConfigWithPolicyMirror, runtimeStaleThresholdMinutes, upsertRuntimeInstance, getRuntimeInstanceById, touchRuntimeInstance, countActiveRuntimeInstancesForAgent, listRuntimeInstancesForAgent, setRuntimeCredentialReady, reconcileAgentStatusFromRuntimes, agentsWithLiveRuntime, expireStaleRuntimeInstances, enqueueAuditRow, enqueueAdmissionRow, flushAuditBuffer, startAuditWriter, stopAuditWriter, startAuditGc, stopAuditGc, handlePullRequest, handleIssue, handleComment, handlePullRequestReview, handleCheckRun, handleCheckSuite, handleWorkflowRun, isGitLabEnabled, initGitLab, verifyGitLabWebhook, handleMergeRequest, handleIssue2 as handleIssue1, handleNote, handlePipeline, repointTrackerSyncBySwarmId, getJiraMetadata, updateJiraMetadata, clearJiraMetadata, registerJiraWebhook, deleteJiraWebhook, isJiraEnabled, initJira, handleJiraWebhook, handleAgentSessionEvent, handleIssueUpdate, handleIssueDelete, handleAgentSessionPrompted, isLinearEnabled, initLinear, parseCookieHeader, extractAndVerifyCookie, issuePageSessionCookie, resolveHttpRequestAuth, loadGlobalConfigsIntoEnv, reloadGlobalConfigsAndIntegrations, scheduleIntegrationsReload, handleCore, userCtx, resolveTaskAuditUserId, resolveHttpAuditUserId, resolveHttpFavoriteOwner, handleApps, cancelApprovalRequest, cancelApprovalRequestAndRun, getUserCommsPrefs, getTaskDetailsInputSchema, getTaskDetailsOutputSchema, getTaskDetailsHandler, cancelTaskInputSchema, cancelTaskOutputSchema, cancelTaskHandler, executeReadOnlyQuery, assertSelectOnlyQuery, handleDbQuery, snapshotMetric, AssetKeyAuthorizationError, authorizeAssetKeyWrite, snapshotPage, assertOAuthAppUrlsSafe, assertOAuthEgressUrlSafe, listOAuthPresets, listOAuthPresetIds, getOAuthPreset, hydrateOAuthAppFromPreset, scopedResourceScopeIdSchema, resolveScopedResourceId, dedupeMemoryDocumentIds, recordMemoryAccesses, recordRetrievals, ExplicitSelfDuplicateError, applyRating, shouldPersistAutomaticTaskMemory, REBOOT_RETRY_PIN_TAG, getPinCandidateAgent, resolveLeadOnlyRecoveryAssignment, getResumeGeneration, getNextResumeGeneration, createWorkerTaskFollowUp, createResumeFollowUp, createRerouteDecisionTask, createPoolStarvationDecisionTask, guardTerminalTaskResultWrite, getTasksInputSchema, getTasksOutputSchema, getTasksHandler, reservedNamespaceError, reservedRoomKeyError, updateMcpServerChecked, updateTouchesStdioExecution, MemoryKeyError, refreshLinks, canReadMemory, getLinksForMemory, expandCandidatesWithGraph, indexMemoryContent, isApiDraining, drainApi, markKapsoMessageRead, sendKapsoReaction, getKapsoConfig, getKapsoNumberMapping, markKapsoMessageSeen, changesAllowMerge, updateSwarmRepoChecked, getCombConfig, resolveRoomNamespace, roomRequestInfo, authorizeRoomNamespace, RoomOperationSchema, removeAwarenessStates, roomTopic, decodeRoomSnapshot, roomView, getRoom, changeRoom, applyRoomUpdate, resetRoom, sweepRooms, closeRooms, removeNamespaceRooms, MEMORY_KEYS_DEFAULT_PREFIX, MEMORY_KEYS_MAX_LIMIT, estimateTokens, posteriorMean, listMemoryKeys, checkChunkIntegrity, getMemoryChunks, getPosteriorsByIds, createEvent, createEventsBatch, getEventCountsFiltered, getEventsFiltered, mergeScheduleTiming, validateRecurringTiming, checkOutputSchemaShape, sendTaskOutputSchema, sendTaskHandler, steerTaskUserInputSchema, steerTaskOutputSchema, steerTaskHandler, canClaim, emitBudgetRefusalSideEffects, taskActionInputSchema, taskActionOutputSchema, taskActionHandler, workflowModelErrors, patchWorkflowDefinition, resolveScriptsOnlyMode, ALL_CAPABILITIES, hasCapability, getEnabledCapabilities, createServer };
135370
+ export { DEFAULT_NEGOTIATED_PROTOCOL_VERSION, SUPPORTED_PROTOCOL_VERSIONS, isJSONRPCRequest, isJSONRPCResultResponse, isJSONRPCErrorResponse, JSONRPCMessageSchema, isInitializeRequest, McpServer, isGitHubEnabled, initGitHub, verifyWebhookSignature, isAgentMailEnabled, initAgentMail, verifyAgentMailWebhook, findUserById, findUserByExternalId, getUserIdentities, listUserEvents, listUserTokens, recordIdentityEvent, findOrCreateUserByEmail, linkIdentity, unlinkIdentity, mintToken, revokeToken, resolveUserByToken, mintSessionToken, revokeSessionToken, fingerprintApiKey, resolveIdentity, renderIdentity, createAdditiveBuffer, listHarnessModelSupport, recordHarnessModelSupport, agentRanModel, getAgentHarnessCliVersion, setAgentHarnessCliVersion, sanitizeModelTierOverrides, parseModelTierOverridesHeader, setAgentModelTierOverrides, previewModelTiers, recordClaimModelResolution, harnessModelErrorFor, poolTaskRunsOnHarness, explicitModelError, explicitModelErrorForAgent, referencedBundlePaths, skillDirs, TaskCreationBlockedError, recordUnmappedIdentity, MAX_TASK_ATTACHMENT_BYTES, recordTaskAttachmentUpload, buildEffectiveText, bufferedFileFailures, fetchSlackFiles, createSlackTaskWithFiles, notifySlackFileFailures, hasOtherUserMention, broadcastMatches, routeMessage, extractTaskFromMessage, extractSlackMessageText, automationIntegrationFixUrl, preflightAutomation, getAutomationSetupStates, listEnabledAutomationPreflightInputs, validateJsonSchema, workflowSaveWarnings, TriggerSchemaError, startWorkflowExecution, setupWorkflowResumeListener, retryFailedRun, cancelWorkflowRun, resumeWaitState, initWaitBusSubscriptions, subscribeWaitToBus, recoverIncompleteRuns, startRetryPoller, stopRetryPoller, validateTemplateVariables, instantiateTemplate, handleWebhookTrigger, logOpenWebhookTriggers, handleEventTrigger, handleScheduleTrigger, verifyHmacSignature, WebhookError, snapshotWorkflow, snapshotAndUpdateWorkflow, startWaitPoller, stopWaitPoller, RawLlmConfigSchema, RawLlmOutputSchema, executeRawLlm, getExecutorRegistry, initWorkflows, dispatchScheduleTarget, calculateNextRun, startScheduler, stopScheduler, runScheduleNow, parseSkillContent, ExtensionAssetConflictError, ExtensionOwnershipError, getExtensionFiles, getExtensionById, getExtensionByName, listExtensions, listExtensionVersions, updateExtensionMeta, listExtensionRuns, SDK_ALLOWLIST, mcpToolNameForSdkMethod, mcpOverflowAuthError, hasKvViewArgs, resolveKvView, toolErr, createToolRegistrar, warnIfCorsAllowsAnyOrigin, isOriginAllowedForCredentials, allowedCredentialRedirect, setCorsHeaders, parseQueryParams, getPathSegments, wireHttpSpanLifecycle, safeRequestUrlForLog, agentWithCapacity, parseBody, BODY_TOO_LARGE, enforceContentLengthCap, json, jsonError, writeUnhandledError, triggerSchemaErrorResponse, deriveApiBaseUrl, httpServerSemconvAttributes, runtimeInstanceHeader, describeRequestRoute, route, handleMcpBridge, Redacted, SCRIPT_SDK_RESPONSE_LIMIT_BYTES, readScriptSdkJsonResponse, ExtensionConfigError, ExtensionLifecycleError, setExtensionLoopbackBaseUrl, enableExtension, disableExtension, activateVersion, ExtensionAssetsInvalidError, installExtensionWithAssets, uninstallExtension, reloadExtension, loadEnabledExtensions, stopExtensionRuntime, ExtensionAbortedError, isRegistered, isExtensionAgentId, getExtensionBridgeToken, resolveBridgeCallOrigin, extensionIdForAgent, runContext, registerLoaded, unregister, listRegistered, dispatchPre, dispatchPost, stripSiblingBlock, createTaskWithSiblingAwareness, isInboxAllowed, isSenderAllowed, handleMessageReceived, isAzureDevOpsEnabled, initAzureDevOps, verifyAzureDevOpsWebhook, isAzureDevOpsUrl, canonicalAzureDevOpsRepoUrl, parseAzureDevOpsRepoUrl, createdPullRequestOf, commentedPayloadOf, handlePullRequestCreated, handlePullRequestCommented, AGENT_MAX_TASKS_CONFIG_KEY, reconcileAgentMaxTasksPolicy, resetAgentMaxTasksMirror, upsertSwarmConfigWithPolicyMirror, runtimeStaleThresholdMinutes, upsertRuntimeInstance, getRuntimeInstanceById, touchRuntimeInstance, countActiveRuntimeInstancesForAgent, listRuntimeInstancesForAgent, setRuntimeCredentialReady, reconcileAgentStatusFromRuntimes, agentsWithLiveRuntime, expireStaleRuntimeInstances, enqueueAuditRow, enqueueAdmissionRow, flushAuditBuffer, startAuditWriter, stopAuditWriter, startAuditGc, stopAuditGc, handlePullRequest, handleIssue, handleComment, handlePullRequestReview, handleCheckRun, handleCheckSuite, handleWorkflowRun, isGitLabEnabled, initGitLab, verifyGitLabWebhook, handleMergeRequest, handleIssue2 as handleIssue1, handleNote, handlePipeline, repointTrackerSyncBySwarmId, getJiraMetadata, updateJiraMetadata, clearJiraMetadata, registerJiraWebhook, deleteJiraWebhook, isJiraEnabled, initJira, handleJiraWebhook, handleAgentSessionEvent, handleIssueUpdate, handleIssueDelete, handleAgentSessionPrompted, isLinearEnabled, initLinear, parseCookieHeader, extractAndVerifyCookie, issuePageSessionCookie, resolveHttpRequestAuth, loadGlobalConfigsIntoEnv, reloadGlobalConfigsAndIntegrations, scheduleIntegrationsReload, handleCore, userCtx, resolveTaskAuditUserId, resolveHttpAuditUserId, resolveHttpFavoriteOwner, handleApps, cancelApprovalRequest, cancelApprovalRequestAndRun, getUserCommsPrefs, getTaskDetailsInputSchema, getTaskDetailsOutputSchema, getTaskDetailsHandler, cancelTaskInputSchema, cancelTaskOutputSchema, cancelTaskHandler, executeReadOnlyQuery, assertSelectOnlyQuery, handleDbQuery, snapshotMetric, AssetKeyAuthorizationError, authorizeAssetKeyWrite, snapshotPage, assertOAuthAppUrlsSafe, assertOAuthEgressUrlSafe, listOAuthPresets, listOAuthPresetIds, getOAuthPreset, hydrateOAuthAppFromPreset, scopedResourceScopeIdSchema, resolveScopedResourceId, dedupeMemoryDocumentIds, recordMemoryAccesses, recordRetrievals, ExplicitSelfDuplicateError, applyRating, shouldPersistAutomaticTaskMemory, REBOOT_RETRY_PIN_TAG, getPinCandidateAgent, resolveLeadOnlyRecoveryAssignment, getResumeGeneration, getNextResumeGeneration, createWorkerTaskFollowUp, createResumeFollowUp, createRerouteDecisionTask, createPoolStarvationDecisionTask, guardTerminalTaskResultWrite, getTasksInputSchema, getTasksOutputSchema, getTasksHandler, reservedNamespaceError, reservedRoomKeyError, updateMcpServerChecked, updateTouchesStdioExecution, MemoryKeyError, refreshLinks, canReadMemory, getLinksForMemory, expandCandidatesWithGraph, indexMemoryContent, isApiDraining, drainApi, markKapsoMessageRead, sendKapsoReaction, getKapsoConfig, getKapsoNumberMapping, markKapsoMessageSeen, changesAllowMerge, updateSwarmRepoChecked, getCombConfig, resolveRoomNamespace, roomRequestInfo, authorizeRoomNamespace, RoomOperationSchema, removeAwarenessStates, roomTopic, decodeRoomSnapshot, roomView, getRoom, changeRoom, applyRoomUpdate, resetRoom, sweepRooms, closeRooms, removeNamespaceRooms, MEMORY_KEYS_DEFAULT_PREFIX, MEMORY_KEYS_MAX_LIMIT, estimateTokens, posteriorMean, listMemoryKeys, checkChunkIntegrity, getMemoryChunks, getPosteriorsByIds, createEvent, createEventsBatch, getEventCountsFiltered, getEventsFiltered, mergeScheduleTiming, validateRecurringTiming, checkOutputSchemaShape, sendTaskOutputSchema, sendTaskHandler, steerTaskUserInputSchema, steerTaskOutputSchema, steerTaskHandler, canClaim, emitBudgetRefusalSideEffects, workflowModelErrors, patchWorkflowDefinition, resolveScriptsOnlyMode, ALL_CAPABILITIES, hasCapability, getEnabledCapabilities, createServer };