@desplega.ai/agent-swarm 2.9.1 → 2.10.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 (315) hide show
  1. package/dist/acp-adapter-bht22g3k.js +16 -0
  2. package/dist/{acp-targets-ny75x1qy.js → acp-targets-arrwv4f0.js} +6 -6
  3. package/dist/{actions-b9qgrmeq.js → actions-y0d2n1c2.js} +49 -28
  4. package/dist/{agent-fs-provision-b5dhdsbd.js → agent-fs-provision-tpj7sktd.js} +4 -4
  5. package/dist/{amp-adapter-vtax2c9s.js → amp-adapter-vmmnmw8d.js} +1 -1
  6. package/dist/{anthropic-messages-r5xf5hqw.js → anthropic-messages-zdca3gv1.js} +13 -13
  7. package/dist/{app-g2z15hax.js → app-wb7w45dq.js} +3 -3
  8. package/dist/{approval-notifications-yt13wp8r.js → approval-notifications-7mqr6vbd.js} +5 -5
  9. package/dist/{assistant-2cgfxsgk.js → assistant-gf60454p.js} +19 -19
  10. package/dist/{boot-args-schema-3gwy0f60.js → boot-args-schema-qxmd59sr.js} +1 -1
  11. package/dist/{boot-reembed-mywmyp4s.js → boot-reembed-5tmeskj2.js} +1 -1
  12. package/dist/{boot-reembed-92g7s5zp.js → boot-reembed-wb44vc3s.js} +1 -1
  13. package/dist/boot-scrub-sweep-25bxhnw4.js +9 -0
  14. package/dist/{boot-seeds-ce7rvgq1.js → boot-seeds-nj9za0vk.js} +4 -4
  15. package/dist/{claude-adapter-3m4q7735.js → claude-adapter-d3krpdyb.js} +5 -5
  16. package/dist/{claude-managed-setup-c217draw.js → claude-managed-setup-7y4pwd81.js} +1 -1
  17. package/dist/{claude-sdk-session-7fbqm51z.js → claude-sdk-session-d138zy0e.js} +5 -5
  18. package/dist/{cli-tvc4jag9.js → cli-01k6wpr9.js} +3 -3
  19. package/dist/{cli-2xs8tsf7.js → cli-124ntmf0.js} +42 -36
  20. package/dist/{cli-jm0hvmz2.js → cli-2rnd5j3t.js} +1 -1
  21. package/dist/{cli-32djehja.js → cli-2spnz7ye.js} +8 -8
  22. package/dist/{cli-2dq9yv8p.js → cli-2v2zdm0a.js} +1 -1
  23. package/dist/{cli-fkef327x.js → cli-3caf7pmg.js} +2 -2
  24. package/dist/{cli-mw620q3n.js → cli-3et6fmfe.js} +1 -1
  25. package/dist/{cli-h9yqfzx9.js → cli-3f8zbtqa.js} +3 -3
  26. package/dist/{cli-mhapr559.js → cli-43evxwj4.js} +1 -1
  27. package/dist/{cli-pyjn0qhk.js → cli-539h29es.js} +138 -21
  28. package/dist/{cli-bnqncekd.js → cli-5qhfv9rw.js} +2 -2
  29. package/dist/{cli-p4kckx1z.js → cli-6037prsx.js} +6 -6
  30. package/dist/{cli-zr6qy15y.js → cli-6cwr32fe.js} +17 -17
  31. package/dist/{cli-1jykg0py.js → cli-7r162fxe.js} +22 -15
  32. package/dist/{cli-sn650d7x.js → cli-8st34zhr.js} +20 -10
  33. package/dist/{cli-rq5rpv6k.js → cli-91pkxres.js} +1 -1
  34. package/dist/{cli-m7zvgt57.js → cli-9fjr27ez.js} +10 -10
  35. package/dist/{cli-f8x9drqr.js → cli-aw83sr40.js} +19 -5
  36. package/dist/{cli-jkw6ptfw.js → cli-cc93xzes.js} +5 -5
  37. package/dist/{cli-gfy38pvt.js → cli-fcfbct2j.js} +5 -5
  38. package/dist/{cli-nafvvsp8.js → cli-fq2rr3jb.js} +5 -5
  39. package/dist/{boot-scrub-sweep-7dkdzqxx.js → cli-had1p04a.js} +8 -9
  40. package/dist/{cli-bg63qmsx.js → cli-j6te8keb.js} +4 -4
  41. package/dist/{cli-br0924pw.js → cli-jrbq4djp.js} +1 -1
  42. package/dist/{cli-kxx4k2jw.js → cli-k3q2va86.js} +2 -2
  43. package/dist/{cli-jaw5v1sy.js → cli-k5yewqgd.js} +3 -3
  44. package/dist/cli-kbtzfrxj.js +404 -0
  45. package/dist/{cli-td9tb872.js → cli-m9cvf7vs.js} +7 -7
  46. package/dist/{cli-f3jyzq4g.js → cli-md50mj0r.js} +2 -2
  47. package/dist/{cli-xag7btpe.js → cli-mk7c5ac4.js} +1 -1
  48. package/dist/cli-mys27d03.js +321 -0
  49. package/dist/{cli-nbt14he0.js → cli-nstkanmx.js} +5 -5
  50. package/dist/{cli-wn13hhdt.js → cli-nv4xsvmk.js} +4 -4
  51. package/dist/{cli-vyff45ve.js → cli-p0c3vtch.js} +2 -2
  52. package/dist/{cli-2czxfnvj.js → cli-p0n7b5rz.js} +662 -93
  53. package/dist/{cli-j7svy295.js → cli-q5srsxq2.js} +12 -12
  54. package/dist/{cli-vt89089n.js → cli-qrta34nb.js} +4 -4
  55. package/dist/{cli-ysvspf5e.js → cli-qx4f057j.js} +2 -2
  56. package/dist/{cli-zh0e5x7p.js → cli-s1khw52h.js} +11 -11
  57. package/dist/{cli-mkwkwq81.js → cli-s1zqk1aj.js} +18 -11
  58. package/dist/{cli-f9gz2vyj.js → cli-sb4426be.js} +7 -7
  59. package/dist/{cli-dgs10ttj.js → cli-th1dkc2v.js} +1 -1
  60. package/dist/{cli-3j873zxq.js → cli-tr27kwyg.js} +2 -2
  61. package/dist/{cli-6945ywhr.js → cli-tvgqesec.js} +6 -4
  62. package/dist/{cli-fjggej24.js → cli-v46zsvqk.js} +1 -1
  63. package/dist/{cli-67mwzr35.js → cli-v8z0yga9.js} +4 -4
  64. package/dist/{cli-pb2ay3sh.js → cli-vfqvrd82.js} +5 -5
  65. package/dist/{cli-fh97xn30.js → cli-vq2eg24x.js} +2 -2
  66. package/dist/{cli-v57d7fmm.js → cli-vsw91x06.js} +23 -22
  67. package/dist/{cli-2yjj3e31.js → cli-w1q68d8x.js} +9 -7
  68. package/dist/{cli-y2ewxhth.js → cli-wafmk3fn.js} +10 -10
  69. package/dist/{cli-ctx0b85j.js → cli-wwp1bd3n.js} +257 -101
  70. package/dist/{cli-bkjdknnp.js → cli-y4ccxtz5.js} +37 -5
  71. package/dist/{cli-w4n323t3.js → cli-y8p78ekx.js} +7 -7
  72. package/dist/{cli-8zh9nrew.js → cli-z0m452jr.js} +1 -1
  73. package/dist/{cli-mjw0yf82.js → cli-zeh2mhkg.js} +1 -1
  74. package/dist/{cli-jwampxxq.js → cli-zk7v5s89.js} +2 -2
  75. package/dist/cli.js +16 -16
  76. package/dist/{cloudflare-workers-ai-system-one-9y1zx3pt.js → cloudflare-workers-ai-system-one-4aysy6rh.js} +2 -2
  77. package/dist/{codex-adapter-n656pvb8.js → codex-adapter-exfdbj73.js} +4 -4
  78. package/dist/{codex-session-runner-p0fbv5y9.js → codex-session-runner-xhznc4g3.js} +4 -4
  79. package/dist/{commands-gwea8z5p.js → commands-d8g349v4.js} +3 -3
  80. package/dist/{controller-t67c3grh.js → controller-mwgdmb8y.js} +3 -3
  81. package/dist/{controllers-connect-ks155r0h.js → controllers-connect-5v7qx04j.js} +19 -19
  82. package/dist/core-sxy4epp2.js +38 -0
  83. package/dist/{cursor-adapter-ygwrtmkv.js → cursor-adapter-p2q5h35d.js} +1 -1
  84. package/dist/{db-rb2xqdb1.js → db-qpganbeb.js} +3 -3
  85. package/dist/{db-kpmx06s9.js → db-wcw0b2j8.js} +2 -2
  86. package/dist/{dispatcher-31sm0ej2.js → dispatcher-8d8s49yz.js} +17 -17
  87. package/dist/{dsh-adapter-qyxh0w31.js → dsh-adapter-me0twn13.js} +1 -1
  88. package/dist/{easter-egg-3d-00wjscn6.js → easter-egg-3d-wv7w5ty6.js} +1 -1
  89. package/dist/{embedding-space-qhw4g68n.js → embedding-space-e48xchqa.js} +6 -6
  90. package/dist/{embeddings-zdv9ke6x.js → embeddings-tgq2afbq.js} +1 -1
  91. package/dist/{execute-zna8wwr7.js → execute-8rhwrk7f.js} +1 -1
  92. package/dist/{external-channel-1ac6t56s.js → external-channel-8bt3j2pm.js} +2 -2
  93. package/dist/{fx-adapter-sk7n0fzc.js → fx-adapter-adtdb3jb.js} +8 -8
  94. package/dist/{grok-adapter-sjbcm5ew.js → grok-adapter-accnn9km.js} +8 -8
  95. package/dist/handlers-1x77561e.js +35 -0
  96. package/dist/{heartbeat-2f6z4kdx.js → heartbeat-x0056ra5.js} +20 -20
  97. package/dist/{hook-w1skzaqc.js → hook-a7vmn2st.js} +4 -4
  98. package/dist/{hook-8y0gvtp1.js → hook-mrd2ayxv.js} +5 -5
  99. package/dist/{http-wghxvpef.js → http-ym9c5svp.js} +676 -273
  100. package/dist/{index-s71ez27v.js → index-01ns1pkw.js} +1 -1
  101. package/dist/index-48qzcqzj.js +35 -0
  102. package/dist/{index-9zkchs9t.js → index-ny60jcat.js} +186 -14
  103. package/dist/{index-rv89fvzf.js → index-p46tvwtx.js} +21 -21
  104. package/dist/index-rkvaambe.js +36 -0
  105. package/dist/{index-8zn8nxn5.js → index-x6azjwm8.js} +1 -1
  106. package/dist/{index-25pvya7q.js → index-xj1mq27m.js} +17 -17
  107. package/dist/k8s-m56sw868.js +217 -0
  108. package/dist/{keepalive-sh02349h.js → keepalive-7yxg8z4c.js} +3 -3
  109. package/dist/lead-enzn86bz.js +74 -0
  110. package/dist/{maintenance-yj0dcjja.js → maintenance-6tefxmk1.js} +1 -1
  111. package/dist/{oauth-refresh-sweep-d9xedk66.js → oauth-refresh-sweep-70cavc3a.js} +2 -2
  112. package/dist/{onboard-dpgjn03r.js → onboard-fja65z08.js} +5 -5
  113. package/dist/{openai-decisions-q3hh60wr.js → openai-decisions-ytp6w6xh.js} +1 -1
  114. package/dist/{opencode-adapter-2d31cpjc.js → opencode-adapter-hakkm7yh.js} +5 -5
  115. package/dist/{otel-impl-1skarpfq.js → otel-impl-7zhnt6gj.js} +1 -1
  116. package/dist/{pending-bfmxtx0g.js → pending-h01yzpx4.js} +18 -18
  117. package/dist/{pi-mono-adapter-gvppnasy.js → pi-mono-adapter-f52hz743.js} +6 -6
  118. package/dist/{pricing-refresh-c6b325mk.js → pricing-refresh-fzxvk2zf.js} +2 -2
  119. package/dist/{rbac-roles-h80qbdbs.js → rbac-roles-9v6vhgbs.js} +3 -3
  120. package/dist/{rbac-roles-zfcx68tx.js → rbac-roles-hfgh8sba.js} +2 -2
  121. package/dist/{render-v2-nx20t3rb.js → render-v2-1rgspxzf.js} +3 -3
  122. package/dist/{resume-5ep8agan.js → resume-tqy61x24.js} +7 -7
  123. package/dist/{runtime-r3pj4mce.js → runtime-exkxyx5f.js} +1 -1
  124. package/dist/{session-access-n7p3m15b.js → session-access-3act7vt4.js} +4 -4
  125. package/dist/{session-source-backfill-v8mt0zwn.js → session-source-backfill-82qe7fqq.js} +2 -2
  126. package/dist/{setup-z1psaqhe.js → setup-ry1vfdef.js} +1 -1
  127. package/dist/thread-buffer-3x93yexa.js +38 -0
  128. package/dist/{typesafe-system-one-f2en2knd.js → typesafe-system-one-vcfj2ak8.js} +2 -2
  129. package/dist/user-merge-jobs-bx6bf7db.js +22 -0
  130. package/dist/{virtual-modules-rrbjdpxn.js → virtual-modules-s0rjzcqq.js} +3 -3
  131. package/dist/{work-objects-4aghh73z.js → work-objects-z2e5tv03.js} +20 -20
  132. package/dist/{worker-follow-up-166zmex1.js → worker-follow-up-y3xeg89w.js} +17 -17
  133. package/dist/worker-zfcv2wbf.js +74 -0
  134. package/openapi.json +1630 -388
  135. package/package.json +3 -3
  136. package/src/be/boot-seeds.ts +7 -1
  137. package/src/be/db/model-groups.ts +238 -0
  138. package/src/be/db/model-profiles.ts +26 -8
  139. package/src/be/db/session-costs.ts +8 -2
  140. package/src/be/db/tasks/read.ts +3 -2
  141. package/src/be/db/tasks/write.ts +2 -1
  142. package/src/be/db/user-references.ts +75 -0
  143. package/src/be/db/users/references.ts +185 -0
  144. package/src/be/db-client.ts +70 -19
  145. package/src/be/db.ts +32 -57
  146. package/src/be/key-window-usage.ts +1 -0
  147. package/src/be/memory/demotion-evidence.ts +34 -0
  148. package/src/be/memory/reranker.ts +34 -12
  149. package/src/be/memory/review-recall-filter.ts +83 -0
  150. package/src/be/memory/search-candidates.ts +19 -6
  151. package/src/be/memory/types.ts +11 -0
  152. package/src/be/migrations/312_task_ui_action_runs_repeatable.sql +6 -0
  153. package/src/be/migrations/314_model_groups.sql +85 -0
  154. package/src/be/migrations/318_superseded_workflow_cut_backfill.sql +22 -0
  155. package/src/be/migrations/319_user_fk_indexes.sql +153 -0
  156. package/src/be/migrations/320_session_costs_kind.sql +4 -0
  157. package/src/be/migrations/321_user_merge_jobs.sql +52 -0
  158. package/src/be/pricing-normalize.ts +2 -0
  159. package/src/be/rbac-roles.ts +6 -4
  160. package/src/be/runtime-pools/db.ts +20 -5
  161. package/src/be/runtime-pools/supervisor.ts +15 -1
  162. package/src/be/scripts/db.ts +11 -0
  163. package/src/be/scripts/typecheck.ts +2 -0
  164. package/src/be/seed-model-groups.ts +86 -0
  165. package/src/be/seed-model-profiles.ts +20 -13
  166. package/src/be/seed-scripts/catalog/dreaming-gather.ts +165 -1
  167. package/src/be/swarm-config-guard.ts +34 -0
  168. package/src/be/task-ui-spec.ts +102 -1
  169. package/src/be/user-merge-jobs.ts +564 -0
  170. package/src/be/users.ts +41 -23
  171. package/src/commands/onboard/agent-fs-version.ts +1 -1
  172. package/src/commands/onboard/compose-generator.ts +1 -1
  173. package/src/commands/onboard/env-generator.ts +1 -1
  174. package/src/commands/provider-credentials.ts +1 -1
  175. package/src/extensions/contract-types.generated.ts +1 -1
  176. package/src/extensions/contract.ts +15 -0
  177. package/src/extensions/dispatcher.ts +14 -4
  178. package/src/github/handlers.ts +57 -0
  179. package/src/github/types.ts +4 -0
  180. package/src/http/all-routes.ts +2 -0
  181. package/src/http/approval-requests.ts +5 -1
  182. package/src/http/auth.ts +3 -1
  183. package/src/http/config.ts +34 -1
  184. package/src/http/index.ts +13 -0
  185. package/src/http/memory.ts +19 -6
  186. package/src/http/model-groups.ts +277 -0
  187. package/src/http/model-profiles.ts +30 -13
  188. package/src/http/tasks.ts +41 -6
  189. package/src/http/tool-hooks.ts +140 -0
  190. package/src/http/users.ts +142 -19
  191. package/src/http/workflows.ts +19 -1
  192. package/src/integrations/chat-sdk/inbound.ts +8 -2
  193. package/src/integrations/chat-sdk/limits.ts +8 -3
  194. package/src/providers/acp-targets.ts +2 -2
  195. package/src/providers/amp-adapter.ts +1 -1
  196. package/src/providers/pricing-sources.md +9 -0
  197. package/src/rbac/legacy-policy.ts +1 -0
  198. package/src/rbac/permissions.ts +5 -0
  199. package/src/runtime-providers/index.ts +7 -5
  200. package/src/runtime-providers/k8s.ts +250 -0
  201. package/src/scripts-runtime/types/stdlib.d.ts +2 -0
  202. package/src/scripts-runtime/types/swarm-extension.d.ts +16 -1
  203. package/src/scripts-runtime/types/swarm-sdk.d.ts +2 -0
  204. package/src/slack/actions.ts +33 -10
  205. package/src/slack/blocks.ts +23 -2
  206. package/src/slack/render-v2.ts +47 -0
  207. package/src/tests/acp-adapter.test.ts +26 -0
  208. package/src/tests/chat-sdk-relay.test.ts +21 -1
  209. package/src/tests/check-pr-body.test.ts +43 -0
  210. package/src/tests/credential-check.test.ts +14 -6
  211. package/src/tests/db-client.test.ts +146 -0
  212. package/src/tests/deploy-guard.test.ts +7 -7
  213. package/src/tests/deploy-select.test.ts +83 -0
  214. package/src/tests/dreaming-gather-corrections.test.ts +467 -0
  215. package/src/tests/event-loop-lag.test.ts +9 -7
  216. package/src/tests/fixtures/extensions/native-tool-recorder/hooks.ts +26 -0
  217. package/src/tests/fixtures/extensions/native-tool-recorder/manifest.json +10 -0
  218. package/src/tests/fixtures/onboard/content.compose.yml.txt +1 -1
  219. package/src/tests/fixtures/onboard/content.env.txt +1 -1
  220. package/src/tests/fixtures/onboard/dev.compose.yml.txt +1 -1
  221. package/src/tests/fixtures/onboard/dev.env.txt +1 -1
  222. package/src/tests/fixtures/onboard/full-all.compose.yml.txt +1 -1
  223. package/src/tests/fixtures/onboard/full-all.env.txt +1 -1
  224. package/src/tests/fixtures/onboard/full.compose.yml.txt +1 -1
  225. package/src/tests/fixtures/onboard/full.env.txt +1 -1
  226. package/src/tests/fixtures/onboard/research.compose.yml.txt +1 -1
  227. package/src/tests/fixtures/onboard/research.env.txt +1 -1
  228. package/src/tests/fixtures/onboard/solo.compose.yml.txt +1 -1
  229. package/src/tests/fixtures/onboard/solo.env.txt +1 -1
  230. package/src/tests/github-event-filter.test.ts +8 -0
  231. package/src/tests/github-handlers-inline-comments.test.ts +2 -0
  232. package/src/tests/github-handlers-reactions.test.ts +4 -0
  233. package/src/tests/github-handlers.test.ts +3 -0
  234. package/src/tests/github-sender-trust.test.ts +223 -0
  235. package/src/tests/http-users.test.ts +142 -41
  236. package/src/tests/k8s-pool-smoke.test.ts +190 -0
  237. package/src/tests/key-window-usage.test.ts +15 -0
  238. package/src/tests/memory-rater-store.test.ts +35 -1
  239. package/src/tests/memory-reranker.test.ts +39 -4
  240. package/src/tests/memory-review-recall-filter.test.ts +205 -0
  241. package/src/tests/migration-318-superseded-workflow-cut-backfill.test.ts +74 -0
  242. package/src/tests/model-groups-api.test.ts +415 -0
  243. package/src/tests/model-profiles-api.test.ts +1 -0
  244. package/src/tests/operator-granted-credentials.test.ts +7 -2
  245. package/src/tests/operator-granted-role-wire.test.ts +2 -1
  246. package/src/tests/rbac-engine.test.ts +1 -0
  247. package/src/tests/runtime-k8s-pools.test.ts +142 -0
  248. package/src/tests/runtime-pools-db.test.ts +42 -2
  249. package/src/tests/runtime-pools-http.test.ts +47 -2
  250. package/src/tests/runtime-provider-registration.test.ts +5 -14
  251. package/src/tests/runtime-providers-k8s.test.ts +303 -0
  252. package/src/tests/script-connections.test.ts +13 -1
  253. package/src/tests/short-id.test.ts +23 -0
  254. package/src/tests/slack-blocks.test.ts +69 -0
  255. package/src/tests/slack-render-v2.test.ts +54 -0
  256. package/src/tests/spec-base-url.test.ts +13 -1
  257. package/src/tests/system-one-decide-session-cost.test.ts +196 -0
  258. package/src/tests/task-ui-action-route.test.ts +59 -1
  259. package/src/tests/task-ui-script-actions.test.ts +517 -0
  260. package/src/tests/tool-hooks-http.test.ts +187 -0
  261. package/src/tests/ui-spec-script-actions-config.test.ts +196 -0
  262. package/src/tests/user-delete-perf.test.ts +321 -0
  263. package/src/tests/user-merge-jobs.test.ts +680 -0
  264. package/src/tests/vcs-provider.test.ts +25 -5
  265. package/src/tests/vendored-openapi.test.ts +13 -1
  266. package/src/tests/workflow-agent-task-retry.test.ts +62 -0
  267. package/src/tests/workflow-foreach-supersede-retry.test.ts +10 -0
  268. package/src/tests/workflow-http-v2.test.ts +27 -0
  269. package/src/tests/workflow-replay.test.ts +10 -1
  270. package/src/tests/workflow-triggers-v2.test.ts +128 -0
  271. package/src/tests/workflow-wait-event.test.ts +109 -1
  272. package/src/tools/memory-search.ts +14 -3
  273. package/src/tools/store-progress.ts +26 -26
  274. package/src/tools/swarm-config/delete-config.ts +12 -1
  275. package/src/tools/swarm-config/set-config.ts +8 -0
  276. package/src/tools/system-one-decide.ts +113 -3
  277. package/src/tools/utils.ts +4 -1
  278. package/src/tools/workflows/create-workflow.ts +2 -0
  279. package/src/tools/workflows/update-workflow.ts +3 -1
  280. package/src/types.ts +86 -2
  281. package/src/ui-spec/actions.ts +30 -4
  282. package/src/ui-spec/schema.ts +38 -0
  283. package/src/ui-spec/script-actions.ts +340 -0
  284. package/src/ui-spec/script-allowlist.ts +48 -0
  285. package/src/utils/short-id.ts +20 -14
  286. package/src/utils/task-ui-spec.ts +16 -4
  287. package/src/vcs/index.ts +12 -2
  288. package/src/workflows/executors/system-one-decision.ts +2 -2
  289. package/src/workflows/resume.ts +3 -2
  290. package/src/workflows/task-step-routing.ts +30 -10
  291. package/src/workflows/triggers.ts +35 -3
  292. package/templates/extensions/manifest.schema.json +13 -0
  293. package/templates/skills/swarm-docs/content.md +2 -0
  294. package/templates/skills/ui-spec/content.md +7 -1
  295. package/templates/workflows/dreaming/content.md +1 -1
  296. package/dist/acp-adapter-g909b5hw.js +0 -16
  297. package/dist/cli-b91nz213.js +0 -93
  298. package/dist/handlers-yzy0c87x.js +0 -35
  299. package/dist/index-2t4859r5.js +0 -35
  300. package/dist/index-cxca2t8y.js +0 -36
  301. package/dist/lead-gk4h5eg7.js +0 -74
  302. package/dist/thread-buffer-a1re2r9r.js +0 -38
  303. package/dist/worker-3dyyb8ev.js +0 -74
  304. package/dist/{azure-openai-responses-590s1eea.js → azure-openai-responses-b3y7fz36.js} +8 -8
  305. package/dist/{cli-m7c2380k.js → cli-3aaeb78m.js} +4 -4
  306. package/dist/{cli-g0vv9dg4.js → cli-8y43jx2r.js} +8 -8
  307. package/dist/{cli-m0cy2vyf.js → cli-k6nejceb.js} +4 -4
  308. package/dist/{google-generative-ai-maq6c9bf.js → google-generative-ai-bh0djqjp.js} +4 -4
  309. package/dist/{google-vertex-2jgsw2nb.js → google-vertex-prjbw8dj.js} +8 -8
  310. package/dist/{mistral-conversations-0c30em7t.js → mistral-conversations-tm2vd4gc.js} +8 -8
  311. package/dist/{node-dqm4xgxw.js → node-2wfcey7d.js} +0 -0
  312. package/dist/{openai-codex-responses-bkcd8pjj.js → openai-codex-responses-sxjv60xx.js} +4 -4
  313. package/dist/{openai-completions-f3n69rep.js → openai-completions-0c7qnhsx.js} +20 -20
  314. package/dist/{openai-responses-gbh0wfqe.js → openai-responses-a7h29chp.js} +15 -15
  315. package/dist/{pi-messages-zebyt7gb.js → pi-messages-2j0fpqwq.js} +5 -5
@@ -0,0 +1,250 @@
1
+ import { redactWithEnv } from "../e2b/env";
2
+ import { scrubSecrets } from "../utils/secret-scrubber";
3
+ import {
4
+ type ConfigStatus,
5
+ type ProvisionRequest,
6
+ RUNTIME_LABELS,
7
+ type RuntimeHandle,
8
+ type RuntimeProvider,
9
+ type RuntimeStatus,
10
+ type RuntimeTargetConfig,
11
+ } from "./types";
12
+
13
+ const SERVICE_ACCOUNT_DIR = "/var/run/secrets/kubernetes.io/serviceaccount";
14
+ const DNS_LABEL = /^[a-z0-9](?:[-a-z0-9]*[a-z0-9])?$/;
15
+
16
+ type Pod = {
17
+ metadata: {
18
+ name: string;
19
+ namespace: string;
20
+ uid: string;
21
+ labels?: Record<string, string>;
22
+ creationTimestamp?: string;
23
+ deletionTimestamp?: string;
24
+ };
25
+ status?: { phase?: string };
26
+ };
27
+
28
+ class KubernetesApiError extends Error {
29
+ constructor(
30
+ readonly statusCode: number,
31
+ method: string,
32
+ ) {
33
+ // Kubernetes validation errors can echo the complete pod, including worker credentials.
34
+ super(`Kubernetes ${method} pods failed (${statusCode})`);
35
+ }
36
+ }
37
+
38
+ function configuration(target: RuntimeTargetConfig) {
39
+ if ("K8S_TOKEN_FILE" in target || "K8S_CA_FILE" in target)
40
+ throw new Error("Kubernetes controller file paths are not supported.");
41
+ const inCluster = !target.K8S_API_URL && !!target.KUBERNETES_SERVICE_HOST;
42
+ let url: URL;
43
+ try {
44
+ url = new URL(target.K8S_API_URL || "https://kubernetes.default.svc");
45
+ } catch {
46
+ throw new Error("K8S_API_URL must be a valid HTTPS origin.");
47
+ }
48
+ if (
49
+ (url.protocol !== "https:" &&
50
+ !(url.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname))) ||
51
+ url.username ||
52
+ url.password ||
53
+ url.search ||
54
+ url.hash ||
55
+ url.pathname !== "/"
56
+ )
57
+ throw new Error("K8S_API_URL must be an HTTPS origin. HTTP is allowed only on loopback.");
58
+ if (!target.K8S_API_URL && !inCluster)
59
+ throw new Error("Set K8S_API_URL or run the API inside Kubernetes.");
60
+ const namespace = target.K8S_NAMESPACE || "default";
61
+ if (namespace.length > 63 || !DNS_LABEL.test(namespace))
62
+ throw new Error("K8S_NAMESPACE must be a valid Kubernetes namespace.");
63
+ if (!target.K8S_TOKEN?.trim() && !inCluster)
64
+ throw new Error("Set K8S_TOKEN in secretConfig or use in-cluster authentication.");
65
+ return {
66
+ url,
67
+ namespace,
68
+ tokenFile: inCluster ? `${SERVICE_ACCOUNT_DIR}/token` : undefined,
69
+ caFile: inCluster ? `${SERVICE_ACCOUNT_DIR}/ca.crt` : undefined,
70
+ };
71
+ }
72
+
73
+ async function kubernetesApi<T>(
74
+ target: RuntimeTargetConfig,
75
+ method: string,
76
+ suffix = "",
77
+ body?: unknown,
78
+ ): Promise<T> {
79
+ const config = configuration(target);
80
+ const token = target.K8S_TOKEN?.trim() || (await Bun.file(config.tokenFile!).text()).trim();
81
+ if (!token) throw new Error("Kubernetes token is empty.");
82
+ const ca =
83
+ target.K8S_CA_CERT || (config.caFile ? await Bun.file(config.caFile).text() : undefined);
84
+ try {
85
+ const response = await fetch(
86
+ new URL(`/api/v1/namespaces/${config.namespace}/pods${suffix}`, config.url),
87
+ {
88
+ method,
89
+ headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
90
+ body: body === undefined ? undefined : JSON.stringify(body),
91
+ redirect: "error",
92
+ signal: AbortSignal.timeout(30_000),
93
+ ...(ca ? { tls: { ca } } : {}),
94
+ },
95
+ );
96
+ if (!response.ok) {
97
+ await response.body?.cancel();
98
+ throw new KubernetesApiError(response.status, method);
99
+ }
100
+ return (await response.json()) as T;
101
+ } catch (error) {
102
+ if (error instanceof KubernetesApiError) throw error;
103
+ throw new Error(redactWithEnv(scrubSecrets(String(error)), { K8S_TOKEN: token }));
104
+ }
105
+ }
106
+
107
+ function podHandle(pod: Pod): RuntimeHandle {
108
+ return {
109
+ kind: "k8s",
110
+ externalId: pod.metadata.name,
111
+ createdAt: pod.metadata.creationTimestamp,
112
+ meta: {
113
+ ...pod.metadata.labels,
114
+ "k8s.namespace": pod.metadata.namespace,
115
+ "k8s.uid": pod.metadata.uid,
116
+ },
117
+ };
118
+ }
119
+
120
+ function handlePath(target: RuntimeTargetConfig, handle: RuntimeHandle): string {
121
+ if (
122
+ handle.kind !== "k8s" ||
123
+ !handle.meta?.["k8s.uid"] ||
124
+ handle.meta["k8s.namespace"] !== configuration(target).namespace
125
+ )
126
+ throw new Error("Kubernetes handle must include a pod UID and the configured namespace.");
127
+ return `/${encodeURIComponent(handle.externalId)}`;
128
+ }
129
+
130
+ export class KubernetesRuntimeProvider implements RuntimeProvider {
131
+ readonly kind = "k8s" as const;
132
+ readonly traits = { canProvision: true, ephemeralDisk: true, supportsPause: false };
133
+
134
+ checkConfig(target: RuntimeTargetConfig): ConfigStatus {
135
+ try {
136
+ configuration(target);
137
+ return { ready: true, missing: [] };
138
+ } catch (error) {
139
+ return { ready: false, missing: [], hint: scrubSecrets(String(error)) };
140
+ }
141
+ }
142
+
143
+ async provision(target: RuntimeTargetConfig, req: ProvisionRequest): Promise<RuntimeHandle> {
144
+ try {
145
+ if (req.cache) throw new Error("Kubernetes pools do not support persistent caches.");
146
+ const labels = {
147
+ ...req.labels,
148
+ [RUNTIME_LABELS.owner]: req.ownerId,
149
+ [RUNTIME_LABELS.runtimeId]: req.runtimeId,
150
+ [RUNTIME_LABELS.poolId]: req.poolId,
151
+ [RUNTIME_LABELS.agentId]: req.agentId,
152
+ };
153
+ const limits = {
154
+ ...(req.resources?.cpu ? { cpu: String(req.resources.cpu) } : {}),
155
+ ...(req.resources?.memoryMb ? { memory: `${req.resources.memoryMb}Mi` } : {}),
156
+ };
157
+ const name = `swarm-rt-${req.runtimeId}`;
158
+ const pod = await kubernetesApi<Pod>(target, "POST", "", {
159
+ apiVersion: "v1",
160
+ kind: "Pod",
161
+ metadata: { name, namespace: configuration(target).namespace, labels },
162
+ spec: {
163
+ restartPolicy: "Never",
164
+ automountServiceAccountToken: false,
165
+ ...(target.K8S_SERVICE_ACCOUNT ? { serviceAccountName: target.K8S_SERVICE_ACCOUNT } : {}),
166
+ ...(target.K8S_IMAGE_PULL_SECRETS
167
+ ? {
168
+ imagePullSecrets: target.K8S_IMAGE_PULL_SECRETS.split(",")
169
+ .map((name) => ({ name: name.trim() }))
170
+ .filter((secret) => secret.name),
171
+ }
172
+ : {}),
173
+ ...(req.ttlSec ? { activeDeadlineSeconds: req.ttlSec } : {}),
174
+ containers: [
175
+ {
176
+ name: "worker",
177
+ image: req.image,
178
+ env: Object.entries(req.env).map(([name, value]) => ({ name, value })),
179
+ ...(Object.keys(limits).length ? { resources: { requests: limits, limits } } : {}),
180
+ },
181
+ ],
182
+ },
183
+ });
184
+ return podHandle(pod);
185
+ } catch (error) {
186
+ throw new Error(redactWithEnv(scrubSecrets(String(error)), req.env));
187
+ }
188
+ }
189
+
190
+ async terminate(target: RuntimeTargetConfig, handle: RuntimeHandle): Promise<void> {
191
+ const path = handlePath(target, handle);
192
+ try {
193
+ await kubernetesApi(target, "DELETE", path, {
194
+ apiVersion: "v1",
195
+ kind: "DeleteOptions",
196
+ preconditions: { uid: handle.meta!["k8s.uid"] },
197
+ });
198
+ } catch (error) {
199
+ // A UID conflict means another pod now uses the name. Preserve that pod.
200
+ if (!(error instanceof KubernetesApiError && [404, 409].includes(error.statusCode)))
201
+ throw error;
202
+ }
203
+ }
204
+
205
+ async status(target: RuntimeTargetConfig, handle: RuntimeHandle): Promise<RuntimeStatus> {
206
+ try {
207
+ const pod = await kubernetesApi<Pod>(target, "GET", handlePath(target, handle));
208
+ if (pod.metadata.uid !== handle.meta!["k8s.uid"]) return "exited";
209
+ if (pod.metadata.deletionTimestamp) return "exited";
210
+ switch (pod.status?.phase) {
211
+ case "Pending":
212
+ return "starting";
213
+ case "Running":
214
+ return "running";
215
+ case "Succeeded":
216
+ return "exited";
217
+ case "Failed":
218
+ return "failed";
219
+ default:
220
+ return "unknown";
221
+ }
222
+ } catch (error) {
223
+ return error instanceof KubernetesApiError && error.statusCode === 404 ? "exited" : "unknown";
224
+ }
225
+ }
226
+
227
+ async list(target: RuntimeTargetConfig, ownerId: string): Promise<RuntimeHandle[]> {
228
+ const query = new URLSearchParams({
229
+ labelSelector: `${RUNTIME_LABELS.owner}=${ownerId},${RUNTIME_LABELS.runtimeId}`,
230
+ limit: "500",
231
+ });
232
+ const handles: RuntimeHandle[] = [];
233
+ let continuation: string | undefined;
234
+ do {
235
+ if (continuation) query.set("continue", continuation);
236
+ const page = await kubernetesApi<{ items: Pod[]; metadata?: { continue?: string } }>(
237
+ target,
238
+ "GET",
239
+ `?${query}`,
240
+ );
241
+ for (const pod of page.items) {
242
+ const labels = pod.metadata.labels;
243
+ if (labels?.[RUNTIME_LABELS.owner] === ownerId && labels[RUNTIME_LABELS.runtimeId])
244
+ handles.push(podHandle(pod));
245
+ }
246
+ continuation = page.metadata?.continue;
247
+ } while (continuation);
248
+ return handles;
249
+ }
250
+ }
@@ -778,6 +778,8 @@ declare module "swarm-sdk" {
778
778
  questions: Record<string, Record<string, unknown>>;
779
779
  timeoutMs?: number;
780
780
  maxRetries?: number;
781
+ /** Task whose session costs record this decision (default: the run's X-Source-Task-Id). */
782
+ taskId?: string;
781
783
  }): Promise<unknown>;
782
784
  }
783
785
 
@@ -352,7 +352,8 @@ declare module "swarm-extension" {
352
352
  runtimeInstanceId: string | undefined;
353
353
  sourceTaskId: string | undefined;
354
354
  contextKey: string | undefined;
355
- callOrigin: "mcp" | "extension" | "script-sdk";
355
+ callOrigin: "mcp" | "native" | "extension" | "script-sdk";
356
+ harness?: string | undefined;
356
357
  };
357
358
 
358
359
  import type { SwarmSdk } from "swarm-sdk";
@@ -394,7 +395,11 @@ declare module "swarm-extension" {
394
395
  };
395
396
  homepage?: string;
396
397
  author?: string;
398
+ /** Tool-call sources this extension's tool handlers receive. Default `["mcp"]`. */
399
+ toolSources?: readonly ToolSource[];
397
400
  }
401
+ /** `mcp`: swarm MCP tools. `native`: harness built-ins reported by a worker shim. */
402
+ export type ToolSource = "mcp" | "native";
398
403
  export interface HooksModule {
399
404
  default: SwarmExtension;
400
405
  config?: z.ZodTypeAny;
@@ -666,8 +671,16 @@ declare module "swarm-extension" {
666
671
  }
667
672
  export interface ToolCallEvent {
668
673
  tool: string;
674
+ /** Secret-scrubbed on native calls: a secret reads as `[REDACTED:<name>]`. */
669
675
  args: unknown;
670
676
  requestInfo: RequestInfo;
677
+ /** Native calls only: the harness's own tool name, such as `Bash`. */
678
+ nativeTool?: string;
679
+ /** Native calls only: the harness's own argument shape, secret-scrubbed. */
680
+ rawArgs?: unknown;
681
+ /** Native calls only: the harness's call id, and its parent for a nested call. */
682
+ toolCallId?: string;
683
+ parentToolCallId?: string;
671
684
  }
672
685
  export interface ToolCallModify {
673
686
  args: unknown;
@@ -797,6 +810,8 @@ declare module "swarm-extension" {
797
810
  export interface ToolCallCompletedEvent extends ToolCallEvent {
798
811
  result: unknown;
799
812
  durationMs: number;
813
+ /** Native calls only: the harness reported the call as failed. */
814
+ isError?: boolean;
800
815
  }
801
816
  export interface SwarmEventMap {
802
817
  "pre.task.create": {
@@ -736,6 +736,8 @@ declare module "swarm-sdk" {
736
736
  questions: Record<string, Record<string, unknown>>;
737
737
  timeoutMs?: number;
738
738
  maxRetries?: number;
739
+ /** Task whose session costs record this decision (default: the run's X-Source-Task-Id). */
740
+ taskId?: string;
739
741
  }): Promise<unknown>;
740
742
  }
741
743
 
@@ -3,7 +3,7 @@ import type { ChatUpdateArguments, WebClient } from "@slack/web-api";
3
3
  import { cancelTask, getAgentById, getLeadAgent, getTaskById } from "../be/db";
4
4
  import { slackContextKey } from "../tasks/context-key";
5
5
  import { createTaskWithSiblingAwareness } from "../tasks/sibling-awareness";
6
- import { runTaskUiAction } from "../ui-spec/actions";
6
+ import { runTaskUiAction, type TaskUiActionResult } from "../ui-spec/actions";
7
7
  import { UI_SPEC_ACTION_PREFIX } from "../utils/task-ui-spec";
8
8
  import { buildCancelledBlocks, getTaskLink } from "./blocks";
9
9
  import { resolveSlackUserId } from "./enrich";
@@ -12,13 +12,35 @@ import { ignoreSlackInbound, noteSlackInboundSideEffect } from "./inbound-dispat
12
12
  import { ensureSlackThreadTree, isSlackRenderV2Enabled } from "./render-v2";
13
13
  import { getAgentDisplayName, getAgentSlackIcon } from "./responses";
14
14
 
15
- /** The ephemeral reply to a card Button click that did not start its action. */
16
- const UI_ACTION_REPLIES = {
17
- forbidden: "Only the person who asked for this task can use its buttons.",
18
- already_done: "This button already ran.",
19
- disabled: "Card buttons are turned off on this swarm.",
20
- unknown_action: "This button has no action.",
21
- } as const;
15
+ /** The ephemeral reply to a card click, or `null` when the click needs none. */
16
+ function uiActionReply(result: TaskUiActionResult, renderV2: boolean): string | null {
17
+ switch (result.status) {
18
+ case "started":
19
+ return null;
20
+ // v2 edits the outcome card in place; v1 keeps no record of the message.
21
+ case "refreshed":
22
+ return renderV2 ? null : "Card refreshed in the dashboard.";
23
+ case "forbidden":
24
+ return "Only the person who asked for this task can use its buttons.";
25
+ case "already_done":
26
+ return "This button already ran.";
27
+ case "disabled":
28
+ return "Card buttons are turned off on this swarm.";
29
+ case "unknown_action":
30
+ return "This button has no action.";
31
+ case "not_allowlisted":
32
+ return "This button's script is not allowlisted for card buttons.";
33
+ case "script_changed":
34
+ return "This button's script changed since it was allowlisted. An admin must re-pin it.";
35
+ case "running":
36
+ return "This button is already running. Try again in a moment.";
37
+ case "rate_limited":
38
+ return `This button ran recently. Try again in ${result.retryAfterSec}s.`;
39
+ case "script_failed":
40
+ case "invalid_output":
41
+ return `Refresh failed: ${result.error}`;
42
+ }
43
+ }
22
44
 
23
45
  type ChatUpdatePayload = ChatUpdateArguments & {
24
46
  unfurl_links: false;
@@ -205,12 +227,13 @@ export function registerActionHandlers(app: App): void {
205
227
  if (isSlackRenderV2Enabled()) await ensureSlackThreadTree([result.taskId]);
206
228
  return;
207
229
  }
208
- if (!channelId) return;
230
+ const reply = uiActionReply(result, isSlackRenderV2Enabled());
231
+ if (!channelId || !reply) return;
209
232
  try {
210
233
  await client.chat.postEphemeral({
211
234
  channel: channelId,
212
235
  user: body.user.id,
213
- text: UI_ACTION_REPLIES[result.status],
236
+ text: reply,
214
237
  });
215
238
  } catch (error) {
216
239
  console.error("[Slack] Failed to post card button reply:", error);
@@ -45,8 +45,26 @@ export function getTaskUrl(taskId: string): string {
45
45
  * - Slack: *bold*, *bold*, _italic_, ~strike~, *Header*, text (url)
46
46
  */
47
47
  export function markdownToSlack(text: string): string {
48
+ const code: string[] = [];
49
+ // Leave the closing delimiter unconsumed so adjacent candidates are all seen.
50
+ const usedMarkers = new Set(
51
+ Array.from(text.matchAll(/\uE002(\d+)(?=\uE002)/g), (match) => match[1]),
52
+ );
53
+ let markerIndex = 0;
54
+ while (usedMarkers.has(String(markerIndex))) markerIndex++;
55
+ const codeMarker = `\uE002${markerIndex}\uE002`;
56
+ // Hide code from every formatting rule, including blank-line normalization.
57
+ const protectedText = text.replace(
58
+ /\\[\s\S]|```[\s\S]*?(?:```|$)|(?<!`)(`+)(?!`)(?:(?!\r?\n[ \t]*\r?\n)[\s\S])*?(?<!`)\1(?!`)/g,
59
+ (match) => {
60
+ // Consume escapes outside code; inline runs must match within one paragraph.
61
+ if (match.startsWith("\\")) return match;
62
+ code.push(match);
63
+ return `${codeMarker}${code.length - 1}\uE003`;
64
+ },
65
+ );
48
66
  return (
49
- text
67
+ protectedText
50
68
  // Images: keep alt text and expose the URL plainly.
51
69
  .replace(/!\[([^\]]*)\]\(([^)\s]+)(?:\s+"[^"]*")?\)/g, (_match, alt, url) =>
52
70
  alt ? `${alt} (${url})` : url,
@@ -68,10 +86,13 @@ export function markdownToSlack(text: string): string {
68
86
  .replace(/\uE000(.+?)\uE001/g, "*$1*")
69
87
  // Strikethrough ~~text~~ -> ~text~
70
88
  .replace(/~~(.+?)~~/g, "~$1~")
71
- // Inline code already works the same
72
89
  // Bullet points already work the same
73
90
  // Remove excessive blank lines
74
91
  .replace(/\n{3,}/g, "\n\n")
92
+ .replace(
93
+ new RegExp(`${codeMarker}(\\d+)\\uE003`, "g"),
94
+ (_match, index) => code[Number(index)]!,
95
+ )
75
96
  );
76
97
  }
77
98
 
@@ -42,6 +42,7 @@ import { isEnvFlagEnabled } from "../utils/env-flag";
42
42
  import { scrubSecrets } from "../utils/secret-scrubber";
43
43
  import { taskAttachmentDisplayUrl } from "../utils/task-attachment-links";
44
44
  import { renderTaskCitations, taskCitationSourceGroups } from "../utils/task-citations";
45
+ import { TASK_UI_SPEC_UPDATED_EVENT } from "../utils/task-ui-spec";
45
46
  import { workflowEventBus } from "../workflows/event-bus";
46
47
  import {
47
48
  finalizeSlackMessageReaction,
@@ -1568,6 +1569,50 @@ export async function streamOutcomeCard(
1568
1569
  });
1569
1570
  }
1570
1571
 
1572
+ /**
1573
+ * Re-renders a settled outcome message after a script action replaced the
1574
+ * task's card. The settled-outcome skip in the thread render never edits it,
1575
+ * so this is its own path. Returns whether Slack was called.
1576
+ */
1577
+ export async function refreshSlackOutcomeCard(taskId: string): Promise<boolean> {
1578
+ const app = getSlackApp();
1579
+ if (!app) return false;
1580
+ const task = await getTaskById(taskId);
1581
+ if (!task?.slackChannelId || !task.slackThreadTs) return false;
1582
+ const card = await getSlackOutcomeMessage(task.id);
1583
+ if (!card?.ts || !card.finalizedAt || !isSettledSlackMessage(card)) return false;
1584
+
1585
+ const tasks = await getSlackTasksInThread(task.slackChannelId, task.slackThreadTs);
1586
+ const duration = formatV2Duration(new Date(task.createdAt), terminalEnd(task, new Date()));
1587
+ const content = await outcomeContent(task, task.slackReplySent);
1588
+ const presentation = await outcomePresentation(task, content);
1589
+ if (!presentation) return false;
1590
+ const captions = [
1591
+ ...(await outcomeCaptionBlocks(task, content)),
1592
+ ...(await outcomeFooter(task, tasks, duration)),
1593
+ ];
1594
+ const uiSpec = await outcomeUiSpec(task);
1595
+ await withUiSpecBlockFallback(uiSpec, task.id, (withCard) => {
1596
+ const text = withUiSpecFallbackText(presentation, uiSpec, withCard);
1597
+ const cardBlocks = withCard && uiSpec ? uiSpec.blocks : [];
1598
+ return callSlackWithRetry(app.client, "chat.update", {
1599
+ channel: task.slackChannelId,
1600
+ ts: card.ts,
1601
+ text,
1602
+ blocks: [{ type: "markdown", text }, ...cardBlocks, ...captions],
1603
+ });
1604
+ });
1605
+ return true;
1606
+ }
1607
+
1608
+ function onTaskUiSpecUpdated(data: unknown): void {
1609
+ const taskId = (data as { taskId?: unknown } | null)?.taskId;
1610
+ if (typeof taskId !== "string") return;
1611
+ refreshSlackOutcomeCard(taskId).catch((error) =>
1612
+ console.error(`[Slack] Failed to refresh the card of task ${taskId}:`, error),
1613
+ );
1614
+ }
1615
+
1571
1616
  /** Render the latest wait or final result into the chain's original card. */
1572
1617
  async function resolvedDeferralContent(
1573
1618
  wake: AgentTask,
@@ -2055,12 +2100,14 @@ function onSlackRenderTaskEvent(data: unknown): void {
2055
2100
  export function startSlackRenderV2Events(): void {
2056
2101
  if (renderEventsSubscribed) return;
2057
2102
  for (const event of SLACK_RENDER_TASK_EVENTS) workflowEventBus.on(event, onSlackRenderTaskEvent);
2103
+ workflowEventBus.on(TASK_UI_SPEC_UPDATED_EVENT, onTaskUiSpecUpdated);
2058
2104
  renderEventsSubscribed = true;
2059
2105
  }
2060
2106
 
2061
2107
  export function stopSlackRenderV2Events(): void {
2062
2108
  if (!renderEventsSubscribed) return;
2063
2109
  for (const event of SLACK_RENDER_TASK_EVENTS) workflowEventBus.off(event, onSlackRenderTaskEvent);
2110
+ workflowEventBus.off(TASK_UI_SPEC_UPDATED_EVENT, onTaskUiSpecUpdated);
2064
2111
  renderEventsSubscribed = false;
2065
2112
  if (dirtyFlushTimer) clearTimeout(dirtyFlushTimer);
2066
2113
  dirtyFlushTimer = null;
@@ -121,6 +121,32 @@ describe("ACPAdapter", () => {
121
121
  );
122
122
  });
123
123
 
124
+ test.each([
125
+ "gemini",
126
+ "Gemini",
127
+ " gemini ",
128
+ "GEMINI",
129
+ ])("normalizes ACP target %j before selecting a preset", (target) => {
130
+ const config = baseConfig({ env: { ACP_TARGET: target } });
131
+ const profile = resolveAcpTarget(config);
132
+ expect(profile.target).toBe("gemini");
133
+ expect(profile.command(config)).toEqual(["gemini", "--acp"]);
134
+ });
135
+
136
+ test.each(["", " \t "])("defaults blank ACP target %j to custom", (target) => {
137
+ const config = baseConfig({
138
+ env: { ACP_TARGET: target, ACP_TARGET_COMMAND: "custom-acp --stdio" },
139
+ });
140
+ const profile = resolveAcpTarget(config);
141
+ expect(profile.target).toBe("custom");
142
+ expect(profile.command(config)).toEqual(["custom-acp", "--stdio"]);
143
+ });
144
+
145
+ test.each(["nope", " NOPE "])("rejects unknown ACP target %j", (target) => {
146
+ const config = baseConfig({ env: { ACP_TARGET: target } });
147
+ expect(() => resolveAcpTarget(config)).toThrow('Unsupported ACP target "nope"');
148
+ });
149
+
124
150
  test.each<{ name: string; usage?: Usage | null }>([
125
151
  { name: "absent", usage: undefined },
126
152
  { name: "null", usage: null },
@@ -189,10 +189,30 @@ describe("chat relay text", () => {
189
189
  const words = Array.from({ length: 2000 }, (_, i) => `word${i}`).join(" ");
190
190
  const chunks = splitChatMessage(words, 4096);
191
191
  expect(chunks.every((chunk) => chunk.length <= 4096)).toBe(true);
192
- expect(chunks.join(" ")).toBe(words);
192
+ expect(chunks.join("")).toBe(words);
193
193
  expect(splitChatMessage("short", 4096)).toEqual(["short"]);
194
194
  });
195
195
 
196
+ test("splitChatMessage keeps a space that falls on a split boundary", () => {
197
+ const chunks = splitChatMessage("hello world", 6);
198
+ expect(chunks).toEqual(["hello ", "world"]);
199
+ expect(chunks.join("")).toBe("hello world");
200
+ // Every boundary kind (space, line break, repeated whitespace) joins back
201
+ // to the original text and stays within the limit.
202
+ const cases: Array<[string, number]> = [
203
+ ["one two three four five", 9],
204
+ ["line one\nline two\nline three", 10],
205
+ ["a \n b", 2],
206
+ ["word ".repeat(50), 17],
207
+ [" leading and trailing ", 5],
208
+ ];
209
+ for (const [text, limit] of cases) {
210
+ const parts = splitChatMessage(text, limit);
211
+ expect(parts.join("")).toBe(text);
212
+ expect(parts.every((part) => part.length <= limit)).toBe(true);
213
+ }
214
+ });
215
+
196
216
  test("splitChatMessage does not loop on a surrogate pair at a tiny limit", () => {
197
217
  // A one-code-unit limit is smaller than an emoji: keep the pair whole.
198
218
  expect(splitChatMessage("😀", 1)).toEqual(["😀"]);
@@ -286,3 +286,46 @@ describe("check-pr-body: PR_TEMPLATE_PATH", () => {
286
286
  }
287
287
  });
288
288
  });
289
+
290
+ describe("check-pr-body: PR_BODY_PROBLEMS_FILE", () => {
291
+ // pr-body-comment.yml posts this file as the fork PR comment.
292
+ test("a failing body writes its problems as a Markdown list; a passing body writes nothing", async () => {
293
+ const dir = await mkdtemp(join(tmpdir(), "pr-body-problems-"));
294
+ try {
295
+ const templatePath = join(dir, "template.md");
296
+ const bodyPath = join(dir, "body.md");
297
+ const problemsPath = join(dir, "problems.md");
298
+ await Bun.write(
299
+ templatePath,
300
+ "**Why:** <!-- one line -->\n\n## Only section\n\n<!-- guidance -->\n",
301
+ );
302
+ const run = (body: string) =>
303
+ Bun.write(bodyPath, body).then(() =>
304
+ runChild(["bun", "scripts/check-pr-body.ts", "--body-file", bodyPath], {
305
+ env: {
306
+ PATH: process.env.PATH,
307
+ HOME: process.env.HOME,
308
+ PR_TITLE: "chore: x",
309
+ PR_AUTHOR: "someone",
310
+ PR_CHANGED_FILES_FILE: bodyPath,
311
+ PR_TEMPLATE_PATH: templatePath,
312
+ PR_BODY_PROBLEMS_FILE: problemsPath,
313
+ },
314
+ }),
315
+ );
316
+
317
+ const failing = await run("## Summary\n\nWrote my own headings.\n");
318
+ expect(failing.exitCode).toBe(1);
319
+ expect(await Bun.file(problemsPath).text()).toBe(
320
+ "- missing line: **Why:**\n- missing section: ## Only section\n",
321
+ );
322
+
323
+ await rm(problemsPath);
324
+ const passing = await run("**Why:** reason.\n\n## Only section\n\nFilled.\n");
325
+ expect(passing.exitCode).toBe(0);
326
+ expect(await Bun.file(problemsPath).exists()).toBe(false);
327
+ } finally {
328
+ await rm(dir, { recursive: true, force: true });
329
+ }
330
+ });
331
+ });
@@ -952,7 +952,7 @@ describe("checkOpencodeCredentials", () => {
952
952
  });
953
953
 
954
954
  describe("ACP readiness", () => {
955
- test.each(["typo", "", " \t "])("rejects unsupported target %j", async (target) => {
955
+ test.each(["typo", "nope", " NOPE "])("rejects unsupported target %j", async (target) => {
956
956
  const status = await checkProviderCredentials("acp", {
957
957
  ACP_TARGET: target,
958
958
  ACP_TARGET_COMMAND: "custom-acp --stdio",
@@ -963,7 +963,12 @@ describe("ACP readiness", () => {
963
963
  for (const supported of ACP_TARGET_IDS) expect(status.hint).toContain(supported);
964
964
  });
965
965
 
966
- test.each([undefined, "custom"])("requires a command for target %s", async (target) => {
966
+ test.each([
967
+ undefined,
968
+ "custom",
969
+ "",
970
+ " \t ",
971
+ ])("requires a command for target %j", async (target) => {
967
972
  const status = await CREDENTIAL_PROVIDER_CHECKERS.acp({ ACP_TARGET: target });
968
973
  expect(status.ready).toBe(false);
969
974
  expect(status.missing).toEqual(["ACP_TARGET_COMMAND"]);
@@ -982,7 +987,7 @@ describe("ACP readiness", () => {
982
987
  });
983
988
 
984
989
  test.each(["ACP_TARGET_COMMAND", "ACP_COMMAND"])("accepts a command from %s", async (key) => {
985
- for (const target of [undefined, "custom"]) {
990
+ for (const target of [undefined, "custom", "", " \t "]) {
986
991
  const status = await checkProviderCredentials("acp", {
987
992
  ACP_TARGET: target,
988
993
  [key]: "custom-acp --stdio",
@@ -991,9 +996,12 @@ describe("ACP readiness", () => {
991
996
  }
992
997
  });
993
998
 
994
- test.each(
995
- ACP_TARGET_IDS.filter((target) => target !== "custom"),
996
- )("keeps preset %s ready without a custom command", async (target) => {
999
+ test.each([
1000
+ ...ACP_TARGET_IDS.filter((target) => target !== "custom"),
1001
+ "Gemini",
1002
+ " gemini ",
1003
+ "GEMINI",
1004
+ ])("keeps preset %s ready without a custom command", async (target) => {
997
1005
  const status = await checkProviderCredentials("acp", { ACP_TARGET: target });
998
1006
  expect(status).toEqual({ ready: true, missing: [], satisfiedBy: "sdk-delegated" });
999
1007
  });