@desplega.ai/agent-swarm 1.136.0 → 1.138.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 (210) hide show
  1. package/README.md +12 -3
  2. package/dist/acp-adapter-6nttxe2q.js +4787 -0
  3. package/dist/{actions-agcbc8nd.js → actions-z9dzgh3f.js} +7 -8
  4. package/dist/{app-g2s78xya.js → app-wb6bc7tt.js} +4 -5
  5. package/dist/{assistant-yd3jkb9d.js → assistant-08pd6pgy.js} +9 -10
  6. package/dist/{boot-reembed-6spqw4q0.js → boot-reembed-hstr4e2c.js} +4 -4
  7. package/dist/{boot-reembed-b22s9w5x.js → boot-reembed-y7p7qjbf.js} +5 -5
  8. package/dist/{boot-scrub-logs-6h3cqkc0.js → boot-scrub-logs-azbnxwhn.js} +3 -3
  9. package/dist/{claude-adapter-ng5y8zd7.js → claude-adapter-rwaq6eda.js} +10 -9
  10. package/dist/{claude-managed-adapter-5zr3n86v.js → claude-managed-adapter-vtseey1x.js} +3 -3
  11. package/dist/{cli-qckgdqmr.js → cli-005yr57a.js} +2 -2
  12. package/dist/{cli-54ht104h.js → cli-0cka8dnm.js} +3 -3
  13. package/dist/{cli-gpdtxzar.js → cli-23cpnqk9.js} +1 -1
  14. package/dist/{cli-qhfkxrpg.js → cli-2ypjdmqg.js} +223 -474
  15. package/dist/{cli-bnq8h7ea.js → cli-3719ggyf.js} +17 -10
  16. package/dist/cli-390sgxn5.js +257 -0
  17. package/dist/{cli-z6e8eqrm.js → cli-47esr8ht.js} +2 -2
  18. package/dist/{cli-jjhnma34.js → cli-4jaj24py.js} +248 -101
  19. package/dist/{cli-6gwgzdgw.js → cli-69377c2a.js} +5 -5
  20. package/dist/{cli-ads0hfw2.js → cli-6v4d8r8c.js} +205 -75
  21. package/dist/{cli-mgef08pc.js → cli-8rtyss6g.js} +1 -1
  22. package/dist/{cli-35jknh9e.js → cli-9w7vsmbm.js} +5 -5
  23. package/dist/{cli-m3z53bed.js → cli-b4zdc3x6.js} +1 -1
  24. package/dist/{cli-fpjmcbhz.js → cli-ba87cw29.js} +4 -4
  25. package/dist/{cli-4gzv54ss.js → cli-bzk75kdc.js} +43 -11
  26. package/dist/{cli-d5ygfv18.js → cli-cywkhzqs.js} +35 -11
  27. package/dist/{cli-0crn5kaz.js → cli-d62cd9qs.js} +16 -4
  28. package/dist/{cli-5bnz1t86.js → cli-f9skf1v7.js} +51 -7
  29. package/dist/{cli-06ghj6pe.js → cli-fytpjraz.js} +4 -4
  30. package/dist/{cli-j7qp8gtf.js → cli-h7c5dam1.js} +16 -11
  31. package/dist/{cli-4r4jkqep.js → cli-kkn46gfr.js} +9 -3
  32. package/dist/{cli-tmn19cdz.js → cli-kq9htgbr.js} +415 -62
  33. package/dist/{cli-8v57p983.js → cli-pkmqqxp8.js} +45 -69
  34. package/dist/{cli-84vrhesc.js → cli-qf34ej1d.js} +1 -1
  35. package/dist/{cli-v3qda694.js → cli-rnyttbh0.js} +0 -5
  36. package/dist/cli-rx5cxzn2.js +7 -0
  37. package/dist/{cli-cw70hymf.js → cli-s25avqg9.js} +2 -0
  38. package/dist/{cli-tee8w7tq.js → cli-s6t1qv67.js} +15 -10
  39. package/dist/{cli-68vayryq.js → cli-tb4csb08.js} +2 -2
  40. package/dist/{cli-y16cesaq.js → cli-vy48y9bx.js} +2 -2
  41. package/dist/{cli-3y553gws.js → cli-y294regh.js} +1 -1
  42. package/dist/{cli-spf767vc.js → cli-y43043ws.js} +1 -1
  43. package/dist/{cli-hz5hp6wn.js → cli-yh2eybyt.js} +1 -1
  44. package/dist/{cli-edwrx42s.js → cli-zmyxt25p.js} +5 -5
  45. package/dist/cli.js +40 -18
  46. package/dist/{codex-adapter-kw11ps3j.js → codex-adapter-yzep6mvb.js} +7 -6
  47. package/dist/{codex-session-runner-sffb69v7.js → codex-session-runner-25e8tn72.js} +7 -6
  48. package/dist/{commands-0xxp4tz8.js → commands-0vv72d6a.js} +3 -3
  49. package/dist/{db-0npp39zd.js → db-x61ncfa1.js} +19 -3
  50. package/dist/{google-generative-ai-6xxdj4t3.js → google-generative-ai-zyhy3dab.js} +1 -1
  51. package/dist/{google-vertex-zma18wb0.js → google-vertex-t25h65yd.js} +1 -1
  52. package/dist/{handlers-5p7a1jx6.js → handlers-fwdcaahf.js} +9 -10
  53. package/dist/{hook-jjpxn4se.js → hook-mpwfgynm.js} +6 -5
  54. package/dist/{hook-hpefr0a8.js → hook-x18504ja.js} +8 -7
  55. package/dist/{http-wfp33653.js → http-83m6qdds.js} +590 -192
  56. package/dist/{index-pe58mf1r.js → index-1nsdwvn5.js} +2 -1
  57. package/dist/{index-17h657rg.js → index-38f98ck3.js} +9 -9
  58. package/dist/{index-m2p7ctyh.js → index-7kxvtd38.js} +24 -12
  59. package/dist/{index-racb4wfq.js → index-a4naswjn.js} +23 -10
  60. package/dist/{index-p13cfsc2.js → index-agykc6k2.js} +2 -1
  61. package/dist/{index-zh66wm65.js → index-dawtzfhw.js} +22 -9
  62. package/dist/{keepalive-wxjd633a.js → keepalive-y0m8g5wn.js} +5 -5
  63. package/dist/{lead-359ec2z0.js → lead-ka18ef6a.js} +36 -36
  64. package/dist/{maintenance-rr03qjtb.js → maintenance-x585p56c.js} +5 -5
  65. package/dist/{oauth-refresh-sweep-jwj22yb8.js → oauth-refresh-sweep-kdm9vj7a.js} +4 -4
  66. package/dist/{onboard-asnhchcv.js → onboard-5v229nvt.js} +664 -248
  67. package/dist/{opencode-adapter-sx38y7f7.js → opencode-adapter-46nnmnvv.js} +3 -3
  68. package/dist/{otel-impl-54cra6mw.js → otel-impl-k47aj4sd.js} +73 -4
  69. package/dist/{pi-mono-adapter-29g7axgj.js → pi-mono-adapter-wawfj09v.js} +42 -40
  70. package/dist/{pricing-refresh-mkyy7c2y.js → pricing-refresh-ky2gjp05.js} +5 -5
  71. package/dist/{rbac-roles-kb3afm95.js → rbac-roles-0j0f7s8r.js} +4 -4
  72. package/dist/{rbac-roles-ak56tr75.js → rbac-roles-az4wc15e.js} +3 -3
  73. package/dist/{render-v2-434asg49.js → render-v2-seyxq61z.js} +4 -5
  74. package/dist/{seed-pricing-nbmd7ah8.js → seed-pricing-fev611hx.js} +4 -4
  75. package/dist/{setup-wh4qmjs4.js → setup-hy404zwh.js} +2 -2
  76. package/dist/{worker-j1d27tjv.js → worker-g1j5hn16.js} +36 -36
  77. package/openapi.json +197 -27
  78. package/package.json +9 -3
  79. package/src/be/db-client.ts +58 -5
  80. package/src/be/db-retention.ts +550 -121
  81. package/src/be/db.ts +367 -55
  82. package/src/be/memory/raters/retrieval.ts +40 -0
  83. package/src/be/migrations/140_approval_request_cancelled_status.sql +64 -0
  84. package/src/be/pricing-normalize.ts +3 -0
  85. package/src/be/script-connections.ts +26 -6
  86. package/src/be/seed-pricing.ts +18 -8
  87. package/src/be/swarm-config-guard.ts +33 -0
  88. package/src/cli.tsx +20 -1
  89. package/src/commands/onboard/compose-generator.ts +63 -7
  90. package/src/commands/onboard/env-generator.ts +32 -4
  91. package/src/commands/onboard/manifest.ts +4 -1
  92. package/src/commands/onboard/non-interactive.ts +159 -0
  93. package/src/commands/onboard/steps/generate.tsx +1 -34
  94. package/src/commands/onboard/steps/harness-credentials.tsx +181 -1
  95. package/src/commands/onboard/steps/harness.tsx +20 -6
  96. package/src/commands/onboard/steps/review.tsx +3 -2
  97. package/src/commands/onboard/types.ts +48 -1
  98. package/src/commands/onboard.tsx +18 -13
  99. package/src/commands/provider-credentials.ts +17 -3
  100. package/src/commands/runner.ts +1 -0
  101. package/src/heartbeat/heartbeat.ts +47 -7
  102. package/src/http/approval-requests.ts +53 -8
  103. package/src/http/index.ts +9 -1
  104. package/src/http/mcp-servers.ts +2 -0
  105. package/src/http/memory.ts +27 -1
  106. package/src/http/oauth-callback.ts +33 -0
  107. package/src/http/repos.ts +6 -0
  108. package/src/http/script-connections.ts +77 -0
  109. package/src/http/session-data.ts +5 -1
  110. package/src/http/stats.ts +21 -30
  111. package/src/http/tasks.ts +10 -0
  112. package/src/oauth/presets.ts +29 -0
  113. package/src/otel-impl.ts +96 -1
  114. package/src/otel.ts +34 -0
  115. package/src/prompts/memories.ts +2 -2
  116. package/src/providers/acp-adapter.ts +325 -0
  117. package/src/providers/acp-swarm-events.ts +113 -0
  118. package/src/providers/acp-targets.ts +103 -0
  119. package/src/providers/claude-managed-models.ts +17 -1
  120. package/src/providers/codex-adapter.ts +3 -3
  121. package/src/providers/codex-oauth/auth-json-fs.ts +2 -2
  122. package/src/providers/codex-oauth/home.ts +13 -0
  123. package/src/providers/index.ts +5 -1
  124. package/src/providers/types.ts +1 -1
  125. package/src/server-user.ts +1 -0
  126. package/src/slack/app.ts +5 -1
  127. package/src/tasks/worker-follow-up.ts +78 -7
  128. package/src/telemetry.ts +151 -0
  129. package/src/tests/acp-adapter.test.ts +192 -0
  130. package/src/tests/acp-swarm-events.test.ts +132 -0
  131. package/src/tests/agents-list-model-display.test.ts +20 -0
  132. package/src/tests/approval-cancellation-migration.test.ts +134 -0
  133. package/src/tests/approval-requests.test.ts +456 -2
  134. package/src/tests/apps-spike2.test.ts +4 -1
  135. package/src/tests/apps-sync-engine.test.ts +22 -18
  136. package/src/tests/claude-managed-adapter.test.ts +12 -0
  137. package/src/tests/codex-oauth-auth-json-fs.test.ts +19 -0
  138. package/src/tests/connection-embedded-auth.test.ts +4 -1
  139. package/src/tests/context-window.test.ts +2 -0
  140. package/src/tests/credential-check.test.ts +6 -0
  141. package/src/tests/db-client-busy-retry.test.ts +18 -0
  142. package/src/tests/db-client.test.ts +23 -0
  143. package/src/tests/db-retention-telemetry.test.ts +569 -0
  144. package/src/tests/db-retention.test.ts +456 -117
  145. package/src/tests/heartbeat.test.ts +140 -0
  146. package/src/tests/memory-http-recall-gating.test.ts +120 -13
  147. package/src/tests/memory-store.test.ts +41 -0
  148. package/src/tests/migration-046-budgets.test.ts +27 -5
  149. package/src/tests/oauth-presets.test.ts +17 -5
  150. package/src/tests/onboard-compose.test.ts +99 -0
  151. package/src/tests/onboard-env.test.ts +43 -0
  152. package/src/tests/onboard-manifest.test.ts +17 -1
  153. package/src/tests/onboard-non-interactive.test.ts +89 -0
  154. package/src/tests/pool-affinity.test.ts +100 -0
  155. package/src/tests/promote-draft-task-route.test.ts +32 -1
  156. package/src/tests/sandbox-spawn-test-helpers.ts +3 -0
  157. package/src/tests/sandboxed-process.test.ts +2 -2
  158. package/src/tests/schedule-target-type.test.ts +6 -3
  159. package/src/tests/script-connections-http.test.ts +4 -3
  160. package/src/tests/script-connections.test.ts +6 -1
  161. package/src/tests/script-workflows-runtime-e2e.test.ts +36 -28
  162. package/src/tests/scripts-external-api.test.ts +8 -5
  163. package/src/tests/scripts-http.test.ts +6 -3
  164. package/src/tests/scripts-mcp-e2e.test.ts +65 -60
  165. package/src/tests/scripts-retention.test.ts +6 -3
  166. package/src/tests/scripts-runtime-identity.test.ts +4 -2
  167. package/src/tests/scripts-runtime.test.ts +18 -16
  168. package/src/tests/session-costs-model-key-normalize.test.ts +2 -0
  169. package/src/tests/slack-read-boundaries.test.ts +3 -1
  170. package/src/tests/task-lifecycle-telemetry.test.ts +1 -0
  171. package/src/tests/task-tools-ctx.test.ts +88 -1
  172. package/src/tests/telemetry-init.test.ts +61 -0
  173. package/src/tests/tool-annotations.test.ts +4 -1
  174. package/src/tests/vendored-openapi.test.ts +15 -2
  175. package/src/tests/workflow-e2e.test.ts +4 -1
  176. package/src/tests/workflow-engine-v2.test.ts +5 -2
  177. package/src/tests/workflow-executors.test.ts +24 -19
  178. package/src/tests/workflow-http-v2.test.ts +17 -2
  179. package/src/tests/workflow-llm.test.ts +57 -0
  180. package/src/tests/workflow-retry-v2.test.ts +142 -1
  181. package/src/tests/workflow-swarm-script.test.ts +20 -17
  182. package/src/tools/get-task-details.ts +1 -0
  183. package/src/tools/mcp-servers/mcp-server-create.ts +7 -1
  184. package/src/tools/memory-search.ts +27 -2
  185. package/src/tools/send-task.ts +28 -10
  186. package/src/tools/task-action.ts +13 -5
  187. package/src/types.ts +31 -2
  188. package/src/utils/context-window.ts +2 -0
  189. package/src/workflows/approval-notifications.ts +72 -0
  190. package/src/workflows/checkpoint.ts +16 -9
  191. package/src/workflows/completed-step-routing.ts +31 -0
  192. package/src/workflows/engine.ts +59 -43
  193. package/src/workflows/executors/human-in-the-loop.ts +38 -4
  194. package/src/workflows/executors/raw-llm.ts +8 -6
  195. package/src/workflows/executors/validate.ts +6 -5
  196. package/src/workflows/executors/workflow-llm.ts +35 -0
  197. package/src/workflows/resume.ts +90 -13
  198. package/src/workflows/retry-poller.ts +8 -1
  199. package/vendored-openapi/README.md +4 -2
  200. package/vendored-openapi/manifest.json +33 -0
  201. package/vendored-openapi/microsoft-graph.json +781 -0
  202. package/dist/cli-5tnr64pm.js +0 -29
  203. package/dist/{anthropic-messages-pm7pp23c.js → anthropic-messages-tvgm75yc.js} +3 -3
  204. package/dist/{azure-openai-responses-cwesc845.js → azure-openai-responses-hed7waek.js} +4 -4
  205. package/dist/{cli-s9gpxh9q.js → cli-5kmzp1wx.js} +0 -0
  206. package/dist/{cli-s73zwwqn.js → cli-xjx3fbtn.js} +4 -4
  207. package/dist/{openai-codex-responses-xxca1qr1.js → openai-codex-responses-gv3n8rg0.js} +3 -3
  208. package/dist/{openai-completions-yzftqrft.js → openai-completions-dkrj9433.js} +8 -8
  209. package/dist/{openai-responses-e4dcwm9g.js → openai-responses-spk6t7kh.js} +11 -11
  210. package/dist/{openrouter-images-asqqnbvh.js → openrouter-images-71hthwh9.js} +3 -3
@@ -35,15 +35,6 @@ import {
35
35
  exports_zod,
36
36
  init_zod
37
37
  } from "./cli-s35981d0.js";
38
- import {
39
- init_secret_scrubber,
40
- registerVolatileSecret,
41
- scrubSecrets
42
- } from "./cli-mkq1rk7b.js";
43
- import {
44
- init_package,
45
- package_default
46
- } from "./cli-4r4jkqep.js";
47
38
  import {
48
39
  _enum,
49
40
  array,
@@ -52,6 +43,15 @@ import {
52
43
  string,
53
44
  union
54
45
  } from "./cli-pqv5gvyf.js";
46
+ import {
47
+ init_package,
48
+ package_default
49
+ } from "./cli-kkn46gfr.js";
50
+ import {
51
+ init_secret_scrubber,
52
+ registerVolatileSecret,
53
+ scrubSecrets
54
+ } from "./cli-mkq1rk7b.js";
55
55
  import {
56
56
  __commonJS,
57
57
  __esm,
@@ -437,6 +437,28 @@ function _resolveInstallMethod(raw, isE2b) {
437
437
  return "e2b";
438
438
  return "manual";
439
439
  }
440
+ function integrationProviderEntry(providerSlug) {
441
+ const raw = providerSlug?.trim().toLowerCase();
442
+ if (!raw)
443
+ return;
444
+ let candidate = raw;
445
+ try {
446
+ candidate = new URL(raw).hostname.toLowerCase();
447
+ } catch {
448
+ const sshHost = raw.match(/^[^@]+@([^:]+):/)?.[1];
449
+ if (sshHost)
450
+ candidate = sshHost;
451
+ }
452
+ if (candidate.startsWith("www."))
453
+ candidate = candidate.slice(4);
454
+ return INTEGRATION_PROVIDERS.get(candidate);
455
+ }
456
+ function _resolveIntegrationType(providerSlug) {
457
+ return integrationProviderEntry(providerSlug)?.type ?? "other";
458
+ }
459
+ function _resolveIntegrationProvider(providerSlug) {
460
+ return integrationProviderEntry(providerSlug)?.provider;
461
+ }
440
462
  function _resolveInstallPreset(raw) {
441
463
  const normalized = raw?.trim();
442
464
  return normalized && KNOWN_INSTALL_PRESETS.has(normalized) ? normalized : undefined;
@@ -554,7 +576,18 @@ function track(options) {
554
576
  }).catch(() => {});
555
577
  } catch {}
556
578
  }
557
- var TELEMETRY_ENDPOINT = "https://proxy.desplega.sh/v1/events", PRODUCT = "agent-swarm", TIMEOUT_MS = 5000, installationId = null, installedAt = null, source = "unknown", cachedIsCloud = false, cachedIsE2b = false, cachedHasEmbedding = false, cachedHasSlackChannel = false, cachedHasEmailChannel = false, cachedInstallMethod = "manual", cachedInstallPreset, CLOUD_HOST_EXACT, CLOUD_HOST_SUFFIXES, KNOWN_INSTALL_METHODS, KNOWN_INSTALL_PRESETS, telemetry;
579
+ function emitIntegrationConnected(type, providerSlug, firstOfType) {
580
+ if (!isEnabled() || !installationId)
581
+ return false;
582
+ const provider = _resolveIntegrationProvider(providerSlug);
583
+ telemetry.integration("connected", {
584
+ type,
585
+ ...provider ? { provider } : {},
586
+ first_of_type: firstOfType
587
+ });
588
+ return true;
589
+ }
590
+ var TELEMETRY_ENDPOINT = "https://proxy.desplega.sh/v1/events", PRODUCT = "agent-swarm", TIMEOUT_MS = 5000, installationId = null, installedAt = null, source = "unknown", cachedIsCloud = false, cachedIsE2b = false, cachedHasEmbedding = false, cachedHasSlackChannel = false, cachedHasEmailChannel = false, cachedInstallMethod = "manual", cachedInstallPreset, CLOUD_HOST_EXACT, CLOUD_HOST_SUFFIXES, KNOWN_INSTALL_METHODS, KNOWN_INSTALL_PRESETS, KNOWN_INTEGRATION_TYPES, INTEGRATION_PROVIDERS, telemetry;
558
591
  var init_telemetry = __esm(() => {
559
592
  init_package();
560
593
  init_env_flag();
@@ -566,6 +599,57 @@ var init_telemetry = __esm(() => {
566
599
  CLOUD_HOST_SUFFIXES = [".agent-swarm.dev", ".agent-swarm.cloud"];
567
600
  KNOWN_INSTALL_METHODS = new Set(["onboard_interactive", "onboard_noninteractive"]);
568
601
  KNOWN_INSTALL_PRESETS = new Set(["dev", "content", "research", "solo", "custom"]);
602
+ KNOWN_INTEGRATION_TYPES = new Set([
603
+ "code_repo",
604
+ "comms",
605
+ "task_manager",
606
+ "information_management",
607
+ "other"
608
+ ]);
609
+ INTEGRATION_PROVIDERS = new Map([
610
+ ["github", { provider: "github", type: "code_repo" }],
611
+ ["github.com", { provider: "github", type: "code_repo" }],
612
+ ["api.github.com", { provider: "github", type: "code_repo" }],
613
+ ["gitlab", { provider: "gitlab", type: "code_repo" }],
614
+ ["gitlab.com", { provider: "gitlab", type: "code_repo" }],
615
+ ["bitbucket", { provider: "bitbucket", type: "code_repo" }],
616
+ ["bitbucket.org", { provider: "bitbucket", type: "code_repo" }],
617
+ ["api.bitbucket.org", { provider: "bitbucket", type: "code_repo" }],
618
+ ["slack", { provider: "slack", type: "comms" }],
619
+ ["slack.com", { provider: "slack", type: "comms" }],
620
+ ["api.slack.com", { provider: "slack", type: "comms" }],
621
+ ["email", { provider: "email", type: "comms" }],
622
+ ["kapso", { provider: "kapso", type: "comms" }],
623
+ ["kapso.ai", { provider: "kapso", type: "comms" }],
624
+ ["api.kapso.ai", { provider: "kapso", type: "comms" }],
625
+ ["discord", { provider: "discord", type: "comms" }],
626
+ ["discord.com", { provider: "discord", type: "comms" }],
627
+ ["telegram", { provider: "telegram", type: "comms" }],
628
+ ["telegram.org", { provider: "telegram", type: "comms" }],
629
+ ["api.telegram.org", { provider: "telegram", type: "comms" }],
630
+ ["whatsapp", { provider: "whatsapp", type: "comms" }],
631
+ ["whatsapp.com", { provider: "whatsapp", type: "comms" }],
632
+ ["linear", { provider: "linear", type: "task_manager" }],
633
+ ["linear.app", { provider: "linear", type: "task_manager" }],
634
+ ["api.linear.app", { provider: "linear", type: "task_manager" }],
635
+ ["jira", { provider: "jira", type: "task_manager" }],
636
+ ["asana", { provider: "asana", type: "task_manager" }],
637
+ ["asana.com", { provider: "asana", type: "task_manager" }],
638
+ ["app.asana.com", { provider: "asana", type: "task_manager" }],
639
+ ["trello", { provider: "trello", type: "task_manager" }],
640
+ ["trello.com", { provider: "trello", type: "task_manager" }],
641
+ ["api.trello.com", { provider: "trello", type: "task_manager" }],
642
+ ["google_drive", { provider: "google_drive", type: "information_management" }],
643
+ ["gdrive", { provider: "google_drive", type: "information_management" }],
644
+ ["drive.google.com", { provider: "google_drive", type: "information_management" }],
645
+ ["notion", { provider: "notion", type: "information_management" }],
646
+ ["notion.so", { provider: "notion", type: "information_management" }],
647
+ ["api.notion.com", { provider: "notion", type: "information_management" }],
648
+ ["dropbox", { provider: "dropbox", type: "information_management" }],
649
+ ["dropbox.com", { provider: "dropbox", type: "information_management" }],
650
+ ["api.dropboxapi.com", { provider: "dropbox", type: "information_management" }],
651
+ ["confluence", { provider: "confluence", type: "information_management" }]
652
+ ]);
569
653
  telemetry = {
570
654
  taskEvent(event, props) {
571
655
  track({ event: `task.${event}`, properties: props });
@@ -585,6 +669,18 @@ var init_telemetry = __esm(() => {
585
669
  agent(event, props) {
586
670
  track({ event: `agent.${event}`, properties: props });
587
671
  },
672
+ integration(event, props) {
673
+ const type = KNOWN_INTEGRATION_TYPES.has(props.type) ? props.type : "other";
674
+ const provider = props.provider ? integrationProviderEntry(props.provider)?.provider : undefined;
675
+ track({
676
+ event: `integration.${event}`,
677
+ properties: {
678
+ type,
679
+ ...provider ? { provider } : {},
680
+ first_of_type: props.first_of_type
681
+ }
682
+ });
683
+ },
588
684
  compaction(event, props) {
589
685
  track({ event: `compaction.${event}`, properties: props });
590
686
  }
@@ -2188,6 +2284,12 @@ var init_types = __esm(() => {
2188
2284
  regular: "devin",
2189
2285
  smart: "devin",
2190
2286
  ultra: "devin"
2287
+ },
2288
+ acp: {
2289
+ smol: "",
2290
+ regular: "",
2291
+ smart: "",
2292
+ ultra: ""
2191
2293
  }
2192
2294
  };
2193
2295
  AgentTaskStatusSchema = exports_zod.enum([
@@ -2247,7 +2349,8 @@ var init_types = __esm(() => {
2247
2349
  "pi",
2248
2350
  "devin",
2249
2351
  "claude-managed",
2250
- "opencode"
2352
+ "opencode",
2353
+ "acp"
2251
2354
  ]);
2252
2355
  SteerModeSchema = exports_zod.enum(["steer", "queue"]);
2253
2356
  SteeringStatusSchema = exports_zod.enum([
@@ -2290,7 +2393,8 @@ var init_types = __esm(() => {
2290
2393
  devin: ["queue"],
2291
2394
  opencode: ["queue"],
2292
2395
  claude: ["queue"],
2293
- codex: ["queue"]
2396
+ codex: ["queue"],
2397
+ acp: []
2294
2398
  };
2295
2399
  FollowUpConfigSchema = exports_zod.object({
2296
2400
  disabled: exports_zod.boolean().optional(),
@@ -2301,7 +2405,8 @@ var init_types = __esm(() => {
2301
2405
  sourceAgentId: exports_zod.string().optional(),
2302
2406
  role: exports_zod.string().max(100).optional(),
2303
2407
  harnessProvider: ProviderNameSchema.optional(),
2304
- capabilities: exports_zod.array(exports_zod.string()).default([])
2408
+ capabilities: exports_zod.array(exports_zod.string()).default([]),
2409
+ leadOnly: exports_zod.boolean().optional()
2305
2410
  }).openapi("RoutingAffinity");
2306
2411
  AgentTaskSchema = exports_zod.object({
2307
2412
  id: exports_zod.uuid(),
@@ -2374,7 +2479,8 @@ var init_types = __esm(() => {
2374
2479
  harnessVariant: exports_zod.string().optional(),
2375
2480
  harnessVariantMeta: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional(),
2376
2481
  totalCostUsd: exports_zod.number().min(0).optional(),
2377
- routingAffinity: RoutingAffinitySchema.optional()
2482
+ routingAffinity: RoutingAffinitySchema.optional(),
2483
+ routingAffinityInvalid: exports_zod.boolean().optional()
2378
2484
  }).openapi("AgentTask");
2379
2485
  CreateTaskOptionsSchema = exports_zod.object({
2380
2486
  key: exports_zod.string().min(1).optional(),
@@ -2711,6 +2817,8 @@ var init_types = __esm(() => {
2711
2817
  "task_rejected",
2712
2818
  "task_claimed",
2713
2819
  "task_claim_rejected_affinity",
2820
+ "task_authorization_rejected",
2821
+ "task_recovery_authorization",
2714
2822
  "task_released",
2715
2823
  "channel_message",
2716
2824
  "service_registered",
@@ -3588,7 +3696,8 @@ var init_types = __esm(() => {
3588
3696
  "pi",
3589
3697
  "opencode",
3590
3698
  "devin",
3591
- "gemini"
3699
+ "gemini",
3700
+ "acp"
3592
3701
  ]);
3593
3702
  PricingTokenClassSchema = exports_zod.enum([
3594
3703
  "input",
@@ -4327,6 +4436,16 @@ class BunSqliteClient {
4327
4436
  return { changes: result.changes };
4328
4437
  });
4329
4438
  }
4439
+ async runTimed(sql, params = []) {
4440
+ let executionMs = 0;
4441
+ const result = await this.execute((db) => {
4442
+ const run = db.query(sql).run(...params);
4443
+ return { changes: run.changes };
4444
+ }, (ms) => {
4445
+ executionMs += ms;
4446
+ });
4447
+ return { ...result, executionMs };
4448
+ }
4330
4449
  async transaction(fn, opts) {
4331
4450
  const existing = txContext.getStore();
4332
4451
  if (existing && !existing.closed) {
@@ -4429,10 +4548,20 @@ class BunSqliteClient {
4429
4548
  throw err;
4430
4549
  }
4431
4550
  }
4432
- async execute(op) {
4551
+ async execute(op, recordExecutionMs) {
4552
+ const timed = (attempt) => {
4553
+ if (!recordExecutionMs)
4554
+ return attempt();
4555
+ const startedAt = performance.now();
4556
+ try {
4557
+ return attempt();
4558
+ } finally {
4559
+ recordExecutionMs(performance.now() - startedAt);
4560
+ }
4561
+ };
4433
4562
  const ctx = txContext.getStore();
4434
4563
  if (ctx && !ctx.closed) {
4435
- return op(this.getDatabase());
4564
+ return timed(() => op(this.getDatabase()));
4436
4565
  }
4437
4566
  let sleptMs = 0;
4438
4567
  for (let attemptIndex = 0;; attemptIndex++) {
@@ -4441,7 +4570,7 @@ class BunSqliteClient {
4441
4570
  const release = await this.lock.acquire();
4442
4571
  let backoff = 0;
4443
4572
  try {
4444
- return canRetryAfter ? this.shortSpin(this.getDatabase(), () => op(this.getDatabase())) : op(this.getDatabase());
4573
+ return timed(() => canRetryAfter ? this.shortSpin(this.getDatabase(), () => op(this.getDatabase())) : op(this.getDatabase()));
4445
4574
  } catch (err) {
4446
4575
  if (!isSqliteBusy(err) || !canRetryAfter || next === undefined)
4447
4576
  throw err;
@@ -5177,6 +5306,13 @@ function integerValidators(keys, min) {
5177
5306
  }
5178
5307
  ]));
5179
5308
  }
5309
+ function boundedIntegerValidatorsFor(bounds) {
5310
+ const validators = {};
5311
+ for (const [key, { min, max }] of Object.entries(bounds)) {
5312
+ Object.assign(validators, boundedIntegerValidators([key], min, max));
5313
+ }
5314
+ return validators;
5315
+ }
5180
5316
  function boundedIntegerValidators(keys, min, max) {
5181
5317
  return Object.fromEntries(keys.map((key) => [
5182
5318
  key,
@@ -5201,11 +5337,16 @@ function validateConfigValue(key, value) {
5201
5337
  const validator = VALIDATED_KEYS[key.toUpperCase()];
5202
5338
  return validator ? validator(value) : null;
5203
5339
  }
5204
- var RESERVED_KEYS, BOOLEAN_LITERALS, MAX_DB_RETENTION_DAYS = 1e6, VALIDATED_KEYS;
5340
+ var RESERVED_KEYS, BOOLEAN_LITERALS, MAX_DB_RETENTION_DAYS = 1e6, DB_RETENTION_TUNING_BOUNDS, VALIDATED_KEYS;
5205
5341
  var init_swarm_config_guard = __esm(() => {
5206
5342
  init_types();
5207
5343
  RESERVED_KEYS = new Set(["API_KEY", "SECRETS_ENCRYPTION_KEY"]);
5208
5344
  BOOLEAN_LITERALS = ["true", "false", "1", "0"];
5345
+ DB_RETENTION_TUNING_BOUNDS = {
5346
+ DB_RETENTION_TICK_BUDGET_MS: { min: 1000, max: 300000 },
5347
+ DB_RETENTION_CATCHUP_INTERVAL_MS: { min: 5000, max: 3600000 },
5348
+ DB_RETENTION_MAX_STATEMENT_MS: { min: 25, max: 5000 }
5349
+ };
5209
5350
  VALIDATED_KEYS = {
5210
5351
  HARNESS_PROVIDER: (value) => {
5211
5352
  const parsed = ProviderNameSchema.safeParse(value);
@@ -5291,6 +5432,7 @@ var init_swarm_config_guard = __esm(() => {
5291
5432
  "DB_QUERY_MCP_MAX_ROWS",
5292
5433
  "AGENT_FS_REQUEST_TIMEOUT_MS"
5293
5434
  ], 1),
5435
+ ...boundedIntegerValidatorsFor(DB_RETENTION_TUNING_BOUNDS),
5294
5436
  ...boundedIntegerValidators(["SESSION_LOG_RETENTION_DAYS", "AGENT_LOG_RETENTION_DAYS", "EVENTS_RETENTION_DAYS"], 1, MAX_DB_RETENTION_DAYS),
5295
5437
  ...integerValidators(["HEARTBEAT_MAX_AUTO_ASSIGN"], 0),
5296
5438
  MEMORY_MIN_SIMILARITY: (value) => validateFloatRange("MEMORY_MIN_SIMILARITY", value, 0, 1, "between 0 and 1 inclusive"),
@@ -5366,11 +5508,13 @@ __export(exports_db, {
5366
5508
  backfillSupersedeTaskResumeTaskId: () => backfillSupersedeTaskResumeTaskId,
5367
5509
  bindSlackMessageTimestamp: () => bindSlackMessageTimestamp,
5368
5510
  buildRoutingAffinityFromAgent: () => buildRoutingAffinityFromAgent,
5511
+ cancelPendingApprovalRequestsForRun: () => cancelPendingApprovalRequestsForRun,
5369
5512
  cancelPendingSteeringForTask: () => cancelPendingSteeringForTask,
5370
5513
  cancelTask: () => cancelTask,
5371
5514
  cascadeFailDependents: () => cascadeFailDependents,
5372
5515
  checkDependencies: () => checkDependencies,
5373
5516
  checkoutPromptTemplate: () => checkoutPromptTemplate,
5517
+ claimApprovalCancellationNotification: () => claimApprovalCancellationNotification,
5374
5518
  claimInboxMessages: () => claimInboxMessages,
5375
5519
  claimKv: () => claimKv,
5376
5520
  claimMentions: () => claimMentions,
@@ -5380,6 +5524,7 @@ __export(exports_db, {
5380
5524
  cleanupStaleSessions: () => cleanupStaleSessions,
5381
5525
  clearKeyRateLimit: () => clearKeyRateLimit,
5382
5526
  closeDb: () => closeDb,
5527
+ completeApprovalCancellationNotificationClaim: () => completeApprovalCancellationNotificationClaim,
5383
5528
  completeTask: () => completeTask,
5384
5529
  computeContentHash: () => computeContentHash,
5385
5530
  countActiveScriptRuns: () => countActiveScriptRuns,
@@ -5449,6 +5594,8 @@ __export(exports_db, {
5449
5594
  deleteUser: () => deleteUser,
5450
5595
  deleteWorkflow: () => deleteWorkflow,
5451
5596
  detachTaskFromWorkflowRunStep: () => detachTaskFromWorkflowRunStep,
5597
+ emitBuiltInIntegrationConnectedOnce: () => emitBuiltInIntegrationConnectedOnce,
5598
+ emitMcpServerConnectedTelemetry: () => emitMcpServerConnectedTelemetry,
5452
5599
  ensureSlackRenderV2Activation: () => ensureSlackRenderV2Activation,
5453
5600
  failPendingResumeIfUnclaimed: () => failPendingResumeIfUnclaimed,
5454
5601
  failTask: () => failTask,
@@ -5679,6 +5826,8 @@ __export(exports_db, {
5679
5826
  listAllPages: () => listAllPages,
5680
5827
  listApprovalRequests: () => listApprovalRequests,
5681
5828
  listAssetSummaries: () => listAssetSummaries,
5829
+ listCancelledApprovalRequestsForRun: () => listCancelledApprovalRequestsForRun,
5830
+ listCancelledApprovalRequestsForStep: () => listCancelledApprovalRequestsForStep,
5682
5831
  listFavorites: () => listFavorites,
5683
5832
  listInboxState: () => listInboxState,
5684
5833
  listKv: () => listKv,
@@ -5723,6 +5872,7 @@ __export(exports_db, {
5723
5872
  recordSlackMessage: () => recordSlackMessage,
5724
5873
  recordTaskPullRequestAttachments: () => recordTaskPullRequestAttachments,
5725
5874
  rejectTask: () => rejectTask,
5875
+ releaseApprovalCancellationNotificationClaim: () => releaseApprovalCancellationNotificationClaim,
5726
5876
  releaseMentionProcessing: () => releaseMentionProcessing,
5727
5877
  releaseStaleMentionProcessing: () => releaseStaleMentionProcessing,
5728
5878
  releaseStaleOfferedTasksForOfflineAgents: () => releaseStaleOfferedTasksForOfflineAgents,
@@ -6311,24 +6461,27 @@ async function buildRoutingAffinityFromAgent(agentId) {
6311
6461
  };
6312
6462
  }
6313
6463
  function isAgentEligibleForTask(agent, task) {
6314
- if (!isPoolAffinityEnforcementEnabled())
6315
- return true;
6316
6464
  const affinity = task.routingAffinity;
6465
+ if (task.routingAffinityInvalid)
6466
+ return false;
6317
6467
  if (!affinity)
6318
6468
  return true;
6469
+ const requiredCapabilities = affinity.capabilities ?? [];
6470
+ const hasRequiredCapabilities = () => {
6471
+ const agentCapabilities = new Set(agent.capabilities ?? []);
6472
+ return requiredCapabilities.every((cap) => agentCapabilities.has(cap));
6473
+ };
6474
+ if (affinity.leadOnly)
6475
+ return agent.isLead && hasRequiredCapabilities();
6476
+ if (!isPoolAffinityEnforcementEnabled())
6477
+ return true;
6319
6478
  if (affinity.sourceAgentId && affinity.sourceAgentId === agent.id)
6320
6479
  return true;
6321
6480
  if (!agent.role || !affinity.role)
6322
6481
  return false;
6323
6482
  if (agent.role !== affinity.role)
6324
6483
  return false;
6325
- const requiredCapabilities = affinity.capabilities ?? [];
6326
- if (requiredCapabilities.length > 0) {
6327
- const agentCapabilities = new Set(agent.capabilities ?? []);
6328
- if (!requiredCapabilities.every((cap) => agentCapabilities.has(cap)))
6329
- return false;
6330
- }
6331
- return true;
6484
+ return hasRequiredCapabilities();
6332
6485
  }
6333
6486
  function rowToAgentTask(row) {
6334
6487
  let followUpConfig;
@@ -6346,16 +6499,19 @@ function rowToAgentTask(row) {
6346
6499
  }
6347
6500
  }
6348
6501
  let routingAffinity;
6502
+ let routingAffinityInvalid = false;
6349
6503
  if (row.routingAffinity) {
6350
6504
  try {
6351
6505
  const parsed = RoutingAffinitySchema.safeParse(JSON.parse(row.routingAffinity));
6352
6506
  if (parsed.success) {
6353
6507
  routingAffinity = parsed.data;
6354
6508
  } else {
6355
- console.warn(`[db] Ignoring invalid agent_tasks.routingAffinity for task ${row.id}:`, parsed.error.message);
6509
+ routingAffinityInvalid = true;
6510
+ console.warn(`[db] Quarantining invalid agent_tasks.routingAffinity for task ${row.id}:`, parsed.error.message);
6356
6511
  }
6357
6512
  } catch (error) {
6358
- console.warn(`[db] Ignoring malformed agent_tasks.routingAffinity for task ${row.id}:`, error instanceof Error ? error.message : String(error));
6513
+ routingAffinityInvalid = true;
6514
+ console.warn(`[db] Quarantining malformed agent_tasks.routingAffinity for task ${row.id}:`, error instanceof Error ? error.message : String(error));
6359
6515
  }
6360
6516
  }
6361
6517
  return {
@@ -6429,7 +6585,8 @@ function rowToAgentTask(row) {
6429
6585
  harnessVariant: row.harnessVariant ?? undefined,
6430
6586
  harnessVariantMeta: row.harnessVariantMeta ? JSON.parse(row.harnessVariantMeta) : undefined,
6431
6587
  totalCostUsd: row.totalCostUsd ?? undefined,
6432
- routingAffinity
6588
+ routingAffinity,
6589
+ routingAffinityInvalid: routingAffinityInvalid || undefined
6433
6590
  };
6434
6591
  }
6435
6592
  function rowToAgentTaskSummary(row) {
@@ -6495,28 +6652,34 @@ async function createTask(agentId, task, options) {
6495
6652
  }
6496
6653
  async function getPendingTaskForAgent(agentId) {
6497
6654
  const rows = await getDbClient().query("SELECT * FROM agent_tasks WHERE agentId = ? AND status = 'pending' ORDER BY priority DESC, createdAt ASC", [agentId]);
6655
+ const agent = await getAgentById(agentId);
6656
+ if (!agent)
6657
+ return null;
6498
6658
  for (const row of rows) {
6499
6659
  const task = rowToAgentTask(row);
6660
+ if (!isAgentEligibleForTask(agent, task))
6661
+ continue;
6500
6662
  const { ready } = await checkDependencies(task.id);
6501
- if (ready) {
6663
+ if (ready)
6502
6664
  return task;
6503
- }
6504
6665
  }
6505
6666
  return null;
6506
6667
  }
6507
6668
  async function assignUnassignedTaskPending(taskId, agentId) {
6508
- if (isPoolAffinityEnforcementEnabled()) {
6669
+ {
6509
6670
  const task = await getTaskById(taskId);
6510
6671
  const agent = await getAgentById(agentId);
6511
- if (task && agent && !isAgentEligibleForTask(agent, task)) {
6672
+ if (task && (!agent || !isAgentEligibleForTask(agent, task))) {
6512
6673
  try {
6513
6674
  await createLogEntry({
6514
6675
  eventType: "task_claim_rejected_affinity",
6515
6676
  agentId,
6516
6677
  taskId,
6517
6678
  metadata: {
6518
- agentRole: agent.role ?? null,
6519
- requiredRole: task.routingAffinity?.role ?? null
6679
+ agentRole: agent?.role ?? null,
6680
+ requiredRole: task.routingAffinity?.role ?? null,
6681
+ leadOnly: task.routingAffinity?.leadOnly === true,
6682
+ agentIsLead: agent?.isLead ?? false
6520
6683
  }
6521
6684
  });
6522
6685
  } catch {}
@@ -8556,8 +8719,24 @@ async function createTaskExtended(task, options) {
8556
8719
  if (parent.followUpConfig && !options.followUpConfig) {
8557
8720
  options.followUpConfig = parent.followUpConfig;
8558
8721
  }
8559
- if (parent.routingAffinity && !options.routingAffinity) {
8560
- options.routingAffinity = parent.routingAffinity;
8722
+ if (parent.routingAffinityInvalid) {
8723
+ throw new Error(`Cannot continue task ${parent.id}: routing affinity is invalid.`);
8724
+ }
8725
+ if (parent.routingAffinity) {
8726
+ if (!options.routingAffinity) {
8727
+ options.routingAffinity = parent.routingAffinity;
8728
+ } else if (parent.routingAffinity.leadOnly) {
8729
+ options.routingAffinity = {
8730
+ ...options.routingAffinity,
8731
+ capabilities: [
8732
+ ...new Set([
8733
+ ...parent.routingAffinity.capabilities ?? [],
8734
+ ...options.routingAffinity.capabilities ?? []
8735
+ ])
8736
+ ],
8737
+ leadOnly: true
8738
+ };
8739
+ }
8561
8740
  }
8562
8741
  }
8563
8742
  }
@@ -8600,6 +8779,24 @@ async function createTaskExtended(task, options) {
8600
8779
  }
8601
8780
  }
8602
8781
  }
8782
+ const targetAgentId = options.agentId ?? options.offeredTo;
8783
+ if (options.routingAffinity && targetAgentId) {
8784
+ const target = await getAgentById(targetAgentId);
8785
+ if (!target || !isAgentEligibleForTask(target, { routingAffinity: options.routingAffinity })) {
8786
+ try {
8787
+ await createLogEntry({
8788
+ eventType: "task_authorization_rejected",
8789
+ agentId: options.creatorAgentId,
8790
+ metadata: {
8791
+ leadOnly: options.routingAffinity.leadOnly === true,
8792
+ targetAgentId,
8793
+ decision: "reject_ineligible_assignment"
8794
+ }
8795
+ });
8796
+ } catch {}
8797
+ throw new Error(options.routingAffinity.leadOnly ? `Lead-only task routing affinity does not authorize assignment or offer to agent "${targetAgentId}".` : `Task routing affinity does not authorize assignment or offer to agent "${targetAgentId}".`);
8798
+ }
8799
+ }
8603
8800
  const auditUserId = getCurrentRequestUserId() ?? null;
8604
8801
  const assetKey = normalizeAssetKey(options?.key ?? defaultAssetKey("task", id));
8605
8802
  const claim = await getDbClient().transaction(async () => {
@@ -8682,7 +8879,11 @@ async function createTaskExtended(task, options) {
8682
8879
  agentId: options?.creatorAgentId,
8683
8880
  taskId: id,
8684
8881
  newValue: status,
8685
- metadata: { source: options?.source ?? "mcp" }
8882
+ metadata: {
8883
+ source: options?.source ?? "mcp",
8884
+ leadOnly: options?.routingAffinity?.leadOnly === true,
8885
+ authorization: options?.routingAffinity?.leadOnly ? { decision: "authorized", targetAgentId: options.agentId ?? options.offeredTo ?? null } : undefined
8886
+ }
8686
8887
  });
8687
8888
  } catch {}
8688
8889
  emitTaskLifecycleTelemetryAfterCommit("created", {
@@ -8690,6 +8891,7 @@ async function createTaskExtended(task, options) {
8690
8891
  source: row.source,
8691
8892
  ...taskContextForTelemetry(rowToAgentTask(row)),
8692
8893
  hasParent: !!row.parentTaskId,
8894
+ has_repo: !!row.vcsRepo,
8693
8895
  priority: row.priority
8694
8896
  }, (task2) => task2 !== null);
8695
8897
  getDbClient().afterCommit(() => {
@@ -8708,18 +8910,20 @@ async function createTaskExtended(task, options) {
8708
8910
  return rowToAgentTask(row);
8709
8911
  }
8710
8912
  async function claimTask(taskId, agentId) {
8711
- if (isPoolAffinityEnforcementEnabled()) {
8913
+ {
8712
8914
  const task = await getTaskById(taskId);
8713
8915
  const agent = await getAgentById(agentId);
8714
- if (task && agent && !isAgentEligibleForTask(agent, task)) {
8916
+ if (task && (!agent || !isAgentEligibleForTask(agent, task))) {
8715
8917
  try {
8716
8918
  await createLogEntry({
8717
8919
  eventType: "task_claim_rejected_affinity",
8718
8920
  agentId,
8719
8921
  taskId,
8720
8922
  metadata: {
8721
- agentRole: agent.role ?? null,
8722
- requiredRole: task.routingAffinity?.role ?? null
8923
+ agentRole: agent?.role ?? null,
8924
+ requiredRole: task.routingAffinity?.role ?? null,
8925
+ leadOnly: task.routingAffinity?.leadOnly === true,
8926
+ agentIsLead: agent?.isLead ?? false
8723
8927
  }
8724
8928
  });
8725
8929
  } catch {}
@@ -8772,6 +8976,22 @@ async function acceptTask(taskId, agentId) {
8772
8976
  const task = await getTaskById(taskId);
8773
8977
  if (!task)
8774
8978
  return null;
8979
+ const agent = await getAgentById(agentId);
8980
+ if ((task.routingAffinity?.leadOnly || task.routingAffinityInvalid) && (!agent || !isAgentEligibleForTask(agent, task))) {
8981
+ try {
8982
+ await createLogEntry({
8983
+ eventType: "task_claim_rejected_affinity",
8984
+ agentId,
8985
+ taskId,
8986
+ metadata: {
8987
+ leadOnly: true,
8988
+ agentIsLead: agent?.isLead ?? false,
8989
+ decision: "reject_offer_accept"
8990
+ }
8991
+ });
8992
+ } catch {}
8993
+ return null;
8994
+ }
8775
8995
  if (!(task.status === "offered" || task.status === "reviewing") || task.offeredTo !== agentId)
8776
8996
  return null;
8777
8997
  const now = new Date().toISOString();
@@ -8922,6 +9142,22 @@ async function claimOfferedTask(taskId, agentId) {
8922
9142
  return null;
8923
9143
  if (task.status !== "offered" || task.offeredTo !== agentId)
8924
9144
  return null;
9145
+ const agent = await getAgentById(agentId);
9146
+ if ((task.routingAffinity?.leadOnly || task.routingAffinityInvalid) && (!agent || !isAgentEligibleForTask(agent, task))) {
9147
+ try {
9148
+ await createLogEntry({
9149
+ eventType: "task_claim_rejected_affinity",
9150
+ agentId,
9151
+ taskId,
9152
+ metadata: {
9153
+ leadOnly: true,
9154
+ agentIsLead: agent?.isLead ?? false,
9155
+ decision: "reject_offer_claim"
9156
+ }
9157
+ });
9158
+ } catch {}
9159
+ return null;
9160
+ }
8925
9161
  const now = new Date().toISOString();
8926
9162
  const row = await getDbClient().get(`UPDATE agent_tasks SET status = 'reviewing', lastUpdatedAt = ?
8927
9163
  WHERE id = ? AND status = 'offered' RETURNING *`, [now, taskId]);
@@ -10591,6 +10827,16 @@ async function upsertSwarmConfig(data) {
10591
10827
  }
10592
10828
  return config;
10593
10829
  }
10830
+ async function emitBuiltInIntegrationConnectedOnce(provider) {
10831
+ try {
10832
+ const key = `telemetry.integration.${provider}.emitted`;
10833
+ if ((await getSwarmConfigs({ scope: "global", key })).length > 0)
10834
+ return;
10835
+ if (!emitIntegrationConnected(_resolveIntegrationType(provider), provider, true))
10836
+ return;
10837
+ await upsertSwarmConfig({ scope: "global", key, value: "true" });
10838
+ } catch {}
10839
+ }
10594
10840
  async function deleteSwarmConfig(id) {
10595
10841
  const result = await getDbClient().run("DELETE FROM swarm_config WHERE id = ?", [id]);
10596
10842
  return result.changes > 0;
@@ -11986,6 +12232,7 @@ function rowToApprovalRequest(row) {
11986
12232
  responses: row.responses ? JSON.parse(row.responses) : null,
11987
12233
  resolvedBy: row.resolvedBy,
11988
12234
  resolvedAt: normalizeDate(row.resolvedAt),
12235
+ resolutionReason: row.resolutionReason,
11989
12236
  timeoutSeconds: row.timeoutSeconds,
11990
12237
  expiresAt: normalizeDate(row.expiresAt),
11991
12238
  notificationChannels: row.notificationChannels ? JSON.parse(row.notificationChannels) : null,
@@ -11997,34 +12244,72 @@ function rowToApprovalRequest(row) {
11997
12244
  async function createApprovalRequest(data) {
11998
12245
  const now = new Date().toISOString();
11999
12246
  const expiresAt = data.timeoutSeconds ? new Date(Date.now() + data.timeoutSeconds * 1000).toISOString() : null;
12000
- const row = await getDbClient().get(`INSERT INTO approval_requests (id, title, questions, workflowRunId, workflowRunStepId, sourceTaskId, approvers, timeoutSeconds, expiresAt, notificationChannels, created_by, createdAt, updatedAt)
12001
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
12247
+ const row = await getDbClient().transaction(async () => {
12248
+ let status = "pending";
12249
+ let resolutionReason = null;
12250
+ if (data.requireActionableWorkflow && data.workflowRunId && data.workflowRunStepId) {
12251
+ const run = await getWorkflowRun(data.workflowRunId);
12252
+ const step = await getWorkflowRunStep(data.workflowRunStepId);
12253
+ if (!run || run.status !== "running" && run.status !== "waiting") {
12254
+ status = "cancelled";
12255
+ resolutionReason = run?.error ?? `Workflow run is ${run?.status ?? "missing"}`;
12256
+ } else if (!step || step.runId !== run.id || step.status !== "running") {
12257
+ status = "cancelled";
12258
+ resolutionReason = `Human-in-the-loop step is ${step?.status ?? "missing"}`;
12259
+ }
12260
+ }
12261
+ return getDbClient().get(`INSERT INTO approval_requests
12262
+ (id, title, questions, workflowRunId, workflowRunStepId, sourceTaskId,
12263
+ approvers, status, resolutionReason, resolvedAt, timeoutSeconds, expiresAt,
12264
+ notificationChannels, created_by, createdAt, updatedAt)
12265
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
12002
12266
  RETURNING *`, [
12003
- data.id,
12004
- data.title,
12005
- JSON.stringify(data.questions),
12006
- data.workflowRunId ?? null,
12007
- data.workflowRunStepId ?? null,
12008
- data.sourceTaskId ?? null,
12009
- JSON.stringify(data.approvers),
12010
- data.timeoutSeconds ?? null,
12011
- expiresAt,
12012
- data.notificationChannels ? JSON.stringify(data.notificationChannels) : null,
12013
- data.createdBy ?? null,
12014
- now,
12015
- now
12016
- ]);
12267
+ data.id,
12268
+ data.title,
12269
+ JSON.stringify(data.questions),
12270
+ data.workflowRunId ?? null,
12271
+ data.workflowRunStepId ?? null,
12272
+ data.sourceTaskId ?? null,
12273
+ JSON.stringify(data.approvers),
12274
+ status,
12275
+ resolutionReason,
12276
+ status === "cancelled" ? now : null,
12277
+ data.timeoutSeconds ?? null,
12278
+ expiresAt,
12279
+ data.notificationChannels ? JSON.stringify(data.notificationChannels) : null,
12280
+ data.createdBy ?? null,
12281
+ now,
12282
+ now
12283
+ ]);
12284
+ });
12017
12285
  return rowToApprovalRequest(row);
12018
12286
  }
12019
12287
  async function getApprovalRequestById(id) {
12020
12288
  const row = await getDbClient().get("SELECT * FROM approval_requests WHERE id = ?", [id]);
12021
12289
  return row ? rowToApprovalRequest(row) : null;
12022
12290
  }
12023
- async function resolveApprovalRequest(id, data) {
12291
+ async function resolveApprovalRequest(id, data, options) {
12024
12292
  const now = new Date().toISOString();
12293
+ const actionableWorkflowClause = options?.requireActionableWorkflow ? `AND (
12294
+ workflowRunId IS NULL
12295
+ OR (
12296
+ EXISTS (
12297
+ SELECT 1 FROM workflow_runs
12298
+ WHERE id = approval_requests.workflowRunId
12299
+ AND status IN ('running', 'waiting')
12300
+ )
12301
+ AND EXISTS (
12302
+ SELECT 1 FROM workflow_run_steps
12303
+ WHERE id = approval_requests.workflowRunStepId
12304
+ AND runId = approval_requests.workflowRunId
12305
+ AND status = 'waiting'
12306
+ )
12307
+ )
12308
+ )` : "";
12025
12309
  const row = await getDbClient().get(`UPDATE approval_requests
12026
12310
  SET status = ?, responses = ?, resolvedBy = ?, resolvedAt = ?, updatedAt = ?
12027
12311
  WHERE id = ? AND status = 'pending'
12312
+ ${actionableWorkflowClause}
12028
12313
  RETURNING *`, [
12029
12314
  data.status,
12030
12315
  data.responses ? JSON.stringify(data.responses) : null,
@@ -12035,6 +12320,68 @@ async function resolveApprovalRequest(id, data) {
12035
12320
  ]);
12036
12321
  return row ? rowToApprovalRequest(row) : null;
12037
12322
  }
12323
+ async function cancelPendingApprovalRequestsForRun(workflowRunId, reason) {
12324
+ const now = new Date().toISOString();
12325
+ const rows = await getDbClient().query(`UPDATE approval_requests
12326
+ SET status = 'cancelled', resolutionReason = ?, resolvedAt = ?, updatedAt = ?
12327
+ WHERE workflowRunId = ? AND status = 'pending'
12328
+ RETURNING *`, [reason, now, now, workflowRunId]);
12329
+ return rows.map(rowToApprovalRequest);
12330
+ }
12331
+ async function listCancelledApprovalRequestsForRun(workflowRunId) {
12332
+ const rows = await getDbClient().query(`SELECT * FROM approval_requests
12333
+ WHERE workflowRunId = ? AND status = 'cancelled'`, [workflowRunId]);
12334
+ return rows.map(rowToApprovalRequest);
12335
+ }
12336
+ async function listCancelledApprovalRequestsForStep(workflowRunStepId) {
12337
+ const rows = await getDbClient().query(`SELECT * FROM approval_requests
12338
+ WHERE workflowRunStepId = ? AND status = 'cancelled'`, [workflowRunStepId]);
12339
+ return rows.map(rowToApprovalRequest);
12340
+ }
12341
+ async function claimApprovalCancellationNotification(id, notificationKey) {
12342
+ return getDbClient().transaction(async () => {
12343
+ const row = await getDbClient().get("SELECT * FROM approval_requests WHERE id = ? AND status = 'cancelled'", [id]);
12344
+ if (!row)
12345
+ return null;
12346
+ const claims = row.cancellationNotificationClaims ? JSON.parse(row.cancellationNotificationClaims) : {};
12347
+ const existing = claims[notificationKey];
12348
+ if (existing === "delivered")
12349
+ return null;
12350
+ if (existing && typeof existing !== "string" && Date.now() - new Date(existing.claimedAt).getTime() < 60000) {
12351
+ return null;
12352
+ }
12353
+ const now = new Date().toISOString();
12354
+ const leaseToken = crypto.randomUUID();
12355
+ claims[notificationKey] = { claimedAt: now, leaseToken };
12356
+ await getDbClient().run(`UPDATE approval_requests
12357
+ SET cancellationNotificationClaims = ?, updatedAt = ?
12358
+ WHERE id = ? AND status = 'cancelled'`, [JSON.stringify(claims), now, id]);
12359
+ return { approval: rowToApprovalRequest(row), leaseToken };
12360
+ });
12361
+ }
12362
+ async function completeApprovalCancellationNotificationClaim(id, notificationKey, leaseToken) {
12363
+ await updateApprovalCancellationNotificationClaim(id, notificationKey, leaseToken, "delivered");
12364
+ }
12365
+ async function releaseApprovalCancellationNotificationClaim(id, notificationKey, leaseToken) {
12366
+ await updateApprovalCancellationNotificationClaim(id, notificationKey, leaseToken, null);
12367
+ }
12368
+ async function updateApprovalCancellationNotificationClaim(id, notificationKey, leaseToken, value) {
12369
+ await getDbClient().transaction(async () => {
12370
+ const row = await getDbClient().get("SELECT cancellationNotificationClaims AS claims FROM approval_requests WHERE id = ?", [id]);
12371
+ const claims = row?.claims ? JSON.parse(row.claims) : {};
12372
+ const current = claims[notificationKey];
12373
+ if (!current || typeof current === "string" || current.leaseToken !== leaseToken) {
12374
+ return;
12375
+ }
12376
+ if (value === null)
12377
+ delete claims[notificationKey];
12378
+ else
12379
+ claims[notificationKey] = value;
12380
+ await getDbClient().run(`UPDATE approval_requests
12381
+ SET cancellationNotificationClaims = ?, updatedAt = ?
12382
+ WHERE id = ? AND status = 'cancelled'`, [JSON.stringify(claims), new Date().toISOString(), id]);
12383
+ });
12384
+ }
12038
12385
  async function updateApprovalRequestNotifications(id, notificationChannels) {
12039
12386
  const now = new Date().toISOString();
12040
12387
  await getDbClient().run("UPDATE approval_requests SET notificationChannels = ?, updatedAt = ? WHERE id = ?", [JSON.stringify(notificationChannels), now, id]);
@@ -12723,6 +13070,12 @@ async function createMcpServer(data) {
12723
13070
  throw new Error("Failed to create MCP server");
12724
13071
  return rowToMcpServer(row);
12725
13072
  }
13073
+ async function emitMcpServerConnectedTelemetry() {
13074
+ try {
13075
+ const row = await getDbClient().get("SELECT COUNT(*) as count FROM mcp_servers");
13076
+ emitIntegrationConnected("other", undefined, row?.count === 1);
13077
+ } catch {}
13078
+ }
12726
13079
  async function updateMcpServer(id, updates) {
12727
13080
  const existing = await getMcpServerById(id);
12728
13081
  if (!existing)
@@ -14313,4 +14666,4 @@ var init_db = __esm(() => {
14313
14666
  };
14314
14667
  });
14315
14668
 
14316
- 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, beginRequestAuthScope, setRequestAuth, getRequestAuth, getCurrentRequestAuth, runWithoutRequestAuth, 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, MAX_DB_RETENTION_DAYS, validateConfigValue, init_swarm_config_guard, onTaskStarted, init_task_lifecycle_events, isSqliteVecAvailable, resolveSqliteVecExtensionPath, __resetSqliteVecExtensionPathCacheForTests, initDb, getDb, closeDb, getDbClient, computeContentHash, createContextVersion, getLatestContextVersion, getContextVersion, getContextVersionHistory, 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, 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, createLogEntry, getLogsByAgentId, getLogsByTaskId, getLogsByTaskIdChronological, getLogsByEventType, getAllLogs, findRecentSimilarTasks, createTaskExtended, claimTask, releaseTask, acceptTask, rejectTask, moveTaskToBacklog, moveTaskFromBacklog, promoteDraftTask, promoteAbandonedDraftTasks, 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, 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, claimKv, deleteKv, KvTypeCollisionError, incrKv, listKv, countKv, createScriptRun, recordInlineScriptRun, getScriptRun, getScriptRunByIdempotencyKey, listScriptRuns, countScriptRuns, countActiveScriptRuns, updateScriptRun, updateScriptRunIfNotTerminal, updateScriptRunIfRunning, getRunningScriptRuns, getScriptRunJournalStep, upsertScriptRunJournalStep, listScriptRunJournalSteps, countScriptRunJournalSteps, countScriptRunJournalAgentTaskSteps, exports_db, init_db };
14669
+ export { normalizeAssetKey, defaultAssetKey, parseAssetKey, canWriteAssetKey, init_key, slackContextKey, agentmailContextKey, githubContextKey, gitlabContextKey, linearContextKey, buildJiraContextKey, scheduleContextKey, workflowContextKey, agentContextKey, pageContextKey, init_context_key, checkSlackRoutingCoherence, init_slack_routing, _resolveIntegrationType, _resolveIntegrationProvider, initTelemetry, telemetry, emitIntegrationConnected, 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, beginRequestAuthScope, setRequestAuth, getRequestAuth, getCurrentRequestAuth, runWithoutRequestAuth, 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, MAX_DB_RETENTION_DAYS, DB_RETENTION_TUNING_BOUNDS, validateConfigValue, init_swarm_config_guard, onTaskStarted, init_task_lifecycle_events, isSqliteVecAvailable, resolveSqliteVecExtensionPath, __resetSqliteVecExtensionPathCacheForTests, initDb, getDb, closeDb, getDbClient, computeContentHash, createContextVersion, getLatestContextVersion, getContextVersion, getContextVersionHistory, 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, 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, createLogEntry, getLogsByAgentId, getLogsByTaskId, getLogsByTaskIdChronological, getLogsByEventType, getAllLogs, findRecentSimilarTasks, createTaskExtended, claimTask, releaseTask, acceptTask, rejectTask, moveTaskToBacklog, moveTaskFromBacklog, promoteDraftTask, promoteAbandonedDraftTasks, 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, 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, emitBuiltInIntegrationConnectedOnce, 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, cancelPendingApprovalRequestsForRun, listCancelledApprovalRequestsForRun, listCancelledApprovalRequestsForStep, claimApprovalCancellationNotification, completeApprovalCancellationNotificationClaim, releaseApprovalCancellationNotificationClaim, 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, emitMcpServerConnectedTelemetry, 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, claimKv, deleteKv, KvTypeCollisionError, incrKv, listKv, countKv, createScriptRun, recordInlineScriptRun, getScriptRun, getScriptRunByIdempotencyKey, listScriptRuns, countScriptRuns, countActiveScriptRuns, updateScriptRun, updateScriptRunIfNotTerminal, updateScriptRunIfRunning, getRunningScriptRuns, getScriptRunJournalStep, upsertScriptRunJournalStep, listScriptRunJournalSteps, countScriptRunJournalSteps, countScriptRunJournalAgentTaskSteps, exports_db, init_db };