@desplega.ai/agent-swarm 1.172.0 → 1.173.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 (214) hide show
  1. package/dist/{acp-adapter-fpecx1g1.js → acp-adapter-ccm9xrep.js} +8 -8
  2. package/dist/{actions-pw87a1a8.js → actions-sgeyv08k.js} +44 -19
  3. package/dist/{amp-adapter-8jem2bc0.js → amp-adapter-gpxp3kc9.js} +1 -1
  4. package/dist/{anthropic-messages-8ee2f22q.js → anthropic-messages-r6czkjv1.js} +7 -7
  5. package/dist/{app-wmf0m843.js → app-km9qnv2f.js} +6 -4
  6. package/dist/{assistant-emp1e108.js → assistant-5r8tcvvd.js} +44 -22
  7. package/dist/{boot-reembed-4ymn9atn.js → boot-reembed-16rv9843.js} +4 -3
  8. package/dist/{boot-reembed-1de4f4aj.js → boot-reembed-swwzdgd7.js} +4 -3
  9. package/dist/{boot-scrub-sweep-adhk1s8c.js → boot-scrub-sweep-zkr6vkqb.js} +5 -4
  10. package/dist/{boot-seeds-8q637aew.js → boot-seeds-d8sp49t2.js} +7 -6
  11. package/dist/{claude-adapter-t26cv8a4.js → claude-adapter-yzzzh8jp.js} +9 -9
  12. package/dist/{claude-sdk-session-gsfsh662.js → claude-sdk-session-4whxere4.js} +9458 -9164
  13. package/dist/{cli-g4f5pj26.js → cli-0a7mm3zp.js} +92 -10
  14. package/dist/{cli-pj6x9qce.js → cli-0kxf81jj.js} +1 -1
  15. package/dist/{cli-kb4ehzx5.js → cli-1w0vj3gw.js} +4 -4
  16. package/dist/{cli-e0a9sk00.js → cli-3nxdmjrc.js} +1 -1
  17. package/dist/{cli-6jb2rf77.js → cli-42qhyvwx.js} +3 -3
  18. package/dist/{cli-esnpehf5.js → cli-5er5gjbm.js} +4 -4
  19. package/dist/{cli-04emfe2q.js → cli-5wpw4rab.js} +1 -1
  20. package/dist/{cli-aspcaef3.js → cli-6r2f7edk.js} +4 -4
  21. package/dist/{cli-xczpdp9e.js → cli-6thk4jz3.js} +1 -1
  22. package/dist/{cli-j6kpj9az.js → cli-7a93cv8c.js} +1458 -48
  23. package/dist/{cli-k46r9hmk.js → cli-94b48jhk.js} +2 -2
  24. package/dist/{cli-gp1rtyvk.js → cli-9xf7fdtp.js} +2 -2
  25. package/dist/{cli-qsztpfry.js → cli-anzdk0z4.js} +1 -1
  26. package/dist/{cli-cceskcvt.js → cli-b07hr3bt.js} +8 -8
  27. package/dist/{cli-c2pq2rjb.js → cli-bv2etw2y.js} +2 -2
  28. package/dist/{cli-hwwvy36w.js → cli-c3rk1v0x.js} +3 -3
  29. package/dist/{cli-tgpfnm6r.js → cli-fmhj1ehj.js} +53 -13
  30. package/dist/{cli-r8smj8b8.js → cli-jpc4r224.js} +1 -1
  31. package/dist/{cli-4nz8p1p5.js → cli-m89t9jdf.js} +5 -5
  32. package/dist/{cli-bf7485pm.js → cli-na2pxe4f.js} +1 -1
  33. package/dist/{cli-prrt9fa0.js → cli-ne7smj1b.js} +4 -4
  34. package/dist/{cli-cf69s3ew.js → cli-nwrdx840.js} +2 -2
  35. package/dist/cli-p0sg24zp.js +16 -0
  36. package/dist/{cli-gj81e47t.js → cli-phcqp1b9.js} +1 -1
  37. package/dist/{cli-5rv1j9ga.js → cli-qm1448f9.js} +51 -5
  38. package/dist/{cli-8hzfb6xz.js → cli-r0byd61h.js} +7 -7
  39. package/dist/{cli-nyhb1r6x.js → cli-r4fqfpwf.js} +3 -3
  40. package/dist/{cli-1hgat6pa.js → cli-rfs4vddv.js} +5 -5
  41. package/dist/{cli-ztrv9y21.js → cli-rfz2ve55.js} +861 -246
  42. package/dist/{cli-pstq9888.js → cli-s8z6x4b4.js} +22 -21
  43. package/dist/{cli-j1pmc07z.js → cli-saqyage0.js} +92 -16
  44. package/dist/{cli-zxm9p3x4.js → cli-srqq3gc5.js} +1 -1
  45. package/dist/{cli-9xsmdpdt.js → cli-tcc4wd5d.js} +136 -42
  46. package/dist/cli-v3zhnxsb.js +263 -0
  47. package/dist/{cli-388egyf6.js → cli-w1apjecb.js} +1 -1
  48. package/dist/{cli-g6t9texm.js → cli-wrh08zjd.js} +4 -4
  49. package/dist/{cli-8vs9trd4.js → cli-x119kdba.js} +1 -1
  50. package/dist/{cli-nv4zd0b9.js → cli-xc7p7s3g.js} +1 -1
  51. package/dist/cli.js +16 -16
  52. package/dist/{codex-adapter-m4tgdysy.js → codex-adapter-r3dn4fp5.js} +6 -6
  53. package/dist/{codex-session-runner-ymwzm6ea.js → codex-session-runner-fwt793h4.js} +6 -6
  54. package/dist/{commands-n0hshcvs.js → commands-z8fq9qna.js} +14 -4
  55. package/dist/{controllers-connect-y07cqcvy.js → controllers-connect-3mf2btyj.js} +21 -19
  56. package/dist/{db-4w7tmt1g.js → db-qfpq4bt7.js} +4 -3
  57. package/dist/{db-hkqvrdcb.js → db-yyhqqrbf.js} +5 -4
  58. package/dist/{dispatcher-5sd69y14.js → dispatcher-x0x7qfcq.js} +20 -18
  59. package/dist/{dsh-adapter-2h8m4cab.js → dsh-adapter-34etvb5m.js} +1 -1
  60. package/dist/external-channel-h1fjecwe.js +51 -0
  61. package/dist/{grok-adapter-8m9yqzbq.js → grok-adapter-e7mr287e.js} +9 -9
  62. package/dist/{handlers-s20xr10r.js → handlers-znb9n7d4.js} +23 -21
  63. package/dist/{heartbeat-3k31q4g2.js → heartbeat-bm4qkn8d.js} +22 -20
  64. package/dist/{hook-gdn6a2fn.js → hook-254r4mza.js} +7 -7
  65. package/dist/{hook-ygwerrdh.js → hook-xaa3q80s.js} +8 -8
  66. package/dist/{http-jdteeg81.js → http-3dgrgp8y.js} +135 -64
  67. package/dist/{index-6ksewd5y.js → index-2ybk7khy.js} +618 -120
  68. package/dist/{index-tsszt7g9.js → index-bdsqa799.js} +22 -20
  69. package/dist/{index-e0snym4t.js → index-fx3jqq1e.js} +20 -18
  70. package/dist/{index-vm3bm9t7.js → index-g2byveez.js} +20 -18
  71. package/dist/{index-ffqzqgwb.js → index-jd7sejm2.js} +4 -3
  72. package/dist/{keepalive-jekc896t.js → keepalive-6ywhpja1.js} +6 -5
  73. package/dist/{lead-4k9s9szx.js → lead-cw45n21s.js} +32 -30
  74. package/dist/{maintenance-shazch4n.js → maintenance-ss1a1ge9.js} +4 -3
  75. package/dist/node-c9we95xf.js +1 -1
  76. package/dist/{oauth-refresh-sweep-5gb36kn8.js → oauth-refresh-sweep-3c6f8vyy.js} +5 -4
  77. package/dist/{onboard-ydrbnvww.js → onboard-8hzdhc1k.js} +2 -2
  78. package/dist/{opencode-adapter-5zh0he20.js → opencode-adapter-qbchbcfz.js} +6 -6
  79. package/dist/{otel-impl-6pf5cv86.js → otel-impl-e6mnvc4v.js} +7 -2
  80. package/dist/{pi-mono-adapter-ef9wwx9m.js → pi-mono-adapter-3c9g9snh.js} +6 -6
  81. package/dist/{pricing-refresh-s52nsa5q.js → pricing-refresh-gedkjdw0.js} +6 -5
  82. package/dist/{rbac-roles-aq3msh4e.js → rbac-roles-dt4vh1yy.js} +4 -3
  83. package/dist/{rbac-roles-q5gb5e8v.js → rbac-roles-eszdg6pm.js} +5 -4
  84. package/dist/{render-v2-pd1rg54q.js → render-v2-907cy6sa.js} +6 -4
  85. package/dist/{resume-gw4a2c6v.js → resume-42stcaz0.js} +11 -9
  86. package/dist/{setup-jda1ksdh.js → setup-adbc1c10.js} +2 -2
  87. package/dist/{virtual-modules-b3ga2m65.js → virtual-modules-rtmt494q.js} +3 -3
  88. package/dist/{work-objects-tb7ycye8.js → work-objects-wpj8ck95.js} +28 -21
  89. package/dist/{worker-njjccz5d.js → worker-bzdra9rf.js} +32 -30
  90. package/openapi.json +423 -7
  91. package/package.json +4 -4
  92. package/src/apps/catalog.generated.json +1309 -53
  93. package/src/apps/page-validator.ts +93 -31
  94. package/src/azure-devops/api.ts +94 -18
  95. package/src/azure-devops/auth.ts +32 -0
  96. package/src/azure-devops/boards-sync.ts +708 -0
  97. package/src/azure-devops/handlers.ts +52 -8
  98. package/src/azure-devops/html.ts +26 -0
  99. package/src/azure-devops/index.ts +15 -0
  100. package/src/azure-devops/templates.ts +86 -0
  101. package/src/azure-devops/types.ts +65 -1
  102. package/src/be/db.ts +22 -6
  103. package/src/be/migrations/213_script_connections_sql.sql +79 -0
  104. package/src/be/script-connections.ts +47 -8
  105. package/src/be/seed-skills/bundled-files.generated.json +10 -0
  106. package/src/be/seed-skills/index.ts +3 -0
  107. package/src/be/sql-connections.ts +118 -0
  108. package/src/be/swarm-config-guard.ts +1 -0
  109. package/src/commands/profile-sync.ts +5 -3
  110. package/src/commands/runner.ts +6 -2
  111. package/src/http/mcp-oauth.ts +6 -13
  112. package/src/http/pages-public.ts +3 -2
  113. package/src/http/pages.ts +2 -1
  114. package/src/http/route-def.ts +7 -6
  115. package/src/http/script-connection-proxy.ts +51 -4
  116. package/src/http/script-connections.ts +5 -2
  117. package/src/http/session-cost-recompute.ts +12 -2
  118. package/src/http/session-data.ts +4 -0
  119. package/src/http/webhooks.ts +24 -1
  120. package/src/jira/adf.ts +3 -1
  121. package/src/kv-reserved-namespaces.ts +2 -0
  122. package/src/oauth/mcp-wrapper.ts +10 -6
  123. package/src/otel-impl.ts +2 -1
  124. package/src/prompts/base-prompt.ts +3 -3
  125. package/src/providers/acp-targets.ts +1 -1
  126. package/src/providers/amp-adapter.ts +1 -1
  127. package/src/providers/claude-adapter.ts +27 -2
  128. package/src/providers/claude-flag-settings.ts +121 -0
  129. package/src/providers/claude-sdk-session.ts +7 -0
  130. package/src/providers/dsh-adapter.ts +1 -1
  131. package/src/providers/opencode-adapter.ts +26 -12
  132. package/src/providers/opencode-billing.ts +86 -0
  133. package/src/providers/opencode-swarm-plugin.ts +20 -0
  134. package/src/providers/pricing-sources.md +4 -1
  135. package/src/providers/types.ts +5 -0
  136. package/src/scripts-runtime/api-client.ts +15 -1
  137. package/src/scripts-runtime/api-types.ts +9 -1
  138. package/src/scripts-runtime/ctx.ts +1 -1
  139. package/src/scripts-runtime/mcp-client.ts +30 -19
  140. package/src/slack/actions.ts +29 -1
  141. package/src/slack/app.ts +14 -2
  142. package/src/slack/assistant.ts +36 -2
  143. package/src/slack/channel-join.ts +3 -16
  144. package/src/slack/commands.ts +9 -1
  145. package/src/slack/external-channel-egress.ts +113 -0
  146. package/src/slack/external-channel.ts +309 -0
  147. package/src/slack/handlers.ts +61 -0
  148. package/src/slack/render-v2.ts +40 -47
  149. package/src/slack/work-objects.ts +5 -0
  150. package/src/tasks/context-key.ts +34 -1
  151. package/src/telemetry.ts +2 -1
  152. package/src/tests/apps-catalog-feedback.test.ts +310 -0
  153. package/src/tests/apps-catalog-inputs.test.ts +70 -0
  154. package/src/tests/apps-catalog-table.test.ts +113 -0
  155. package/src/tests/azure-devops-boards-sync.test.ts +584 -0
  156. package/src/tests/azure-devops-html.test.ts +13 -0
  157. package/src/tests/azure-devops-webhook-malformed.test.ts +4 -0
  158. package/src/tests/claude-adapter-binary.test.ts +139 -0
  159. package/src/tests/claude-flag-settings.test.ts +106 -0
  160. package/src/tests/claude-sdk-lifecycle.test.ts +142 -1
  161. package/src/tests/claude-sdk-process.fixture.ts +7 -0
  162. package/src/tests/context-key.test.ts +32 -0
  163. package/src/tests/deferred-task-wake.test.ts +52 -4
  164. package/src/tests/docs-index-footprint.test.js +3 -3
  165. package/src/tests/dsh-adapter.test.ts +1 -1
  166. package/src/tests/fixtures/azure-boards/workitem.commented.json +89 -0
  167. package/src/tests/fixtures/azure-boards/workitem.created.json +81 -0
  168. package/src/tests/fixtures/azure-boards/workitem.deleted.json +70 -0
  169. package/src/tests/fixtures/azure-boards/workitem.restored.json +82 -0
  170. package/src/tests/fixtures/azure-boards/workitem.updated.json +130 -0
  171. package/src/tests/fixtures/catalog-feedback-definition.json.txt +860 -0
  172. package/src/tests/fixtures/catalog-inputs-definition.json.txt +910 -0
  173. package/src/tests/fixtures/catalog-table-definition.json.txt +468 -0
  174. package/src/tests/fixtures/runner-identity-refresh.ts +3 -0
  175. package/src/tests/node-env-runtime.test.ts +98 -0
  176. package/src/tests/opencode-adapter.test.ts +132 -1
  177. package/src/tests/opencode-billing.test.ts +28 -0
  178. package/src/tests/runner-identity-refresh.test.ts +3 -0
  179. package/src/tests/script-connections-sql.test.ts +675 -0
  180. package/src/tests/script-connections.test.ts +5 -1
  181. package/src/tests/session-cost-recompute-unit.test.ts +48 -0
  182. package/src/tests/slack-channel-join.test.ts +4 -1
  183. package/src/tests/slack-external-channel-config.test.ts +65 -0
  184. package/src/tests/slack-external-channel-egress.test.ts +237 -0
  185. package/src/tests/slack-external-channel-guard.test.ts +280 -0
  186. package/src/tests/slack-external-channel-tools.test.ts +173 -0
  187. package/src/tests/slack-external-channel.test.ts +370 -0
  188. package/src/tests/slack-render-v2.test.ts +86 -10
  189. package/src/tests/spec-base-url.test.ts +16 -1
  190. package/src/tests/vendored-openapi.test.ts +16 -1
  191. package/src/tools/defer-task.ts +17 -0
  192. package/src/tools/slack-post.ts +6 -0
  193. package/src/tools/slack-read.ts +8 -0
  194. package/src/tools/slack-reply.ts +6 -0
  195. package/src/tools/slack-start-thread.ts +6 -0
  196. package/src/tools/slack-update.ts +6 -0
  197. package/src/tools/slack-upload-file.ts +6 -0
  198. package/src/utils/node-env.ts +24 -0
  199. package/templates/skills/apps/SKILL.md +742 -0
  200. package/templates/skills/apps/content.md +52 -21
  201. package/templates/skills/qa-loom/config.json +14 -0
  202. package/templates/skills/qa-loom/content.md +187 -0
  203. package/templates/skills/qa-loom/files/build-loom.mjs +221 -0
  204. package/templates/skills/qa-loom/files/run-qa.sh +57 -0
  205. package/templates/skills/slack-interaction/content.md +4 -0
  206. package/dist/{azure-openai-responses-ap1gwxgr.js → azure-openai-responses-ygfreq4t.js} +5 -5
  207. package/dist/{cli-4fnb6884.js → cli-h7k0xtry.js} +3 -3
  208. package/dist/{cli-5rqrj7q0.js → cli-pw7ebjdt.js} +0 -0
  209. package/dist/{google-generative-ai-7pavrbv7.js → google-generative-ai-szdxbpqg.js} +1 -1
  210. package/dist/{google-vertex-3f1jk41f.js → google-vertex-qzw3p36d.js} +1 -1
  211. package/dist/{openai-codex-responses-33qhkkdy.js → openai-codex-responses-3bk0grnr.js} +4 -4
  212. package/dist/{openai-completions-s88xm3ns.js → openai-completions-5d4jpakc.js} +9 -9
  213. package/dist/{openai-responses-7xd2f2e2.js → openai-responses-krb51f59.js} +5 -5
  214. package/dist/{pi-messages-xszk613n.js → pi-messages-x9gzynm1.js} +3 -3
@@ -6,7 +6,7 @@ import {
6
6
  } from "./cli-1x7da0de.js";
7
7
  import {
8
8
  checkGrokCredentials
9
- } from "./cli-nv4zd0b9.js";
9
+ } from "./cli-xc7p7s3g.js";
10
10
  import {
11
11
  createSkillInvokeTracker,
12
12
  isSkillLoaderCall,
@@ -15,7 +15,7 @@ import {
15
15
  import {
16
16
  checkCodexCredentials,
17
17
  codexUserHome
18
- } from "./cli-k46r9hmk.js";
18
+ } from "./cli-94b48jhk.js";
19
19
  import {
20
20
  checkClaudeManagedCredentials
21
21
  } from "./cli-d603qf86.js";
@@ -24,14 +24,14 @@ import {
24
24
  } from "./cli-e3pmyt39.js";
25
25
  import {
26
26
  checkOpencodeCredentials
27
- } from "./cli-j1pmc07z.js";
27
+ } from "./cli-saqyage0.js";
28
28
  import {
29
29
  checkDshCredentials
30
- } from "./cli-zxm9p3x4.js";
30
+ } from "./cli-srqq3gc5.js";
31
31
  import {
32
32
  checkAmpCredentials,
33
33
  liveTestAmpCredentials
34
- } from "./cli-04emfe2q.js";
34
+ } from "./cli-5wpw4rab.js";
35
35
  import {
36
36
  isLeadChannelMonitoringEnabled,
37
37
  isUnknownModelError,
@@ -50,7 +50,7 @@ import {
50
50
  } from "./cli-bqjfjex4.js";
51
51
  import {
52
52
  checkClaudeCredentials
53
- } from "./cli-g4f5pj26.js";
53
+ } from "./cli-0a7mm3zp.js";
54
54
  import {
55
55
  getContextWindowSize
56
56
  } from "./cli-7avy4v8w.js";
@@ -67,13 +67,13 @@ import {
67
67
  isAzureDevOpsUrl,
68
68
  parseAzureDevOpsRepoUrl,
69
69
  resolveScriptsOnlyMode
70
- } from "./cli-ztrv9y21.js";
70
+ } from "./cli-rfz2ve55.js";
71
71
  import {
72
72
  terminateRegisteredProcessGroups
73
73
  } from "./cli-zt3w1cn1.js";
74
74
  import {
75
75
  validateJsonSchema
76
- } from "./cli-kb4ehzx5.js";
76
+ } from "./cli-1w0vj3gw.js";
77
77
  import {
78
78
  authJsonToCredentialSelection,
79
79
  credentialsToAuthJson,
@@ -88,7 +88,7 @@ import {
88
88
  startSpan,
89
89
  withSpan,
90
90
  withSpanContext
91
- } from "./cli-9xsmdpdt.js";
91
+ } from "./cli-tcc4wd5d.js";
92
92
  import {
93
93
  MASKED_SECRET_VALUE,
94
94
  initTelemetry,
@@ -101,7 +101,7 @@ import {
101
101
  isCodexAuthFailureReason,
102
102
  mapTriggerSurface,
103
103
  telemetry
104
- } from "./cli-tgpfnm6r.js";
104
+ } from "./cli-fmhj1ehj.js";
105
105
  import {
106
106
  ProviderNameSchema,
107
107
  WorkerNudgeSchema,
@@ -111,6 +111,7 @@ import {
111
111
  resolveTaskModelSelection
112
112
  } from "./cli-hsem16hb.js";
113
113
  import {
114
+ WORKSPACE_CLAUDE_MD_PATH,
114
115
  buildContextPreamble,
115
116
  buildResumeContextPreamble,
116
117
  contentSha256,
@@ -131,7 +132,7 @@ import {
131
132
  taskAttachmentFetchCommand,
132
133
  writeIdentityBaselines,
133
134
  writeProfileFileFromDb
134
- } from "./cli-nyhb1r6x.js";
135
+ } from "./cli-r4fqfpwf.js";
135
136
  import {
136
137
  init_steering_enabled,
137
138
  isSteeringEnabled
@@ -225,15 +226,15 @@ async function materializeCodexAuthJson(_slot, creds, deps = {}) {
225
226
  async function createProviderAdapter(provider) {
226
227
  switch (provider) {
227
228
  case "claude": {
228
- const { ClaudeAdapter } = await import("./claude-adapter-t26cv8a4.js");
229
+ const { ClaudeAdapter } = await import("./claude-adapter-yzzzh8jp.js");
229
230
  return new ClaudeAdapter;
230
231
  }
231
232
  case "pi": {
232
- const { PiMonoAdapter } = await import("./pi-mono-adapter-ef9wwx9m.js");
233
+ const { PiMonoAdapter } = await import("./pi-mono-adapter-3c9g9snh.js");
233
234
  return new PiMonoAdapter;
234
235
  }
235
236
  case "codex": {
236
- const { CodexAdapter } = await import("./codex-adapter-m4tgdysy.js");
237
+ const { CodexAdapter } = await import("./codex-adapter-r3dn4fp5.js");
237
238
  return new CodexAdapter;
238
239
  }
239
240
  case "claude-managed": {
@@ -245,15 +246,15 @@ async function createProviderAdapter(provider) {
245
246
  return new DevinAdapter;
246
247
  }
247
248
  case "opencode": {
248
- const { OpencodeAdapter } = await import("./opencode-adapter-5zh0he20.js");
249
+ const { OpencodeAdapter } = await import("./opencode-adapter-qbchbcfz.js");
249
250
  return new OpencodeAdapter;
250
251
  }
251
252
  case "dsh": {
252
- const { DshAdapter } = await import("./dsh-adapter-2h8m4cab.js");
253
+ const { DshAdapter } = await import("./dsh-adapter-34etvb5m.js");
253
254
  return new DshAdapter;
254
255
  }
255
256
  case "amp": {
256
- const { AmpAdapter } = await import("./amp-adapter-8jem2bc0.js");
257
+ const { AmpAdapter } = await import("./amp-adapter-gpxp3kc9.js");
257
258
  return new AmpAdapter;
258
259
  }
259
260
  case "cursor": {
@@ -261,11 +262,11 @@ async function createProviderAdapter(provider) {
261
262
  return new CursorAdapter;
262
263
  }
263
264
  case "grok": {
264
- const { GrokAdapter } = await import("./grok-adapter-8m9yqzbq.js");
265
+ const { GrokAdapter } = await import("./grok-adapter-e7mr287e.js");
265
266
  return new GrokAdapter;
266
267
  }
267
268
  case "acp": {
268
- const { ACPAdapter } = await import("./acp-adapter-fpecx1g1.js");
269
+ const { ACPAdapter } = await import("./acp-adapter-ccm9xrep.js");
269
270
  return new ACPAdapter;
270
271
  }
271
272
  default:
@@ -1130,7 +1131,7 @@ var CREDENTIAL_PROVIDER_CHECKERS = {
1130
1131
  devin: (env) => checkDevinCredentials(env),
1131
1132
  opencode: (env, opts) => checkOpencodeCredentials(env, opts),
1132
1133
  pi: async (env, opts) => {
1133
- const { checkPiMonoCredentials } = await import("./pi-mono-adapter-ef9wwx9m.js");
1134
+ const { checkPiMonoCredentials } = await import("./pi-mono-adapter-3c9g9snh.js");
1134
1135
  return checkPiMonoCredentials(env, opts);
1135
1136
  },
1136
1137
  acp: (env) => {
@@ -5577,7 +5578,7 @@ ${agentSetupScript}
5577
5578
  }
5578
5579
  if (agentClaudeMd) {
5579
5580
  try {
5580
- const backupPath = await writeProfileFileFromDb("/workspace/CLAUDE.md", agentClaudeMd);
5581
+ const backupPath = await writeProfileFileFromDb(WORKSPACE_CLAUDE_MD_PATH, agentClaudeMd);
5581
5582
  if (backupPath)
5582
5583
  console.warn(`[${role}] Archived differing CLAUDE.md at ${backupPath}`);
5583
5584
  console.log(`[${role}] Wrote CLAUDE.md to workspace`);
@@ -9,7 +9,7 @@ import {
9
9
  renderGoalReminder,
10
10
  summarizeTranscript,
11
11
  syncIdentityFilesToServer
12
- } from "./cli-bf7485pm.js";
12
+ } from "./cli-na2pxe4f.js";
13
13
  import {
14
14
  fetchInstalledMcpServers
15
15
  } from "./cli-tng3131n.js";
@@ -57,6 +57,65 @@ init_env_flag();
57
57
  init_openrouter_base_url();
58
58
  init_secret_scrubber();
59
59
 
60
+ // src/providers/opencode-billing.ts
61
+ function parseOpenRouterBilledCost(body) {
62
+ const payloads = body.trimStart().startsWith("{") ? [body] : body.split(`
63
+ `).filter((line) => line.startsWith("data:")).map((line) => line.slice(5).trim());
64
+ let cost = null;
65
+ for (const payload of payloads) {
66
+ if (!payload.includes('"cost"'))
67
+ continue;
68
+ let usage;
69
+ try {
70
+ usage = JSON.parse(payload).usage;
71
+ } catch {
72
+ continue;
73
+ }
74
+ if (usage?.is_byok === true)
75
+ return null;
76
+ if (typeof usage?.cost === "number" && Number.isFinite(usage.cost))
77
+ cost = usage.cost;
78
+ }
79
+ return cost;
80
+ }
81
+
82
+ class OpenRouterBilling {
83
+ requests = 0;
84
+ billed = 0;
85
+ costUsd = 0;
86
+ pending = new Set;
87
+ observe(response) {
88
+ this.requests++;
89
+ if (!response.ok) {
90
+ this.billed++;
91
+ return;
92
+ }
93
+ const read = response.clone().text().then((body) => {
94
+ const cost = parseOpenRouterBilledCost(body);
95
+ if (cost === null)
96
+ return;
97
+ this.billed++;
98
+ this.costUsd += cost;
99
+ }).catch(() => {}).finally(() => this.pending.delete(read));
100
+ this.pending.add(read);
101
+ }
102
+ async settle(timeoutMs) {
103
+ if (this.pending.size > 0) {
104
+ let timer;
105
+ await Promise.race([
106
+ Promise.all(this.pending),
107
+ new Promise((resolve) => {
108
+ timer = setTimeout(resolve, timeoutMs);
109
+ })
110
+ ]);
111
+ clearTimeout(timer);
112
+ }
113
+ if (this.requests === 0)
114
+ return null;
115
+ return { costUsd: this.costUsd, complete: this.billed === this.requests };
116
+ }
117
+ }
118
+
60
119
  // src/providers/opencode-swarm-plugin.ts
61
120
  function createOpencodeSwarmPlugin(config, options = {}) {
62
121
  return {
@@ -90,6 +149,15 @@ function createOpencodeSwarmPlugin(config, options = {}) {
90
149
  if (concurrent)
91
150
  event.system.push({ type: "text", text: concurrent });
92
151
  });
152
+ await ctx.session.hook("title", (event) => {
153
+ event.result = config.taskId ? `swarm task ${config.taskId}` : "swarm session";
154
+ });
155
+ const onOpenRouterResponse = options.onOpenRouterResponse;
156
+ if (onOpenRouterResponse) {
157
+ await ctx.session.hook("http.response", (event) => {
158
+ onOpenRouterResponse(event.response);
159
+ }, { providerID: "openrouter" });
160
+ }
93
161
  await ctx.session.hook("compaction", async (event) => {
94
162
  if (!config.taskId)
95
163
  return;
@@ -210,6 +278,7 @@ function applyOpenRouterBaseUrlOverride(opencodeConfig, env = process.env) {
210
278
  var SWARM_AGENT_NAME = "swarm";
211
279
  var TRANSCRIPT_TAIL_CHARS = 20000;
212
280
  var TOOL_RESULT_PREVIEW_CHARS = 500;
281
+ var BILLING_SETTLE_MS = 2000;
213
282
  var SWARM_MCP_SERVER = "swarm";
214
283
  var REQUIRED_SWARM_TOOLS = ["store-progress"];
215
284
  var ADMISSION_POLL_MS = 250;
@@ -278,6 +347,7 @@ class OpencodeSession {
278
347
  swarm;
279
348
  cwd;
280
349
  appliedReasoningEffort;
350
+ billing;
281
351
  listeners = [];
282
352
  pendingEvents = [];
283
353
  completionResolve;
@@ -294,13 +364,14 @@ class OpencodeSession {
294
364
  toolNames = new Map;
295
365
  textByMessage = new Map;
296
366
  transcript = [];
297
- constructor(host, _sessionId, model, swarm, cwd, appliedReasoningEffort = null) {
367
+ constructor(host, _sessionId, model, swarm, cwd, appliedReasoningEffort = null, billing) {
298
368
  this.host = host;
299
369
  this._sessionId = _sessionId;
300
370
  this.model = model;
301
371
  this.swarm = swarm;
302
372
  this.cwd = cwd;
303
373
  this.appliedReasoningEffort = appliedReasoningEffort;
374
+ this.billing = billing;
304
375
  this.completionPromise = new Promise((resolve) => {
305
376
  this.completionResolve = resolve;
306
377
  });
@@ -431,12 +502,13 @@ class OpencodeSession {
431
502
  case "session.usage.updated":
432
503
  this.usage = { cost: ev.data.cost, tokens: ev.data.tokens };
433
504
  break;
434
- case "session.execution.succeeded": {
435
- const cost = this.buildCostData(false);
436
- this.emit({ type: "result", cost, isError: false });
437
- this.finish({ exitCode: 0, sessionId: this._sessionId, cost, isError: false });
505
+ case "session.execution.succeeded":
506
+ this.finish(async () => {
507
+ const cost = await this.buildCostData(false);
508
+ this.emit({ type: "result", cost, isError: false });
509
+ return { exitCode: 0, sessionId: this._sessionId, cost, isError: false };
510
+ });
438
511
  break;
439
- }
440
512
  case "session.execution.failed":
441
513
  this.fail(errorMessage(ev.data.error, "opencode session error"));
442
514
  break;
@@ -463,23 +535,24 @@ class OpencodeSession {
463
535
  if (this.aborted || this.completed)
464
536
  return;
465
537
  this.emit({ type: "error", message });
466
- this.finish({
538
+ this.finish(async () => ({
467
539
  exitCode: 1,
468
540
  sessionId: this._sessionId,
469
- cost: this.buildCostData(true),
541
+ cost: await this.buildCostData(true),
470
542
  isError: true,
471
543
  failureReason: message
472
- });
544
+ }));
473
545
  }
474
- buildCostData(isError) {
546
+ async buildCostData(isError) {
475
547
  const { cost, tokens } = this.usage;
548
+ const billed = await this.billing?.settle(BILLING_SETTLE_MS);
476
549
  return {
477
550
  sessionId: this._sessionId,
478
551
  taskId: this.swarm.taskId,
479
552
  agentId: this.swarm.agentId,
480
- totalCostUsd: cost,
553
+ ...billed?.complete ? { totalCostUsd: billed.costUsd, harnessCostBilled: true } : { totalCostUsd: cost },
481
554
  inputTokens: tokens.input,
482
- outputTokens: tokens.output,
555
+ outputTokens: tokens.output + tokens.reasoning,
483
556
  reasoningOutputTokens: tokens.reasoning,
484
557
  cacheReadTokens: tokens.cache.read,
485
558
  cacheWriteTokens: tokens.cache.write,
@@ -507,11 +580,12 @@ class OpencodeSession {
507
580
  headers: apiHeaders(this.swarm)
508
581
  });
509
582
  }
510
- async finish(result) {
583
+ async finish(settle) {
511
584
  if (this.completed)
512
585
  return;
513
586
  this.completed = true;
514
587
  const { signal } = this.sessionEnd;
588
+ const result = typeof settle === "function" ? await settle() : settle;
515
589
  try {
516
590
  if (!this.aborted) {
517
591
  await settleWithin(this.runSessionEnd(signal), sessionHooks.budgetMs, signal);
@@ -637,13 +711,15 @@ class OpencodeAdapter {
637
711
  };
638
712
  const { sdk, version: opencodeVersion } = await loadOpencodeSdkImpl();
639
713
  let listTools;
714
+ const billing = config.model.startsWith("openrouter/") ? new OpenRouterBilling : undefined;
640
715
  const host = await sdk.OpenCode.create({
641
716
  config: { content: JSON.stringify(opencodeConfig) },
642
717
  plugins: [
643
718
  createOpencodeSwarmPlugin(swarm, {
644
719
  onToolRegistry: (lister) => {
645
720
  listTools = lister;
646
- }
721
+ },
722
+ ...billing ? { onOpenRouterResponse: (response) => billing.observe(response) } : {}
647
723
  })
648
724
  ],
649
725
  log: {
@@ -662,7 +738,7 @@ class OpencodeAdapter {
662
738
  await host.close().catch(() => {});
663
739
  throw err;
664
740
  }
665
- const session = new OpencodeSession(host, sessionId, config.model, swarm, config.cwd, appliedReasoningEffort);
741
+ const session = new OpencodeSession(host, sessionId, config.model, swarm, config.cwd, appliedReasoningEffort, billing);
666
742
  session.emitSessionInit(opencodeVersion ? { version: opencodeVersion } : undefined);
667
743
  (async () => {
668
744
  try {
@@ -66,7 +66,7 @@ function addDshStepUsage(acc, step) {
66
66
  // src/providers/dsh-adapter.ts
67
67
  init_openrouter_base_url();
68
68
  init_secret_scrubber();
69
- var DSH_PACKAGE = "@deepseek-ai/dsh@0.2.1-alpha.2";
69
+ var DSH_PACKAGE = "@deepseek-ai/dsh@0.2.1-alpha.3";
70
70
  function checkDshCredentials(env) {
71
71
  return env.DEEPSEEK_API_KEY?.trim() || env.OPENROUTER_API_KEY?.trim() ? { ready: true, missing: [], satisfiedBy: "env" } : {
72
72
  ready: false,