@desplega.ai/agent-swarm 1.148.0 → 1.149.1

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 (191) hide show
  1. package/README.md +2 -1
  2. package/dist/{acp-adapter-grez7xhd.js → acp-adapter-vhkzfpjg.js} +12 -5
  3. package/dist/{actions-kweznh5a.js → actions-9d2694yk.js} +10 -9
  4. package/dist/{app-5fvvjv9m.js → app-fq2ggynt.js} +6 -6
  5. package/dist/{assistant-40m4w50s.js → assistant-edb6n9nn.js} +13 -11
  6. package/dist/{boot-reembed-9rxmb26n.js → boot-reembed-msweabbp.js} +8 -8
  7. package/dist/{boot-reembed-cn357y5n.js → boot-reembed-q5wd3tha.js} +7 -7
  8. package/dist/{boot-scrub-logs-5tpp0x3y.js → boot-scrub-logs-3g1az933.js} +5 -5
  9. package/dist/{claude-adapter-9pz5q2pb.js → claude-adapter-v3rnzsdc.js} +9 -9
  10. package/dist/{claude-managed-adapter-sactwn31.js → claude-managed-adapter-qvsmh6mv.js} +2 -2
  11. package/dist/{claude-sdk-session-v8w0s7qm.js → claude-sdk-session-qxrpsna1.js} +9 -9
  12. package/dist/{cli-cdjezzc7.js → cli-01g3x1ca.js} +8 -5
  13. package/dist/{cli-y6b6fb76.js → cli-08b07b4r.js} +1 -1
  14. package/dist/{cli-8fc8de14.js → cli-0z2v4nhw.js} +1 -1
  15. package/dist/{cli-qy6h009w.js → cli-1c94wvcw.js} +7 -6
  16. package/dist/{cli-kpv03zhj.js → cli-3apbzgyk.js} +27 -15
  17. package/dist/{cli-dk3me3qs.js → cli-3sysyjve.js} +8 -8
  18. package/dist/{cli-kzvhgvk3.js → cli-3z634pqe.js} +3 -3
  19. package/dist/{cli-n9grk3yd.js → cli-4260r1tg.js} +37 -26
  20. package/dist/{cli-d8brzxjb.js → cli-4wtq5jjv.js} +2 -2
  21. package/dist/{cli-0amc6myn.js → cli-5m0qmvdp.js} +1 -1
  22. package/dist/{cli-ct0et58h.js → cli-5my3bjsd.js} +1 -1
  23. package/dist/{cli-cn6mmc7f.js → cli-6664w7y4.js} +1 -1
  24. package/dist/{cli-hzhhrt7b.js → cli-6skz3rk8.js} +1 -1
  25. package/dist/{cli-v3e51x7w.js → cli-73gq0zxn.js} +3 -3
  26. package/dist/{cli-9216xm24.js → cli-7evafqvy.js} +20 -20
  27. package/dist/{cli-56y3hch2.js → cli-7fehefdf.js} +133 -22
  28. package/dist/{cli-hp2est46.js → cli-7xx10h0a.js} +3 -3
  29. package/dist/{cli-n2cwscdd.js → cli-9br8ypfv.js} +2 -2
  30. package/dist/{cli-7gn7c2af.js → cli-ayvy5kde.js} +1 -1
  31. package/dist/{cli-dcem3pr1.js → cli-cd60fv6j.js} +2 -2
  32. package/dist/{cli-p73drk6p.js → cli-cv7s5zdq.js} +167 -40
  33. package/dist/{cli-f8j56xv2.js → cli-ddfw1mc4.js} +53 -13
  34. package/dist/{cli-anedxf1w.js → cli-e06a8a7y.js} +1 -1
  35. package/dist/{cli-tebsjpk7.js → cli-hzqmgcm2.js} +2 -2
  36. package/dist/{cli-xqcpg1st.js → cli-j4d4f6hv.js} +1 -1
  37. package/dist/{cli-rvqz34y5.js → cli-jecc01cb.js} +1 -1
  38. package/dist/{cli-5khqvvnq.js → cli-jezx9b9c.js} +2 -2
  39. package/dist/{cli-m1p5cysp.js → cli-k351hv5k.js} +3 -3
  40. package/dist/{cli-6s2y152y.js → cli-qgd4sqz5.js} +286 -11
  41. package/dist/{cli-xqcq9y5e.js → cli-r2ap2czm.js} +1 -0
  42. package/dist/{cli-hz8xhefy.js → cli-sdzq01t9.js} +4 -4
  43. package/dist/{cli-0er5m69z.js → cli-svbrpf5q.js} +4 -4
  44. package/dist/{cli-brxyat7h.js → cli-tg8qj8ee.js} +5 -5
  45. package/dist/{cli-ztn0ga15.js → cli-wby1xnnb.js} +1 -1
  46. package/dist/{cli-0b6y7kxm.js → cli-xm87hzbw.js} +1 -1
  47. package/dist/{cli-3n7cbfjn.js → cli-y3pq4v9g.js} +6 -2
  48. package/dist/{cli-m9sxbkhm.js → cli-zvz62chv.js} +3 -3
  49. package/dist/cli.js +14 -14
  50. package/dist/{codex-adapter-ehhj2qwc.js → codex-adapter-jyw7a91z.js} +4 -4
  51. package/dist/{codex-hook-bw8p5nh4.js → codex-hook-hfrt9shr.js} +2 -2
  52. package/dist/{codex-session-runner-5hne566k.js → codex-session-runner-bmngj0s5.js} +4 -4
  53. package/dist/{commands-xnvh951h.js → commands-n755g391.js} +5 -5
  54. package/dist/{db-ycr5zfr4.js → db-s1cgh5gv.js} +5 -5
  55. package/dist/{e2b-6hb103d8.js → e2b-p04vmtx0.js} +1 -1
  56. package/dist/{handlers-1vt77kgq.js → handlers-nsg0bcye.js} +14 -11
  57. package/dist/{hook-91ntpmff.js → hook-h9cqrm8q.js} +7 -7
  58. package/dist/{hook-qfwjydvn.js → hook-jf0xe8zh.js} +8 -8
  59. package/dist/{http-h6g7bv5b.js → http-nc6pydw5.js} +96 -45
  60. package/dist/{index-d2mytx95.js → index-0wdy6gwc.js} +13 -13
  61. package/dist/{index-antf9t4p.js → index-769nc012.js} +14 -14
  62. package/dist/{index-47ghesbn.js → index-ezxkds2n.js} +575 -152
  63. package/dist/{index-0ez2aack.js → index-x1zcj09z.js} +15 -15
  64. package/dist/{keepalive-c4sp7yvd.js → keepalive-nesm3xb6.js} +7 -7
  65. package/dist/{lead-4r7z9e8v.js → lead-bwy6t2za.js} +32 -32
  66. package/dist/{maintenance-yqjfdjas.js → maintenance-8w393zf0.js} +8 -8
  67. package/dist/{oauth-refresh-sweep-wtqgnh3c.js → oauth-refresh-sweep-sh8xjy08.js} +6 -6
  68. package/dist/{onboard-a4krmh46.js → onboard-25ps29h1.js} +4 -3
  69. package/dist/{opencode-adapter-fef1mrn2.js → opencode-adapter-dce4wskd.js} +2 -2
  70. package/dist/{otel-impl-725kq0vp.js → otel-impl-b93gxnz5.js} +2 -2
  71. package/dist/{pi-mono-adapter-2has4gnp.js → pi-mono-adapter-zvshk5cj.js} +2 -2
  72. package/dist/{pricing-refresh-kqxd7w9h.js → pricing-refresh-5v56x7gb.js} +7 -7
  73. package/dist/{rbac-roles-t3wygpth.js → rbac-roles-0p0s6pbj.js} +6 -6
  74. package/dist/{rbac-roles-gws5xej6.js → rbac-roles-x55cnezn.js} +5 -5
  75. package/dist/{render-v2-x1wxvn51.js → render-v2-hyd45w8b.js} +6 -6
  76. package/dist/{seed-pricing-t6y8d0vf.js → seed-pricing-49gbgn96.js} +6 -6
  77. package/dist/{setup-x50py6xg.js → setup-qvq64vzq.js} +2 -2
  78. package/dist/{worker-zsz0qfxk.js → worker-scj60cxg.js} +32 -32
  79. package/dist/{x-n2phr5vm.js → x-n3e0v3xa.js} +2 -2
  80. package/openapi.json +46 -4
  81. package/package.json +1 -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/automation-toggle.ts +69 -0
  93. package/src/be/seed/schedules-seeder.ts +28 -6
  94. package/src/be/seed/workflows-seeder.ts +18 -6
  95. package/src/be/seed-scripts/catalog/delegate.ts +5 -1
  96. package/src/be/seed-skills/bundled-files.generated.json +10 -0
  97. package/src/be/seed-skills/index.ts +3 -0
  98. package/src/be/steering.ts +1 -0
  99. package/src/be/swarm-config-guard.ts +12 -0
  100. package/src/commands/onboard/steps/post-task.tsx +1 -0
  101. package/src/github/handlers.ts +9 -0
  102. package/src/gitlab/handlers.ts +4 -0
  103. package/src/heartbeat/heartbeat.ts +8 -0
  104. package/src/http/approval-requests.ts +1 -0
  105. package/src/http/apps.ts +1 -0
  106. package/src/http/config.ts +15 -6
  107. package/src/http/mcp.ts +31 -4
  108. package/src/http/script-runs.ts +6 -0
  109. package/src/http/tasks.ts +52 -30
  110. package/src/integrations/kapso/inbound.ts +1 -0
  111. package/src/jira/sync.ts +2 -0
  112. package/src/linear/sync.ts +2 -0
  113. package/src/prompts/session-templates.ts +29 -15
  114. package/src/scheduler/deferred-task-waits.ts +123 -0
  115. package/src/scheduler/schedule-task.ts +42 -0
  116. package/src/scheduler/scheduler.ts +22 -31
  117. package/src/script-workflows/workflow-ctx.ts +2 -0
  118. package/src/scripts-runtime/types/stdlib.d.ts +38 -24
  119. package/src/scripts-runtime/types/swarm-sdk.d.ts +38 -24
  120. package/src/server.ts +10 -1
  121. package/src/slack/actions.ts +1 -0
  122. package/src/slack/assistant.ts +2 -0
  123. package/src/slack/handlers.ts +3 -0
  124. package/src/slack/thread-buffer.ts +2 -0
  125. package/src/tasks/worker-follow-up.ts +9 -0
  126. package/src/tests/acp-adapter.test.ts +35 -6
  127. package/src/tests/acp-session-token.test.ts +67 -0
  128. package/src/tests/asset-key-api.test.ts +15 -2
  129. package/src/tests/asset-key-mcp.test.ts +2 -0
  130. package/src/tests/automation-preflight-alert.test.ts +91 -0
  131. package/src/tests/claude-worker-parity.test.ts +3 -0
  132. package/src/tests/config-session-auth.test.ts +143 -0
  133. package/src/tests/defer-task.test.ts +117 -6
  134. package/src/tests/deferred-task-wake.test.ts +456 -0
  135. package/src/tests/heartbeat-reroute-decision.test.ts +1 -0
  136. package/src/tests/http-api-integration.test.ts +33 -4
  137. package/src/tests/model-control.test.ts +18 -5
  138. package/src/tests/opencode-adapter.test.ts +2 -2
  139. package/src/tests/promote-draft-task-route.test.ts +4 -0
  140. package/src/tests/prompt-template-session.test.ts +13 -4
  141. package/src/tests/rbac-wire-e2e.test.ts +2 -2
  142. package/src/tests/routing-decision-persistence.test.ts +520 -0
  143. package/src/tests/routing-reason-contract.test.ts +89 -0
  144. package/src/tests/routing-reason-inventory.test.ts +55 -0
  145. package/src/tests/schedule-target-type.test.ts +48 -1
  146. package/src/tests/scheduled-task-required-params-migration.test.ts +182 -0
  147. package/src/tests/scheduled-tasks.test.ts +9 -5
  148. package/src/tests/script-connections.test.ts +4 -0
  149. package/src/tests/script-runs-http.test.ts +31 -0
  150. package/src/tests/scripts-typecheck.test.ts +11 -0
  151. package/src/tests/secret-scrubber.test.ts +12 -0
  152. package/src/tests/seed-registry.test.ts +2 -2
  153. package/src/tests/seed-schedules.test.ts +99 -3
  154. package/src/tests/seed-workflows.test.ts +74 -0
  155. package/src/tests/send-task-output-schema.test.ts +66 -1
  156. package/src/tests/send-task-requested-by.test.ts +1 -0
  157. package/src/tests/send-task-slack-routing-guard.test.ts +2 -0
  158. package/src/tests/store-progress-blocked-waiting-gate.test.ts +151 -0
  159. package/src/tests/swarm-tool-result-gate.test.ts +24 -0
  160. package/src/tests/task-tool-manifest.test.ts +47 -0
  161. package/src/tests/task-tool-preload-mcp.test.ts +125 -0
  162. package/src/tests/task-tools-ctx.test.ts +2 -0
  163. package/src/tests/tool-output-agent-id.test.ts +1 -0
  164. package/src/tests/ui-followup-lead-delegation.test.ts +6 -1
  165. package/src/tests/workflow-agent-task.test.ts +24 -1
  166. package/src/tests/workflow-engine-v2.test.ts +58 -2
  167. package/src/tools/defer-task.ts +73 -21
  168. package/src/tools/send-task.ts +31 -0
  169. package/src/tools/skills/skill-publish.ts +1 -0
  170. package/src/tools/store-progress.ts +43 -0
  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/schedules/daily-blocker-digest/config.json +6 -1
  181. package/templates/schedules/daily-compounding-reflection/config.json +1 -0
  182. package/templates/schedules/daily-status-report/config.json +6 -1
  183. package/templates/schedules/daily-swarm-update-check/config.json +19 -0
  184. package/templates/schedules/daily-swarm-update-check/content.md +49 -0
  185. package/templates/schedules/daily-workflow-health-audit/config.json +6 -1
  186. package/templates/skills/comms/config.json +18 -0
  187. package/templates/skills/comms/content.md +74 -0
  188. package/templates/skills/comms/files/references/ste-rules.md +73 -0
  189. package/templates/skills/comms/files/references/visual-shapes.md +112 -0
  190. package/templates/skills/swarm-scripts/SKILL.md +3 -2
  191. package/templates/skills/swarm-scripts/content.md +3 -2
@@ -49,7 +49,7 @@ import {
49
49
  setSlackMessageTracking,
50
50
  slackContextKey,
51
51
  updateSlackMessageRecord
52
- } from "./cli-6s2y152y.js";
52
+ } from "./cli-qgd4sqz5.js";
53
53
  import {
54
54
  getAppUrl,
55
55
  init_constants
@@ -61,7 +61,7 @@ import {
61
61
  import {
62
62
  init_secret_scrubber,
63
63
  scrubSecrets
64
- } from "./cli-xqcq9y5e.js";
64
+ } from "./cli-r2ap2czm.js";
65
65
  import {
66
66
  require_extension,
67
67
  require_permessage_deflate,
@@ -54475,7 +54475,7 @@ async function initOtel(serviceRole = process.env.AGENT_ROLE || "api") {
54475
54475
  return;
54476
54476
  initialized = true;
54477
54477
  try {
54478
- const impl = await import("./otel-impl-725kq0vp.js");
54478
+ const impl = await import("./otel-impl-b93gxnz5.js");
54479
54479
  await impl.boot(serviceRole);
54480
54480
  realWithSpan = impl.withSpan;
54481
54481
  realStartSpan = impl.startSpan;
@@ -55793,13 +55793,13 @@ async function initSlackApp() {
55793
55793
  logLevel: import_bolt.LogLevel.DEBUG,
55794
55794
  ...slackApiUrl ? { clientOptions: { slackApiUrl } } : {}
55795
55795
  });
55796
- const { registerMessageHandler } = await import("./handlers-1vt77kgq.js");
55797
- const { registerCommandHandler } = await import("./commands-xnvh951h.js");
55798
- const { registerActionHandlers } = await import("./actions-kweznh5a.js");
55796
+ const { registerMessageHandler } = await import("./handlers-nsg0bcye.js");
55797
+ const { registerCommandHandler } = await import("./commands-n755g391.js");
55798
+ const { registerActionHandlers } = await import("./actions-9d2694yk.js");
55799
55799
  registerMessageHandler(app);
55800
55800
  registerCommandHandler(app);
55801
55801
  registerActionHandlers(app);
55802
- const { createAssistant } = await import("./assistant-40m4w50s.js");
55802
+ const { createAssistant } = await import("./assistant-edb6n9nn.js");
55803
55803
  app.assistant(createAssistant());
55804
55804
  return app;
55805
55805
  }
@@ -55808,7 +55808,7 @@ async function startSlackApp() {
55808
55808
  await initSlackApp();
55809
55809
  }
55810
55810
  if (app) {
55811
- const { isSlackRenderV2Enabled: isSlackRenderV2Enabled2 } = await import("./render-v2-x1wxvn51.js");
55811
+ const { isSlackRenderV2Enabled: isSlackRenderV2Enabled2 } = await import("./render-v2-hyd45w8b.js");
55812
55812
  if (isSlackRenderV2Enabled2())
55813
55813
  await ensureSlackRenderV2Activation();
55814
55814
  await app.start();
@@ -4,15 +4,15 @@ import {
4
4
  getEmbeddingProvider,
5
5
  init_embedding,
6
6
  serializeEmbedding
7
- } from "./cli-5khqvvnq.js";
7
+ } from "./cli-jezx9b9c.js";
8
8
  import {
9
9
  getDbClient,
10
10
  init_db
11
- } from "./cli-6s2y152y.js";
11
+ } from "./cli-qgd4sqz5.js";
12
12
  import {
13
13
  init_secret_scrubber,
14
14
  scrubSecrets
15
- } from "./cli-xqcq9y5e.js";
15
+ } from "./cli-r2ap2czm.js";
16
16
 
17
17
  // src/be/scripts/embeddings.ts
18
18
  init_secret_scrubber();
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  SYSTEM_COLUMN_KINDS,
3
3
  listAppRecords
4
- } from "./cli-tebsjpk7.js";
4
+ } from "./cli-hzqmgcm2.js";
5
5
  import {
6
6
  getScriptApiTypes,
7
7
  getScriptMcpTypes,
8
8
  require_typescript
9
- } from "./cli-0er5m69z.js";
9
+ } from "./cli-svbrpf5q.js";
10
10
  import {
11
11
  deleteSwarmConfigByKey,
12
12
  getAgentById,
@@ -15,11 +15,11 @@ import {
15
15
  getSwarmConfigs,
16
16
  init_db,
17
17
  upsertSwarmConfig
18
- } from "./cli-6s2y152y.js";
18
+ } from "./cli-qgd4sqz5.js";
19
19
  import {
20
20
  init_secret_scrubber,
21
21
  scrubSecrets
22
- } from "./cli-xqcq9y5e.js";
22
+ } from "./cli-r2ap2czm.js";
23
23
  import {
24
24
  __require,
25
25
  __toESM
@@ -629,6 +629,36 @@ export type ScriptScope = "agent" | "global";
629
629
  export type ScriptFsMode = "none" | "workspace-rw";
630
630
  export type ScriptApiRawOptions = { raw: true };
631
631
  export type ScriptApiDefaultOptions = { raw?: false };
632
+ export type RoutingReason = "skill" | "continuity" | "overflow" | "human_pinned" | "reroute_fault";
633
+ export type TaskSendArgs = Record<string, unknown> & {
634
+ task: string;
635
+ routingNote?: string;
636
+ } & (
637
+ | { agentId: string; routingReason: RoutingReason }
638
+ | { agentId?: never; routingReason?: never }
639
+ );
640
+ export type AgentTaskStepConfig = {
641
+ template?: string;
642
+ task?: string;
643
+ agentId?: string;
644
+ routingReason?: RoutingReason;
645
+ routingNote?: string;
646
+ tags?: string[];
647
+ priority?: number;
648
+ offerMode?: boolean;
649
+ dir?: string;
650
+ vcsRepo?: string;
651
+ model?: string;
652
+ parentTaskId?: string;
653
+ requestedByUserId?: string;
654
+ outputSchema?: Record<string, unknown>;
655
+ /** Wait for the dispatched task to reach a terminal status before resolving. Default: true. */
656
+ waitForCompletion?: boolean;
657
+ /** Max ms to wait for a terminal status before throwing. Default: 2h. Only used when waitForCompletion is true. */
658
+ timeoutMs?: number;
659
+ /** Throw when the task ends failed/cancelled/superseded (default), or resolve with {taskId,status,error} when false. */
660
+ failOnTaskFailure?: boolean;
661
+ };
632
662
 
633
663
  export interface ScriptApiRawResult {
634
664
  ok: boolean;
@@ -732,7 +762,7 @@ export interface SwarmSdk {
732
762
  task_list(args?: Record<string, unknown>): Promise<unknown>;
733
763
  task_get(args: { taskId: string }): Promise<unknown>;
734
764
  task_storeProgress(args: Record<string, unknown>): Promise<unknown>;
735
- task_defer(args: { taskId: string; delayMs?: number; runAt?: string; summary: string; note: string; checks?: string[] }): Promise<unknown>;
765
+ task_defer(args: { taskId: string; delayMs?: number; runAt?: string; wakeOn?: { event: "task.completed" | "task.failed" | "settled"; taskId: string }; summary: string; note: string; checks?: string[] }): Promise<unknown>;
736
766
  task_poll(args?: Record<string, unknown>): Promise<unknown>;
737
767
  // --- kv ---
738
768
  kv_get<T = unknown>(args: { key: string; namespace?: string }): Promise<KvSdkResponse<KvEntry<T>>>;
@@ -813,7 +843,7 @@ export interface SwarmSdk {
813
843
  inject_learning(args: { content: string; name?: string; scope?: "agent" | "swarm"; source?: string; tags?: string[] }): Promise<unknown>;
814
844
 
815
845
  // --- write: tasks ---
816
- task_send(args: Record<string, unknown>): Promise<unknown>;
846
+ task_send(args: TaskSendArgs): Promise<unknown>;
817
847
  task_cancel(args: { taskId: string }): Promise<unknown>;
818
848
  task_steer(args: { taskId: string; message: string; mode?: "steer" | "queue"; onUnsupported?: "degrade" | "fail" }): Promise<unknown>;
819
849
  task_action(args: Record<string, unknown>): Promise<unknown>;
@@ -968,26 +998,7 @@ export interface ScriptWorkflowSteps {
968
998
  ): Promise<unknown>;
969
999
  agentTask(
970
1000
  label: string,
971
- config: {
972
- template?: string;
973
- task?: string;
974
- agentId?: string;
975
- tags?: string[];
976
- priority?: number;
977
- offerMode?: boolean;
978
- dir?: string;
979
- vcsRepo?: string;
980
- model?: string;
981
- parentTaskId?: string;
982
- requestedByUserId?: string;
983
- outputSchema?: Record<string, unknown>;
984
- /** Wait for the dispatched task to reach a terminal status before resolving. Default: true. */
985
- waitForCompletion?: boolean;
986
- /** Max ms to wait for a terminal status before throwing. Default: 2h. Only used when waitForCompletion is true. */
987
- timeoutMs?: number;
988
- /** Throw when the task ends failed/cancelled/superseded (default), or resolve with {taskId,status,error} when false. */
989
- failOnTaskFailure?: boolean;
990
- },
1001
+ config: AgentTaskStepConfig,
991
1002
  ): Promise<unknown>;
992
1003
  swarmScript(
993
1004
  label: string,
@@ -13,11 +13,11 @@ import {
13
13
  parseClaudeMdPendingRecord,
14
14
  planClaudeMdSync,
15
15
  withFileLock
16
- } from "./cli-m9sxbkhm.js";
16
+ } from "./cli-zvz62chv.js";
17
17
  import {
18
18
  init_secret_scrubber,
19
19
  scrubSecrets
20
- } from "./cli-xqcq9y5e.js";
20
+ } from "./cli-r2ap2czm.js";
21
21
 
22
22
  // src/commands/claude-md-session.ts
23
23
  init_file_lock();
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getDb,
3
3
  init_db
4
- } from "./cli-6s2y152y.js";
4
+ } from "./cli-qgd4sqz5.js";
5
5
 
6
6
  // src/be/seed-pricing.ts
7
7
  init_db();
@@ -35,7 +35,7 @@ import {
35
35
  import {
36
36
  init_secret_scrubber,
37
37
  scrubSecrets
38
- } from "./cli-xqcq9y5e.js";
38
+ } from "./cli-r2ap2czm.js";
39
39
  import {
40
40
  __toESM
41
41
  } from "./cli-bc05qbss.js";
@@ -19,7 +19,7 @@ import {
19
19
  import {
20
20
  init_secret_scrubber,
21
21
  scrubSecrets
22
- } from "./cli-xqcq9y5e.js";
22
+ } from "./cli-r2ap2czm.js";
23
23
 
24
24
  // src/providers/claude-managed-adapter.ts
25
25
  init_secret_scrubber();
@@ -5,7 +5,7 @@ import {
5
5
  getDb,
6
6
  getDbClient,
7
7
  init_db
8
- } from "./cli-6s2y152y.js";
8
+ } from "./cli-qgd4sqz5.js";
9
9
 
10
10
  // src/be/rbac-roles.ts
11
11
  init_db();
@@ -13,7 +13,7 @@ import {
13
13
  } from "./cli-b5b30yzk.js";
14
14
  import {
15
15
  summarizeSession
16
- } from "./cli-rvqz34y5.js";
16
+ } from "./cli-jecc01cb.js";
17
17
  import {
18
18
  CTX_MODE_NUDGE_EVERY
19
19
  } from "./cli-zm7njwzd.js";
@@ -49,11 +49,11 @@ import {
49
49
  import {
50
50
  init_package,
51
51
  package_default
52
- } from "./cli-anedxf1w.js";
52
+ } from "./cli-e06a8a7y.js";
53
53
  import {
54
54
  init_secret_scrubber,
55
55
  scrubSecrets
56
- } from "./cli-xqcq9y5e.js";
56
+ } from "./cli-r2ap2czm.js";
57
57
  import {
58
58
  __require
59
59
  } from "./cli-bc05qbss.js";
@@ -1,27 +1,27 @@
1
1
  import {
2
2
  renderSteeringDelivery
3
- } from "./cli-0b6y7kxm.js";
3
+ } from "./cli-xm87hzbw.js";
4
4
  import {
5
5
  checkCodexCredentials,
6
6
  codexUserHome
7
- } from "./cli-v3e51x7w.js";
7
+ } from "./cli-73gq0zxn.js";
8
8
  import {
9
9
  checkClaudeManagedCredentials
10
- } from "./cli-cn6mmc7f.js";
10
+ } from "./cli-6664w7y4.js";
11
11
  import {
12
12
  checkDevinCredentials
13
13
  } from "./cli-9b13ggd1.js";
14
14
  import {
15
15
  checkOpencodeCredentials
16
- } from "./cli-ct0et58h.js";
16
+ } from "./cli-5my3bjsd.js";
17
17
  import {
18
18
  renderMemoriesPrompt,
19
19
  resolveScriptsOnlyMode,
20
20
  writeSkillsToFilesystem
21
- } from "./cli-p73drk6p.js";
21
+ } from "./cli-cv7s5zdq.js";
22
22
  import {
23
23
  checkClaudeCredentials
24
- } from "./cli-m1p5cysp.js";
24
+ } from "./cli-k351hv5k.js";
25
25
  import {
26
26
  MAX_RATE_LIMIT_RESET_MS,
27
27
  isCodexCreditsExhaustedMessage,
@@ -34,7 +34,7 @@ import {
34
34
  } from "./cli-s25avqg9.js";
35
35
  import {
36
36
  validateJsonSchema
37
- } from "./cli-f8j56xv2.js";
37
+ } from "./cli-ddfw1mc4.js";
38
38
  import {
39
39
  authJsonToCredentialSelection,
40
40
  credentialsToAuthJson,
@@ -61,7 +61,7 @@ import {
61
61
  syncProfileFilesToServer,
62
62
  writeIdentityBaselines,
63
63
  writeProfileFileFromDb
64
- } from "./cli-m9sxbkhm.js";
64
+ } from "./cli-zvz62chv.js";
65
65
  import {
66
66
  ensure,
67
67
  initOtel,
@@ -71,7 +71,7 @@ import {
71
71
  startSpan,
72
72
  withSpan,
73
73
  withSpanContext
74
- } from "./cli-dk3me3qs.js";
74
+ } from "./cli-3sysyjve.js";
75
75
  import {
76
76
  init_task_attachment_links,
77
77
  taskAttachmentFetchCommand
@@ -83,7 +83,7 @@ import {
83
83
  init_types,
84
84
  resolveTaskModelSelection,
85
85
  telemetry
86
- } from "./cli-6s2y152y.js";
86
+ } from "./cli-qgd4sqz5.js";
87
87
  import {
88
88
  generateDefaultClaudeMd,
89
89
  generateDefaultIdentityMd,
@@ -93,7 +93,7 @@ import {
93
93
  init_base_prompt,
94
94
  init_defaults,
95
95
  init_templates
96
- } from "./cli-y6b6fb76.js";
96
+ } from "./cli-08b07b4r.js";
97
97
  import {
98
98
  configureHttpResolver,
99
99
  init_resolver,
@@ -102,7 +102,7 @@ import {
102
102
  interpolate,
103
103
  isSteeringEnabled,
104
104
  resolveTemplateAsync
105
- } from "./cli-kpv03zhj.js";
105
+ } from "./cli-3apbzgyk.js";
106
106
  import {
107
107
  getMcpBaseUrl,
108
108
  init_constants
@@ -114,7 +114,7 @@ import {
114
114
  import {
115
115
  init_secret_scrubber,
116
116
  scrubSecrets
117
- } from "./cli-xqcq9y5e.js";
117
+ } from "./cli-r2ap2czm.js";
118
118
  import {
119
119
  __require
120
120
  } from "./cli-bc05qbss.js";
@@ -151,19 +151,19 @@ async function materializeCodexAuthJson(_slot, creds, deps = {}) {
151
151
  async function createProviderAdapter(provider) {
152
152
  switch (provider) {
153
153
  case "claude": {
154
- const { ClaudeAdapter } = await import("./claude-adapter-9pz5q2pb.js");
154
+ const { ClaudeAdapter } = await import("./claude-adapter-v3rnzsdc.js");
155
155
  return new ClaudeAdapter;
156
156
  }
157
157
  case "pi": {
158
- const { PiMonoAdapter } = await import("./pi-mono-adapter-2has4gnp.js");
158
+ const { PiMonoAdapter } = await import("./pi-mono-adapter-zvshk5cj.js");
159
159
  return new PiMonoAdapter;
160
160
  }
161
161
  case "codex": {
162
- const { CodexAdapter } = await import("./codex-adapter-ehhj2qwc.js");
162
+ const { CodexAdapter } = await import("./codex-adapter-jyw7a91z.js");
163
163
  return new CodexAdapter;
164
164
  }
165
165
  case "claude-managed": {
166
- const { ClaudeManagedAdapter } = await import("./claude-managed-adapter-sactwn31.js");
166
+ const { ClaudeManagedAdapter } = await import("./claude-managed-adapter-qvsmh6mv.js");
167
167
  return new ClaudeManagedAdapter;
168
168
  }
169
169
  case "devin": {
@@ -171,11 +171,11 @@ async function createProviderAdapter(provider) {
171
171
  return new DevinAdapter;
172
172
  }
173
173
  case "opencode": {
174
- const { OpencodeAdapter } = await import("./opencode-adapter-fef1mrn2.js");
174
+ const { OpencodeAdapter } = await import("./opencode-adapter-dce4wskd.js");
175
175
  return new OpencodeAdapter;
176
176
  }
177
177
  case "acp": {
178
- const { ACPAdapter } = await import("./acp-adapter-grez7xhd.js");
178
+ const { ACPAdapter } = await import("./acp-adapter-vhkzfpjg.js");
179
179
  return new ACPAdapter;
180
180
  }
181
181
  default:
@@ -588,7 +588,7 @@ var CREDENTIAL_PROVIDER_CHECKERS = {
588
588
  devin: (env) => checkDevinCredentials(env),
589
589
  opencode: (env, opts) => checkOpencodeCredentials(env, opts),
590
590
  pi: async (env, opts) => {
591
- const { checkPiMonoCredentials } = await import("./pi-mono-adapter-2has4gnp.js");
591
+ const { checkPiMonoCredentials } = await import("./pi-mono-adapter-zvshk5cj.js");
592
592
  return checkPiMonoCredentials(env, opts);
593
593
  },
594
594
  acp: () => ({ ready: true, missing: [], satisfiedBy: "sdk-delegated" })
@@ -6,25 +6,26 @@ import {
6
6
  getExecutorRegistry,
7
7
  handleScheduleTrigger,
8
8
  isNeedsSetupFailure,
9
+ notifyAutomationPreflightFailure,
9
10
  preflightAutomation,
10
11
  recordSchedulePreflightFailure,
11
12
  renderAutomationTokens,
12
13
  schedulePreflightInput,
13
14
  startWorkflowExecution
14
- } from "./cli-f8j56xv2.js";
15
+ } from "./cli-ddfw1mc4.js";
15
16
  import {
16
17
  buildScriptCredentialBindings,
17
18
  getScript,
18
19
  getScriptApiConnectionDescriptors,
19
20
  getScriptMcpConnectionDescriptors,
20
21
  runScript
21
- } from "./cli-0er5m69z.js";
22
+ } from "./cli-svbrpf5q.js";
22
23
  import {
23
24
  createTaskWithSiblingAwareness
24
- } from "./cli-7gn7c2af.js";
25
+ } from "./cli-ayvy5kde.js";
25
26
  import {
26
27
  ensure
27
- } from "./cli-dk3me3qs.js";
28
+ } from "./cli-3sysyjve.js";
28
29
  import {
29
30
  getDbClient,
30
31
  getDueScheduledTasks,
@@ -38,7 +39,11 @@ import {
38
39
  scheduleContextKey,
39
40
  telemetry,
40
41
  updateScheduledTask
41
- } from "./cli-6s2y152y.js";
42
+ } from "./cli-qgd4sqz5.js";
43
+ import {
44
+ init_event_bus,
45
+ workflowEventBus
46
+ } from "./cli-f7kvq46p.js";
42
47
  import {
43
48
  __toESM
44
49
  } from "./cli-bc05qbss.js";
@@ -46,31 +51,27 @@ import {
46
51
  // src/scheduler/scheduler.ts
47
52
  var import_cron_parser = __toESM(require_dist(), 1);
48
53
  init_db();
49
- init_context_key();
50
54
  init_telemetry();
51
- var schedulerInterval = null;
52
- var isProcessing = false;
53
- var executorRegistry = null;
54
- function resolveExecutorRegistry() {
55
- if (executorRegistry)
56
- return executorRegistry;
57
- try {
58
- return getExecutorRegistry();
59
- } catch {
60
- return null;
61
- }
62
- }
55
+
56
+ // src/scheduler/deferred-task-waits.ts
57
+ init_db();
58
+ init_event_bus();
59
+
60
+ // src/scheduler/schedule-task.ts
61
+ init_db();
62
+ init_context_key();
63
63
  async function createStandaloneScheduleTask(schedule, extraTags = []) {
64
64
  if (!schedule.taskTemplate) {
65
65
  throw new Error(`Schedule "${schedule.name}" has no taskTemplate (targetType=agent-task)`);
66
66
  }
67
- return await createTaskWithSiblingAwareness(schedule.taskTemplate, {
67
+ const task = await createTaskWithSiblingAwareness(schedule.taskTemplate, {
68
68
  key: schedule.key,
69
69
  creatorAgentId: schedule.createdByAgentId,
70
70
  taskType: schedule.taskType,
71
71
  tags: [...schedule.tags, "scheduled", `schedule:${schedule.name}`, ...extraTags],
72
72
  priority: schedule.priority,
73
73
  agentId: schedule.targetAgentId,
74
+ routingReason: schedule.targetAgentId ? "human_pinned" : undefined,
74
75
  model: schedule.model,
75
76
  modelTier: schedule.modelTier,
76
77
  scheduleId: schedule.id,
@@ -79,6 +80,109 @@ async function createStandaloneScheduleTask(schedule, extraTags = []) {
79
80
  contextKey: scheduleContextKey({ scheduleId: schedule.id }),
80
81
  parentTaskId: schedule.parentTaskId
81
82
  });
83
+ if (schedule.taskType === "deferred" && schedule.parentTaskId) {
84
+ await getDbClient().run("UPDATE deferred_task_waits SET taskId = ?, updated_at = ? WHERE status = 'pending' AND taskId = ?", [task.id, new Date().toISOString(), schedule.parentTaskId]);
85
+ }
86
+ return task;
87
+ }
88
+
89
+ // src/scheduler/deferred-task-waits.ts
90
+ async function dispatchDeferredTaskWait(scheduleId, reason, extraTags = []) {
91
+ const client = getDbClient();
92
+ if (!await client.get("SELECT * FROM deferred_task_waits WHERE scheduleId = ?", [
93
+ scheduleId
94
+ ]))
95
+ return;
96
+ return client.transaction(async () => {
97
+ const wait = await client.get("SELECT * FROM deferred_task_waits WHERE scheduleId = ?", [scheduleId]);
98
+ if (!wait || wait.status !== "pending")
99
+ return {};
100
+ if (reason !== "ceiling" && wait.eventName !== "settled" && wait.eventName !== reason)
101
+ return {};
102
+ let schedule = await getScheduledTaskById(scheduleId);
103
+ if (!schedule?.enabled)
104
+ return {};
105
+ const now = new Date().toISOString();
106
+ const claimed = await client.run("UPDATE deferred_task_waits SET status = 'fired', firedBy = ?, resolvedAt = ?, updated_at = ? WHERE scheduleId = ? AND status = 'pending'", [reason, now, now, scheduleId]);
107
+ if (!claimed.changes)
108
+ return {};
109
+ if (schedule.createdBy && !await getUserById(schedule.createdBy)) {
110
+ schedule = { ...schedule, createdBy: undefined };
111
+ }
112
+ if (!schedule.taskTemplate)
113
+ throw new Error(`Schedule "${schedule.name}" has no taskTemplate`);
114
+ const cause = reason === "ceiling" ? "ceiling expired" : `${reason} for task ${wait.taskId}`;
115
+ const task = await createStandaloneScheduleTask({
116
+ ...schedule,
117
+ taskTemplate: `${schedule.taskTemplate}
118
+
119
+ Wake-up cause: ${cause}.`
120
+ }, extraTags);
121
+ await client.run("UPDATE deferred_task_waits SET childTaskId = ? WHERE scheduleId = ?", [
122
+ task.id,
123
+ scheduleId
124
+ ]);
125
+ await updateScheduledTask(scheduleId, {
126
+ enabled: false,
127
+ nextRunAt: null,
128
+ lastRunAt: now,
129
+ lastUpdatedAt: now,
130
+ consecutiveErrors: 0,
131
+ lastErrorAt: null,
132
+ lastErrorMessage: null
133
+ });
134
+ return { task };
135
+ });
136
+ }
137
+ async function reconcileDeferredTaskWaits(taskId) {
138
+ const rows = await getDbClient().query(`SELECT w.*, t.status AS taskStatus FROM deferred_task_waits w
139
+ JOIN agent_tasks t ON t.id = w.taskId
140
+ JOIN scheduled_tasks s ON s.id = w.scheduleId
141
+ WHERE w.status = 'pending' AND s.enabled = 1 AND t.status IN ('completed', 'failed')
142
+ AND NOT EXISTS (
143
+ SELECT 1 FROM scheduled_tasks d
144
+ WHERE d.parentTaskId = t.id AND d.taskType = 'deferred' AND d.enabled = 1
145
+ )
146
+ AND (w.eventName = 'settled' OR w.eventName = 'task.' || t.status)
147
+ ${taskId ? "AND w.taskId = ?" : ""}`, taskId ? [taskId] : []);
148
+ for (const row of rows) {
149
+ try {
150
+ await dispatchDeferredTaskWait(row.scheduleId, `task.${row.taskStatus}`);
151
+ } catch (err) {
152
+ console.error(`[Scheduler] Deferred task wake failed for ${row.scheduleId}:`, err);
153
+ }
154
+ }
155
+ }
156
+ function onTaskTerminal(payload) {
157
+ if (!payload || typeof payload !== "object" || !("taskId" in payload) || typeof payload.taskId !== "string")
158
+ return;
159
+ reconcileDeferredTaskWaits(payload.taskId).catch((err) => {
160
+ console.error("[Scheduler] Deferred task event wake failed:", err);
161
+ });
162
+ }
163
+ async function initDeferredTaskWaits() {
164
+ stopDeferredTaskWaits();
165
+ workflowEventBus.on("task.completed", onTaskTerminal);
166
+ workflowEventBus.on("task.failed", onTaskTerminal);
167
+ await reconcileDeferredTaskWaits();
168
+ }
169
+ function stopDeferredTaskWaits() {
170
+ workflowEventBus.off("task.completed", onTaskTerminal);
171
+ workflowEventBus.off("task.failed", onTaskTerminal);
172
+ }
173
+
174
+ // src/scheduler/scheduler.ts
175
+ var schedulerInterval = null;
176
+ var isProcessing = false;
177
+ var executorRegistry = null;
178
+ function resolveExecutorRegistry() {
179
+ if (executorRegistry)
180
+ return executorRegistry;
181
+ try {
182
+ return getExecutorRegistry();
183
+ } catch {
184
+ return null;
185
+ }
82
186
  }
83
187
  async function executeScheduleScript(schedule) {
84
188
  if (!schedule.scriptName) {
@@ -121,9 +225,14 @@ function renderScheduledTaskParams(schedule) {
121
225
  return renderAutomationTokens(schedule, schedule.params ?? {});
122
226
  }
123
227
  async function dispatchScheduleTarget(schedule, extraTags = []) {
228
+ const deferred = await dispatchDeferredTaskWait(schedule.id, "ceiling", extraTags);
229
+ if (deferred)
230
+ return { triggeredWorkflows: false, ...deferred };
124
231
  const preflight = preflightAutomation(schedulePreflightInput(schedule), await getAutomationSetupStates());
125
232
  if (preflight.state === "needs_setup") {
126
- await recordSchedulePreflightFailure(schedule.id, preflight.failureReason);
233
+ const recorded = await recordSchedulePreflightFailure(schedule.id, preflight.failureReason);
234
+ if (recorded)
235
+ await notifyAutomationPreflightFailure(preflight);
127
236
  throw new AutomationNeedsSetupError(preflight.failureReason);
128
237
  }
129
238
  schedule = renderScheduledTaskParams(schedule);
@@ -376,7 +485,7 @@ function startScheduler(registry, intervalMs = 1e4, opts) {
376
485
  }
377
486
  executorRegistry = registry;
378
487
  console.log(`[Scheduler] Starting with ${intervalMs}ms polling interval`);
379
- recoverMissedSchedules().then(() => processSchedules());
488
+ initDeferredTaskWaits().then(() => recoverMissedSchedules()).then(() => processSchedules()).catch((err) => console.error("[Scheduler] Recovery failed:", err));
380
489
  schedulerInterval = setInterval(async () => {
381
490
  await processSchedules();
382
491
  }, intervalMs);
@@ -402,6 +511,7 @@ async function processSchedules() {
402
511
  return;
403
512
  isProcessing = true;
404
513
  try {
514
+ await reconcileDeferredTaskWaits();
405
515
  const dueSchedules = await getDueScheduledTasks();
406
516
  for (const schedule of dueSchedules) {
407
517
  try {
@@ -415,6 +525,7 @@ async function processSchedules() {
415
525
  }
416
526
  }
417
527
  function stopScheduler() {
528
+ stopDeferredTaskWaits();
418
529
  if (schedulerInterval) {
419
530
  clearInterval(schedulerInterval);
420
531
  schedulerInterval = null;
@@ -448,4 +559,4 @@ async function runScheduleNow(scheduleId) {
448
559
  console.log(`[Scheduler] Manually executed schedule "${schedule.name}"`);
449
560
  }
450
561
  }
451
- export { dispatchScheduleTarget, calculateNextRun, startScheduler, stopScheduler, runScheduleNow };
562
+ export { reconcileDeferredTaskWaits, dispatchScheduleTarget, calculateNextRun, startScheduler, stopScheduler, runScheduleNow };
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  buildModelsDevSeedRows,
3
3
  loadModelsDevCache
4
- } from "./cli-0amc6myn.js";
4
+ } from "./cli-5m0qmvdp.js";
5
5
  import {
6
6
  createLogEntry,
7
7
  getActivePricingRow,
8
8
  getDbClient,
9
9
  init_db,
10
10
  insertPricingRow
11
- } from "./cli-6s2y152y.js";
11
+ } from "./cli-qgd4sqz5.js";
12
12
  import {
13
13
  init_secret_scrubber,
14
14
  scrubSecrets
15
- } from "./cli-xqcq9y5e.js";
15
+ } from "./cli-r2ap2czm.js";
16
16
 
17
17
  // src/be/pricing-refresh.ts
18
18
  init_secret_scrubber();
@@ -4,12 +4,12 @@ import {
4
4
  linkIdentity,
5
5
  recordUnmappedIdentity,
6
6
  resolveIdentity
7
- } from "./cli-xqcpg1st.js";
7
+ } from "./cli-j4d4f6hv.js";
8
8
  import {
9
9
  getKv,
10
10
  init_db,
11
11
  upsertKv
12
- } from "./cli-6s2y152y.js";
12
+ } from "./cli-qgd4sqz5.js";
13
13
 
14
14
  // src/slack/enrich.ts
15
15
  init_db();