@desplega.ai/agent-swarm 1.114.0 → 1.115.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 (117) hide show
  1. package/dist/{actions-bm8vdxys.js → actions-17ya5wde.js} +6 -6
  2. package/dist/{app-bhwdxmvp.js → app-4f718yk0.js} +4 -4
  3. package/dist/{assistant-15mp2apr.js → assistant-ah7csnjz.js} +9 -9
  4. package/dist/{boot-reembed-awr2179r.js → boot-reembed-4jpxhb25.js} +4 -4
  5. package/dist/{boot-reembed-b9sbk87z.js → boot-reembed-qata34xa.js} +3 -3
  6. package/dist/{boot-scrub-logs-c1zsaw9m.js → boot-scrub-logs-tv48nn3z.js} +2 -2
  7. package/dist/{claude-adapter-2k45y7p7.js → claude-adapter-3csn5bks.js} +2 -2
  8. package/dist/{cli-zmmp2r79.js → cli-12vb0xg6.js} +13 -2
  9. package/dist/{cli-jzwtn8rm.js → cli-15y7qhzp.js} +188 -18
  10. package/dist/{cli-w3nq88yc.js → cli-3samkyap.js} +2 -2
  11. package/dist/{cli-7rgh0w0k.js → cli-52fg7s7x.js} +10 -3
  12. package/dist/{cli-5afkmcfj.js → cli-65ekje01.js} +6 -6
  13. package/dist/{cli-113wmegp.js → cli-6aq8xhvm.js} +1 -1
  14. package/dist/{cli-byjcad11.js → cli-7xje5amz.js} +1 -1
  15. package/dist/{cli-0kgcv878.js → cli-86fdnerz.js} +63 -2
  16. package/dist/{cli-f5pzfvwb.js → cli-b23axgz4.js} +1 -1
  17. package/dist/{cli-a0t7vapf.js → cli-bc89my0z.js} +1 -1
  18. package/dist/{cli-q4e2x252.js → cli-beea4a3y.js} +73 -24
  19. package/dist/{cli-w4wk3kx6.js → cli-cchksf5q.js} +2 -2
  20. package/dist/{cli-f9n2jg31.js → cli-cmw9rzy5.js} +2 -2
  21. package/dist/{cli-hvg05qwm.js → cli-cnwssmsr.js} +1 -1
  22. package/dist/{cli-2t4e4ayk.js → cli-dcca6j8m.js} +46 -5
  23. package/dist/{cli-tkmm5nf9.js → cli-e61fs2hp.js} +59 -2
  24. package/dist/{cli-e2xbxmhd.js → cli-hrhye2rm.js} +90 -32
  25. package/dist/{cli-312v3c41.js → cli-k3y4z3h5.js} +1 -1
  26. package/dist/{cli-6xd0bvf8.js → cli-ma04faw5.js} +1 -1
  27. package/dist/{cli-ggy8c7tk.js → cli-mnbgv3w7.js} +1 -1
  28. package/dist/{cli-hq39e630.js → cli-pet3aev6.js} +95 -10
  29. package/dist/{cli-a6tzw6vq.js → cli-q1rx7g0d.js} +6 -6
  30. package/dist/{cli-pnfyyp6h.js → cli-r9f6ngrf.js} +6 -3
  31. package/dist/{cli-q1z5d5ss.js → cli-shvaxw27.js} +4 -4
  32. package/dist/{cli-49j095n9.js → cli-t0vqevnm.js} +1 -1
  33. package/dist/{cli-k6h2zkw3.js → cli-tece6zgm.js} +1 -1
  34. package/dist/{cli-5ktc9fd4.js → cli-tffvrh6j.js} +1 -1
  35. package/dist/cli-wh91zby6.js +187222 -0
  36. package/dist/{cli-r3mtrrzp.js → cli-zsrdty74.js} +12 -12
  37. package/dist/cli.js +10 -10
  38. package/dist/{codex-adapter-4z8m9mb5.js → codex-adapter-de3w0nch.js} +2 -2
  39. package/dist/{codex-session-runner-rbct46dg.js → codex-session-runner-bnw8cysk.js} +2 -2
  40. package/dist/{commands-zk4d6esf.js → commands-hch4e2k1.js} +2 -2
  41. package/dist/{db-stn16jp2.js → db-p3h2j06x.js} +12 -2
  42. package/dist/{handlers-gshprvpf.js → handlers-9er4zx9q.js} +9 -9
  43. package/dist/{hook-amzx9tap.js → hook-4axs756z.js} +1 -1
  44. package/dist/{http-6g0hfzax.js → http-809fvtz2.js} +182 -65
  45. package/dist/{index-ty42rxw9.js → index-47em3d2n.js} +10 -10
  46. package/dist/{index-jbm7qcqk.js → index-9fqaktjr.js} +8 -8
  47. package/dist/{index-f03rnnrs.js → index-9ht8gr56.js} +9 -9
  48. package/dist/{index-df8fmphk.js → index-rm85cfdx.js} +331 -30
  49. package/dist/{keepalive-pm6g2wpw.js → keepalive-3cps6e3e.js} +4 -4
  50. package/dist/{lead-h79fzpzw.js → lead-fkk95wgq.js} +24 -24
  51. package/dist/{maintenance-433zndy1.js → maintenance-fweqh0yj.js} +4 -4
  52. package/dist/{oauth-refresh-sweep-mjsbmsk2.js → oauth-refresh-sweep-sycqtbph.js} +3 -3
  53. package/dist/{onboard-vdr9hc3f.js → onboard-cy0rkgvx.js} +2 -2
  54. package/dist/{opencode-adapter-mqsxr170.js → opencode-adapter-p6bxnbm4.js} +2 -2
  55. package/dist/{otel-impl-yswd0fty.js → otel-impl-wbns8hf7.js} +1 -1
  56. package/dist/{pi-mono-adapter-vbrvg1p8.js → pi-mono-adapter-05sck1ds.js} +1 -1
  57. package/dist/{pricing-refresh-2kk2ap9b.js → pricing-refresh-0hvazmkf.js} +4 -4
  58. package/dist/{rbac-roles-xdc5208b.js → rbac-roles-kfesjy9y.js} +4 -4
  59. package/dist/{rbac-roles-2wgh9b5t.js → rbac-roles-mwcwhbxc.js} +11 -4
  60. package/dist/{seed-pricing-m9h69d2t.js → seed-pricing-h2kdq4cq.js} +3 -3
  61. package/dist/{setup-eynkvafa.js → setup-8506q97w.js} +2 -2
  62. package/dist/{worker-136q8dc2.js → worker-4r5c6zyb.js} +24 -24
  63. package/openapi.json +8 -4
  64. package/package.json +1 -1
  65. package/src/be/db.ts +253 -20
  66. package/src/be/migrations/113_task_routing_affinity.sql +9 -0
  67. package/src/be/migrations/114_backfill_gpt_5_6_pricing.sql +15 -0
  68. package/src/be/modelsdev-cache.json +135 -0
  69. package/src/be/rbac-audit.ts +19 -8
  70. package/src/be/rbac-roles.ts +8 -1
  71. package/src/be/script-connections.ts +4 -4
  72. package/src/be/scripts/typecheck.ts +11 -0
  73. package/src/be/seed-scripts/catalog/catalog-report.inline.ts +325 -24
  74. package/src/be/seed-scripts/catalog/catalog-report.ts +325 -24
  75. package/src/heartbeat/heartbeat.ts +143 -21
  76. package/src/http/favorites.ts +1 -5
  77. package/src/http/mcp-servers.ts +38 -0
  78. package/src/http/poll.ts +7 -2
  79. package/src/http/scripts.ts +6 -0
  80. package/src/http/skills.ts +11 -0
  81. package/src/http/tasks.ts +21 -9
  82. package/src/providers/codex-models.ts +100 -30
  83. package/src/providers/modelsdev-reasoning.json +51 -0
  84. package/src/providers/reasoning-effort.ts +11 -5
  85. package/src/rbac/admission.ts +26 -2
  86. package/src/rbac/index.ts +2 -2
  87. package/src/rbac/legacy-policy.ts +9 -0
  88. package/src/rbac/permissions.ts +36 -0
  89. package/src/scripts-runtime/api-client.ts +82 -6
  90. package/src/scripts-runtime/types/swarm-sdk.d.ts +11 -0
  91. package/src/server-user.ts +114 -59
  92. package/src/slack/responses.ts +91 -1
  93. package/src/slack/watcher.ts +9 -6
  94. package/src/tasks/worker-follow-up.ts +100 -3
  95. package/src/tests/codex-adapter.test.ts +46 -23
  96. package/src/tests/heartbeat.test.ts +48 -3
  97. package/src/tests/model-control.test.ts +8 -2
  98. package/src/tests/pool-affinity.test.ts +401 -0
  99. package/src/tests/rbac-admission-e2e.test.ts +152 -7
  100. package/src/tests/rbac-admission.test.ts +60 -1
  101. package/src/tests/rbac-engine.test.ts +9 -0
  102. package/src/tests/rbac-mcp-admission-e2e.test.ts +362 -0
  103. package/src/tests/rbac-roles.test.ts +2 -0
  104. package/src/tests/reasoning-effort.test.ts +15 -2
  105. package/src/tests/script-apis-mcp.test.ts +37 -13
  106. package/src/tests/script-connections.test.ts +27 -1
  107. package/src/tests/scripts-runtime.test.ts +187 -0
  108. package/src/tests/seed-scripts.test.ts +36 -0
  109. package/src/tests/slack-inline-output.test.ts +65 -0
  110. package/src/tests/user-token-rest-auth.test.ts +110 -0
  111. package/src/tools/script-apis.ts +62 -3
  112. package/src/tools/send-task.ts +15 -1
  113. package/src/tools/task-action.ts +34 -2
  114. package/src/tools/templates.ts +48 -0
  115. package/src/tools/utils.ts +2 -0
  116. package/src/types.ts +27 -5
  117. package/dist/cli-46b6kc7f.js +0 -1698
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  resolveSlackUserId
3
- } from "./cli-w4wk3kx6.js";
4
- import"./cli-113wmegp.js";
3
+ } from "./cli-cchksf5q.js";
4
+ import"./cli-6aq8xhvm.js";
5
5
  import {
6
6
  buildCancelledBlocks,
7
7
  getTaskLink
8
- } from "./cli-6xd0bvf8.js";
8
+ } from "./cli-ma04faw5.js";
9
9
  import"./cli-wspgs9bt.js";
10
10
  import {
11
11
  createTaskWithSiblingAwareness,
12
12
  slackContextKey
13
- } from "./cli-312v3c41.js";
13
+ } from "./cli-k3y4z3h5.js";
14
14
  import"./cli-dh55d5fg.js";
15
15
  import {
16
16
  cancelTask,
@@ -18,11 +18,11 @@ import {
18
18
  getLeadAgent,
19
19
  getTaskById,
20
20
  init_db
21
- } from "./cli-jzwtn8rm.js";
21
+ } from "./cli-15y7qhzp.js";
22
22
  import"./cli-z2zcxes1.js";
23
23
  import"./cli-bw80ck94.js";
24
24
  import"./cli-xz9aq0rf.js";
25
- import"./cli-f5pzfvwb.js";
25
+ import"./cli-b23axgz4.js";
26
26
  import"./cli-4j2mrzag.js";
27
27
  import"./cli-p9swy5t3.js";
28
28
 
@@ -3,17 +3,17 @@ import {
3
3
  initSlackApp,
4
4
  startSlackApp,
5
5
  stopSlackApp
6
- } from "./cli-hq39e630.js";
6
+ } from "./cli-pet3aev6.js";
7
7
  import"./cli-rkndnn90.js";
8
8
  import"./cli-b0p7rfnd.js";
9
- import"./cli-6xd0bvf8.js";
9
+ import"./cli-ma04faw5.js";
10
10
  import"./cli-wspgs9bt.js";
11
11
  import"./cli-dh55d5fg.js";
12
- import"./cli-jzwtn8rm.js";
12
+ import"./cli-15y7qhzp.js";
13
13
  import"./cli-z2zcxes1.js";
14
14
  import"./cli-bw80ck94.js";
15
15
  import"./cli-xz9aq0rf.js";
16
- import"./cli-f5pzfvwb.js";
16
+ import"./cli-b23axgz4.js";
17
17
  import"./cli-4j2mrzag.js";
18
18
  import"./cli-e15jhafb.js";
19
19
  import"./cli-7wmybrt5.js";
@@ -1,26 +1,26 @@
1
1
  import {
2
2
  bufferThreadMessage,
3
3
  wasEventSeen
4
- } from "./cli-5afkmcfj.js";
4
+ } from "./cli-65ekje01.js";
5
5
  import {
6
6
  hasOtherUserMention
7
- } from "./cli-5ktc9fd4.js";
7
+ } from "./cli-tffvrh6j.js";
8
8
  import {
9
9
  require_dist
10
- } from "./cli-hq39e630.js";
10
+ } from "./cli-pet3aev6.js";
11
11
  import"./cli-rkndnn90.js";
12
12
  import"./cli-b0p7rfnd.js";
13
13
  import {
14
14
  resolveSlackUserId,
15
15
  rewriteSlackMentions
16
- } from "./cli-w4wk3kx6.js";
17
- import"./cli-113wmegp.js";
18
- import"./cli-6xd0bvf8.js";
16
+ } from "./cli-cchksf5q.js";
17
+ import"./cli-6aq8xhvm.js";
18
+ import"./cli-ma04faw5.js";
19
19
  import"./cli-wspgs9bt.js";
20
20
  import {
21
21
  createTaskWithSiblingAwareness,
22
22
  slackContextKey
23
- } from "./cli-312v3c41.js";
23
+ } from "./cli-k3y4z3h5.js";
24
24
  import"./cli-dh55d5fg.js";
25
25
  import {
26
26
  getAgentWorkingOnThread,
@@ -29,11 +29,11 @@ import {
29
29
  init_db,
30
30
  init_resolver,
31
31
  resolveTemplate
32
- } from "./cli-jzwtn8rm.js";
32
+ } from "./cli-15y7qhzp.js";
33
33
  import"./cli-z2zcxes1.js";
34
34
  import"./cli-bw80ck94.js";
35
35
  import"./cli-xz9aq0rf.js";
36
- import"./cli-f5pzfvwb.js";
36
+ import"./cli-b23axgz4.js";
37
37
  import"./cli-4j2mrzag.js";
38
38
  import"./cli-e15jhafb.js";
39
39
  import"./cli-7wmybrt5.js";
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  embedScript,
3
3
  embeddingProvider
4
- } from "./cli-f9n2jg31.js";
5
- import"./cli-byjcad11.js";
4
+ } from "./cli-cmw9rzy5.js";
5
+ import"./cli-7xje5amz.js";
6
6
  import"./cli-q25ejbyn.js";
7
7
  import {
8
8
  getDb,
9
9
  init_db
10
- } from "./cli-jzwtn8rm.js";
10
+ } from "./cli-15y7qhzp.js";
11
11
  import"./cli-z2zcxes1.js";
12
12
  import"./cli-bw80ck94.js";
13
13
  import"./cli-xz9aq0rf.js";
14
- import"./cli-f5pzfvwb.js";
14
+ import"./cli-b23axgz4.js";
15
15
  import"./cli-4j2mrzag.js";
16
16
  import"./cli-p9swy5t3.js";
17
17
 
@@ -3,16 +3,16 @@ import {
3
3
  getEmbeddingProvider,
4
4
  getMemoryStore,
5
5
  init_constants
6
- } from "./cli-byjcad11.js";
6
+ } from "./cli-7xje5amz.js";
7
7
  import"./cli-q25ejbyn.js";
8
8
  import {
9
9
  getDb,
10
10
  init_db
11
- } from "./cli-jzwtn8rm.js";
11
+ } from "./cli-15y7qhzp.js";
12
12
  import"./cli-z2zcxes1.js";
13
13
  import"./cli-bw80ck94.js";
14
14
  import"./cli-xz9aq0rf.js";
15
- import"./cli-f5pzfvwb.js";
15
+ import"./cli-b23axgz4.js";
16
16
  import"./cli-4j2mrzag.js";
17
17
  import"./cli-p9swy5t3.js";
18
18
 
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  getDb,
3
3
  init_db
4
- } from "./cli-jzwtn8rm.js";
4
+ } from "./cli-15y7qhzp.js";
5
5
  import"./cli-z2zcxes1.js";
6
6
  import"./cli-bw80ck94.js";
7
7
  import"./cli-xz9aq0rf.js";
8
- import"./cli-f5pzfvwb.js";
8
+ import"./cli-b23axgz4.js";
9
9
  import {
10
10
  init_secret_scrubber,
11
11
  scrubSecrets
@@ -12,12 +12,12 @@ import {
12
12
  resolveClaudeBinary,
13
13
  resolveClaudeBinaryArgv,
14
14
  resolveClaudeBridgeEnabled
15
- } from "./cli-ggy8c7tk.js";
15
+ } from "./cli-mnbgv3w7.js";
16
16
  import"./cli-tng3131n.js";
17
17
  import"./cli-psrqtw2m.js";
18
18
  import"./cli-zm7njwzd.js";
19
19
  import"./cli-tghre7g6.js";
20
- import"./cli-tkmm5nf9.js";
20
+ import"./cli-e61fs2hp.js";
21
21
  import"./cli-z2zcxes1.js";
22
22
  import"./cli-4j2mrzag.js";
23
23
  import"./cli-7zd05xb4.js";
@@ -2,7 +2,7 @@ import {
2
2
  getScriptApiTypes,
3
3
  getScriptMcpTypes,
4
4
  require_typescript
5
- } from "./cli-pnfyyp6h.js";
5
+ } from "./cli-r9f6ngrf.js";
6
6
  import {
7
7
  deleteSwarmConfigByKey,
8
8
  getAgentById,
@@ -11,7 +11,7 @@ import {
11
11
  getSwarmConfigs,
12
12
  init_db,
13
13
  upsertSwarmConfig
14
- } from "./cli-jzwtn8rm.js";
14
+ } from "./cli-15y7qhzp.js";
15
15
  import {
16
16
  init_secret_scrubber,
17
17
  scrubSecrets
@@ -362,6 +362,17 @@ var SCRIPT_SDK_TYPES = `
362
362
  export type JsonValue = null | boolean | number | string | JsonValue[] | { [key: string]: JsonValue };
363
363
  export type ScriptScope = "agent" | "global";
364
364
  export type ScriptFsMode = "none" | "workspace-rw";
365
+ export type ScriptApiRawOptions = { raw: true };
366
+ export type ScriptApiDefaultOptions = { raw?: false };
367
+
368
+ export interface ScriptApiRawResult {
369
+ ok: boolean;
370
+ status: number;
371
+ statusText: string;
372
+ headers: Record<string, string>;
373
+ url: string;
374
+ response: Response;
375
+ }
365
376
 
366
377
  export interface Redacted<T> {
367
378
  readonly __redactedBrand?: T;
@@ -26,7 +26,7 @@ import {
26
26
  import {
27
27
  init_package,
28
28
  package_default
29
- } from "./cli-f5pzfvwb.js";
29
+ } from "./cli-b23axgz4.js";
30
30
  import {
31
31
  init_secret_scrubber,
32
32
  scrubSecrets
@@ -470,12 +470,12 @@ function resolveTaskModelSelection(opts) {
470
470
  function isTerminalTaskStatus(status) {
471
471
  return TERMINAL_TASK_STATUSES.includes(status);
472
472
  }
473
- var ModelTierSchema, MODEL_TIERS, ReasoningEffortSchema, LEGACY_MODEL_TO_TIER, DEFAULT_MODEL_TIER_MAP, AgentTaskStatusSchema, TERMINAL_TASK_STATUSES, InboxMessageStatusSchema, InboxMessageSchema, AgentTaskSourceSchema, ProviderNameSchema, FollowUpConfigSchema, AgentTaskSchema, TaskAttachmentKindSchema, attachmentCommonFields, AttachmentInputSchema, TaskAttachmentSchema, UserSchema, IdentityEventTypeSchema, InboxItemTypeSchema, InboxItemStatusSchema, InboxItemStateSchema, FavoriteItemTypeSchema, UserFavoriteSchema, TaskTemplateKindSchema, TaskTemplateSchema, AgentStatusSchema, AgentSchema, AgentCredStatusLiveTestSchema, AgentLatestModelSchema, AgentBedrockStatusSchema, AgentCredStatusSchema, AgentWithTasksSchema, ChangeSourceSchema, VersionableFieldSchema, ContextVersionSchema, ChannelTypeSchema, ChannelSchema, ChannelMessageSchema, ServiceStatusSchema, ServiceSchema, AgentLogEventTypeSchema, ResumeReasonSchema, AgentLogSchema, SessionLogSchema, SessionCostSourceSchema, SessionCostSchema, EventCategorySchema, EventStatusSchema, EventSourceSchema, EventNameSchema, SwarmEventSchema, ScheduledTaskTargetTypeSchema, ScheduledTaskSchema, SwarmConfigScopeSchema, SwarmConfigSchema, RepoGuidelinesSchema, RepoHooksSchema, SwarmRepoSchema, AgentMemoryScopeSchema, AgentMemorySourceSchema, AgentMemorySchema, ActiveSessionSchema, RetryPolicySchema, ExecutorMetaSchema, ValidationResultSchema, StepValidationConfigSchema, SwarmScriptNodeConfigSchema, WorkflowNodeSchema, WorkflowEdgeSchema, WorkflowDefinitionSchema, WorkflowNodePatchSchema, WorkflowPatchSchema, WebhookVerificationSchema, TriggerConfigSchema, CooldownConfigSchema, InputValueSchema, WorkflowTemplateSchema, WorkflowSnapshotSchema, WorkflowSchema, WorkflowVersionSchema, PageContentTypeSchema, PageAuthModeSchema, PageSnapshotSchema, PageSchema, PageVersionSchema, MetricParamSchema, MetricVariableTypeSchema, MetricFormatSchema, MetricVisualizationSchema, MetricQuerySchema, MetricVariableSchema, MetricVizConfigSchema, MetricWidgetSchema, MetricDefinitionSchema, MetricSnapshotSchema, MetricSchema, MetricVersionSchema, WorkflowRunStatusSchema, WorkflowRunSchema, ScriptRunStatusSchema, TERMINAL_SCRIPT_RUN_STATUSES, ScriptRunKindSchema, ScriptRunSchema, ScriptRunListItemSchema, ScriptRunJournalEntrySchema, WorkflowRunStepStatusSchema, WorkflowRunStepSchema, WaitModeSchema, WaitStateStatusSchema, WaitStateRowSchema, PromptTemplateScopeSchema, PromptTemplateStateSchema, PromptTemplateSchema, PromptTemplateHistorySchema, ScriptScopeSchema, ScriptFsModeSchema, ScriptRecordSchema, ScriptVersionRecordSchema, ScriptApiAuthModeSchema, ScriptApiRecordSchema, SkillTypeSchema, SkillScopeSchema, SkillSchema, AgentSkillSchema, SkillWithInstallInfoSchema, SkillFileSchema, McpServerTransportSchema, McpServerScopeSchema, McpAuthMethodSchema, McpServerSchema, AgentMcpServerSchema, McpServerWithInstallInfoSchema, ContextSnapshotEventTypeSchema, ContextFormulaSchema, ContextSnapshotSchema, BudgetScopeSchema, BudgetSchema, PricingProviderSchema, PricingTokenClassSchema, PricingRowSchema, BudgetRefusalCauseSchema, BudgetRefusalNotificationSchema, BudgetRefusedTriggerSchema, KvValueTypeSchema, KV_NAME_REGEX, KvNamespaceSchema, KvKeySchema, KvEntrySchema;
473
+ var ModelTierSchema, MODEL_TIERS, ReasoningEffortSchema, LEGACY_MODEL_TO_TIER, DEFAULT_MODEL_TIER_MAP, AgentTaskStatusSchema, TERMINAL_TASK_STATUSES, InboxMessageStatusSchema, InboxMessageSchema, AgentTaskSourceSchema, ProviderNameSchema, FollowUpConfigSchema, RoutingAffinitySchema, AgentTaskSchema, TaskAttachmentKindSchema, attachmentCommonFields, AttachmentInputSchema, TaskAttachmentSchema, UserSchema, IdentityEventTypeSchema, InboxItemTypeSchema, InboxItemStatusSchema, InboxItemStateSchema, FavoriteItemTypeSchema, UserFavoriteSchema, TaskTemplateKindSchema, TaskTemplateSchema, AgentStatusSchema, AgentSchema, AgentCredStatusLiveTestSchema, AgentLatestModelSchema, AgentBedrockStatusSchema, AgentCredStatusSchema, AgentWithTasksSchema, ChangeSourceSchema, VersionableFieldSchema, ContextVersionSchema, ChannelTypeSchema, ChannelSchema, ChannelMessageSchema, ServiceStatusSchema, ServiceSchema, AgentLogEventTypeSchema, ResumeReasonSchema, AgentLogSchema, SessionLogSchema, SessionCostSourceSchema, SessionCostSchema, EventCategorySchema, EventStatusSchema, EventSourceSchema, EventNameSchema, SwarmEventSchema, ScheduledTaskTargetTypeSchema, ScheduledTaskSchema, SwarmConfigScopeSchema, SwarmConfigSchema, RepoGuidelinesSchema, RepoHooksSchema, SwarmRepoSchema, AgentMemoryScopeSchema, AgentMemorySourceSchema, AgentMemorySchema, ActiveSessionSchema, RetryPolicySchema, ExecutorMetaSchema, ValidationResultSchema, StepValidationConfigSchema, SwarmScriptNodeConfigSchema, WorkflowNodeSchema, WorkflowEdgeSchema, WorkflowDefinitionSchema, WorkflowNodePatchSchema, WorkflowPatchSchema, WebhookVerificationSchema, TriggerConfigSchema, CooldownConfigSchema, InputValueSchema, WorkflowTemplateSchema, WorkflowSnapshotSchema, WorkflowSchema, WorkflowVersionSchema, PageContentTypeSchema, PageAuthModeSchema, PageSnapshotSchema, PageSchema, PageVersionSchema, MetricParamSchema, MetricVariableTypeSchema, MetricFormatSchema, MetricVisualizationSchema, MetricQuerySchema, MetricVariableSchema, MetricVizConfigSchema, MetricWidgetSchema, MetricDefinitionSchema, MetricSnapshotSchema, MetricSchema, MetricVersionSchema, WorkflowRunStatusSchema, WorkflowRunSchema, ScriptRunStatusSchema, TERMINAL_SCRIPT_RUN_STATUSES, ScriptRunKindSchema, ScriptRunSchema, ScriptRunListItemSchema, ScriptRunJournalEntrySchema, WorkflowRunStepStatusSchema, WorkflowRunStepSchema, WaitModeSchema, WaitStateStatusSchema, WaitStateRowSchema, PromptTemplateScopeSchema, PromptTemplateStateSchema, PromptTemplateSchema, PromptTemplateHistorySchema, ScriptScopeSchema, ScriptFsModeSchema, ScriptRecordSchema, ScriptVersionRecordSchema, ScriptApiAuthModeSchema, ScriptApiRecordSchema, SkillTypeSchema, SkillScopeSchema, SkillSchema, AgentSkillSchema, SkillWithInstallInfoSchema, SkillFileSchema, McpServerTransportSchema, McpServerScopeSchema, McpAuthMethodSchema, McpServerSchema, AgentMcpServerSchema, McpServerWithInstallInfoSchema, ContextSnapshotEventTypeSchema, ContextFormulaSchema, ContextSnapshotSchema, BudgetScopeSchema, BudgetSchema, PricingProviderSchema, PricingTokenClassSchema, PricingRowSchema, BudgetRefusalCauseSchema, BudgetRefusalNotificationSchema, BudgetRefusedTriggerSchema, KvValueTypeSchema, KV_NAME_REGEX, KvNamespaceSchema, KvKeySchema, KvEntrySchema;
474
474
  var init_types = __esm(() => {
475
475
  init_zod();
476
476
  ModelTierSchema = _enum(["smol", "regular", "smart", "ultra"]);
477
477
  MODEL_TIERS = ModelTierSchema.options;
478
- ReasoningEffortSchema = _enum(["off", "low", "medium", "high", "xhigh"]);
478
+ ReasoningEffortSchema = _enum(["off", "low", "medium", "high", "xhigh", "max"]);
479
479
  LEGACY_MODEL_TO_TIER = {
480
480
  haiku: "smol",
481
481
  sonnet: "regular",
@@ -496,10 +496,10 @@ var init_types = __esm(() => {
496
496
  ultra: "claude-fable-5"
497
497
  },
498
498
  codex: {
499
- smol: "gpt-5.4-mini",
500
- regular: "gpt-5.4",
501
- smart: "gpt-5.5",
502
- ultra: "gpt-5.5"
499
+ smol: "gpt-5.6-luna",
500
+ regular: "gpt-5.6-terra",
501
+ smart: "gpt-5.6-sol",
502
+ ultra: "gpt-5.6-sol"
503
503
  },
504
504
  pi: {
505
505
  smol: "openrouter/deepseek/deepseek-v4-flash",
@@ -583,6 +583,12 @@ var init_types = __esm(() => {
583
583
  onCompleted: string().max(4000).optional(),
584
584
  onFailed: string().max(4000).optional()
585
585
  });
586
+ RoutingAffinitySchema = object({
587
+ sourceAgentId: uuid().optional(),
588
+ role: string().max(100).optional(),
589
+ harnessProvider: ProviderNameSchema.optional(),
590
+ capabilities: array(string()).default([])
591
+ });
586
592
  AgentTaskSchema = object({
587
593
  id: uuid(),
588
594
  agentId: uuid().nullable(),
@@ -650,7 +656,8 @@ var init_types = __esm(() => {
650
656
  providerMeta: record(string(), unknown()).optional(),
651
657
  harnessVariant: string().optional(),
652
658
  harnessVariantMeta: record(string(), unknown()).optional(),
653
- totalCostUsd: number().min(0).optional()
659
+ totalCostUsd: number().min(0).optional(),
660
+ routingAffinity: RoutingAffinitySchema.optional()
654
661
  });
655
662
  TaskAttachmentKindSchema = _enum(["agent-fs", "url", "shared-fs", "page"]);
656
663
  attachmentCommonFields = {
@@ -922,6 +929,7 @@ var init_types = __esm(() => {
922
929
  "task_accepted",
923
930
  "task_rejected",
924
931
  "task_claimed",
932
+ "task_claim_rejected_affinity",
925
933
  "task_released",
926
934
  "channel_message",
927
935
  "service_registered",
@@ -3198,6 +3206,41 @@ This work will NOT fall back to the unassigned pool — you are the only re-dele
3198
3206
  ],
3199
3207
  category: "task_lifecycle"
3200
3208
  });
3209
+ registerTemplate({
3210
+ eventType: "task.pool.starved.decision",
3211
+ header: "",
3212
+ defaultBody: `Reroute decision: a pooled task has no eligible worker.
3213
+
3214
+ Original task ID: {{original_task_id}}
3215
+ Task: "{{task_desc}}"
3216
+ Required role: {{required_role}}
3217
+ Required capabilities: {{required_capabilities}}{{artifacts_block}}
3218
+
3219
+ ## Your job
3220
+
3221
+ 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.
3222
+
3223
+ 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}}\`.
3224
+
3225
+ This work will NOT fall back to the unassigned pool — you are the only re-delegation path.`,
3226
+ variables: [
3227
+ { name: "original_task_id", description: "ID of the starved pool task" },
3228
+ { name: "task_desc", description: "Original task description (truncated to 200 chars)" },
3229
+ {
3230
+ name: "required_role",
3231
+ description: "Role declared on the task's routingAffinity, or a placeholder"
3232
+ },
3233
+ {
3234
+ name: "required_capabilities",
3235
+ description: "Comma-joined capabilities declared on the task's routingAffinity, or a placeholder"
3236
+ },
3237
+ {
3238
+ name: "artifacts_block",
3239
+ description: "Formatted attachment list from the original task, or empty string"
3240
+ }
3241
+ ],
3242
+ category: "task_lifecycle"
3243
+ });
3201
3244
  });
3202
3245
 
3203
3246
  // src/be/seed-prompt-templates.ts
@@ -3630,6 +3673,8 @@ __export(exports_db, {
3630
3673
  listAllMetrics: () => listAllMetrics,
3631
3674
  listAgentsWithCredStatusByProvider: () => listAgentsWithCredStatusByProvider,
3632
3675
  isSqliteVecAvailable: () => isSqliteVecAvailable,
3676
+ isPoolAffinityEnforcementEnabled: () => isPoolAffinityEnforcementEnabled,
3677
+ isAgentEligibleForTask: () => isAgentEligibleForTask,
3633
3678
  installSystemDefaultSkillsForAgent: () => installSystemDefaultSkillsForAgent,
3634
3679
  installSkill: () => installSkill,
3635
3680
  installMcpServer: () => installMcpServer,
@@ -3659,6 +3704,7 @@ __export(exports_db, {
3659
3704
  getUnreadMessages: () => getUnreadMessages,
3660
3705
  getUnreadInboxMessages: () => getUnreadInboxMessages,
3661
3706
  getUnassignedTasksCount: () => getUnassignedTasksCount,
3707
+ getUnassignedTaskIdsForAgent: () => getUnassignedTaskIdsForAgent,
3662
3708
  getUnassignedTaskIds: () => getUnassignedTaskIds,
3663
3709
  getUnassignedPoolTasks: () => getUnassignedPoolTasks,
3664
3710
  getTasksCount: () => getTasksCount,
@@ -3683,6 +3729,7 @@ __export(exports_db, {
3683
3729
  getStepCountForNode: () => getStepCountForNode,
3684
3730
  getStepByIdempotencyKey: () => getStepByIdempotencyKey,
3685
3731
  getStalledInProgressTasks: () => getStalledInProgressTasks,
3732
+ getStaleUnassignedAffinityTasks: () => getStaleUnassignedAffinityTasks,
3686
3733
  getStalePinnedResumes: () => getStalePinnedResumes,
3687
3734
  getSkillFiles: () => getSkillFiles,
3688
3735
  getSkillFile: () => getSkillFile,
@@ -3903,6 +3950,7 @@ __export(exports_db, {
3903
3950
  checkDependencies: () => checkDependencies,
3904
3951
  cascadeFailDependents: () => cascadeFailDependents,
3905
3952
  cancelTask: () => cancelTask,
3953
+ buildRoutingAffinityFromAgent: () => buildRoutingAffinityFromAgent,
3906
3954
  backfillSupersedeTaskResumeTaskId: () => backfillSupersedeTaskResumeTaskId,
3907
3955
  autoEncryptLegacyPlaintextSecrets: () => autoEncryptLegacyPlaintextSecrets,
3908
3956
  assignUnassignedTaskPending: () => assignUnassignedTaskPending,
@@ -4356,6 +4404,40 @@ function updateAgentStatusFromCapacity(agentId) {
4356
4404
  updateAgentStatus(agentId, newStatus);
4357
4405
  }
4358
4406
  }
4407
+ function isPoolAffinityEnforcementEnabled() {
4408
+ return process.env.POOL_AFFINITY_ENFORCEMENT !== "0";
4409
+ }
4410
+ function buildRoutingAffinityFromAgent(agentId) {
4411
+ const agent = getAgentById(agentId);
4412
+ if (!agent)
4413
+ return null;
4414
+ return {
4415
+ sourceAgentId: agent.id,
4416
+ role: agent.role,
4417
+ harnessProvider: agent.harnessProvider ?? agent.provider ?? undefined,
4418
+ capabilities: agent.capabilities ?? []
4419
+ };
4420
+ }
4421
+ function isAgentEligibleForTask(agent, task) {
4422
+ if (!isPoolAffinityEnforcementEnabled())
4423
+ return true;
4424
+ const affinity = task.routingAffinity;
4425
+ if (!affinity)
4426
+ return true;
4427
+ if (affinity.sourceAgentId && affinity.sourceAgentId === agent.id)
4428
+ return true;
4429
+ if (!agent.role || !affinity.role)
4430
+ return false;
4431
+ if (agent.role !== affinity.role)
4432
+ return false;
4433
+ const requiredCapabilities = affinity.capabilities ?? [];
4434
+ if (requiredCapabilities.length > 0) {
4435
+ const agentCapabilities = new Set(agent.capabilities ?? []);
4436
+ if (!requiredCapabilities.every((cap) => agentCapabilities.has(cap)))
4437
+ return false;
4438
+ }
4439
+ return true;
4440
+ }
4359
4441
  function rowToAgentTask(row) {
4360
4442
  let followUpConfig;
4361
4443
  if (row.followUpConfig) {
@@ -4371,6 +4453,19 @@ function rowToAgentTask(row) {
4371
4453
  followUpConfig = undefined;
4372
4454
  }
4373
4455
  }
4456
+ let routingAffinity;
4457
+ if (row.routingAffinity) {
4458
+ try {
4459
+ const parsed = RoutingAffinitySchema.safeParse(JSON.parse(row.routingAffinity));
4460
+ if (parsed.success) {
4461
+ routingAffinity = parsed.data;
4462
+ } else {
4463
+ console.warn(`[db] Ignoring invalid agent_tasks.routingAffinity for task ${row.id}:`, parsed.error.message);
4464
+ }
4465
+ } catch (error) {
4466
+ console.warn(`[db] Ignoring malformed agent_tasks.routingAffinity for task ${row.id}:`, error instanceof Error ? error.message : String(error));
4467
+ }
4468
+ }
4374
4469
  return {
4375
4470
  id: row.id,
4376
4471
  agentId: row.agentId,
@@ -4438,7 +4533,8 @@ function rowToAgentTask(row) {
4438
4533
  providerMeta: parseProviderMeta(row.provider, row.providerMeta),
4439
4534
  harnessVariant: row.harnessVariant ?? undefined,
4440
4535
  harnessVariantMeta: row.harnessVariantMeta ? JSON.parse(row.harnessVariantMeta) : undefined,
4441
- totalCostUsd: row.totalCostUsd ?? undefined
4536
+ totalCostUsd: row.totalCostUsd ?? undefined,
4537
+ routingAffinity
4442
4538
  };
4443
4539
  }
4444
4540
  function rowToAgentTaskSummary(row) {
@@ -4500,6 +4596,24 @@ function getPendingTaskForAgent(agentId) {
4500
4596
  return null;
4501
4597
  }
4502
4598
  function assignUnassignedTaskPending(taskId, agentId) {
4599
+ if (isPoolAffinityEnforcementEnabled()) {
4600
+ const task = getTaskById(taskId);
4601
+ const agent = getAgentById(agentId);
4602
+ if (task && agent && !isAgentEligibleForTask(agent, task)) {
4603
+ try {
4604
+ createLogEntry({
4605
+ eventType: "task_claim_rejected_affinity",
4606
+ agentId,
4607
+ taskId,
4608
+ metadata: {
4609
+ agentRole: agent.role ?? null,
4610
+ requiredRole: task.routingAffinity?.role ?? null
4611
+ }
4612
+ });
4613
+ } catch {}
4614
+ return null;
4615
+ }
4616
+ }
4503
4617
  const now = new Date().toISOString();
4504
4618
  const row = getDb().prepare(`UPDATE agent_tasks SET agentId = ?, status = 'pending', lastUpdatedAt = ?
4505
4619
  WHERE id = ? AND status = 'unassigned' RETURNING *`).get(agentId, now, taskId);
@@ -5591,6 +5705,9 @@ function createTaskExtended(task, options) {
5591
5705
  if (parent.followUpConfig && !options.followUpConfig) {
5592
5706
  options.followUpConfig = parent.followUpConfig;
5593
5707
  }
5708
+ if (parent.routingAffinity && !options.routingAffinity) {
5709
+ options.routingAffinity = parent.routingAffinity;
5710
+ }
5594
5711
  }
5595
5712
  }
5596
5713
  const existingTrackerWork = findExistingLinearTrackerContextWork(options?.contextKey);
@@ -5615,8 +5732,8 @@ function createTaskExtended(task, options) {
5615
5732
  vcsInstallationId, vcsNodeId,
5616
5733
  agentmailInboxId, agentmailMessageId, agentmailThreadId,
5617
5734
  mentionMessageId, mentionChannelId, dir, parentTaskId, model, modelTier, effort, scheduleId,
5618
- workflowRunId, workflowRunStepId, outputSchema, followUpConfig, requestedByUserId, contextKey, swarmVersion, createdAt, lastUpdatedAt, created_by, updated_by
5619
- ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING *`).get(id, options?.agentId ?? null, options?.creatorAgentId ?? null, task, status, options?.source ?? "mcp", options?.taskType ?? null, JSON.stringify(options?.tags ?? []), options?.priority ?? 50, JSON.stringify(options?.dependsOn ?? []), options?.offeredTo ?? null, options?.offeredTo ? now : null, options?.slackChannelId ?? null, options?.slackThreadTs ?? null, options?.slackUserId ?? null, options?.vcsProvider ?? null, options?.vcsRepo ?? null, options?.vcsEventType ?? null, options?.vcsNumber ?? null, options?.vcsCommentId ?? null, options?.vcsAuthor ?? null, options?.vcsUrl ?? null, options?.vcsInstallationId ?? null, options?.vcsNodeId ?? null, options?.agentmailInboxId ?? null, options?.agentmailMessageId ?? null, options?.agentmailThreadId ?? null, options?.mentionMessageId ?? null, options?.mentionChannelId ?? null, options?.dir ?? null, options?.parentTaskId ?? null, options?.model ?? null, options?.modelTier ?? null, options?.effort ?? null, options?.scheduleId ?? null, options?.workflowRunId ?? null, options?.workflowRunStepId ?? null, options?.outputSchema ? JSON.stringify(options.outputSchema) : null, options?.followUpConfig ? JSON.stringify(options.followUpConfig) : null, options?.requestedByUserId ?? null, options?.contextKey ?? null, package_default.version, now, now, auditUserId, auditUserId);
5735
+ workflowRunId, workflowRunStepId, outputSchema, followUpConfig, requestedByUserId, contextKey, routingAffinity, swarmVersion, createdAt, lastUpdatedAt, created_by, updated_by
5736
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING *`).get(id, options?.agentId ?? null, options?.creatorAgentId ?? null, task, status, options?.source ?? "mcp", options?.taskType ?? null, JSON.stringify(options?.tags ?? []), options?.priority ?? 50, JSON.stringify(options?.dependsOn ?? []), options?.offeredTo ?? null, options?.offeredTo ? now : null, options?.slackChannelId ?? null, options?.slackThreadTs ?? null, options?.slackUserId ?? null, options?.vcsProvider ?? null, options?.vcsRepo ?? null, options?.vcsEventType ?? null, options?.vcsNumber ?? null, options?.vcsCommentId ?? null, options?.vcsAuthor ?? null, options?.vcsUrl ?? null, options?.vcsInstallationId ?? null, options?.vcsNodeId ?? null, options?.agentmailInboxId ?? null, options?.agentmailMessageId ?? null, options?.agentmailThreadId ?? null, options?.mentionMessageId ?? null, options?.mentionChannelId ?? null, options?.dir ?? null, options?.parentTaskId ?? null, options?.model ?? null, options?.modelTier ?? null, options?.effort ?? null, options?.scheduleId ?? null, options?.workflowRunId ?? null, options?.workflowRunStepId ?? null, options?.outputSchema ? JSON.stringify(options.outputSchema) : null, options?.followUpConfig ? JSON.stringify(options.followUpConfig) : null, options?.requestedByUserId ?? null, options?.contextKey ?? null, options?.routingAffinity ? JSON.stringify(options.routingAffinity) : null, package_default.version, now, now, auditUserId, auditUserId);
5620
5737
  if (!row)
5621
5738
  throw new Error("Failed to create task");
5622
5739
  try {
@@ -5651,6 +5768,24 @@ function createTaskExtended(task, options) {
5651
5768
  return rowToAgentTask(row);
5652
5769
  }
5653
5770
  function claimTask(taskId, agentId) {
5771
+ if (isPoolAffinityEnforcementEnabled()) {
5772
+ const task = getTaskById(taskId);
5773
+ const agent = getAgentById(agentId);
5774
+ if (task && agent && !isAgentEligibleForTask(agent, task)) {
5775
+ try {
5776
+ createLogEntry({
5777
+ eventType: "task_claim_rejected_affinity",
5778
+ agentId,
5779
+ taskId,
5780
+ metadata: {
5781
+ agentRole: agent.role ?? null,
5782
+ requiredRole: task.routingAffinity?.role ?? null
5783
+ }
5784
+ });
5785
+ } catch {}
5786
+ return null;
5787
+ }
5788
+ }
5654
5789
  const now = new Date().toISOString();
5655
5790
  const row = getDb().prepare(`UPDATE agent_tasks SET agentId = ?, status = 'in_progress', lastUpdatedAt = ?
5656
5791
  WHERE id = ? AND status = 'unassigned' RETURNING *`).get(agentId, now, taskId);
@@ -5822,6 +5957,31 @@ function getUnassignedTaskIds(limit = 10) {
5822
5957
  const rows = getDb().prepare("SELECT id FROM agent_tasks WHERE status = 'unassigned' ORDER BY priority DESC, createdAt ASC, rowid ASC LIMIT ?").all(limit);
5823
5958
  return rows.map((r) => r.id);
5824
5959
  }
5960
+ function getUnassignedTaskIdsForAgent(agentId, limit = 10) {
5961
+ const agent = getAgentById(agentId);
5962
+ if (!agent)
5963
+ return [];
5964
+ const batchSize = Math.max(limit * 5, ELIGIBILITY_SCAN_BATCH_SIZE);
5965
+ const eligible = [];
5966
+ let offset = 0;
5967
+ while (eligible.length < limit && offset < ELIGIBILITY_SCAN_CAP) {
5968
+ const rows = getDb().prepare("SELECT * FROM agent_tasks WHERE status = 'unassigned' ORDER BY priority DESC, createdAt ASC, rowid ASC LIMIT ? OFFSET ?").all(batchSize, offset);
5969
+ if (rows.length === 0)
5970
+ break;
5971
+ for (const row of rows) {
5972
+ const task = rowToAgentTask(row);
5973
+ if (isAgentEligibleForTask(agent, task)) {
5974
+ eligible.push(task.id);
5975
+ if (eligible.length >= limit)
5976
+ break;
5977
+ }
5978
+ }
5979
+ offset += rows.length;
5980
+ if (rows.length < batchSize)
5981
+ break;
5982
+ }
5983
+ return eligible;
5984
+ }
5825
5985
  function checkDependencies(taskId) {
5826
5986
  const task = getTaskById(taskId);
5827
5987
  if (!task || !task.dependsOn || task.dependsOn.length === 0) {
@@ -7218,8 +7378,11 @@ function getStalledInProgressTasks(thresholdMinutes = 30) {
7218
7378
  function getStalePinnedResumes(graceMin) {
7219
7379
  const cutoff = new Date(Date.now() - graceMin * 60 * 1000).toISOString();
7220
7380
  return getDb().prepare(`SELECT * FROM agent_tasks
7221
- WHERE taskType = 'resume' AND status = 'pending'
7222
- AND (tags LIKE '%"crash-recovery-pin"%' OR tags LIKE '%"graceful-shutdown-pin"%')
7381
+ WHERE status = 'pending'
7382
+ AND (
7383
+ (taskType = 'resume' AND (tags LIKE '%"crash-recovery-pin"%' OR tags LIKE '%"graceful-shutdown-pin"%'))
7384
+ OR tags LIKE '%"reboot-retry-pin"%'
7385
+ )
7223
7386
  AND createdAt < ?
7224
7387
  ORDER BY createdAt ASC`).all(cutoff).map(rowToAgentTask);
7225
7388
  }
@@ -7250,11 +7413,16 @@ function getIdleWorkersWithCapacity() {
7250
7413
  return activeCount < (agent.maxTasks ?? 1);
7251
7414
  });
7252
7415
  }
7253
- function getUnassignedPoolTasks(limit = 10) {
7416
+ function getUnassignedPoolTasks(limit = 10, offset = 0) {
7254
7417
  return getDb().prepare(`SELECT * FROM agent_tasks
7255
7418
  WHERE status = 'unassigned'
7256
- ORDER BY priority DESC, createdAt ASC
7257
- LIMIT ?`).all(limit).map(rowToAgentTask);
7419
+ ORDER BY priority DESC, createdAt ASC, rowid ASC
7420
+ LIMIT ? OFFSET ?`).all(limit, offset).map(rowToAgentTask);
7421
+ }
7422
+ function getStaleUnassignedAffinityTasks(cutoffIso) {
7423
+ return getDb().prepare(`SELECT * FROM agent_tasks
7424
+ WHERE status = 'unassigned' AND routingAffinity IS NOT NULL AND createdAt < ?
7425
+ ORDER BY createdAt ASC`).all(cutoffIso).map(rowToAgentTask);
7258
7426
  }
7259
7427
  function getRecentFailedTasks(hours = 6) {
7260
7428
  const since = new Date(Date.now() - hours * 60 * 60 * 1000).toISOString();
@@ -10028,7 +10196,7 @@ function countScriptRunJournalAgentTaskSteps(runId) {
10028
10196
  const row = getDb().prepare("SELECT COUNT(*) AS count FROM script_run_journal WHERE runId = ? AND stepType = 'agent-task'").get(runId);
10029
10197
  return row?.count ?? 0;
10030
10198
  }
10031
- var db = null, sqliteVecAvailable = false, VERSIONABLE_FIELDS, agentQueries, MAX_EMPTY_POLLS = 2, taskQueries, findTaskByGitHub, LINEAR_TRACKER_CONTEXT_KEY_PREFIX = "task:trackers:linear:", logQueries, sessionLogQueries, sessionCostQueries, SCHEDULE_TEMPLATE_PREVIEW_LENGTH = 280, TASK_PREVIEW_LENGTH = 300, RESERVED_CONFIG_PLACEHOLDER = "[reserved key stored in swarm_config; delete this row]", SKILL_FILE_LIMITS, BINARY_SKILL_FILE_PLACEHOLDER = "[binary file - not synced]", SKILL_SLIM_COLUMNS = "id, name, description, type, scope, ownerAgentId, sourceUrl, sourceRepo, sourcePath, sourceBranch, sourceHash, isComplex, allowedTools, model, effort, context, agent, disableModelInvocation, userInvocable, version, isEnabled, systemDefault, createdAt, lastUpdatedAt, lastFetchedAt, '' as content", contextSnapshotQueries, KvTypeCollisionError;
10199
+ var db = null, sqliteVecAvailable = false, VERSIONABLE_FIELDS, agentQueries, MAX_EMPTY_POLLS = 2, taskQueries, findTaskByGitHub, LINEAR_TRACKER_CONTEXT_KEY_PREFIX = "task:trackers:linear:", logQueries, ELIGIBILITY_SCAN_BATCH_SIZE, ELIGIBILITY_SCAN_CAP, sessionLogQueries, sessionCostQueries, SCHEDULE_TEMPLATE_PREVIEW_LENGTH = 280, TASK_PREVIEW_LENGTH = 300, RESERVED_CONFIG_PLACEHOLDER = "[reserved key stored in swarm_config; delete this row]", SKILL_FILE_LIMITS, BINARY_SKILL_FILE_PLACEHOLDER = "[binary file - not synced]", SKILL_SLIM_COLUMNS = "id, name, description, type, scope, ownerAgentId, sourceUrl, sourceRepo, sourcePath, sourceBranch, sourceHash, isComplex, allowedTools, model, effort, context, agent, disableModelInvocation, userInvocable, version, isEnabled, systemDefault, createdAt, lastUpdatedAt, lastFetchedAt, '' as content", contextSnapshotQueries, KvTypeCollisionError;
10032
10200
  var init_db = __esm(() => {
10033
10201
  init_provider_metadata();
10034
10202
  init_package();
@@ -10088,6 +10256,8 @@ var init_db = __esm(() => {
10088
10256
  getByEventType: () => getDb().prepare("SELECT * FROM agent_log WHERE eventType = ? ORDER BY createdAt DESC"),
10089
10257
  getAll: () => getDb().prepare("SELECT * FROM agent_log ORDER BY createdAt DESC")
10090
10258
  };
10259
+ ELIGIBILITY_SCAN_BATCH_SIZE = Number(process.env.ELIGIBILITY_SCAN_BATCH_SIZE) || 25;
10260
+ ELIGIBILITY_SCAN_CAP = Number(process.env.ELIGIBILITY_SCAN_CAP) || 500;
10091
10261
  sessionLogQueries = {
10092
10262
  insert: () => getDb().prepare(`INSERT INTO session_logs (id, taskId, sessionId, iteration, cli, content, lineNumber, createdAt)
10093
10263
  VALUES (?, ?, ?, ?, ?, ?, ?, strftime('%Y-%m-%dT%H:%M:%fZ', 'now')) RETURNING *`),
@@ -10136,4 +10306,4 @@ var init_db = __esm(() => {
10136
10306
  };
10137
10307
  });
10138
10308
 
10139
- export { interpolate, deepInterpolate, init_template, registerTemplate, getTemplateDefinition, getAllTemplateDefinitions, init_registry, configureHttpResolver, resolveTemplate, resolveTemplateAsync, init_resolver, initTelemetry, telemetry, init_telemetry, ModelTierSchema, ReasoningEffortSchema, splitLegacyModelAlias, resolveTaskModelSelection, AgentTaskStatusSchema, isTerminalTaskStatus, AgentTaskSourceSchema, ProviderNameSchema, FollowUpConfigSchema, AgentTaskSchema, AttachmentInputSchema, TaskAttachmentSchema, InboxItemTypeSchema, InboxItemStatusSchema, FavoriteItemTypeSchema, TaskTemplateKindSchema, AgentSchema, AgentLatestModelSchema, AgentCredStatusSchema, ChannelTypeSchema, ChannelSchema, ChannelMessageSchema, ServiceStatusSchema, ServiceSchema, ResumeReasonSchema, AgentLogSchema, EventCategorySchema, EventStatusSchema, EventSourceSchema, EventNameSchema, ScheduledTaskTargetTypeSchema, SwarmConfigScopeSchema, SwarmConfigSchema, RepoGuidelinesSchema, RepoHooksSchema, SwarmRepoSchema, AgentMemoryScopeSchema, AgentMemorySourceSchema, AgentMemorySchema, WorkflowDefinitionSchema, WorkflowNodePatchSchema, WorkflowPatchSchema, TriggerConfigSchema, CooldownConfigSchema, InputValueSchema, PageContentTypeSchema, PageAuthModeSchema, MetricDefinitionSchema, MetricVersionSchema, WorkflowRunStatusSchema, ScriptRunStatusSchema, TERMINAL_SCRIPT_RUN_STATUSES, PromptTemplateScopeSchema, PromptTemplateStateSchema, PromptTemplateSchema, PromptTemplateHistorySchema, ScriptScopeSchema, ScriptFsModeSchema, ScriptApiAuthModeSchema, ContextSnapshotEventTypeSchema, ContextFormulaSchema, BudgetScopeSchema, BudgetSchema, PricingProviderSchema, PricingTokenClassSchema, PricingRowSchema, BudgetRefusalCauseSchema, BudgetRefusalNotificationSchema, KvValueTypeSchema, KvNamespaceSchema, KvKeySchema, KvEntrySchema, init_types, setRequestAuth, getRequestAuth, getCurrentRequestAuth, init_request_auth_context, encryptSecret, decryptSecret, getEncryptionKey, init_crypto, normalizeDate, normalizeDateRequired, init_date_utils, init_session_templates, init_templates, init_templates2 as init_templates1, isReservedConfigKey, reservedKeyError, validateConfigValue, init_swarm_config_guard, onTaskStarted, init_task_lifecycle_events, generateDefaultClaudeMd, generateDefaultSoulMd, generateDefaultIdentityMd, generateDefaultToolsMd, init_defaults, isSqliteVecAvailable, initDb, getDb, closeDb, computeContentHash, createContextVersion, getLatestContextVersion, getContextVersion, getContextVersionHistory, agentQueries, updateAgentCredentialState, createAgent, getAgentById, getAllAgents, getLeadAgent, updateAgentStatus, updateAgentMaxTasks, updateAgentProvider, setAgentHarnessProvider, updateAgentCredStatus, listAgentsWithCredStatusByProvider, getAgentHarnessProviders, updateAgentActivity, MAX_EMPTY_POLLS, incrementEmptyPollCount, resetEmptyPollCount, shouldBlockPolling, deleteAgent, getActiveTaskCount, hasCapacity, getRemainingCapacity, updateAgentStatusFromCapacity, taskQueries, createTask, getPendingTaskForAgent, assignUnassignedTaskPending, startTask, getTaskById, markTaskSlackReplySent, setSlackMessageTracking, getChildTasks, hasNonTerminalResumeChild, hasNonTerminalRerouteDecisionChild, updateTaskClaudeSessionId, updateTaskVcs, getTasksByAgentId, getAgentCurrentTask, getTasksByStatus, findTaskByVcs, findTaskByGitHub, getAllTasks, getTasksCount, getTaskStats, getCompletedSlackTasks, getRecentlyFinishedWorkerTasks, markTasksNotified, resetTasksNotified, getInProgressSlackTasks, getInProgressTasksByContextKey, findExistingLinearTrackerContextWork, getLatestTaskByContextKey, getAgentWorkingOnThread, getLatestActiveTaskInThread, getMostRecentTaskInThread, findCompletedTaskInThread, findRecentCancelledTaskInThread, completeTask, failTask, cancelTask, supersedeTask, backfillSupersedeTaskResumeTaskId, pauseTask, resumeTask, getPausedTasksForAgent, getOrphanedInProgressTasksForAgent, resetOrphanedInProgressTasksForAgent, getRecentlyCancelledTasksForAgent, deleteTask, updateTaskProgress, insertTaskAttachment, deleteTaskAttachment, replaceTaskAttachment, getTaskAttachments, getAgentWithTasks, getAllAgentsWithTasks, logQueries, createLogEntry, getLogsByAgentId, getLogsByTaskId, getLogsByTaskIdChronological, getLogsByEventType, getAllLogs, findRecentSimilarTasks, createTaskExtended, claimTask, releaseTask, acceptTask, rejectTask, moveTaskToBacklog, moveTaskFromBacklog, releaseStaleReviewingTasks, getOfferedTasksForAgent, claimOfferedTask, getUnassignedTasksCount, getUnassignedTaskIds, checkDependencies, getDependentTasks, cascadeFailDependents, updateAgentProfile, updateAgentName, createChannel, getMessageById, getChannelById, getChannelByName, getAllChannels, deleteChannel, postMessage, getChannelMessages, updateReadState, getLastReadAt, getUnreadMessages, getMentionsForAgent, getInboxSummary, claimMentions, releaseMentionProcessing, releaseStaleMentionProcessing, createService, getServiceById, getServiceByAgentAndName, getServicesByAgentId, getAllServices, updateServiceStatus, deleteService, upsertService, deleteServicesByAgentId, sessionLogQueries, createSessionLogs, getSessionLogsByTaskId, getSessionLogsBySession, createSessionCost, getSessionCostsByTaskId, getSessionCostsByAgentId, getAllSessionCosts, getSessionCostsFiltered, getSessionCostSummary, getDashboardCostSummary, createInboxMessage, getInboxMessageById, getUnreadInboxMessages, claimInboxMessages, markInboxMessageRead, markInboxMessageResponded, markInboxMessageDelegated, releaseStaleProcessingInbox, getConcurrentContext, getScheduledTasks, getScheduledTaskById, getScheduledTaskByName, createScheduledTask, updateScheduledTask, deleteScheduledTask, getDueScheduledTasks, autoEncryptLegacyPlaintextSecrets, maskSecrets, getSwarmConfigs, getInjectableGlobalConfigs, getSwarmConfigById, getSwarmConfigLookupById, upsertSwarmConfig, deleteSwarmConfig, deleteSwarmConfigByKey, getResolvedConfig, getSwarmRepos, getSwarmRepoById, getSwarmRepoByName, getSwarmRepoByUrl, createSwarmRepo, updateSwarmRepo, deleteSwarmRepo, getAgentMailInboxMapping, getAgentMailInboxMappingsByAgent, getAllAgentMailInboxMappings, createAgentMailInboxMapping, deleteAgentMailInboxMapping, findTaskByAgentMailThread, insertActiveSession, deleteActiveSession, deleteActiveSessionById, getActiveSessions, heartbeatActiveSession, cleanupStaleSessions, cleanupAgentSessions, updateActiveSessionProviderSessionId, getActiveSessionForTask, reassociateSessionLogs, getStalledInProgressTasks, getStalePinnedResumes, failPendingResumeIfUnclaimed, getIdleWorkersWithCapacity, getUnassignedPoolTasks, getRecentFailedTasks, getRecentCompletedCount, getRecentFailedCount, createWorkflow, getWorkflow, listWorkflows, updateWorkflow, deleteWorkflow, getWorkflowsByScheduleId, createWorkflowRun, getWorkflowRun, updateWorkflowRun, listWorkflowRuns, createWorkflowRunStep, getWorkflowRunStep, updateWorkflowRunStep, getWorkflowRunStepsByRunId, getStuckWorkflowRuns, getLastSuccessfulRun, getLastRunStart, getRetryableSteps, getCompletedStepNodeIds, getTaskByWorkflowRunStepId, getStepByIdempotencyKey, getStepCountForNode, getLatestStepForNode, createWorkflowVersion, getWorkflowVersions, getWorkflowVersion, 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, listUserFavorites, getFavoriteItemIdSet, 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, upsertKv, deleteKv, KvTypeCollisionError, incrKv, listKv, countKv, createScriptRun, recordInlineScriptRun, getScriptRun, getScriptRunByIdempotencyKey, listScriptRuns, countScriptRuns, countActiveScriptRuns, updateScriptRun, getRunningScriptRuns, getScriptRunJournalStep, upsertScriptRunJournalStep, listScriptRunJournalSteps, countScriptRunJournalSteps, countScriptRunJournalAgentTaskSteps, exports_db, init_db };
10309
+ export { interpolate, deepInterpolate, init_template, registerTemplate, getTemplateDefinition, getAllTemplateDefinitions, init_registry, configureHttpResolver, resolveTemplate, resolveTemplateAsync, init_resolver, initTelemetry, telemetry, init_telemetry, ModelTierSchema, ReasoningEffortSchema, splitLegacyModelAlias, resolveTaskModelSelection, AgentTaskStatusSchema, isTerminalTaskStatus, AgentTaskSourceSchema, ProviderNameSchema, FollowUpConfigSchema, AgentTaskSchema, AttachmentInputSchema, TaskAttachmentSchema, InboxItemTypeSchema, InboxItemStatusSchema, FavoriteItemTypeSchema, TaskTemplateKindSchema, AgentSchema, AgentLatestModelSchema, AgentCredStatusSchema, ChannelTypeSchema, ChannelSchema, ChannelMessageSchema, ServiceStatusSchema, ServiceSchema, ResumeReasonSchema, AgentLogSchema, EventCategorySchema, EventStatusSchema, EventSourceSchema, EventNameSchema, ScheduledTaskTargetTypeSchema, SwarmConfigScopeSchema, SwarmConfigSchema, RepoGuidelinesSchema, RepoHooksSchema, SwarmRepoSchema, AgentMemoryScopeSchema, AgentMemorySourceSchema, AgentMemorySchema, WorkflowDefinitionSchema, WorkflowNodePatchSchema, WorkflowPatchSchema, TriggerConfigSchema, CooldownConfigSchema, InputValueSchema, PageContentTypeSchema, PageAuthModeSchema, MetricDefinitionSchema, MetricVersionSchema, WorkflowRunStatusSchema, ScriptRunStatusSchema, TERMINAL_SCRIPT_RUN_STATUSES, PromptTemplateScopeSchema, PromptTemplateStateSchema, PromptTemplateSchema, PromptTemplateHistorySchema, ScriptScopeSchema, ScriptFsModeSchema, ScriptApiAuthModeSchema, ContextSnapshotEventTypeSchema, ContextFormulaSchema, BudgetScopeSchema, BudgetSchema, PricingProviderSchema, PricingTokenClassSchema, PricingRowSchema, BudgetRefusalCauseSchema, BudgetRefusalNotificationSchema, KvValueTypeSchema, KvNamespaceSchema, KvKeySchema, KvEntrySchema, init_types, setRequestAuth, getRequestAuth, getCurrentRequestAuth, init_request_auth_context, encryptSecret, decryptSecret, getEncryptionKey, init_crypto, normalizeDate, normalizeDateRequired, init_date_utils, init_session_templates, init_templates, init_templates2 as init_templates1, isReservedConfigKey, reservedKeyError, validateConfigValue, init_swarm_config_guard, onTaskStarted, init_task_lifecycle_events, generateDefaultClaudeMd, generateDefaultSoulMd, generateDefaultIdentityMd, generateDefaultToolsMd, init_defaults, isSqliteVecAvailable, initDb, getDb, closeDb, computeContentHash, createContextVersion, getLatestContextVersion, getContextVersion, getContextVersionHistory, agentQueries, updateAgentCredentialState, createAgent, getAgentById, getAllAgents, getLeadAgent, updateAgentStatus, updateAgentMaxTasks, updateAgentProvider, setAgentHarnessProvider, updateAgentCredStatus, listAgentsWithCredStatusByProvider, getAgentHarnessProviders, updateAgentActivity, MAX_EMPTY_POLLS, incrementEmptyPollCount, resetEmptyPollCount, shouldBlockPolling, deleteAgent, getActiveTaskCount, hasCapacity, getRemainingCapacity, updateAgentStatusFromCapacity, isPoolAffinityEnforcementEnabled, buildRoutingAffinityFromAgent, isAgentEligibleForTask, taskQueries, createTask, getPendingTaskForAgent, assignUnassignedTaskPending, startTask, getTaskById, markTaskSlackReplySent, setSlackMessageTracking, getChildTasks, hasNonTerminalResumeChild, hasNonTerminalRerouteDecisionChild, updateTaskClaudeSessionId, updateTaskVcs, getTasksByAgentId, getAgentCurrentTask, getTasksByStatus, findTaskByVcs, findTaskByGitHub, getAllTasks, getTasksCount, getTaskStats, getCompletedSlackTasks, getRecentlyFinishedWorkerTasks, markTasksNotified, resetTasksNotified, getInProgressSlackTasks, getInProgressTasksByContextKey, findExistingLinearTrackerContextWork, getLatestTaskByContextKey, getAgentWorkingOnThread, getLatestActiveTaskInThread, getMostRecentTaskInThread, findCompletedTaskInThread, findRecentCancelledTaskInThread, completeTask, failTask, cancelTask, supersedeTask, backfillSupersedeTaskResumeTaskId, pauseTask, resumeTask, getPausedTasksForAgent, getOrphanedInProgressTasksForAgent, resetOrphanedInProgressTasksForAgent, getRecentlyCancelledTasksForAgent, deleteTask, updateTaskProgress, insertTaskAttachment, deleteTaskAttachment, replaceTaskAttachment, getTaskAttachments, getAgentWithTasks, getAllAgentsWithTasks, logQueries, createLogEntry, getLogsByAgentId, getLogsByTaskId, getLogsByTaskIdChronological, getLogsByEventType, getAllLogs, findRecentSimilarTasks, createTaskExtended, claimTask, releaseTask, acceptTask, rejectTask, moveTaskToBacklog, moveTaskFromBacklog, releaseStaleReviewingTasks, getOfferedTasksForAgent, claimOfferedTask, getUnassignedTasksCount, getUnassignedTaskIds, getUnassignedTaskIdsForAgent, checkDependencies, getDependentTasks, cascadeFailDependents, updateAgentProfile, updateAgentName, createChannel, getMessageById, getChannelById, getChannelByName, getAllChannels, deleteChannel, postMessage, getChannelMessages, updateReadState, getLastReadAt, getUnreadMessages, getMentionsForAgent, getInboxSummary, claimMentions, releaseMentionProcessing, releaseStaleMentionProcessing, createService, getServiceById, getServiceByAgentAndName, getServicesByAgentId, getAllServices, updateServiceStatus, deleteService, upsertService, deleteServicesByAgentId, sessionLogQueries, createSessionLogs, getSessionLogsByTaskId, getSessionLogsBySession, createSessionCost, getSessionCostsByTaskId, getSessionCostsByAgentId, getAllSessionCosts, getSessionCostsFiltered, getSessionCostSummary, getDashboardCostSummary, createInboxMessage, getInboxMessageById, getUnreadInboxMessages, claimInboxMessages, markInboxMessageRead, markInboxMessageResponded, markInboxMessageDelegated, releaseStaleProcessingInbox, getConcurrentContext, getScheduledTasks, getScheduledTaskById, getScheduledTaskByName, createScheduledTask, updateScheduledTask, deleteScheduledTask, getDueScheduledTasks, autoEncryptLegacyPlaintextSecrets, maskSecrets, getSwarmConfigs, getInjectableGlobalConfigs, getSwarmConfigById, getSwarmConfigLookupById, upsertSwarmConfig, deleteSwarmConfig, deleteSwarmConfigByKey, getResolvedConfig, getSwarmRepos, getSwarmRepoById, getSwarmRepoByName, getSwarmRepoByUrl, createSwarmRepo, updateSwarmRepo, deleteSwarmRepo, getAgentMailInboxMapping, getAgentMailInboxMappingsByAgent, getAllAgentMailInboxMappings, createAgentMailInboxMapping, deleteAgentMailInboxMapping, findTaskByAgentMailThread, insertActiveSession, deleteActiveSession, deleteActiveSessionById, getActiveSessions, heartbeatActiveSession, cleanupStaleSessions, cleanupAgentSessions, updateActiveSessionProviderSessionId, getActiveSessionForTask, reassociateSessionLogs, getStalledInProgressTasks, getStalePinnedResumes, failPendingResumeIfUnclaimed, getIdleWorkersWithCapacity, getUnassignedPoolTasks, getStaleUnassignedAffinityTasks, getRecentFailedTasks, getRecentCompletedCount, getRecentFailedCount, createWorkflow, getWorkflow, listWorkflows, updateWorkflow, deleteWorkflow, getWorkflowsByScheduleId, createWorkflowRun, getWorkflowRun, updateWorkflowRun, listWorkflowRuns, createWorkflowRunStep, getWorkflowRunStep, updateWorkflowRunStep, getWorkflowRunStepsByRunId, getStuckWorkflowRuns, getLastSuccessfulRun, getLastRunStart, getRetryableSteps, getCompletedStepNodeIds, getTaskByWorkflowRunStepId, getStepByIdempotencyKey, getStepCountForNode, getLatestStepForNode, createWorkflowVersion, getWorkflowVersions, getWorkflowVersion, 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, listUserFavorites, getFavoriteItemIdSet, 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, upsertKv, deleteKv, KvTypeCollisionError, incrKv, listKv, countKv, createScriptRun, recordInlineScriptRun, getScriptRun, getScriptRunByIdempotencyKey, listScriptRuns, countScriptRuns, countActiveScriptRuns, updateScriptRun, getRunningScriptRuns, getScriptRunJournalStep, upsertScriptRunJournalStep, listScriptRunJournalSteps, countScriptRunJournalSteps, countScriptRunJournalAgentTaskSteps, exports_db, init_db };