@desplega.ai/agent-swarm 1.131.1 → 1.134.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 (360) hide show
  1. package/README.md +3 -3
  2. package/dist/{actions-jgcy477k.js → actions-7kast243.js} +20 -18
  3. package/dist/{anthropic-messages-rjmd2e7n.js → anthropic-messages-706yad38.js} +33 -17
  4. package/dist/app-0g84t8wf.js +28 -0
  5. package/dist/{artifact-jysj3wrg.js → artifact-dje5ke4h.js} +37 -131
  6. package/dist/{assistant-f2vkk1hj.js → assistant-ac4htcky.js} +25 -22
  7. package/dist/{azure-openai-responses-c0yjmbfd.js → azure-openai-responses-be59fbsz.js} +13 -13
  8. package/dist/{boot-reembed-q7mp8hcr.js → boot-reembed-b1rcqn85.js} +13 -11
  9. package/dist/{boot-reembed-xmw8wcx6.js → boot-reembed-kw2541c4.js} +14 -12
  10. package/dist/{boot-scrub-logs-dsqrv79n.js → boot-scrub-logs-ja29t92g.js} +11 -9
  11. package/dist/{claude-adapter-q6x7yspx.js → claude-adapter-5cg1fv8s.js} +33 -29
  12. package/dist/{claude-managed-adapter-wsg37bt8.js → claude-managed-adapter-9z9sdytx.js} +9 -9
  13. package/dist/{claude-managed-setup-52z4mq9w.js → claude-managed-setup-3zqp51cr.js} +5 -5
  14. package/dist/{claude-1ex232fc.js → claude-wqn3dtca.js} +1 -1
  15. package/dist/{cli-4wgngmwv.js → cli-00w4hbam.js} +1 -1
  16. package/dist/{cli-er3a4bb0.js → cli-15429qdw.js} +6 -1
  17. package/dist/{cli-e5dabkx0.js → cli-1cwhyvta.js} +4 -4
  18. package/dist/{cli-zsspvvm2.js → cli-1ybr6vw2.js} +237 -237
  19. package/dist/{cli-xpxde7rm.js → cli-2wv4kj0e.js} +60 -31
  20. package/dist/cli-34w2584r.js +530 -0
  21. package/dist/{cli-se2p6rkb.js → cli-38taxznr.js} +6 -6
  22. package/dist/{cli-9sbhdpvb.js → cli-3cgfyfzm.js} +14 -14
  23. package/dist/{cli-5n6e5yfn.js → cli-3zmdzfjf.js} +79 -74
  24. package/dist/{cli-3ty0t082.js → cli-43x36mty.js} +197 -8
  25. package/dist/{cli-ycrnynpw.js → cli-480nehnh.js} +29 -22
  26. package/dist/{cli-0258203w.js → cli-492e7ap5.js} +140 -20
  27. package/dist/{cli-3fj60etf.js → cli-497b685t.js} +3 -3
  28. package/dist/{cli-pxfxkx5m.js → cli-4bap00k0.js} +1 -1
  29. package/dist/{cli-w2wxd56v.js → cli-4bc8vmhm.js} +848 -770
  30. package/dist/{cli-aca5pz9f.js → cli-589599p9.js} +1 -1
  31. package/dist/{cli-t930g0xh.js → cli-5tnr64pm.js} +1 -1
  32. package/dist/{cli-jxg3s9ey.js → cli-65d93ves.js} +7 -7
  33. package/dist/{cli-6dpytdr2.js → cli-6x363v1z.js} +2 -2
  34. package/dist/{cli-dxak0fqd.js → cli-787ph852.js} +11 -11
  35. package/dist/{cli-793jvbsh.js → cli-7bv8nckk.js} +16 -11
  36. package/dist/{cli-zyxs93y9.js → cli-7jcc9y1r.js} +3 -3
  37. package/dist/{cli-f1am9szv.js → cli-87t2gstf.js} +1 -1
  38. package/dist/{cli-9aryf9tv.js → cli-95m51ztz.js} +1 -1
  39. package/dist/{cli-4w4fmq9x.js → cli-9w49enmh.js} +2 -2
  40. package/dist/{cli-v69vk5h0.js → cli-9y5b02vr.js} +13 -13
  41. package/dist/{cli-x23me2mg.js → cli-a1rrkrb4.js} +1 -1
  42. package/dist/{cli-psrqtw2m.js → cli-a3pkfpqs.js} +2 -2
  43. package/dist/{cli-h0rgxd24.js → cli-a4ajmfvp.js} +6 -6
  44. package/dist/{cli-ygrbmjja.js → cli-aw8bb6sf.js} +6 -6
  45. package/dist/{cli-g74vpjp2.js → cli-brm3et47.js} +55 -22
  46. package/dist/{cli-czkae1fp.js → cli-c5ddbdfj.js} +9 -9
  47. package/dist/{cli-114fvtmj.js → cli-c79a9zrc.js} +1 -1
  48. package/dist/{cli-49n9f49x.js → cli-dx3dz0ms.js} +3 -3
  49. package/dist/{cli-6dp3ydxa.js → cli-e07exmsb.js} +18 -14
  50. package/dist/cli-et1bbwqf.js +13 -0
  51. package/dist/{cli-yazx6hap.js → cli-f3s9dry0.js} +14 -14
  52. package/dist/{cli-t8d349cy.js → cli-f4wj0s3m.js} +3 -3
  53. package/dist/{cli-d6n0thxw.js → cli-f64gdfxc.js} +1 -1
  54. package/dist/{cli-pwfsqc2x.js → cli-fyd58xgb.js} +55 -55
  55. package/dist/{cli-7dm2zqy2.js → cli-g0j14czv.js} +2 -2
  56. package/dist/{cli-b0p7rfnd.js → cli-g2p9bd1z.js} +14 -14
  57. package/dist/{cli-z905tvmm.js → cli-g814jbst.js} +2 -2
  58. package/dist/{cli-5dsbcjjw.js → cli-ghexzd2d.js} +970 -970
  59. package/dist/{cli-jvv0g8bh.js → cli-gpt9kf01.js} +15 -15
  60. package/dist/{cli-rgrfzg8z.js → cli-grt6qv91.js} +380 -380
  61. package/dist/{cli-wz9115x0.js → cli-gtafvdy0.js} +8 -8
  62. package/dist/{cli-q5dzzak0.js → cli-gy07xk4s.js} +2 -2
  63. package/dist/{cli-sy7jk3tx.js → cli-h0djenzm.js} +2 -2
  64. package/dist/{cli-nrkkknat.js → cli-h37gbjbf.js} +2 -281
  65. package/dist/{cli-jevgrb4w.js → cli-h39xxnq6.js} +1200 -491
  66. package/dist/{cli-gz9sbyk3.js → cli-jepmgn7r.js} +1 -1
  67. package/dist/{cli-ccf9vy7q.js → cli-jmvk6et8.js} +7 -7
  68. package/dist/{cli-2rk0cx7s.js → cli-jxj92gkt.js} +51 -41
  69. package/dist/{cli-bqw0mt1n.js → cli-k46t4664.js} +18 -3
  70. package/dist/{cli-50vbt00w.js → cli-m07313tr.js} +1153 -696
  71. package/dist/{cli-4j2mrzag.js → cli-mkq1rk7b.js} +1 -1
  72. package/dist/{cli-1z7048dy.js → cli-mnm7w46e.js} +1 -1
  73. package/dist/{cli-kd1ck4rx.js → cli-mp9sg4cg.js} +14 -8
  74. package/dist/{cli-jbcva0xj.js → cli-mrammd8c.js} +60 -35
  75. package/dist/cli-nanaxrz6.js +27 -0
  76. package/dist/{cli-p9swy5t3.js → cli-pq2ee5ja.js} +8 -6
  77. package/dist/{cli-2wadx7p2.js → cli-pt43pdp1.js} +2 -2
  78. package/dist/{cli-7sgrxg9a.js → cli-q6d0vvey.js} +4 -4
  79. package/dist/{cli-k9qkf1hw.js → cli-qf9kpsve.js} +9 -9
  80. package/dist/cli-qh4sqfws.js +15 -0
  81. package/dist/{cli-e15jhafb.js → cli-qntkxysp.js} +14 -14
  82. package/dist/{cli-sajgpkqg.js → cli-qs9hhsvb.js} +1723 -325
  83. package/dist/{cli-z2zcxes1.js → cli-qt5bt3vk.js} +1 -1
  84. package/dist/{cli-wx82tw1k.js → cli-qtekrty1.js} +3 -3
  85. package/dist/{cli-g1re8r05.js → cli-rh6f3s9n.js} +3 -3
  86. package/dist/{cli-n0krnc6d.js → cli-rzhcrw2p.js} +2 -2
  87. package/dist/{cli-gecy3z2s.js → cli-snw62ze5.js} +4 -4
  88. package/dist/{cli-n6h8qt8n.js → cli-snz3p4yf.js} +15 -10
  89. package/dist/{cli-r6kqqbj0.js → cli-tkf8n6cw.js} +11 -11
  90. package/dist/{cli-4rkfg1wx.js → cli-tkrr24mz.js} +14 -9
  91. package/dist/{cli-9dr5qzc0.js → cli-tv9f1kyb.js} +54 -43
  92. package/dist/{cli-gm9cbhbq.js → cli-vtz6yj3v.js} +28 -9
  93. package/dist/{cli-2f07m0xr.js → cli-wf86d5t7.js} +1 -1
  94. package/dist/{cli-7zd05xb4.js → cli-whrvct19.js} +45 -45
  95. package/dist/{cli-ap1czx8f.js → cli-wrrea8xm.js} +3 -3
  96. package/dist/{cli-57khth04.js → cli-xmyqv00z.js} +120 -4
  97. package/dist/{cli-cwy5hqbq.js → cli-yjmk7tzc.js} +1 -1
  98. package/dist/{cli-6pcz9h15.js → cli-zykjrwcx.js} +180 -394
  99. package/dist/cli.js +45 -45
  100. package/dist/{codex-adapter-htjkn22b.js → codex-adapter-hsq6mz3m.js} +21 -19
  101. package/dist/{codex-hook-hq54t9ft.js → codex-hook-8c500gq8.js} +8 -7
  102. package/dist/{codex-login-z6yhbkmk.js → codex-login-x7603481.js} +3 -3
  103. package/dist/{codex-session-runner-wjfc7smz.js → codex-session-runner-c1x3x143.js} +15 -13
  104. package/dist/{commands-xhrfwqsk.js → commands-rwtddtst.js} +11 -9
  105. package/dist/{db-anvwb22f.js → db-j2b355vz.js} +458 -444
  106. package/dist/{devin-adapter-v1sarqtw.js → devin-adapter-8qmhqpy3.js} +3 -3
  107. package/dist/{devtools-2y1r7yqk.js → devtools-j2rnj8w7.js} +4 -4
  108. package/dist/{e2b-jdkwemv2.js → e2b-znpx78eg.js} +16 -16
  109. package/dist/{es5-vjgtkgp6.js → es5-fmqrjzy3.js} +2 -2
  110. package/dist/{event-bus-axn823e9.js → event-bus-n8sb35pw.js} +4 -4
  111. package/dist/{getMachineId-bsd-6tc9wxdj.js → getMachineId-bsd-wpzbhkm6.js} +4 -4
  112. package/dist/{getMachineId-darwin-sjt9sgnc.js → getMachineId-darwin-45zabjy0.js} +4 -4
  113. package/dist/{getMachineId-linux-v5n18y9p.js → getMachineId-linux-warnp5pd.js} +3 -3
  114. package/dist/{getMachineId-unsupported-yrjyqw3d.js → getMachineId-unsupported-5spent2a.js} +3 -3
  115. package/dist/{getMachineId-win-w3r8063c.js → getMachineId-win-v4bvcw7a.js} +4 -4
  116. package/dist/{google-generative-ai-hysrd8qx.js → google-generative-ai-b0wzss55.js} +17 -14
  117. package/dist/{google-vertex-p5arrga0.js → google-vertex-e8q4dpya.js} +18 -15
  118. package/dist/{handlers-b9kbc621.js → handlers-hchgrxkh.js} +32 -29
  119. package/dist/{hook-xkvn6c5h.js → hook-p49egqc0.js} +66 -52
  120. package/dist/hook-spb00w76.js +34 -0
  121. package/dist/{http-9xh6ta4r.js → http-nh14kkms.js} +663 -181
  122. package/dist/index-1qthq7vc.js +6 -0
  123. package/dist/{index-0g68f0p6.js → index-20xqmn3v.js} +3 -3
  124. package/dist/{index-vdkr5z2w.js → index-3e03k6e4.js} +114 -114
  125. package/dist/{index-ywds4812.js → index-4cbyhq2g.js} +43 -41
  126. package/dist/index-67pzqfrb.js +36 -0
  127. package/dist/{index-bccrkdkn.js → index-7m8yxkw5.js} +16 -16
  128. package/dist/{index-eaxyqcmj.js → index-dvsk64sm.js} +163 -83
  129. package/dist/{index-dqkpnmqm.js → index-e19s2m8k.js} +18 -18
  130. package/dist/{index-j30k5zxn.js → index-emvxcy98.js} +16 -16
  131. package/dist/{index-7ndw6ecy.js → index-gqnmr60d.js} +9 -9
  132. package/dist/{index-9znhar3x.js → index-j02xvjtd.js} +184 -185
  133. package/dist/{index-1s2442yw.js → index-ns5kksc1.js} +7 -7
  134. package/dist/{index-dpy2hth8.js → index-pdxc8kfh.js} +71 -71
  135. package/dist/{index-z1m7pw0v.js → index-ptcqm8bc.js} +107 -107
  136. package/dist/{index-070v4eyb.js → index-pyp7rexm.js} +5 -6
  137. package/dist/{index-86znjz1p.js → index-shne41sd.js} +13 -13
  138. package/dist/{index-2qn2qndv.js → index-t36q2v4t.js} +183 -183
  139. package/dist/index-tcnvv8w6.js +7 -0
  140. package/dist/index-w91qbfv1.js +7 -0
  141. package/dist/{index-fzc0mwvj.js → index-yqweff5n.js} +32 -32
  142. package/dist/index-yrfphye1.js +39 -0
  143. package/dist/{keepalive-vc7s2aa6.js → keepalive-9k51nqhc.js} +21 -15
  144. package/dist/lead-2xq3dxbz.js +88 -0
  145. package/dist/maintenance-0c0g6nym.js +28 -0
  146. package/dist/mistral-conversations-2njwdwhj.js +717 -0
  147. package/dist/{multipart-parser-qaktc7p8.js → multipart-parser-6gftesw0.js} +2 -2
  148. package/dist/{oauth-refresh-sweep-yecgjpk4.js → oauth-refresh-sweep-273a64r2.js} +14 -12
  149. package/dist/{onboard-xj0f73f9.js → onboard-tsv9wwhz.js} +12 -12
  150. package/dist/{openai-codex-responses-5g27pd6f.js → openai-codex-responses-kt84eq86.js} +26 -26
  151. package/dist/{openai-completions-3vkmfz2a.js → openai-completions-mrypq7qp.js} +17 -16
  152. package/dist/{openai-responses-dg4t7j7a.js → openai-responses-qhrk21ez.js} +20 -17
  153. package/dist/{opencode-adapter-1gm38aba.js → opencode-adapter-rar9676j.js} +13 -11
  154. package/dist/{openrouter-images-g3gm8931.js → openrouter-images-684fysx9.js} +5 -5
  155. package/dist/{otel-impl-nxg0n0b3.js → otel-impl-wp1mfzd2.js} +752 -537
  156. package/dist/{photon_rs-ky7dj5qw.js → photon_rs-8dwt2pzy.js} +581 -581
  157. package/dist/{pi-messages-tqj8q6b9.js → pi-messages-txp9f97r.js} +7 -7
  158. package/dist/{pi-mono-adapter-4g5kby31.js → pi-mono-adapter-yz47kk8e.js} +1910 -1180
  159. package/dist/pricing-refresh-jw1yw2fn.js +22 -0
  160. package/dist/rbac-roles-dg964c8p.js +32 -0
  161. package/dist/{rbac-roles-1hcxdtg7.js → rbac-roles-p53cg5cv.js} +19 -17
  162. package/dist/{registry-02cy9z5z.js → registry-mh12y17v.js} +4 -4
  163. package/dist/render-v2-56vn2rk9.js +36 -0
  164. package/dist/seed-pricing-52xx6z63.js +19 -0
  165. package/dist/{setup-46xtgq3c.js → setup-e8gp79sy.js} +7 -7
  166. package/dist/token-util-zy908s1a.js +6 -0
  167. package/dist/{token-fxkn2zf2.js → token-xg5711x5.js} +4 -4
  168. package/dist/worker-s17f1g46.js +88 -0
  169. package/dist/{x-6mg4kfpe.js → x-xkfh0w0v.js} +5 -5
  170. package/openapi.json +566 -22
  171. package/package.json +6 -6
  172. package/src/be/budget-refusal-notify.ts +14 -7
  173. package/src/be/db-queries/task-artifacts.ts +182 -0
  174. package/src/be/db.ts +834 -171
  175. package/src/be/events.ts +5 -0
  176. package/src/be/migrations/131_session_logs_created_at_index.sql +2 -0
  177. package/src/be/migrations/132_multi_runtime_instances.sql +44 -0
  178. package/src/be/migrations/133_workflow_run_trigger_type.sql +12 -0
  179. package/src/be/migrations/135_backfill_task_pull_request_attachments.sql +228 -0
  180. package/src/be/migrations/136_task_requester_provenance.sql +37 -0
  181. package/src/be/migrations/137_memory_retrieval_composite_index.sql +1 -0
  182. package/src/be/migrations/runner.ts +17 -11
  183. package/src/be/multi-runtime.ts +430 -0
  184. package/src/be/scripts/extract-schema.ts +3 -1
  185. package/src/be/scripts/typecheck.ts +6 -2
  186. package/src/be/seed-prompt-templates.ts +25 -2
  187. package/src/be/seed-skills/index.ts +7 -0
  188. package/src/be/steering.ts +1 -1
  189. package/src/be/swarm-config-guard.ts +18 -0
  190. package/src/commands/credential-wait.ts +54 -0
  191. package/src/commands/onboard/steps/core-credentials.tsx +1 -1
  192. package/src/commands/onboard/steps/custom-templates.tsx +1 -1
  193. package/src/commands/onboard/steps/harness-credentials.tsx +1 -1
  194. package/src/commands/onboard/steps/health-check.tsx +1 -1
  195. package/src/commands/onboard/steps/start.tsx +1 -1
  196. package/src/commands/profile-sync-audit.ts +56 -0
  197. package/src/commands/profile-sync.ts +287 -15
  198. package/src/commands/provider-credentials.ts +46 -19
  199. package/src/commands/runner.ts +199 -33
  200. package/src/commands/templates.ts +22 -0
  201. package/src/github/handlers.ts +55 -9
  202. package/src/heartbeat/heartbeat.ts +109 -17
  203. package/src/hooks/hook.ts +49 -33
  204. package/src/http/active-sessions.ts +11 -1
  205. package/src/http/agents.ts +261 -30
  206. package/src/http/all-routes.ts +1 -0
  207. package/src/http/config.ts +13 -2
  208. package/src/http/core.ts +102 -4
  209. package/src/http/db-query-bounded.ts +313 -0
  210. package/src/http/db-query-shared.ts +249 -0
  211. package/src/http/db-query.ts +54 -42
  212. package/src/http/events.ts +2 -0
  213. package/src/http/index.ts +23 -2
  214. package/src/http/mcp-bridge.ts +37 -3
  215. package/src/http/mcp.ts +12 -0
  216. package/src/http/memory.ts +13 -2
  217. package/src/http/openapi.ts +1 -0
  218. package/src/http/poll.ts +70 -27
  219. package/src/http/prompt-templates.ts +36 -13
  220. package/src/http/route-def.ts +43 -9
  221. package/src/http/schedules.ts +2 -2
  222. package/src/http/scripts.ts +10 -1
  223. package/src/http/session-data.ts +44 -0
  224. package/src/http/tasks.ts +2 -2
  225. package/src/http/users.ts +74 -52
  226. package/src/http/webhooks.ts +5 -2
  227. package/src/http/workflows.ts +1 -4
  228. package/src/integrations/kapso/inbound.ts +1 -1
  229. package/src/jira/outbound.ts +39 -8
  230. package/src/jira/webhook-lifecycle.ts +13 -2
  231. package/src/linear/outbound.ts +43 -10
  232. package/src/oauth/keepalive.ts +13 -2
  233. package/src/prompts/base-prompt.ts +1 -1
  234. package/src/prompts/default-drift.ts +21 -0
  235. package/src/prompts/session-templates.ts +56 -7
  236. package/src/providers/claude-adapter.ts +6 -0
  237. package/src/providers/codex-adapter.ts +6 -0
  238. package/src/providers/opencode-adapter.ts +6 -0
  239. package/src/providers/pi-mono-adapter.ts +8 -0
  240. package/src/providers/pricing-sources.md +24 -0
  241. package/src/queue-stall-alarm.ts +216 -0
  242. package/src/rbac/legacy-policy.ts +3 -0
  243. package/src/rbac/permissions.ts +12 -0
  244. package/src/scheduler/scheduler.ts +7 -0
  245. package/src/script-workflows/executor.ts +2 -1
  246. package/src/scripts-runtime/executors/native.ts +2 -1
  247. package/src/scripts-runtime/executors/types.ts +5 -0
  248. package/src/scripts-runtime/loader.ts +5 -0
  249. package/src/scripts-runtime/sdk-allowlist.ts +3 -0
  250. package/src/scripts-runtime/swarm-config.ts +8 -0
  251. package/src/scripts-runtime/swarm-sdk.ts +7 -0
  252. package/src/scripts-runtime/types/stdlib.d.ts +4 -0
  253. package/src/scripts-runtime/types/swarm-sdk.d.ts +4 -0
  254. package/src/server.ts +6 -0
  255. package/src/slack/channel-join.ts +22 -3
  256. package/src/slack/channel-lifecycle.ts +114 -0
  257. package/src/tests/budget-claim-gate.test.ts +20 -0
  258. package/src/tests/claude-adapter.test.ts +32 -0
  259. package/src/tests/codex-adapter.test.ts +30 -0
  260. package/src/tests/create-task-validation.test.ts +128 -0
  261. package/src/tests/credential-wait.test.ts +67 -1
  262. package/src/tests/db-query.test.ts +711 -2
  263. package/src/tests/heartbeat-checklist.test.ts +28 -0
  264. package/src/tests/http-api-integration.test.ts +81 -0
  265. package/src/tests/http-users.test.ts +166 -1
  266. package/src/tests/identity-field-budget.test.ts +176 -0
  267. package/src/tests/mcp-tools-user.test.ts +34 -0
  268. package/src/tests/mcp-user-route.test.ts +17 -0
  269. package/src/tests/metrics-http.test.ts +44 -0
  270. package/src/tests/migration-failure.test.ts +86 -0
  271. package/src/tests/multi-runtime-registration.test.ts +2810 -0
  272. package/src/tests/openapi-response-contract.test.ts +24 -0
  273. package/src/tests/openapi-route-headers.test.ts +83 -0
  274. package/src/tests/opencode-adapter.test.ts +40 -0
  275. package/src/tests/outbound-listener-rejection.test.ts +138 -0
  276. package/src/tests/pi-mono-adapter.test.ts +98 -0
  277. package/src/tests/preload.ts +2 -0
  278. package/src/tests/profile-sync-warning.test.ts +277 -0
  279. package/src/tests/profile-sync.test.ts +232 -6
  280. package/src/tests/prompt-template-resolver.test.ts +177 -6
  281. package/src/tests/prompt-template-session.test.ts +39 -3
  282. package/src/tests/queue-stall-alarm.test.ts +226 -0
  283. package/src/tests/rbac-charact-slack.test.ts +29 -0
  284. package/src/tests/rbac-engine.test.ts +3 -0
  285. package/src/tests/requester-comms.test.ts +32 -0
  286. package/src/tests/runner-requester-profile.test.ts +38 -0
  287. package/src/tests/schedule-target-type.test.ts +38 -0
  288. package/src/tests/script-connections.test.ts +13 -1
  289. package/src/tests/scripts-runtime-identity.test.ts +375 -0
  290. package/src/tests/scripts-runtime.test.ts +4 -3
  291. package/src/tests/sdk-allowlist.test.ts +47 -0
  292. package/src/tests/send-task-requested-by.test.ts +9 -0
  293. package/src/tests/session-costs.test.ts +506 -1
  294. package/src/tests/shutdown-error-scrubbing.test.ts +92 -0
  295. package/src/tests/slack-channel-lifecycle.test.ts +241 -0
  296. package/src/tests/slack-render-v2.test.ts +43 -0
  297. package/src/tests/steering-core.test.ts +28 -0
  298. package/src/tests/swarm-config-reserved-keys.test.ts +22 -0
  299. package/src/tests/task-artifacts.test.ts +386 -0
  300. package/src/tests/task-attachments-schema.test.ts +17 -1
  301. package/src/tests/task-completion-idempotency.test.ts +57 -0
  302. package/src/tests/task-pull-request-backfill-migration.test.ts +321 -0
  303. package/src/tests/tool-annotations.test.ts +4 -0
  304. package/src/tests/update-profile-api.test.ts +67 -39
  305. package/src/tests/update-profile-auth.test.ts +48 -4
  306. package/src/tests/user-attribution-migration.test.ts +54 -0
  307. package/src/tests/user-identity.test.ts +72 -0
  308. package/src/tests/workflow-async-v2.test.ts +39 -1
  309. package/src/tests/workflow-http-v2.test.ts +3 -2
  310. package/src/tests/workflow-mcp-trigger-schema.test.ts +52 -3
  311. package/src/tests/workflow-retry-v2.test.ts +45 -1
  312. package/src/tools/db-query.ts +18 -8
  313. package/src/tools/get-task-details.ts +24 -3
  314. package/src/tools/manage-user.ts +36 -3
  315. package/src/tools/poll-task.ts +93 -14
  316. package/src/tools/script-common.ts +5 -0
  317. package/src/tools/send-task.ts +1 -4
  318. package/src/tools/slack-archive-channel.ts +70 -0
  319. package/src/tools/slack-create-channel.ts +74 -0
  320. package/src/tools/slack-invite-to-channel.ts +78 -0
  321. package/src/tools/store-progress.ts +13 -2
  322. package/src/tools/swarm-config/delete-config.ts +9 -0
  323. package/src/tools/swarm-config/set-config.ts +3 -2
  324. package/src/tools/task-action.ts +30 -0
  325. package/src/tools/task-tool-ctx.ts +8 -1
  326. package/src/tools/tool-config.ts +4 -1
  327. package/src/tools/update-profile.ts +16 -21
  328. package/src/tools/utils.ts +5 -0
  329. package/src/tools/workflows/trigger-workflow.ts +7 -1
  330. package/src/types.ts +165 -1
  331. package/src/utils/github-pull-request.ts +76 -0
  332. package/src/utils/identity-field-budget.ts +73 -0
  333. package/src/utils/multi-runtime.ts +20 -0
  334. package/src/utils/requester-comms.ts +24 -0
  335. package/src/workflows/engine.ts +22 -2
  336. package/src/workflows/resume.ts +19 -11
  337. package/src/workflows/retry-poller.ts +1 -0
  338. package/src/workflows/triggers.ts +4 -0
  339. package/templates/skills/db-query-guidance/config.json +14 -0
  340. package/templates/skills/db-query-guidance/content.md +57 -0
  341. package/dist/app-5da78bd4.js +0 -26
  342. package/dist/cli-3te4jdkm.js +0 -225
  343. package/dist/cli-bmze986d.js +0 -7
  344. package/dist/cli-kh3ba2zf.js +0 -607
  345. package/dist/hook-cgk4wxmx.js +0 -31
  346. package/dist/index-25wjsdv2.js +0 -34
  347. package/dist/index-76at2ymp.js +0 -7
  348. package/dist/index-hase6zbe.js +0 -6
  349. package/dist/index-vg4snay4.js +0 -36
  350. package/dist/index-vy8edt27.js +0 -7
  351. package/dist/lead-r2yqfmx7.js +0 -85
  352. package/dist/maintenance-mw70k468.js +0 -26
  353. package/dist/mistral-conversations-81fwav0j.js +0 -30578
  354. package/dist/otel-nqa12wf3.js +0 -3149
  355. package/dist/pricing-refresh-2cn6effr.js +0 -20
  356. package/dist/rbac-roles-vynday5g.js +0 -30
  357. package/dist/render-v2-tc0bh8kk.js +0 -34
  358. package/dist/seed-pricing-8kceb43f.js +0 -17
  359. package/dist/token-util-pqyc8kng.js +0 -6
  360. package/dist/worker-qrbz6hmv.js +0 -85
@@ -1,35 +1,44 @@
1
+ import {
2
+ IdentityFieldBudgetError,
3
+ checkIdentityFieldBudget,
4
+ init_identity_field_budget,
5
+ init_templates
6
+ } from "./cli-34w2584r.js";
1
7
  import {
2
8
  configureDbResolver,
3
9
  getAllTemplateDefinitions,
4
- init_env_flag,
5
10
  init_registry,
6
11
  init_resolver,
7
12
  init_session_templates,
8
13
  init_steering_enabled,
9
- isEnvFlagEnabled,
10
14
  isSteeringEnabled,
11
15
  registerTemplate
12
- } from "./cli-xpxde7rm.js";
16
+ } from "./cli-2wv4kj0e.js";
13
17
  import {
14
18
  MAX_PROFILE_FILE_LENGTH,
15
19
  init_constants
16
- } from "./cli-x23me2mg.js";
20
+ } from "./cli-a1rrkrb4.js";
17
21
  import {
18
22
  deriveProviderFromKeyType,
19
23
  init_credentials
20
- } from "./cli-z2zcxes1.js";
24
+ } from "./cli-qt5bt3vk.js";
25
+ import {
26
+ init_env_flag,
27
+ isEnvFlagEnabled
28
+ } from "./cli-nanaxrz6.js";
21
29
  import {
22
30
  exports_zod,
23
31
  init_zod
24
- } from "./cli-zsspvvm2.js";
25
- import {
26
- init_secret_scrubber,
27
- scrubSecrets
28
- } from "./cli-4j2mrzag.js";
32
+ } from "./cli-1ybr6vw2.js";
29
33
  import {
30
34
  init_package,
31
35
  package_default
32
- } from "./cli-ccf9vy7q.js";
36
+ } from "./cli-jmvk6et8.js";
37
+ import {
38
+ init_secret_scrubber,
39
+ registerVolatileSecret,
40
+ scrubSecrets
41
+ } from "./cli-mkq1rk7b.js";
33
42
  import {
34
43
  _enum,
35
44
  array,
@@ -37,13 +46,13 @@ import {
37
46
  object,
38
47
  string,
39
48
  union
40
- } from "./cli-5dsbcjjw.js";
49
+ } from "./cli-ghexzd2d.js";
41
50
  import {
42
51
  __commonJS,
43
52
  __esm,
44
53
  __export,
45
54
  __require
46
- } from "./cli-p9swy5t3.js";
55
+ } from "./cli-pq2ee5ja.js";
47
56
 
48
57
  // src/utils/provider-metadata.ts
49
58
  function parseProviderMeta(rawProvider, rawMeta) {
@@ -2077,7 +2086,7 @@ function resolveTaskModelSelection(opts) {
2077
2086
  function isTerminalTaskStatus(status) {
2078
2087
  return TERMINAL_TASK_STATUSES.includes(status);
2079
2088
  }
2080
- var AssetKeySchema, AssetEntityTypeSchema, AssetProviderRefSchema, AssetKeyMappingSchema, AssetSummarySchema, ModelTierSchema, MODEL_TIERS, ReasoningEffortSchema, LEGACY_MODEL_TO_TIER, DEFAULT_MODEL_TIER_MAP, AgentTaskStatusSchema, TERMINAL_TASK_STATUSES, InboxMessageStatusSchema, InboxMessageSchema, AgentTaskSourceSchema, ProviderNameSchema, SteerModeSchema, SteeringStatusSchema, SteeringSourceSchema, SteeringMessageSchema, SteerOutcomeSchema, OnUnsupportedSchema, SteerResultSchema, PROVIDER_STEER_CAPABILITIES, FollowUpConfigSchema, RoutingAffinitySchema, AgentTaskSchema, TaskAttachmentKindSchema, attachmentCommonFields, AttachmentInputSchema, TaskAttachmentSchema, UserSchema, IdentityEventTypeSchema, InboxItemTypeSchema, InboxItemStatusSchema, InboxItemStateSchema, FavoriteItemTypeSchema, UserFavoriteSchema, TaskTemplateKindSchema, TaskTemplateSchema, AgentStatusSchema, AgentAvatarSchema, AgentSchema, AgentCredStatusLiveTestSchema, AgentLatestModelSchema, AgentBedrockStatusSchema, AgentCredStatusSchema, AgentWithTasksSchema, ChangeSourceSchema, VersionableFieldSchema, ContextVersionSchema, ChannelTypeSchema, ChannelSchema, ChannelMessageSchema, ServiceStatusSchema, ServiceSchema, AgentLogEventTypeSchema, ResumeReasonSchema, AgentLogSchema, SessionLogSchema, SessionCostSourceSchema, SessionCostModelBreakdownSchema, SessionCostSchema, EventCategorySchema, EventStatusSchema, EventSourceSchema, EventNameSchema, SwarmEventSchema, ScheduledTaskTargetTypeSchema, ScheduledTaskSchema, SwarmConfigScopeSchema, SwarmConfigSchema, RepoGuidelinesSchema, RepoHooksSchema, SwarmRepoSchema, AgentMemoryScopeSchema, AgentMemorySourceSchema, AgentMemorySchema, ActiveSessionSchema, RetryPolicySchema, ExecutorMetaSchema, ValidationResultSchema, StepValidationConfigSchema, SwarmScriptNodeConfigSchema, WorkflowNodeSchema, WorkflowEdgeSchema, WorkflowDefinitionSchema, WorkflowNodePatchSchema, WorkflowPatchSchema, WebhookVerificationSchema, TriggerConfigSchema, CooldownConfigSchema, InputValueSchema, WorkflowTemplateSchema, WorkflowSnapshotSchema, WorkflowSchema, WorkflowVersionSchema, PageContentTypeSchema, PageAuthModeSchema, PageSnapshotSchema, PageSchema, PageVersionSchema, MetricParamSchema, MetricVariableTypeSchema, MetricFormatSchema, MetricVisualizationSchema, MetricQuerySchema, MetricVariableSchema, MetricVizConfigSchema, MetricWidgetSchema, MetricDefinitionSchema, MetricSnapshotSchema, MetricSchema, MetricVersionSchema, WorkflowRunStatusSchema, WorkflowRunSchema, ScriptRunStatusSchema, TERMINAL_SCRIPT_RUN_STATUSES, ScriptRunKindSchema, ScriptRunSchema, ScriptRunListItemSchema, ScriptRunJournalEntrySchema, WorkflowRunStepStatusSchema, WorkflowRunStepSchema, WaitModeSchema, WaitStateStatusSchema, WaitStateRowSchema, PromptTemplateScopeSchema, PromptTemplateStateSchema, PromptTemplateSchema, PromptTemplateHistorySchema, ScriptScopeSchema, ScriptFsModeSchema, ScriptRecordSchema, ScriptVersionRecordSchema, ScriptApiAuthModeSchema, ScriptApiRecordSchema, SkillTypeSchema, SkillScopeSchema, SkillSchema, AgentSkillSchema, SkillWithInstallInfoSchema, SkillFileSchema, McpServerTransportSchema, McpServerScopeSchema, McpAuthMethodSchema, McpServerSchema, AgentMcpServerSchema, McpServerWithInstallInfoSchema, ContextSnapshotEventTypeSchema, ContextFormulaSchema, ContextSnapshotSchema, BudgetScopeSchema, BudgetSchema, PricingProviderSchema, PricingTokenClassSchema, PricingRowSchema, BudgetRefusalCauseSchema, BudgetRefusalNotificationSchema, BudgetRefusedTriggerSchema, KvValueTypeSchema, KV_NAME_REGEX, KvNamespaceSchema, KvKeySchema, KvEntrySchema;
2089
+ var AssetKeySchema, AssetEntityTypeSchema, AssetProviderRefSchema, AssetKeyMappingSchema, AssetSummarySchema, ModelTierSchema, MODEL_TIERS, ReasoningEffortSchema, LEGACY_MODEL_TO_TIER, DEFAULT_MODEL_TIER_MAP, AgentTaskStatusSchema, TERMINAL_TASK_STATUSES, InboxMessageStatusSchema, InboxMessageSchema, AgentTaskSourceSchema, ProviderNameSchema, SteerModeSchema, SteeringStatusSchema, SteeringSourceSchema, SteeringMessageSchema, SteerOutcomeSchema, OnUnsupportedSchema, SteerResultSchema, PROVIDER_STEER_CAPABILITIES, FollowUpConfigSchema, RoutingAffinitySchema, AgentTaskSchema, CreateTaskOptionsSchema, TaskAttachmentKindSchema, SERVER_GENERATED_ATTACHMENT_CAPABILITY = "_agentSwarmGeneratedBy", attachmentCapabilitiesSchema, attachmentCommonFields, AttachmentInputSchema, TaskAttachmentSchema, UserSchema, UserCommsPrefsSchema, IdentityEventTypeSchema, InboxItemTypeSchema, InboxItemStatusSchema, InboxItemStateSchema, FavoriteItemTypeSchema, UserFavoriteSchema, TaskTemplateKindSchema, TaskTemplateSchema, AgentStatusSchema, AgentAvatarSchema, AgentSchema, AgentCredStatusLiveTestSchema, AgentLatestModelSchema, AgentBedrockStatusSchema, AgentCredStatusSchema, AgentWithTasksSchema, ChangeSourceSchema, VersionableFieldSchema, ContextVersionSchema, ChannelTypeSchema, ChannelSchema, ChannelMessageSchema, ServiceStatusSchema, ServiceSchema, AgentLogEventTypeSchema, ResumeReasonSchema, AgentLogSchema, SessionLogSchema, SessionCostSourceSchema, SessionCostModelBreakdownSchema, SessionCostSchema, EventCategorySchema, EventStatusSchema, EventSourceSchema, EventNameSchema, SwarmEventSchema, ScheduledTaskTargetTypeSchema, ScheduledTaskSchema, SwarmConfigScopeSchema, SwarmConfigSchema, RepoGuidelinesSchema, RepoHooksSchema, SwarmRepoSchema, AgentMemoryScopeSchema, AgentMemorySourceSchema, AgentMemorySchema, ActiveSessionSchema, RuntimeInstanceStatusSchema, RuntimeInstanceSchema, RetryPolicySchema, ExecutorMetaSchema, ValidationResultSchema, StepValidationConfigSchema, SwarmScriptNodeConfigSchema, WorkflowNodeSchema, WorkflowEdgeSchema, WorkflowDefinitionSchema, WorkflowNodePatchSchema, WorkflowPatchSchema, WebhookVerificationSchema, TriggerConfigSchema, CooldownConfigSchema, InputValueSchema, WorkflowTemplateSchema, WorkflowSnapshotSchema, WorkflowSchema, WorkflowVersionSchema, PageContentTypeSchema, PageAuthModeSchema, PageSnapshotSchema, PageSchema, PageVersionSchema, MetricParamSchema, MetricVariableTypeSchema, MetricFormatSchema, MetricVisualizationSchema, MetricQuerySchema, MetricVariableSchema, MetricVizConfigSchema, MetricWidgetSchema, MetricDefinitionSchema, MetricSnapshotSchema, MetricSchema, MetricVersionSchema, WorkflowRunStatusSchema, WorkflowRunSchema, ScriptRunStatusSchema, TERMINAL_SCRIPT_RUN_STATUSES, ScriptRunKindSchema, ScriptRunSchema, ScriptRunListItemSchema, ScriptRunJournalEntrySchema, WorkflowRunStepStatusSchema, WorkflowRunStepSchema, WaitModeSchema, WaitStateStatusSchema, WaitStateRowSchema, PromptTemplateScopeSchema, PromptTemplateStateSchema, PromptTemplateSchema, PromptTemplateHistorySchema, ScriptScopeSchema, ScriptFsModeSchema, ScriptRecordSchema, ScriptVersionRecordSchema, ScriptApiAuthModeSchema, ScriptApiRecordSchema, SkillTypeSchema, SkillScopeSchema, SkillSchema, AgentSkillSchema, SkillWithInstallInfoSchema, SkillFileSchema, McpServerTransportSchema, McpServerScopeSchema, McpAuthMethodSchema, McpServerSchema, AgentMcpServerSchema, McpServerWithInstallInfoSchema, ContextSnapshotEventTypeSchema, ContextFormulaSchema, ContextSnapshotSchema, BudgetScopeSchema, BudgetSchema, PricingProviderSchema, PricingTokenClassSchema, PricingRowSchema, BudgetRefusalCauseSchema, BudgetRefusalNotificationSchema, BudgetRefusedTriggerSchema, KvValueTypeSchema, KV_NAME_REGEX, KvNamespaceSchema, KvKeySchema, KvEntrySchema;
2081
2090
  var init_types = __esm(() => {
2082
2091
  init_key();
2083
2092
  init_constants();
@@ -2361,12 +2370,62 @@ var init_types = __esm(() => {
2361
2370
  totalCostUsd: exports_zod.number().min(0).optional(),
2362
2371
  routingAffinity: RoutingAffinitySchema.optional()
2363
2372
  }).openapi("AgentTask");
2373
+ CreateTaskOptionsSchema = exports_zod.object({
2374
+ key: exports_zod.string().min(1).optional(),
2375
+ agentId: exports_zod.string().nullable().optional(),
2376
+ creatorAgentId: exports_zod.string().optional(),
2377
+ source: AgentTaskSourceSchema.optional(),
2378
+ taskType: exports_zod.string().max(50).optional(),
2379
+ tags: exports_zod.array(exports_zod.string()).optional(),
2380
+ priority: exports_zod.number().int().min(0).max(100).optional(),
2381
+ dependsOn: exports_zod.array(exports_zod.string()).optional(),
2382
+ offeredTo: exports_zod.string().optional(),
2383
+ status: exports_zod.enum(["backlog", "unassigned"]).optional(),
2384
+ slackChannelId: exports_zod.string().optional(),
2385
+ slackThreadTs: exports_zod.string().optional(),
2386
+ slackTriggerMessageTs: exports_zod.string().optional(),
2387
+ slackUserId: exports_zod.string().optional(),
2388
+ overrideSlackContext: exports_zod.boolean().optional(),
2389
+ vcsProvider: exports_zod.enum(["github", "gitlab"]).optional(),
2390
+ vcsRepo: exports_zod.string().optional(),
2391
+ vcsEventType: exports_zod.string().optional(),
2392
+ vcsNumber: exports_zod.number().int().optional(),
2393
+ vcsCommentId: exports_zod.number().int().optional(),
2394
+ vcsAuthor: exports_zod.string().optional(),
2395
+ vcsUrl: exports_zod.string().optional(),
2396
+ vcsInstallationId: exports_zod.number().int().optional(),
2397
+ vcsNodeId: exports_zod.string().optional(),
2398
+ agentmailInboxId: exports_zod.string().optional(),
2399
+ agentmailMessageId: exports_zod.string().optional(),
2400
+ agentmailThreadId: exports_zod.string().optional(),
2401
+ mentionMessageId: exports_zod.string().optional(),
2402
+ mentionChannelId: exports_zod.string().optional(),
2403
+ dir: exports_zod.string().optional(),
2404
+ parentTaskId: exports_zod.string().optional(),
2405
+ model: exports_zod.string().optional(),
2406
+ modelTier: ModelTierSchema.optional(),
2407
+ effort: ReasoningEffortSchema.optional(),
2408
+ scheduleId: exports_zod.string().optional(),
2409
+ workflowRunId: exports_zod.string().optional(),
2410
+ workflowRunStepId: exports_zod.string().optional(),
2411
+ sourceTaskId: exports_zod.string().optional(),
2412
+ outputSchema: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional(),
2413
+ inheritParentOutputSchema: exports_zod.boolean().optional(),
2414
+ followUpConfig: FollowUpConfigSchema.optional(),
2415
+ requestedByUserId: exports_zod.string().optional(),
2416
+ contextKey: exports_zod.string().optional(),
2417
+ bypassTrackerContextDedup: exports_zod.boolean().optional(),
2418
+ routingAffinity: RoutingAffinitySchema.optional()
2419
+ });
2364
2420
  TaskAttachmentKindSchema = exports_zod.enum(["agent-fs", "url", "shared-fs", "page"]);
2421
+ attachmentCapabilitiesSchema = exports_zod.record(exports_zod.string(), exports_zod.unknown()).refine((capabilities) => !(SERVER_GENERATED_ATTACHMENT_CAPABILITY in capabilities), {
2422
+ message: `${SERVER_GENERATED_ATTACHMENT_CAPABILITY} is reserved for server-generated attachments`
2423
+ });
2365
2424
  attachmentCommonFields = {
2366
2425
  name: exports_zod.string().min(1).describe("Display name for the attachment."),
2367
2426
  providerId: exports_zod.string().min(1).optional(),
2368
2427
  providerKey: exports_zod.string().min(1).optional(),
2369
- capabilities: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional(),
2428
+ capabilities: attachmentCapabilitiesSchema.optional(),
2370
2429
  mimeType: exports_zod.string().optional(),
2371
2430
  sizeBytes: exports_zod.number().int().min(0).optional(),
2372
2431
  sha256: exports_zod.string().optional(),
@@ -2437,6 +2496,11 @@ var init_types = __esm(() => {
2437
2496
  createdAt: exports_zod.iso.datetime(),
2438
2497
  lastUpdatedAt: exports_zod.iso.datetime()
2439
2498
  }).openapi("User");
2499
+ UserCommsPrefsSchema = exports_zod.object({
2500
+ tone: exports_zod.string().optional(),
2501
+ language: exports_zod.string().optional(),
2502
+ verbosity: exports_zod.string().optional()
2503
+ }).openapi("UserCommsPrefs");
2440
2504
  IdentityEventTypeSchema = exports_zod.enum([
2441
2505
  "auto_merge",
2442
2506
  "manual_merge",
@@ -2746,6 +2810,8 @@ var init_types = __esm(() => {
2746
2810
  "system.boot",
2747
2811
  "system.migration",
2748
2812
  "system.error",
2813
+ "system.profile_sync_rejected",
2814
+ "system.profile_sync_reconciled",
2749
2815
  "script.global_upsert",
2750
2816
  "schedule.deleted"
2751
2817
  ]);
@@ -2891,9 +2957,22 @@ var init_types = __esm(() => {
2891
2957
  taskDescription: exports_zod.string().nullable(),
2892
2958
  runnerSessionId: exports_zod.string().nullable(),
2893
2959
  providerSessionId: exports_zod.string().nullable(),
2960
+ runtimeInstanceId: exports_zod.string().nullable().optional(),
2894
2961
  startedAt: exports_zod.iso.datetime(),
2895
2962
  lastHeartbeatAt: exports_zod.iso.datetime()
2896
2963
  }).openapi("ActiveSession");
2964
+ RuntimeInstanceStatusSchema = exports_zod.enum(["active", "offline"]);
2965
+ RuntimeInstanceSchema = exports_zod.object({
2966
+ id: exports_zod.string(),
2967
+ agentId: exports_zod.string(),
2968
+ status: RuntimeInstanceStatusSchema,
2969
+ reportedSlots: exports_zod.number().int(),
2970
+ credentialReady: exports_zod.boolean().nullable().optional(),
2971
+ metadata: exports_zod.record(exports_zod.string(), exports_zod.unknown()).nullable(),
2972
+ lastSeenAt: exports_zod.iso.datetime(),
2973
+ createdAt: exports_zod.iso.datetime(),
2974
+ updatedAt: exports_zod.iso.datetime()
2975
+ }).openapi("RuntimeInstance");
2897
2976
  RetryPolicySchema = exports_zod.object({
2898
2977
  maxRetries: exports_zod.number().int().min(0).default(3),
2899
2978
  strategy: exports_zod.enum(["exponential", "static", "linear"]).default("exponential"),
@@ -3201,6 +3280,7 @@ var init_types = __esm(() => {
3201
3280
  triggerData: exports_zod.unknown().optional(),
3202
3281
  context: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional(),
3203
3282
  error: exports_zod.string().optional(),
3283
+ createdBy: exports_zod.string().optional(),
3204
3284
  startedAt: exports_zod.string(),
3205
3285
  lastUpdatedAt: exports_zod.string(),
3206
3286
  finishedAt: exports_zod.string().optional()
@@ -3564,6 +3644,58 @@ var init_types = __esm(() => {
3564
3644
  }).openapi("KvEntry");
3565
3645
  });
3566
3646
 
3647
+ // src/utils/github-pull-request.ts
3648
+ function parseGitHubPullRequestToken(token) {
3649
+ const candidate = token.replace(TRAILING_PROSE_PUNCTUATION_RE, "");
3650
+ const lowerCandidate = candidate.toLowerCase();
3651
+ if (!lowerCandidate.startsWith("https://github.com/") && !lowerCandidate.startsWith("http://github.com/") && !lowerCandidate.startsWith("github.com/")) {
3652
+ return null;
3653
+ }
3654
+ const withScheme = /^https?:\/\//i.test(candidate) ? candidate : `https://${candidate}`;
3655
+ let parsed;
3656
+ try {
3657
+ parsed = new URL(withScheme);
3658
+ } catch {
3659
+ return null;
3660
+ }
3661
+ if (parsed.host.toLowerCase() !== "github.com" || parsed.username.length > 0 || parsed.password.length > 0) {
3662
+ return null;
3663
+ }
3664
+ const [owner, repo, pull, numberText] = parsed.pathname.split("/").filter(Boolean);
3665
+ if (!owner || !repo || pull?.toLowerCase() !== "pull" || !numberText || !GITHUB_PATH_SEGMENT_RE.test(owner) || !GITHUB_PATH_SEGMENT_RE.test(repo) || !/^\d+$/.test(numberText)) {
3666
+ return null;
3667
+ }
3668
+ return {
3669
+ url: `https://github.com/${owner}/${repo}/pull/${numberText}`,
3670
+ owner,
3671
+ repo,
3672
+ number: Number(numberText)
3673
+ };
3674
+ }
3675
+ function extractGitHubPullRequestUrls(text) {
3676
+ if (!text)
3677
+ return [];
3678
+ const results = [];
3679
+ const seen = new Set;
3680
+ for (const match of text.matchAll(CANDIDATE_TOKEN_RE)) {
3681
+ const pullRequest = parseGitHubPullRequestToken(match[0]);
3682
+ if (!pullRequest)
3683
+ continue;
3684
+ const dedupeKey = pullRequest.url.toLowerCase();
3685
+ if (seen.has(dedupeKey))
3686
+ continue;
3687
+ seen.add(dedupeKey);
3688
+ results.push(pullRequest);
3689
+ }
3690
+ return results;
3691
+ }
3692
+ var CANDIDATE_TOKEN_RE, TRAILING_PROSE_PUNCTUATION_RE, GITHUB_PATH_SEGMENT_RE;
3693
+ var init_github_pull_request = __esm(() => {
3694
+ CANDIDATE_TOKEN_RE = /[^\s()[\]{}<>"'`]+/g;
3695
+ TRAILING_PROSE_PUNCTUATION_RE = /[)\]},.;:!]+$/;
3696
+ GITHUB_PATH_SEGMENT_RE = /^[\w.-]+$/;
3697
+ });
3698
+
3567
3699
  // src/utils/request-auth-context.ts
3568
3700
  import { AsyncLocalStorage } from "node:async_hooks";
3569
3701
  function setRequestAuth(req, auth) {
@@ -4224,19 +4356,19 @@ function runMigrations(db) {
4224
4356
  }
4225
4357
  continue;
4226
4358
  }
4227
- console.debug(`[migrations] Applying: ${migration.name}`);
4359
+ console.log(`[migrations] Applying: ${migration.name}`);
4228
4360
  const start = performance.now();
4229
- db.transaction(() => {
4230
- db.exec(migration.sql);
4231
- db.run("INSERT INTO _migrations (version, name, applied_at, checksum) VALUES (?, ?, ?, ?)", [
4232
- migration.version,
4233
- migration.name,
4234
- new Date().toISOString(),
4235
- migration.checksum
4236
- ]);
4237
- })();
4361
+ try {
4362
+ db.transaction(() => {
4363
+ db.exec(migration.sql);
4364
+ db.run("INSERT INTO _migrations (version, name, applied_at, checksum) VALUES (?, ?, ?, ?)", [migration.version, migration.name, new Date().toISOString(), migration.checksum]);
4365
+ })();
4366
+ } catch (error) {
4367
+ const detail = error instanceof Error ? error.message : String(error);
4368
+ throw new Error(`[migrations] Migration ${migration.version} (${migration.name}) failed: ${detail}`, { cause: error });
4369
+ }
4238
4370
  const elapsed = (performance.now() - start).toFixed(1);
4239
- console.debug(`[migrations] Applied: ${migration.name} (${elapsed}ms)`);
4371
+ console.log(`[migrations] Applied: ${migration.name} (${elapsed}ms)`);
4240
4372
  }
4241
4373
  db.run("PRAGMA foreign_keys = ON");
4242
4374
  }
@@ -4302,135 +4434,18 @@ var init_oauth_encryption_backfill = __esm(() => {
4302
4434
  init_crypto();
4303
4435
  });
4304
4436
 
4305
- // src/commands/templates.ts
4306
- var init_templates = __esm(() => {
4307
- init_registry();
4308
- registerTemplate({
4309
- eventType: "task.trigger.assigned",
4310
- header: "",
4311
- defaultBody: `{{work_on_task_cmd}} {{task_id}}{{task_desc_section}}{{attachments_section}}{{output_instructions}}`,
4312
- variables: [
4313
- { name: "work_on_task_cmd", description: "Formatted /work-on-task command" },
4314
- { name: "task_id", description: "Task ID" },
4315
- { name: "task_desc_section", description: "Task description section or empty string" },
4316
- {
4317
- name: "attachments_section",
4318
- description: "Ready-to-run fetch recipe per task attachment (or empty string if none) — lets the agent download an attachment in one call instead of discovering the path/provider itself"
4319
- },
4320
- {
4321
- name: "output_instructions",
4322
- description: "Output format instructions (with outputSchema if present, or generic store-progress)"
4323
- }
4324
- ],
4325
- category: "task_lifecycle"
4326
- });
4327
- registerTemplate({
4328
- eventType: "task.trigger.offered",
4329
- header: "",
4330
- defaultBody: `{{review_offered_task_cmd}} {{task_id}}{{task_desc_section}}
4331
-
4332
- Accept if you have capacity and skills. Reject with a reason if you cannot handle it.`,
4333
- variables: [
4334
- { name: "review_offered_task_cmd", description: "Formatted /review-offered-task command" },
4335
- { name: "task_id", description: "Task ID" },
4336
- { name: "task_desc_section", description: "Task description section or empty string" }
4337
- ],
4338
- category: "task_lifecycle"
4339
- });
4340
- registerTemplate({
4341
- eventType: "task.trigger.unread_mentions",
4342
- header: "",
4343
- defaultBody: `You have {{mention_count}} mention(s) in chat channels.
4344
-
4345
- 1. Use \`read-messages\` with unreadOnly: true to see them
4346
- 2. Respond to questions or requests directed at you
4347
- 3. If a message requires work, create a task using \`send-task\``,
4348
- variables: [{ name: "mention_count", description: "Number of unread mentions or 'unread'" }],
4349
- category: "task_lifecycle"
4350
- });
4351
- registerTemplate({
4352
- eventType: "task.trigger.pool_available",
4353
- header: "",
4354
- defaultBody: `{{task_count}} task(s) available in the pool.
4355
-
4356
- 1. Run \`get-tasks\` with unassigned: true to browse
4357
- 2. Pick one matching your skills
4358
- 3. Run \`task-action\` with action: "claim" and taskId: "<id>"
4359
-
4360
- Note: Claims are first-come-first-serve. If claim fails, pick another.`,
4361
- variables: [{ name: "task_count", description: "Number of available pool tasks" }],
4362
- category: "task_lifecycle"
4363
- });
4364
- registerTemplate({
4365
- eventType: "task.trigger.channel_activity",
4366
- header: "",
4367
- defaultBody: `## Slack Channel Activity
4368
-
4369
- {{message_count}} new message(s) in monitored Slack channels:
4370
-
4371
- {{messages_detail}}
4372
- ## Your Task
4373
-
4374
- Review these messages and decide if any require action:
4375
- 1. If a message is a question or request, respond using \`slack-reply\` or create a task with \`send-task\`
4376
- 2. If a message is informational, no action needed
4377
- 3. Use \`slack-read\` with the channelId to get more context if needed`,
4378
- variables: [
4379
- { name: "message_count", description: "Number of new messages" },
4380
- {
4381
- name: "messages_detail",
4382
- description: "Formatted list of messages with channel and user info"
4383
- }
4384
- ],
4385
- category: "task_lifecycle"
4386
- });
4387
- registerTemplate({
4388
- eventType: "task.resumption.with_progress",
4389
- header: "",
4390
- defaultBody: `{{work_on_task_cmd}} {{task_id}}
4391
-
4392
- **RESUMED TASK** - This task was interrupted during a deployment and is being resumed.
4393
-
4394
- Task: "{{task_description}}"
4395
-
4396
- Previous Progress:
4397
- {{progress}}
4398
-
4399
- Continue from where you left off. Review the progress above and complete the remaining work.{{completion_instructions}}`,
4400
- variables: [
4401
- { name: "work_on_task_cmd", description: "Formatted /work-on-task command" },
4402
- { name: "task_id", description: "Task ID" },
4403
- { name: "task_description", description: "Original task description" },
4404
- { name: "progress", description: "Previous progress text" },
4405
- {
4406
- name: "completion_instructions",
4407
- description: "Completion instructions (empty for providers without MCP)"
4408
- }
4409
- ],
4410
- category: "task_lifecycle"
4411
- });
4412
- registerTemplate({
4413
- eventType: "task.resumption.no_progress",
4414
- header: "",
4415
- defaultBody: `{{work_on_task_cmd}} {{task_id}}
4416
-
4417
- **RESUMED TASK** - This task was interrupted during a deployment and is being resumed.
4418
-
4419
- Task: "{{task_description}}"
4420
-
4421
- No progress was saved before the interruption. Start the task fresh but be aware files may have been partially modified.{{completion_instructions}}`,
4422
- variables: [
4423
- { name: "work_on_task_cmd", description: "Formatted /work-on-task command" },
4424
- { name: "task_id", description: "Task ID" },
4425
- { name: "task_description", description: "Original task description" },
4426
- {
4427
- name: "completion_instructions",
4428
- description: "Completion instructions (empty for providers without MCP)"
4429
- }
4430
- ],
4431
- category: "task_lifecycle"
4432
- });
4433
- });
4437
+ // src/prompts/default-drift.ts
4438
+ function getPromptTemplateDefaultDrift(template, defaultBody) {
4439
+ const customizedBytes = Buffer.byteLength(template.body, "utf8");
4440
+ const defaultBytes = Buffer.byteLength(defaultBody, "utf8");
4441
+ return {
4442
+ defaultDrifted: !template.isDefault && template.body !== defaultBody,
4443
+ customizedBytes,
4444
+ defaultBytes,
4445
+ byteDelta: defaultBytes - customizedBytes
4446
+ };
4447
+ }
4448
+ var init_default_drift = () => {};
4434
4449
 
4435
4450
  // src/tools/templates.ts
4436
4451
  var init_templates2 = __esm(() => {
@@ -4678,10 +4693,23 @@ function seedDefaultTemplates() {
4678
4693
  });
4679
4694
  } else if (globalRecord.isDefault && globalRecord.body !== def.defaultBody) {
4680
4695
  resetPromptTemplateToDefault(globalRecord.id, def.defaultBody);
4696
+ } else if (!globalRecord.isDefault) {
4697
+ const drift = getPromptTemplateDefaultDrift(globalRecord, def.defaultBody);
4698
+ if (drift.defaultDrifted) {
4699
+ const ageMs = Math.max(0, Date.now() - Date.parse(globalRecord.updatedAt));
4700
+ const frozenDays = Math.floor(ageMs / 86400000);
4701
+ const frozenHours = Math.floor(ageMs / 3600000);
4702
+ const frozenFor = frozenDays > 0 ? `${frozenDays} day${frozenDays === 1 ? "" : "s"}` : `${frozenHours} hour${frozenHours === 1 ? "" : "s"}`;
4703
+ const signedByteDelta = drift.byteDelta > 0 ? `+${drift.byteDelta}` : `${drift.byteDelta}`;
4704
+ console.warn(`[prompt-templates] Customized template "${def.eventType}" has drifted from its code default; frozen for ${frozenFor} since ${globalRecord.updatedAt}; byte delta ${signedByteDelta} (code default ${drift.defaultBytes} bytes, customization ${drift.customizedBytes} bytes). The customization was preserved; reset it manually to reconcile.`);
4705
+ } else if (globalRecord.state === "enabled") {
4706
+ resetPromptTemplateToDefault(globalRecord.id, def.defaultBody);
4707
+ }
4681
4708
  }
4682
4709
  }
4683
4710
  }
4684
4711
  var init_seed_prompt_templates = __esm(() => {
4712
+ init_default_drift();
4685
4713
  init_registry();
4686
4714
  init_db();
4687
4715
  init_session_templates();
@@ -4712,7 +4740,7 @@ function promoteSteeringToTask(task, message) {
4712
4740
  source: message.source === "script" ? "api" : message.source,
4713
4741
  taskType: "follow-up",
4714
4742
  parentTaskId: task.id,
4715
- requestedByUserId: message.createdByUserId ?? task.requestedByUserId,
4743
+ requestedByUserId: message.createdByUserId,
4716
4744
  bypassTrackerContextDedup: true
4717
4745
  });
4718
4746
  }
@@ -4915,7 +4943,15 @@ var init_swarm_config_guard = __esm(() => {
4915
4943
  return null;
4916
4944
  return "Invalid BEDROCK_AUTH_MODE value (must be one of: sdk, bearer)";
4917
4945
  },
4946
+ AGENT_MAX_TASKS: (value) => {
4947
+ const str = String(value).trim();
4948
+ if (!/^\d+$/.test(str) || Number(str) < 1 || Number(str) > 100) {
4949
+ return "Invalid AGENT_MAX_TASKS (must be an integer between 1 and 100)";
4950
+ }
4951
+ return null;
4952
+ },
4918
4953
  ...booleanValidators([
4954
+ "MULTI_RUNTIME_ENABLED",
4919
4955
  "STEERING_ENABLED",
4920
4956
  "MEMORY_HYBRID_SEARCH",
4921
4957
  "MEMORY_GRAPH_EXPANSION",
@@ -4938,7 +4974,8 @@ var init_swarm_config_guard = __esm(() => {
4938
4974
  "MCP_OAUTH_ALLOW_PRIVATE_HOSTS",
4939
4975
  "OTEL_TRACE_POLL",
4940
4976
  "ANONYMIZED_TELEMETRY",
4941
- "SWARM_HIDE_CLOUD_PROMO"
4977
+ "SWARM_HIDE_CLOUD_PROMO",
4978
+ "DB_QUERY_BOUNDED_ENABLED"
4942
4979
  ]),
4943
4980
  ...enumValidator("SLACK_THREAD_STEERING", ["lead", "all"]),
4944
4981
  ...enumValidator("SLACK_THREAD_STEERING_MODE", ["steer", "queue"]),
@@ -4953,8 +4990,13 @@ var init_swarm_config_guard = __esm(() => {
4953
4990
  "WORKFLOW_MAX_ITERATIONS",
4954
4991
  "WORKFLOW_MAX_STEPS_PER_RUN",
4955
4992
  "SCHEDULER_INTERVAL_MS",
4993
+ "RUNTIME_STALE_THRESHOLD_MIN",
4956
4994
  "SCRIPT_RUN_CONCURRENCY_CAP",
4957
- "WORKER_API_READY_TIMEOUT_SECONDS"
4995
+ "WORKER_API_READY_TIMEOUT_SECONDS",
4996
+ "DB_QUERY_HTTP_BUDGET_MS",
4997
+ "DB_QUERY_HTTP_MAX_ROWS",
4998
+ "DB_QUERY_MCP_BUDGET_MS",
4999
+ "DB_QUERY_MCP_MAX_ROWS"
4958
5000
  ], 1),
4959
5001
  ...integerValidators(["HEARTBEAT_MAX_AUTO_ASSIGN"], 0),
4960
5002
  MEMORY_MIN_SIMILARITY: (value) => validateFloatRange("MEMORY_MIN_SIMILARITY", value, 0, 1, "between 0 and 1 inclusive"),
@@ -5171,7 +5213,7 @@ Environment-specific knowledge that's unique to your setup:
5171
5213
  var init_defaults = () => {};
5172
5214
 
5173
5215
  // node_modules/sqlite-vec/index.cjs
5174
- var require_sqlite_vec = __commonJS((exports, module) => {
5216
+ var require_sqlite_vec = __commonJS(function(exports, module) {
5175
5217
  var { arch, platform } = __require("node:process");
5176
5218
  var BASE_PACKAGE_NAME = "sqlite-vec";
5177
5219
  var ENTRYPOINT_BASE_NAME = "vec0";
@@ -5208,442 +5250,448 @@ var require_sqlite_vec = __commonJS((exports, module) => {
5208
5250
  // src/be/db.ts
5209
5251
  var exports_db = {};
5210
5252
  __export(exports_db, {
5211
- withFavoriteFlags: () => withFavoriteFlags,
5212
- upsertSwarmConfig: () => upsertSwarmConfig,
5213
- upsertSkillFiles: () => upsertSkillFiles,
5214
- upsertSkillFile: () => upsertSkillFile,
5215
- upsertService: () => upsertService,
5216
- upsertScriptRunJournalStep: () => upsertScriptRunJournalStep,
5217
- upsertPromptTemplate: () => upsertPromptTemplate,
5218
- upsertKv: () => upsertKv,
5219
- upsertInboxState: () => upsertInboxState,
5220
- upsertChannelActivityCursor: () => upsertChannelActivityCursor,
5221
- upsertBudget: () => upsertBudget,
5222
- upsertAssetKeyMapping: () => upsertAssetKeyMapping,
5223
- updateWorkflowRunStep: () => updateWorkflowRunStep,
5224
- updateWorkflowRun: () => updateWorkflowRun,
5225
- updateWorkflow: () => updateWorkflow,
5226
- updateUser: () => updateUser,
5227
- updateTaskVcs: () => updateTaskVcs,
5228
- updateTaskTitle: () => updateTaskTitle,
5229
- updateTaskProgress: () => updateTaskProgress,
5230
- updateTaskClaudeSessionId: () => updateTaskClaudeSessionId,
5231
- updateSwarmRepo: () => updateSwarmRepo,
5232
- updateSlackMessageRecord: () => updateSlackMessageRecord,
5233
- updateSkill: () => updateSkill,
5234
- updateServiceStatus: () => updateServiceStatus,
5235
- updateScriptRun: () => updateScriptRun,
5236
- updateScheduledTask: () => updateScheduledTask,
5237
- updateReadState: () => updateReadState,
5238
- updatePage: () => updatePage,
5239
- updateMetric: () => updateMetric,
5240
- updateMcpServer: () => updateMcpServer,
5241
- updateApprovalRequestNotifications: () => updateApprovalRequestNotifications,
5242
- updateAgentStatusFromCapacity: () => updateAgentStatusFromCapacity,
5243
- updateAgentStatus: () => updateAgentStatus,
5244
- updateAgentProvider: () => updateAgentProvider,
5245
- updateAgentProfile: () => updateAgentProfile,
5246
- updateAgentName: () => updateAgentName,
5247
- updateAgentMaxTasks: () => updateAgentMaxTasks,
5248
- updateAgentCredentialState: () => updateAgentCredentialState,
5249
- updateAgentCredStatus: () => updateAgentCredStatus,
5250
- updateAgentActivity: () => updateAgentActivity,
5251
- updateActiveSessionProviderSessionId: () => updateActiveSessionProviderSessionId,
5252
- uninstallSkill: () => uninstallSkill,
5253
- uninstallMcpServer: () => uninstallMcpServer,
5254
- toggleAgentSkill: () => toggleAgentSkill,
5255
- taskQueries: () => taskQueries,
5256
- sweepExpiredKvPrefix: () => sweepExpiredKvPrefix,
5257
- sweepExpiredKv: () => sweepExpiredKv,
5258
- supersedeTask: () => supersedeTask,
5259
- startTask: () => startTask,
5260
- shouldBlockPolling: () => shouldBlockPolling,
5261
- setUserFavorite: () => setUserFavorite,
5262
- setSlackMessageTracking: () => setSlackMessageTracking,
5263
- setFavorite: () => setFavorite,
5264
- setBudgetRefusalFollowUpTaskId: () => setBudgetRefusalFollowUpTaskId,
5265
- setApiKeyName: () => setApiKeyName,
5266
- setAgentHarnessProvider: () => setAgentHarnessProvider,
5267
- sessionLogQueries: () => sessionLogQueries,
5268
- searchSkills: () => searchSkills,
5269
- resumeTask: () => resumeTask,
5270
- resolveWaitState: () => resolveWaitState,
5271
- resolvePromptTemplate: () => resolvePromptTemplate,
5272
- resolveApprovalRequest: () => resolveApprovalRequest,
5273
- resetTasksNotified: () => resetTasksNotified,
5274
- resetPromptTemplateToDefault: () => resetPromptTemplateToDefault,
5275
- resetOrphanedInProgressTasksForAgent: () => resetOrphanedInProgressTasksForAgent,
5276
- resetEmptyPollCount: () => resetEmptyPollCount,
5277
- reserveSlackMessage: () => reserveSlackMessage,
5278
- replaceTaskAttachment: () => replaceTaskAttachment,
5279
- releaseTask: () => releaseTask,
5280
- releaseStaleReviewingTasks: () => releaseStaleReviewingTasks,
5281
- releaseStaleProcessingInbox: () => releaseStaleProcessingInbox,
5282
- releaseStaleMentionProcessing: () => releaseStaleMentionProcessing,
5283
- releaseMentionProcessing: () => releaseMentionProcessing,
5284
- rejectTask: () => rejectTask,
5285
- recordSlackMessage: () => recordSlackMessage,
5286
- recordKeyUsage: () => recordKeyUsage,
5287
- recordKeyRateLimitWindows: () => recordKeyRateLimitWindows,
5288
- recordInlineScriptRun: () => recordInlineScriptRun,
5289
- recordBudgetRefusalNotification: () => recordBudgetRefusalNotification,
5290
- reassociateSessionLogs: () => reassociateSessionLogs,
5291
- postMessage: () => postMessage,
5292
- pauseTask: () => pauseTask,
5293
- overwriteTerminalTaskResultText: () => overwriteTerminalTaskResultText,
5294
- normalizeSkillFilePath: () => normalizeSkillFilePath,
5295
- moveTaskToBacklog: () => moveTaskToBacklog,
5296
- moveTaskFromBacklog: () => moveTaskFromBacklog,
5297
- moveAssetKey: () => moveAssetKey,
5298
- maskSecrets: () => maskSecrets,
5299
- markTasksNotified: () => markTasksNotified,
5300
- markTaskSlackReplySent: () => markTaskSlackReplySent,
5301
- markSteeringPromoted: () => markSteeringPromoted,
5302
- markSteeringHandled: () => markSteeringHandled,
5303
- markSteeringDelivered: () => markSteeringDelivered,
5304
- markSlackTreeRendered: () => markSlackTreeRendered,
5305
- markKeyRateLimited: () => markKeyRateLimited,
5306
- markInboxMessageResponded: () => markInboxMessageResponded,
5307
- markInboxMessageRead: () => markInboxMessageRead,
5308
- markInboxMessageDelegated: () => markInboxMessageDelegated,
5309
- logQueries: () => logQueries,
5310
- listWorkflows: () => listWorkflows,
5311
- listWorkflowRunsPage: () => listWorkflowRunsPage,
5312
- listWorkflowRuns: () => listWorkflowRuns,
5313
- listUserFavorites: () => listUserFavorites,
5314
- listTaskTemplates: () => listTaskTemplates,
5315
- listSkills: () => listSkills,
5316
- listSkillFileManifest: () => listSkillFileManifest,
5317
- listScriptRuns: () => listScriptRuns,
5318
- listScriptRunJournalSteps: () => listScriptRunJournalSteps,
5319
- listRecentSessions: () => listRecentSessions,
5320
- listPagesByAgent: () => listPagesByAgent,
5321
- listMetricsByAgent: () => listMetricsByAgent,
5322
- listMcpServers: () => listMcpServers,
5323
- listKv: () => listKv,
5324
- listInboxState: () => listInboxState,
5325
- listFavorites: () => listFavorites,
5326
- listAssetSummaries: () => listAssetSummaries,
5327
- listApprovalRequests: () => listApprovalRequests,
5328
- listAllPages: () => listAllPages,
5329
- listAllMetrics: () => listAllMetrics,
5330
- listAgentsWithCredStatusByProvider: () => listAgentsWithCredStatusByProvider,
5331
- isSqliteVecAvailable: () => isSqliteVecAvailable,
5332
- isPoolAffinityEnforcementEnabled: () => isPoolAffinityEnforcementEnabled,
5333
- isPendingSlackMessage: () => isPendingSlackMessage,
5334
- isAgentEligibleForTask: () => isAgentEligibleForTask,
5335
- installSystemDefaultSkillsForAgent: () => installSystemDefaultSkillsForAgent,
5336
- installSkill: () => installSkill,
5337
- installMcpServer: () => installMcpServer,
5338
- insertTaskAttachment: () => insertTaskAttachment,
5339
- insertPricingRow: () => insertPricingRow,
5340
- insertActiveSession: () => insertActiveSession,
5341
- initDb: () => initDb,
5342
- incrementPageViewCount: () => incrementPageViewCount,
5343
- incrementEmptyPollCount: () => incrementEmptyPollCount,
5344
- incrKv: () => incrKv,
5345
- heartbeatActiveSession: () => heartbeatActiveSession,
5346
- hasPendingSteering: () => hasPendingSteering,
5347
- hasNonTerminalResumeChild: () => hasNonTerminalResumeChild,
5348
- hasNonTerminalRerouteDecisionChild: () => hasNonTerminalRerouteDecisionChild,
5349
- hasFirstCompletedTask: () => hasFirstCompletedTask,
5350
- hasCapacity: () => hasCapacity,
5351
- hasBudgetRefusalNotificationToday: () => hasBudgetRefusalNotificationToday,
5352
- getWorkflowsByScheduleId: () => getWorkflowsByScheduleId,
5353
- getWorkflowVersions: () => getWorkflowVersions,
5354
- getWorkflowVersion: () => getWorkflowVersion,
5355
- getWorkflowRunStepsByRunId: () => getWorkflowRunStepsByRunId,
5356
- getWorkflowRunStep: () => getWorkflowRunStep,
5357
- getWorkflowRun: () => getWorkflowRun,
5358
- getWorkflow: () => getWorkflow,
5359
- getWaitStateByStepId: () => getWaitStateByStepId,
5360
- getWaitStateById: () => getWaitStateById,
5361
- getUserById: () => getUserById,
5362
- getUnreadMessages: () => getUnreadMessages,
5363
- getUnreadInboxMessages: () => getUnreadInboxMessages,
5364
- getUnassignedTasksCount: () => getUnassignedTasksCount,
5365
- getUnassignedTaskIdsForAgent: () => getUnassignedTaskIdsForAgent,
5366
- getUnassignedTaskIds: () => getUnassignedTaskIds,
5367
- getUnassignedPoolTasks: () => getUnassignedPoolTasks,
5368
- getTasksCount: () => getTasksCount,
5369
- getTasksByStatus: () => getTasksByStatus,
5370
- getTasksByAgentId: () => getTasksByAgentId,
5371
- getTaskStats: () => getTaskStats,
5372
- getTaskByWorkflowRunStepId: () => getTaskByWorkflowRunStepId,
5373
- getTaskById: () => getTaskById,
5374
- getTaskAttachments: () => getTaskAttachments,
5375
- getSystemDefaultSkills: () => getSystemDefaultSkills,
5376
- getSwarmRepos: () => getSwarmRepos,
5377
- getSwarmRepoByUrl: () => getSwarmRepoByUrl,
5378
- getSwarmRepoByName: () => getSwarmRepoByName,
5379
- getSwarmRepoById: () => getSwarmRepoById,
5380
- getSwarmMetrics: () => getSwarmMetrics,
5381
- getSwarmConfigs: () => getSwarmConfigs,
5382
- getSwarmConfigLookupById: () => getSwarmConfigLookupById,
5383
- getSwarmConfigById: () => getSwarmConfigById,
5384
- getStuckWorkflowRuns: () => getStuckWorkflowRuns,
5385
- getStuckWaitRuns: () => getStuckWaitRuns,
5386
- getStuckApprovalRuns: () => getStuckApprovalRuns,
5387
- getStepCountForNode: () => getStepCountForNode,
5388
- getStepByIdempotencyKey: () => getStepByIdempotencyKey,
5389
- getSteeringMessagesForTask: () => getSteeringMessagesForTask,
5390
- getSteeringMessageById: () => getSteeringMessageById,
5391
- getStalledInProgressTasks: () => getStalledInProgressTasks,
5392
- getStaleUnassignedAffinityTasks: () => getStaleUnassignedAffinityTasks,
5393
- getStalePinnedResumes: () => getStalePinnedResumes,
5394
- getSlackTreeMessages: () => getSlackTreeMessages,
5395
- getSlackTreeMessageByThread: () => getSlackTreeMessageByThread,
5396
- getSlackTreeMessage: () => getSlackTreeMessage,
5397
- getSlackTasksMissingTree: () => getSlackTasksMissingTree,
5398
- getSlackTasksInThread: () => getSlackTasksInThread,
5399
- getSlackRenderV2ActivatedAt: () => getSlackRenderV2ActivatedAt,
5400
- getSlackOutcomeMessage: () => getSlackOutcomeMessage,
5401
- getSlackMessageByChannelTs: () => getSlackMessageByChannelTs,
5402
- getSkillFiles: () => getSkillFiles,
5403
- getSkillFile: () => getSkillFile,
5404
- getSkillByName: () => getSkillByName,
5405
- getSkillById: () => getSkillById,
5406
- getSessionLogsByTaskId: () => getSessionLogsByTaskId,
5407
- getSessionLogsBySession: () => getSessionLogsBySession,
5408
- getSessionCostsFiltered: () => getSessionCostsFiltered,
5409
- getSessionCostsByTaskId: () => getSessionCostsByTaskId,
5410
- getSessionCostsByAgentId: () => getSessionCostsByAgentId,
5411
- getSessionCostSummary: () => getSessionCostSummary,
5412
- getServicesByAgentId: () => getServicesByAgentId,
5413
- getServiceById: () => getServiceById,
5414
- getServiceByAgentAndName: () => getServiceByAgentAndName,
5415
- getScriptRunJournalStep: () => getScriptRunJournalStep,
5416
- getScriptRunByIdempotencyKey: () => getScriptRunByIdempotencyKey,
5417
- getScriptRun: () => getScriptRun,
5418
- getScheduledTasks: () => getScheduledTasks,
5419
- getScheduledTaskByName: () => getScheduledTaskByName,
5420
- getScheduledTaskById: () => getScheduledTaskById,
5421
- getRunningScriptRuns: () => getRunningScriptRuns,
5422
- getRootTaskChain: () => getRootTaskChain,
5423
- getRetryableSteps: () => getRetryableSteps,
5424
- getResolvedConfig: () => getResolvedConfig,
5425
- getRemainingCapacity: () => getRemainingCapacity,
5426
- getRecentlyFinishedWorkerTasks: () => getRecentlyFinishedWorkerTasks,
5427
- getRecentlyCancelledTasksForAgent: () => getRecentlyCancelledTasksForAgent,
5428
- getRecentFailedTasks: () => getRecentFailedTasks,
5429
- getRecentFailedCount: () => getRecentFailedCount,
5430
- getRecentCompletedCount: () => getRecentCompletedCount,
5431
- getRecentBudgetRefusalNotifications: () => getRecentBudgetRefusalNotifications,
5432
- getPromptTemplates: () => getPromptTemplates,
5433
- getPromptTemplateHistory: () => getPromptTemplateHistory,
5434
- getPromptTemplateById: () => getPromptTemplateById,
5435
- getPricingRows: () => getPricingRows,
5436
- getPendingWaitsByEvent: () => getPendingWaitsByEvent,
5437
- getPendingTaskForAgent: () => getPendingTaskForAgent,
5438
- getPendingSteeringForTask: () => getPendingSteeringForTask,
5439
- getPendingSteeringForAgent: () => getPendingSteeringForAgent,
5440
- getPendingEventWaitNames: () => getPendingEventWaitNames,
5441
- getPausedTasksForAgent: () => getPausedTasksForAgent,
5442
- getPageVersions: () => getPageVersions,
5443
- getPageVersion: () => getPageVersion,
5444
- getPageBySlug: () => getPageBySlug,
5445
- getPage: () => getPage,
5446
- getOrphanedInProgressTasksForAgent: () => getOrphanedInProgressTasksForAgent,
5447
- getOfferedTasksForAgent: () => getOfferedTasksForAgent,
5448
- getMostRecentTaskInThread: () => getMostRecentTaskInThread,
5449
- getMetricVersions: () => getMetricVersions,
5450
- getMetricVersion: () => getMetricVersion,
5451
- getMetricBySlug: () => getMetricBySlug,
5452
- getMetric: () => getMetric,
5453
- getMessageById: () => getMessageById,
5454
- getMentionsForAgent: () => getMentionsForAgent,
5455
- getMcpServerByName: () => getMcpServerByName,
5456
- getMcpServerById: () => getMcpServerById,
5457
- getLogsByTaskIdChronological: () => getLogsByTaskIdChronological,
5458
- getLogsByTaskId: () => getLogsByTaskId,
5459
- getLogsByEventType: () => getLogsByEventType,
5460
- getLogsByAgentId: () => getLogsByAgentId,
5461
- getLiveAgentCounts: () => getLiveAgentCounts,
5462
- getLeadAgent: () => getLeadAgent,
5463
- getLatestTaskByContextKey: () => getLatestTaskByContextKey,
5464
- getLatestStepForNode: () => getLatestStepForNode,
5465
- getLatestScriptRunStepTaskByContextKey: () => getLatestScriptRunStepTaskByContextKey,
5466
- getLatestPageBySlug: () => getLatestPageBySlug,
5467
- getLatestLeadTaskInThread: () => getLatestLeadTaskInThread,
5468
- getLatestContextVersion: () => getLatestContextVersion,
5469
- getLatestActiveTaskInThread: () => getLatestActiveTaskInThread,
5470
- getLastSuccessfulRun: () => getLastSuccessfulRun,
5471
- getLastRunStart: () => getLastRunStart,
5472
- getLastReadAt: () => getLastReadAt,
5473
- getKv: () => getKv,
5474
- getKeyStatuses: () => getKeyStatuses,
5475
- getKeyCostSummary: () => getKeyCostSummary,
5476
- getInstanceActivity: () => getInstanceActivity,
5477
- getInjectableGlobalConfigs: () => getInjectableGlobalConfigs,
5478
- getInboxSummary: () => getInboxSummary,
5479
- getInboxMessageById: () => getInboxMessageById,
5480
- getInProgressTasksByContextKey: () => getInProgressTasksByContextKey,
5481
- getInProgressSlackTasks: () => getInProgressSlackTasks,
5482
- getIdleWorkersWithCapacity: () => getIdleWorkersWithCapacity,
5483
- getFavoriteItemIdSet: () => getFavoriteItemIdSet,
5484
- getExpiredPendingApprovals: () => getExpiredPendingApprovals,
5485
- getDueWaitStates: () => getDueWaitStates,
5486
- getDueScheduledTasks: () => getDueScheduledTasks,
5487
- getDependentTasks: () => getDependentTasks,
5488
- getDb: () => getDb,
5489
- getDashboardCostSummary: () => getDashboardCostSummary,
5490
- getDailySpendGlobal: () => getDailySpendGlobal,
5491
- getDailySpendForUser: () => getDailySpendForUser,
5492
- getDailySpendForAgent: () => getDailySpendForAgent,
5493
- getContextVersionHistory: () => getContextVersionHistory,
5494
- getContextVersion: () => getContextVersion,
5495
- getContextSummaryByTaskId: () => getContextSummaryByTaskId,
5496
- getContextSnapshotsByTaskId: () => getContextSnapshotsByTaskId,
5497
- getContextSnapshotsBySessionId: () => getContextSnapshotsBySessionId,
5498
- getConcurrentContext: () => getConcurrentContext,
5499
- getCompletedStepNodeIds: () => getCompletedStepNodeIds,
5500
- getCompletedSlackTasks: () => getCompletedSlackTasks,
5501
- getChildTasks: () => getChildTasks,
5502
- getChannelMessages: () => getChannelMessages,
5503
- getChannelByName: () => getChannelByName,
5504
- getChannelById: () => getChannelById,
5505
- getChannelActivityCursor: () => getChannelActivityCursor,
5506
- getBudgets: () => getBudgets,
5507
- getBudgetRefusalNotification: () => getBudgetRefusalNotification,
5508
- getBudget: () => getBudget,
5509
- getAvailableKeyIndices: () => getAvailableKeyIndices,
5510
- getAssetKeyMappingByProvider: () => getAssetKeyMappingByProvider,
5511
- getAssetKeyMapping: () => getAssetKeyMapping,
5512
- getApprovalRequestByStepId: () => getApprovalRequestByStepId,
5513
- getApprovalRequestById: () => getApprovalRequestById,
5514
- getAppVersions: () => getAppVersions,
5515
- getAppVersion: () => getAppVersion,
5516
- getAllUsers: () => getAllUsers,
5517
- getAllTasks: () => getAllTasks,
5518
- getAllSessionCosts: () => getAllSessionCosts,
5519
- getAllServices: () => getAllServices,
5520
- getAllPricingRows: () => getAllPricingRows,
5521
- getAllLogs: () => getAllLogs,
5522
- getAllChannels: () => getAllChannels,
5523
- getAllChannelActivityCursors: () => getAllChannelActivityCursors,
5524
- getAllAgentsWithTasks: () => getAllAgentsWithTasks,
5525
- getAllAgents: () => getAllAgents,
5526
- getAllAgentMailInboxMappings: () => getAllAgentMailInboxMappings,
5527
- getAgentWorkingOnThread: () => getAgentWorkingOnThread,
5528
- getAgentWithTasks: () => getAgentWithTasks,
5529
- getAgentSkills: () => getAgentSkills,
5530
- getAgentMcpServers: () => getAgentMcpServers,
5531
- getAgentMailInboxMappingsByAgent: () => getAgentMailInboxMappingsByAgent,
5532
- getAgentMailInboxMapping: () => getAgentMailInboxMapping,
5533
- getAgentHarnessProviders: () => getAgentHarnessProviders,
5534
- getAgentCurrentTask: () => getAgentCurrentTask,
5535
- getAgentById: () => getAgentById,
5536
- getActiveTaskCount: () => getActiveTaskCount,
5537
- getActiveSessions: () => getActiveSessions,
5538
- getActiveSessionForTask: () => getActiveSessionForTask,
5539
- getActivePricingRow: () => getActivePricingRow,
5540
- generateDefaultToolsMd: () => generateDefaultToolsMd,
5541
- generateDefaultSoulMd: () => generateDefaultSoulMd,
5542
- generateDefaultIdentityMd: () => generateDefaultIdentityMd,
5543
- generateDefaultClaudeMd: () => generateDefaultClaudeMd,
5544
- findTaskByVcs: () => findTaskByVcs,
5545
- findTaskByGitHub: () => findTaskByGitHub,
5546
- findTaskByAgentMailThread: () => findTaskByAgentMailThread,
5547
- findRecentSimilarTasks: () => findRecentSimilarTasks,
5548
- findRecentCancelledTaskInThread: () => findRecentCancelledTaskInThread,
5549
- findExistingLinearTrackerContextWork: () => findExistingLinearTrackerContextWork,
5550
- findCompletedTaskInThread: () => findCompletedTaskInThread,
5551
- failTask: () => failTask,
5552
- failPendingResumeIfUnclaimed: () => failPendingResumeIfUnclaimed,
5553
- ensureSlackRenderV2Activation: () => ensureSlackRenderV2Activation,
5554
- detachTaskFromWorkflowRunStep: () => detachTaskFromWorkflowRunStep,
5555
- deleteWorkflow: () => deleteWorkflow,
5556
- deleteUser: () => deleteUser,
5557
- deleteTaskAttachment: () => deleteTaskAttachment,
5558
- deleteTask: () => deleteTask,
5559
- deleteSwarmRepo: () => deleteSwarmRepo,
5560
- deleteSwarmConfigByKey: () => deleteSwarmConfigByKey,
5561
- deleteSwarmConfig: () => deleteSwarmConfig,
5562
- deleteSlackMessageRecord: () => deleteSlackMessageRecord,
5563
- deleteSkillFile: () => deleteSkillFile,
5564
- deleteSkill: () => deleteSkill,
5565
- deleteServicesByAgentId: () => deleteServicesByAgentId,
5566
- deleteService: () => deleteService,
5567
- deleteScheduledTask: () => deleteScheduledTask,
5568
- deletePromptTemplate: () => deletePromptTemplate,
5569
- deletePricingRow: () => deletePricingRow,
5570
- deletePage: () => deletePage,
5571
- deleteMetric: () => deleteMetric,
5572
- deleteMcpServer: () => deleteMcpServer,
5573
- deleteKv: () => deleteKv,
5574
- deleteChannel: () => deleteChannel,
5575
- deleteBudget: () => deleteBudget,
5576
- deleteAgentMailInboxMapping: () => deleteAgentMailInboxMapping,
5577
- deleteAgent: () => deleteAgent,
5578
- deleteActiveSessionById: () => deleteActiveSessionById,
5579
- deleteActiveSession: () => deleteActiveSession,
5580
- createWorkflowVersion: () => createWorkflowVersion,
5581
- createWorkflowRunStep: () => createWorkflowRunStep,
5582
- createWorkflowRun: () => createWorkflowRun,
5583
- createWorkflow: () => createWorkflow,
5584
- createWaitState: () => createWaitState,
5585
- createUser: () => createUser,
5586
- createTaskExtended: () => createTaskExtended,
5587
- createTask: () => createTask,
5588
- createSwarmRepo: () => createSwarmRepo,
5589
- createSteeringMessage: () => createSteeringMessage,
5590
- createSkill: () => createSkill,
5591
- createSessionLogs: () => createSessionLogs,
5592
- createSessionCost: () => createSessionCost,
5593
- createService: () => createService,
5594
- createScriptRun: () => createScriptRun,
5595
- createScheduledTask: () => createScheduledTask,
5596
- createPageVersion: () => createPageVersion,
5597
- createPage: () => createPage,
5598
- createMetricVersion: () => createMetricVersion,
5599
- createMetric: () => createMetric,
5600
- createMcpServer: () => createMcpServer,
5601
- createLogEntry: () => createLogEntry,
5602
- createInboxMessage: () => createInboxMessage,
5603
- createContextVersion: () => createContextVersion,
5604
- createContextSnapshot: () => createContextSnapshot,
5605
- createChannel: () => createChannel,
5606
- createApprovalRequest: () => createApprovalRequest,
5607
- createAppVersion: () => createAppVersion,
5608
- createAgentMailInboxMapping: () => createAgentMailInboxMapping,
5609
- createAgent: () => createAgent,
5610
- countWorkflowRuns: () => countWorkflowRuns,
5611
- countSessions: () => countSessions,
5612
- countScriptRuns: () => countScriptRuns,
5613
- countScriptRunJournalSteps: () => countScriptRunJournalSteps,
5614
- countScriptRunJournalAgentTaskSteps: () => countScriptRunJournalAgentTaskSteps,
5615
- countPagesByAgent: () => countPagesByAgent,
5616
- countMetricsByAgent: () => countMetricsByAgent,
5617
- countKv: () => countKv,
5618
- countAllPages: () => countAllPages,
5619
- countAllMetrics: () => countAllMetrics,
5620
- countActiveScriptRuns: () => countActiveScriptRuns,
5621
- computeContentHash: () => computeContentHash,
5622
- completeTask: () => completeTask,
5623
- closeDb: () => closeDb,
5624
- clearKeyRateLimit: () => clearKeyRateLimit,
5625
- cleanupStaleSessions: () => cleanupStaleSessions,
5626
- cleanupAgentSessions: () => cleanupAgentSessions,
5627
- claimTask: () => claimTask,
5628
- claimOfferedTask: () => claimOfferedTask,
5629
- claimMentions: () => claimMentions,
5630
- claimInboxMessages: () => claimInboxMessages,
5631
- checkoutPromptTemplate: () => checkoutPromptTemplate,
5632
- checkDependencies: () => checkDependencies,
5633
- cascadeFailDependents: () => cascadeFailDependents,
5634
- cancelTask: () => cancelTask,
5635
- cancelPendingSteeringForTask: () => cancelPendingSteeringForTask,
5636
- buildRoutingAffinityFromAgent: () => buildRoutingAffinityFromAgent,
5637
- bindSlackMessageTimestamp: () => bindSlackMessageTimestamp,
5638
- backfillSupersedeTaskResumeTaskId: () => backfillSupersedeTaskResumeTaskId,
5639
- autoEncryptLegacyPlaintextSecrets: () => autoEncryptLegacyPlaintextSecrets,
5640
- assignUnassignedTaskPending: () => assignUnassignedTaskPending,
5641
- agentQueries: () => agentQueries,
5642
- acceptTask: () => acceptTask,
5643
- UNATTRIBUTED_USER_ID: () => UNATTRIBUTED_USER_ID,
5644
- SKILL_FILE_LIMITS: () => SKILL_FILE_LIMITS,
5253
+ KvTypeCollisionError: () => KvTypeCollisionError,
5645
5254
  MAX_EMPTY_POLLS: () => MAX_EMPTY_POLLS,
5646
- KvTypeCollisionError: () => KvTypeCollisionError
5255
+ SKILL_FILE_LIMITS: () => SKILL_FILE_LIMITS,
5256
+ UNATTRIBUTED_USER_ID: () => UNATTRIBUTED_USER_ID,
5257
+ __resetSqliteVecExtensionPathCacheForTests: () => __resetSqliteVecExtensionPathCacheForTests,
5258
+ acceptTask: () => acceptTask,
5259
+ agentQueries: () => agentQueries,
5260
+ assignUnassignedTaskPending: () => assignUnassignedTaskPending,
5261
+ autoEncryptLegacyPlaintextSecrets: () => autoEncryptLegacyPlaintextSecrets,
5262
+ backfillSupersedeTaskResumeTaskId: () => backfillSupersedeTaskResumeTaskId,
5263
+ bindSlackMessageTimestamp: () => bindSlackMessageTimestamp,
5264
+ buildRoutingAffinityFromAgent: () => buildRoutingAffinityFromAgent,
5265
+ cancelPendingSteeringForTask: () => cancelPendingSteeringForTask,
5266
+ cancelTask: () => cancelTask,
5267
+ cascadeFailDependents: () => cascadeFailDependents,
5268
+ checkDependencies: () => checkDependencies,
5269
+ checkoutPromptTemplate: () => checkoutPromptTemplate,
5270
+ claimInboxMessages: () => claimInboxMessages,
5271
+ claimMentions: () => claimMentions,
5272
+ claimOfferedTask: () => claimOfferedTask,
5273
+ claimTask: () => claimTask,
5274
+ cleanupAgentSessions: () => cleanupAgentSessions,
5275
+ cleanupStaleSessions: () => cleanupStaleSessions,
5276
+ clearKeyRateLimit: () => clearKeyRateLimit,
5277
+ closeDb: () => closeDb,
5278
+ completeTask: () => completeTask,
5279
+ computeContentHash: () => computeContentHash,
5280
+ countActiveScriptRuns: () => countActiveScriptRuns,
5281
+ countAllMetrics: () => countAllMetrics,
5282
+ countAllPages: () => countAllPages,
5283
+ countKv: () => countKv,
5284
+ countMetricsByAgent: () => countMetricsByAgent,
5285
+ countPagesByAgent: () => countPagesByAgent,
5286
+ countScriptRunJournalAgentTaskSteps: () => countScriptRunJournalAgentTaskSteps,
5287
+ countScriptRunJournalSteps: () => countScriptRunJournalSteps,
5288
+ countScriptRuns: () => countScriptRuns,
5289
+ countSessions: () => countSessions,
5290
+ countWorkflowRuns: () => countWorkflowRuns,
5291
+ createAgent: () => createAgent,
5292
+ createAgentMailInboxMapping: () => createAgentMailInboxMapping,
5293
+ createAppVersion: () => createAppVersion,
5294
+ createApprovalRequest: () => createApprovalRequest,
5295
+ createChannel: () => createChannel,
5296
+ createContextSnapshot: () => createContextSnapshot,
5297
+ createContextVersion: () => createContextVersion,
5298
+ createInboxMessage: () => createInboxMessage,
5299
+ createLogEntry: () => createLogEntry,
5300
+ createMcpServer: () => createMcpServer,
5301
+ createMetric: () => createMetric,
5302
+ createMetricVersion: () => createMetricVersion,
5303
+ createPage: () => createPage,
5304
+ createPageVersion: () => createPageVersion,
5305
+ createScheduledTask: () => createScheduledTask,
5306
+ createScriptRun: () => createScriptRun,
5307
+ createService: () => createService,
5308
+ createSessionCost: () => createSessionCost,
5309
+ createSessionLogs: () => createSessionLogs,
5310
+ createSkill: () => createSkill,
5311
+ createSteeringMessage: () => createSteeringMessage,
5312
+ createSwarmRepo: () => createSwarmRepo,
5313
+ createTask: () => createTask,
5314
+ createTaskExtended: () => createTaskExtended,
5315
+ createUser: () => createUser,
5316
+ createWaitState: () => createWaitState,
5317
+ createWorkflow: () => createWorkflow,
5318
+ createWorkflowRun: () => createWorkflowRun,
5319
+ createWorkflowRunStep: () => createWorkflowRunStep,
5320
+ createWorkflowVersion: () => createWorkflowVersion,
5321
+ deleteActiveSession: () => deleteActiveSession,
5322
+ deleteActiveSessionById: () => deleteActiveSessionById,
5323
+ deleteAgent: () => deleteAgent,
5324
+ deleteAgentMailInboxMapping: () => deleteAgentMailInboxMapping,
5325
+ deleteBudget: () => deleteBudget,
5326
+ deleteChannel: () => deleteChannel,
5327
+ deleteKv: () => deleteKv,
5328
+ deleteMcpServer: () => deleteMcpServer,
5329
+ deleteMetric: () => deleteMetric,
5330
+ deletePage: () => deletePage,
5331
+ deletePricingRow: () => deletePricingRow,
5332
+ deletePromptTemplate: () => deletePromptTemplate,
5333
+ deleteScheduledTask: () => deleteScheduledTask,
5334
+ deleteService: () => deleteService,
5335
+ deleteServicesByAgentId: () => deleteServicesByAgentId,
5336
+ deleteSkill: () => deleteSkill,
5337
+ deleteSkillFile: () => deleteSkillFile,
5338
+ deleteSlackMessageRecord: () => deleteSlackMessageRecord,
5339
+ deleteSwarmConfig: () => deleteSwarmConfig,
5340
+ deleteSwarmConfigByKey: () => deleteSwarmConfigByKey,
5341
+ deleteSwarmRepo: () => deleteSwarmRepo,
5342
+ deleteTask: () => deleteTask,
5343
+ deleteTaskAttachment: () => deleteTaskAttachment,
5344
+ deleteUser: () => deleteUser,
5345
+ deleteWorkflow: () => deleteWorkflow,
5346
+ detachTaskFromWorkflowRunStep: () => detachTaskFromWorkflowRunStep,
5347
+ ensureSlackRenderV2Activation: () => ensureSlackRenderV2Activation,
5348
+ failPendingResumeIfUnclaimed: () => failPendingResumeIfUnclaimed,
5349
+ failTask: () => failTask,
5350
+ findCompletedTaskInThread: () => findCompletedTaskInThread,
5351
+ findExistingLinearTrackerContextWork: () => findExistingLinearTrackerContextWork,
5352
+ findRecentCancelledTaskInThread: () => findRecentCancelledTaskInThread,
5353
+ findRecentSimilarTasks: () => findRecentSimilarTasks,
5354
+ findTaskByAgentMailThread: () => findTaskByAgentMailThread,
5355
+ findTaskByGitHub: () => findTaskByGitHub,
5356
+ findTaskByVcs: () => findTaskByVcs,
5357
+ generateDefaultClaudeMd: () => generateDefaultClaudeMd,
5358
+ generateDefaultIdentityMd: () => generateDefaultIdentityMd,
5359
+ generateDefaultSoulMd: () => generateDefaultSoulMd,
5360
+ generateDefaultToolsMd: () => generateDefaultToolsMd,
5361
+ getActivePricingRow: () => getActivePricingRow,
5362
+ getActiveSessionForTask: () => getActiveSessionForTask,
5363
+ getActiveSessions: () => getActiveSessions,
5364
+ getActiveTaskCount: () => getActiveTaskCount,
5365
+ getAgentById: () => getAgentById,
5366
+ getAgentCurrentTask: () => getAgentCurrentTask,
5367
+ getAgentHarnessProviders: () => getAgentHarnessProviders,
5368
+ getAgentMailInboxMapping: () => getAgentMailInboxMapping,
5369
+ getAgentMailInboxMappingsByAgent: () => getAgentMailInboxMappingsByAgent,
5370
+ getAgentMcpServers: () => getAgentMcpServers,
5371
+ getAgentSkills: () => getAgentSkills,
5372
+ getAgentWithTasks: () => getAgentWithTasks,
5373
+ getAgentWorkingOnThread: () => getAgentWorkingOnThread,
5374
+ getAllAgentMailInboxMappings: () => getAllAgentMailInboxMappings,
5375
+ getAllAgents: () => getAllAgents,
5376
+ getAllAgentsWithTasks: () => getAllAgentsWithTasks,
5377
+ getAllChannelActivityCursors: () => getAllChannelActivityCursors,
5378
+ getAllChannels: () => getAllChannels,
5379
+ getAllLogs: () => getAllLogs,
5380
+ getAllPricingRows: () => getAllPricingRows,
5381
+ getAllServices: () => getAllServices,
5382
+ getAllSessionCosts: () => getAllSessionCosts,
5383
+ getAllTasks: () => getAllTasks,
5384
+ getAllUsers: () => getAllUsers,
5385
+ getAppVersion: () => getAppVersion,
5386
+ getAppVersions: () => getAppVersions,
5387
+ getApprovalRequestById: () => getApprovalRequestById,
5388
+ getApprovalRequestByStepId: () => getApprovalRequestByStepId,
5389
+ getAssetKeyMapping: () => getAssetKeyMapping,
5390
+ getAssetKeyMappingByProvider: () => getAssetKeyMappingByProvider,
5391
+ getAttributionByPerson: () => getAttributionByPerson,
5392
+ getAvailableKeyIndices: () => getAvailableKeyIndices,
5393
+ getBudget: () => getBudget,
5394
+ getBudgetRefusalNotification: () => getBudgetRefusalNotification,
5395
+ getBudgets: () => getBudgets,
5396
+ getChannelActivityCursor: () => getChannelActivityCursor,
5397
+ getChannelById: () => getChannelById,
5398
+ getChannelByName: () => getChannelByName,
5399
+ getChannelMessages: () => getChannelMessages,
5400
+ getChildTasks: () => getChildTasks,
5401
+ getCompletedSlackTasks: () => getCompletedSlackTasks,
5402
+ getCompletedStepNodeIds: () => getCompletedStepNodeIds,
5403
+ getConcurrentContext: () => getConcurrentContext,
5404
+ getContextSnapshotsBySessionId: () => getContextSnapshotsBySessionId,
5405
+ getContextSnapshotsByTaskId: () => getContextSnapshotsByTaskId,
5406
+ getContextSummaryByTaskId: () => getContextSummaryByTaskId,
5407
+ getContextVersion: () => getContextVersion,
5408
+ getContextVersionHistory: () => getContextVersionHistory,
5409
+ getDailySpendForAgent: () => getDailySpendForAgent,
5410
+ getDailySpendForUser: () => getDailySpendForUser,
5411
+ getDailySpendGlobal: () => getDailySpendGlobal,
5412
+ getDashboardCostSummary: () => getDashboardCostSummary,
5413
+ getDb: () => getDb,
5414
+ getDependentTasks: () => getDependentTasks,
5415
+ getDueScheduledTasks: () => getDueScheduledTasks,
5416
+ getDueWaitStates: () => getDueWaitStates,
5417
+ getExpiredPendingApprovals: () => getExpiredPendingApprovals,
5418
+ getFavoriteItemIdSet: () => getFavoriteItemIdSet,
5419
+ getIdleWorkersWithCapacity: () => getIdleWorkersWithCapacity,
5420
+ getInProgressSlackTasks: () => getInProgressSlackTasks,
5421
+ getInProgressTasksByContextKey: () => getInProgressTasksByContextKey,
5422
+ getInboxMessageById: () => getInboxMessageById,
5423
+ getInboxSummary: () => getInboxSummary,
5424
+ getInjectableGlobalConfigs: () => getInjectableGlobalConfigs,
5425
+ getInstanceActivity: () => getInstanceActivity,
5426
+ getKeyCostSummary: () => getKeyCostSummary,
5427
+ getKeyStatuses: () => getKeyStatuses,
5428
+ getKv: () => getKv,
5429
+ getLastReadAt: () => getLastReadAt,
5430
+ getLastRunStart: () => getLastRunStart,
5431
+ getLastSuccessfulRun: () => getLastSuccessfulRun,
5432
+ getLatestActiveTaskInThread: () => getLatestActiveTaskInThread,
5433
+ getLatestContextVersion: () => getLatestContextVersion,
5434
+ getLatestLeadTaskInThread: () => getLatestLeadTaskInThread,
5435
+ getLatestPageBySlug: () => getLatestPageBySlug,
5436
+ getLatestScriptRunStepTaskByContextKey: () => getLatestScriptRunStepTaskByContextKey,
5437
+ getLatestStepForNode: () => getLatestStepForNode,
5438
+ getLatestTaskByContextKey: () => getLatestTaskByContextKey,
5439
+ getLeadAgent: () => getLeadAgent,
5440
+ getLiveAgentCounts: () => getLiveAgentCounts,
5441
+ getLogsByAgentId: () => getLogsByAgentId,
5442
+ getLogsByEventType: () => getLogsByEventType,
5443
+ getLogsByTaskId: () => getLogsByTaskId,
5444
+ getLogsByTaskIdChronological: () => getLogsByTaskIdChronological,
5445
+ getMcpServerById: () => getMcpServerById,
5446
+ getMcpServerByName: () => getMcpServerByName,
5447
+ getMentionsForAgent: () => getMentionsForAgent,
5448
+ getMessageById: () => getMessageById,
5449
+ getMetric: () => getMetric,
5450
+ getMetricBySlug: () => getMetricBySlug,
5451
+ getMetricVersion: () => getMetricVersion,
5452
+ getMetricVersions: () => getMetricVersions,
5453
+ getMostRecentTaskInThread: () => getMostRecentTaskInThread,
5454
+ getOfferedTasksForAgent: () => getOfferedTasksForAgent,
5455
+ getOrphanedInProgressTasksForAgent: () => getOrphanedInProgressTasksForAgent,
5456
+ getPage: () => getPage,
5457
+ getPageBySlug: () => getPageBySlug,
5458
+ getPageVersion: () => getPageVersion,
5459
+ getPageVersions: () => getPageVersions,
5460
+ getPausedTasksForAgent: () => getPausedTasksForAgent,
5461
+ getPendingEventWaitNames: () => getPendingEventWaitNames,
5462
+ getPendingSteeringForAgent: () => getPendingSteeringForAgent,
5463
+ getPendingSteeringForTask: () => getPendingSteeringForTask,
5464
+ getPendingTaskForAgent: () => getPendingTaskForAgent,
5465
+ getPendingWaitsByEvent: () => getPendingWaitsByEvent,
5466
+ getPricingRows: () => getPricingRows,
5467
+ getPromptTemplateById: () => getPromptTemplateById,
5468
+ getPromptTemplateHistory: () => getPromptTemplateHistory,
5469
+ getPromptTemplates: () => getPromptTemplates,
5470
+ getRecentBudgetRefusalNotifications: () => getRecentBudgetRefusalNotifications,
5471
+ getRecentCompletedCount: () => getRecentCompletedCount,
5472
+ getRecentFailedCount: () => getRecentFailedCount,
5473
+ getRecentFailedTasks: () => getRecentFailedTasks,
5474
+ getRecentlyCancelledTasksForAgent: () => getRecentlyCancelledTasksForAgent,
5475
+ getRecentlyFinishedWorkerTasks: () => getRecentlyFinishedWorkerTasks,
5476
+ getRemainingCapacity: () => getRemainingCapacity,
5477
+ getResolvedConfig: () => getResolvedConfig,
5478
+ getRetryableSteps: () => getRetryableSteps,
5479
+ getRootTaskChain: () => getRootTaskChain,
5480
+ getRunningScriptRuns: () => getRunningScriptRuns,
5481
+ getScheduledTaskById: () => getScheduledTaskById,
5482
+ getScheduledTaskByName: () => getScheduledTaskByName,
5483
+ getScheduledTasks: () => getScheduledTasks,
5484
+ getScriptRun: () => getScriptRun,
5485
+ getScriptRunByIdempotencyKey: () => getScriptRunByIdempotencyKey,
5486
+ getScriptRunJournalStep: () => getScriptRunJournalStep,
5487
+ getServiceByAgentAndName: () => getServiceByAgentAndName,
5488
+ getServiceById: () => getServiceById,
5489
+ getServicesByAgentId: () => getServicesByAgentId,
5490
+ getSessionCostSummary: () => getSessionCostSummary,
5491
+ getSessionCostsByAgentId: () => getSessionCostsByAgentId,
5492
+ getSessionCostsByTaskId: () => getSessionCostsByTaskId,
5493
+ getSessionCostsFiltered: () => getSessionCostsFiltered,
5494
+ getSessionLogsBySession: () => getSessionLogsBySession,
5495
+ getSessionLogsByTaskId: () => getSessionLogsByTaskId,
5496
+ getSkillById: () => getSkillById,
5497
+ getSkillByName: () => getSkillByName,
5498
+ getSkillFile: () => getSkillFile,
5499
+ getSkillFiles: () => getSkillFiles,
5500
+ getSlackMessageByChannelTs: () => getSlackMessageByChannelTs,
5501
+ getSlackOutcomeMessage: () => getSlackOutcomeMessage,
5502
+ getSlackRenderV2ActivatedAt: () => getSlackRenderV2ActivatedAt,
5503
+ getSlackTasksInThread: () => getSlackTasksInThread,
5504
+ getSlackTasksMissingTree: () => getSlackTasksMissingTree,
5505
+ getSlackTreeMessage: () => getSlackTreeMessage,
5506
+ getSlackTreeMessageByThread: () => getSlackTreeMessageByThread,
5507
+ getSlackTreeMessages: () => getSlackTreeMessages,
5508
+ getStalePinnedResumes: () => getStalePinnedResumes,
5509
+ getStaleUnassignedAffinityTasks: () => getStaleUnassignedAffinityTasks,
5510
+ getStalledInProgressTasks: () => getStalledInProgressTasks,
5511
+ getSteeringMessageById: () => getSteeringMessageById,
5512
+ getSteeringMessagesForTask: () => getSteeringMessagesForTask,
5513
+ getStepByIdempotencyKey: () => getStepByIdempotencyKey,
5514
+ getStepCountForNode: () => getStepCountForNode,
5515
+ getStuckApprovalRuns: () => getStuckApprovalRuns,
5516
+ getStuckWaitRuns: () => getStuckWaitRuns,
5517
+ getStuckWorkflowRuns: () => getStuckWorkflowRuns,
5518
+ getSwarmConfigById: () => getSwarmConfigById,
5519
+ getSwarmConfigLookupById: () => getSwarmConfigLookupById,
5520
+ getSwarmConfigs: () => getSwarmConfigs,
5521
+ getSwarmMetrics: () => getSwarmMetrics,
5522
+ getSwarmRepoById: () => getSwarmRepoById,
5523
+ getSwarmRepoByName: () => getSwarmRepoByName,
5524
+ getSwarmRepoByUrl: () => getSwarmRepoByUrl,
5525
+ getSwarmRepos: () => getSwarmRepos,
5526
+ getSystemDefaultSkills: () => getSystemDefaultSkills,
5527
+ getTaskAttachments: () => getTaskAttachments,
5528
+ getTaskById: () => getTaskById,
5529
+ getTaskByWorkflowRunStepId: () => getTaskByWorkflowRunStepId,
5530
+ getTaskStats: () => getTaskStats,
5531
+ getTasksByAgentId: () => getTasksByAgentId,
5532
+ getTasksByStatus: () => getTasksByStatus,
5533
+ getTasksCount: () => getTasksCount,
5534
+ getUnassignedPoolTasks: () => getUnassignedPoolTasks,
5535
+ getUnassignedTaskIds: () => getUnassignedTaskIds,
5536
+ getUnassignedTaskIdsForAgent: () => getUnassignedTaskIdsForAgent,
5537
+ getUnassignedTasksCount: () => getUnassignedTasksCount,
5538
+ getUnreadInboxMessages: () => getUnreadInboxMessages,
5539
+ getUnreadMessages: () => getUnreadMessages,
5540
+ getUserById: () => getUserById,
5541
+ getWaitStateById: () => getWaitStateById,
5542
+ getWaitStateByStepId: () => getWaitStateByStepId,
5543
+ getWorkflow: () => getWorkflow,
5544
+ getWorkflowRun: () => getWorkflowRun,
5545
+ getWorkflowRunStep: () => getWorkflowRunStep,
5546
+ getWorkflowRunStepsByRunId: () => getWorkflowRunStepsByRunId,
5547
+ getWorkflowVersion: () => getWorkflowVersion,
5548
+ getWorkflowVersions: () => getWorkflowVersions,
5549
+ getWorkflowsByScheduleId: () => getWorkflowsByScheduleId,
5550
+ hasBudgetRefusalNotificationToday: () => hasBudgetRefusalNotificationToday,
5551
+ hasCapacity: () => hasCapacity,
5552
+ hasFirstCompletedTask: () => hasFirstCompletedTask,
5553
+ hasNonTerminalRerouteDecisionChild: () => hasNonTerminalRerouteDecisionChild,
5554
+ hasNonTerminalResumeChild: () => hasNonTerminalResumeChild,
5555
+ hasPendingSteering: () => hasPendingSteering,
5556
+ heartbeatActiveSession: () => heartbeatActiveSession,
5557
+ incrKv: () => incrKv,
5558
+ incrementEmptyPollCount: () => incrementEmptyPollCount,
5559
+ incrementPageViewCount: () => incrementPageViewCount,
5560
+ initDb: () => initDb,
5561
+ insertActiveSession: () => insertActiveSession,
5562
+ insertPricingRow: () => insertPricingRow,
5563
+ insertTaskAttachment: () => insertTaskAttachment,
5564
+ installMcpServer: () => installMcpServer,
5565
+ installSkill: () => installSkill,
5566
+ installSystemDefaultSkillsForAgent: () => installSystemDefaultSkillsForAgent,
5567
+ isAgentEligibleForTask: () => isAgentEligibleForTask,
5568
+ isPendingSlackMessage: () => isPendingSlackMessage,
5569
+ isPoolAffinityEnforcementEnabled: () => isPoolAffinityEnforcementEnabled,
5570
+ isSqliteVecAvailable: () => isSqliteVecAvailable,
5571
+ listAgentsWithCredStatusByProvider: () => listAgentsWithCredStatusByProvider,
5572
+ listAllMetrics: () => listAllMetrics,
5573
+ listAllPages: () => listAllPages,
5574
+ listApprovalRequests: () => listApprovalRequests,
5575
+ listAssetSummaries: () => listAssetSummaries,
5576
+ listFavorites: () => listFavorites,
5577
+ listInboxState: () => listInboxState,
5578
+ listKv: () => listKv,
5579
+ listMcpServers: () => listMcpServers,
5580
+ listMetricsByAgent: () => listMetricsByAgent,
5581
+ listPagesByAgent: () => listPagesByAgent,
5582
+ listRecentSessions: () => listRecentSessions,
5583
+ listScriptRunJournalSteps: () => listScriptRunJournalSteps,
5584
+ listScriptRuns: () => listScriptRuns,
5585
+ listSkillFileManifest: () => listSkillFileManifest,
5586
+ listSkills: () => listSkills,
5587
+ listTaskTemplates: () => listTaskTemplates,
5588
+ listUserFavorites: () => listUserFavorites,
5589
+ listWorkflowRuns: () => listWorkflowRuns,
5590
+ listWorkflowRunsPage: () => listWorkflowRunsPage,
5591
+ listWorkflows: () => listWorkflows,
5592
+ logQueries: () => logQueries,
5593
+ markInboxMessageDelegated: () => markInboxMessageDelegated,
5594
+ markInboxMessageRead: () => markInboxMessageRead,
5595
+ markInboxMessageResponded: () => markInboxMessageResponded,
5596
+ markKeyRateLimited: () => markKeyRateLimited,
5597
+ markSlackTreeRendered: () => markSlackTreeRendered,
5598
+ markSteeringDelivered: () => markSteeringDelivered,
5599
+ markSteeringHandled: () => markSteeringHandled,
5600
+ markSteeringPromoted: () => markSteeringPromoted,
5601
+ markTaskSlackReplySent: () => markTaskSlackReplySent,
5602
+ markTasksNotified: () => markTasksNotified,
5603
+ maskSecrets: () => maskSecrets,
5604
+ moveAssetKey: () => moveAssetKey,
5605
+ moveTaskFromBacklog: () => moveTaskFromBacklog,
5606
+ moveTaskToBacklog: () => moveTaskToBacklog,
5607
+ normalizeSkillFilePath: () => normalizeSkillFilePath,
5608
+ overwriteTerminalTaskResultText: () => overwriteTerminalTaskResultText,
5609
+ pauseTask: () => pauseTask,
5610
+ postMessage: () => postMessage,
5611
+ reassociateSessionLogs: () => reassociateSessionLogs,
5612
+ recordBudgetRefusalNotification: () => recordBudgetRefusalNotification,
5613
+ recordInlineScriptRun: () => recordInlineScriptRun,
5614
+ recordKeyRateLimitWindows: () => recordKeyRateLimitWindows,
5615
+ recordKeyUsage: () => recordKeyUsage,
5616
+ recordSlackMessage: () => recordSlackMessage,
5617
+ recordTaskPullRequestAttachments: () => recordTaskPullRequestAttachments,
5618
+ rejectTask: () => rejectTask,
5619
+ releaseMentionProcessing: () => releaseMentionProcessing,
5620
+ releaseStaleMentionProcessing: () => releaseStaleMentionProcessing,
5621
+ releaseStaleOfferedTasksForOfflineAgents: () => releaseStaleOfferedTasksForOfflineAgents,
5622
+ releaseStaleProcessingInbox: () => releaseStaleProcessingInbox,
5623
+ releaseStaleReviewingTasks: () => releaseStaleReviewingTasks,
5624
+ releaseTask: () => releaseTask,
5625
+ replaceTaskAttachment: () => replaceTaskAttachment,
5626
+ reserveSlackMessage: () => reserveSlackMessage,
5627
+ resetEmptyPollCount: () => resetEmptyPollCount,
5628
+ resetOrphanedInProgressTasksForAgent: () => resetOrphanedInProgressTasksForAgent,
5629
+ resetPromptTemplateToDefault: () => resetPromptTemplateToDefault,
5630
+ resetTasksNotified: () => resetTasksNotified,
5631
+ resolveApprovalRequest: () => resolveApprovalRequest,
5632
+ resolvePromptTemplate: () => resolvePromptTemplate,
5633
+ resolveSqliteVecExtensionPath: () => resolveSqliteVecExtensionPath,
5634
+ resolveWaitState: () => resolveWaitState,
5635
+ resumeTask: () => resumeTask,
5636
+ searchSkills: () => searchSkills,
5637
+ sessionLogQueries: () => sessionLogQueries,
5638
+ setAgentHarnessProvider: () => setAgentHarnessProvider,
5639
+ setApiKeyName: () => setApiKeyName,
5640
+ setBudgetRefusalFollowUpTaskId: () => setBudgetRefusalFollowUpTaskId,
5641
+ setFavorite: () => setFavorite,
5642
+ setSlackMessageTracking: () => setSlackMessageTracking,
5643
+ setUserFavorite: () => setUserFavorite,
5644
+ shouldBlockPolling: () => shouldBlockPolling,
5645
+ startTask: () => startTask,
5646
+ supersedeTask: () => supersedeTask,
5647
+ sweepExpiredKv: () => sweepExpiredKv,
5648
+ sweepExpiredKvPrefix: () => sweepExpiredKvPrefix,
5649
+ taskQueries: () => taskQueries,
5650
+ toggleAgentSkill: () => toggleAgentSkill,
5651
+ uninstallMcpServer: () => uninstallMcpServer,
5652
+ uninstallSkill: () => uninstallSkill,
5653
+ updateActiveSessionProviderSessionId: () => updateActiveSessionProviderSessionId,
5654
+ updateAgentActivity: () => updateAgentActivity,
5655
+ updateAgentCredStatus: () => updateAgentCredStatus,
5656
+ updateAgentCredentialMissing: () => updateAgentCredentialMissing,
5657
+ updateAgentCredentialState: () => updateAgentCredentialState,
5658
+ updateAgentMaxTasks: () => updateAgentMaxTasks,
5659
+ updateAgentName: () => updateAgentName,
5660
+ updateAgentProfile: () => updateAgentProfile,
5661
+ updateAgentProvider: () => updateAgentProvider,
5662
+ updateAgentStatus: () => updateAgentStatus,
5663
+ updateAgentStatusFromCapacity: () => updateAgentStatusFromCapacity,
5664
+ updateApprovalRequestNotifications: () => updateApprovalRequestNotifications,
5665
+ updateMcpServer: () => updateMcpServer,
5666
+ updateMetric: () => updateMetric,
5667
+ updatePage: () => updatePage,
5668
+ updateReadState: () => updateReadState,
5669
+ updateScheduledTask: () => updateScheduledTask,
5670
+ updateScriptRun: () => updateScriptRun,
5671
+ updateServiceStatus: () => updateServiceStatus,
5672
+ updateSkill: () => updateSkill,
5673
+ updateSlackMessageRecord: () => updateSlackMessageRecord,
5674
+ updateSwarmRepo: () => updateSwarmRepo,
5675
+ updateTaskClaudeSessionId: () => updateTaskClaudeSessionId,
5676
+ updateTaskProgress: () => updateTaskProgress,
5677
+ updateTaskTitle: () => updateTaskTitle,
5678
+ updateTaskVcs: () => updateTaskVcs,
5679
+ updateUser: () => updateUser,
5680
+ updateWorkflow: () => updateWorkflow,
5681
+ updateWorkflowRun: () => updateWorkflowRun,
5682
+ updateWorkflowRunStep: () => updateWorkflowRunStep,
5683
+ upsertAssetKeyMapping: () => upsertAssetKeyMapping,
5684
+ upsertBudget: () => upsertBudget,
5685
+ upsertChannelActivityCursor: () => upsertChannelActivityCursor,
5686
+ upsertInboxState: () => upsertInboxState,
5687
+ upsertKv: () => upsertKv,
5688
+ upsertPromptTemplate: () => upsertPromptTemplate,
5689
+ upsertScriptRunJournalStep: () => upsertScriptRunJournalStep,
5690
+ upsertService: () => upsertService,
5691
+ upsertSkillFile: () => upsertSkillFile,
5692
+ upsertSkillFiles: () => upsertSkillFiles,
5693
+ upsertSwarmConfig: () => upsertSwarmConfig,
5694
+ withFavoriteFlags: () => withFavoriteFlags
5647
5695
  });
5648
5696
  import { Database } from "bun:sqlite";
5649
5697
  function assetKeyPrefixPattern(input) {
@@ -5672,6 +5720,24 @@ function taskContextForTelemetry(task) {
5672
5720
  function isSqliteVecAvailable() {
5673
5721
  return sqliteVecAvailable;
5674
5722
  }
5723
+ function resolveSqliteVecExtensionPath() {
5724
+ if (cachedSqliteVecExtensionPath !== null)
5725
+ return cachedSqliteVecExtensionPath;
5726
+ const extensionPath = process.env.SQLITE_VEC_EXTENSION_PATH;
5727
+ if (extensionPath) {
5728
+ cachedSqliteVecExtensionPath = extensionPath;
5729
+ return cachedSqliteVecExtensionPath;
5730
+ }
5731
+ try {
5732
+ cachedSqliteVecExtensionPath = require_sqlite_vec().getLoadablePath();
5733
+ } catch {
5734
+ cachedSqliteVecExtensionPath = undefined;
5735
+ }
5736
+ return cachedSqliteVecExtensionPath;
5737
+ }
5738
+ function __resetSqliteVecExtensionPathCacheForTests() {
5739
+ cachedSqliteVecExtensionPath = null;
5740
+ }
5675
5741
  function loadSqliteVec(database) {
5676
5742
  sqliteVecAvailable = false;
5677
5743
  try {
@@ -5715,7 +5781,17 @@ function initDb(dbPath = "./agent-swarm-db.sqlite") {
5715
5781
  database.run("PRAGMA mmap_size = 268435456;");
5716
5782
  database.run("PRAGMA temp_store = MEMORY;");
5717
5783
  loadSqliteVec(database);
5718
- runMigrations(database);
5784
+ try {
5785
+ runMigrations(database);
5786
+ } catch (error) {
5787
+ db = null;
5788
+ try {
5789
+ database.close();
5790
+ } catch (closeError) {
5791
+ console.error("[migrations] Failed to close database after migration failure:", closeError);
5792
+ }
5793
+ throw error;
5794
+ }
5719
5795
  ensureAgentProfileColumns(database);
5720
5796
  try {
5721
5797
  const taskSchemaInfo = db.prepare("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = 'agent_tasks'").get();
@@ -5933,6 +6009,10 @@ function updateAgentCredentialState(agentId, ready, missing) {
5933
6009
  resetEmptyPollCount(agentId);
5934
6010
  return row ? rowToAgent(row) : null;
5935
6011
  }
6012
+ function updateAgentCredentialMissing(agentId, missing) {
6013
+ const json = missing && missing.length > 0 ? JSON.stringify(missing) : null;
6014
+ getDb().prepare("UPDATE agents SET credentialMissing = ?, lastUpdatedAt = strftime('%Y-%m-%dT%H:%M:%fZ', 'now') WHERE id = ?").run(json, agentId);
6015
+ }
5936
6016
  function createAgent(agent) {
5937
6017
  const id = agent.id ?? crypto.randomUUID();
5938
6018
  const maxTasks = agent.maxTasks ?? 1;
@@ -6040,7 +6120,9 @@ function deleteAgent(id) {
6040
6120
  return result.changes > 0;
6041
6121
  }
6042
6122
  function getActiveTaskCount(agentId) {
6043
- const result = getDb().prepare("SELECT COUNT(*) as count FROM agent_tasks WHERE agentId = ? AND status = 'in_progress'").get(agentId);
6123
+ const result = getDb().prepare(`SELECT COUNT(*) as count FROM agent_tasks
6124
+ WHERE (agentId = ? AND status = 'in_progress')
6125
+ OR (offeredTo = ? AND status = 'reviewing')`).get(agentId, agentId);
6044
6126
  return result?.count ?? 0;
6045
6127
  }
6046
6128
  function hasCapacity(agentId) {
@@ -6583,9 +6665,18 @@ function updateTaskTitle(taskId, title) {
6583
6665
  return row ? rowToAgentTask(row) : null;
6584
6666
  }
6585
6667
  function updateTaskVcs(taskId, vcs) {
6586
- const row = getDb().prepare(`UPDATE agent_tasks
6587
- SET vcsProvider = ?, vcsRepo = ?, vcsNumber = ?, vcsUrl = ?, lastUpdatedAt = ?
6588
- WHERE id = ? RETURNING *`).get(vcs.vcsProvider, vcs.vcsRepo, vcs.vcsNumber, vcs.vcsUrl, new Date().toISOString(), taskId);
6668
+ const row = getDb().transaction(() => {
6669
+ const updated = getDb().prepare(`UPDATE agent_tasks
6670
+ SET vcsProvider = ?, vcsRepo = ?, vcsNumber = ?, vcsUrl = ?, lastUpdatedAt = ?
6671
+ WHERE id = ? RETURNING *`).get(vcs.vcsProvider, vcs.vcsRepo, vcs.vcsNumber, vcs.vcsUrl, new Date().toISOString(), taskId);
6672
+ if (updated) {
6673
+ reconcileTaskPullRequestAttachments(taskId, updated.agentId, [
6674
+ updated.output,
6675
+ vcs.vcsProvider === "github" ? vcs.vcsUrl : null
6676
+ ]);
6677
+ }
6678
+ return updated;
6679
+ })();
6589
6680
  return row ? rowToAgentTask(row) : null;
6590
6681
  }
6591
6682
  function getTasksByAgentId(agentId) {
@@ -7020,13 +7111,24 @@ function completeTask(id, output) {
7020
7111
  if (isTerminalTaskStatus(oldTask.status)) {
7021
7112
  return null;
7022
7113
  }
7023
- const finishedAt = new Date().toISOString();
7024
- let row = taskQueries.updateStatus().get("completed", finishedAt, id);
7114
+ const row = getDb().transaction(() => {
7115
+ const finishedAt = new Date().toISOString();
7116
+ let completed = taskQueries.updateStatus().get("completed", finishedAt, id);
7117
+ if (!completed)
7118
+ return null;
7119
+ if (output) {
7120
+ completed = taskQueries.setOutput().get(scrubSecrets(output), id);
7121
+ }
7122
+ if (completed) {
7123
+ reconcileTaskPullRequestAttachments(id, completed.agentId, [
7124
+ completed.output,
7125
+ completed.vcsProvider === "github" ? completed.vcsUrl : null
7126
+ ]);
7127
+ }
7128
+ return completed;
7129
+ })();
7025
7130
  if (!row)
7026
7131
  return null;
7027
- if (output) {
7028
- row = taskQueries.setOutput().get(scrubSecrets(output), id);
7029
- }
7030
7132
  if (row && oldTask) {
7031
7133
  emitTaskLifecycleTelemetryAfterCommit("completed", {
7032
7134
  taskId: id,
@@ -7044,17 +7146,15 @@ function completeTask(id, output) {
7044
7146
  newValue: "completed"
7045
7147
  });
7046
7148
  } catch {}
7047
- try {
7048
- import("./event-bus-axn823e9.js").then(({ workflowEventBus }) => {
7049
- workflowEventBus.emit("task.completed", {
7050
- taskId: id,
7051
- output,
7052
- agentId: row.agentId,
7053
- workflowRunId: row.workflowRunId,
7054
- workflowRunStepId: row.workflowRunStepId
7055
- });
7149
+ import("./event-bus-n8sb35pw.js").then(({ workflowEventBus }) => {
7150
+ workflowEventBus.emit("task.completed", {
7151
+ taskId: id,
7152
+ output,
7153
+ agentId: row.agentId,
7154
+ workflowRunId: row.workflowRunId,
7155
+ workflowRunStepId: row.workflowRunStepId
7056
7156
  });
7057
- } catch {}
7157
+ }).catch((err) => console.error("[db] task.completed event not emitted:", scrubSecrets(err instanceof Error ? err.message : String(err))));
7058
7158
  try {
7059
7159
  promotePendingSteeringForTask(id, "Task completed before steering was delivered");
7060
7160
  } catch (error) {
@@ -7091,17 +7191,15 @@ function failTask(id, reason) {
7091
7191
  metadata: { reason: scrubbedReason }
7092
7192
  });
7093
7193
  } catch {}
7094
- try {
7095
- import("./event-bus-axn823e9.js").then(({ workflowEventBus }) => {
7096
- workflowEventBus.emit("task.failed", {
7097
- taskId: id,
7098
- failureReason: reason,
7099
- agentId: row.agentId,
7100
- workflowRunId: row.workflowRunId,
7101
- workflowRunStepId: row.workflowRunStepId
7102
- });
7194
+ import("./event-bus-n8sb35pw.js").then(({ workflowEventBus }) => {
7195
+ workflowEventBus.emit("task.failed", {
7196
+ taskId: id,
7197
+ failureReason: reason,
7198
+ agentId: row.agentId,
7199
+ workflowRunId: row.workflowRunId,
7200
+ workflowRunStepId: row.workflowRunStepId
7103
7201
  });
7104
- } catch {}
7202
+ }).catch((err) => console.error("[db] task.failed event not emitted:", scrubSecrets(err instanceof Error ? err.message : String(err))));
7105
7203
  try {
7106
7204
  promotePendingSteeringForTask(id, "Task failed before steering was delivered");
7107
7205
  } catch (error) {
@@ -7121,7 +7219,16 @@ function overwriteTerminalTaskResultText(id, patch) {
7121
7219
  return null;
7122
7220
  const output = patch.output !== undefined ? scrubSecrets(patch.output) : task.output ?? null;
7123
7221
  const failureReason = patch.failureReason !== undefined ? scrubSecrets(patch.failureReason) : task.failureReason ?? null;
7124
- const row = taskQueries.setTerminalResultText().get(output, failureReason, id) ?? null;
7222
+ const row = getDb().transaction(() => {
7223
+ const updated = taskQueries.setTerminalResultText().get(output, failureReason, id) ?? null;
7224
+ if (updated && patch.output !== undefined) {
7225
+ reconcileTaskPullRequestAttachments(id, updated.agentId, [
7226
+ updated.output,
7227
+ updated.vcsProvider === "github" ? updated.vcsUrl : null
7228
+ ]);
7229
+ }
7230
+ return updated;
7231
+ })();
7125
7232
  return row ? rowToAgentTask(row) : task;
7126
7233
  }
7127
7234
  function cancelTask(id, reason) {
@@ -7152,16 +7259,14 @@ function cancelTask(id, reason) {
7152
7259
  metadata: reason ? { reason } : undefined
7153
7260
  });
7154
7261
  } catch {}
7155
- try {
7156
- import("./event-bus-axn823e9.js").then(({ workflowEventBus }) => {
7157
- workflowEventBus.emit("task.cancelled", {
7158
- taskId: id,
7159
- agentId: row.agentId,
7160
- workflowRunId: row.workflowRunId,
7161
- workflowRunStepId: row.workflowRunStepId
7162
- });
7262
+ import("./event-bus-n8sb35pw.js").then(({ workflowEventBus }) => {
7263
+ workflowEventBus.emit("task.cancelled", {
7264
+ taskId: id,
7265
+ agentId: row.agentId,
7266
+ workflowRunId: row.workflowRunId,
7267
+ workflowRunStepId: row.workflowRunStepId
7163
7268
  });
7164
- } catch {}
7269
+ }).catch((err) => console.error("[db] task.cancelled event not emitted:", scrubSecrets(err instanceof Error ? err.message : String(err))));
7165
7270
  try {
7166
7271
  promotePendingSteeringForTask(id, "Task was cancelled before steering was delivered");
7167
7272
  } catch (error) {
@@ -7208,18 +7313,16 @@ function supersedeTask(id, args) {
7208
7313
  metadata: { reason: args.reason, resumeTaskId: args.resumeTaskId }
7209
7314
  });
7210
7315
  } catch {}
7211
- try {
7212
- import("./event-bus-axn823e9.js").then(({ workflowEventBus }) => {
7213
- workflowEventBus.emit("task.superseded", {
7214
- taskId: id,
7215
- reason: args.reason,
7216
- resumeTaskId: args.resumeTaskId,
7217
- agentId: row.agentId,
7218
- workflowRunId: row.workflowRunId,
7219
- workflowRunStepId: row.workflowRunStepId
7220
- });
7316
+ import("./event-bus-n8sb35pw.js").then(({ workflowEventBus }) => {
7317
+ workflowEventBus.emit("task.superseded", {
7318
+ taskId: id,
7319
+ reason: args.reason,
7320
+ resumeTaskId: args.resumeTaskId,
7321
+ agentId: row.agentId,
7322
+ workflowRunId: row.workflowRunId,
7323
+ workflowRunStepId: row.workflowRunStepId
7221
7324
  });
7222
- } catch {}
7325
+ }).catch((err) => console.error("[db] task.superseded event not emitted:", scrubSecrets(err instanceof Error ? err.message : String(err))));
7223
7326
  try {
7224
7327
  cascadeFailDependents(id, "superseded");
7225
7328
  } catch (err) {
@@ -7373,15 +7476,13 @@ function updateTaskProgress(id, progress) {
7373
7476
  newValue: scrubbedProgress
7374
7477
  });
7375
7478
  } catch {}
7376
- try {
7377
- import("./event-bus-axn823e9.js").then(({ workflowEventBus }) => {
7378
- workflowEventBus.emit("task.progress", {
7379
- taskId: id,
7380
- progress: scrubbedProgress,
7381
- agentId: row.agentId
7382
- });
7479
+ import("./event-bus-n8sb35pw.js").then(({ workflowEventBus }) => {
7480
+ workflowEventBus.emit("task.progress", {
7481
+ taskId: id,
7482
+ progress: scrubbedProgress,
7483
+ agentId: row.agentId
7383
7484
  });
7384
- } catch {}
7485
+ }).catch((err) => console.error("[db] task.progress event not emitted:", scrubSecrets(err instanceof Error ? err.message : String(err))));
7385
7486
  }
7386
7487
  return row ? rowToAgentTask(row) : null;
7387
7488
  }
@@ -7446,6 +7547,55 @@ function insertTaskAttachment(input) {
7446
7547
  return attachment;
7447
7548
  })();
7448
7549
  }
7550
+ function pullRequestKey(pullRequest) {
7551
+ return `${pullRequest.owner.toLowerCase()}/${pullRequest.repo.toLowerCase()}#${pullRequest.number}`;
7552
+ }
7553
+ function recordTaskPullRequestAttachments(taskId, agentId, text) {
7554
+ const pullRequests = extractGitHubPullRequestUrls(text);
7555
+ if (pullRequests.length === 0)
7556
+ return [];
7557
+ const existingPullRequests = new Set(getDb().prepare("SELECT url FROM task_attachments WHERE task_id = ? AND kind = 'url' AND url IS NOT NULL").all(taskId).flatMap((row) => extractGitHubPullRequestUrls(row.url)).map(pullRequestKey));
7558
+ const stored = [];
7559
+ for (const pullRequest of pullRequests) {
7560
+ const dedupeKey = pullRequestKey(pullRequest);
7561
+ if (existingPullRequests.has(dedupeKey))
7562
+ continue;
7563
+ stored.push(insertTaskAttachment({
7564
+ taskId,
7565
+ agentId,
7566
+ name: `GitHub pull request #${pullRequest.number}`,
7567
+ kind: "url",
7568
+ url: pullRequest.url,
7569
+ providerId: GENERATED_PULL_REQUEST_PROVIDER_ID,
7570
+ capabilities: {
7571
+ [SERVER_GENERATED_ATTACHMENT_CAPABILITY]: GENERATED_PULL_REQUEST_SOURCE
7572
+ },
7573
+ intent: GENERATED_PULL_REQUEST_INTENT,
7574
+ description: GENERATED_PULL_REQUEST_DESCRIPTION
7575
+ }));
7576
+ existingPullRequests.add(dedupeKey);
7577
+ }
7578
+ return stored;
7579
+ }
7580
+ function reconcileTaskPullRequestAttachments(taskId, agentId, sourceTexts) {
7581
+ const desiredPullRequests = sourceTexts.flatMap(extractGitHubPullRequestUrls);
7582
+ const desiredKeys = new Set(desiredPullRequests.map(pullRequestKey));
7583
+ const generatedRows = getDb().prepare(`SELECT id, name, url
7584
+ FROM task_attachments
7585
+ WHERE task_id = ?
7586
+ AND kind = 'url'
7587
+ AND url IS NOT NULL
7588
+ AND json_extract(capabilities, '$.${SERVER_GENERATED_ATTACHMENT_CAPABILITY}') = ?`).all(taskId, GENERATED_PULL_REQUEST_SOURCE);
7589
+ for (const row of generatedRows) {
7590
+ const pullRequest = extractGitHubPullRequestUrls(row.url)[0];
7591
+ const expectedName = pullRequest ? `GitHub pull request #${pullRequest.number}` : null;
7592
+ if (!pullRequest || row.name !== expectedName || !desiredKeys.has(pullRequestKey(pullRequest))) {
7593
+ getDb().run("DELETE FROM task_attachments WHERE id = ?", [row.id]);
7594
+ }
7595
+ }
7596
+ return recordTaskPullRequestAttachments(taskId, agentId, desiredPullRequests.map((pullRequest) => pullRequest.url).join(`
7597
+ `));
7598
+ }
7449
7599
  function insertTaskAttachmentRow(input) {
7450
7600
  const db2 = getDb();
7451
7601
  if (input.sha256) {
@@ -7986,6 +8136,11 @@ function findRecentSimilarTasks(opts) {
7986
8136
  return getDb().prepare(query).all(...params).map(rowToAgentTask);
7987
8137
  }
7988
8138
  function createTaskExtended(task, options) {
8139
+ if (typeof task !== "string" || task.trim().length === 0) {
8140
+ throw new Error("createTaskExtended: 'task' must be a non-empty string");
8141
+ }
8142
+ options = CreateTaskOptionsSchema.parse(options ?? {});
8143
+ let requestedByUserIdInherited = false;
7989
8144
  const id = crypto.randomUUID();
7990
8145
  const now = new Date().toISOString();
7991
8146
  const status = options?.offeredTo ? "offered" : options?.agentId ? "pending" : options?.status === "backlog" ? "backlog" : "unassigned";
@@ -8052,6 +8207,7 @@ function createTaskExtended(task, options) {
8052
8207
  }
8053
8208
  if (parent.requestedByUserId && !options.requestedByUserId) {
8054
8209
  options.requestedByUserId = parent.requestedByUserId;
8210
+ requestedByUserIdInherited = true;
8055
8211
  }
8056
8212
  if (parent.key && !options.key) {
8057
8213
  options.key = parent.key;
@@ -8121,8 +8277,8 @@ function createTaskExtended(task, options) {
8121
8277
  vcsInstallationId, vcsNodeId,
8122
8278
  agentmailInboxId, agentmailMessageId, agentmailThreadId,
8123
8279
  mentionMessageId, mentionChannelId, dir, parentTaskId, model, modelTier, effort, scheduleId,
8124
- workflowRunId, workflowRunStepId, outputSchema, followUpConfig, requestedByUserId, contextKey, routingAffinity, swarmVersion, createdAt, lastUpdatedAt, created_by, updated_by
8125
- ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING *`).get(id, assetKey, options?.agentId ?? null, options?.creatorAgentId ?? null, task, status, options?.source ?? "mcp", options?.taskType ?? null, JSON.stringify(options?.tags ?? []), options?.priority ?? 50, JSON.stringify(options?.dependsOn ?? []), options?.offeredTo ?? null, options?.offeredTo ? now : null, options?.slackChannelId ?? null, options?.slackThreadTs ?? null, options?.slackTriggerMessageTs ?? null, options?.slackUserId ?? null, options?.vcsProvider ?? null, options?.vcsRepo ?? null, options?.vcsEventType ?? null, options?.vcsNumber ?? null, options?.vcsCommentId ?? null, options?.vcsAuthor ?? null, options?.vcsUrl ?? null, options?.vcsInstallationId ?? null, options?.vcsNodeId ?? null, options?.agentmailInboxId ?? null, options?.agentmailMessageId ?? null, options?.agentmailThreadId ?? null, options?.mentionMessageId ?? null, options?.mentionChannelId ?? null, options?.dir ?? null, options?.parentTaskId ?? null, options?.model ?? null, options?.modelTier ?? null, options?.effort ?? null, options?.scheduleId ?? null, options?.workflowRunId ?? null, options?.workflowRunStepId ?? null, options?.outputSchema ? JSON.stringify(options.outputSchema) : null, options?.followUpConfig ? JSON.stringify(options.followUpConfig) : null, options?.requestedByUserId ?? null, options?.contextKey ?? null, options?.routingAffinity ? JSON.stringify(options.routingAffinity) : null, package_default.version, now, now, auditUserId, auditUserId);
8280
+ workflowRunId, workflowRunStepId, outputSchema, followUpConfig, requestedByUserId, requestedByUserIdInherited, contextKey, routingAffinity, swarmVersion, createdAt, lastUpdatedAt, created_by, updated_by
8281
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING *`).get(id, assetKey, options?.agentId ?? null, options?.creatorAgentId ?? null, task, status, options?.source ?? "mcp", options?.taskType ?? null, JSON.stringify(options?.tags ?? []), options?.priority ?? 50, JSON.stringify(options?.dependsOn ?? []), options?.offeredTo ?? null, options?.offeredTo ? now : null, options?.slackChannelId ?? null, options?.slackThreadTs ?? null, options?.slackTriggerMessageTs ?? null, options?.slackUserId ?? null, options?.vcsProvider ?? null, options?.vcsRepo ?? null, options?.vcsEventType ?? null, options?.vcsNumber ?? null, options?.vcsCommentId ?? null, options?.vcsAuthor ?? null, options?.vcsUrl ?? null, options?.vcsInstallationId ?? null, options?.vcsNodeId ?? null, options?.agentmailInboxId ?? null, options?.agentmailMessageId ?? null, options?.agentmailThreadId ?? null, options?.mentionMessageId ?? null, options?.mentionChannelId ?? null, options?.dir ?? null, options?.parentTaskId ?? null, options?.model ?? null, options?.modelTier ?? null, options?.effort ?? null, options?.scheduleId ?? null, options?.workflowRunId ?? null, options?.workflowRunStepId ?? null, options?.outputSchema ? JSON.stringify(options.outputSchema) : null, options?.followUpConfig ? JSON.stringify(options.followUpConfig) : null, options?.requestedByUserId ?? null, requestedByUserIdInherited ? 1 : 0, options?.contextKey ?? null, options?.routingAffinity ? JSON.stringify(options.routingAffinity) : null, package_default.version, now, now, auditUserId, auditUserId);
8126
8282
  if (!row)
8127
8283
  throw new Error("Failed to create task");
8128
8284
  try {
@@ -8141,19 +8297,17 @@ function createTaskExtended(task, options) {
8141
8297
  hasParent: !!row.parentTaskId,
8142
8298
  priority: row.priority
8143
8299
  }, (task2) => task2 !== null);
8144
- try {
8145
- import("./event-bus-axn823e9.js").then(({ workflowEventBus }) => {
8146
- workflowEventBus.emit("task.created", {
8147
- taskId: row.id,
8148
- task: row.task,
8149
- source: row.source,
8150
- tags: options?.tags ?? [],
8151
- agentId: row.agentId,
8152
- workflowRunId: row.workflowRunId,
8153
- workflowRunStepId: row.workflowRunStepId
8154
- });
8300
+ import("./event-bus-n8sb35pw.js").then(({ workflowEventBus }) => {
8301
+ workflowEventBus.emit("task.created", {
8302
+ taskId: row.id,
8303
+ task: row.task,
8304
+ source: row.source,
8305
+ tags: options?.tags ?? [],
8306
+ agentId: row.agentId,
8307
+ workflowRunId: row.workflowRunId,
8308
+ workflowRunStepId: row.workflowRunStepId
8155
8309
  });
8156
- } catch {}
8310
+ }).catch((err) => console.error("[db] task.created event not emitted:", scrubSecrets(err instanceof Error ? err.message : String(err))));
8157
8311
  return rowToAgentTask(row);
8158
8312
  }
8159
8313
  function claimTask(taskId, agentId) {
@@ -8313,6 +8467,17 @@ function releaseStaleReviewingTasks(timeoutMinutes = 30) {
8313
8467
  WHERE status = 'reviewing' AND lastUpdatedAt < ?`, [now, cutoffTime]);
8314
8468
  return result.changes;
8315
8469
  }
8470
+ function releaseStaleOfferedTasksForOfflineAgents() {
8471
+ const now = new Date().toISOString();
8472
+ const result = getDb().run(`UPDATE agent_tasks
8473
+ SET status = 'unassigned', offeredTo = NULL, offeredAt = NULL, lastUpdatedAt = ?
8474
+ WHERE status = 'offered'
8475
+ AND offeredTo IS NOT NULL
8476
+ AND NOT EXISTS (
8477
+ SELECT 1 FROM agents WHERE agents.id = agent_tasks.offeredTo AND agents.status != 'offline'
8478
+ )`, [now]);
8479
+ return result.changes;
8480
+ }
8316
8481
  function getOfferedTasksForAgent(agentId) {
8317
8482
  return getDb().prepare("SELECT * FROM agent_tasks WHERE offeredTo = ? AND status = 'offered' ORDER BY createdAt ASC, rowid ASC").all(agentId).map(rowToAgentTask);
8318
8483
  }
@@ -8424,6 +8589,24 @@ function updateAgentProfile(id, updates, meta) {
8424
8589
  const current = database.prepare("SELECT * FROM agents WHERE id = ?").get(id);
8425
8590
  if (!current)
8426
8591
  return null;
8592
+ for (const field of BUDGETED_IDENTITY_FIELDS) {
8593
+ const nextValue = updates[field];
8594
+ if (nextValue === undefined)
8595
+ continue;
8596
+ const result = checkIdentityFieldBudget({
8597
+ field,
8598
+ currentValue: current[field] ?? "",
8599
+ nextValue
8600
+ });
8601
+ if (!result.ok) {
8602
+ throw new IdentityFieldBudgetError(result, computeContentHash(current[field] ?? ""), computeContentHash(nextValue));
8603
+ }
8604
+ }
8605
+ if (updates.name !== undefined) {
8606
+ const existingAgent = database.prepare("SELECT * FROM agents WHERE name = ? AND id != ?").get(updates.name, id);
8607
+ if (existingAgent)
8608
+ throw new Error("Agent name already exists");
8609
+ }
8427
8610
  for (const field of VERSIONABLE_FIELDS) {
8428
8611
  const newValue = updates[field];
8429
8612
  if (newValue === undefined || newValue === null)
@@ -8451,6 +8634,7 @@ function updateAgentProfile(id, updates, meta) {
8451
8634
  const avatarJson = updates.avatar ? JSON.stringify(updates.avatar) : null;
8452
8635
  const now = new Date().toISOString();
8453
8636
  const row = database.prepare(`UPDATE agents SET
8637
+ name = COALESCE(?, name),
8454
8638
  description = COALESCE(?, description),
8455
8639
  role = COALESCE(?, role),
8456
8640
  capabilities = COALESCE(?, capabilities),
@@ -8462,18 +8646,12 @@ function updateAgentProfile(id, updates, meta) {
8462
8646
  heartbeatMd = COALESCE(?, heartbeatMd),
8463
8647
  avatar = CASE WHEN ? = 1 THEN ? ELSE avatar END,
8464
8648
  lastUpdatedAt = ?
8465
- WHERE id = ? RETURNING *`).get(updates.description ?? null, updates.role ?? null, updates.capabilities ? JSON.stringify(updates.capabilities) : null, updates.claudeMd ?? null, updates.soulMd ?? null, updates.identityMd ?? null, updates.setupScript ?? null, updates.toolsMd ?? null, updates.heartbeatMd ?? null, avatarProvided ? 1 : 0, avatarJson, now, id);
8649
+ WHERE id = ? RETURNING *`).get(updates.name ?? null, updates.description ?? null, updates.role ?? null, updates.capabilities ? JSON.stringify(updates.capabilities) : null, updates.claudeMd ?? null, updates.soulMd ?? null, updates.identityMd ?? null, updates.setupScript ?? null, updates.toolsMd ?? null, updates.heartbeatMd ?? null, avatarProvided ? 1 : 0, avatarJson, now, id);
8466
8650
  return row ? rowToAgent(row) : null;
8467
8651
  })();
8468
8652
  }
8469
8653
  function updateAgentName(id, newName) {
8470
- const existingAgent = getDb().prepare("SELECT * FROM agents WHERE name = ? AND id != ?").get(newName, id);
8471
- if (existingAgent) {
8472
- throw new Error("Agent name already exists");
8473
- }
8474
- const now = new Date().toISOString();
8475
- const row = getDb().prepare("UPDATE agents SET name = ?, lastUpdatedAt = ? WHERE id = ? RETURNING *").get(newName, now, id);
8476
- return row ? rowToAgent(row) : null;
8654
+ return updateAgentProfile(id, { name: newName });
8477
8655
  }
8478
8656
  function rowToChannel(row) {
8479
8657
  return {
@@ -9017,13 +9195,14 @@ function getSessionCostSummary(opts) {
9017
9195
  params.push(opts.agentId);
9018
9196
  }
9019
9197
  if (opts.userId === UNATTRIBUTED_USER_ID) {
9020
- conditions.push("t.requestedByUserId IS NULL");
9198
+ conditions.push(`(t.requestedByUserId IS NULL OR ${HUMAN_FREE_SQL})`);
9021
9199
  } else if (opts.userId) {
9022
- conditions.push("t.requestedByUserId = ?");
9200
+ conditions.push(`(t.requestedByUserId = ? AND NOT ${HUMAN_FREE_SQL})`);
9023
9201
  params.push(opts.userId);
9024
9202
  }
9025
9203
  const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
9026
- const totalsRow = getDb().prepare(`SELECT
9204
+ const totalsRow = getDb().prepare(`WITH RECURSIVE ${HUMAN_FREE_TASKS_CTE}
9205
+ SELECT
9027
9206
  COALESCE(SUM(sc.totalCostUsd), 0) as totalCostUsd,
9028
9207
  COALESCE(SUM(sc.inputTokens), 0) as totalInputTokens,
9029
9208
  COALESCE(SUM(sc.outputTokens), 0) as totalOutputTokens,
@@ -9031,8 +9210,13 @@ function getSessionCostSummary(opts) {
9031
9210
  COALESCE(SUM(sc.cacheWriteTokens), 0) as totalCacheWriteTokens,
9032
9211
  COALESCE(SUM(sc.durationMs), 0) as totalDurationMs,
9033
9212
  COUNT(*) as totalSessions,
9034
- COALESCE(SUM(CASE WHEN t.requestedByUserId IS NOT NULL THEN sc.totalCostUsd ELSE 0 END), 0)
9035
- as attributedCostUsd
9213
+ COALESCE(SUM(CASE WHEN t.requestedByUserId IS NOT NULL AND NOT ${HUMAN_FREE_SQL}
9214
+ THEN sc.totalCostUsd ELSE 0 END), 0) as attributedCostUsd,
9215
+ COALESCE(SUM(CASE WHEN NOT ${HUMAN_FREE_SQL}
9216
+ THEN sc.totalCostUsd ELSE 0 END), 0) as attributableCostUsd,
9217
+ COALESCE(SUM(CASE WHEN ${HUMAN_FREE_SQL}
9218
+ THEN sc.totalCostUsd ELSE 0 END), 0) as excludedCostUsd,
9219
+ COUNT(DISTINCT CASE WHEN ${HUMAN_FREE_SQL} THEN t.id END) as excludedTaskCount
9036
9220
  ${from} ${where}`).get(...params);
9037
9221
  const totals = totalsRow ? {
9038
9222
  ...totalsRow,
@@ -9046,12 +9230,16 @@ function getSessionCostSummary(opts) {
9046
9230
  totalDurationMs: 0,
9047
9231
  totalSessions: 0,
9048
9232
  avgCostPerSession: 0,
9049
- attributedCostUsd: 0
9233
+ attributedCostUsd: 0,
9234
+ attributableCostUsd: 0,
9235
+ excludedCostUsd: 0,
9236
+ excludedTaskCount: 0
9050
9237
  };
9051
9238
  const groupBy = opts.groupBy ?? "both";
9052
9239
  let daily = [];
9053
9240
  if (groupBy === "day" || groupBy === "both") {
9054
- daily = getDb().prepare(`SELECT
9241
+ daily = getDb().prepare(`WITH RECURSIVE ${HUMAN_FREE_TASKS_CTE}
9242
+ SELECT
9055
9243
  DATE(sc.createdAt) as date,
9056
9244
  COALESCE(SUM(sc.totalCostUsd), 0) as costUsd,
9057
9245
  COALESCE(SUM(sc.inputTokens), 0) as inputTokens,
@@ -9063,7 +9251,8 @@ function getSessionCostSummary(opts) {
9063
9251
  }
9064
9252
  let byAgent = [];
9065
9253
  if (groupBy === "agent" || groupBy === "both") {
9066
- byAgent = getDb().prepare(`SELECT
9254
+ byAgent = getDb().prepare(`WITH RECURSIVE ${HUMAN_FREE_TASKS_CTE}
9255
+ SELECT
9067
9256
  sc.agentId as agentId,
9068
9257
  COALESCE(SUM(sc.totalCostUsd), 0) as costUsd,
9069
9258
  COALESCE(SUM(sc.inputTokens), 0) as inputTokens,
@@ -9076,19 +9265,175 @@ function getSessionCostSummary(opts) {
9076
9265
  }
9077
9266
  let byUser = [];
9078
9267
  if (groupBy === "user" || groupBy === "both") {
9079
- byUser = getDb().prepare(`SELECT
9080
- t.requestedByUserId as userId,
9268
+ byUser = getDb().prepare(`WITH RECURSIVE ${HUMAN_FREE_TASKS_CTE}
9269
+ SELECT
9270
+ CASE WHEN ${HUMAN_FREE_SQL} THEN NULL ELSE t.requestedByUserId END as userId,
9081
9271
  COALESCE(SUM(sc.totalCostUsd), 0) as costUsd,
9082
9272
  COALESCE(SUM(sc.inputTokens), 0) as inputTokens,
9083
9273
  COALESCE(SUM(sc.outputTokens), 0) as outputTokens,
9084
9274
  COUNT(DISTINCT sc.taskId) as tasks,
9085
9275
  COALESCE(SUM(sc.durationMs), 0) as durationMs
9086
9276
  ${from} ${where}
9087
- GROUP BY t.requestedByUserId
9277
+ GROUP BY CASE WHEN ${HUMAN_FREE_SQL} THEN NULL ELSE t.requestedByUserId END
9088
9278
  ORDER BY costUsd DESC`).all(...params);
9089
9279
  }
9090
9280
  return { totals, daily, byAgent, byUser };
9091
9281
  }
9282
+ function getAttributionByPerson(opts) {
9283
+ const conditions = ["t.requestedByUserId IS NOT NULL"];
9284
+ const params = [];
9285
+ if (opts.startDate) {
9286
+ conditions.push("t.createdAt >= ?");
9287
+ params.push(opts.startDate);
9288
+ }
9289
+ if (opts.endDate) {
9290
+ const dateOnlyEnd = /^\d{4}-\d{2}-\d{2}$/.test(opts.endDate) ? new Date(`${opts.endDate}T00:00:00.000Z`) : null;
9291
+ if (dateOnlyEnd && !Number.isNaN(dateOnlyEnd.getTime()) && dateOnlyEnd.toISOString().slice(0, 10) === opts.endDate) {
9292
+ dateOnlyEnd.setUTCDate(dateOnlyEnd.getUTCDate() + 1);
9293
+ conditions.push("t.createdAt < ?");
9294
+ params.push(dateOnlyEnd.toISOString());
9295
+ } else {
9296
+ conditions.push("t.createdAt <= ?");
9297
+ params.push(opts.endDate);
9298
+ }
9299
+ }
9300
+ const where = `WHERE ${conditions.join(" AND ")}`;
9301
+ const rootRows = getDb().prepare(`WITH RECURSIVE selected_roots(id, requestedByUserId, status, output) AS (
9302
+ SELECT t.id, t.requestedByUserId, t.status, t.output
9303
+ FROM agent_tasks t
9304
+ ${where} AND t.parentTaskId IS NULL AND NOT ${ROOT_HUMAN_FREE_SQL}
9305
+ ),
9306
+ task_tree(rootId, taskId, output) AS (
9307
+ SELECT id, id, output
9308
+ FROM selected_roots
9309
+
9310
+ UNION ALL
9311
+
9312
+ SELECT tree.rootId, child.id, child.output
9313
+ FROM agent_tasks child
9314
+ JOIN task_tree tree ON child.parentTaskId = tree.taskId
9315
+ )
9316
+ SELECT
9317
+ t.requestedByUserId as userId,
9318
+ COUNT(*) as initiated,
9319
+ SUM(CASE WHEN t.status = 'completed' AND (
9320
+ EXISTS (
9321
+ SELECT 1
9322
+ FROM task_tree tree
9323
+ JOIN task_attachments ta ON ta.task_id = tree.taskId
9324
+ WHERE tree.rootId = t.id
9325
+ AND ta.kind = 'url'
9326
+ AND (
9327
+ ta.url LIKE '%github.com/%/pull/%'
9328
+ OR ta.url LIKE '%/-/merge_requests/%'
9329
+ )
9330
+ )
9331
+ OR EXISTS (
9332
+ SELECT 1 FROM task_attachments ta
9333
+ JOIN task_tree tree ON tree.taskId = ta.task_id
9334
+ WHERE tree.rootId = t.id AND ta.kind = 'page'
9335
+ )
9336
+ OR EXISTS (
9337
+ SELECT 1 FROM task_tree tree
9338
+ WHERE tree.rootId = t.id
9339
+ AND (
9340
+ tree.output LIKE '%github.com/%/pull/%'
9341
+ OR tree.output LIKE '%/-/merge_requests/%'
9342
+ )
9343
+ )
9344
+ ) THEN 1 ELSE 0 END) as shipped
9345
+ FROM selected_roots t
9346
+ GROUP BY t.requestedByUserId`).all(...params);
9347
+ const reachRows = getDb().prepare(`WITH RECURSIVE report_tasks AS (
9348
+ SELECT t.*
9349
+ FROM agent_tasks t
9350
+ ${where}
9351
+ ),
9352
+ task_ancestry(
9353
+ taskId, id, parentTaskId, requestedByUserId, requestedByUserIdInherited,
9354
+ taskType, tags, source, workflowRunId
9355
+ ) AS (
9356
+ SELECT
9357
+ id, id, parentTaskId, requestedByUserId, requestedByUserIdInherited,
9358
+ taskType, tags, source, workflowRunId
9359
+ FROM report_tasks
9360
+
9361
+ UNION ALL
9362
+
9363
+ SELECT
9364
+ child.taskId, parent.id, parent.parentTaskId, parent.requestedByUserId,
9365
+ parent.requestedByUserIdInherited, parent.taskType, parent.tags,
9366
+ parent.source, parent.workflowRunId
9367
+ FROM agent_tasks parent
9368
+ JOIN task_ancestry child ON parent.id = child.parentTaskId
9369
+ WHERE child.requestedByUserId IS NULL
9370
+ OR child.requestedByUserIdInherited = 1
9371
+ ),
9372
+ human_free_report_tasks(id) AS (
9373
+ SELECT DISTINCT ancestor.taskId
9374
+ FROM task_ancestry ancestor
9375
+ LEFT JOIN agent_tasks parent ON parent.id = ancestor.parentTaskId
9376
+ WHERE COALESCE(ancestor.taskType, '') IN ('heartbeat', 'heartbeat-checklist', 'boot-triage')
9377
+ OR COALESCE(ancestor.tags, '[]') LIKE '%"heartbeat"%'
9378
+ OR (COALESCE(ancestor.source, '') = 'schedule' AND ancestor.requestedByUserId IS NULL)
9379
+ OR (
9380
+ ancestor.parentTaskId IS NULL
9381
+ AND COALESCE(ancestor.source, '') = 'workflow'
9382
+ AND ancestor.requestedByUserId IS NULL
9383
+ AND EXISTS (
9384
+ SELECT 1
9385
+ FROM workflow_runs run
9386
+ WHERE run.id = ancestor.workflowRunId
9387
+ AND run.triggerType = 'schedule'
9388
+ AND run.created_by IS NULL
9389
+ )
9390
+ )
9391
+ OR (
9392
+ COALESCE(ancestor.source, '') = 'system'
9393
+ AND parent.id IS NOT NULL
9394
+ AND parent.requestedByUserId IS NULL
9395
+ )
9396
+ )
9397
+ SELECT
9398
+ t.requestedByUserId as userId,
9399
+ COUNT(DISTINCT t.agentId) as agentsReached,
9400
+ COUNT(DISTINCT t.vcsRepo) as reposReached,
9401
+ COUNT(DISTINCT t.source) as surfacesReached
9402
+ FROM report_tasks t
9403
+ WHERE NOT EXISTS (SELECT 1 FROM human_free_report_tasks WHERE id = t.id)
9404
+ GROUP BY t.requestedByUserId`).all(...params);
9405
+ const byUser = new Map;
9406
+ for (const r of rootRows) {
9407
+ byUser.set(r.userId, {
9408
+ userId: r.userId,
9409
+ problemsInitiated: r.initiated,
9410
+ problemsShipped: r.shipped,
9411
+ agentsReached: 0,
9412
+ reposReached: 0,
9413
+ surfacesReached: 0,
9414
+ firstPassYield: null
9415
+ });
9416
+ }
9417
+ for (const r of reachRows) {
9418
+ const existing = byUser.get(r.userId);
9419
+ if (existing) {
9420
+ existing.agentsReached = r.agentsReached;
9421
+ existing.reposReached = r.reposReached;
9422
+ existing.surfacesReached = r.surfacesReached;
9423
+ } else {
9424
+ byUser.set(r.userId, {
9425
+ userId: r.userId,
9426
+ problemsInitiated: 0,
9427
+ problemsShipped: 0,
9428
+ agentsReached: r.agentsReached,
9429
+ reposReached: r.reposReached,
9430
+ surfacesReached: r.surfacesReached,
9431
+ firstPassYield: null
9432
+ });
9433
+ }
9434
+ }
9435
+ return Array.from(byUser.values());
9436
+ }
9092
9437
  function getDashboardCostSummary() {
9093
9438
  const now = new Date;
9094
9439
  const startOfDayUtc = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate())).toISOString();
@@ -9612,6 +9957,9 @@ function upsertSwarmConfig(data) {
9612
9957
  console.error(`Failed to write env file ${config.envPath}:`, e);
9613
9958
  }
9614
9959
  }
9960
+ if (config.isSecret) {
9961
+ registerVolatileSecret(config.value, `config:${config.key}`);
9962
+ }
9615
9963
  return config;
9616
9964
  }
9617
9965
  function deleteSwarmConfig(id) {
@@ -9766,9 +10114,9 @@ function findTaskByAgentMailThread(agentmailThreadId) {
9766
10114
  function insertActiveSession(session) {
9767
10115
  const id = crypto.randomUUID();
9768
10116
  const now = new Date().toISOString();
9769
- const row = getDb().prepare(`INSERT INTO active_sessions (id, agentId, taskId, triggerType, inboxMessageId, taskDescription, runnerSessionId, startedAt, lastHeartbeatAt)
9770
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
9771
- RETURNING *`).get(id, session.agentId, session.taskId ?? null, session.triggerType, session.inboxMessageId ?? null, session.taskDescription ?? null, session.runnerSessionId ?? null, now, now);
10117
+ const row = getDb().prepare(`INSERT INTO active_sessions (id, agentId, taskId, triggerType, inboxMessageId, taskDescription, runnerSessionId, runtimeInstanceId, startedAt, lastHeartbeatAt)
10118
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
10119
+ RETURNING *`).get(id, session.agentId, session.taskId ?? null, session.triggerType, session.inboxMessageId ?? null, session.taskDescription ?? null, session.runnerSessionId ?? null, session.runtimeInstanceId ?? null, now, now);
9772
10120
  if (!row)
9773
10121
  throw new Error("Failed to insert active session");
9774
10122
  return row;
@@ -10075,6 +10423,7 @@ function rowToWorkflowRun(row) {
10075
10423
  triggerData: row.triggerData ? JSON.parse(row.triggerData) : undefined,
10076
10424
  context: row.context ? JSON.parse(row.context) : undefined,
10077
10425
  error: row.error ?? undefined,
10426
+ createdBy: row.created_by ?? undefined,
10078
10427
  startedAt: normalizeDateRequired(row.startedAt),
10079
10428
  lastUpdatedAt: normalizeDateRequired(row.lastUpdatedAt),
10080
10429
  finishedAt: normalizeDate(row.finishedAt) ?? undefined
@@ -10082,7 +10431,7 @@ function rowToWorkflowRun(row) {
10082
10431
  }
10083
10432
  function createWorkflowRun(data) {
10084
10433
  const now = new Date().toISOString();
10085
- const row = getDb().prepare(`INSERT INTO workflow_runs (id, workflowId, startedAt, triggerData) VALUES (?, ?, ?, ?) RETURNING *`).get(data.id, data.workflowId, now, data.triggerData ? JSON.stringify(data.triggerData) : null);
10434
+ const row = getDb().prepare(`INSERT INTO workflow_runs (id, workflowId, triggerType, startedAt, triggerData, created_by) VALUES (?, ?, ?, ?, ?, ?) RETURNING *`).get(data.id, data.workflowId, data.triggerType ?? "manual", now, data.triggerData ? JSON.stringify(data.triggerData) : null, data.createdBy ?? null);
10086
10435
  if (!row)
10087
10436
  throw new Error("Failed to create workflow run");
10088
10437
  return rowToWorkflowRun(row);
@@ -11969,10 +12318,63 @@ function updateUser(id, data) {
11969
12318
  const row = getDb().prepare(`UPDATE users SET ${sets.join(", ")} WHERE id = ? RETURNING *`).get(...params);
11970
12319
  return row ? rowToUser(row) : null;
11971
12320
  }
11972
- function deleteUser(id) {
11973
- getDb().prepare("UPDATE agent_tasks SET requestedByUserId = NULL WHERE requestedByUserId = ?").run(id);
11974
- const result = getDb().prepare("DELETE FROM users WHERE id = ?").run(id);
11975
- return result.changes > 0;
12321
+ function quoteSqlIdentifier(identifier) {
12322
+ return `"${identifier.replaceAll('"', '""')}"`;
12323
+ }
12324
+ function deleteUser(id, replacementUserId) {
12325
+ if (replacementUserId === id) {
12326
+ throw new Error("Replacement user must differ from deleted user");
12327
+ }
12328
+ const database = getDb();
12329
+ return database.transaction(() => {
12330
+ const userExists = database.prepare("SELECT EXISTS(SELECT 1 FROM users WHERE id = ?) AS present").get(id)?.present;
12331
+ if (!userExists)
12332
+ return false;
12333
+ if (replacementUserId) {
12334
+ const replacementExists = database.prepare("SELECT EXISTS(SELECT 1 FROM users WHERE id = ?) AS present").get(replacementUserId)?.present;
12335
+ if (!replacementExists)
12336
+ throw new Error("Replacement user not found");
12337
+ }
12338
+ const references = database.prepare(`SELECT tables.name AS tableName, foreign_keys."from" AS columnName
12339
+ FROM sqlite_schema AS tables
12340
+ JOIN pragma_foreign_key_list(tables.name) AS foreign_keys
12341
+ JOIN pragma_table_info(tables.name) AS columns
12342
+ ON columns.name = foreign_keys."from"
12343
+ WHERE tables.type = 'table'
12344
+ AND foreign_keys."table" = 'users'
12345
+ AND foreign_keys.on_delete IN ('NO ACTION', 'RESTRICT')
12346
+ AND columns."notnull" = 0
12347
+ UNION ALL
12348
+ SELECT 'scheduled_tasks' AS tableName, columns.name AS columnName
12349
+ FROM pragma_table_info('scheduled_tasks') AS columns
12350
+ WHERE columns.name IN ('created_by', 'updated_by')
12351
+ AND columns."notnull" = 0
12352
+ AND NOT EXISTS (
12353
+ SELECT 1
12354
+ FROM pragma_foreign_key_list('scheduled_tasks') AS foreign_keys
12355
+ WHERE foreign_keys."from" = columns.name
12356
+ AND foreign_keys."table" = 'users'
12357
+ )`).all();
12358
+ const replacement = replacementUserId ?? null;
12359
+ for (const reference of references) {
12360
+ const table = quoteSqlIdentifier(reference.tableName);
12361
+ const column = quoteSqlIdentifier(reference.columnName);
12362
+ database.prepare(`UPDATE ${table} SET ${column} = ? WHERE ${column} = ?`).run(replacement, id);
12363
+ }
12364
+ if (replacementUserId) {
12365
+ database.prepare(`UPDATE workflow_runs
12366
+ SET context = json_set(context, '$.swarm.requestedByUserId', ?)
12367
+ WHERE json_valid(context)
12368
+ AND json_extract(context, '$.swarm.requestedByUserId') = ?`).run(replacementUserId, id);
12369
+ } else {
12370
+ database.prepare(`UPDATE workflow_runs
12371
+ SET context = json_remove(context, '$.swarm.requestedByUserId')
12372
+ WHERE json_valid(context)
12373
+ AND json_extract(context, '$.swarm.requestedByUserId') = ?`).run(id);
12374
+ }
12375
+ const result = database.prepare("DELETE FROM users WHERE id = ?").run(id);
12376
+ return result.changes > 0;
12377
+ })();
11976
12378
  }
11977
12379
  function rowToInboxItemState(row) {
11978
12380
  return {
@@ -12811,7 +13213,54 @@ function countScriptRunJournalAgentTaskSteps(runId) {
12811
13213
  const row = getDb().prepare("SELECT COUNT(*) AS count FROM script_run_journal WHERE runId = ? AND stepType = 'agent-task'").get(runId);
12812
13214
  return row?.count ?? 0;
12813
13215
  }
12814
- var db = null, sqliteVecAvailable = false, VERSIONABLE_FIELDS, agentQueries, MAX_EMPTY_POLLS = 2, taskQueries, PENDING_SLACK_MESSAGE_TS_PREFIX = "pending:", findTaskByGitHub, LINEAR_TRACKER_CONTEXT_KEY_PREFIX = "task:trackers:linear:", logQueries, ELIGIBILITY_SCAN_BATCH_SIZE, ELIGIBILITY_SCAN_CAP, sessionLogQueries, sessionCostQueries, UNATTRIBUTED_USER_ID = "unattributed", SCHEDULE_TEMPLATE_PREVIEW_LENGTH = 280, TASK_PREVIEW_LENGTH = 300, RESERVED_CONFIG_PLACEHOLDER = "[reserved key stored in swarm_config; delete this row]", SKILL_FILE_LIMITS, BINARY_SKILL_FILE_PLACEHOLDER = "[binary file - not synced]", SKILL_SLIM_COLUMNS = "id, name, description, type, scope, ownerAgentId, sourceUrl, sourceRepo, sourcePath, sourceBranch, sourceHash, isComplex, allowedTools, model, effort, context, agent, disableModelInvocation, userInvocable, version, isEnabled, systemDefault, createdAt, lastUpdatedAt, lastFetchedAt, '' as content", contextSnapshotQueries, KvTypeCollisionError;
13216
+ var db = null, sqliteVecAvailable = false, cachedSqliteVecExtensionPath = null, VERSIONABLE_FIELDS, BUDGETED_IDENTITY_FIELDS, agentQueries, MAX_EMPTY_POLLS = 2, taskQueries, PENDING_SLACK_MESSAGE_TS_PREFIX = "pending:", findTaskByGitHub, LINEAR_TRACKER_CONTEXT_KEY_PREFIX = "task:trackers:linear:", GENERATED_PULL_REQUEST_PROVIDER_ID = "github", GENERATED_PULL_REQUEST_INTENT = "task-deliverable", GENERATED_PULL_REQUEST_DESCRIPTION = "Pull request shipped by this task", GENERATED_PULL_REQUEST_SOURCE = "task-pull-request-recorder", logQueries, ELIGIBILITY_SCAN_BATCH_SIZE, ELIGIBILITY_SCAN_CAP, sessionLogQueries, sessionCostQueries, UNATTRIBUTED_USER_ID = "unattributed", HUMAN_FREE_TASKS_CTE = `human_free_tasks(id) AS (
13217
+ SELECT task.id
13218
+ FROM agent_tasks task
13219
+ LEFT JOIN agent_tasks parent ON parent.id = task.parentTaskId
13220
+ WHERE COALESCE(task.taskType, '') IN ('heartbeat', 'heartbeat-checklist', 'boot-triage')
13221
+ OR COALESCE(task.tags, '[]') LIKE '%"heartbeat"%'
13222
+ OR (COALESCE(task.source, '') = 'schedule' AND task.requestedByUserId IS NULL)
13223
+ OR (
13224
+ task.parentTaskId IS NULL
13225
+ AND COALESCE(task.source, '') = 'workflow'
13226
+ AND task.requestedByUserId IS NULL
13227
+ AND EXISTS (
13228
+ SELECT 1
13229
+ FROM workflow_runs run
13230
+ WHERE run.id = task.workflowRunId
13231
+ AND run.triggerType = 'schedule'
13232
+ AND run.created_by IS NULL
13233
+ )
13234
+ )
13235
+ OR (
13236
+ COALESCE(task.source, '') = 'system'
13237
+ AND parent.id IS NOT NULL
13238
+ AND parent.requestedByUserId IS NULL
13239
+ )
13240
+
13241
+ UNION
13242
+
13243
+ SELECT child.id
13244
+ FROM agent_tasks child
13245
+ JOIN human_free_tasks parent ON child.parentTaskId = parent.id
13246
+ WHERE child.requestedByUserId IS NULL
13247
+ OR child.requestedByUserIdInherited = 1
13248
+ )`, HUMAN_FREE_SQL = "EXISTS (SELECT 1 FROM human_free_tasks WHERE id = t.id)", ROOT_HUMAN_FREE_SQL = `(
13249
+ COALESCE(t.taskType, '') IN ('heartbeat', 'heartbeat-checklist', 'boot-triage')
13250
+ OR COALESCE(t.tags, '[]') LIKE '%"heartbeat"%'
13251
+ OR (COALESCE(t.source, '') = 'schedule' AND t.requestedByUserId IS NULL)
13252
+ OR (
13253
+ COALESCE(t.source, '') = 'workflow'
13254
+ AND t.requestedByUserId IS NULL
13255
+ AND EXISTS (
13256
+ SELECT 1
13257
+ FROM workflow_runs run
13258
+ WHERE run.id = t.workflowRunId
13259
+ AND run.triggerType = 'schedule'
13260
+ AND run.created_by IS NULL
13261
+ )
13262
+ )
13263
+ )`, SCHEDULE_TEMPLATE_PREVIEW_LENGTH = 280, TASK_PREVIEW_LENGTH = 300, RESERVED_CONFIG_PLACEHOLDER = "[reserved key stored in swarm_config; delete this row]", SKILL_FILE_LIMITS, BINARY_SKILL_FILE_PLACEHOLDER = "[binary file - not synced]", SKILL_SLIM_COLUMNS = "id, name, description, type, scope, ownerAgentId, sourceUrl, sourceRepo, sourcePath, sourceBranch, sourceHash, isComplex, allowedTools, model, effort, context, agent, disableModelInvocation, userInvocable, version, isEnabled, systemDefault, createdAt, lastUpdatedAt, lastFetchedAt, '' as content", contextSnapshotQueries, KvTypeCollisionError;
12815
13264
  var init_db = __esm(() => {
12816
13265
  init_provider_metadata();
12817
13266
  init_package();
@@ -12822,6 +13271,8 @@ var init_db = __esm(() => {
12822
13271
  init_types();
12823
13272
  init_credentials();
12824
13273
  init_env_flag();
13274
+ init_github_pull_request();
13275
+ init_identity_field_budget();
12825
13276
  init_request_auth_context();
12826
13277
  init_secret_scrubber();
12827
13278
  init_asset_key_audit();
@@ -12843,6 +13294,12 @@ var init_db = __esm(() => {
12843
13294
  "setupScript",
12844
13295
  "heartbeatMd"
12845
13296
  ];
13297
+ BUDGETED_IDENTITY_FIELDS = [
13298
+ "soulMd",
13299
+ "identityMd",
13300
+ "claudeMd",
13301
+ "toolsMd"
13302
+ ];
12846
13303
  agentQueries = {
12847
13304
  insert: () => getDb().prepare("INSERT INTO agents (id, name, isLead, status, maxTasks, provider, harness_provider, createdAt, lastUpdatedAt) VALUES (?, ?, ?, ?, ?, ?, ?, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'), strftime('%Y-%m-%dT%H:%M:%fZ', 'now')) RETURNING *"),
12848
13305
  getById: () => getDb().prepare("SELECT * FROM agents WHERE id = ?"),
@@ -12932,4 +13389,4 @@ var init_db = __esm(() => {
12932
13389
  };
12933
13390
  });
12934
13391
 
12935
- export { normalizeAssetKey, defaultAssetKey, parseAssetKey, canWriteAssetKey, init_key, slackContextKey, agentmailContextKey, githubContextKey, gitlabContextKey, linearContextKey, buildJiraContextKey, scheduleContextKey, workflowContextKey, agentContextKey, pageContextKey, init_context_key, checkSlackRoutingCoherence, init_slack_routing, initTelemetry, telemetry, init_telemetry, $OpenAPIRegistry, $OpenApiGeneratorV31, init_dist, init_zod_openapi, AssetKeySchema, AssetEntityTypeSchema, AssetKeyMappingSchema, AssetSummarySchema, ModelTierSchema, ReasoningEffortSchema, splitLegacyModelAlias, resolveTaskModelSelection, AgentTaskStatusSchema, isTerminalTaskStatus, AgentTaskSourceSchema, ProviderNameSchema, SteerModeSchema, SteeringSourceSchema, SteeringMessageSchema, SteerOutcomeSchema, OnUnsupportedSchema, SteerResultSchema, FollowUpConfigSchema, AgentTaskSchema, AttachmentInputSchema, TaskAttachmentSchema, UserSchema, InboxItemTypeSchema, InboxItemStatusSchema, InboxItemStateSchema, FavoriteItemTypeSchema, UserFavoriteSchema, TaskTemplateKindSchema, TaskTemplateSchema, AgentStatusSchema, AgentAvatarSchema, AgentSchema, AgentLatestModelSchema, AgentCredStatusSchema, AgentWithTasksSchema, ChannelTypeSchema, ServiceStatusSchema, ServiceSchema, ResumeReasonSchema, AgentLogSchema, SessionLogSchema, SessionCostModelBreakdownSchema, SessionCostSchema, EventCategorySchema, EventStatusSchema, EventSourceSchema, EventNameSchema, SwarmEventSchema, ScheduledTaskTargetTypeSchema, ScheduledTaskSchema, SwarmConfigScopeSchema, SwarmConfigSchema, RepoGuidelinesSchema, RepoHooksSchema, SwarmRepoSchema, AgentMemoryScopeSchema, AgentMemorySourceSchema, AgentMemorySchema, ActiveSessionSchema, WorkflowEdgeSchema, WorkflowDefinitionSchema, WorkflowNodePatchSchema, WorkflowPatchSchema, TriggerConfigSchema, CooldownConfigSchema, InputValueSchema, WorkflowSchema, WorkflowVersionSchema, PageContentTypeSchema, PageAuthModeSchema, PageSchema, PageVersionSchema, MetricWidgetSchema, MetricDefinitionSchema, MetricSchema, MetricVersionSchema, WorkflowRunStatusSchema, WorkflowRunSchema, ScriptRunStatusSchema, TERMINAL_SCRIPT_RUN_STATUSES, ScriptRunSchema, ScriptRunListItemSchema, ScriptRunJournalEntrySchema, WorkflowRunStepSchema, PromptTemplateScopeSchema, PromptTemplateStateSchema, PromptTemplateSchema, PromptTemplateHistorySchema, ScriptScopeSchema, ScriptFsModeSchema, ScriptRecordSchema, ScriptVersionRecordSchema, ScriptApiAuthModeSchema, ScriptApiRecordSchema, SkillSchema, AgentSkillSchema, SkillWithInstallInfoSchema, SkillFileSchema, McpAuthMethodSchema, McpServerSchema, AgentMcpServerSchema, McpServerWithInstallInfoSchema, ContextSnapshotEventTypeSchema, ContextFormulaSchema, ContextSnapshotSchema, BudgetScopeSchema, BudgetSchema, PricingProviderSchema, PricingTokenClassSchema, PricingRowSchema, BudgetRefusalCauseSchema, BudgetRefusalNotificationSchema, BudgetRefusedTriggerSchema, KvValueTypeSchema, KvNamespaceSchema, KvKeySchema, KvEntrySchema, init_types, setRequestAuth, getRequestAuth, getCurrentRequestAuth, init_request_auth_context, auditAssetKeys, init_asset_key_audit, CredentialBindingSchema, placeholderForConfigKey, CredentialBroker, DEFAULT_CREDENTIAL_BINDINGS, init_credential_broker, encryptSecret, decryptSecret, getEncryptionKey, init_crypto, normalizeDate, normalizeDateRequired, init_date_utils, init_templates, init_templates2 as init_templates1, SteeringRequestError, isSteeringEnabled2 as isSteeringEnabled, getTaskSteeringFields, promotePendingSteeringForTask, markSteeringUndeliverable, requestSteering, init_steering, isReservedConfigKey, reservedKeyError, validateConfigValue, init_swarm_config_guard, onTaskStarted, init_task_lifecycle_events, generateDefaultClaudeMd, generateDefaultSoulMd, generateDefaultIdentityMd, generateDefaultToolsMd, init_defaults, isSqliteVecAvailable, initDb, getDb, closeDb, computeContentHash, createContextVersion, getLatestContextVersion, getContextVersion, getContextVersionHistory, agentQueries, updateAgentCredentialState, createAgent, getAgentById, getAllAgents, getLeadAgent, updateAgentStatus, updateAgentMaxTasks, updateAgentProvider, setAgentHarnessProvider, updateAgentCredStatus, listAgentsWithCredStatusByProvider, getAgentHarnessProviders, updateAgentActivity, MAX_EMPTY_POLLS, incrementEmptyPollCount, resetEmptyPollCount, shouldBlockPolling, deleteAgent, getActiveTaskCount, hasCapacity, getRemainingCapacity, updateAgentStatusFromCapacity, isPoolAffinityEnforcementEnabled, buildRoutingAffinityFromAgent, isAgentEligibleForTask, taskQueries, createTask, getPendingTaskForAgent, assignUnassignedTaskPending, startTask, getTaskById, getSlackRenderV2ActivatedAt, ensureSlackRenderV2Activation, isPendingSlackMessage, recordSlackMessage, reserveSlackMessage, bindSlackMessageTimestamp, updateSlackMessageRecord, markSlackTreeRendered, deleteSlackMessageRecord, getSlackTreeMessage, getSlackTreeMessageByThread, getSlackOutcomeMessage, getSlackTreeMessages, getSlackMessageByChannelTs, getSlackTasksInThread, markTaskSlackReplySent, setSlackMessageTracking, getChildTasks, hasNonTerminalResumeChild, hasNonTerminalRerouteDecisionChild, updateTaskClaudeSessionId, updateTaskTitle, updateTaskVcs, getTasksByAgentId, getAgentCurrentTask, getTasksByStatus, findTaskByVcs, findTaskByGitHub, getAllTasks, getTasksCount, getTaskStats, getCompletedSlackTasks, getRecentlyFinishedWorkerTasks, markTasksNotified, resetTasksNotified, getInProgressSlackTasks, getSlackTasksMissingTree, getInProgressTasksByContextKey, findExistingLinearTrackerContextWork, getLatestTaskByContextKey, getLatestScriptRunStepTaskByContextKey, getAgentWorkingOnThread, getLatestActiveTaskInThread, getLatestLeadTaskInThread, getMostRecentTaskInThread, findCompletedTaskInThread, findRecentCancelledTaskInThread, completeTask, failTask, overwriteTerminalTaskResultText, cancelTask, supersedeTask, backfillSupersedeTaskResumeTaskId, pauseTask, resumeTask, getPausedTasksForAgent, getOrphanedInProgressTasksForAgent, resetOrphanedInProgressTasksForAgent, getRecentlyCancelledTasksForAgent, deleteTask, updateTaskProgress, insertTaskAttachment, getAssetKeyMappingByProvider, upsertAssetKeyMapping, getAssetKeyMapping, listAssetSummaries, moveAssetKey, deleteTaskAttachment, replaceTaskAttachment, getTaskAttachments, createSteeringMessage, getSteeringMessagesForTask, getSteeringMessageById, getPendingSteeringForTask, getPendingSteeringForAgent, markSteeringDelivered, markSteeringHandled, markSteeringPromoted, cancelPendingSteeringForTask, hasPendingSteering, getAgentWithTasks, getAllAgentsWithTasks, logQueries, createLogEntry, getLogsByAgentId, getLogsByTaskId, getLogsByTaskIdChronological, getLogsByEventType, getAllLogs, findRecentSimilarTasks, createTaskExtended, claimTask, releaseTask, acceptTask, rejectTask, moveTaskToBacklog, moveTaskFromBacklog, releaseStaleReviewingTasks, getOfferedTasksForAgent, claimOfferedTask, getUnassignedTasksCount, getUnassignedTaskIds, getUnassignedTaskIdsForAgent, checkDependencies, getDependentTasks, cascadeFailDependents, updateAgentProfile, updateAgentName, createChannel, getMessageById, getChannelById, getChannelByName, getAllChannels, deleteChannel, postMessage, getChannelMessages, updateReadState, getLastReadAt, getUnreadMessages, getMentionsForAgent, getInboxSummary, claimMentions, releaseMentionProcessing, releaseStaleMentionProcessing, createService, getServiceById, getServiceByAgentAndName, getServicesByAgentId, getAllServices, updateServiceStatus, deleteService, upsertService, deleteServicesByAgentId, sessionLogQueries, createSessionLogs, getSessionLogsByTaskId, getSessionLogsBySession, createSessionCost, getSessionCostsByTaskId, getSessionCostsByAgentId, getAllSessionCosts, getSessionCostsFiltered, UNATTRIBUTED_USER_ID, getSessionCostSummary, getDashboardCostSummary, createInboxMessage, getInboxMessageById, getUnreadInboxMessages, claimInboxMessages, markInboxMessageRead, markInboxMessageResponded, markInboxMessageDelegated, releaseStaleProcessingInbox, getConcurrentContext, getScheduledTasks, getScheduledTaskById, getScheduledTaskByName, createScheduledTask, updateScheduledTask, deleteScheduledTask, getDueScheduledTasks, autoEncryptLegacyPlaintextSecrets, maskSecrets, getSwarmConfigs, getInjectableGlobalConfigs, getSwarmConfigById, getSwarmConfigLookupById, upsertSwarmConfig, deleteSwarmConfig, deleteSwarmConfigByKey, getResolvedConfig, getSwarmRepos, getSwarmRepoById, getSwarmRepoByName, getSwarmRepoByUrl, createSwarmRepo, updateSwarmRepo, deleteSwarmRepo, getAgentMailInboxMapping, getAgentMailInboxMappingsByAgent, getAllAgentMailInboxMappings, createAgentMailInboxMapping, deleteAgentMailInboxMapping, findTaskByAgentMailThread, insertActiveSession, deleteActiveSession, deleteActiveSessionById, getActiveSessions, heartbeatActiveSession, cleanupStaleSessions, cleanupAgentSessions, updateActiveSessionProviderSessionId, getActiveSessionForTask, reassociateSessionLogs, getStalledInProgressTasks, getStalePinnedResumes, failPendingResumeIfUnclaimed, getIdleWorkersWithCapacity, getUnassignedPoolTasks, getStaleUnassignedAffinityTasks, getRecentFailedTasks, getRecentCompletedCount, getRecentFailedCount, createWorkflow, getWorkflow, listWorkflows, updateWorkflow, deleteWorkflow, getWorkflowsByScheduleId, createWorkflowRun, getWorkflowRun, updateWorkflowRun, listWorkflowRuns, countWorkflowRuns, listWorkflowRunsPage, createWorkflowRunStep, getWorkflowRunStep, updateWorkflowRunStep, getWorkflowRunStepsByRunId, getStuckWorkflowRuns, getLastSuccessfulRun, getLastRunStart, getRetryableSteps, getCompletedStepNodeIds, getTaskByWorkflowRunStepId, detachTaskFromWorkflowRunStep, getStepByIdempotencyKey, getStepCountForNode, getLatestStepForNode, createWorkflowVersion, getWorkflowVersions, getWorkflowVersion, createAppVersion, getAppVersions, getAppVersion, createPage, getPage, getPageBySlug, getLatestPageBySlug, listPagesByAgent, listAllPages, countAllPages, countPagesByAgent, updatePage, deletePage, incrementPageViewCount, createPageVersion, getPageVersions, getPageVersion, createMetric, getMetric, getMetricBySlug, listMetricsByAgent, listAllMetrics, countAllMetrics, countMetricsByAgent, updateMetric, deleteMetric, createMetricVersion, getMetricVersions, getMetricVersion, getPromptTemplates, getPromptTemplateById, upsertPromptTemplate, deletePromptTemplate, resetPromptTemplateToDefault, getPromptTemplateHistory, resolvePromptTemplate, checkoutPromptTemplate, getAllChannelActivityCursors, getChannelActivityCursor, upsertChannelActivityCursor, createApprovalRequest, getApprovalRequestById, resolveApprovalRequest, updateApprovalRequestNotifications, listApprovalRequests, getStuckApprovalRuns, getApprovalRequestByStepId, getExpiredPendingApprovals, createWaitState, getWaitStateById, getWaitStateByStepId, getDueWaitStates, getPendingEventWaitNames, getPendingWaitsByEvent, resolveWaitState, getStuckWaitRuns, SKILL_FILE_LIMITS, normalizeSkillFilePath, createSkill, updateSkill, listSkillFileManifest, getSkillFiles, getSkillFile, upsertSkillFile, upsertSkillFiles, deleteSkillFile, deleteSkill, getSkillById, getSkillByName, listSkills, searchSkills, installSkill, getSystemDefaultSkills, installSystemDefaultSkillsForAgent, uninstallSkill, getAgentSkills, toggleAgentSkill, createMcpServer, updateMcpServer, deleteMcpServer, getMcpServerById, getMcpServerByName, listMcpServers, installMcpServer, uninstallMcpServer, getAgentMcpServers, createContextSnapshot, getContextSnapshotsByTaskId, getContextSnapshotsBySessionId, getContextSummaryByTaskId, getAvailableKeyIndices, recordKeyUsage, markKeyRateLimited, recordKeyRateLimitWindows, setApiKeyName, clearKeyRateLimit, getKeyStatuses, getKeyCostSummary, getUserById, getAllUsers, createUser, updateUser, deleteUser, listInboxState, upsertInboxState, listFavorites, listUserFavorites, getFavoriteItemIdSet, setFavorite, setUserFavorite, withFavoriteFlags, listTaskTemplates, getRootTaskChain, listRecentSessions, countSessions, getBudget, getBudgets, upsertBudget, deleteBudget, getAllPricingRows, getPricingRows, getActivePricingRow, insertPricingRow, deletePricingRow, getDailySpendForAgent, getDailySpendGlobal, getDailySpendForUser, recordBudgetRefusalNotification, getBudgetRefusalNotification, getRecentBudgetRefusalNotifications, hasBudgetRefusalNotificationToday, setBudgetRefusalFollowUpTaskId, getLiveAgentCounts, getInstanceActivity, getSwarmMetrics, hasFirstCompletedTask, getKv, sweepExpiredKv, sweepExpiredKvPrefix, upsertKv, deleteKv, KvTypeCollisionError, incrKv, listKv, countKv, createScriptRun, recordInlineScriptRun, getScriptRun, getScriptRunByIdempotencyKey, listScriptRuns, countScriptRuns, countActiveScriptRuns, updateScriptRun, getRunningScriptRuns, getScriptRunJournalStep, upsertScriptRunJournalStep, listScriptRunJournalSteps, countScriptRunJournalSteps, countScriptRunJournalAgentTaskSteps, exports_db, init_db };
13392
+ export { normalizeAssetKey, defaultAssetKey, parseAssetKey, canWriteAssetKey, init_key, slackContextKey, agentmailContextKey, githubContextKey, gitlabContextKey, linearContextKey, buildJiraContextKey, scheduleContextKey, workflowContextKey, agentContextKey, pageContextKey, init_context_key, checkSlackRoutingCoherence, init_slack_routing, initTelemetry, telemetry, init_telemetry, $OpenAPIRegistry, $OpenApiGeneratorV31, init_dist, init_zod_openapi, AssetKeySchema, AssetEntityTypeSchema, AssetKeyMappingSchema, AssetSummarySchema, ModelTierSchema, ReasoningEffortSchema, splitLegacyModelAlias, resolveTaskModelSelection, AgentTaskStatusSchema, isTerminalTaskStatus, AgentTaskSourceSchema, ProviderNameSchema, SteerModeSchema, SteeringSourceSchema, SteeringMessageSchema, SteerOutcomeSchema, OnUnsupportedSchema, SteerResultSchema, FollowUpConfigSchema, AgentTaskSchema, AttachmentInputSchema, TaskAttachmentSchema, UserSchema, UserCommsPrefsSchema, InboxItemTypeSchema, InboxItemStatusSchema, InboxItemStateSchema, FavoriteItemTypeSchema, UserFavoriteSchema, TaskTemplateKindSchema, TaskTemplateSchema, AgentStatusSchema, AgentAvatarSchema, AgentSchema, AgentLatestModelSchema, AgentCredStatusSchema, AgentWithTasksSchema, ChannelTypeSchema, ServiceStatusSchema, ServiceSchema, ResumeReasonSchema, AgentLogSchema, SessionLogSchema, SessionCostModelBreakdownSchema, SessionCostSchema, EventCategorySchema, EventStatusSchema, EventSourceSchema, EventNameSchema, SwarmEventSchema, ScheduledTaskTargetTypeSchema, ScheduledTaskSchema, SwarmConfigScopeSchema, SwarmConfigSchema, RepoGuidelinesSchema, RepoHooksSchema, SwarmRepoSchema, AgentMemoryScopeSchema, AgentMemorySourceSchema, AgentMemorySchema, ActiveSessionSchema, RuntimeInstanceSchema, WorkflowEdgeSchema, WorkflowDefinitionSchema, WorkflowNodePatchSchema, WorkflowPatchSchema, TriggerConfigSchema, CooldownConfigSchema, InputValueSchema, WorkflowSchema, WorkflowVersionSchema, PageContentTypeSchema, PageAuthModeSchema, PageSchema, PageVersionSchema, MetricWidgetSchema, MetricDefinitionSchema, MetricSchema, MetricVersionSchema, WorkflowRunStatusSchema, WorkflowRunSchema, ScriptRunStatusSchema, TERMINAL_SCRIPT_RUN_STATUSES, ScriptRunSchema, ScriptRunListItemSchema, ScriptRunJournalEntrySchema, WorkflowRunStepSchema, PromptTemplateScopeSchema, PromptTemplateStateSchema, PromptTemplateSchema, PromptTemplateHistorySchema, ScriptScopeSchema, ScriptFsModeSchema, ScriptRecordSchema, ScriptVersionRecordSchema, ScriptApiAuthModeSchema, ScriptApiRecordSchema, SkillSchema, AgentSkillSchema, SkillWithInstallInfoSchema, SkillFileSchema, McpAuthMethodSchema, McpServerSchema, AgentMcpServerSchema, McpServerWithInstallInfoSchema, ContextSnapshotEventTypeSchema, ContextFormulaSchema, ContextSnapshotSchema, BudgetScopeSchema, BudgetSchema, PricingProviderSchema, PricingTokenClassSchema, PricingRowSchema, BudgetRefusalCauseSchema, BudgetRefusalNotificationSchema, BudgetRefusedTriggerSchema, KvValueTypeSchema, KvNamespaceSchema, KvKeySchema, KvEntrySchema, init_types, setRequestAuth, getRequestAuth, getCurrentRequestAuth, init_request_auth_context, auditAssetKeys, init_asset_key_audit, CredentialBindingSchema, placeholderForConfigKey, CredentialBroker, DEFAULT_CREDENTIAL_BINDINGS, init_credential_broker, encryptSecret, decryptSecret, getEncryptionKey, init_crypto, normalizeDate, normalizeDateRequired, init_date_utils, getPromptTemplateDefaultDrift, init_default_drift, init_templates2 as init_templates, SteeringRequestError, isSteeringEnabled2 as isSteeringEnabled, getTaskSteeringFields, promotePendingSteeringForTask, markSteeringUndeliverable, requestSteering, init_steering, isReservedConfigKey, reservedKeyError, validateConfigValue, init_swarm_config_guard, onTaskStarted, init_task_lifecycle_events, generateDefaultClaudeMd, generateDefaultSoulMd, generateDefaultIdentityMd, generateDefaultToolsMd, init_defaults, isSqliteVecAvailable, resolveSqliteVecExtensionPath, __resetSqliteVecExtensionPathCacheForTests, initDb, getDb, closeDb, computeContentHash, createContextVersion, getLatestContextVersion, getContextVersion, getContextVersionHistory, agentQueries, updateAgentCredentialState, updateAgentCredentialMissing, createAgent, getAgentById, getAllAgents, getLeadAgent, updateAgentStatus, updateAgentMaxTasks, updateAgentProvider, setAgentHarnessProvider, updateAgentCredStatus, listAgentsWithCredStatusByProvider, getAgentHarnessProviders, updateAgentActivity, MAX_EMPTY_POLLS, incrementEmptyPollCount, resetEmptyPollCount, shouldBlockPolling, deleteAgent, getActiveTaskCount, hasCapacity, getRemainingCapacity, updateAgentStatusFromCapacity, isPoolAffinityEnforcementEnabled, buildRoutingAffinityFromAgent, isAgentEligibleForTask, taskQueries, createTask, getPendingTaskForAgent, assignUnassignedTaskPending, startTask, getTaskById, getSlackRenderV2ActivatedAt, ensureSlackRenderV2Activation, isPendingSlackMessage, recordSlackMessage, reserveSlackMessage, bindSlackMessageTimestamp, updateSlackMessageRecord, markSlackTreeRendered, deleteSlackMessageRecord, getSlackTreeMessage, getSlackTreeMessageByThread, getSlackOutcomeMessage, getSlackTreeMessages, getSlackMessageByChannelTs, getSlackTasksInThread, markTaskSlackReplySent, setSlackMessageTracking, getChildTasks, hasNonTerminalResumeChild, hasNonTerminalRerouteDecisionChild, updateTaskClaudeSessionId, updateTaskTitle, updateTaskVcs, getTasksByAgentId, getAgentCurrentTask, getTasksByStatus, findTaskByVcs, findTaskByGitHub, getAllTasks, getTasksCount, getTaskStats, getCompletedSlackTasks, getRecentlyFinishedWorkerTasks, markTasksNotified, resetTasksNotified, getInProgressSlackTasks, getSlackTasksMissingTree, getInProgressTasksByContextKey, findExistingLinearTrackerContextWork, getLatestTaskByContextKey, getLatestScriptRunStepTaskByContextKey, getAgentWorkingOnThread, getLatestActiveTaskInThread, getLatestLeadTaskInThread, getMostRecentTaskInThread, findCompletedTaskInThread, findRecentCancelledTaskInThread, completeTask, failTask, overwriteTerminalTaskResultText, cancelTask, supersedeTask, backfillSupersedeTaskResumeTaskId, pauseTask, resumeTask, getPausedTasksForAgent, getOrphanedInProgressTasksForAgent, resetOrphanedInProgressTasksForAgent, getRecentlyCancelledTasksForAgent, deleteTask, updateTaskProgress, insertTaskAttachment, recordTaskPullRequestAttachments, getAssetKeyMappingByProvider, upsertAssetKeyMapping, getAssetKeyMapping, listAssetSummaries, moveAssetKey, deleteTaskAttachment, replaceTaskAttachment, getTaskAttachments, createSteeringMessage, getSteeringMessagesForTask, getSteeringMessageById, getPendingSteeringForTask, getPendingSteeringForAgent, markSteeringDelivered, markSteeringHandled, markSteeringPromoted, cancelPendingSteeringForTask, hasPendingSteering, getAgentWithTasks, getAllAgentsWithTasks, logQueries, createLogEntry, getLogsByAgentId, getLogsByTaskId, getLogsByTaskIdChronological, getLogsByEventType, getAllLogs, findRecentSimilarTasks, createTaskExtended, claimTask, releaseTask, acceptTask, rejectTask, moveTaskToBacklog, moveTaskFromBacklog, releaseStaleReviewingTasks, releaseStaleOfferedTasksForOfflineAgents, getOfferedTasksForAgent, claimOfferedTask, getUnassignedTasksCount, getUnassignedTaskIds, getUnassignedTaskIdsForAgent, checkDependencies, getDependentTasks, cascadeFailDependents, updateAgentProfile, updateAgentName, createChannel, getMessageById, getChannelById, getChannelByName, getAllChannels, deleteChannel, postMessage, getChannelMessages, updateReadState, getLastReadAt, getUnreadMessages, getMentionsForAgent, getInboxSummary, claimMentions, releaseMentionProcessing, releaseStaleMentionProcessing, createService, getServiceById, getServiceByAgentAndName, getServicesByAgentId, getAllServices, updateServiceStatus, deleteService, upsertService, deleteServicesByAgentId, sessionLogQueries, createSessionLogs, getSessionLogsByTaskId, getSessionLogsBySession, createSessionCost, getSessionCostsByTaskId, getSessionCostsByAgentId, getAllSessionCosts, getSessionCostsFiltered, UNATTRIBUTED_USER_ID, getSessionCostSummary, getAttributionByPerson, getDashboardCostSummary, createInboxMessage, getInboxMessageById, getUnreadInboxMessages, claimInboxMessages, markInboxMessageRead, markInboxMessageResponded, markInboxMessageDelegated, releaseStaleProcessingInbox, getConcurrentContext, getScheduledTasks, getScheduledTaskById, getScheduledTaskByName, createScheduledTask, updateScheduledTask, deleteScheduledTask, getDueScheduledTasks, autoEncryptLegacyPlaintextSecrets, maskSecrets, getSwarmConfigs, getInjectableGlobalConfigs, getSwarmConfigById, getSwarmConfigLookupById, upsertSwarmConfig, deleteSwarmConfig, deleteSwarmConfigByKey, getResolvedConfig, getSwarmRepos, getSwarmRepoById, getSwarmRepoByName, getSwarmRepoByUrl, createSwarmRepo, updateSwarmRepo, deleteSwarmRepo, getAgentMailInboxMapping, getAgentMailInboxMappingsByAgent, getAllAgentMailInboxMappings, createAgentMailInboxMapping, deleteAgentMailInboxMapping, findTaskByAgentMailThread, insertActiveSession, deleteActiveSession, deleteActiveSessionById, getActiveSessions, heartbeatActiveSession, cleanupStaleSessions, cleanupAgentSessions, updateActiveSessionProviderSessionId, getActiveSessionForTask, reassociateSessionLogs, getStalledInProgressTasks, getStalePinnedResumes, failPendingResumeIfUnclaimed, getIdleWorkersWithCapacity, getUnassignedPoolTasks, getStaleUnassignedAffinityTasks, getRecentFailedTasks, getRecentCompletedCount, getRecentFailedCount, createWorkflow, getWorkflow, listWorkflows, updateWorkflow, deleteWorkflow, getWorkflowsByScheduleId, createWorkflowRun, getWorkflowRun, updateWorkflowRun, listWorkflowRuns, countWorkflowRuns, listWorkflowRunsPage, createWorkflowRunStep, getWorkflowRunStep, updateWorkflowRunStep, getWorkflowRunStepsByRunId, getStuckWorkflowRuns, getLastSuccessfulRun, getLastRunStart, getRetryableSteps, getCompletedStepNodeIds, getTaskByWorkflowRunStepId, detachTaskFromWorkflowRunStep, getStepByIdempotencyKey, getStepCountForNode, getLatestStepForNode, createWorkflowVersion, getWorkflowVersions, getWorkflowVersion, createAppVersion, getAppVersions, getAppVersion, createPage, getPage, getPageBySlug, getLatestPageBySlug, listPagesByAgent, listAllPages, countAllPages, countPagesByAgent, updatePage, deletePage, incrementPageViewCount, createPageVersion, getPageVersions, getPageVersion, createMetric, getMetric, getMetricBySlug, listMetricsByAgent, listAllMetrics, countAllMetrics, countMetricsByAgent, updateMetric, deleteMetric, createMetricVersion, getMetricVersions, getMetricVersion, getPromptTemplates, getPromptTemplateById, upsertPromptTemplate, deletePromptTemplate, resetPromptTemplateToDefault, getPromptTemplateHistory, resolvePromptTemplate, checkoutPromptTemplate, getAllChannelActivityCursors, getChannelActivityCursor, upsertChannelActivityCursor, createApprovalRequest, getApprovalRequestById, resolveApprovalRequest, updateApprovalRequestNotifications, listApprovalRequests, getStuckApprovalRuns, getApprovalRequestByStepId, getExpiredPendingApprovals, createWaitState, getWaitStateById, getWaitStateByStepId, getDueWaitStates, getPendingEventWaitNames, getPendingWaitsByEvent, resolveWaitState, getStuckWaitRuns, SKILL_FILE_LIMITS, normalizeSkillFilePath, createSkill, updateSkill, listSkillFileManifest, getSkillFiles, getSkillFile, upsertSkillFile, upsertSkillFiles, deleteSkillFile, deleteSkill, getSkillById, getSkillByName, listSkills, searchSkills, installSkill, getSystemDefaultSkills, installSystemDefaultSkillsForAgent, uninstallSkill, getAgentSkills, toggleAgentSkill, createMcpServer, updateMcpServer, deleteMcpServer, getMcpServerById, getMcpServerByName, listMcpServers, installMcpServer, uninstallMcpServer, getAgentMcpServers, createContextSnapshot, getContextSnapshotsByTaskId, getContextSnapshotsBySessionId, getContextSummaryByTaskId, getAvailableKeyIndices, recordKeyUsage, markKeyRateLimited, recordKeyRateLimitWindows, setApiKeyName, clearKeyRateLimit, getKeyStatuses, getKeyCostSummary, getUserById, getAllUsers, createUser, updateUser, deleteUser, listInboxState, upsertInboxState, listFavorites, listUserFavorites, getFavoriteItemIdSet, setFavorite, setUserFavorite, withFavoriteFlags, listTaskTemplates, getRootTaskChain, listRecentSessions, countSessions, getBudget, getBudgets, upsertBudget, deleteBudget, getAllPricingRows, getPricingRows, getActivePricingRow, insertPricingRow, deletePricingRow, getDailySpendForAgent, getDailySpendGlobal, getDailySpendForUser, recordBudgetRefusalNotification, getBudgetRefusalNotification, getRecentBudgetRefusalNotifications, hasBudgetRefusalNotificationToday, setBudgetRefusalFollowUpTaskId, getLiveAgentCounts, getInstanceActivity, getSwarmMetrics, hasFirstCompletedTask, getKv, sweepExpiredKv, sweepExpiredKvPrefix, upsertKv, deleteKv, KvTypeCollisionError, incrKv, listKv, countKv, createScriptRun, recordInlineScriptRun, getScriptRun, getScriptRunByIdempotencyKey, listScriptRuns, countScriptRuns, countActiveScriptRuns, updateScriptRun, getRunningScriptRuns, getScriptRunJournalStep, upsertScriptRunJournalStep, listScriptRunJournalSteps, countScriptRunJournalSteps, countScriptRunJournalAgentTaskSteps, exports_db, init_db };