@desplega.ai/agent-swarm 1.147.0 → 1.149.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 (185) hide show
  1. package/README.md +13 -1
  2. package/dist/{acp-adapter-9n319wqc.js → acp-adapter-4jncb126.js} +12 -5
  3. package/dist/{actions-2vxqvpr9.js → actions-31vp3ae7.js} +10 -9
  4. package/dist/{app-w066xfy0.js → app-1hh67x8w.js} +6 -6
  5. package/dist/{assistant-kt31dj2h.js → assistant-z66dmz6p.js} +13 -11
  6. package/dist/{boot-reembed-az5rassp.js → boot-reembed-fqzxxzjh.js} +7 -7
  7. package/dist/{boot-reembed-j3mm3rfz.js → boot-reembed-wxa8ya0s.js} +8 -8
  8. package/dist/{boot-scrub-logs-b6h54817.js → boot-scrub-logs-jnyndh79.js} +5 -5
  9. package/dist/{claude-adapter-w1z04ann.js → claude-adapter-3qpa9w0j.js} +9 -9
  10. package/dist/{claude-managed-adapter-sactwn31.js → claude-managed-adapter-qvsmh6mv.js} +2 -2
  11. package/dist/{claude-sdk-session-f0cc1kec.js → claude-sdk-session-2yxgjs5d.js} +9 -9
  12. package/dist/{cli-y6b6fb76.js → cli-08b07b4r.js} +1 -1
  13. package/dist/{cli-8fc8de14.js → cli-0z2v4nhw.js} +1 -1
  14. package/dist/{cli-de14znh8.js → cli-19f354qr.js} +2 -2
  15. package/dist/{cli-hbv0kq6w.js → cli-2qts1hys.js} +3 -3
  16. package/dist/{cli-kpv03zhj.js → cli-3apbzgyk.js} +27 -15
  17. package/dist/{cli-1th1728g.js → cli-3q5ejx9p.js} +2 -2
  18. package/dist/{cli-d8brzxjb.js → cli-4wtq5jjv.js} +2 -2
  19. package/dist/{cli-ct0et58h.js → cli-5my3bjsd.js} +1 -1
  20. package/dist/{cli-cn6mmc7f.js → cli-6664w7y4.js} +1 -1
  21. package/dist/{cli-yz3djrm0.js → cli-6pqcb4q0.js} +53 -13
  22. package/dist/{cli-719k9j2c.js → cli-7smrsr25.js} +3 -3
  23. package/dist/{cli-rw51bq3j.js → cli-9fy6nk6g.js} +1 -1
  24. package/dist/{cli-zhjmqxzh.js → cli-9hspd3dp.js} +2 -2
  25. package/dist/{cli-3tgwnf43.js → cli-aae6hz6a.js} +4 -4
  26. package/dist/{cli-89xfd7f9.js → cli-cr12paw2.js} +5 -5
  27. package/dist/{cli-b5bq9crk.js → cli-d8ftsp62.js} +8 -8
  28. package/dist/{cli-4nr988h6.js → cli-e95cx1eb.js} +3 -3
  29. package/dist/{cli-n8508nre.js → cli-gjhjfeeg.js} +1 -1
  30. package/dist/{cli-p1d5b073.js → cli-gv88e1vf.js} +1 -1
  31. package/dist/{cli-rvqz34y5.js → cli-jecc01cb.js} +1 -1
  32. package/dist/{cli-8v0g1yc8.js → cli-k0cr4kat.js} +1 -1
  33. package/dist/{cli-mmemxxdc.js → cli-kgz4np97.js} +4 -4
  34. package/dist/{cli-w9kb3bk1.js → cli-kjwt6hdf.js} +3 -1
  35. package/dist/{cli-f7dsy61y.js → cli-mnmsfd1w.js} +6 -2
  36. package/dist/{cli-54wwve05.js → cli-n3dz2942.js} +37 -26
  37. package/dist/{cli-12fz972k.js → cli-nye12xk5.js} +8 -5
  38. package/dist/{cli-tzvk9haz.js → cli-phsxnkp6.js} +20 -20
  39. package/dist/{cli-53s590z8.js → cli-q50ef8g0.js} +1 -1
  40. package/dist/{cli-f146mn5s.js → cli-qaacms9y.js} +7 -6
  41. package/dist/{cli-xqcq9y5e.js → cli-r2ap2czm.js} +1 -0
  42. package/dist/{cli-m8yrsg97.js → cli-sd5pv3b1.js} +3 -3
  43. package/dist/{cli-0b6y7kxm.js → cli-xm87hzbw.js} +1 -1
  44. package/dist/{cli-ftht3zzj.js → cli-yab68w40.js} +285 -11
  45. package/dist/{cli-atcve9y8.js → cli-yb9qhqam.js} +227 -59
  46. package/dist/{cli-smby5m17.js → cli-ygweqcn4.js} +133 -22
  47. package/dist/{cli-dttph1bw.js → cli-ykxrnd1q.js} +2 -2
  48. package/dist/{cli-m9sxbkhm.js → cli-zvz62chv.js} +3 -3
  49. package/dist/cli.js +16 -14
  50. package/dist/{codex-adapter-zw4dwsx7.js → codex-adapter-8meawydj.js} +4 -4
  51. package/dist/{codex-hook-bw8p5nh4.js → codex-hook-hfrt9shr.js} +2 -2
  52. package/dist/{codex-session-runner-k981s65v.js → codex-session-runner-gjgxyp5j.js} +4 -4
  53. package/dist/{commands-sykrxx7e.js → commands-hz3nb95f.js} +5 -5
  54. package/dist/{db-sfbsc8wt.js → db-ggz97zbm.js} +5 -5
  55. package/dist/{e2b-6hb103d8.js → e2b-p04vmtx0.js} +1 -1
  56. package/dist/{handlers-0aspcejm.js → handlers-nbzdzn9k.js} +14 -11
  57. package/dist/{hook-hxccs7m5.js → hook-bks2q1f6.js} +7 -7
  58. package/dist/{hook-4nvqj2sb.js → hook-kq9wp0ep.js} +8 -8
  59. package/dist/{http-y06z517d.js → http-hrf77v87.js} +96 -45
  60. package/dist/{index-tce1rss4.js → index-6nsbg88z.js} +443 -144
  61. package/dist/{index-x5j894zf.js → index-8hmeg8j1.js} +14 -14
  62. package/dist/{index-k8znfx0z.js → index-cqtebbhb.js} +13 -13
  63. package/dist/{index-hssww7kj.js → index-n28pw1zt.js} +15 -15
  64. package/dist/{keepalive-w733ax66.js → keepalive-dxc12gvg.js} +7 -7
  65. package/dist/{lead-75bjqa9d.js → lead-yckfn18d.js} +32 -32
  66. package/dist/{maintenance-w4f1zjck.js → maintenance-6kfb2m5e.js} +8 -8
  67. package/dist/{oauth-refresh-sweep-wdetky26.js → oauth-refresh-sweep-1x1ac722.js} +6 -6
  68. package/dist/{onboard-bb5net8s.js → onboard-dcyt1609.js} +4 -3
  69. package/dist/{opencode-adapter-fef1mrn2.js → opencode-adapter-dce4wskd.js} +2 -2
  70. package/dist/{otel-impl-0w7c14ap.js → otel-impl-tbk3e5dr.js} +2 -2
  71. package/dist/{pi-mono-adapter-2has4gnp.js → pi-mono-adapter-zvshk5cj.js} +2 -2
  72. package/dist/{pricing-refresh-9nzsrgcq.js → pricing-refresh-kaqg567e.js} +7 -7
  73. package/dist/{rbac-roles-z1jrffbt.js → rbac-roles-ammq6rd2.js} +5 -5
  74. package/dist/{rbac-roles-r3hqjp09.js → rbac-roles-cf97v1vd.js} +6 -6
  75. package/dist/{render-v2-vbr89fnb.js → render-v2-80w603vy.js} +6 -6
  76. package/dist/{seed-pricing-g62hy1pk.js → seed-pricing-zbrn83xv.js} +6 -6
  77. package/dist/{setup-gnfqnptp.js → setup-fe66kczs.js} +2 -2
  78. package/dist/{worker-kznxp4qm.js → worker-qmb2d1e2.js} +32 -32
  79. package/dist/{x-n2phr5vm.js → x-n3e0v3xa.js} +2 -2
  80. package/openapi.json +46 -4
  81. package/package.json +3 -1
  82. package/src/agentmail/handlers.ts +5 -0
  83. package/src/automation-preflight-alert.ts +41 -0
  84. package/src/be/automation-preflight.ts +3 -3
  85. package/src/be/budget-refusal-notify.ts +1 -0
  86. package/src/be/db/tasks/read.ts +5 -0
  87. package/src/be/db.ts +132 -2
  88. package/src/be/migrations/150_deferred_task_waits.sql +18 -0
  89. package/src/be/migrations/151_repair_scheduled_task_required_params.sql +39 -0
  90. package/src/be/migrations/152_routing_decisions.sql +44 -0
  91. package/src/be/scripts/typecheck.ts +33 -22
  92. package/src/be/seed-scripts/catalog/delegate.ts +5 -1
  93. package/src/be/seed-skills/bundled-files.generated.json +10 -0
  94. package/src/be/seed-skills/index.ts +3 -0
  95. package/src/be/steering.ts +1 -0
  96. package/src/be/swarm-config-guard.ts +11 -0
  97. package/src/commands/onboard/steps/post-task.tsx +1 -0
  98. package/src/github/handlers.ts +9 -0
  99. package/src/gitlab/handlers.ts +4 -0
  100. package/src/heartbeat/heartbeat.ts +8 -0
  101. package/src/http/approval-requests.ts +1 -0
  102. package/src/http/apps.ts +1 -0
  103. package/src/http/config.ts +15 -6
  104. package/src/http/mcp.ts +31 -4
  105. package/src/http/script-runs.ts +6 -0
  106. package/src/http/tasks.ts +52 -30
  107. package/src/integrations/kapso/inbound.ts +1 -0
  108. package/src/jira/sync.ts +2 -0
  109. package/src/linear/sync.ts +2 -0
  110. package/src/prompts/session-templates.ts +29 -15
  111. package/src/scheduler/deferred-task-waits.ts +123 -0
  112. package/src/scheduler/schedule-task.ts +42 -0
  113. package/src/scheduler/scheduler.ts +22 -31
  114. package/src/script-workflows/workflow-ctx.ts +2 -0
  115. package/src/scripts-runtime/types/stdlib.d.ts +38 -24
  116. package/src/scripts-runtime/types/swarm-sdk.d.ts +38 -24
  117. package/src/server.ts +10 -1
  118. package/src/slack/actions.ts +1 -0
  119. package/src/slack/assistant.ts +2 -0
  120. package/src/slack/handlers.ts +3 -0
  121. package/src/slack/thread-buffer.ts +2 -0
  122. package/src/tasks/worker-follow-up.ts +9 -0
  123. package/src/tests/acp-adapter.test.ts +35 -6
  124. package/src/tests/acp-session-token.test.ts +67 -0
  125. package/src/tests/asset-key-api.test.ts +15 -2
  126. package/src/tests/asset-key-mcp.test.ts +2 -0
  127. package/src/tests/automation-preflight-alert.test.ts +91 -0
  128. package/src/tests/claude-worker-parity.test.ts +3 -0
  129. package/src/tests/config-session-auth.test.ts +143 -0
  130. package/src/tests/defer-task.test.ts +117 -6
  131. package/src/tests/deferred-task-wake.test.ts +456 -0
  132. package/src/tests/heartbeat-reroute-decision.test.ts +1 -0
  133. package/src/tests/http-api-integration.test.ts +33 -4
  134. package/src/tests/mcp-input-ergonomics.test.ts +386 -0
  135. package/src/tests/model-control.test.ts +18 -5
  136. package/src/tests/opencode-adapter.test.ts +2 -2
  137. package/src/tests/promote-draft-task-route.test.ts +4 -0
  138. package/src/tests/prompt-template-session.test.ts +13 -4
  139. package/src/tests/rbac-wire-e2e.test.ts +2 -2
  140. package/src/tests/routing-decision-persistence.test.ts +520 -0
  141. package/src/tests/routing-reason-contract.test.ts +89 -0
  142. package/src/tests/routing-reason-inventory.test.ts +55 -0
  143. package/src/tests/schedule-target-type.test.ts +48 -1
  144. package/src/tests/scheduled-task-required-params-migration.test.ts +182 -0
  145. package/src/tests/scheduled-tasks.test.ts +9 -5
  146. package/src/tests/script-connections.test.ts +4 -0
  147. package/src/tests/script-runs-http.test.ts +31 -0
  148. package/src/tests/scripts-typecheck.test.ts +11 -0
  149. package/src/tests/secret-scrubber.test.ts +12 -0
  150. package/src/tests/send-task-output-schema.test.ts +66 -1
  151. package/src/tests/send-task-requested-by.test.ts +1 -0
  152. package/src/tests/send-task-slack-routing-guard.test.ts +2 -0
  153. package/src/tests/store-progress-blocked-waiting-gate.test.ts +151 -0
  154. package/src/tests/swarm-tool-result-gate.test.ts +24 -0
  155. package/src/tests/task-tool-manifest.test.ts +47 -0
  156. package/src/tests/task-tool-preload-mcp.test.ts +125 -0
  157. package/src/tests/task-tools-ctx.test.ts +2 -0
  158. package/src/tests/tool-output-agent-id.test.ts +1 -0
  159. package/src/tests/ui-followup-lead-delegation.test.ts +6 -1
  160. package/src/tests/workflow-agent-task.test.ts +24 -1
  161. package/src/tests/workflow-engine-v2.test.ts +58 -2
  162. package/src/tools/accept-steer.ts +0 -1
  163. package/src/tools/defer-task.ts +73 -21
  164. package/src/tools/memory-get.ts +10 -3
  165. package/src/tools/memory-rate.ts +19 -7
  166. package/src/tools/memory-search.ts +2 -1
  167. package/src/tools/memory-store.ts +25 -5
  168. package/src/tools/send-task.ts +40 -2
  169. package/src/tools/skills/skill-publish.ts +1 -0
  170. package/src/tools/store-progress.ts +78 -4
  171. package/src/tools/templates.ts +2 -1
  172. package/src/tools/utils.ts +33 -2
  173. package/src/types.ts +14 -1
  174. package/src/utils/acp-session-token.ts +14 -4
  175. package/src/utils/secret-scrubber.ts +2 -0
  176. package/src/utils/task-tool-manifest.ts +33 -0
  177. package/src/workflows/engine.ts +4 -1
  178. package/src/workflows/executors/agent-task.ts +7 -1
  179. package/templates/ai-toolbox.manifest.json +6 -1
  180. package/templates/skills/comms/config.json +18 -0
  181. package/templates/skills/comms/content.md +74 -0
  182. package/templates/skills/comms/files/references/ste-rules.md +73 -0
  183. package/templates/skills/comms/files/references/visual-shapes.md +112 -0
  184. package/templates/skills/swarm-scripts/SKILL.md +3 -2
  185. package/templates/skills/swarm-scripts/content.md +3 -2
@@ -10,7 +10,7 @@ import {
10
10
  init_templates,
11
11
  matchesDefaultClaudeMd,
12
12
  matchesDefaultIdentityMd
13
- } from "./cli-y6b6fb76.js";
13
+ } from "./cli-08b07b4r.js";
14
14
  import {
15
15
  configureDbResolver,
16
16
  getAllTemplateDefinitions,
@@ -20,7 +20,7 @@ import {
20
20
  init_steering_enabled,
21
21
  isSteeringEnabled,
22
22
  registerTemplate
23
- } from "./cli-kpv03zhj.js";
23
+ } from "./cli-3apbzgyk.js";
24
24
  import {
25
25
  MAX_PROFILE_FILE_LENGTH,
26
26
  init_constants
@@ -41,6 +41,7 @@ import {
41
41
  _enum,
42
42
  array,
43
43
  boolean,
44
+ exports_external,
44
45
  object,
45
46
  string,
46
47
  union
@@ -48,12 +49,12 @@ import {
48
49
  import {
49
50
  init_package,
50
51
  package_default
51
- } from "./cli-w9kb3bk1.js";
52
+ } from "./cli-kjwt6hdf.js";
52
53
  import {
53
54
  init_secret_scrubber,
54
55
  registerVolatileSecret,
55
56
  scrubSecrets
56
- } from "./cli-xqcq9y5e.js";
57
+ } from "./cli-r2ap2czm.js";
57
58
  import {
58
59
  init_bus,
59
60
  realtimeBus
@@ -2186,7 +2187,7 @@ function resolveTaskModelSelection(opts) {
2186
2187
  function isTerminalTaskStatus(status) {
2187
2188
  return TERMINAL_TASK_STATUSES.includes(status);
2188
2189
  }
2189
- 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, AcpSessionConfigSelectValueSchema, AcpSessionConfigSelectGroupSchema, AcpSessionConfigOptionSchema, AgentAcpStatusSchema, AgentCredStatusSchema, AgentWithTasksSchema, ChangeSourceSchema, VersionableFieldSchema, ContextVersionSchema, ChannelTypeSchema, ChannelSchema, ChannelMessageSchema, ServiceStatusSchema, ServiceSchema, AgentLogEventTypeSchema, ResumeReasonSchema, AgentLogSchema, SessionLogSchema, SessionCostSourceSchema, SessionCostModelBreakdownSchema, SessionCostSchema, EventCategorySchema, EventStatusSchema, EventSourceSchema, EventNameSchema, SwarmEventSchema, AutomationIntegrationIdSchema, ScheduledTaskTargetTypeSchema, ScheduledTaskSchema, SwarmConfigScopeSchema, SwarmConfigSchema, RepoGuidelinesSchema, REPO_GUIDELINES_MAX_ENTRIES = 50, RepoGuidelinesInputSchema, 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;
2190
+ 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, RoutingReasonSchema, 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, AcpSessionConfigSelectValueSchema, AcpSessionConfigSelectGroupSchema, AcpSessionConfigOptionSchema, AgentAcpStatusSchema, AgentCredStatusSchema, AgentWithTasksSchema, ChangeSourceSchema, VersionableFieldSchema, ContextVersionSchema, ChannelTypeSchema, ChannelSchema, ChannelMessageSchema, ServiceStatusSchema, ServiceSchema, AgentLogEventTypeSchema, ResumeReasonSchema, AgentLogSchema, SessionLogSchema, SessionCostSourceSchema, SessionCostModelBreakdownSchema, SessionCostSchema, EventCategorySchema, EventStatusSchema, EventSourceSchema, EventNameSchema, SwarmEventSchema, AutomationIntegrationIdSchema, ScheduledTaskTargetTypeSchema, ScheduledTaskSchema, SwarmConfigScopeSchema, SwarmConfigSchema, RepoGuidelinesSchema, REPO_GUIDELINES_MAX_ENTRIES = 50, RepoGuidelinesInputSchema, 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;
2190
2191
  var init_types = __esm(() => {
2191
2192
  init_key();
2192
2193
  init_constants();
@@ -2342,6 +2343,13 @@ var init_types = __esm(() => {
2342
2343
  "linear",
2343
2344
  "jira"
2344
2345
  ]);
2346
+ RoutingReasonSchema = exports_zod.enum([
2347
+ "skill",
2348
+ "continuity",
2349
+ "overflow",
2350
+ "human_pinned",
2351
+ "reroute_fault"
2352
+ ]);
2345
2353
  ProviderNameSchema = exports_zod.enum([
2346
2354
  "claude",
2347
2355
  "codex",
@@ -2416,6 +2424,8 @@ var init_types = __esm(() => {
2416
2424
  title: exports_zod.string().optional(),
2417
2425
  status: AgentTaskStatusSchema,
2418
2426
  source: AgentTaskSourceSchema.default("mcp"),
2427
+ routingReason: RoutingReasonSchema.optional(),
2428
+ routingNote: exports_zod.string().max(200).optional(),
2419
2429
  taskType: exports_zod.string().max(50).optional(),
2420
2430
  tags: exports_zod.array(exports_zod.string()).default([]),
2421
2431
  priority: exports_zod.number().int().min(0).max(100).default(50),
@@ -2486,6 +2496,8 @@ var init_types = __esm(() => {
2486
2496
  agentId: exports_zod.string().nullable().optional(),
2487
2497
  creatorAgentId: exports_zod.string().optional(),
2488
2498
  source: AgentTaskSourceSchema.optional(),
2499
+ routingReason: RoutingReasonSchema.optional(),
2500
+ routingNote: exports_zod.string().max(200).optional(),
2489
2501
  taskType: exports_zod.string().max(50).optional(),
2490
2502
  tags: exports_zod.array(exports_zod.string()).optional(),
2491
2503
  priority: exports_zod.number().int().min(0).max(100).optional(),
@@ -3182,7 +3194,7 @@ var init_types = __esm(() => {
3182
3194
  id: exports_zod.string().describe("Unique node identifier, used in 'next' and 'inputs' mappings"),
3183
3195
  type: exports_zod.string().describe("Executor type: 'agent-task', 'script', 'swarm-script', 'raw-llm', 'validate', 'property-match'"),
3184
3196
  label: exports_zod.string().optional().describe("Human-readable label for UI display"),
3185
- config: exports_zod.record(exports_zod.string(), exports_zod.unknown()).describe("Executor-specific config. For agent-task: { template, outputSchema?, agentId?, tags?, priority?, dir?, vcsRepo?, model? }. " + "For script: { runtime, script, args?, timeout? }. " + "For swarm-script: { scriptName, scope?, pinHash?, args?, fsMode?, timeoutMs? (1000-300000) }. " + "Agent-task templates and ordinary config values support {{interpolation}} from the node's inputs context, including trigger and declared upstream aliases. " + "SECURITY: executable source for script/swarm-script nodes does not interpolate trigger.* or upstream node outputs; only input/workflow/swarm/run values are allowed in inline script source, and named swarm-script source is not workflow-interpolated. " + "Pass dynamic values through config.args instead (inline script receives them as argv; swarm-script receives its args object). " + "NOTE: config.outputSchema on agent-task nodes validates the AGENT's raw JSON output, " + "while node-level outputSchema validates the EXECUTOR's return value ({taskId, taskOutput})."),
3197
+ config: exports_zod.record(exports_zod.string(), exports_zod.unknown()).describe("Executor-specific config. For agent-task: { template, outputSchema?, agentId?, routingReason?, routingNote?, tags?, priority?, dir?, vcsRepo?, model? }; configured agentId defaults routingReason to human_pinned. " + "For script: { runtime, script, args?, timeout? }. " + "For swarm-script: { scriptName, scope?, pinHash?, args?, fsMode?, timeoutMs? (1000-300000) }. " + "Agent-task templates and ordinary config values support {{interpolation}} from the node's inputs context, including trigger and declared upstream aliases. " + "SECURITY: executable source for script/swarm-script nodes does not interpolate trigger.* or upstream node outputs; only input/workflow/swarm/run values are allowed in inline script source, and named swarm-script source is not workflow-interpolated. " + "Pass dynamic values through config.args instead (inline script receives them as argv; swarm-script receives its args object). " + "NOTE: config.outputSchema on agent-task nodes validates the AGENT's raw JSON output, " + "while node-level outputSchema validates the EXECUTOR's return value ({taskId, taskOutput})."),
3186
3198
  next: exports_zod.union([exports_zod.string(), exports_zod.array(exports_zod.string()), exports_zod.record(exports_zod.string(), exports_zod.string())]).optional().describe("Next node(s): string for simple chaining, string[] for fan-out to parallel nodes, or record for port-based routing ({pass: 'a', fail: 'b'})"),
3187
3199
  validation: StepValidationConfigSchema.optional(),
3188
3200
  retry: RetryPolicySchema.optional(),
@@ -5184,6 +5196,7 @@ Use the crashed agent's identity above as context for who was on it and what kin
5184
5196
 
5185
5197
  Dispatch via \`send-task\` with ALL of:
5186
5198
  - an explicit \`agentId\` (the chosen worker) — REQUIRED. If you omit it, \`send-task\` auto-routes to the original task's agent, which is the dead worker, and the work re-strands.
5199
+ - \`routingReason: "reroute_fault"\`
5187
5200
  - \`taskType: "resume"\`
5188
5201
  - the tag \`resume-generation:{{generation_next}}\`
5189
5202
  - \`parentTaskId: {{original_task_id}}\`
@@ -5225,7 +5238,7 @@ Required capabilities: {{required_capabilities}}{{artifacts_block}}
5225
5238
 
5226
5239
  This task has been sitting unassigned because no currently-registered agent matches its required role/capabilities. Pick an agent to take this work over and RE-DELEGATE it — do NOT execute it yourself.
5227
5240
 
5228
- Dispatch via \`send-task\` with an explicit \`agentId\` (REQUIRED — omitting it re-pools the work under the same affinity tag and it will starve again) and \`parentTaskId: {{original_task_id}}\`.
5241
+ Dispatch via \`send-task\` with an explicit \`agentId\` (REQUIRED — omitting it re-pools the work under the same affinity tag and it will starve again), \`routingReason: "overflow"\`, and \`parentTaskId: {{original_task_id}}\`.
5229
5242
 
5230
5243
  This work will NOT fall back to the unassigned pool — you are the only re-delegation path.`,
5231
5244
  variables: [
@@ -5896,6 +5909,8 @@ function rowToAgentTask(row) {
5896
5909
  title: row.title ?? undefined,
5897
5910
  status: row.status,
5898
5911
  source: row.source,
5912
+ routingReason: row.routing_reason ?? undefined,
5913
+ routingNote: row.routing_note ?? undefined,
5899
5914
  taskType: row.taskType ?? undefined,
5900
5915
  tags: row.tags ? JSON.parse(row.tags) : [],
5901
5916
  priority: row.priority ?? 50,
@@ -7130,6 +7145,7 @@ async function getTaskSteeringFields(task) {
7130
7145
  async function promoteSteeringToTask(task, message) {
7131
7146
  return await createTaskExtended(message.body, {
7132
7147
  agentId: task.agentId,
7148
+ routingReason: task.agentId ? "continuity" : undefined,
7133
7149
  creatorAgentId: message.createdByAgentId,
7134
7150
  source: message.source === "script" ? "api" : message.source,
7135
7151
  taskType: "follow-up",
@@ -7288,6 +7304,177 @@ var init_reaction_shortcode = __esm(() => {
7288
7304
  SLACK_REACTION_SHORTCODE_PATTERN = /^[a-z0-9_+'-]+(::skin-tone-[2-6])?$/;
7289
7305
  });
7290
7306
 
7307
+ // src/tools/tool-config.ts
7308
+ var CORE_TOOLS, DEFERRED_TOOLS, ALL_TOOLS;
7309
+ var init_tool_config = __esm(() => {
7310
+ CORE_TOOLS = new Set([
7311
+ "join-swarm",
7312
+ "my-agent-info",
7313
+ "poll-task",
7314
+ "get-task-details",
7315
+ "store-progress",
7316
+ "task-action",
7317
+ "send-task",
7318
+ "get-tasks",
7319
+ "defer-task",
7320
+ "memory-search",
7321
+ "memory-get",
7322
+ "memory-store",
7323
+ "memory-delete",
7324
+ "memory_rate",
7325
+ "get-swarm",
7326
+ "script-run",
7327
+ "db-query",
7328
+ "kv-get",
7329
+ "script-query-types",
7330
+ "get-repos",
7331
+ "accept-steer",
7332
+ "memory-edit",
7333
+ "script-search",
7334
+ "steer-task",
7335
+ "kv-list",
7336
+ "get-config"
7337
+ ]);
7338
+ DEFERRED_TOOLS = new Set([
7339
+ "list-schedules",
7340
+ "create-schedule",
7341
+ "update-schedule",
7342
+ "patch-schedule",
7343
+ "delete-schedule",
7344
+ "run-schedule-now",
7345
+ "create-workflow",
7346
+ "list-workflows",
7347
+ "get-workflow",
7348
+ "update-workflow",
7349
+ "patch-workflow",
7350
+ "patch-workflow-node",
7351
+ "delete-workflow",
7352
+ "trigger-workflow",
7353
+ "list-workflow-runs",
7354
+ "get-workflow-run",
7355
+ "retry-workflow-run",
7356
+ "cancel-workflow-run",
7357
+ "register-service",
7358
+ "unregister-service",
7359
+ "list-services",
7360
+ "update-service-status",
7361
+ "set-config",
7362
+ "list-config",
7363
+ "delete-config",
7364
+ "credential-bindings",
7365
+ "script-connections",
7366
+ "update-repo",
7367
+ "update-profile",
7368
+ "context-history",
7369
+ "context-diff",
7370
+ "read-messages",
7371
+ "post-message",
7372
+ "slack-reply",
7373
+ "slack-read",
7374
+ "slack-upload-file",
7375
+ "slack-download-file",
7376
+ "slack-list-channels",
7377
+ "slack-post",
7378
+ "slack-start-thread",
7379
+ "slack-create-channel",
7380
+ "slack-invite-to-channel",
7381
+ "slack-archive-channel",
7382
+ "slack-delete",
7383
+ "slack-update",
7384
+ "create-channel",
7385
+ "delete-channel",
7386
+ "list-channels",
7387
+ "register-agentmail-inbox",
7388
+ "register-kapso-number",
7389
+ "unregister-kapso-number",
7390
+ "send-whatsapp-message",
7391
+ "reply-whatsapp-message",
7392
+ "tracker-status",
7393
+ "get-oauth-access-token",
7394
+ "tracker-link-task",
7395
+ "tracker-unlink",
7396
+ "tracker-sync-status",
7397
+ "tracker-map-agent",
7398
+ "list-prompt-templates",
7399
+ "get-prompt-template",
7400
+ "set-prompt-template",
7401
+ "delete-prompt-template",
7402
+ "preview-prompt-template",
7403
+ "create_metric",
7404
+ "request-human-input",
7405
+ "skill-create",
7406
+ "skill-update",
7407
+ "skill-delete",
7408
+ "skill-get",
7409
+ "skill-get-file",
7410
+ "skill-list",
7411
+ "skill-search",
7412
+ "skill-install",
7413
+ "skill-uninstall",
7414
+ "skill-install-remote",
7415
+ "skill-sync-remote",
7416
+ "skill-publish",
7417
+ "mcp-server-create",
7418
+ "mcp-server-delete",
7419
+ "mcp-server-get",
7420
+ "mcp-server-install",
7421
+ "mcp-server-list",
7422
+ "mcp-server-uninstall",
7423
+ "mcp-server-update",
7424
+ "resolve-user",
7425
+ "manage-user",
7426
+ "app-get",
7427
+ "app-list",
7428
+ "app-patch",
7429
+ "app-query",
7430
+ "app-sync",
7431
+ "app-upsert",
7432
+ "app-history",
7433
+ "app-diff",
7434
+ "app-rollback",
7435
+ "create_page",
7436
+ "delete-page",
7437
+ "kv-set",
7438
+ "kv-delete",
7439
+ "kv-incr",
7440
+ "room-get",
7441
+ "room-change",
7442
+ "room-reset",
7443
+ "room-decode",
7444
+ "script-upsert",
7445
+ "script-delete",
7446
+ "script-apis",
7447
+ "launch-script-run",
7448
+ "get-script-run",
7449
+ "list-script-runs",
7450
+ "swarm_x",
7451
+ "cancel-task",
7452
+ "inject-learning",
7453
+ "get-metrics"
7454
+ ]);
7455
+ ALL_TOOLS = new Set([...CORE_TOOLS, ...DEFERRED_TOOLS]);
7456
+ });
7457
+
7458
+ // src/utils/task-tool-manifest.ts
7459
+ function parseTaskToolManifest(value) {
7460
+ return taskToolManifestSchema.parse(JSON.parse(value));
7461
+ }
7462
+ function selectTaskTools(manifest, task) {
7463
+ const fromSchedule = task.scheduleId && Object.hasOwn(manifest.schedules ?? {}, task.scheduleId) ? manifest.schedules?.[task.scheduleId] : undefined;
7464
+ const fromType = task.taskType && Object.hasOwn(manifest.taskTypes ?? {}, task.taskType) ? manifest.taskTypes?.[task.taskType] : undefined;
7465
+ return [...new Set(fromSchedule ?? fromType ?? [])].filter((name) => !name.startsWith("slack-") || Boolean(task.slackChannelId));
7466
+ }
7467
+ var toolNames, taskToolManifestSchema;
7468
+ var init_task_tool_manifest = __esm(() => {
7469
+ init_zod();
7470
+ init_tool_config();
7471
+ toolNames = exports_external.array(exports_external.string().refine((name) => ALL_TOOLS.has(name), "Unknown swarm tool")).max(16);
7472
+ taskToolManifestSchema = exports_external.strictObject({
7473
+ taskTypes: exports_external.record(exports_external.string().min(1).max(50), toolNames).optional(),
7474
+ schedules: exports_external.record(exports_external.uuid(), toolNames).optional()
7475
+ });
7476
+ });
7477
+
7291
7478
  // src/be/swarm-config-guard.ts
7292
7479
  function isReservedConfigKey(key) {
7293
7480
  return RESERVED_KEYS.has(key.toUpperCase());
@@ -7370,6 +7557,7 @@ var RESERVED_KEYS, BOOLEAN_LITERALS, MAX_DB_RETENTION_DAYS = 1e6, DB_RETENTION_T
7370
7557
  var init_swarm_config_guard = __esm(() => {
7371
7558
  init_reaction_shortcode();
7372
7559
  init_types();
7560
+ init_task_tool_manifest();
7373
7561
  RESERVED_KEYS = new Set(["API_KEY", "SECRETS_ENCRYPTION_KEY", "CORS_ALLOW_ANY_ORIGIN"]);
7374
7562
  BOOLEAN_LITERALS = ["true", "false", "1", "0"];
7375
7563
  DB_RETENTION_TUNING_BOUNDS = {
@@ -7378,6 +7566,16 @@ var init_swarm_config_guard = __esm(() => {
7378
7566
  DB_RETENTION_MAX_STATEMENT_MS: { min: 25, max: 5000 }
7379
7567
  };
7380
7568
  VALIDATED_KEYS = {
7569
+ TASK_TOOL_MANIFESTS: (value) => {
7570
+ try {
7571
+ if (typeof value !== "string")
7572
+ throw new Error("Expected JSON string");
7573
+ parseTaskToolManifest(value);
7574
+ return null;
7575
+ } catch {
7576
+ return "Invalid TASK_TOOL_MANIFESTS (expected JSON with taskTypes and/or schedules maps, each selecting at most 16 known swarm tools)";
7577
+ }
7578
+ },
7381
7579
  FEEDBACK_ENDPOINT: (value) => {
7382
7580
  if (typeof value !== "string") {
7383
7581
  return "Invalid FEEDBACK_ENDPOINT (must use HTTPS, or HTTP on a loopback host)";
@@ -7454,6 +7652,7 @@ var init_swarm_config_guard = __esm(() => {
7454
7652
  "HEARTBEAT_PIN_CRASH_RESUME",
7455
7653
  "POOL_AFFINITY_ENFORCEMENT",
7456
7654
  "SCRIPTS_ONLY_MCP",
7655
+ "TASK_TOOL_PRELOAD_ENABLED",
7457
7656
  "SLACK_DISABLE",
7458
7657
  "SLACK_RENDER_V2",
7459
7658
  "SLACK_RENDER_V2_DELEGATION",
@@ -9041,6 +9240,51 @@ async function findRecentSimilarTasks(opts) {
9041
9240
  const rows = await getDbClient().query(query, params);
9042
9241
  return rows.map(rowToAgentTask);
9043
9242
  }
9243
+ async function findLatestRoutingCandidate(where, params) {
9244
+ const row = await getDbClient().get(`SELECT id AS taskId, ${ROUTING_HOLDER_SQL} AS agentId
9245
+ FROM agent_tasks
9246
+ WHERE ${where}
9247
+ AND ${ROUTING_HOLDER_SQL} IN (SELECT id FROM agents WHERE isLead = 0)
9248
+ ORDER BY createdAt DESC, rowid DESC
9249
+ LIMIT 1`, params);
9250
+ return row ?? null;
9251
+ }
9252
+ async function captureRoutingDecisionSnapshot(options) {
9253
+ const workerStatuses = await getDbClient().query(`SELECT agent.id AS agentId, agent.status,
9254
+ COUNT(task.id) AS openTaskCount,
9255
+ SUM(CASE WHEN task.status IN ('in_progress', 'reviewing') THEN 1 ELSE 0 END) AS activeTaskCount
9256
+ FROM agents agent
9257
+ LEFT JOIN agent_tasks task ON
9258
+ (task.agentId = agent.id OR task.offeredTo = agent.id)
9259
+ AND task.status NOT IN ('completed', 'failed', 'cancelled', 'superseded')
9260
+ WHERE agent.isLead = 0
9261
+ GROUP BY agent.id, agent.status
9262
+ ORDER BY agent.id`);
9263
+ const samePr = options.vcsRepo && options.vcsNumber != null ? await findLatestRoutingCandidate("vcsRepo = ? AND vcsNumber = ?", [
9264
+ options.vcsRepo,
9265
+ options.vcsNumber
9266
+ ]) : null;
9267
+ let sameThread = null;
9268
+ if (options.slackChannelId && options.slackThreadTs) {
9269
+ sameThread = await findLatestRoutingCandidate("slackChannelId = ? AND slackThreadTs = ?", [
9270
+ options.slackChannelId,
9271
+ options.slackThreadTs
9272
+ ]);
9273
+ } else if (options.agentmailThreadId) {
9274
+ sameThread = await findLatestRoutingCandidate("agentmailThreadId = ?", [
9275
+ options.agentmailThreadId
9276
+ ]);
9277
+ }
9278
+ const sameRepo = options.vcsRepo ? await findLatestRoutingCandidate("vcsRepo = ?", [options.vcsRepo]) : null;
9279
+ return {
9280
+ capturedAt: new Date().toISOString(),
9281
+ workerStatuses,
9282
+ continuityCandidates: { samePr, sameThread, sameRepo }
9283
+ };
9284
+ }
9285
+ function logRoutingDecisionFailure(taskId, stage, error) {
9286
+ console.warn(`[routing-decision] Failed to ${stage} snapshot for task ${taskId}:`, scrubSecrets(error instanceof Error ? error.message : String(error)));
9287
+ }
9044
9288
  async function createTaskExtended(task, options) {
9045
9289
  if (typeof task !== "string" || task.trim().length === 0) {
9046
9290
  throw new Error("createTaskExtended: 'task' must be a non-empty string");
@@ -9213,8 +9457,14 @@ async function createTaskExtended(task, options) {
9213
9457
  const existingTrackerWork = options?.bypassTrackerContextDedup ? null : await findExistingLinearTrackerContextWork(options?.contextKey);
9214
9458
  if (existingTrackerWork)
9215
9459
  return { existing: existingTrackerWork };
9460
+ let routingDecisionSnapshot = null;
9461
+ try {
9462
+ routingDecisionSnapshot = await captureRoutingDecisionSnapshot(options);
9463
+ } catch (error) {
9464
+ logRoutingDecisionFailure(id, "capture", error);
9465
+ }
9216
9466
  const inserted = await getDbClient().get(`INSERT INTO agent_tasks (
9217
- id, "key", agentId, creatorAgentId, task, status, source,
9467
+ id, "key", agentId, creatorAgentId, task, status, source, routing_reason, routing_note,
9218
9468
  taskType, tags, priority, dependsOn, offeredTo, offeredAt,
9219
9469
  slackChannelId, slackThreadTs, slackTriggerMessageTs, slackUserId,
9220
9470
  vcsProvider, vcsRepo, vcsEventType, vcsNumber, vcsCommentId, vcsAuthor, vcsUrl,
@@ -9222,7 +9472,7 @@ async function createTaskExtended(task, options) {
9222
9472
  agentmailInboxId, agentmailMessageId, agentmailThreadId,
9223
9473
  mentionMessageId, mentionChannelId, dir, parentTaskId, model, modelTier, effort, scheduleId,
9224
9474
  workflowRunId, workflowRunStepId, outputSchema, followUpConfig, requestedByUserId, requestedByUserIdInherited, contextKey, routingAffinity, swarmVersion, createdAt, lastUpdatedAt, created_by, updated_by
9225
- ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING *`, [
9475
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING *`, [
9226
9476
  id,
9227
9477
  assetKey,
9228
9478
  options?.agentId ?? null,
@@ -9230,6 +9480,8 @@ async function createTaskExtended(task, options) {
9230
9480
  task,
9231
9481
  status,
9232
9482
  options?.source ?? "mcp",
9483
+ options?.routingReason ?? null,
9484
+ options?.routingNote ?? null,
9233
9485
  options?.taskType ?? null,
9234
9486
  JSON.stringify(options?.tags ?? []),
9235
9487
  options?.priority ?? 50,
@@ -9276,6 +9528,24 @@ async function createTaskExtended(task, options) {
9276
9528
  ]);
9277
9529
  if (!inserted)
9278
9530
  throw new Error("Failed to create task");
9531
+ if (routingDecisionSnapshot) {
9532
+ try {
9533
+ await getDbClient().run(`INSERT INTO routing_decisions (
9534
+ task_id, selected_agent_id, captured_at, worker_statuses,
9535
+ continuity_candidates, created_by, updated_by
9536
+ ) VALUES (?, ?, ?, ?, ?, ?, ?)`, [
9537
+ id,
9538
+ options.offeredTo ?? options.agentId ?? null,
9539
+ routingDecisionSnapshot.capturedAt,
9540
+ JSON.stringify(routingDecisionSnapshot.workerStatuses),
9541
+ JSON.stringify(routingDecisionSnapshot.continuityCandidates),
9542
+ auditUserId,
9543
+ auditUserId
9544
+ ]);
9545
+ } catch (error) {
9546
+ logRoutingDecisionFailure(id, "write", error);
9547
+ }
9548
+ }
9279
9549
  return { row: inserted };
9280
9550
  });
9281
9551
  if ("existing" in claim) {
@@ -9893,6 +10163,7 @@ async function postMessage(channelId, agentId, content, options) {
9893
10163
  const taskDescription = `Task from ${senderName} in #${channelName}: "${truncated}"`;
9894
10164
  const task = await createTaskExtended(taskDescription, {
9895
10165
  agentId: mentionedAgentId,
10166
+ routingReason: "human_pinned",
9896
10167
  creatorAgentId: agentId ?? undefined,
9897
10168
  source: "mcp",
9898
10169
  taskType: "task",
@@ -15055,7 +15326,10 @@ async function countScriptRunJournalAgentTaskSteps(runId) {
15055
15326
  const row = await getDbClient().get("SELECT COUNT(*) AS count FROM script_run_journal WHERE runId = ? AND stepType = 'agent-task'", [runId]);
15056
15327
  return row?.count ?? 0;
15057
15328
  }
15058
- var VERSIONABLE_FIELDS2, BUDGETED_IDENTITY_FIELDS, PENDING_SLACK_MESSAGE_TS_PREFIX = "pending:", 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", ELIGIBILITY_SCAN_BATCH_SIZE, ELIGIBILITY_SCAN_CAP, UNATTRIBUTED_USER_ID = "unattributed", HUMAN_FREE_TASKS_CTE = `human_free_tasks(id) AS (
15329
+ var VERSIONABLE_FIELDS2, BUDGETED_IDENTITY_FIELDS, PENDING_SLACK_MESSAGE_TS_PREFIX = "pending:", 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", ROUTING_HOLDER_SQL = `CASE
15330
+ WHEN status IN ('draft', 'offered', 'reviewing') AND offeredTo IS NOT NULL THEN offeredTo
15331
+ ELSE COALESCE(agentId, offeredTo)
15332
+ END`, ELIGIBILITY_SCAN_BATCH_SIZE, ELIGIBILITY_SCAN_CAP, UNATTRIBUTED_USER_ID = "unattributed", HUMAN_FREE_TASKS_CTE = `human_free_tasks(id) AS (
15059
15333
  SELECT task.id
15060
15334
  FROM agent_tasks task
15061
15335
  LEFT JOIN agent_tasks parent ON parent.id = task.parentTaskId
@@ -15183,4 +15457,4 @@ var init_db = __esm(() => {
15183
15457
  };
15184
15458
  });
15185
15459
 
15186
- 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, AgentAcpStatusSchema, AgentCredStatusSchema, AgentWithTasksSchema, VersionableFieldSchema, ChannelTypeSchema, ServiceStatusSchema, ServiceSchema, ResumeReasonSchema, AgentLogSchema, SessionLogSchema, SessionCostModelBreakdownSchema, SessionCostSchema, EventCategorySchema, EventStatusSchema, EventSourceSchema, EventNameSchema, SwarmEventSchema, AutomationIntegrationIdSchema, ScheduledTaskTargetTypeSchema, ScheduledTaskSchema, SwarmConfigScopeSchema, SwarmConfigSchema, RepoGuidelinesInputSchema, 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, HeartbeatExpiryError, init_heartbeat_expiry, beginRequestAuthScope, setRequestAuth, getRequestAuth, getCurrentRequestAuth, runWithoutRequestAuth, init_request_auth_context, auditAssetKeys, init_asset_key_audit, encryptSecret, decryptSecret, getEncryptionKey, init_crypto, normalizeDate, normalizeDateRequired, init_date_utils, CredentialBindingSchema, placeholderForConfigKey, CredentialBroker, DEFAULT_CREDENTIAL_BINDINGS, init_credential_broker, getPromptTemplateDefaultDrift, init_default_drift, init_templates2 as init_templates, isSqliteVecAvailable, resolveSqliteVecExtensionPath, __resetSqliteVecExtensionPathCacheForTests, initDb, getDb, closeDb, getDbClient, 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, computeContentHash, createContextVersion, getLatestContextVersion, getContextVersion, getContextVersionHistory, getTaskById, getChildTasks, hasNonTerminalResumeChild, hasNonTerminalRerouteDecisionChild, getTasksByAgentId, getAgentCurrentTask, getTasksByStatus, findTaskByVcs, findTaskByGitHub, getAllTasks, getTasksCount, getTaskStats, getCompletedSlackTasks, getPendingSlackRelayTasks, markSlackRelayAttempted, markSlackRelayDelivered, markFinalizedSlackRelaysDelivered, getRecentlyFinishedWorkerTasks, markTasksNotified, resetTasksNotified, getInProgressSlackTasks, getSlackTasksMissingTree, getInProgressTasksByContextKey, findExistingLinearTrackerContextWork, getLatestTaskByContextKey, getLatestScriptRunStepTaskByContextKey, getAgentWorkingOnThread, getLatestActiveTaskInThread, getLatestLeadTaskInThread, getMostRecentTaskInThread, findCompletedTaskInThread, findRecentCancelledTaskInThread, onTaskStarted, init_task_lifecycle_events, createTask, getPendingTaskForAgent, assignUnassignedTaskPending, startTask, updateTaskClaudeSessionId, updateTaskTitle, completeTask, failTask, overwriteTerminalTaskResultText, cancelTask, supersedeTask, backfillSupersedeTaskResumeTaskId, pauseTask, resumeTask, getPausedTasksForAgent, getOrphanedInProgressTasksForAgent, resetOrphanedInProgressTasksForAgent, getRecentlyCancelledTasksForAgent, deleteTask, updateTaskProgress, SteeringRequestError, isSteeringEnabled2 as isSteeringEnabled, getTaskSteeringFields, promotePendingSteeringForTask, markSteeringUndeliverable, requestSteering, init_steering, SLACK_REACTION_DEFAULTS, SLACK_REACTION_CONFIG_KEYS, reactionName, init_reaction_shortcode, isReservedConfigKey, reservedKeyError, MAX_DB_RETENTION_DAYS, DB_RETENTION_TUNING_BOUNDS, validateConfigValue, init_swarm_config_guard, getSlackRenderV2ActivatedAt, ensureSlackRenderV2Activation, getSlackDelegationActivatedAt, ensureSlackDelegationActivation, isPendingSlackMessage, recordSlackMessage, reserveSlackMessage, bindSlackMessageTimestamp, updateSlackMessageRecord, markSlackTreeRendered, deleteSlackMessageRecord, getSlackTreeMessage, getSlackTreeMessageByThread, getSlackOutcomeMessage, getSlackTreeMessages, getSlackMessageByChannelTs, getSlackTasksInThread, markTaskSlackReplySent, setSlackMessageTracking, updateTaskVcs, 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, refreshDraftTaskLease, 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 };
15460
+ 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, RoutingReasonSchema, ProviderNameSchema, SteerModeSchema, SteeringSourceSchema, SteeringMessageSchema, SteerOutcomeSchema, OnUnsupportedSchema, SteerResultSchema, FollowUpConfigSchema, AgentTaskSchema, AttachmentInputSchema, TaskAttachmentSchema, UserSchema, UserCommsPrefsSchema, InboxItemTypeSchema, InboxItemStatusSchema, InboxItemStateSchema, FavoriteItemTypeSchema, UserFavoriteSchema, TaskTemplateKindSchema, TaskTemplateSchema, AgentStatusSchema, AgentAvatarSchema, AgentSchema, AgentLatestModelSchema, AgentAcpStatusSchema, AgentCredStatusSchema, AgentWithTasksSchema, VersionableFieldSchema, ChannelTypeSchema, ServiceStatusSchema, ServiceSchema, ResumeReasonSchema, AgentLogSchema, SessionLogSchema, SessionCostModelBreakdownSchema, SessionCostSchema, EventCategorySchema, EventStatusSchema, EventSourceSchema, EventNameSchema, SwarmEventSchema, AutomationIntegrationIdSchema, ScheduledTaskTargetTypeSchema, ScheduledTaskSchema, SwarmConfigScopeSchema, SwarmConfigSchema, RepoGuidelinesInputSchema, 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, HeartbeatExpiryError, init_heartbeat_expiry, beginRequestAuthScope, setRequestAuth, getRequestAuth, getCurrentRequestAuth, runWithoutRequestAuth, init_request_auth_context, auditAssetKeys, init_asset_key_audit, encryptSecret, decryptSecret, getEncryptionKey, init_crypto, normalizeDate, normalizeDateRequired, init_date_utils, CredentialBindingSchema, placeholderForConfigKey, CredentialBroker, DEFAULT_CREDENTIAL_BINDINGS, init_credential_broker, getPromptTemplateDefaultDrift, init_default_drift, init_templates2 as init_templates, isSqliteVecAvailable, resolveSqliteVecExtensionPath, __resetSqliteVecExtensionPathCacheForTests, initDb, getDb, closeDb, getDbClient, 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, computeContentHash, createContextVersion, getLatestContextVersion, getContextVersion, getContextVersionHistory, getTaskById, getChildTasks, hasNonTerminalResumeChild, hasNonTerminalRerouteDecisionChild, getTasksByAgentId, getAgentCurrentTask, getTasksByStatus, findTaskByVcs, findTaskByGitHub, getAllTasks, getTasksCount, getTaskStats, getCompletedSlackTasks, getPendingSlackRelayTasks, markSlackRelayAttempted, markSlackRelayDelivered, markFinalizedSlackRelaysDelivered, getRecentlyFinishedWorkerTasks, markTasksNotified, resetTasksNotified, getInProgressSlackTasks, getSlackTasksMissingTree, getInProgressTasksByContextKey, findExistingLinearTrackerContextWork, getLatestTaskByContextKey, getLatestScriptRunStepTaskByContextKey, getAgentWorkingOnThread, getLatestActiveTaskInThread, getLatestLeadTaskInThread, getMostRecentTaskInThread, findCompletedTaskInThread, findRecentCancelledTaskInThread, onTaskStarted, init_task_lifecycle_events, createTask, getPendingTaskForAgent, assignUnassignedTaskPending, startTask, updateTaskClaudeSessionId, updateTaskTitle, completeTask, failTask, overwriteTerminalTaskResultText, cancelTask, supersedeTask, backfillSupersedeTaskResumeTaskId, pauseTask, resumeTask, getPausedTasksForAgent, getOrphanedInProgressTasksForAgent, resetOrphanedInProgressTasksForAgent, getRecentlyCancelledTasksForAgent, deleteTask, updateTaskProgress, SteeringRequestError, isSteeringEnabled2 as isSteeringEnabled, getTaskSteeringFields, promotePendingSteeringForTask, markSteeringUndeliverable, requestSteering, init_steering, SLACK_REACTION_DEFAULTS, SLACK_REACTION_CONFIG_KEYS, reactionName, init_reaction_shortcode, parseTaskToolManifest, selectTaskTools, init_task_tool_manifest, isReservedConfigKey, reservedKeyError, MAX_DB_RETENTION_DAYS, DB_RETENTION_TUNING_BOUNDS, validateConfigValue, init_swarm_config_guard, getSlackRenderV2ActivatedAt, ensureSlackRenderV2Activation, getSlackDelegationActivatedAt, ensureSlackDelegationActivation, isPendingSlackMessage, recordSlackMessage, reserveSlackMessage, bindSlackMessageTimestamp, updateSlackMessageRecord, markSlackTreeRendered, deleteSlackMessageRecord, getSlackTreeMessage, getSlackTreeMessageByThread, getSlackOutcomeMessage, getSlackTreeMessages, getSlackMessageByChannelTs, getSlackTasksInThread, markTaskSlackReplySent, setSlackMessageTracking, updateTaskVcs, 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, refreshDraftTaskLease, 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 };