@desplega.ai/agent-swarm 1.165.0 → 1.167.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 (296) hide show
  1. package/dist/acp-adapter-zpvy6321.js +34 -0
  2. package/dist/{actions-jna0b3wm.js → actions-fq2zrwtf.js} +30 -34
  3. package/dist/{amp-adapter-0eve81pz.js → amp-adapter-5gbk7501.js} +7 -7
  4. package/dist/{anthropic-messages-hst62ws9.js → anthropic-messages-13yn502s.js} +4 -4
  5. package/dist/{app-75hm5cfa.js → app-nctetn1e.js} +11 -11
  6. package/dist/{assistant-yzd51j33.js → assistant-0aq8gjvj.js} +31 -35
  7. package/dist/{azure-openai-responses-mh8tvf78.js → azure-openai-responses-9st34pfz.js} +5 -5
  8. package/dist/{boot-reembed-z158xq32.js → boot-reembed-1ze5853n.js} +14 -16
  9. package/dist/{boot-reembed-2ex2mcsh.js → boot-reembed-fmp5ww69.js} +15 -16
  10. package/dist/boot-scrub-sweep-cbp8xd4e.js +212 -0
  11. package/dist/{boot-seeds-2bmnh18p.js → boot-seeds-22tx8a53.js} +13 -12
  12. package/dist/{claude-adapter-jbj1mycz.js → claude-adapter-0jhgeh1d.js} +25 -25
  13. package/dist/{claude-managed-adapter-17ggz09t.js → claude-managed-adapter-tzwxy803.js} +5 -5
  14. package/dist/{claude-managed-setup-ptm1nzm2.js → claude-managed-setup-nrhfx5b0.js} +5 -5
  15. package/dist/{claude-sdk-session-9re1g7r2.js → claude-sdk-session-wh77rh83.js} +2632 -2614
  16. package/dist/{cli-zsh093hk.js → cli-014vns2y.js} +63 -1
  17. package/dist/{cli-qvfk83fy.js → cli-13xwcqvj.js} +2 -2
  18. package/dist/{cli-8gpbwy09.js → cli-1yrcfa5s.js} +5 -5
  19. package/dist/{cli-xtgtyafv.js → cli-577bxkf6.js} +212 -451
  20. package/dist/{cli-ma3zvh39.js → cli-5qkcdv8c.js} +6118 -5874
  21. package/dist/{cli-cwxhbf43.js → cli-5t5my0h8.js} +85 -2
  22. package/dist/{cli-zvckv750.js → cli-69egj654.js} +2 -2
  23. package/dist/{cli-9xb89xca.js → cli-6bpvv8h4.js} +9 -9
  24. package/dist/{cli-90v942q1.js → cli-6qxmjpem.js} +8 -8
  25. package/dist/{cli-9866bd07.js → cli-6vfz44sr.js} +1 -1
  26. package/dist/{cli-32bca7nr.js → cli-7avy4v8w.js} +1 -1
  27. package/dist/{cli-xb3c6aat.js → cli-7mhy3ths.js} +21 -18
  28. package/dist/{cli-q38n4bq0.js → cli-95zs84qw.js} +3 -3
  29. package/dist/cli-a35hzdve.js +33 -0
  30. package/dist/{cli-x3x0qwky.js → cli-bxqez1p0.js} +51 -23
  31. package/dist/{cli-prt9emct.js → cli-c2tpw9ck.js} +3 -3
  32. package/dist/{cli-0n4fasz0.js → cli-c8r99akr.js} +16 -16
  33. package/dist/{cli-5anb0ev3.js → cli-cexctgn5.js} +89 -26
  34. package/dist/{cli-bns5c8k9.js → cli-cf2vgn9d.js} +105 -91
  35. package/dist/{cli-ng97fjq7.js → cli-cmxkbzzs.js} +33 -7
  36. package/dist/{cli-nexwh8zg.js → cli-g7k7zbcz.js} +12 -5
  37. package/dist/{cli-mmzwwptd.js → cli-hf5s9pgf.js} +1 -1
  38. package/dist/{cli-nvvfd8bq.js → cli-jbzbr36n.js} +4091 -3793
  39. package/dist/{cli-zn2v3t8v.js → cli-jvmtxqtc.js} +27 -15
  40. package/dist/{cli-pkke6geq.js → cli-km4x66j0.js} +83 -65
  41. package/dist/cli-kw0jcfje.js +516 -0
  42. package/dist/{cli-28smfvbn.js → cli-m7vmeepg.js} +32 -19
  43. package/dist/{cli-hpryr6em.js → cli-mb75wpxf.js} +1 -1
  44. package/dist/{cli-qdv8kgz7.js → cli-mkdsy1nq.js} +14018 -3333
  45. package/dist/{cli-b0f70z24.js → cli-mn8qkd8v.js} +1 -1
  46. package/dist/{cli-420bdgw0.js → cli-mv2520nm.js} +1 -1
  47. package/dist/{cli-n9ehc28t.js → cli-mxry91sa.js} +31 -10
  48. package/dist/{cli-wfajtmf7.js → cli-mxvnnv5q.js} +596 -13
  49. package/dist/cli-nkqjj42q.js +104 -0
  50. package/dist/{cli-e7t4snpa.js → cli-p8rt8spp.js} +5 -5
  51. package/dist/{cli-gh5yqzpe.js → cli-pkj1w46r.js} +12 -7
  52. package/dist/cli-q1vnz8wv.js +96 -0
  53. package/dist/{cli-fj86xr3c.js → cli-qd97v6z2.js} +2 -2
  54. package/dist/{cli-ba66wyhy.js → cli-qzmzwegq.js} +60 -20
  55. package/dist/{cli-5b2fjjzh.js → cli-r7eeddkq.js} +14 -9
  56. package/dist/{cli-8ssjez7e.js → cli-rhy7z1rp.js} +22 -11
  57. package/dist/{cli-4mevd1hf.js → cli-s9y81s7j.js} +5 -5
  58. package/dist/{cli-59jn5twa.js → cli-tc5zec7v.js} +7 -7
  59. package/dist/{cli-ttbsse3f.js → cli-tmhsxhb8.js} +1 -1
  60. package/dist/{cli-k6xx3pve.js → cli-tx2zvn23.js} +4 -4
  61. package/dist/{cli-pjxnr1jn.js → cli-ty4bzkqr.js} +5 -5
  62. package/dist/{cli-nfygw434.js → cli-v1pwxreq.js} +55 -52
  63. package/dist/{cli-ftry7975.js → cli-v1w7pbd8.js} +3 -2
  64. package/dist/{cli-10zmp1p7.js → cli-vr5avem2.js} +27 -32
  65. package/dist/{cli-bzr0ftht.js → cli-wnb9b2g3.js} +19 -0
  66. package/dist/cli-wt7ccy4r.js +2654 -0
  67. package/dist/{cli-50eg13rj.js → cli-wydz3feg.js} +549 -321
  68. package/dist/{cli-krqm5f11.js → cli-xezn9nkh.js} +16 -13
  69. package/dist/{cli-8kt0bmgx.js → cli-xf713zz0.js} +2 -2
  70. package/dist/{cli-x7afk5wm.js → cli-xvc3q9br.js} +1 -1
  71. package/dist/{cli-9s3h836g.js → cli-xvdgasgy.js} +1 -1
  72. package/dist/{cli-j0pdrmwg.js → cli-y0kjpfm9.js} +3 -3
  73. package/dist/{cli-6zcfw0x7.js → cli-y195hv1a.js} +1 -1
  74. package/dist/{cli-amwhs8h2.js → cli-ykt8f7va.js} +22 -9
  75. package/dist/{cli-1kzfvd1z.js → cli-ymmc1zxg.js} +15 -11
  76. package/dist/{cli-xnzrzets.js → cli-ypgba1a8.js} +2 -2
  77. package/dist/{cli-bdv39kgj.js → cli-z1dqhc9y.js} +31 -20
  78. package/dist/{cli-fw6vdcq5.js → cli-zp67qg5x.js} +34 -1
  79. package/dist/{cli-qbksc292.js → cli-zy39d433.js} +2 -0
  80. package/dist/cli.js +36 -32
  81. package/dist/{cloudflare-workers-ai-system-one-tt484t61.js → cloudflare-workers-ai-system-one-sta45jf9.js} +7 -5
  82. package/dist/{codex-adapter-3qnxshje.js → codex-adapter-cgesnjkr.js} +20 -20
  83. package/dist/{codex-login-brkxhhdg.js → codex-login-g1cyt5zm.js} +2 -2
  84. package/dist/{codex-session-runner-612wnapp.js → codex-session-runner-8kd7ddhr.js} +20 -20
  85. package/dist/{commands-2ybfcxkj.js → commands-h6zaaxym.js} +11 -10
  86. package/dist/{cursor-adapter-p3jgdehv.js → cursor-adapter-v8mm6bp5.js} +7 -7
  87. package/dist/{db-f4ans0jj.js → db-qg3myn53.js} +13 -10
  88. package/dist/{devin-adapter-dhzt01ff.js → devin-adapter-bffjj5n4.js} +2 -2
  89. package/dist/{dispatcher-pk182apd.js → dispatcher-7vnwj9qw.js} +28 -32
  90. package/dist/{dsh-adapter-7twaeps1.js → dsh-adapter-tz6hfp5r.js} +7 -7
  91. package/dist/{e2b-y8t3jzyz.js → e2b-nd50eccg.js} +1 -1
  92. package/dist/{easter-egg-3d-mtpnw06s.js → easter-egg-3d-66zxervv.js} +2 -2
  93. package/dist/{event-bus-w7ac4n3c.js → event-bus-vnfthafg.js} +2 -2
  94. package/dist/{execute-s4ccjq3n.js → execute-h4jgevyw.js} +61 -11
  95. package/dist/{google-generative-ai-d6nphg3q.js → google-generative-ai-b8zxrpax.js} +5 -5
  96. package/dist/{google-vertex-cpshkref.js → google-vertex-nrdd697t.js} +5 -5
  97. package/dist/grok-adapter-jdt2dz2s.js +39 -0
  98. package/dist/{handlers-g2wnr4t9.js → handlers-2qtkpncr.js} +31 -35
  99. package/dist/{hook-f7jt9vnm.js → hook-51yfcgsv.js} +48 -39
  100. package/dist/{hook-bbdpnkb4.js → hook-qnbdgwvd.js} +15 -17
  101. package/dist/{http-w40q4w94.js → http-jsmtag08.js} +536 -231
  102. package/dist/{index-056j5kzn.js → index-2t9kesn1.js} +13 -12
  103. package/dist/{index-cj1r9q83.js → index-bt8wkv1w.js} +29 -33
  104. package/dist/{index-7n70jwbb.js → index-cx1sb9bq.js} +42 -35
  105. package/dist/{index-9bfssf54.js → index-ekywyv2v.js} +28 -32
  106. package/dist/{index-fdk1t4d6.js → index-n0rxa4ca.js} +11962 -9900
  107. package/dist/{index-k8xc083e.js → index-t4g06w93.js} +28 -32
  108. package/dist/{keepalive-1tj10tf4.js → keepalive-4aezx4bj.js} +16 -12
  109. package/dist/{lead-st0bg7v4.js → lead-r44bkpm5.js} +52 -56
  110. package/dist/{llama-cpp-classify-tgj35k8d.js → llama-cpp-classify-6erb7wwv.js} +3 -1
  111. package/dist/{maintenance-nz71zats.js → maintenance-grz5jrzh.js} +12 -13
  112. package/dist/{mistral-conversations-8445ddjn.js → mistral-conversations-059y51zt.js} +4 -4
  113. package/dist/{node-f0ykebbv.js → node-qm9eb6z0.js} +25 -7
  114. package/dist/{oauth-refresh-sweep-aefzwvvq.js → oauth-refresh-sweep-wm4ctjfj.js} +15 -11
  115. package/dist/{onboard-kgpr9mbn.js → onboard-v60zgqf0.js} +2 -2
  116. package/dist/{openai-codex-responses-9ynm88zy.js → openai-codex-responses-jzxkta9b.js} +8 -7
  117. package/dist/{openai-completions-nhqwjmaw.js → openai-completions-663yncfq.js} +4 -4
  118. package/dist/openai-decisions-vj9nkpf8.js +162 -0
  119. package/dist/{openai-responses-xx1c4kgm.js → openai-responses-m3g43rrt.js} +5 -5
  120. package/dist/{opencode-adapter-0c8e70dk.js → opencode-adapter-yjyqynzf.js} +8 -8
  121. package/dist/{openrouter-images-8yx3487g.js → openrouter-images-kr60n6b9.js} +1 -1
  122. package/dist/{otel-impl-x8zp4y5a.js → otel-impl-ghh4dyf8.js} +2 -2
  123. package/dist/{pi-messages-vxdt8v7j.js → pi-messages-xszk613n.js} +1 -1
  124. package/dist/{pi-mono-adapter-t280ah5c.js → pi-mono-adapter-0eg8kw2c.js} +69 -52
  125. package/dist/{pricing-refresh-9e0q7cwk.js → pricing-refresh-mjrqvnvw.js} +12 -11
  126. package/dist/{rbac-roles-790j3ga8.js → rbac-roles-axv4d74x.js} +11 -10
  127. package/dist/{rbac-roles-kcp6zge2.js → rbac-roles-fd5tskj9.js} +11 -10
  128. package/dist/{render-v2-tch4nefj.js → render-v2-k50j33qd.js} +11 -11
  129. package/dist/{runtime-v2t1r79e.js → runtime-h9ha1mq6.js} +4 -4
  130. package/dist/{setup-rcm303ns.js → setup-4syh0pd2.js} +2 -2
  131. package/dist/{typesafe-system-one-datfr82p.js → typesafe-system-one-e988vty7.js} +7 -5
  132. package/dist/{virtual-modules-wm8mxdxx.js → virtual-modules-ftr9kwe8.js} +11 -11
  133. package/dist/{work-objects-ctg7t70w.js → work-objects-jcdbg8rr.js} +32 -36
  134. package/dist/{worker-5dp0xm55.js → worker-x8j8c9sx.js} +52 -56
  135. package/dist/{x-v3yw66zs.js → x-ma4gnfgy.js} +2 -2
  136. package/openapi.json +5 -2
  137. package/package.json +15 -11
  138. package/src/be/automation-preflight.ts +9 -4
  139. package/src/be/boot-scrub-sweep.ts +302 -0
  140. package/src/be/crypto/key-bootstrap.ts +1 -1
  141. package/src/be/db/approvals.ts +15 -1
  142. package/src/be/db/codex-oauth-device-flows.ts +40 -0
  143. package/src/be/db/config-secrets.ts +31 -0
  144. package/src/be/db/runtime.ts +4 -0
  145. package/src/be/db/script-runs.ts +15 -0
  146. package/src/be/db/tasks/write.ts +1 -1
  147. package/src/be/db-queries/mcp-oauth.ts +5 -0
  148. package/src/be/db-queries/oauth.ts +77 -0
  149. package/src/be/db.ts +162 -59
  150. package/src/be/events.ts +17 -1
  151. package/src/be/memory/index-content.ts +2 -2
  152. package/src/be/memory/providers/openai-embedding.ts +7 -2
  153. package/src/be/memory/providers/sqlite-store.ts +63 -11
  154. package/src/be/memory/raters/llm-summarizer.ts +7 -2
  155. package/src/be/memory/types.ts +14 -0
  156. package/src/be/migrations/201_workflow_replay_columns.sql +10 -0
  157. package/src/be/migrations/202_codex_oauth_device_flows.sql +24 -0
  158. package/src/be/modelsdev-cache.json +61 -0
  159. package/src/be/scripts/db.ts +28 -4
  160. package/src/be/scripts/source-secrets.ts +37 -0
  161. package/src/be/scrub-json.ts +32 -0
  162. package/src/be/sealed-json.ts +59 -0
  163. package/src/be/secret-registry.ts +131 -0
  164. package/src/be/seed-pricing.ts +84 -53
  165. package/src/be/swarm-config-guard.ts +13 -0
  166. package/src/be/workflow-replay.ts +77 -0
  167. package/src/commands/provider-credentials.ts +28 -5
  168. package/src/commands/runner.ts +7 -12
  169. package/src/heartbeat/heartbeat.ts +91 -19
  170. package/src/hooks/hook.ts +72 -27
  171. package/src/http/codex-oauth-device.ts +8 -10
  172. package/src/http/db-query-bounded.ts +3 -0
  173. package/src/http/db-query-shared.ts +107 -15
  174. package/src/http/db-query.ts +10 -2
  175. package/src/http/index.ts +23 -6
  176. package/src/http/mcp.ts +5 -0
  177. package/src/http/onboarding.ts +2 -0
  178. package/src/http/script-runs.ts +9 -1
  179. package/src/http/scripts.ts +15 -0
  180. package/src/http/workflows.ts +3 -2
  181. package/src/oauth/mcp-wrapper.ts +1 -1
  182. package/src/providers/acp-adapter.ts +25 -11
  183. package/src/providers/acp-target-catalog.ts +35 -1
  184. package/src/providers/acp-targets.ts +78 -7
  185. package/src/providers/amp-adapter.ts +1 -1
  186. package/src/providers/claude-adapter.ts +26 -0
  187. package/src/providers/codex-adapter.ts +30 -3
  188. package/src/providers/codex-oauth/auth-json.ts +21 -4
  189. package/src/providers/codex-oauth/types.ts +2 -0
  190. package/src/providers/cursor-adapter.ts +1 -1
  191. package/src/providers/dsh-adapter.ts +10 -1
  192. package/src/providers/grok-adapter.ts +18 -2
  193. package/src/providers/opencode-adapter.ts +21 -5
  194. package/src/providers/pi-mono-extension.ts +56 -25
  195. package/src/providers/pricing-sources.md +2 -0
  196. package/src/script-workflows/supervisor.ts +11 -2
  197. package/src/scripts-runtime/eval-harness.ts +2 -12
  198. package/src/scripts-runtime/executors/quickjs-bundle.ts +152 -0
  199. package/src/scripts-runtime/executors/quickjs-prelude.ts +285 -0
  200. package/src/scripts-runtime/executors/quickjs-runner.ts +580 -0
  201. package/src/scripts-runtime/executors/quickjs-worker.ts +81 -0
  202. package/src/scripts-runtime/executors/quickjs.ts +196 -0
  203. package/src/scripts-runtime/executors/registry.ts +2 -0
  204. package/src/scripts-runtime/executors/sourcemap.ts +79 -0
  205. package/src/scripts-runtime/script-error-hints.ts +14 -0
  206. package/src/server.ts +66 -4
  207. package/src/tests/acp-adapter.test.ts +277 -12
  208. package/src/tests/boot-scrub-sweep.test.ts +390 -0
  209. package/src/tests/check-text-columns.test.ts +145 -0
  210. package/src/tests/ci-unit-test-report.test.ts +73 -0
  211. package/src/tests/claude-default-route.test.ts +75 -0
  212. package/src/tests/claude-hook-output.test.ts +233 -0
  213. package/src/tests/claude-sdk-process.fixture.ts +13 -2
  214. package/src/tests/codex-adapter-pool-auth-revalidate.test.ts +4 -2
  215. package/src/tests/codex-adapter.test.ts +166 -26
  216. package/src/tests/codex-oauth-auth-timestamps.test.ts +76 -0
  217. package/src/tests/codex-oauth-device.test.ts +23 -37
  218. package/src/tests/codex-oauth.test.ts +4 -1
  219. package/src/tests/context-window.test.ts +2 -2
  220. package/src/tests/credential-check.test.ts +51 -1
  221. package/src/tests/db-query-denylist.test.ts +202 -0
  222. package/src/tests/db-task-read-contract.test.ts +1 -0
  223. package/src/tests/db-task-write-contract.test.ts +1 -0
  224. package/src/tests/dsh-adapter.test.ts +23 -1
  225. package/src/tests/enabled-tools.test.ts +269 -0
  226. package/src/tests/entrypoint-acp-target-binary.test.ts +31 -1
  227. package/src/tests/entrypoint-codex-oauth-seed.test.ts +12 -0
  228. package/src/tests/events-scrub.test.ts +88 -0
  229. package/src/tests/fixtures/secret-corpus.ts +320 -0
  230. package/src/tests/grok-adapter.test.ts +13 -0
  231. package/src/tests/haiku-5-5-pricing.test.ts +38 -0
  232. package/src/tests/heartbeat-checklist.test.ts +158 -1
  233. package/src/tests/onboarding.test.ts +44 -0
  234. package/src/tests/opencode-adapter.test.ts +66 -3
  235. package/src/tests/opencode-plugin.test.ts +37 -0
  236. package/src/tests/openrouter-attribution-call-sites.test.ts +204 -0
  237. package/src/tests/openrouter-base-url.test.ts +30 -39
  238. package/src/tests/pi-mono-extension.test.ts +161 -2
  239. package/src/tests/pricing-refresh.test.ts +70 -1
  240. package/src/tests/reasoning-effort.test.ts +3 -1
  241. package/src/tests/script-connections.test.ts +5 -0
  242. package/src/tests/script-executor-conformance.test.ts +3 -0
  243. package/src/tests/script-executor-quickjs.test.ts +442 -0
  244. package/src/tests/script-executor-registry.test.ts +6 -1
  245. package/src/tests/script-runs-http.test.ts +88 -1
  246. package/src/tests/script-runs-scrub.test.ts +275 -0
  247. package/src/tests/scripts-http.test.ts +82 -1
  248. package/src/tests/scrubbed-text-12e.test.ts +289 -0
  249. package/src/tests/sealed-key-guard.test.ts +166 -0
  250. package/src/tests/secret-canary-sweep.test.ts +958 -0
  251. package/src/tests/secret-registry.test.ts +355 -0
  252. package/src/tests/secret-rules.test.ts +230 -0
  253. package/src/tests/secret-scrubber.test.ts +3 -2
  254. package/src/tests/telemetry-trigger.test.ts +12 -1
  255. package/src/tests/workflow-llm.test.ts +14 -0
  256. package/src/tests/workflow-replay.test.ts +518 -0
  257. package/src/tests/workflow-scrub.test.ts +242 -0
  258. package/src/tests/workflow-system-one-decision-providers.test.ts +33 -0
  259. package/src/tools/db-query.ts +1 -1
  260. package/src/tools/inject-learning.ts +1 -1
  261. package/src/tools/request-human-input.ts +7 -2
  262. package/src/tools/workflows/get-workflow-run.ts +3 -2
  263. package/src/types.ts +1 -1
  264. package/src/utils/enabled-tools.ts +27 -0
  265. package/src/utils/internal-ai/complete-structured.ts +11 -3
  266. package/src/utils/openrouter-base-url.ts +23 -0
  267. package/src/utils/secret-rules.generated.ts +2055 -0
  268. package/src/utils/secret-scrubber.ts +363 -29
  269. package/src/workflows/engine.ts +39 -4
  270. package/src/workflows/executors/raw-llm.ts +1 -0
  271. package/src/workflows/executors/system-one-decision.ts +2 -0
  272. package/src/workflows/executors/validate.ts +1 -0
  273. package/src/workflows/executors/workflow-llm.ts +9 -2
  274. package/src/workflows/recovery.ts +10 -1
  275. package/src/workflows/resume.ts +62 -3
  276. package/src/workflows/retry-poller.ts +3 -0
  277. package/templates/skills/agent-browser/SKILL.md +2 -0
  278. package/templates/skills/agent-browser/content.md +2 -0
  279. package/templates/skills/code-quality/content.md +1 -0
  280. package/templates/skills/heartbeat-runbook/content.md +1 -1
  281. package/templates/skills/work-on-task/SKILL.md +4 -0
  282. package/templates/skills/work-on-task/content.md +4 -0
  283. package/templates/skills/workflow-iterate/content.md +9 -0
  284. package/dist/acp-adapter-w6zws6me.js +0 -23
  285. package/dist/boot-scrub-logs-246yn076.js +0 -99
  286. package/dist/cli-3a4m1aws.js +0 -572
  287. package/dist/cli-3dpj7atn.js +0 -11
  288. package/dist/cli-a87b04k8.js +0 -951
  289. package/dist/cli-cvk6yzw5.js +0 -40
  290. package/dist/cli-gvcgmx69.js +0 -183
  291. package/dist/cli-h1spv8v4.js +0 -427
  292. package/dist/cli-jqt9hrnz.js +0 -168
  293. package/dist/cli-yhmwmv0g.js +0 -9281
  294. package/dist/grok-adapter-yt9pab3k.js +0 -29
  295. package/src/be/boot-scrub-logs.ts +0 -132
  296. package/dist/{codex-hook-d2rkvf39.js → codex-hook-15dgc4cb.js} +1 -1
@@ -15,12 +15,12 @@ import {
15
15
  require_proper_lockfile,
16
16
  resolveConfigValueOrThrow,
17
17
  resolveHeadersOrThrow
18
- } from "./cli-krqm5f11.js";
18
+ } from "./cli-xezn9nkh.js";
19
19
  import {
20
20
  APP_NAME,
21
21
  VERSION,
22
22
  getAgentDir
23
- } from "./cli-cwxhbf43.js";
23
+ } from "./cli-5t5my0h8.js";
24
24
  import {
25
25
  oauthErrorHtml,
26
26
  oauthSuccessHtml
@@ -328,19 +328,20 @@ function parseWwwAuthenticate(header) {
328
328
  errorDescription: field(header, "error_description")
329
329
  };
330
330
  }
331
- async function fetchMetadata(url, fetch, protocolVersion) {
331
+ async function fetchMetadata(url, fetch, protocolVersion, signal) {
332
332
  return fetch(url, {
333
- headers: { Accept: "application/json", "MCP-Protocol-Version": protocolVersion }
333
+ headers: { Accept: "application/json", "MCP-Protocol-Version": protocolVersion },
334
+ signal
334
335
  });
335
336
  }
336
337
  async function discoverProtectedResourceMetadata(serverUrl, options = {}) {
337
338
  const server = new URL(serverUrl);
338
339
  const fetch = options.fetch ?? globalThis.fetch;
339
340
  const version = options.protocolVersion ?? LATEST_PROTOCOL_VERSION;
340
- let response = await fetchMetadata(options.resourceMetadataUrl ? new URL(options.resourceMetadataUrl) : new URL(`/.well-known/oauth-protected-resource${pathSuffix(server.pathname)}`, server.origin), fetch, version);
341
+ let response = await fetchMetadata(options.resourceMetadataUrl ? new URL(options.resourceMetadataUrl) : new URL(`/.well-known/oauth-protected-resource${pathSuffix(server.pathname)}`, server.origin), fetch, version, options.signal);
341
342
  if (!options.resourceMetadataUrl && server.pathname !== "/" && isDiscoveryMiss(response.status)) {
342
343
  discard(response);
343
- response = await fetchMetadata(new URL("/.well-known/oauth-protected-resource", server.origin), fetch, version);
344
+ response = await fetchMetadata(new URL("/.well-known/oauth-protected-resource", server.origin), fetch, version, options.signal);
344
345
  }
345
346
  if (!response.ok) {
346
347
  discard(response);
@@ -362,7 +363,7 @@ function buildAuthorizationServerDiscoveryUrls(authorizationServerUrl) {
362
363
  async function discoverAuthorizationServerMetadata(authorizationServerUrl, options = {}) {
363
364
  const fetch = options.fetch ?? globalThis.fetch;
364
365
  for (const { url } of buildAuthorizationServerDiscoveryUrls(authorizationServerUrl)) {
365
- const response = await fetchMetadata(url, fetch, options.protocolVersion ?? LATEST_PROTOCOL_VERSION);
366
+ const response = await fetchMetadata(url, fetch, options.protocolVersion ?? LATEST_PROTOCOL_VERSION, options.signal);
366
367
  if (!response.ok) {
367
368
  discard(response);
368
369
  if (isDiscoveryMiss(response.status))
@@ -385,7 +386,8 @@ async function discoverOAuthServerInfo(serverUrl, options = {}) {
385
386
  try {
386
387
  resourceMetadata = await discoverProtectedResourceMetadata(serverUrl, {
387
388
  resourceMetadataUrl: options.resourceMetadataUrl,
388
- fetch: options.fetch
389
+ fetch: options.fetch,
390
+ signal: options.signal
389
391
  });
390
392
  } catch (error) {
391
393
  if (error instanceof TypeError)
@@ -393,7 +395,7 @@ async function discoverOAuthServerInfo(serverUrl, options = {}) {
393
395
  }
394
396
  if (options.authorizationServerMetadataUrl) {
395
397
  const url = options.authorizationServerMetadataUrl;
396
- const response = await fetchMetadata(url, options.fetch ?? globalThis.fetch, LATEST_PROTOCOL_VERSION);
398
+ const response = await fetchMetadata(url, options.fetch ?? globalThis.fetch, LATEST_PROTOCOL_VERSION, options.signal);
397
399
  if (!response.ok) {
398
400
  discard(response);
399
401
  throw new Error(`HTTP ${response.status} loading authorization server metadata from ${url}`);
@@ -406,7 +408,8 @@ async function discoverOAuthServerInfo(serverUrl, options = {}) {
406
408
  authorizationServerUrl,
407
409
  authorizationServerMetadata: await discoverAuthorizationServerMetadata(authorizationServerUrl, {
408
410
  fetch: options.fetch,
409
- skipIssuerValidation: options.skipIssuerValidation
411
+ skipIssuerValidation: options.skipIssuerValidation,
412
+ signal: options.signal
410
413
  }),
411
414
  resourceMetadata
412
415
  };
@@ -517,7 +520,12 @@ async function tokenRequest(authorizationServerUrl, options, params) {
517
520
  } else {
518
521
  applyClientAuthentication(selectClientAuthMethod(options.clientInformation, options.metadata?.token_endpoint_auth_methods_supported ?? []), options.clientInformation, headers, params);
519
522
  }
520
- const response = await (options.fetch ?? globalThis.fetch)(url, { method: "POST", headers, body: params });
523
+ const response = await (options.fetch ?? globalThis.fetch)(url, {
524
+ method: "POST",
525
+ headers,
526
+ body: params,
527
+ signal: options.signal
528
+ });
521
529
  const text = await response.text();
522
530
  let value;
523
531
  try {
@@ -541,7 +549,8 @@ async function registerClient(authorizationServerUrl, options) {
541
549
  ...options.clientMetadata,
542
550
  application_type: options.clientMetadata.application_type ?? applicationType(options.clientMetadata.redirect_uris),
543
551
  ...options.scope ? { scope: options.scope } : {}
544
- })
552
+ }),
553
+ signal: options.signal
545
554
  });
546
555
  if (!response.ok)
547
556
  throw new OAuthRegistrationError(response.status, await response.text());
@@ -575,14 +584,16 @@ async function runFlow(provider, options) {
575
584
  authorizationServerUrl: cached.authorizationServerUrl,
576
585
  authorizationServerMetadata: cached.authorizationServerMetadata ?? await discoverAuthorizationServerMetadata(cached.authorizationServerUrl, {
577
586
  fetch: options.fetch,
578
- skipIssuerValidation: options.skipIssuerValidation
587
+ skipIssuerValidation: options.skipIssuerValidation,
588
+ signal: options.signal
579
589
  }),
580
590
  resourceMetadata: cached.resourceMetadata
581
591
  } : await discoverOAuthServerInfo(options.serverUrl, {
582
592
  resourceMetadataUrl: options.resourceMetadataUrl,
583
593
  authorizationServerMetadataUrl: metadataUrl,
584
594
  fetch: options.fetch,
585
- skipIssuerValidation: options.skipIssuerValidation
595
+ skipIssuerValidation: options.skipIssuerValidation,
596
+ signal: options.signal
586
597
  });
587
598
  if (!metadataUrl) {
588
599
  await provider.saveDiscoveryState?.({
@@ -610,7 +621,8 @@ async function runFlow(provider, options) {
610
621
  metadata,
611
622
  clientMetadata: provider.clientMetadata,
612
623
  scope,
613
- fetch: options.fetch
624
+ fetch: options.fetch,
625
+ signal: options.signal
614
626
  });
615
627
  await provider.saveClientInformation(client);
616
628
  }
@@ -620,7 +632,8 @@ async function runFlow(provider, options) {
620
632
  clientInformation: client,
621
633
  resource,
622
634
  addClientAuthentication: provider.addClientAuthentication,
623
- fetch: options.fetch
635
+ fetch: options.fetch,
636
+ signal: options.signal
624
637
  };
625
638
  if (options.authorizationCode) {
626
639
  const iss = options.iss;
@@ -647,7 +660,7 @@ async function runFlow(provider, options) {
647
660
  await provider.saveTokens(withScope(tokens, existing.scope));
648
661
  return "AUTHORIZED";
649
662
  } catch (error) {
650
- if (error instanceof OAuthInsecureEndpointError)
663
+ if (options.signal?.aborted || error instanceof OAuthInsecureEndpointError)
651
664
  throw error;
652
665
  if (error instanceof OAuthError && error.code !== "server_error")
653
666
  throw error;
@@ -806,7 +819,7 @@ var CALLBACK_PATH = "/callback";
806
819
  var CLIENT_METADATA_BASE_URL = "https://pi.dev/oauth";
807
820
  var FALLBACK_REDIRECT_URL = `http://${CALLBACK_HOST}${CALLBACK_PATH}`;
808
821
  var REFRESH_SKEW_MS = 30000;
809
- var REFRESH_REQUEST_TIMEOUT_MS = 15000;
822
+ var OAUTH_REQUEST_TIMEOUT_MS = 15000;
810
823
  var REFRESH_LOCK_STALE_MS = 20000;
811
824
  var REFRESH_LOCK_WAIT_MS = 25000;
812
825
  var REFRESH_LOCK_RETRY_MS = 100;
@@ -920,6 +933,12 @@ class McpOAuthCredentialStore {
920
933
  });
921
934
  }
922
935
  }
936
+ function timedFetch(fetch = globalThis.fetch) {
937
+ return (input, init) => {
938
+ const timeout = AbortSignal.timeout(OAUTH_REQUEST_TIMEOUT_MS);
939
+ return fetch(input, { ...init, signal: init?.signal ? AbortSignal.any([init.signal, timeout]) : timeout });
940
+ };
941
+ }
923
942
  function registeredRedirectUrls(client) {
924
943
  return client && "redirect_uris" in client ? client.redirect_uris : [];
925
944
  }
@@ -970,7 +989,7 @@ function createMcpAuthProvider(options) {
970
989
  resourceMetadataUrl: challenge?.resourceMetadataUrl,
971
990
  authorizationServerMetadataUrl: settings.authServerMetadataUrl,
972
991
  scope: challenge?.scope,
973
- fetch: (input, init) => fetch(input, { ...init, signal: AbortSignal.timeout(REFRESH_REQUEST_TIMEOUT_MS) })
992
+ fetch: timedFetch(fetch)
974
993
  });
975
994
  if (result === "REDIRECT")
976
995
  throw new McpOAuthAuthorizationRequiredError;
@@ -1035,10 +1054,11 @@ function responseFromRedirectUrl(input, state, redirectUrl) {
1035
1054
  throw new Error("The redirect URL does not contain an authorization code");
1036
1055
  return { code, iss: url.searchParams.get("iss") ?? undefined };
1037
1056
  }
1038
- async function waitForAuthorizationResponse(callback, state, redirectUrl, prompt) {
1057
+ async function waitForAuthorizationResponse(callback, state, redirectUrl, prompt, signal) {
1039
1058
  const controller = new AbortController;
1059
+ const promptSignal = signal ? AbortSignal.any([controller.signal, signal]) : controller.signal;
1040
1060
  const fromBrowser = callback.waitForCallback(state, redirectUrl.pathname);
1041
- const fromUser = prompt.promptForRedirectUrl(controller.signal).then((input) => {
1061
+ const fromUser = prompt.promptForRedirectUrl(promptSignal).then((input) => {
1042
1062
  if (!input?.trim())
1043
1063
  throw new McpSignInCancelledError;
1044
1064
  return responseFromRedirectUrl(input, state, redirectUrl);
@@ -1072,7 +1092,9 @@ async function listenForCallback(settings, extraPaths, port, required) {
1072
1092
  }
1073
1093
  }
1074
1094
  async function signInMcpServer(options) {
1075
- const { serverUrl, store, settings } = options;
1095
+ const { serverUrl, store, settings, signal } = options;
1096
+ if (signal?.aborted)
1097
+ throw new McpSignInCancelledError;
1076
1098
  const stored = await store.load();
1077
1099
  const stepUp = options.challenge?.error === "insufficient_scope";
1078
1100
  const callbackOptions = callbackSettings(settings);
@@ -1099,6 +1121,8 @@ async function signInMcpServer(options) {
1099
1121
  });
1100
1122
  const flow = {
1101
1123
  serverUrl,
1124
+ fetch: timedFetch(),
1125
+ signal,
1102
1126
  resourceMetadataUrl: options.challenge?.resourceMetadataUrl,
1103
1127
  authorizationServerMetadataUrl: settings.authServerMetadataUrl,
1104
1128
  scope: mergeScopes(settings.scope, stepUp ? stepUpScope(stored?.tokens?.scope, options.challenge?.scope) : options.challenge?.scope)
@@ -1111,8 +1135,12 @@ async function signInMcpServer(options) {
1111
1135
  const state = await provider.state();
1112
1136
  const authorizationRedirectUrl = new URL(authorizationUrl.searchParams.get("redirect_uri") ?? redirectUrl);
1113
1137
  options.prompt.showAuthorizationUrl(authorizationUrl);
1114
- const { code, iss } = await waitForAuthorizationResponse(callback, state, authorizationRedirectUrl, options.prompt);
1138
+ const { code, iss } = await waitForAuthorizationResponse(callback, state, authorizationRedirectUrl, options.prompt, signal);
1115
1139
  await authorizeMcp(provider, { ...flow, authorizationCode: code, iss });
1140
+ } catch (error) {
1141
+ if (signal?.aborted)
1142
+ throw new McpSignInCancelledError;
1143
+ throw error;
1116
1144
  } finally {
1117
1145
  await callback.close();
1118
1146
  }
@@ -4,13 +4,13 @@ import {
4
4
  getAllUsers,
5
5
  getResolvedConfig,
6
6
  getSwarmConfigs,
7
- init_db,
7
+ init_db1 as init_db,
8
8
  upsertSwarmConfig
9
- } from "./cli-qdv8kgz7.js";
9
+ } from "./cli-mkdsy1nq.js";
10
10
  import {
11
11
  init_secret_scrubber,
12
12
  scrubSecrets
13
- } from "./cli-h1spv8v4.js";
13
+ } from "./cli-wt7ccy4r.js";
14
14
  import {
15
15
  __require
16
16
  } from "./cli-bc05qbss.js";
@@ -4,10 +4,6 @@ import {
4
4
  import {
5
5
  require_semver
6
6
  } from "./cli-3er6gcsn.js";
7
- import {
8
- init_task_attachment_links,
9
- taskAttachmentDisplayUrl
10
- } from "./cli-cvk6yzw5.js";
11
7
  import {
12
8
  require_jws,
13
9
  require_p_retry
@@ -55,7 +51,7 @@ import {
55
51
  getTaskAttachments,
56
52
  getTaskById,
57
53
  init_context_key,
58
- init_db,
54
+ init_db1 as init_db,
59
55
  init_reaction_shortcode,
60
56
  isPendingSlackMessage,
61
57
  isSettledSlackMessage,
@@ -73,11 +69,15 @@ import {
73
69
  setSlackMessageTracking,
74
70
  slackContextKey,
75
71
  updateSlackMessageRecord
76
- } from "./cli-qdv8kgz7.js";
72
+ } from "./cli-mkdsy1nq.js";
77
73
  import {
78
74
  init_types,
79
75
  isTerminalTaskStatus
80
- } from "./cli-9s3h836g.js";
76
+ } from "./cli-xvdgasgy.js";
77
+ import {
78
+ init_task_attachment_links,
79
+ taskAttachmentDisplayUrl
80
+ } from "./cli-mxvnnv5q.js";
81
81
  import {
82
82
  getSlackConfiguration,
83
83
  init_config
@@ -104,7 +104,7 @@ import {
104
104
  init_secret_scrubber,
105
105
  scrubObject,
106
106
  scrubSecrets
107
- } from "./cli-h1spv8v4.js";
107
+ } from "./cli-wt7ccy4r.js";
108
108
  import {
109
109
  __commonJS,
110
110
  __require,
@@ -52915,7 +52915,7 @@ async function initOtel(serviceRole = process.env.AGENT_ROLE || "api") {
52915
52915
  return;
52916
52916
  initialized = true;
52917
52917
  try {
52918
- const impl = await import("./otel-impl-x8zp4y5a.js");
52918
+ const impl = await import("./otel-impl-ghh4dyf8.js");
52919
52919
  await impl.boot(serviceRole, {
52920
52920
  exportConsoleLogs: serviceRole === "api" && isApiLogExportEnabled()
52921
52921
  });
@@ -54410,15 +54410,15 @@ async function initSlackApp() {
54410
54410
  ...clientOptions ? { clientOptions } : {}
54411
54411
  });
54412
54412
  initialized2 = true;
54413
- const { registerMessageHandler } = await import("./handlers-g2wnr4t9.js");
54414
- const { registerCommandHandler } = await import("./commands-2ybfcxkj.js");
54415
- const { registerActionHandlers } = await import("./actions-jna0b3wm.js");
54416
- const { registerWorkObjectHandlers } = await import("./work-objects-ctg7t70w.js");
54413
+ const { registerMessageHandler } = await import("./handlers-2qtkpncr.js");
54414
+ const { registerCommandHandler } = await import("./commands-h6zaaxym.js");
54415
+ const { registerActionHandlers } = await import("./actions-fq2zrwtf.js");
54416
+ const { registerWorkObjectHandlers } = await import("./work-objects-jcdbg8rr.js");
54417
54417
  registerMessageHandler(app);
54418
54418
  registerCommandHandler(app);
54419
54419
  registerActionHandlers(app);
54420
54420
  registerWorkObjectHandlers(app);
54421
- const { createAssistant } = await import("./assistant-yzd51j33.js");
54421
+ const { createAssistant } = await import("./assistant-0aq8gjvj.js");
54422
54422
  app.assistant(createAssistant());
54423
54423
  return app;
54424
54424
  }
@@ -54427,7 +54427,7 @@ async function startSlackApp() {
54427
54427
  await initSlackApp();
54428
54428
  }
54429
54429
  if (app) {
54430
- const { isSlackRenderV2Enabled: isSlackRenderV2Enabled2 } = await import("./render-v2-tch4nefj.js");
54430
+ const { isSlackRenderV2Enabled: isSlackRenderV2Enabled2 } = await import("./render-v2-k50j33qd.js");
54431
54431
  if (isSlackRenderV2Enabled2())
54432
54432
  await ensureSlackRenderV2Activation();
54433
54433
  await app.start();
@@ -56191,4 +56191,4 @@ function _resetSlackRenderV2ForTests() {
56191
56191
  }
56192
56192
  var _noteOutcomeDeliveryFailureForTests = (task, tree, error) => noteOutcomeDeliveryFailure(task, tree, error, undefined);
56193
56193
 
56194
- export { require_dist7 as require_dist, getSlackConnectionState, isPollTracingEnabled, initOtel, withSpan, startSpan, withSpanContext, withRemoteContext, injectTraceContext, recordSessionCost, recordDbRetentionSweep, recordDbRetentionStatement, slackTaskOutput, ackSlackMessage, getTaskLink, getTaskUrl, markdownToSlack, buildCaptionBlock, buildCancelledBlocks, buildBufferFlushBlocks, buildTreeBlocks, taskCitationIssues, stripInvalidTaskCitations, taskCitationSourceGroups, renderTaskCitations, taskCitationWarnings, MAX_TASK_CITATIONS, CitationInputSchema, TaskCitationSchema, upsertTaskCitations, getTaskCitations, getTaskCitationsForTasks, hasTaskCitationCheckRefusal, initialize, ensure2 as ensure, getAgentDisplayName, getAgentEmoji, markSlackSessionProcessing, isSlackRenderV2Enabled, isSlackDelegationEnabled, callSlackWithRetry, formatV2Duration, renderThreadTree, ensureSlackThreadTree, withStatusLead, childOutcomeContent, streamOutcomeCard, slackErrorCode2 as slackErrorCode, isTerminalSlackError, describeSlackError, slackErrorSummary, refreshResolvedDeferralCards, processSlackRenderV2, _resetSlackRenderV2ForTests, _noteOutcomeDeliveryFailureForTests, registerTreeMessage, getSlackApp, initSlackApp, startSlackApp, stopSlackApp };
56194
+ export { require_content_type, require_dist7 as require_dist, getSlackConnectionState, isPollTracingEnabled, initOtel, withSpan, startSpan, withSpanContext, withRemoteContext, injectTraceContext, recordSessionCost, recordDbRetentionSweep, recordDbRetentionStatement, slackTaskOutput, ackSlackMessage, getTaskLink, getTaskUrl, markdownToSlack, buildCaptionBlock, buildCancelledBlocks, buildBufferFlushBlocks, buildTreeBlocks, taskCitationIssues, stripInvalidTaskCitations, taskCitationSourceGroups, renderTaskCitations, taskCitationWarnings, MAX_TASK_CITATIONS, CitationInputSchema, TaskCitationSchema, upsertTaskCitations, getTaskCitations, getTaskCitationsForTasks, hasTaskCitationCheckRefusal, initialize, ensure2 as ensure, getAgentDisplayName, getAgentEmoji, markSlackSessionProcessing, isSlackRenderV2Enabled, isSlackDelegationEnabled, callSlackWithRetry, formatV2Duration, renderThreadTree, ensureSlackThreadTree, withStatusLead, childOutcomeContent, streamOutcomeCard, slackErrorCode2 as slackErrorCode, isTerminalSlackError, describeSlackError, slackErrorSummary, refreshResolvedDeferralCards, processSlackRenderV2, _resetSlackRenderV2ForTests, _noteOutcomeDeliveryFailureForTests, registerTreeMessage, getSlackApp, initSlackApp, startSlackApp, stopSlackApp };
@@ -1,17 +1,21 @@
1
1
  import {
2
- clampContextPercent,
3
- getContextWindowSize
4
- } from "./cli-32bca7nr.js";
2
+ applyOpenRouterBaseUrlOverride
3
+ } from "./cli-jvmtxqtc.js";
4
+ import {
5
+ ACP_TARGET_IDS,
6
+ getAcpTargetCatalogEntry,
7
+ isAcpTarget
8
+ } from "./cli-zp67qg5x.js";
5
9
  import {
6
10
  fetchInstalledMcpServers
7
11
  } from "./cli-tng3131n.js";
8
12
  import {
9
- getAcpTargetCatalogEntry,
10
- isAcpTarget
11
- } from "./cli-fw6vdcq5.js";
13
+ clampContextPercent,
14
+ getContextWindowSize
15
+ } from "./cli-7avy4v8w.js";
12
16
  import {
13
17
  applyReasoningEffort
14
- } from "./cli-ttbsse3f.js";
18
+ } from "./cli-tmhsxhb8.js";
15
19
  import {
16
20
  detachedProcessGroup,
17
21
  registerProcessGroup,
@@ -20,7 +24,7 @@ import {
20
24
  import {
21
25
  init_src,
22
26
  normalizeGrokModel
23
- } from "./cli-zsh093hk.js";
27
+ } from "./cli-014vns2y.js";
24
28
  import {
25
29
  array,
26
30
  boolean,
@@ -40,11 +44,11 @@ import {
40
44
  import {
41
45
  init_package,
42
46
  package_default
43
- } from "./cli-1kzfvd1z.js";
47
+ } from "./cli-ymmc1zxg.js";
44
48
  import {
45
49
  init_secret_scrubber,
46
50
  scrubSecrets
47
- } from "./cli-h1spv8v4.js";
51
+ } from "./cli-wt7ccy4r.js";
48
52
 
49
53
  // node_modules/@agentclientprotocol/sdk/dist/schema/index.js
50
54
  var AGENT_METHODS = {
@@ -4728,7 +4732,7 @@ function translateAcpSessionNotification(notification) {
4728
4732
 
4729
4733
  // src/providers/acp-targets.ts
4730
4734
  init_src();
4731
- import { mkdtemp } from "node:fs/promises";
4735
+ import { mkdir, mkdtemp, rm } from "node:fs/promises";
4732
4736
  import { tmpdir } from "node:os";
4733
4737
  import { join } from "node:path";
4734
4738
  class AcpTargetResolutionError extends Error {
@@ -4799,9 +4803,8 @@ function configuredOptions(config) {
4799
4803
  options.model = config.model.trim();
4800
4804
  return options;
4801
4805
  }
4802
- function withModelInJsonEnv(env, key, model) {
4803
- if (!model.trim())
4804
- return;
4806
+ function withOpencodeConfig(env, model) {
4807
+ const key = "OPENCODE_CONFIG_CONTENT";
4805
4808
  let value = {};
4806
4809
  const existing = env[key];
4807
4810
  if (existing) {
@@ -4814,7 +4817,10 @@ function withModelInJsonEnv(env, key, model) {
4814
4817
  console.warn(`\x1B[33m[acp]\x1B[0m Replacing invalid ${key} JSON for model fallback`);
4815
4818
  }
4816
4819
  }
4817
- env[key] = JSON.stringify({ ...value, model: model.trim() });
4820
+ if (model.trim())
4821
+ value.model = model.trim();
4822
+ applyOpenRouterBaseUrlOverride(value, env);
4823
+ env[key] = JSON.stringify(value);
4818
4824
  }
4819
4825
  function parseCommand(command, args) {
4820
4826
  const trimmed = command.trim();
@@ -4869,7 +4875,8 @@ var opencodeTargetProfile = {
4869
4875
  const env = baseTargetEnv(config);
4870
4876
  const entry = getAcpTargetCatalogEntry("opencode");
4871
4877
  copyEnvKeys(config, env, entry.envKeys);
4872
- withModelInJsonEnv(env, "OPENCODE_CONFIG_CONTENT", config.model);
4878
+ copyEnvKeys(config, env, ["OPENROUTER_APP_ATTRIBUTION"]);
4879
+ withOpencodeConfig(env, config.model);
4873
4880
  return env;
4874
4881
  },
4875
4882
  configuredOptions,
@@ -4904,6 +4911,46 @@ var geminiTargetProfile = {
4904
4911
  geminiSystemPromptPaths.set(config, path);
4905
4912
  }
4906
4913
  };
4914
+ function copilotInstructionsDir(config) {
4915
+ const key = new Bun.CryptoHasher("sha256").update(`${config.agentId}:${config.taskId}:${config.cwd}`).digest("hex").slice(0, 16);
4916
+ return join(tmpdir(), "agent-swarm-copilot-instructions", key);
4917
+ }
4918
+ var COPILOT_INSTRUCTIONS_FILE = join(".github", "instructions", "agent-swarm.instructions.md");
4919
+ var copilotTargetProfile = {
4920
+ target: "copilot",
4921
+ command() {
4922
+ const entry = getAcpTargetCatalogEntry("copilot");
4923
+ return [entry.command, ...entry.args ?? []];
4924
+ },
4925
+ env(config) {
4926
+ const env = baseTargetEnv(config);
4927
+ const entry = getAcpTargetCatalogEntry("copilot");
4928
+ copyEnvKeys(config, env, entry.envKeys);
4929
+ if (config.model.trim())
4930
+ env.COPILOT_MODEL = config.model.trim();
4931
+ env.COPILOT_AUTO_UPDATE = "false";
4932
+ const operatorDirs = readEnv(config, "COPILOT_CUSTOM_INSTRUCTIONS_DIRS")?.trim();
4933
+ env.COPILOT_CUSTOM_INSTRUCTIONS_DIRS = [copilotInstructionsDir(config), operatorDirs].filter(Boolean).join(",");
4934
+ return env;
4935
+ },
4936
+ configuredOptions,
4937
+ async writeSystemPromptArtifact(config) {
4938
+ const dir = copilotInstructionsDir(config);
4939
+ await rm(dir, { recursive: true, force: true });
4940
+ if (!config.systemPrompt)
4941
+ return;
4942
+ await mkdir(join(dir, ".github", "instructions"), { recursive: true });
4943
+ await Bun.write(join(dir, COPILOT_INSTRUCTIONS_FILE), `---
4944
+ applyTo: "**"
4945
+ ---
4946
+
4947
+ ${config.systemPrompt}
4948
+ `);
4949
+ },
4950
+ async cleanupSystemPromptArtifact(config) {
4951
+ await rm(copilotInstructionsDir(config), { recursive: true, force: true });
4952
+ }
4953
+ };
4907
4954
  var GROK_ISOLATION_ENV = {
4908
4955
  GROK_DISABLE_AUTOUPDATER: "1",
4909
4956
  GROK_TELEMETRY_ENABLED: "0",
@@ -5067,13 +5114,15 @@ var grokTargetProfile = {
5067
5114
  function resolveAcpTarget(config) {
5068
5115
  const target = readEnv(config, "ACP_TARGET") ?? "custom";
5069
5116
  if (!isAcpTarget(target)) {
5070
- throw new AcpTargetResolutionError(`Unsupported ACP target "${target}". Supported targets: opencode, gemini, custom.`);
5117
+ throw new AcpTargetResolutionError(`Unsupported ACP target "${target}". Supported targets: ${ACP_TARGET_IDS.join(", ")}.`);
5071
5118
  }
5072
5119
  switch (target) {
5073
5120
  case "opencode":
5074
5121
  return opencodeTargetProfile;
5075
5122
  case "gemini":
5076
5123
  return geminiTargetProfile;
5124
+ case "copilot":
5125
+ return copilotTargetProfile;
5077
5126
  case "custom":
5078
5127
  return customTargetProfile;
5079
5128
  }
@@ -5402,15 +5451,27 @@ class ACPAdapter {
5402
5451
  async createSession(config) {
5403
5452
  const target = this.options.target ?? resolveAcpTarget(config);
5404
5453
  await target.writeSystemPromptArtifact(config);
5405
- const command = target.command(config);
5406
- const proc = registerProcessGroup(Bun.spawn(command, {
5407
- cwd: config.cwd,
5408
- detached: detachedProcessGroup,
5409
- env: target.env(config),
5410
- stdin: "pipe",
5411
- stdout: "pipe",
5412
- stderr: "pipe"
5413
- }));
5454
+ const cleanupArtifact = async () => {
5455
+ try {
5456
+ await target.cleanupSystemPromptArtifact?.(config);
5457
+ } catch (err) {
5458
+ console.warn(`\x1B[33m[acp]\x1B[0m System prompt cleanup failed: ${formatError(err)}`);
5459
+ }
5460
+ };
5461
+ let proc;
5462
+ try {
5463
+ proc = registerProcessGroup(Bun.spawn(target.command(config), {
5464
+ cwd: config.cwd,
5465
+ detached: detachedProcessGroup,
5466
+ env: target.env(config),
5467
+ stdin: "pipe",
5468
+ stdout: "pipe",
5469
+ stderr: "pipe"
5470
+ }));
5471
+ } catch (err) {
5472
+ await cleanupArtifact();
5473
+ throw err;
5474
+ }
5414
5475
  let session = null;
5415
5476
  const preSessionEvents = [];
5416
5477
  const client2 = new SwarmAcpClient((event) => {
@@ -5455,12 +5516,14 @@ class ACPAdapter {
5455
5516
  }, ephemeralToken.tokenId);
5456
5517
  for (const event of preSessionEvents)
5457
5518
  session.emitFromAcp(event);
5519
+ session.waitForCompletion().finally(cleanupArtifact);
5458
5520
  return session;
5459
5521
  } catch (err) {
5460
5522
  if (ephemeralToken && !session) {
5461
5523
  revokeAcpSessionToken(config.apiUrl, config.apiKey, ephemeralToken.tokenId);
5462
5524
  }
5463
5525
  await terminateProcessGroup(proc.pid);
5526
+ await cleanupArtifact();
5464
5527
  throw new Error(`ACP target failed during startup: ${describeTargetError(target, scrubSecrets(formatError(err)))}`);
5465
5528
  }
5466
5529
  }