@desplega.ai/agent-swarm 2.7.10 → 2.8.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 (296) hide show
  1. package/dist/acp-adapter-pdy3qsvg.js +15 -0
  2. package/dist/{actions-b8aqhrsg.js → actions-pwjpn0j6.js} +19 -20
  3. package/dist/{amp-adapter-4c165vgn.js → amp-adapter-cq9jgj6x.js} +2 -3
  4. package/dist/{app-m9khefrh.js → app-cnfffgwg.js} +3 -3
  5. package/dist/{assistant-rh4v3ntz.js → assistant-kpn317y1.js} +21 -22
  6. package/dist/{boot-args-schema-hwkc8bzv.js → boot-args-schema-pbbnhmc3.js} +1 -1
  7. package/dist/{boot-reembed-fdyk55h4.js → boot-reembed-9m0ysxma.js} +1 -1
  8. package/dist/{boot-reembed-5y6yw9sj.js → boot-reembed-majbn53m.js} +1 -1
  9. package/dist/{boot-scrub-sweep-r5r8kqsn.js → boot-scrub-sweep-app8g8ym.js} +3 -3
  10. package/dist/{boot-seeds-8f9zt5cm.js → boot-seeds-pbtmvcjm.js} +4 -5
  11. package/dist/{claude-adapter-s5df247c.js → claude-adapter-wn1g3qp5.js} +7 -8
  12. package/dist/{claude-managed-adapter-h74d06yz.js → claude-managed-adapter-jh6c523j.js} +3 -3
  13. package/dist/{claude-managed-setup-9gsmwzyx.js → claude-managed-setup-pd47nzch.js} +6 -6
  14. package/dist/{claude-sdk-session-dq1j4nz9.js → claude-sdk-session-3a2a6589.js} +9066 -8818
  15. package/dist/{cli-n5yexkdg.js → cli-0b4zam62.js} +1 -0
  16. package/dist/{cli-5wfz00be.js → cli-0jzra9ad.js} +2 -2
  17. package/dist/{cli-zjphdj1a.js → cli-0ntbxyaa.js} +40 -18
  18. package/dist/{cli-yz7v0sh4.js → cli-1xh9a7hn.js} +4 -6
  19. package/dist/{cli-eqtfgfr6.js → cli-2gxeg5gr.js} +1 -1
  20. package/dist/{cli-hfkwwy1h.js → cli-2zp0et3v.js} +21 -2
  21. package/dist/{cli-6m6b4bep.js → cli-3rkdne1h.js} +2 -2
  22. package/dist/{cli-mr97t7cc.js → cli-4r05hnqa.js} +263 -14
  23. package/dist/{cli-jc1g9ndz.js → cli-5j88qqa8.js} +10 -5
  24. package/dist/{cli-xfjrc279.js → cli-5mrq3ake.js} +48 -14
  25. package/dist/{cli-an1knn2k.js → cli-6mma83xa.js} +5 -5
  26. package/dist/{cli-tph5wt3y.js → cli-6wj7p986.js} +1 -1
  27. package/dist/{cli-t73cas91.js → cli-7349va39.js} +8100 -7620
  28. package/dist/{cli-5xcb8gxq.js → cli-7b8sbmag.js} +8 -8
  29. package/dist/{cli-3xj33nrx.js → cli-7cp6aa1q.js} +10 -3
  30. package/dist/{cli-mp9aa8g5.js → cli-7p1kvkck.js} +6 -6
  31. package/dist/{cli-j7d73g1y.js → cli-7w69ne2f.js} +3035 -354
  32. package/dist/{cli-cr14kftt.js → cli-89cqnasv.js} +3 -3
  33. package/dist/{cli-w3bk0dgv.js → cli-8aes17e4.js} +2 -2
  34. package/dist/{cli-7wz05bx3.js → cli-93k32c37.js} +468 -745
  35. package/dist/{cli-eqk5p56g.js → cli-9vhebtjz.js} +9 -9
  36. package/dist/{cli-td33w98c.js → cli-9wngrawf.js} +10 -10
  37. package/dist/cli-a3b239vq.js +242 -0
  38. package/dist/{cli-kx4c8j05.js → cli-b085njxz.js} +63 -19
  39. package/dist/{cli-8ewkreqd.js → cli-b5rs97a6.js} +7 -9
  40. package/dist/{cli-bxz823sz.js → cli-b8e9nb04.js} +1 -1
  41. package/dist/{cli-nj3x45rw.js → cli-bb431xey.js} +52 -43
  42. package/dist/{cli-36wdfzgn.js → cli-bsywb58a.js} +8 -8
  43. package/dist/{cli-18qt3few.js → cli-cyhbbd1z.js} +1 -1
  44. package/dist/{cli-eb2azq8n.js → cli-d3p5vwbk.js} +9 -9
  45. package/dist/{cli-2tsfpc70.js → cli-dy32zecz.js} +1 -1
  46. package/dist/{cli-rjyghzg4.js → cli-g70vxtjh.js} +2 -2
  47. package/dist/{cli-55bkx8hh.js → cli-gax7fk3t.js} +1 -1
  48. package/dist/{cli-jg24scat.js → cli-jcpr5smb.js} +3 -3
  49. package/dist/{cli-n07eecjs.js → cli-jywyhqws.js} +3 -3
  50. package/dist/{cli-38yww4e9.js → cli-k0615eh8.js} +8 -8
  51. package/dist/{cli-3xddv0rk.js → cli-k26bkr9t.js} +5 -7
  52. package/dist/{cli-xd5ebp64.js → cli-k93bq1wq.js} +3 -3
  53. package/dist/{cli-f2zenhja.js → cli-kc7v1nfv.js} +1 -1
  54. package/dist/{cli-x9exydey.js → cli-m4dqmnbp.js} +1 -1
  55. package/dist/{cli-gpwhbgx0.js → cli-m9s2qff2.js} +57 -25
  56. package/dist/{cli-ybjdc978.js → cli-mrt48bx7.js} +7 -4
  57. package/dist/{cli-ttbqe3q4.js → cli-p1w18yhx.js} +1 -1
  58. package/dist/{cli-h49ejvmc.js → cli-pcad4cb1.js} +1 -1
  59. package/dist/{cli-tmft5dz2.js → cli-qmqk2yc2.js} +1 -1
  60. package/dist/{cli-g1px1g2e.js → cli-re4raaj0.js} +1 -1
  61. package/dist/{cli-xbtq4d6s.js → cli-sn7rtnj4.js} +12 -8
  62. package/dist/{cli-n9abj89w.js → cli-syybb0p1.js} +8 -8
  63. package/dist/{cli-v2fwbnsk.js → cli-tacge1w0.js} +6 -6
  64. package/dist/{cli-pyrxt9gw.js → cli-tk7cjj8h.js} +1 -1
  65. package/dist/{cli-xvymtmv4.js → cli-tqegb8eq.js} +3 -3
  66. package/dist/{cli-kf3pxxdg.js → cli-v1dv1r37.js} +1 -1
  67. package/dist/{cli-z9cs5m0w.js → cli-vbh10fqa.js} +12 -12
  68. package/dist/{cli-3xcwp3z8.js → cli-vj75tyaw.js} +3 -3
  69. package/dist/{cli-xncjscpm.js → cli-vqptjbr7.js} +50 -24
  70. package/dist/{cli-q581b386.js → cli-wk18cm92.js} +5 -5
  71. package/dist/{cli-4vwxp550.js → cli-x1wa213s.js} +1 -1
  72. package/dist/{cli-n9ftpys4.js → cli-x6t50dmw.js} +7 -7
  73. package/dist/{cli-jrp1dt73.js → cli-xzm9vcfg.js} +1 -1
  74. package/dist/{cli-16phend6.js → cli-yn2bbre9.js} +1 -1
  75. package/dist/{cli-rt0ag4x1.js → cli-yncmerje.js} +5 -5
  76. package/dist/{cli-0m7rtm11.js → cli-zcsw143p.js} +1 -1
  77. package/dist/cli.js +18 -18
  78. package/dist/{codex-adapter-yr60sme6.js → codex-adapter-nha71q3n.js} +5 -6
  79. package/dist/{codex-hook-fac6175r.js → codex-hook-h3vk6xzr.js} +1 -1
  80. package/dist/{codex-session-runner-pch8x584.js → codex-session-runner-ak9x1k1h.js} +5 -6
  81. package/dist/{commands-phjfbkv0.js → commands-f587qpq8.js} +3 -3
  82. package/dist/{controller-jkx994pz.js → controller-hxx8wwy1.js} +2 -2
  83. package/dist/{controllers-connect-c4448kwa.js → controllers-connect-k5sg9m9h.js} +20 -21
  84. package/dist/{cursor-adapter-ndebqnm8.js → cursor-adapter-n5nc3mfe.js} +1 -2
  85. package/dist/{db-ef32tbfc.js → db-amm8w15a.js} +10 -2
  86. package/dist/{db-ez6egt6v.js → db-nzf8zb5z.js} +3 -3
  87. package/dist/{devin-adapter-z46ep5ph.js → devin-adapter-xedz98zv.js} +1 -1
  88. package/dist/{dispatcher-g3tt9hs9.js → dispatcher-89zrts8f.js} +18 -19
  89. package/dist/{dsh-adapter-tcyn3099.js → dsh-adapter-nrhbrjz8.js} +1 -2
  90. package/dist/{easter-egg-3d-e36hk5td.js → easter-egg-3d-533knw22.js} +1 -1
  91. package/dist/{embedding-space-4kyh5qqj.js → embedding-space-ezwenjmj.js} +6 -6
  92. package/dist/{embeddings-6a8v4a6t.js → embeddings-np74ht6g.js} +1 -1
  93. package/dist/{execute-3cbg0twf.js → execute-b3mrb1mv.js} +1 -1
  94. package/dist/{external-channel-se646snz.js → external-channel-z46yx9d7.js} +2 -2
  95. package/dist/{fx-adapter-yw795hqq.js → fx-adapter-3q12snn6.js} +7 -8
  96. package/dist/{grok-adapter-ttmcss2j.js → grok-adapter-ahb1w033.js} +7 -8
  97. package/dist/handlers-vbww69re.js +32 -0
  98. package/dist/heartbeat-dt9qw9c8.js +43 -0
  99. package/dist/{hook-hq93y5ej.js → hook-8k6fbz9b.js} +5 -5
  100. package/dist/{hook-g3nhexsy.js → hook-jgcgygex.js} +6 -6
  101. package/dist/{http-5a9p4h6y.js → http-haw4r8ne.js} +284 -142
  102. package/dist/{index-0eny15vj.js → index-2skqtd76.js} +2 -2
  103. package/dist/{index-6haqt3v5.js → index-4a0670yh.js} +8917 -8476
  104. package/dist/index-4xwaf5th.js +32 -0
  105. package/dist/{index-3c5pxbge.js → index-5gk12my8.js} +1 -1
  106. package/dist/{index-w7em4ktq.js → index-d6wkh8ar.js} +2 -2
  107. package/dist/index-f0hcrs8e.js +33 -0
  108. package/dist/{index-rvccek1w.js → index-gjwaqaq8.js} +5 -5
  109. package/dist/{index-e5pfbsys.js → index-hjhfk3ra.js} +3 -3
  110. package/dist/{index-1qw6f2dc.js → index-khe3gp0k.js} +4 -4
  111. package/dist/index-s4ewdma4.js +37 -0
  112. package/dist/{index-hgn3c961.js → index-tez78qj3.js} +979 -36
  113. package/dist/{index-s72rqgsx.js → index-tvfafeyy.js} +1 -1
  114. package/dist/{keepalive-1j4n4dmk.js → keepalive-xn6s7rmg.js} +3 -3
  115. package/dist/lead-6ygbfhbh.js +70 -0
  116. package/dist/{maintenance-dmghacy5.js → maintenance-vdts800b.js} +1 -1
  117. package/dist/{node-je82wjet.js → node-4c5jqxr3.js} +1 -1
  118. package/dist/{oauth-refresh-sweep-yy06c03c.js → oauth-refresh-sweep-094c8wfk.js} +2 -2
  119. package/dist/{onboard-52f9t5dm.js → onboard-v99eh56m.js} +3 -3
  120. package/dist/{opencode-adapter-krnh9jkn.js → opencode-adapter-dsagkhtw.js} +5 -6
  121. package/dist/{otel-impl-xjqz6wjj.js → otel-impl-q7yr9yp0.js} +1 -1
  122. package/dist/{pi-mono-adapter-dbxyp0qv.js → pi-mono-adapter-546cd1cc.js} +9 -9
  123. package/dist/{pricing-refresh-ctdr74pd.js → pricing-refresh-7dh2yase.js} +2 -3
  124. package/dist/{rbac-roles-ehv8s10n.js → rbac-roles-mdmc96p4.js} +3 -3
  125. package/dist/{rbac-roles-q0gr8eyj.js → rbac-roles-npbmdh77.js} +4 -6
  126. package/dist/{registry-hpjfmcfz.js → registry-32b1mft6.js} +1 -1
  127. package/dist/{render-v2-5b6chvcq.js → render-v2-twhhwmms.js} +3 -3
  128. package/dist/{resume-5a5d2845.js → resume-5gsrjd5e.js} +6 -6
  129. package/dist/{runtime-khxszyfp.js → runtime-1hv06jsn.js} +1 -1
  130. package/dist/{session-access-gj0bjhqg.js → session-access-m191x30x.js} +4 -4
  131. package/dist/{session-source-backfill-2sy0krfk.js → session-source-backfill-nt923ask.js} +2 -2
  132. package/dist/{setup-7ssfakk1.js → setup-wv467afy.js} +1 -1
  133. package/dist/{virtual-modules-pjj0knwf.js → virtual-modules-gazyapte.js} +3 -3
  134. package/dist/{work-objects-bf3syvhq.js → work-objects-8zkrpy13.js} +21 -22
  135. package/dist/{worker-follow-up-38xevga6.js → worker-follow-up-cecqszem.js} +18 -19
  136. package/dist/worker-mz5z7kj0.js +70 -0
  137. package/openapi.json +334 -7
  138. package/package.json +5 -5
  139. package/src/apps/definition.ts +11 -0
  140. package/src/apps/store.ts +28 -8
  141. package/src/be/db/model-profiles.ts +147 -38
  142. package/src/be/db/tasks/read.ts +5 -1
  143. package/src/be/db/workflow-run-definitions.ts +117 -0
  144. package/src/be/db.ts +24 -3
  145. package/src/be/memory/constants.ts +14 -1
  146. package/src/be/memory/key-paths.ts +8 -0
  147. package/src/be/memory/providers/sqlite-store.ts +160 -10
  148. package/src/be/memory/task-learning.ts +79 -14
  149. package/src/be/memory/types.ts +24 -1
  150. package/src/be/migrations/279_backfill_learning_expiry.sql +15 -0
  151. package/src/be/migrations/281_model_profiles_pr2.sql +28 -0
  152. package/src/be/migrations/283_workflow_run_definitions.sql +14 -0
  153. package/src/be/model-profile-check.ts +284 -0
  154. package/src/be/model-tier-resolution.ts +112 -12
  155. package/src/be/multi-runtime.ts +27 -0
  156. package/src/be/runtime-pools/routing.ts +52 -4
  157. package/src/be/scripts/typecheck.ts +1 -0
  158. package/src/be/seed-scripts/catalog/dreaming-learnings.ts +552 -0
  159. package/src/be/seed-scripts/catalog/dreaming-memtax-create.ts +389 -14
  160. package/src/be/seed-scripts/catalog/dreaming-memtax.ts +6 -3
  161. package/src/be/seed-scripts/index.ts +9 -0
  162. package/src/be/steering.ts +8 -2
  163. package/src/commands/onboard/agent-fs-version.ts +1 -1
  164. package/src/commands/runner.ts +32 -1
  165. package/src/fs/provider.ts +17 -3
  166. package/src/heartbeat/heartbeat.ts +12 -1
  167. package/src/heartbeat/index.ts +1 -0
  168. package/src/http/agents.ts +56 -4
  169. package/src/http/apps.ts +3 -1
  170. package/src/http/config.ts +2 -6
  171. package/src/http/index.ts +2 -3
  172. package/src/http/model-profiles.ts +58 -10
  173. package/src/http/poll.ts +36 -3
  174. package/src/http/schedules.ts +42 -3
  175. package/src/http/tasks.ts +37 -12
  176. package/src/http/workflows.ts +15 -2
  177. package/src/prompts/session-templates.ts +1 -1
  178. package/src/providers/acp-targets.ts +11 -6
  179. package/src/providers/amp-adapter.ts +1 -1
  180. package/src/providers/claude-sdk-session.ts +132 -23
  181. package/src/providers/codex-skill-resolver.ts +10 -4
  182. package/src/providers/cursor-adapter.ts +1 -1
  183. package/src/providers/devin-skill-resolver.ts +5 -5
  184. package/src/providers/dsh-adapter.ts +1 -1
  185. package/src/scheduler/schedule-task.ts +1 -0
  186. package/src/scripts-runtime/eval-harness.ts +14 -1
  187. package/src/scripts-runtime/executors/types.ts +3 -0
  188. package/src/scripts-runtime/sdk-allowlist.ts +1 -0
  189. package/src/scripts-runtime/swarm-sdk.ts +18 -1
  190. package/src/scripts-runtime/types/stdlib.d.ts +1 -0
  191. package/src/scripts-runtime/types/swarm-sdk.d.ts +1 -0
  192. package/src/server.ts +2 -0
  193. package/src/slack/app.ts +93 -0
  194. package/src/slack/inbound-dispatch.ts +18 -1
  195. package/src/slack/workspace-guard.ts +345 -0
  196. package/src/tasks/task-terminal-effects.ts +4 -0
  197. package/src/tasks/worker-follow-up.ts +102 -2
  198. package/src/tests/acp-adapter.test.ts +82 -0
  199. package/src/tests/apps-icon.test.ts +120 -0
  200. package/src/tests/chained-task-follow-up.test.ts +248 -0
  201. package/src/tests/check-pr-body.test.ts +40 -0
  202. package/src/tests/claude-sdk-lifecycle.test.ts +216 -1
  203. package/src/tests/claude-sdk-process.fixture.ts +57 -0
  204. package/src/tests/codex-skill-resolver.test.ts +31 -0
  205. package/src/tests/credentials-allowlist.test.ts +470 -0
  206. package/src/tests/db-task-read-contract.test.ts +5 -0
  207. package/src/tests/db-task-write-contract.test.ts +5 -0
  208. package/src/tests/deferred-wake-follow-up.test.ts +47 -0
  209. package/src/tests/docs-index-footprint.test.js +3 -3
  210. package/src/tests/dreaming-learnings.test.ts +1395 -0
  211. package/src/tests/dsh-adapter.test.ts +1 -1
  212. package/src/tests/explicit-model-validation.test.ts +2 -0
  213. package/src/tests/fs-provider.test.ts +42 -0
  214. package/src/tests/heartbeat.test.ts +28 -1
  215. package/src/tests/human-free-reclassify.test.ts +5 -1
  216. package/src/tests/list-endpoint-slimming.test.ts +17 -0
  217. package/src/tests/mcp-tools.test.ts +1 -1
  218. package/src/tests/migration-283-workflow-run-definitions.test.ts +69 -0
  219. package/src/tests/model-profile-check.test.ts +387 -0
  220. package/src/tests/model-profiles-api.test.ts +528 -1
  221. package/src/tests/profile-claim.test.ts +415 -3
  222. package/src/tests/profile-tier-alias.test.ts +382 -0
  223. package/src/tests/schedule-profile.test.ts +359 -0
  224. package/src/tests/script-connections.test.ts +6 -0
  225. package/src/tests/script-native-unawaited-drain.test.ts +167 -0
  226. package/src/tests/script-per-script-executor.test.ts +1 -0
  227. package/src/tests/scripts-sdk-bridge-tool-failure.test.ts +141 -0
  228. package/src/tests/seed-scripts.test.ts +2 -2
  229. package/src/tests/slack-inbound-receipts.test.ts +22 -2
  230. package/src/tests/slack-socket-ack.test.ts +16 -1
  231. package/src/tests/slack-workspace-guard.test.ts +905 -0
  232. package/src/tests/steering-core.test.ts +40 -0
  233. package/src/tests/store-progress-learning.test.ts +605 -20
  234. package/src/tests/tool-annotations.test.ts +1 -1
  235. package/src/tests/workflow-convergence.test.ts +46 -40
  236. package/src/tests/workflow-definition-pinning-recovery.test.ts +552 -0
  237. package/src/tests/workflow-definition-pinning.test.ts +645 -0
  238. package/src/tests/workflow-executors.test.ts +16 -7
  239. package/src/tests/workflow-foreach.test.ts +43 -20
  240. package/src/tests/workflow-notify-slack-ready.test.ts +161 -0
  241. package/src/tests/workflow-profile.test.ts +328 -0
  242. package/src/tools/app-upsert.ts +1 -1
  243. package/src/tools/memory-edit.ts +2 -1
  244. package/src/tools/model-profiles/check-model-profile.ts +63 -0
  245. package/src/tools/schedules/create-schedule.ts +45 -4
  246. package/src/tools/schedules/patch-schedule.ts +50 -4
  247. package/src/tools/schedules/update-schedule.ts +50 -4
  248. package/src/tools/script-run.ts +1 -1
  249. package/src/tools/send-task.ts +17 -2
  250. package/src/tools/store-progress.ts +15 -3
  251. package/src/tools/task-action.ts +9 -1
  252. package/src/tools/templates.ts +13 -0
  253. package/src/tools/tool-config.ts +2 -1
  254. package/src/tools/utils.ts +61 -4
  255. package/src/tools/workflows/create-workflow.ts +1 -1
  256. package/src/tools/workflows/retry-workflow-run.ts +1 -1
  257. package/src/tools/workflows/update-workflow.ts +10 -1
  258. package/src/types.ts +56 -1
  259. package/src/utils/credentials.ts +89 -12
  260. package/src/workflows/engine.ts +10 -1
  261. package/src/workflows/executors/agent-task.ts +21 -2
  262. package/src/workflows/executors/foreach.ts +4 -1
  263. package/src/workflows/executors/notify.ts +62 -6
  264. package/src/workflows/executors/sub-workflow.ts +1 -1
  265. package/src/workflows/executors/swarm-script.ts +4 -1
  266. package/src/workflows/foreach-driver.ts +8 -5
  267. package/src/workflows/limits.ts +2 -1
  268. package/src/workflows/model-validation.ts +27 -2
  269. package/src/workflows/patch-definition.ts +3 -1
  270. package/src/workflows/recovery.ts +6 -6
  271. package/src/workflows/resume.ts +9 -9
  272. package/src/workflows/retry-poller.ts +2 -2
  273. package/templates/skills/apps/SKILL.md +2 -0
  274. package/templates/skills/apps/content.md +2 -0
  275. package/templates/skills/code-quality/content.md +12 -0
  276. package/templates/skills/memory/content.md +8 -0
  277. package/templates/skills/scheduling/config.json +1 -1
  278. package/templates/skills/scheduling/content.md +2 -2
  279. package/templates/skills/swarm-docs/content.md +4 -0
  280. package/templates/skills/swarm-extensions/content.md +1 -1
  281. package/templates/skills/swarm-scripts/SKILL.md +2 -2
  282. package/templates/skills/swarm-scripts/content.md +2 -2
  283. package/templates/skills/work-on-task/SKILL.md +2 -0
  284. package/templates/skills/work-on-task/content.md +2 -0
  285. package/templates/workflows/dreaming/content.md +174 -7
  286. package/dist/acp-adapter-srfhs1s9.js +0 -16
  287. package/dist/cli-bzvs88tv.js +0 -339
  288. package/dist/cli-cyn9v8zr.js +0 -748
  289. package/dist/cli-ed6yqpf1.js +0 -779
  290. package/dist/handlers-17wha3ze.js +0 -33
  291. package/dist/heartbeat-gwewgdms.js +0 -42
  292. package/dist/index-8arwq8mw.js +0 -34
  293. package/dist/index-tpw054az.js +0 -38
  294. package/dist/index-waq75j2j.js +0 -31
  295. package/dist/lead-re73kdgc.js +0 -72
  296. package/dist/worker-r8mz7a65.js +0 -72
@@ -16,6 +16,11 @@ import {
16
16
  updateScheduledTask,
17
17
  withFavoriteFlags,
18
18
  } from "../be/db";
19
+ import {
20
+ modelProfileRefError,
21
+ scheduleProfileUpdate,
22
+ taskProfileError,
23
+ } from "../be/db/model-profiles";
19
24
  import { explicitModelErrorForAgent } from "../be/model-validation";
20
25
  import { mergeScheduleTiming, validateRecurringTiming } from "../be/schedules/validate";
21
26
  import { getScript } from "../be/scripts/db";
@@ -52,6 +57,8 @@ const scheduleUpdateBodySchema = z.object({
52
57
  timezone: z.string().optional(),
53
58
  model: z.string().nullable().optional(),
54
59
  modelTier: ModelTierSchema.nullable().optional(),
60
+ /** Model profile for every fired task. Exclusive with model/modelTier; setting one clears the other. */
61
+ profile: z.string().nullable().optional(),
55
62
  /** Accept a `model` the catalog does not list (a custom id). Without it an unknown id is a 400. */
56
63
  allowCustomModel: z.boolean().optional(),
57
64
  nextRunAt: z.string().nullable().optional(),
@@ -113,6 +120,8 @@ const createSchedule = route({
113
120
  timezone: z.string().optional(),
114
121
  model: z.string().optional(),
115
122
  modelTier: ModelTierSchema.optional(),
123
+ /** Model profile for every fired task. Exclusive with model/modelTier. */
124
+ profile: z.string().optional(),
116
125
  /** Accept a `model` the catalog does not list (a custom id). Without it an unknown id is a 400. */
117
126
  allowCustomModel: z.boolean().optional(),
118
127
  scheduleType: z.enum(["recurring", "one_time"]).optional(),
@@ -411,6 +420,16 @@ export async function handleSchedules(
411
420
  jsonError(res, modelError, 400);
412
421
  return true;
413
422
  }
423
+ const profileError = await taskProfileError({
424
+ profile: body.profile,
425
+ model: body.model,
426
+ modelTier: body.modelTier,
427
+ agentId: body.targetAgentId,
428
+ });
429
+ if (profileError) {
430
+ jsonError(res, profileError, 400);
431
+ return true;
432
+ }
414
433
 
415
434
  try {
416
435
  const trustedUserId = await resolveHttpAuditUserId(req, myAgentId);
@@ -456,6 +475,7 @@ export async function handleSchedules(
456
475
  nextRunAt,
457
476
  timezone: body.timezone,
458
477
  ...splitLegacyModelAlias({ model: body.model, modelTier: body.modelTier }),
478
+ profile: body.profile?.trim() || undefined,
459
479
  scheduleType: body.scheduleType,
460
480
  targetType: body.targetType,
461
481
  workflowId: body.workflowId,
@@ -468,7 +488,12 @@ export async function handleSchedules(
468
488
  });
469
489
 
470
490
  createSchedule.respond(res, 201, schedule);
471
- } catch (_error) {
491
+ } catch (error) {
492
+ // The profile was deleted between taskProfileError and the insert.
493
+ if (modelProfileRefError(error) === "missing") {
494
+ jsonError(res, `Unknown model profile "${body.profile}".`, 400);
495
+ return true;
496
+ }
472
497
  jsonError(res, "Failed to create schedule", 500);
473
498
  }
474
499
  return true;
@@ -593,6 +618,11 @@ export async function handleSchedules(
593
618
  const agentChanged =
594
619
  parsed.body.targetAgentId !== undefined &&
595
620
  parsed.body.targetAgentId !== existing.targetAgentId;
621
+ const profileUpdate = await scheduleProfileUpdate(existing, parsed.body);
622
+ if (profileUpdate.error !== undefined) {
623
+ jsonError(res, profileUpdate.error, 400);
624
+ return true;
625
+ }
596
626
  if (parsed.body.model !== undefined || parsed.body.modelTier !== undefined) {
597
627
  const normalizedModel = splitLegacyModelAlias({
598
628
  model: parsed.body.model,
@@ -614,7 +644,7 @@ export async function handleSchedules(
614
644
  if (parsed.body.modelTier !== undefined || normalizedModel.modelTier) {
615
645
  body.modelTier = normalizedModel.modelTier ?? null;
616
646
  }
617
- } else if (agentChanged && existing.model) {
647
+ } else if (agentChanged && existing.model && !profileUpdate.fields.profile) {
618
648
  // Harness only: the stored id already passed the catalog check when it was written.
619
649
  const modelError = await explicitModelErrorForAgent({
620
650
  model: existing.model,
@@ -626,6 +656,7 @@ export async function handleSchedules(
626
656
  return true;
627
657
  }
628
658
  }
659
+ Object.assign(body, profileUpdate.fields);
629
660
 
630
661
  // Reject updates on completed one-time schedules
631
662
  if (existing.scheduleType === "one_time" && !existing.enabled && existing.lastRunAt) {
@@ -750,7 +781,15 @@ export async function handleSchedules(
750
781
 
751
782
  const updatedBy = await resolveHttpAuditUserId(req, myAgentId);
752
783
  if (updatedBy !== null) body.updatedBy = updatedBy;
753
- const schedule = await updateScheduledTask(parsed.params.id, body);
784
+ let schedule: Awaited<ReturnType<typeof updateScheduledTask>>;
785
+ try {
786
+ schedule = await updateScheduledTask(parsed.params.id, body);
787
+ } catch (error) {
788
+ // The profile was deleted between scheduleProfileUpdate and the write.
789
+ if (modelProfileRefError(error) !== "missing") throw error;
790
+ jsonError(res, `Unknown model profile "${body.profile}".`, 400);
791
+ return true;
792
+ }
754
793
  routeHandle.respond(res, 200, schedule);
755
794
  return true;
756
795
  }
package/src/http/tasks.ts CHANGED
@@ -39,7 +39,12 @@ import {
39
39
  updateTaskTitle,
40
40
  updateTaskVcs,
41
41
  } from "../be/db";
42
- import { modelProfileRefError, taskProfileError } from "../be/db/model-profiles";
42
+ import {
43
+ getModelProfileByName,
44
+ hasUnreadableCredentialAllowlist,
45
+ modelProfileRefError,
46
+ taskProfileError,
47
+ } from "../be/db/model-profiles";
43
48
  import { explicitModelErrorForAgent } from "../be/model-validation";
44
49
  import { getUserGrant } from "../be/rbac-roles";
45
50
  import { hasSessionAccess, type SessionAccess } from "../be/session-shares";
@@ -69,6 +74,7 @@ import {
69
74
  AgentTaskStatusSchema,
70
75
  AssetKeySchema,
71
76
  isTerminalTaskStatus,
77
+ ModelProfileCredentialsSchema,
72
78
  ModelTierSchema,
73
79
  OnUnsupportedSchema,
74
80
  ProviderNameSchema,
@@ -140,6 +146,8 @@ const AgentTaskSummarySchema = AgentTaskSchema.pick({
140
146
  modelAlias: true,
141
147
  effort: true,
142
148
  resolvedEffort: true,
149
+ profile: true,
150
+ resolvedProfile: true,
143
151
  provider: true,
144
152
  requestedByUserId: true,
145
153
  progress: true,
@@ -706,6 +714,9 @@ const listPausedTasks = route({
706
714
  // Same requester projection a fresh task_assigned trigger carries,
707
715
  // so a resumed session gets the same requester-profile prompt.
708
716
  requestedBy: TaskRequestedBySchema.optional(),
717
+ // The claimed profile's pooled-key allowlist, read again from the
718
+ // profile, so the recovery spawn picks keys as the claim did.
719
+ credentialAllowlist: ModelProfileCredentialsSchema.optional(),
709
720
  }),
710
721
  ),
711
722
  }),
@@ -1083,16 +1094,6 @@ export async function handleTasks(
1083
1094
  jsonError(res, modelError, 400);
1084
1095
  return true;
1085
1096
  }
1086
- const profileError = await taskProfileError({
1087
- profile: parsed.body.profile,
1088
- ...splitLegacyModelAlias({ model: parsed.body.model, modelTier: parsed.body.modelTier }),
1089
- agentId: defaultAgentId,
1090
- });
1091
- if (profileError) {
1092
- jsonError(res, profileError, 400);
1093
- return true;
1094
- }
1095
-
1096
1097
  const parentTask = parsed.body.parentTaskId
1097
1098
  ? await getTaskById(parsed.body.parentTaskId)
1098
1099
  : null;
@@ -1127,6 +1128,18 @@ export async function handleTasks(
1127
1128
  jsonError(res, "You don't have access to the tasks in this context.", 403);
1128
1129
  return true;
1129
1130
  }
1131
+ // The child inherits the parent's repo in createTaskExtended, and the worker
1132
+ // loads that repo's config, so the profile check judges the same pool.
1133
+ const profileError = await taskProfileError({
1134
+ profile: parsed.body.profile,
1135
+ ...splitLegacyModelAlias({ model: parsed.body.model, modelTier: parsed.body.modelTier }),
1136
+ agentId: defaultAgentId,
1137
+ vcsRepo: parentTask?.vcsRepo,
1138
+ });
1139
+ if (profileError) {
1140
+ jsonError(res, profileError, 400);
1141
+ return true;
1142
+ }
1130
1143
  let assetKey: string | undefined;
1131
1144
  try {
1132
1145
  const inheritedKey = parentTask?.key;
@@ -1930,14 +1943,26 @@ export async function handleTasks(
1930
1943
  const tasks = await Promise.all(
1931
1944
  pausedTasks.map(async (task) => {
1932
1945
  const requestedBy = await buildTaskRequestedBy(task);
1946
+ const profile = task.resolvedProfile
1947
+ ? await getModelProfileByName(task.resolvedProfile)
1948
+ : null;
1949
+ // Without an allowlist the recovery spawn picks from the whole pool, so
1950
+ // the task stays paused until the profile's credentials are set again.
1951
+ if (profile && hasUnreadableCredentialAllowlist(profile)) {
1952
+ console.warn(
1953
+ `[paused-tasks] holding task ${task.id}: profile "${profile.name}" has an unreadable credential allowlist`,
1954
+ );
1955
+ return null;
1956
+ }
1933
1957
  return {
1934
1958
  ...task,
1935
1959
  attachments: await getTaskAttachments(task.id),
1936
1960
  ...(requestedBy && { requestedBy }),
1961
+ ...(profile?.credentials && { credentialAllowlist: profile.credentials }),
1937
1962
  };
1938
1963
  }),
1939
1964
  );
1940
- listPausedTasks.respond(res, 200, { tasks });
1965
+ listPausedTasks.respond(res, 200, { tasks: tasks.filter((task) => task !== null) });
1941
1966
  return true;
1942
1967
  }
1943
1968
 
@@ -425,6 +425,8 @@ const retryWorkflowRunRoute = route({
425
425
  path: "/api/workflow-runs/{id}/retry",
426
426
  pattern: ["api", "workflow-runs", null, "retry"],
427
427
  summary: "Retry a failed workflow run",
428
+ description:
429
+ "Retries on the definition the run started with; to use an edited workflow, trigger a new run.",
428
430
  tags: ["Workflows"],
429
431
  params: z.object({ id: z.string() }),
430
432
  responses: {
@@ -675,7 +677,9 @@ export async function handleWorkflows(
675
677
  jsonError(res, `Invalid definition: ${validation.errors.join("; ")}`, 400);
676
678
  return true;
677
679
  }
678
- const modelErrors = await workflowModelErrors(parsed.body.definition);
680
+ const modelErrors = await workflowModelErrors(parsed.body.definition, {
681
+ vcsRepo: parsed.body.vcsRepo,
682
+ });
679
683
  if (modelErrors.length > 0) {
680
684
  jsonError(res, `Invalid definition: ${modelErrors.join("; ")}`, 400);
681
685
  return true;
@@ -881,7 +885,16 @@ export async function handleWorkflows(
881
885
  jsonError(res, `Invalid definition: ${validation.errors.join("; ")}`, 400);
882
886
  return true;
883
887
  }
884
- const modelErrors = await workflowModelErrors(body.definition);
888
+ }
889
+ // A stored definition moving to another repo is judged again: its static
890
+ // profiles now check against that repo's credential pool.
891
+ const repoChanged =
892
+ body.vcsRepo !== undefined && (body.vcsRepo ?? null) !== (existing.vcsRepo ?? null);
893
+ const judged = body.definition ?? (repoChanged ? existing.definition : undefined);
894
+ if (judged) {
895
+ const modelErrors = await workflowModelErrors(judged, {
896
+ vcsRepo: body.vcsRepo === undefined ? existing.vcsRepo : body.vcsRepo,
897
+ });
885
898
  if (modelErrors.length > 0) {
886
899
  jsonError(res, `Invalid definition: ${modelErrors.join("; ")}`, 400);
887
900
  return true;
@@ -182,7 +182,7 @@ registerTemplate({
182
182
  ## Memory
183
183
 
184
184
  Memories from past sessions are in your task message. Read them before you start. For a wider search, run the \`task-context-gathering\` script with the task ID and two to four queries.
185
- When you learn something that would change how the next agent works (a fix, a pattern, a gotcha), pass it as \`learning\` on a \`store-progress\` call before the task ends. Completed task outputs are stored for you.
185
+ Pass a fix, pattern or gotcha the next agent needs as \`learning\` on a \`store-progress\` call before the task ends: line 1 a title, line 2 the rule ("When X, do Y"), never a status line. Completed task outputs are stored for you.
186
186
  You MUST use the \`memory\` skill before you store, edit, or delete a memory.
187
187
  `,
188
188
  variables: [],
@@ -161,14 +161,18 @@ function copyEnvKeys(
161
161
 
162
162
  function parseStringArray(value: string | undefined): string[] {
163
163
  if (!value?.trim()) return [];
164
+ let parsed: unknown;
164
165
  try {
165
- const parsed = JSON.parse(value);
166
- if (Array.isArray(parsed) && parsed.every((entry) => typeof entry === "string")) {
167
- return parsed;
168
- }
166
+ parsed = JSON.parse(value);
169
167
  } catch {
170
168
  // Accept comma-separated values for hand-authored environment config.
171
169
  }
170
+ if (Array.isArray(parsed)) {
171
+ if (!parsed.every((entry) => typeof entry === "string")) {
172
+ throw new AcpTargetResolutionError("ACP_TARGET_ENV_KEYS must be a JSON array of strings.");
173
+ }
174
+ return parsed;
175
+ }
172
176
  return value
173
177
  .split(",")
174
178
  .map((entry) => entry.trim())
@@ -423,7 +427,7 @@ const copilotTargetProfile: AcpTargetProfile = {
423
427
  },
424
428
  };
425
429
 
426
- /** Qwen Code's `--auth-type` choices (0.26.6). `qwen-oauth` needs a browser, so it is left out. */
430
+ /** Qwen Code's `--auth-type` choices (0.26.7). `qwen-oauth` needs a browser, so it is left out. */
427
431
  const QWEN_AUTH_TYPES = ["openai", "openai-responses", "anthropic", "gemini", "vertex-ai"] as const;
428
432
 
429
433
  // Qwen Code is a Gemini CLI fork: QWEN_SYSTEM_MD replaces its built-in prompt
@@ -475,7 +479,8 @@ const qwenTargetProfile: AcpTargetProfile = {
475
479
  /**
476
480
  * Kiro CLI reads its prompt from a Kiro agent config, not from a flag or an
477
481
  * env var, so the swarm system prompt is not injected (as with OpenCode).
478
- * Kiro 2.29.1 advertises no ACP config options, so the model rides on argv.
482
+ * Kiro advertises no ACP config options (checked on 2.29.1), so the model
483
+ * rides on argv as `--model`, which `kiro-cli acp` still accepts in 3.0.0.
479
484
  */
480
485
  const kiroTargetProfile: AcpTargetProfile = {
481
486
  target: "kiro",
@@ -45,7 +45,7 @@ import type {
45
45
  * default; the image installs exactly this version and the per-task settings
46
46
  * set `amp.updates.mode: "disabled"`. Bump it deliberately, with a live run.
47
47
  */
48
- export const AMP_PACKAGE = "@ampcode/cli@0.0.1793707234-gc72860";
48
+ export const AMP_PACKAGE = "@ampcode/cli@0.0.1793851242-g61361b";
49
49
 
50
50
  /** MCP server name. Amp exposes its tools as `agent_swarm` / `store_progress` (dashes become underscores). */
51
51
  const AMP_MCP_SERVER_NAME = "agent-swarm";
@@ -101,12 +101,13 @@ export class ClaudeInputQueue implements AsyncIterable<SDKUserMessage> {
101
101
  return this.entries.length + this.inFlight;
102
102
  }
103
103
 
104
- enqueue(text: string): Promise<void> {
104
+ enqueue(text: string, uuid = crypto.randomUUID()): Promise<void> {
105
105
  if (this.closed) return Promise.reject(new Error("Claude SDK input is closed"));
106
106
  return new Promise((accepted, rejected) => {
107
107
  this.entries.push({
108
108
  message: {
109
109
  type: "user",
110
+ uuid,
110
111
  message: { role: "user", content: text },
111
112
  parent_tool_use_id: null,
112
113
  },
@@ -323,6 +324,13 @@ class ClaudeSdkSession implements ProviderSession {
323
324
  private aborted = false;
324
325
  private abortReason = "cancelled";
325
326
  private acceptingInput = true;
327
+ private deliveryTail: Promise<unknown> = Promise.resolve();
328
+ private pendingDeliveries = 0;
329
+ private turnActive = true;
330
+ private resultWaiters = new Set<() => void>();
331
+ private completionCandidate = false;
332
+ private unansweredInputs = new Set<string>();
333
+ private inputResultIdsSupported = false;
326
334
  private errorTracker = new SessionErrorTracker();
327
335
  private shutdownPromise: Promise<void> | undefined;
328
336
  /** Keeps the session heartbeat fresh while Claude idles on background tasks. */
@@ -334,7 +342,7 @@ class ClaudeSdkSession implements ProviderSession {
334
342
  this.contextWindowSize = getContextWindowSize(options.model);
335
343
  this.transcript = [`User: ${scrubSecrets(options.config.prompt)}`];
336
344
  if (options.queueSteeringSupported) {
337
- this.deliverSteering = (delivery) => this.deliverQueuedSteering(delivery);
345
+ this.deliverSteering = (delivery) => this.deliverLiveSteering(delivery);
338
346
  }
339
347
  this.completionPromise = this.run();
340
348
  }
@@ -360,6 +368,9 @@ class ClaudeSdkSession implements ProviderSession {
360
368
  this.aborted = true;
361
369
  this.acceptingInput = false;
362
370
  this.abortReason = scrubSecrets(reason ?? "cancelled");
371
+ this.input.close(this.abortReason);
372
+ for (const resolve of this.resultWaiters) resolve();
373
+ this.resultWaiters.clear();
363
374
  const interrupt = this.query?.interrupt();
364
375
  if (interrupt) {
365
376
  await Promise.race([interrupt.catch(() => undefined), Bun.sleep(SDK_INTERRUPT_TIMEOUT_MS)]);
@@ -369,22 +380,80 @@ class ClaudeSdkSession implements ProviderSession {
369
380
  await this.shutdownAfterSdkGrace();
370
381
  }
371
382
 
372
- private async deliverQueuedSteering({ mode, text }: SteerDelivery): Promise<SteerDeliveryResult> {
383
+ private deliverLiveSteering(delivery: SteerDelivery): Promise<SteerDeliveryResult> {
384
+ // Reserve before yielding: a result can arrive while an interrupt or an
385
+ // earlier delivery is awaiting its control response.
373
386
  if (!this.acceptingInput || this.aborted) {
374
- return { delivered: false, reason: "Claude SDK session has completed" };
387
+ return Promise.resolve({ delivered: false, reason: "Claude SDK session has completed" });
375
388
  }
376
- if (mode === "steer") {
377
- return {
378
- delivered: false,
379
- reason: "Claude SDK transport currently supports queued input only",
380
- };
389
+ this.pendingDeliveries++;
390
+ const operation = this.deliveryTail.then(async (): Promise<SteerDeliveryResult> => {
391
+ try {
392
+ if (!this.acceptingInput || this.aborted) {
393
+ throw new Error("Claude SDK session has completed");
394
+ }
395
+ if (delivery.mode === "steer" && this.turnActive && this.query) {
396
+ // The control receipt precedes the interrupted result. Wait for both
397
+ // before writing the redirect, so that result cannot close its input.
398
+ // interrupt() preserves messages already queued inside Claude.
399
+ let release!: () => void;
400
+ const result = new Promise<void>((resolve) => {
401
+ release = resolve;
402
+ this.resultWaiters.add(resolve);
403
+ });
404
+ let timer: ReturnType<typeof setTimeout> | undefined;
405
+ try {
406
+ await Promise.race([
407
+ Promise.all([this.query.interrupt(), result]),
408
+ new Promise<never>((_, reject) => {
409
+ timer = setTimeout(
410
+ () => reject(new Error("Claude SDK redirect timed out")),
411
+ 10_000,
412
+ );
413
+ }),
414
+ ]);
415
+ } finally {
416
+ clearTimeout(timer);
417
+ this.resultWaiters.delete(release);
418
+ }
419
+ }
420
+ if (!this.acceptingInput || this.aborted) {
421
+ throw new Error("Claude SDK session has completed");
422
+ }
423
+ this.completionCandidate = false;
424
+ this.turnActive = true;
425
+ const uuid = crypto.randomUUID();
426
+ this.unansweredInputs.add(uuid);
427
+ try {
428
+ await this.input.enqueue(delivery.text, uuid);
429
+ } catch (error) {
430
+ this.unansweredInputs.delete(uuid);
431
+ throw error;
432
+ }
433
+ this.transcript.push(`User: ${scrubSecrets(delivery.text)}`);
434
+ return { delivered: true, mode: delivery.mode };
435
+ } catch (error) {
436
+ return { delivered: false, reason: scrubSecrets(String(error)) };
437
+ } finally {
438
+ this.pendingDeliveries--;
439
+ this.maybeCloseInput();
440
+ }
441
+ });
442
+ this.deliveryTail = operation;
443
+ return operation;
444
+ }
445
+
446
+ private maybeCloseInput(): void {
447
+ if (
448
+ !this.completionCandidate ||
449
+ this.pendingDeliveries > 0 ||
450
+ this.input.pendingCount > 0 ||
451
+ this.unansweredInputs.size > 0
452
+ ) {
453
+ return;
381
454
  }
382
- try {
383
- this.transcript.push(`User: ${scrubSecrets(text)}`);
384
- await this.input.enqueue(text);
385
- return { delivered: true, mode: "queue" };
386
- } catch (error) {
387
- return { delivered: false, reason: scrubSecrets(String(error)) };
455
+ if (!this.backgroundKeepalive.holdInputForBackgroundWork(() => this.closeInput())) {
456
+ this.closeInput();
388
457
  }
389
458
  }
390
459
 
@@ -420,8 +489,49 @@ class ClaudeSdkSession implements ProviderSession {
420
489
  return this.shutdownPromise;
421
490
  }
422
491
 
492
+ /**
493
+ * A singular `user_message_uuid` names the last message merged into the turn.
494
+ * Every unanswered input enqueued at or before it was coalesced into that
495
+ * turn and is not echoed on its own. Inputs enqueued after it stay open.
496
+ */
497
+ private answerCoalescedThrough(lastUuid: string): void {
498
+ if (!this.unansweredInputs.has(lastUuid)) return;
499
+ for (const uuid of [...this.unansweredInputs]) {
500
+ this.unansweredInputs.delete(uuid);
501
+ if (uuid === lastUuid) return;
502
+ }
503
+ }
504
+
505
+ private noteAnsweredInputs(result: SDKResultMessage): void {
506
+ const listed = result.user_message_uuids;
507
+ if (listed && listed.length > 0) {
508
+ this.inputResultIdsSupported = true;
509
+ for (const uuid of listed) this.unansweredInputs.delete(uuid);
510
+ return;
511
+ }
512
+ if (result.user_message_uuid) {
513
+ this.inputResultIdsSupported = true;
514
+ this.answerCoalescedThrough(result.user_message_uuid);
515
+ return;
516
+ }
517
+ if (!this.inputResultIdsSupported) {
518
+ // Older executables do not echo input UUIDs. Preserve their existing
519
+ // queued_turn_count completion contract.
520
+ this.unansweredInputs.clear();
521
+ }
522
+ }
523
+
423
524
  private handleMessage(message: SDKMessage): boolean {
424
525
  const json = message as ClaudeProtocolMessage;
526
+ if (json.type === "result") {
527
+ const result = message as SDKResultMessage;
528
+ this.noteAnsweredInputs(result);
529
+ this.turnActive = (result.queued_turn_count ?? 0) > 0 || this.unansweredInputs.size > 0;
530
+ for (const resolve of this.resultWaiters) resolve();
531
+ this.resultWaiters.clear();
532
+ } else if (json.type === "assistant" && !json.parent_tool_use_id) {
533
+ this.turnActive = true;
534
+ }
425
535
  this.backgroundKeepalive.observe(json);
426
536
  const normalized = normalizeClaudeMessage(json, {
427
537
  taskId: this.options.config.taskId,
@@ -462,7 +572,9 @@ class ClaudeSdkSession implements ProviderSession {
462
572
  let terminalError: unknown;
463
573
  let stderrOutput = "";
464
574
 
465
- void this.input.enqueue(config.prompt).catch(() => {});
575
+ const initialUuid = crypto.randomUUID();
576
+ this.unansweredInputs.add(initialUuid);
577
+ void this.input.enqueue(config.prompt, initialUuid).catch(() => {});
466
578
  try {
467
579
  const executable = resolveClaudeSdkExecutable(
468
580
  this.options.claudeBinaryArgv[0] ?? "claude",
@@ -529,13 +641,8 @@ class ClaudeSdkSession implements ProviderSession {
529
641
  const isResult = this.handleMessage(message);
530
642
  if (!isResult) continue;
531
643
  terminalResult = message as SDKResultMessage;
532
- if ((terminalResult.queued_turn_count ?? 0) === 0 && this.input.pendingCount === 0) {
533
- // Live background work gets its notification turn; the result after
534
- // it settles closes input.
535
- if (!this.backgroundKeepalive.holdInputForBackgroundWork(() => this.closeInput())) {
536
- this.closeInput();
537
- }
538
- }
644
+ this.completionCandidate = (terminalResult.queued_turn_count ?? 0) === 0;
645
+ this.maybeCloseInput();
539
646
  }
540
647
  } catch (error) {
541
648
  terminalError = error;
@@ -544,6 +651,8 @@ class ClaudeSdkSession implements ProviderSession {
544
651
  this.emit({ type: "error", message, category: "sdk_transport" });
545
652
  }
546
653
  } finally {
654
+ for (const resolve of this.resultWaiters) resolve();
655
+ this.resultWaiters.clear();
547
656
  this.backgroundKeepalive.stop();
548
657
  this.acceptingInput = false;
549
658
  this.input.close();
@@ -30,7 +30,12 @@ import type { ProviderEvent } from "./types";
30
30
  */
31
31
  const SLASH_COMMAND_REGEX = /^\/([a-z0-9:_-]+)(?:\s+(.*))?$/;
32
32
 
33
- const MAX_SKILL_CHARS = Number(process.env.MAX_SKILL_CHARS) || 100_000;
33
+ const DEFAULT_MAX_SKILL_CHARS = 100_000;
34
+
35
+ export function getMaxSkillChars(): number {
36
+ const parsed = Number(process.env.MAX_SKILL_CHARS);
37
+ return Number.isInteger(parsed) && parsed > 0 ? parsed : DEFAULT_MAX_SKILL_CHARS;
38
+ }
34
39
 
35
40
  /**
36
41
  * Resolve the default skills directory for Codex.
@@ -128,12 +133,13 @@ export async function resolveSlashSkillPrompt(
128
133
  return prompt;
129
134
  }
130
135
 
131
- if (skillContent.length > MAX_SKILL_CHARS) {
136
+ const maxSkillChars = getMaxSkillChars();
137
+ if (skillContent.length > maxSkillChars) {
132
138
  opts.emit?.({
133
139
  type: "raw_stderr",
134
- content: `[${opts.providerLabel}] skill resolver: SKILL.md for /${commandName} exceeds ${MAX_SKILL_CHARS} chars (${skillContent.length}), truncating\n`,
140
+ content: `[${opts.providerLabel}] skill resolver: SKILL.md for /${commandName} exceeds ${maxSkillChars} chars (${skillContent.length}), truncating\n`,
135
141
  });
136
- skillContent = skillContent.slice(0, MAX_SKILL_CHARS);
142
+ skillContent = skillContent.slice(0, maxSkillChars);
137
143
  }
138
144
 
139
145
  if (opts.stripFrontmatter) {
@@ -35,7 +35,7 @@ import type {
35
35
  } from "./types";
36
36
 
37
37
  /** Pinned in package.json and Dockerfile.worker; bump all three together. */
38
- export const CURSOR_SDK_VERSION = "1.3.0";
38
+ export const CURSOR_SDK_VERSION = "1.3.1";
39
39
 
40
40
  /** MCP server name; Cursor reports its tools as `mcp` calls with this `providerIdentifier`. */
41
41
  const CURSOR_MCP_SERVER_NAME = "agent-swarm";
@@ -13,6 +13,7 @@
13
13
  */
14
14
 
15
15
  import { join } from "node:path";
16
+ import { getMaxSkillChars } from "./codex-skill-resolver";
16
17
  import type { ProviderEvent } from "./types";
17
18
 
18
19
  /**
@@ -24,8 +25,6 @@ import type { ProviderEvent } from "./types";
24
25
  */
25
26
  const SKILL_COMMAND_REGEX = /^@skills:([a-z0-9:_-]+)(?:\s+(.*))?$/;
26
27
 
27
- const MAX_SKILL_CHARS = Number(process.env.MAX_SKILL_CHARS) || 100_000;
28
-
29
28
  /**
30
29
  * Default skills directory — `plugin/pi-skills/` relative to the project root.
31
30
  *
@@ -97,12 +96,13 @@ export async function resolveDevinPrompt(
97
96
  return prompt;
98
97
  }
99
98
 
100
- if (skillContent.length > MAX_SKILL_CHARS) {
99
+ const maxSkillChars = getMaxSkillChars();
100
+ if (skillContent.length > maxSkillChars) {
101
101
  emit?.({
102
102
  type: "raw_stderr",
103
- content: `[devin] skill resolver: SKILL.md for @skills:${commandName} exceeds ${MAX_SKILL_CHARS} chars (${skillContent.length}), truncating\n`,
103
+ content: `[devin] skill resolver: SKILL.md for @skills:${commandName} exceeds ${maxSkillChars} chars (${skillContent.length}), truncating\n`,
104
104
  });
105
- skillContent = skillContent.slice(0, MAX_SKILL_CHARS);
105
+ skillContent = skillContent.slice(0, maxSkillChars);
106
106
  }
107
107
 
108
108
  // Assemble the user-request body: trailing args from the @skills: line (if any),
@@ -37,7 +37,7 @@ import type {
37
37
  } from "./types";
38
38
 
39
39
  // npm's `latest` is older and lacks the JSON/stdin contract used here.
40
- export const DSH_PACKAGE = "@deepseek-ai/dsh@0.2.2-alpha.3";
40
+ export const DSH_PACKAGE = "@deepseek-ai/dsh@0.2.2-rc.1";
41
41
 
42
42
  export function checkDshCredentials(env: Record<string, string | undefined>): CredStatus {
43
43
  return env.DEEPSEEK_API_KEY?.trim() || env.OPENROUTER_API_KEY?.trim()
@@ -73,6 +73,7 @@ export async function prepareStandaloneScheduleTask(
73
73
  routingSource: schedule.targetAgentId ? "engine_default" : undefined,
74
74
  model: schedule.model,
75
75
  modelTier: schedule.modelTier,
76
+ profile: schedule.profile,
76
77
  scheduleId: schedule.id,
77
78
  source: "schedule",
78
79
  requestedByUserId: schedule.createdBy,
@@ -1,6 +1,6 @@
1
1
  import { buildCtx } from "./ctx";
2
2
  import { patchFetchWithEgressSubstitution } from "./egress-secrets";
3
- import type { SwarmConfigPayload } from "./executors/types";
3
+ import { type SwarmConfigPayload, UNAWAITED_WORK_DRAIN_MS } from "./executors/types";
4
4
  import { isHostValidationEquivalent } from "./host-validated-args";
5
5
  import { ctxSignatureHintFor } from "./script-error-hints";
6
6
  import { SwarmConfig } from "./swarm-config";
@@ -167,6 +167,19 @@ try {
167
167
 
168
168
  const result = await mod.default(validatedArgs, ctx);
169
169
  await Bun.write(requiredEnv("SWARM_SCRIPT_RESULT_FILE"), JSON.stringify(result ?? null));
170
+ // The run settles once the entry function resolves. Bun would otherwise keep
171
+ // the process alive while any call the script did not await is pending (a
172
+ // nested script_run that lost a Promise.race, a fire-and-forget kv_set), so
173
+ // the executor kept waiting until that call settled or the wall-clock
174
+ // watchdog killed the run and discarded the result. The timer is unref'd:
175
+ // with nothing pending the process exits at once, as before. Un-awaited work
176
+ // gets this window to finish; whatever is still pending then is stopped.
177
+ setTimeout(() => {
178
+ console.error(
179
+ `[swarm-script] the script returned, but un-awaited calls were still pending ${UNAWAITED_WORK_DRAIN_MS} ms later; they were stopped. Await every call whose effect must land.`,
180
+ );
181
+ process.exit(0);
182
+ }, UNAWAITED_WORK_DRAIN_MS).unref();
170
183
  } catch (error) {
171
184
  await emitError(error);
172
185
  process.exit(1);