@desplega.ai/agent-swarm 1.148.0 → 1.149.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/README.md +2 -1
  2. package/dist/{acp-adapter-grez7xhd.js → acp-adapter-4jncb126.js} +12 -5
  3. package/dist/{actions-kweznh5a.js → actions-31vp3ae7.js} +10 -9
  4. package/dist/{app-5fvvjv9m.js → app-1hh67x8w.js} +6 -6
  5. package/dist/{assistant-40m4w50s.js → assistant-z66dmz6p.js} +13 -11
  6. package/dist/{boot-reembed-cn357y5n.js → boot-reembed-fqzxxzjh.js} +7 -7
  7. package/dist/{boot-reembed-9rxmb26n.js → boot-reembed-wxa8ya0s.js} +8 -8
  8. package/dist/{boot-scrub-logs-5tpp0x3y.js → boot-scrub-logs-jnyndh79.js} +5 -5
  9. package/dist/{claude-adapter-9pz5q2pb.js → claude-adapter-3qpa9w0j.js} +9 -9
  10. package/dist/{claude-managed-adapter-sactwn31.js → claude-managed-adapter-qvsmh6mv.js} +2 -2
  11. package/dist/{claude-sdk-session-v8w0s7qm.js → claude-sdk-session-2yxgjs5d.js} +9 -9
  12. package/dist/{cli-y6b6fb76.js → cli-08b07b4r.js} +1 -1
  13. package/dist/{cli-8fc8de14.js → cli-0z2v4nhw.js} +1 -1
  14. package/dist/{cli-tebsjpk7.js → cli-19f354qr.js} +2 -2
  15. package/dist/{cli-kzvhgvk3.js → cli-2qts1hys.js} +3 -3
  16. package/dist/{cli-kpv03zhj.js → cli-3apbzgyk.js} +27 -15
  17. package/dist/{cli-5khqvvnq.js → cli-3q5ejx9p.js} +2 -2
  18. package/dist/{cli-d8brzxjb.js → cli-4wtq5jjv.js} +2 -2
  19. package/dist/{cli-ct0et58h.js → cli-5my3bjsd.js} +1 -1
  20. package/dist/{cli-cn6mmc7f.js → cli-6664w7y4.js} +1 -1
  21. package/dist/{cli-f8j56xv2.js → cli-6pqcb4q0.js} +53 -13
  22. package/dist/{cli-m1p5cysp.js → cli-7smrsr25.js} +3 -3
  23. package/dist/{cli-0amc6myn.js → cli-9fy6nk6g.js} +1 -1
  24. package/dist/{cli-dcem3pr1.js → cli-9hspd3dp.js} +2 -2
  25. package/dist/{cli-0er5m69z.js → cli-aae6hz6a.js} +4 -4
  26. package/dist/{cli-brxyat7h.js → cli-cr12paw2.js} +5 -5
  27. package/dist/{cli-dk3me3qs.js → cli-d8ftsp62.js} +8 -8
  28. package/dist/{cli-v3e51x7w.js → cli-e95cx1eb.js} +3 -3
  29. package/dist/{cli-ztn0ga15.js → cli-gjhjfeeg.js} +1 -1
  30. package/dist/{cli-xqcpg1st.js → cli-gv88e1vf.js} +1 -1
  31. package/dist/{cli-rvqz34y5.js → cli-jecc01cb.js} +1 -1
  32. package/dist/{cli-hzhhrt7b.js → cli-k0cr4kat.js} +1 -1
  33. package/dist/{cli-hz8xhefy.js → cli-kgz4np97.js} +4 -4
  34. package/dist/{cli-anedxf1w.js → cli-kjwt6hdf.js} +1 -1
  35. package/dist/{cli-3n7cbfjn.js → cli-mnmsfd1w.js} +6 -2
  36. package/dist/{cli-n9grk3yd.js → cli-n3dz2942.js} +37 -26
  37. package/dist/{cli-cdjezzc7.js → cli-nye12xk5.js} +8 -5
  38. package/dist/{cli-9216xm24.js → cli-phsxnkp6.js} +20 -20
  39. package/dist/{cli-7gn7c2af.js → cli-q50ef8g0.js} +1 -1
  40. package/dist/{cli-qy6h009w.js → cli-qaacms9y.js} +7 -6
  41. package/dist/{cli-xqcq9y5e.js → cli-r2ap2czm.js} +1 -0
  42. package/dist/{cli-hp2est46.js → cli-sd5pv3b1.js} +3 -3
  43. package/dist/{cli-0b6y7kxm.js → cli-xm87hzbw.js} +1 -1
  44. package/dist/{cli-6s2y152y.js → cli-yab68w40.js} +285 -11
  45. package/dist/{cli-p73drk6p.js → cli-yb9qhqam.js} +167 -40
  46. package/dist/{cli-56y3hch2.js → cli-ygweqcn4.js} +133 -22
  47. package/dist/{cli-n2cwscdd.js → cli-ykxrnd1q.js} +2 -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-8meawydj.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-gjgxyp5j.js} +4 -4
  53. package/dist/{commands-xnvh951h.js → commands-hz3nb95f.js} +5 -5
  54. package/dist/{db-ycr5zfr4.js → db-ggz97zbm.js} +5 -5
  55. package/dist/{e2b-6hb103d8.js → e2b-p04vmtx0.js} +1 -1
  56. package/dist/{handlers-1vt77kgq.js → handlers-nbzdzn9k.js} +14 -11
  57. package/dist/{hook-91ntpmff.js → hook-bks2q1f6.js} +7 -7
  58. package/dist/{hook-qfwjydvn.js → hook-kq9wp0ep.js} +8 -8
  59. package/dist/{http-h6g7bv5b.js → http-hrf77v87.js} +96 -45
  60. package/dist/{index-47ghesbn.js → index-6nsbg88z.js} +443 -144
  61. package/dist/{index-antf9t4p.js → index-8hmeg8j1.js} +14 -14
  62. package/dist/{index-d2mytx95.js → index-cqtebbhb.js} +13 -13
  63. package/dist/{index-0ez2aack.js → index-n28pw1zt.js} +15 -15
  64. package/dist/{keepalive-c4sp7yvd.js → keepalive-dxc12gvg.js} +7 -7
  65. package/dist/{lead-4r7z9e8v.js → lead-yckfn18d.js} +32 -32
  66. package/dist/{maintenance-yqjfdjas.js → maintenance-6kfb2m5e.js} +8 -8
  67. package/dist/{oauth-refresh-sweep-wtqgnh3c.js → oauth-refresh-sweep-1x1ac722.js} +6 -6
  68. package/dist/{onboard-a4krmh46.js → onboard-dcyt1609.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-tbk3e5dr.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-kaqg567e.js} +7 -7
  73. package/dist/{rbac-roles-gws5xej6.js → rbac-roles-ammq6rd2.js} +5 -5
  74. package/dist/{rbac-roles-t3wygpth.js → rbac-roles-cf97v1vd.js} +6 -6
  75. package/dist/{render-v2-x1wxvn51.js → render-v2-80w603vy.js} +6 -6
  76. package/dist/{seed-pricing-t6y8d0vf.js → seed-pricing-zbrn83xv.js} +6 -6
  77. package/dist/{setup-x50py6xg.js → setup-fe66kczs.js} +2 -2
  78. package/dist/{worker-zsz0qfxk.js → worker-qmb2d1e2.js} +32 -32
  79. package/dist/{x-n2phr5vm.js → x-n3e0v3xa.js} +2 -2
  80. package/openapi.json +46 -4
  81. package/package.json +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-scripts/catalog/delegate.ts +5 -1
  93. package/src/be/seed-skills/bundled-files.generated.json +10 -0
  94. package/src/be/seed-skills/index.ts +3 -0
  95. package/src/be/steering.ts +1 -0
  96. package/src/be/swarm-config-guard.ts +11 -0
  97. package/src/commands/onboard/steps/post-task.tsx +1 -0
  98. package/src/github/handlers.ts +9 -0
  99. package/src/gitlab/handlers.ts +4 -0
  100. package/src/heartbeat/heartbeat.ts +8 -0
  101. package/src/http/approval-requests.ts +1 -0
  102. package/src/http/apps.ts +1 -0
  103. package/src/http/config.ts +15 -6
  104. package/src/http/mcp.ts +31 -4
  105. package/src/http/script-runs.ts +6 -0
  106. package/src/http/tasks.ts +52 -30
  107. package/src/integrations/kapso/inbound.ts +1 -0
  108. package/src/jira/sync.ts +2 -0
  109. package/src/linear/sync.ts +2 -0
  110. package/src/prompts/session-templates.ts +29 -15
  111. package/src/scheduler/deferred-task-waits.ts +123 -0
  112. package/src/scheduler/schedule-task.ts +42 -0
  113. package/src/scheduler/scheduler.ts +22 -31
  114. package/src/script-workflows/workflow-ctx.ts +2 -0
  115. package/src/scripts-runtime/types/stdlib.d.ts +38 -24
  116. package/src/scripts-runtime/types/swarm-sdk.d.ts +38 -24
  117. package/src/server.ts +10 -1
  118. package/src/slack/actions.ts +1 -0
  119. package/src/slack/assistant.ts +2 -0
  120. package/src/slack/handlers.ts +3 -0
  121. package/src/slack/thread-buffer.ts +2 -0
  122. package/src/tasks/worker-follow-up.ts +9 -0
  123. package/src/tests/acp-adapter.test.ts +35 -6
  124. package/src/tests/acp-session-token.test.ts +67 -0
  125. package/src/tests/asset-key-api.test.ts +15 -2
  126. package/src/tests/asset-key-mcp.test.ts +2 -0
  127. package/src/tests/automation-preflight-alert.test.ts +91 -0
  128. package/src/tests/claude-worker-parity.test.ts +3 -0
  129. package/src/tests/config-session-auth.test.ts +143 -0
  130. package/src/tests/defer-task.test.ts +117 -6
  131. package/src/tests/deferred-task-wake.test.ts +456 -0
  132. package/src/tests/heartbeat-reroute-decision.test.ts +1 -0
  133. package/src/tests/http-api-integration.test.ts +33 -4
  134. package/src/tests/model-control.test.ts +18 -5
  135. package/src/tests/opencode-adapter.test.ts +2 -2
  136. package/src/tests/promote-draft-task-route.test.ts +4 -0
  137. package/src/tests/prompt-template-session.test.ts +13 -4
  138. package/src/tests/rbac-wire-e2e.test.ts +2 -2
  139. package/src/tests/routing-decision-persistence.test.ts +520 -0
  140. package/src/tests/routing-reason-contract.test.ts +89 -0
  141. package/src/tests/routing-reason-inventory.test.ts +55 -0
  142. package/src/tests/schedule-target-type.test.ts +48 -1
  143. package/src/tests/scheduled-task-required-params-migration.test.ts +182 -0
  144. package/src/tests/scheduled-tasks.test.ts +9 -5
  145. package/src/tests/script-connections.test.ts +4 -0
  146. package/src/tests/script-runs-http.test.ts +31 -0
  147. package/src/tests/scripts-typecheck.test.ts +11 -0
  148. package/src/tests/secret-scrubber.test.ts +12 -0
  149. package/src/tests/send-task-output-schema.test.ts +66 -1
  150. package/src/tests/send-task-requested-by.test.ts +1 -0
  151. package/src/tests/send-task-slack-routing-guard.test.ts +2 -0
  152. package/src/tests/store-progress-blocked-waiting-gate.test.ts +151 -0
  153. package/src/tests/swarm-tool-result-gate.test.ts +24 -0
  154. package/src/tests/task-tool-manifest.test.ts +47 -0
  155. package/src/tests/task-tool-preload-mcp.test.ts +125 -0
  156. package/src/tests/task-tools-ctx.test.ts +2 -0
  157. package/src/tests/tool-output-agent-id.test.ts +1 -0
  158. package/src/tests/ui-followup-lead-delegation.test.ts +6 -1
  159. package/src/tests/workflow-agent-task.test.ts +24 -1
  160. package/src/tests/workflow-engine-v2.test.ts +58 -2
  161. package/src/tools/defer-task.ts +73 -21
  162. package/src/tools/send-task.ts +31 -0
  163. package/src/tools/skills/skill-publish.ts +1 -0
  164. package/src/tools/store-progress.ts +43 -0
  165. package/src/tools/templates.ts +2 -1
  166. package/src/tools/utils.ts +33 -2
  167. package/src/types.ts +14 -1
  168. package/src/utils/acp-session-token.ts +14 -4
  169. package/src/utils/secret-scrubber.ts +2 -0
  170. package/src/utils/task-tool-manifest.ts +33 -0
  171. package/src/workflows/engine.ts +4 -1
  172. package/src/workflows/executors/agent-task.ts +7 -1
  173. package/templates/ai-toolbox.manifest.json +6 -1
  174. package/templates/skills/comms/config.json +18 -0
  175. package/templates/skills/comms/content.md +74 -0
  176. package/templates/skills/comms/files/references/ste-rules.md +73 -0
  177. package/templates/skills/comms/files/references/visual-shapes.md +112 -0
  178. package/templates/skills/swarm-scripts/SKILL.md +3 -2
  179. package/templates/skills/swarm-scripts/content.md +3 -2
@@ -1,25 +1,25 @@
1
1
  import {
2
2
  handleHook
3
- } from "./cli-brxyat7h.js";
4
- import"./cli-d8brzxjb.js";
5
- import"./cli-rvqz34y5.js";
3
+ } from "./cli-cr12paw2.js";
4
+ import"./cli-4wtq5jjv.js";
5
+ import"./cli-jecc01cb.js";
6
6
  import"./cli-hp1n6zq3.js";
7
7
  import"./cli-xvkmedgn.js";
8
8
  import"./cli-1ebpar1q.js";
9
9
  import"./cli-e7d20cty.js";
10
10
  import"./cli-3dpj7atn.js";
11
11
  import"./cli-f14fvzag.js";
12
- import"./cli-m9sxbkhm.js";
12
+ import"./cli-zvz62chv.js";
13
13
  import"./cli-bsakbbkm.js";
14
14
  import"./cli-9d8ntetj.js";
15
- import"./cli-y6b6fb76.js";
16
- import"./cli-kpv03zhj.js";
15
+ import"./cli-08b07b4r.js";
16
+ import"./cli-3apbzgyk.js";
17
17
  import"./cli-e29gmdmw.js";
18
18
  import"./cli-ej6gbxfb.js";
19
19
  import"./cli-sd0mxa3c.js";
20
20
  import"./cli-w5e1d1vv.js";
21
- import"./cli-anedxf1w.js";
22
- import"./cli-xqcq9y5e.js";
21
+ import"./cli-kjwt6hdf.js";
22
+ import"./cli-r2ap2czm.js";
23
23
  import"./cli-c4eeb5q2.js";
24
24
  import"./cli-btbzvq95.js";
25
25
  import"./cli-1m2e086m.js";
@@ -182,8 +182,8 @@ import {
182
182
  warnIfCorsAllowsAnyOrigin,
183
183
  wireHttpSpanLifecycle,
184
184
  writeSkillsToFilesystem
185
- } from "./cli-p73drk6p.js";
186
- import"./cli-8fc8de14.js";
185
+ } from "./cli-yb9qhqam.js";
186
+ import"./cli-0z2v4nhw.js";
187
187
  import {
188
188
  Anthropic
189
189
  } from "./cli-j490egb5.js";
@@ -201,16 +201,16 @@ import {
201
201
  import {
202
202
  calculateNextRun,
203
203
  dispatchScheduleTarget
204
- } from "./cli-56y3hch2.js";
204
+ } from "./cli-ygweqcn4.js";
205
205
  import {
206
206
  getModelsCatalog
207
- } from "./cli-hp2est46.js";
207
+ } from "./cli-sd5pv3b1.js";
208
208
  import {
209
209
  normalizeModelKey
210
- } from "./cli-0amc6myn.js";
210
+ } from "./cli-9fy6nk6g.js";
211
211
  import {
212
212
  getUserGrant
213
- } from "./cli-hzhhrt7b.js";
213
+ } from "./cli-k0cr4kat.js";
214
214
  import {
215
215
  can,
216
216
  clearAuditSink,
@@ -227,12 +227,12 @@ import {
227
227
  scriptSdkTypesWithGeneratedApis,
228
228
  scriptStdlibTypesWithGeneratedApis,
229
229
  typecheckScript
230
- } from "./cli-n9grk3yd.js";
230
+ } from "./cli-n3dz2942.js";
231
231
  import {
232
232
  collectScriptReferences,
233
233
  getApp,
234
234
  listAppRecords
235
- } from "./cli-tebsjpk7.js";
235
+ } from "./cli-19f354qr.js";
236
236
  import {
237
237
  require_dist
238
238
  } from "./cli-qgm2pfpq.js";
@@ -240,7 +240,7 @@ import {
240
240
  checkHeartbeatChecklist,
241
241
  runHeartbeatSweep,
242
242
  stopHeartbeat
243
- } from "./cli-cdjezzc7.js";
243
+ } from "./cli-nye12xk5.js";
244
244
  import {
245
245
  AGENT_MAX_TASKS_CONFIG_KEY,
246
246
  createResumeFollowUp,
@@ -255,7 +255,7 @@ import {
255
255
  touchRuntimeInstance,
256
256
  upsertRuntimeInstance,
257
257
  upsertSwarmConfigWithPolicyMirror
258
- } from "./cli-3n7cbfjn.js";
258
+ } from "./cli-mnmsfd1w.js";
259
259
  import {
260
260
  isMultiRuntimeEnabled
261
261
  } from "./cli-07jd68a1.js";
@@ -278,7 +278,7 @@ import {
278
278
  startWorkflowExecution,
279
279
  validateJsonSchema,
280
280
  verifyHmacSignature
281
- } from "./cli-f8j56xv2.js";
281
+ } from "./cli-6pqcb4q0.js";
282
282
  import"./cli-1ebpar1q.js";
283
283
  import {
284
284
  deriveCodexKeySuffix,
@@ -363,11 +363,11 @@ import {
363
363
  upsertScriptByName,
364
364
  upsertScriptConnection,
365
365
  validateDefinition
366
- } from "./cli-0er5m69z.js";
366
+ } from "./cli-aae6hz6a.js";
367
367
  import"./cli-epan13p1.js";
368
368
  import {
369
369
  searchScripts
370
- } from "./cli-kzvhgvk3.js";
370
+ } from "./cli-2qts1hys.js";
371
371
  import {
372
372
  CANDIDATE_SET_MULTIPLIER,
373
373
  getEmbeddingProvider,
@@ -375,7 +375,7 @@ import {
375
375
  init_constants as init_constants2,
376
376
  init_reranker,
377
377
  rerank
378
- } from "./cli-5khqvvnq.js";
378
+ } from "./cli-3q5ejx9p.js";
379
379
  import {
380
380
  detachedProcessGroup,
381
381
  forceTerminateProcessGroup,
@@ -386,7 +386,7 @@ import {
386
386
  import {
387
387
  getApiKey
388
388
  } from "./cli-f14fvzag.js";
389
- import"./cli-m9sxbkhm.js";
389
+ import"./cli-zvz62chv.js";
390
390
  import {
391
391
  acquireOAuthRefreshLock,
392
392
  buildAuthorizationUrl,
@@ -410,7 +410,7 @@ import {
410
410
  updateAuthorizationIdentity,
411
411
  updateOAuthAppById,
412
412
  upsertAuthorization
413
- } from "./cli-dcem3pr1.js";
413
+ } from "./cli-9hspd3dp.js";
414
414
  import"./cli-fad8m16k.js";
415
415
  import"./cli-aehm1rbq.js";
416
416
  import"./cli-bsakbbkm.js";
@@ -418,7 +418,7 @@ import"./cli-51tf7ac3.js";
418
418
  import {
419
419
  MAX_TASK_ATTACHMENT_BYTES,
420
420
  recordTaskAttachmentUpload
421
- } from "./cli-hz8xhefy.js";
421
+ } from "./cli-kgz4np97.js";
422
422
  import {
423
423
  FilesError,
424
424
  getFileStorageProvider,
@@ -441,10 +441,10 @@ import {
441
441
  revokeSessionToken,
442
442
  revokeToken,
443
443
  unlinkIdentity
444
- } from "./cli-xqcpg1st.js";
444
+ } from "./cli-gv88e1vf.js";
445
445
  import {
446
446
  createTaskWithSiblingAwareness
447
- } from "./cli-7gn7c2af.js";
447
+ } from "./cli-q50ef8g0.js";
448
448
  import {
449
449
  ensure,
450
450
  getSlackApp,
@@ -460,7 +460,7 @@ import {
460
460
  withRemoteContext,
461
461
  withSpan,
462
462
  withSpanContext
463
- } from "./cli-dk3me3qs.js";
463
+ } from "./cli-d8ftsp62.js";
464
464
  import"./cli-q51yprfq.js";
465
465
  import"./cli-9d8ntetj.js";
466
466
  import"./cli-yatxqynm.js";
@@ -536,6 +536,7 @@ import {
536
536
  RepoGuidelinesInputSchema,
537
537
  RepoHooksSchema,
538
538
  ResumeReasonSchema,
539
+ RoutingReasonSchema,
539
540
  RuntimeInstanceSchema,
540
541
  ScheduledTaskSchema,
541
542
  ScheduledTaskTargetTypeSchema,
@@ -760,6 +761,7 @@ import {
760
761
  init_request_auth_context,
761
762
  init_steering,
762
763
  init_swarm_config_guard,
764
+ init_task_tool_manifest,
763
765
  init_telemetry,
764
766
  init_templates,
765
767
  init_types,
@@ -798,6 +800,7 @@ import {
798
800
  moveAssetKey,
799
801
  normalizeDate,
800
802
  pageContextKey,
803
+ parseTaskToolManifest,
801
804
  pauseTask,
802
805
  placeholderForConfigKey,
803
806
  promoteDraftTask,
@@ -814,6 +817,7 @@ import {
814
817
  resolvePromptTemplate,
815
818
  resumeTask,
816
819
  searchSkills,
820
+ selectTaskTools,
817
821
  setAgentHarnessProvider,
818
822
  setApiKeyName,
819
823
  setFavorite,
@@ -861,12 +865,12 @@ import {
861
865
  upsertSwarmConfig,
862
866
  validateConfigValue,
863
867
  withFavoriteFlags
864
- } from "./cli-6s2y152y.js";
868
+ } from "./cli-yab68w40.js";
865
869
  import {
866
870
  IDENTITY_FIELD_BUDGETS,
867
871
  IdentityFieldBudgetError,
868
872
  init_identity_field_budget
869
- } from "./cli-y6b6fb76.js";
873
+ } from "./cli-08b07b4r.js";
870
874
  import {
871
875
  getAllTemplateDefinitions,
872
876
  getTemplateDefinition,
@@ -877,7 +881,7 @@ import {
877
881
  interpolate,
878
882
  isSteeringEnabled,
879
883
  resolveTemplate
880
- } from "./cli-kpv03zhj.js";
884
+ } from "./cli-3apbzgyk.js";
881
885
  import {
882
886
  MAX_PROFILE_FILE_LENGTH,
883
887
  getAppUrl,
@@ -889,7 +893,8 @@ import {
889
893
  import"./cli-c2mk1kgf.js";
890
894
  import {
891
895
  init_env_flag,
892
- isEnvFlagEnabled
896
+ isEnvFlagEnabled,
897
+ parseEnvFlag
893
898
  } from "./cli-ej6gbxfb.js";
894
899
  import {
895
900
  init_zod
@@ -906,13 +911,13 @@ import {
906
911
  import {
907
912
  init_package,
908
913
  package_default
909
- } from "./cli-anedxf1w.js";
914
+ } from "./cli-kjwt6hdf.js";
910
915
  import {
911
916
  init_secret_scrubber,
912
917
  registerVolatileSecret,
913
918
  scrubObject,
914
919
  scrubSecrets
915
- } from "./cli-xqcq9y5e.js";
920
+ } from "./cli-r2ap2czm.js";
916
921
  import {
917
922
  import_websocket,
918
923
  import_websocket_server
@@ -5073,6 +5078,7 @@ async function handleApprovalRequests(req, res, pathSegments, queryParams) {
5073
5078
  });
5074
5079
  await createTaskExtended(taskText, {
5075
5080
  agentId: sourceTask.agentId,
5081
+ routingReason: sourceTask.agentId ? "continuity" : undefined,
5076
5082
  parentTaskId: updated.sourceTaskId,
5077
5083
  source: "system",
5078
5084
  taskType: "hitl-follow-up",
@@ -5723,10 +5729,19 @@ function singleHeader(req, name) {
5723
5729
  const raw = req.headers[name];
5724
5730
  return Array.isArray(raw) ? raw[0] : raw;
5725
5731
  }
5726
- async function userMayReadSecrets(req) {
5732
+ async function requestMayReadSecrets(req) {
5727
5733
  const auth = getRequestAuth(req);
5728
5734
  if (auth?.kind === "operator")
5729
5735
  return true;
5736
+ if (auth?.kind === "agent") {
5737
+ const agent = await getAgentById(auth.agentId);
5738
+ return can({
5739
+ principal: { kind: "agent", agentId: auth.agentId, isLead: agent?.isLead ?? false },
5740
+ verb: "config.read.secrets",
5741
+ resource: { kind: "none" },
5742
+ source: "http"
5743
+ }).allow;
5744
+ }
5730
5745
  if (auth?.kind !== "user")
5731
5746
  return true;
5732
5747
  if (!isRbacEnabled())
@@ -5735,7 +5750,7 @@ async function userMayReadSecrets(req) {
5735
5750
  return grant.grantsAll || grant.verbs.has("config.read.secrets");
5736
5751
  }
5737
5752
  async function resolveSecretsRead(req, includeSecrets) {
5738
- if (!includeSecrets || await userMayReadSecrets(req)) {
5753
+ if (!includeSecrets || await requestMayReadSecrets(req)) {
5739
5754
  return { effectiveIncludeSecrets: includeSecrets, secretsNote: "" };
5740
5755
  }
5741
5756
  return { effectiveIncludeSecrets: false, secretsNote: SECRETS_FORCE_MASK_NOTE };
@@ -5744,7 +5759,7 @@ async function ensureConfigAdmin(req, res, verb) {
5744
5759
  const auth = getRequestAuth(req);
5745
5760
  if (auth?.kind === "operator" || auth?.kind === "user")
5746
5761
  return true;
5747
- const agentId = singleHeader(req, "x-agent-id");
5762
+ const agentId = auth?.kind === "agent" ? auth.agentId : singleHeader(req, "x-agent-id");
5748
5763
  const agent = agentId ? await getAgentById(agentId) : undefined;
5749
5764
  const decision = can({
5750
5765
  principal: { kind: "agent", agentId: agentId ?? "", isLead: agent?.isLead ?? false },
@@ -8977,7 +8992,9 @@ class StreamableHTTPServerTransport {
8977
8992
 
8978
8993
  // src/http/mcp.ts
8979
8994
  init_db();
8995
+ init_env_flag();
8980
8996
  init_request_auth_context();
8997
+ init_task_tool_manifest();
8981
8998
  var DEFAULT_MCP_TRANSPORT_IDLE_TIMEOUT_MS = 2 * 60 * 60 * 1000;
8982
8999
  function markMcpTransportActivity(sessionActivity, sessionId, now = Date.now()) {
8983
9000
  if (sessionId) {
@@ -9113,8 +9130,24 @@ async function handleMcp(req, res, transports, sessionActivity = {}, sessionAgen
9113
9130
  delete sessionActivity[transport.sessionId];
9114
9131
  }
9115
9132
  };
9116
- const configValue = (await getResolvedConfig(agentId)).find((config) => config.key === "SCRIPTS_ONLY_MCP")?.value;
9133
+ const configs = await getResolvedConfig(agentId);
9134
+ const configValue = configs.find((config) => config.key === "SCRIPTS_ONLY_MCP")?.value;
9135
+ const preloadEnabled = parseEnvFlag(configs.find((config) => config.key === "TASK_TOOL_PRELOAD_ENABLED")?.value ?? process.env.TASK_TOOL_PRELOAD_ENABLED, false);
9136
+ let preloadedTools = [];
9137
+ if (preloadEnabled) {
9138
+ const taskId = headerValue(req.headers["x-source-task-id"]);
9139
+ const task = taskId ? await getTaskById(taskId) : undefined;
9140
+ if (task?.agentId === agentId) {
9141
+ const manifestValue = configs.find((config) => config.key === "TASK_TOOL_MANIFESTS")?.value ?? process.env.TASK_TOOL_MANIFESTS ?? "{}";
9142
+ try {
9143
+ preloadedTools = selectTaskTools(parseTaskToolManifest(manifestValue), task);
9144
+ } catch {
9145
+ console.warn("[MCP] Invalid TASK_TOOL_MANIFESTS; using ordinary tool discovery");
9146
+ }
9147
+ }
9148
+ }
9117
9149
  const server = await createServer({
9150
+ preloadedTools,
9118
9151
  scriptsOnly: resolveScriptsOnlyMode({
9119
9152
  env: process.env.SCRIPTS_ONLY_MCP,
9120
9153
  configValue
@@ -18278,6 +18311,8 @@ var agentTaskBodySchema = exports_external.object({
18278
18311
  template: exports_external.string().optional(),
18279
18312
  task: exports_external.string().optional(),
18280
18313
  agentId: exports_external.string().optional(),
18314
+ routingReason: RoutingReasonSchema.optional(),
18315
+ routingNote: exports_external.string().max(200).optional(),
18281
18316
  tags: exports_external.array(exports_external.string()).optional(),
18282
18317
  priority: exports_external.number().int().min(0).max(100).optional(),
18283
18318
  offerMode: exports_external.boolean().optional(),
@@ -18738,6 +18773,8 @@ async function handleScriptRuns(req, res, pathSegments, queryParams, agentId) {
18738
18773
  if (!task) {
18739
18774
  task = await createTaskExtended(parsed.body.template ?? parsed.body.task ?? parsed.body.stepKey, {
18740
18775
  agentId: parsed.body.agentId,
18776
+ routingReason: parsed.body.routingReason ?? (parsed.body.agentId ? "human_pinned" : undefined),
18777
+ routingNote: parsed.body.routingNote,
18741
18778
  tags: parsed.body.tags,
18742
18779
  priority: parsed.body.priority,
18743
18780
  offeredTo: parsed.body.offerMode ? parsed.body.agentId : undefined,
@@ -22007,6 +22044,8 @@ var createTask = route({
22007
22044
  body: exports_external.object({
22008
22045
  task: exports_external.string().min(1),
22009
22046
  agentId: exports_external.string().optional(),
22047
+ routingReason: RoutingReasonSchema.optional(),
22048
+ routingNote: exports_external.string().max(200).optional(),
22010
22049
  taskType: exports_external.string().optional(),
22011
22050
  tags: exports_external.array(exports_external.string()).optional(),
22012
22051
  priority: exports_external.number().int().min(0).max(100).optional(),
@@ -22023,6 +22062,14 @@ var createTask = route({
22023
22062
  modelTier: ModelTierSchema.optional(),
22024
22063
  effort: ReasoningEffortSchema.optional(),
22025
22064
  draft: exports_external.boolean().optional()
22065
+ }).superRefine((body, ctx) => {
22066
+ if ((body.agentId !== undefined || body.offeredTo !== undefined) && !body.routingReason) {
22067
+ ctx.addIssue({
22068
+ code: exports_external.ZodIssueCode.custom,
22069
+ message: "routingReason is required when agentId or offeredTo is supplied.",
22070
+ path: ["routingReason"]
22071
+ });
22072
+ }
22026
22073
  }),
22027
22074
  responses: {
22028
22075
  201: { description: "Task created", schema: AgentTaskSchema },
@@ -22492,9 +22539,10 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
22492
22539
  if (lead)
22493
22540
  defaultAgentId = lead.id;
22494
22541
  }
22542
+ const parentTask = parsed.body.parentTaskId ? await getTaskById(parsed.body.parentTaskId) : null;
22495
22543
  let assetKey;
22496
22544
  try {
22497
- const inheritedKey = parsed.body.parentTaskId ? (await getTaskById(parsed.body.parentTaskId))?.key : undefined;
22545
+ const inheritedKey = parentTask?.key;
22498
22546
  const requestedKey = parsed.body.key ?? inheritedKey;
22499
22547
  assetKey = requestedKey ? await authorizeAssetKeyWrite(requestedKey, trustedUserId) : undefined;
22500
22548
  } catch (error) {
@@ -22508,6 +22556,8 @@ async function handleTasks(req, res, pathSegments, queryParams, myAgentId) {
22508
22556
  const task = await createTaskWithSiblingAwareness(parsed.body.task, {
22509
22557
  key: assetKey,
22510
22558
  agentId: defaultAgentId,
22559
+ routingReason: parsed.body.routingReason ?? (defaultAgentId ? parentTask?.agentId === defaultAgentId ? "continuity" : "skill" : undefined),
22560
+ routingNote: parsed.body.routingNote,
22511
22561
  creatorAgentId: myAgentId || undefined,
22512
22562
  taskType: parsed.body.taskType || undefined,
22513
22563
  tags: parsed.body.tags || undefined,
@@ -24780,6 +24830,7 @@ async function routeKapsoInbound(payload) {
24780
24830
  }
24781
24831
  const task = await createTaskWithSiblingAwareness(await buildTaskDescription(payload), {
24782
24832
  agentId: mapping.agentId ?? null,
24833
+ routingReason: mapping.agentId ? "human_pinned" : undefined,
24783
24834
  source: "system",
24784
24835
  taskType: "kapso-inbound",
24785
24836
  tags: ["kapso-whatsapp", "inbound"],
@@ -26504,7 +26555,7 @@ async function shutdown() {
26504
26555
  sessionsProcessed: getServerSessionsProcessed()
26505
26556
  });
26506
26557
  if (hasCapability("scheduling")) {
26507
- const { stopScheduler } = await import("./index-antf9t4p.js");
26558
+ const { stopScheduler } = await import("./index-8hmeg8j1.js");
26508
26559
  stopScheduler();
26509
26560
  }
26510
26561
  stopHeartbeat();
@@ -26512,7 +26563,7 @@ async function shutdown() {
26512
26563
  await stopScriptRunSupervisor();
26513
26564
  await stopSlackApp();
26514
26565
  if (process.env.OAUTH_KEEPALIVE_DISABLE !== "true") {
26515
- const { stopOAuthKeepalive } = await import("./keepalive-c4sp7yvd.js");
26566
+ const { stopOAuthKeepalive } = await import("./keepalive-dxc12gvg.js");
26516
26567
  await stopOAuthKeepalive();
26517
26568
  }
26518
26569
  stopOAuthPendingGc();
@@ -26579,15 +26630,15 @@ try {
26579
26630
  console.warn("[startup] CAPABILITIES upgrade seed failed (non-fatal):", err);
26580
26631
  }
26581
26632
  try {
26582
- const { seedPricingFromModelsDev } = await import("./seed-pricing-t6y8d0vf.js");
26633
+ const { seedPricingFromModelsDev } = await import("./seed-pricing-zbrn83xv.js");
26583
26634
  seedPricingFromModelsDev();
26584
- const { startPricingRefreshLoop } = await import("./pricing-refresh-kqxd7w9h.js");
26635
+ const { startPricingRefreshLoop } = await import("./pricing-refresh-kaqg567e.js");
26585
26636
  startPricingRefreshLoop();
26586
26637
  } catch (err) {
26587
26638
  console.error("[startup] Failed to seed pricing rows:", err);
26588
26639
  }
26589
26640
  try {
26590
- const { ensureRbacSeedsSynced } = await import("./rbac-roles-t3wygpth.js");
26641
+ const { ensureRbacSeedsSynced } = await import("./rbac-roles-cf97v1vd.js");
26591
26642
  ensureRbacSeedsSynced();
26592
26643
  } catch (err) {
26593
26644
  console.error("[startup] Failed to sync RBAC seed rows:", err);
@@ -26595,7 +26646,7 @@ try {
26595
26646
  throw err;
26596
26647
  }
26597
26648
  try {
26598
- const { runAllSeeders } = await import("./index-47ghesbn.js");
26649
+ const { runAllSeeders } = await import("./index-6nsbg88z.js");
26599
26650
  await runAllSeeders({ scriptEmbeddingMode: "skip" });
26600
26651
  } catch (err) {
26601
26652
  console.error("[startup] Failed to seed built-in entities:", err);
@@ -26636,36 +26687,36 @@ httpServer.listen(port, async () => {
26636
26687
  await initWorkflows();
26637
26688
  await startScriptRunSupervisor(getMcpBaseUrl());
26638
26689
  if (hasCapability("scheduling")) {
26639
- const { startScheduler } = await import("./index-antf9t4p.js");
26640
- const { getExecutorRegistry: getExecutorRegistry2 } = await import("./index-d2mytx95.js");
26690
+ const { startScheduler } = await import("./index-8hmeg8j1.js");
26691
+ const { getExecutorRegistry: getExecutorRegistry2 } = await import("./index-cqtebbhb.js");
26641
26692
  const intervalMs = Number(process.env.SCHEDULER_INTERVAL_MS) || 1e4;
26642
26693
  startScheduler(getExecutorRegistry2(), intervalMs, {
26643
26694
  runId: globalState.__runId
26644
26695
  });
26645
26696
  }
26646
26697
  if (!isEnvFlagEnabled("HEARTBEAT_DISABLE", false)) {
26647
- const { startHeartbeat } = await import("./index-0ez2aack.js");
26698
+ const { startHeartbeat } = await import("./index-n28pw1zt.js");
26648
26699
  const heartbeatMs = Number(process.env.HEARTBEAT_INTERVAL_MS) || 90000;
26649
26700
  startHeartbeat(heartbeatMs);
26650
26701
  }
26651
26702
  if (process.env.OAUTH_KEEPALIVE_DISABLE !== "true") {
26652
- const { startOAuthKeepalive } = await import("./keepalive-c4sp7yvd.js");
26703
+ const { startOAuthKeepalive } = await import("./keepalive-dxc12gvg.js");
26653
26704
  startOAuthKeepalive();
26654
26705
  }
26655
26706
  if (process.env.OAUTH_REFRESH_SWEEP_DISABLE !== "true") {
26656
- const { startOAuthRefreshSweep } = await import("./oauth-refresh-sweep-wtqgnh3c.js");
26707
+ const { startOAuthRefreshSweep } = await import("./oauth-refresh-sweep-1x1ac722.js");
26657
26708
  startOAuthRefreshSweep();
26658
26709
  }
26659
26710
  startOAuthPendingGc();
26660
26711
  await startMemoryGc();
26661
26712
  await startDbRetention();
26662
- import("./boot-reembed-cn357y5n.js").then(({ runBootReembed }) => runBootReembed()).catch((err) => {
26713
+ import("./boot-reembed-fqzxxzjh.js").then(({ runBootReembed }) => runBootReembed()).catch((err) => {
26663
26714
  console.error("[boot-reembed] startup backfill failed (non-fatal):", err);
26664
26715
  });
26665
- import("./boot-reembed-9rxmb26n.js").then(({ runBootReembedScripts }) => runBootReembedScripts()).catch((err) => {
26716
+ import("./boot-reembed-wxa8ya0s.js").then(({ runBootReembedScripts }) => runBootReembedScripts()).catch((err) => {
26666
26717
  console.error("[boot-reembed-scripts] startup backfill failed (non-fatal):", err);
26667
26718
  });
26668
- import("./boot-scrub-logs-5tpp0x3y.js").then(({ runBootScrubLogs }) => runBootScrubLogs()).catch((err) => {
26719
+ import("./boot-scrub-logs-jnyndh79.js").then(({ runBootScrubLogs }) => runBootScrubLogs()).catch((err) => {
26669
26720
  console.error("[boot-scrub-logs] startup scrub failed (non-fatal):", err);
26670
26721
  });
26671
26722
  }).on("error", (err) => {