@desplega.ai/agent-swarm 1.160.0 → 1.162.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 (398) hide show
  1. package/README.md +4 -3
  2. package/dist/{acp-adapter-2mjwcsfh.js → acp-adapter-74m73ae9.js} +163 -49
  3. package/dist/{actions-e43rxskr.js → actions-4sr14gnt.js} +42 -38
  4. package/dist/{anthropic-messages-5qx80j9k.js → anthropic-messages-8xxrzky9.js} +22 -26
  5. package/dist/{app-mc7xfagn.js → app-pt68fbwp.js} +17 -14
  6. package/dist/{artifact-3v5t9jtg.js → artifact-fey7dvj9.js} +3 -2
  7. package/dist/{assistant-sedkzv3b.js → assistant-cv3jytks.js} +43 -39
  8. package/dist/{azure-openai-responses-nfb21z9a.js → azure-openai-responses-f5cqsyj8.js} +15 -10
  9. package/dist/{boot-reembed-m3656j2n.js → boot-reembed-4ht4gqth.js} +17 -14
  10. package/dist/{boot-reembed-cqz9swn5.js → boot-reembed-nxpcvpj9.js} +16 -13
  11. package/dist/{boot-scrub-logs-xbxf5d7w.js → boot-scrub-logs-k93kyw8k.js} +13 -10
  12. package/dist/boot-seeds-1skcrs0e.js +32 -0
  13. package/dist/{claude-adapter-dc6289mc.js → claude-adapter-r5g0tzge.js} +39 -30
  14. package/dist/{claude-managed-adapter-naaw51me.js → claude-managed-adapter-yxkfxg8j.js} +6 -5
  15. package/dist/{claude-managed-setup-eacvchx0.js → claude-managed-setup-pkyrgshb.js} +27 -27
  16. package/dist/{claude-sdk-session-bqp2xvym.js → claude-sdk-session-jxyxnrwd.js} +8041 -7910
  17. package/dist/{cli-4derpgyk.js → cli-2hhfhfq5.js} +6 -1
  18. package/dist/{cli-rykfmgwg.js → cli-2x0e561b.js} +1 -1
  19. package/dist/{cli-tzx2ke1v.js → cli-2zy95vhm.js} +137 -64
  20. package/dist/{cli-0x01kwrd.js → cli-4cwxn7gp.js} +47 -186
  21. package/dist/{cli-xjcywfsf.js → cli-4dcpaefp.js} +12 -11
  22. package/dist/{cli-v7fn5gms.js → cli-4x0csdjq.js} +164 -76
  23. package/dist/{cli-12tszpk9.js → cli-5bcd7sfy.js} +91 -29
  24. package/dist/{cli-jz4w45qt.js → cli-5k6k8ta3.js} +190 -50
  25. package/dist/{cli-tpq83z89.js → cli-5xhpb3kv.js} +20 -19
  26. package/dist/{cli-r1mxd1xh.js → cli-7af8yhav.js} +6 -179
  27. package/dist/{cli-jajnsm8q.js → cli-7tre70zp.js} +18160 -31345
  28. package/dist/{cli-447dt1h3.js → cli-8ev9xqnx.js} +218 -25
  29. package/dist/cli-bsky8g7w.js +449 -0
  30. package/dist/{cli-0z2v4nhw.js → cli-cat6h73s.js} +1 -1
  31. package/dist/{cli-25fcq4b4.js → cli-cebmgwsc.js} +15 -11
  32. package/dist/{cli-shkxm1vn.js → cli-cvatsam7.js} +189 -13
  33. package/dist/{cli-2658f6at.js → cli-cvk6yzw5.js} +6 -8
  34. package/dist/cli-dbmwby6a.js +9 -0
  35. package/dist/{cli-ptr8h7kp.js → cli-eg0b3p0k.js} +5 -218
  36. package/dist/cli-f9w1semm.js +413 -0
  37. package/dist/{cli-523679eh.js → cli-g739zqzt.js} +6 -5
  38. package/dist/{cli-dv6cdjs2.js → cli-gd4favx9.js} +28 -7
  39. package/dist/{cli-c8a36vcc.js → cli-gpqpmns7.js} +2 -2
  40. package/dist/{cli-5nbmpy8w.js → cli-hb5c2x5y.js} +1 -1
  41. package/dist/{cli-741yb0xx.js → cli-hmsw1gpy.js} +55 -169
  42. package/dist/{cli-qydf22qq.js → cli-jf7wmv1r.js} +2562 -735
  43. package/dist/{cli-mfe5btp9.js → cli-jxs2ygaw.js} +317 -121
  44. package/dist/{cli-kmcpfwn2.js → cli-jyy6pm2f.js} +19 -3
  45. package/dist/cli-kdkwd3yr.js +615 -0
  46. package/dist/{cli-6cs6wzxt.js → cli-kh04eqwe.js} +2 -2
  47. package/dist/{cli-9hsgwz4w.js → cli-kp42yek0.js} +1309 -391
  48. package/dist/cli-ma3zvh39.js +10404 -0
  49. package/dist/{cli-ybgv4kw2.js → cli-mbssg1xv.js} +9 -2
  50. package/dist/{cli-jsp14b6c.js → cli-mzfth0bp.js} +38 -1
  51. package/dist/{cli-r2ap2czm.js → cli-nexqx4ve.js} +6 -0
  52. package/dist/{cli-f8gy6r2r.js → cli-nq7yqw7b.js} +19 -8
  53. package/dist/{cli-10nhj6xq.js → cli-nt8hecg9.js} +34 -33
  54. package/dist/cli-p0r8sxj5.js +303 -0
  55. package/dist/{cli-58e8yr0d.js → cli-pkd6s2wy.js} +4 -2
  56. package/dist/{cli-a8dvhzrt.js → cli-q24re23n.js} +7 -5
  57. package/dist/cli-qjjvzwzd.js +222 -0
  58. package/dist/cli-qrgt5bqf.js +189 -0
  59. package/dist/{cli-et8m9xsv.js → cli-rfjw9jw2.js} +22 -10
  60. package/dist/{cli-7e398j1h.js → cli-rj0gqwwp.js} +3 -3
  61. package/dist/{cli-btfv8y88.js → cli-rnyzn44p.js} +2 -2
  62. package/dist/{cli-d5czme6m.js → cli-s3hwpt9v.js} +4754 -4945
  63. package/dist/{cli-0jwe9034.js → cli-sptrj5f5.js} +3 -3
  64. package/dist/{cli-0q3avq3s.js → cli-sqvfa090.js} +19 -11
  65. package/dist/{cli-azhgzetg.js → cli-swfmp1fx.js} +27 -27
  66. package/dist/{cli-jyk0ynw2.js → cli-t845n9xk.js} +23 -10
  67. package/dist/{cli-zpep9q5e.js → cli-tcen9p5w.js} +20 -15
  68. package/dist/{cli-74h9hscv.js → cli-tre4bdgq.js} +1 -1
  69. package/dist/{cli-pm1rst0h.js → cli-twrh04ap.js} +30 -15
  70. package/dist/{cli-phsaj4xq.js → cli-v0pvvhfq.js} +1 -1
  71. package/dist/{cli-ydmcgve1.js → cli-vc9bp061.js} +5 -5
  72. package/dist/{cli-g2whhdrf.js → cli-vxe6qa4h.js} +1 -1
  73. package/dist/{cli-vctdqs5h.js → cli-vy3ed88x.js} +15 -2
  74. package/dist/{cli-br0qdrnp.js → cli-vyqs9ya8.js} +18 -18
  75. package/dist/{cli-cpvsaqsw.js → cli-w0bwte75.js} +8 -5
  76. package/dist/cli-wbvnn6tk.js +861 -0
  77. package/dist/{cli-r94z9p1z.js → cli-wgbezhw2.js} +3 -0
  78. package/dist/{cli-evvtk35y.js → cli-wjgs5wxe.js} +7 -7
  79. package/dist/cli-wxkkd0e0.js +33 -0
  80. package/dist/{cli-0wgxmwf6.js → cli-xk79303e.js} +20 -7
  81. package/dist/{cli-ktmyrtpn.js → cli-xqpk3rp7.js} +33 -10
  82. package/dist/{cli-ygwm91nt.js → cli-yy6dew39.js} +1 -1
  83. package/dist/cli-zp38xvtm.js +9487 -0
  84. package/dist/{cli-tfky2838.js → cli-zvhd3f64.js} +4 -4
  85. package/dist/{cli-jayjpjmb.js → cli-zxqx25nz.js} +66 -23
  86. package/dist/cli.js +40 -32
  87. package/dist/{cloudflare-workers-ai-system-one-k6fbxw9d.js → cloudflare-workers-ai-system-one-k8ddqjkq.js} +8 -6
  88. package/dist/{codex-adapter-nmxcatww.js → codex-adapter-esvmnhn7.js} +24 -23
  89. package/dist/{codex-hook-20me6byw.js → codex-hook-m73jmqgx.js} +19 -3
  90. package/dist/{codex-login-w6fz4xbz.js → codex-login-cf7mzsgg.js} +2 -2
  91. package/dist/{codex-session-runner-90aa80ev.js → codex-session-runner-ban9excr.js} +24 -23
  92. package/dist/{commands-8wcq1kn7.js → commands-75413p2n.js} +13 -10
  93. package/dist/{db-j40kc4se.js → db-7f5pecwg.js} +17 -10
  94. package/dist/{dispatcher-4zqy768d.js → dispatcher-fh9at8nz.js} +41 -37
  95. package/dist/dsh-adapter-wpze65d4.js +24 -0
  96. package/dist/{e2b-ez07znam.js → e2b-gjgdjp91.js} +12 -9
  97. package/dist/easter-egg-3d-3w5c2n4c.js +1057 -0
  98. package/dist/{execute-6e7qeyk4.js → execute-f50wg9nh.js} +203 -49
  99. package/dist/{google-generative-ai-k6n5nbpp.js → google-generative-ai-jxxpnegy.js} +2 -2
  100. package/dist/{google-vertex-44xxtcvp.js → google-vertex-x7q1angm.js} +5 -5
  101. package/dist/{handlers-kjdce1w5.js → handlers-w13787bb.js} +44 -40
  102. package/dist/{hook-r2t4bqfg.js → hook-46g1jrvx.js} +34 -20
  103. package/dist/{hook-czx13n12.js → hook-4tpts2ry.js} +25 -21
  104. package/dist/{http-3bbb19be.js → http-19pzbfrt.js} +1440 -283
  105. package/dist/{index-668me3f0.js → index-8fd4dm4h.js} +42 -38
  106. package/dist/{index-fg0dsp6c.js → index-dqmp15bq.js} +41 -37
  107. package/dist/{index-kkv84jq9.js → index-qb4q1y3e.js} +41 -37
  108. package/dist/index-s75wc4wd.js +33 -0
  109. package/dist/{index-zg7vp46x.js → index-scptvdxg.js} +64 -38
  110. package/dist/{keepalive-yra8dy57.js → keepalive-xa5ts9cd.js} +15 -12
  111. package/dist/{lead-va0pad2c.js → lead-qp4xkvjq.js} +59 -54
  112. package/dist/{maintenance-hqewtmyg.js → maintenance-rm5885hm.js} +17 -14
  113. package/dist/{mistral-conversations-pc3ntnxt.js → mistral-conversations-rw7fbt22.js} +4 -4
  114. package/dist/{node-a5e00qhp.js → node-8zkdq42h.js} +834 -833
  115. package/dist/node-f0ykebbv.js +2107 -0
  116. package/dist/node-wyamey5r.js +19 -0
  117. package/dist/{oauth-refresh-sweep-7rdt1m9n.js → oauth-refresh-sweep-1csdfebf.js} +14 -11
  118. package/dist/{onboard-j6ms6d0x.js → onboard-r6b78cs4.js} +10 -10
  119. package/dist/{openai-codex-responses-bbancrr0.js → openai-codex-responses-efvrgrq3.js} +4 -4
  120. package/dist/{openai-completions-jpaj5g2b.js → openai-completions-bbbrrz4z.js} +12 -8
  121. package/dist/{openai-responses-200k1wx4.js → openai-responses-9jjyrcm1.js} +15 -10
  122. package/dist/{opencode-adapter-89rabkw2.js → opencode-adapter-kb3g6pkf.js} +12 -9
  123. package/dist/{otel-impl-a792rjz0.js → otel-impl-0y9knpky.js} +6 -6
  124. package/dist/{pi-mono-adapter-g7qzvr3v.js → pi-mono-adapter-z6s1bme2.js} +128 -37
  125. package/dist/{pricing-refresh-wx0tp7cb.js → pricing-refresh-mth26tgp.js} +15 -12
  126. package/dist/{rbac-roles-8tzawacv.js → rbac-roles-kwntb23q.js} +17 -12
  127. package/dist/rbac-roles-vpk4ebm8.js +45 -0
  128. package/dist/{registry-v5wytg0s.js → registry-km6t1jd2.js} +1 -1
  129. package/dist/{render-v2-mm7zswb8.js → render-v2-hcm7h00y.js} +17 -14
  130. package/dist/{runtime-zyssgse0.js → runtime-vfjsfsc5.js} +5 -4
  131. package/dist/{setup-8y70ys6t.js → setup-hbyzd65h.js} +2 -2
  132. package/dist/{virtual-modules-6nmk7h3n.js → virtual-modules-9bv7ry91.js} +9 -7
  133. package/dist/{work-objects-fg6xkb0n.js → work-objects-m09sxnhe.js} +44 -40
  134. package/dist/{worker-wmwhxsph.js → worker-0h35rvk4.js} +59 -54
  135. package/dist/{x-n3e0v3xa.js → x-f1gt1pz3.js} +2 -2
  136. package/openapi.json +699 -26
  137. package/package.json +19 -11
  138. package/src/azure-devops/api.ts +121 -0
  139. package/src/azure-devops/auth.ts +78 -0
  140. package/src/azure-devops/handlers.ts +413 -0
  141. package/src/azure-devops/index.ts +27 -0
  142. package/src/azure-devops/templates.ts +108 -0
  143. package/src/azure-devops/types.ts +90 -0
  144. package/src/be/api-drain.ts +184 -0
  145. package/src/be/db/tasks/read.ts +32 -7
  146. package/src/be/db/tasks/write.ts +21 -4
  147. package/src/be/db-client.ts +11 -2
  148. package/src/be/db-retention.ts +95 -32
  149. package/src/be/db.ts +44 -19
  150. package/src/be/memory/constants.ts +16 -0
  151. package/src/be/memory/graph-expansion.ts +8 -1
  152. package/src/be/memory/index-content.ts +20 -1
  153. package/src/be/memory/key-guard.ts +93 -0
  154. package/src/be/memory/key-paths.ts +103 -0
  155. package/src/be/memory/link-resolver.ts +29 -3
  156. package/src/be/memory/providers/sqlite-store.ts +152 -45
  157. package/src/be/memory/raters/llm-summarizer.ts +10 -4
  158. package/src/be/memory/raters/llm.ts +15 -5
  159. package/src/be/memory/raters/store.ts +6 -3
  160. package/src/be/memory/raters/types.ts +11 -0
  161. package/src/be/memory/reranker.ts +38 -7
  162. package/src/be/memory/types.ts +12 -1
  163. package/src/be/migrations/190_memory_rating_model.sql +7 -0
  164. package/src/be/migrations/191_context_versions_previous_index.sql +8 -0
  165. package/src/be/migrations/192_favorites_agent_fs_path.sql +36 -0
  166. package/src/be/onboarding.ts +7 -1
  167. package/src/be/pricing-normalize.ts +4 -2
  168. package/src/be/scripts/typecheck.ts +4 -3
  169. package/src/be/seed-pricing.ts +16 -0
  170. package/src/be/seed-prompt-templates.ts +1 -0
  171. package/src/be/swarm-config-guard.ts +46 -17
  172. package/src/be/task-citations.ts +11 -5
  173. package/src/be/users.ts +3 -0
  174. package/src/cli.tsx +3 -2
  175. package/src/comb/agent-fs.ts +39 -0
  176. package/src/comb/config.ts +37 -0
  177. package/src/comb/markers.ts +37 -0
  178. package/src/comb/review-batch.ts +486 -0
  179. package/src/comb/templates.ts +88 -0
  180. package/src/commands/claude-managed-setup.ts +33 -31
  181. package/src/commands/context-preamble.ts +4 -1
  182. package/src/commands/hook.ts +2 -1
  183. package/src/commands/provider-credentials.ts +28 -15
  184. package/src/commands/runner.ts +458 -110
  185. package/src/commands/templates.ts +10 -0
  186. package/src/e2b/env.ts +2 -0
  187. package/src/extensions/catalog.generated.json +17 -0
  188. package/src/extensions/contract-types.generated.ts +1 -1
  189. package/src/fs/agent-fs-provider.ts +106 -2
  190. package/src/github/handlers.ts +10 -74
  191. package/src/github/reactions.ts +119 -138
  192. package/src/github/task-reactions.ts +34 -11
  193. package/src/heartbeat/heartbeat.ts +4 -0
  194. package/src/hooks/codex-hook.ts +25 -1
  195. package/src/hooks/hook.ts +14 -1
  196. package/src/hooks/pr-body-guard.ts +983 -0
  197. package/src/http/agents.ts +1 -1
  198. package/src/http/all-routes.ts +1 -0
  199. package/src/http/assets.ts +5 -17
  200. package/src/http/comb.ts +131 -0
  201. package/src/http/core.ts +14 -1
  202. package/src/http/extensions.ts +51 -27
  203. package/src/http/fs.ts +9 -17
  204. package/src/http/index.ts +27 -9
  205. package/src/http/mcp-user.ts +8 -13
  206. package/src/http/mcp.ts +19 -12
  207. package/src/http/memory.ts +80 -14
  208. package/src/http/onboarding.ts +21 -2
  209. package/src/http/poll.ts +30 -3
  210. package/src/http/realtime.ts +62 -0
  211. package/src/http/request-principal.ts +22 -0
  212. package/src/http/session-data.ts +6 -4
  213. package/src/http/stats.ts +1 -0
  214. package/src/http/status.ts +34 -2
  215. package/src/http/tasks.ts +17 -3
  216. package/src/http/users.ts +1 -1
  217. package/src/http/webhooks.ts +120 -2
  218. package/src/kv-reserved-namespaces.ts +10 -5
  219. package/src/providers/claude-adapter.ts +84 -16
  220. package/src/providers/claude-managed-adapter.ts +29 -2
  221. package/src/providers/codex-adapter.ts +1 -1
  222. package/src/providers/codex-skill-resolver.ts +6 -0
  223. package/src/providers/dsh-adapter.ts +204 -7
  224. package/src/providers/opencode-adapter.ts +24 -3
  225. package/src/providers/pi-mono-adapter.ts +154 -5
  226. package/src/providers/pi-mono-extension.ts +1 -1
  227. package/src/providers/pricing-sources.md +5 -1
  228. package/src/providers/reasoning-effort.ts +10 -2
  229. package/src/providers/types.ts +1 -1
  230. package/src/rbac/legacy-policy.ts +3 -0
  231. package/src/rbac/permissions.ts +14 -0
  232. package/src/realtime/auth.ts +63 -1
  233. package/src/realtime/tickets.ts +52 -0
  234. package/src/realtime/transport.ts +51 -22
  235. package/src/scripts-runtime/types/stdlib.d.ts +13 -5
  236. package/src/scripts-runtime/types/swarm-extension.d.ts +7 -3
  237. package/src/scripts-runtime/types/swarm-sdk.d.ts +13 -5
  238. package/src/tasks/context-key.ts +38 -1
  239. package/src/telemetry-context.ts +175 -0
  240. package/src/telemetry-contract/EVENTS.md +81 -0
  241. package/src/telemetry-contract/SOURCE.json +9 -0
  242. package/src/telemetry-contract/catalog.json +1335 -0
  243. package/src/telemetry-contract/index.ts +60 -0
  244. package/src/telemetry-contract/types.gen.ts +1971 -0
  245. package/src/telemetry-identity.ts +129 -0
  246. package/src/telemetry-snapshot.ts +211 -0
  247. package/src/telemetry-trigger.ts +125 -0
  248. package/src/telemetry-types.typetest.ts +40 -0
  249. package/src/telemetry.ts +271 -67
  250. package/src/tests/api-drain-e2e.test.ts +249 -0
  251. package/src/tests/api-drain-worker-e2e.test.ts +216 -0
  252. package/src/tests/api-drain.test.ts +351 -0
  253. package/src/tests/azure-devops-auth.test.ts +100 -0
  254. package/src/tests/azure-devops-handlers.test.ts +324 -0
  255. package/src/tests/azure-devops-webhook-malformed.test.ts +96 -0
  256. package/src/tests/claude-default-route.test.ts +260 -0
  257. package/src/tests/claude-managed-adapter.test.ts +47 -0
  258. package/src/tests/claude-managed-setup.test.ts +48 -0
  259. package/src/tests/claude-prompt-body-once.test.ts +117 -0
  260. package/src/tests/claude-routes-e2e.test.ts +316 -0
  261. package/src/tests/comb-config-guard.test.ts +38 -0
  262. package/src/tests/comb-links.test.ts +162 -0
  263. package/src/tests/comb-markers.test.ts +68 -0
  264. package/src/tests/comb-review-batch.test.ts +770 -0
  265. package/src/tests/comb-status.test.ts +152 -0
  266. package/src/tests/context-versions-retention.test.ts +314 -0
  267. package/src/tests/core-auth.test.ts +7 -0
  268. package/src/tests/db-retention.test.ts +14 -14
  269. package/src/tests/db-task-read-contract.test.ts +3 -0
  270. package/src/tests/db-task-write-contract.test.ts +3 -0
  271. package/src/tests/docs-index-footprint.test.js +3 -3
  272. package/src/tests/dsh-adapter.test.ts +134 -2
  273. package/src/tests/dsh-usage.test.ts +153 -0
  274. package/src/tests/extensions-catalog.test.ts +1 -0
  275. package/src/tests/extensions-example-deploy-awareness.test.ts +301 -0
  276. package/src/tests/extensions-http.test.ts +137 -10
  277. package/src/tests/extensions-mcp-tools.test.ts +28 -0
  278. package/src/tests/favorites-agent-fs-path.test.ts +226 -0
  279. package/src/tests/fetch-resolved-env.test.ts +24 -0
  280. package/src/tests/fixtures/azure-devops/pull-request-commented.json +129 -0
  281. package/src/tests/fixtures/azure-devops/pull-request-created.json +88 -0
  282. package/src/tests/fixtures/fake-claude-routes.ts +229 -0
  283. package/src/tests/github-handlers-reactions.test.ts +486 -0
  284. package/src/tests/github-reactions.test.ts +280 -0
  285. package/src/tests/harness-cli-version.test.ts +62 -0
  286. package/src/tests/http-api-integration.test.ts +21 -0
  287. package/src/tests/http-task-write-ownership.test.ts +24 -1
  288. package/src/tests/internal-ai/complete-structured.test.ts +94 -0
  289. package/src/tests/internal-ai/credentials.test.ts +22 -0
  290. package/src/tests/internal-ai/models.test.ts +36 -2
  291. package/src/tests/internal-ai/schema-parity.test.ts +25 -1
  292. package/src/tests/internal-ai/summarize-session.test.ts +23 -7
  293. package/src/tests/mcp-user-route.test.ts +133 -0
  294. package/src/tests/memory-key-paths.test.ts +1055 -0
  295. package/src/tests/memory-link-resolver.test.ts +34 -0
  296. package/src/tests/memory-rate-endpoint.test.ts +66 -0
  297. package/src/tests/memory-rater-llm-summarizer.test.ts +2 -1
  298. package/src/tests/memory-rater-llm.test.ts +73 -0
  299. package/src/tests/memory-rater-store.test.ts +31 -0
  300. package/src/tests/memory-reranker.test.ts +40 -0
  301. package/src/tests/onboarding.test.ts +108 -0
  302. package/src/tests/opencode-adapter.test.ts +57 -0
  303. package/src/tests/opencode-plugin.test.ts +4 -0
  304. package/src/tests/pi-codemode.test.ts +82 -4
  305. package/src/tests/pi-mono-adapter.test.ts +265 -2
  306. package/src/tests/pr-body-leaks.test.ts +789 -0
  307. package/src/tests/preload.ts +14 -0
  308. package/src/tests/provider-registration.test.ts +0 -2
  309. package/src/tests/providers/pi-cost.test.ts +190 -4
  310. package/src/tests/rbac-engine.test.ts +25 -1
  311. package/src/tests/realtime-room-auth.test.ts +104 -1
  312. package/src/tests/realtime-tickets.test.ts +74 -0
  313. package/src/tests/realtime-transport.test.ts +131 -4
  314. package/src/tests/runner-api-drain.test.ts +301 -0
  315. package/src/tests/runner-fallback-output.test.ts +61 -0
  316. package/src/tests/runner-fenced-json-output.test.ts +178 -0
  317. package/src/tests/runner-slot-reconcile.test.ts +199 -0
  318. package/src/tests/script-connections.test.ts +6 -0
  319. package/src/tests/send-task-requested-by.test.ts +133 -15
  320. package/src/tests/session-costs-recompute-all-providers.test.ts +23 -0
  321. package/src/tests/task-lifecycle-telemetry.test.ts +8 -3
  322. package/src/tests/task-reactions.test.ts +29 -6
  323. package/src/tests/telemetry-context.test.ts +314 -0
  324. package/src/tests/telemetry-init.test.ts +51 -19
  325. package/src/tests/telemetry-snapshot.test.ts +229 -0
  326. package/src/tests/telemetry-trigger.test.ts +200 -0
  327. package/src/tests/template-registry-helpers.ts +1 -0
  328. package/src/tests/vcs-azure-devops.test.ts +73 -0
  329. package/src/tests/webhooks-task-blocked.test.ts +23 -0
  330. package/src/tests/workflow-agent-task-retry.test.ts +363 -0
  331. package/src/tests/workflow-definition-telemetry.test.ts +4 -4
  332. package/src/tests/workflow-llm.test.ts +14 -0
  333. package/src/tools/context-diff.ts +20 -0
  334. package/src/tools/extension-install.ts +27 -16
  335. package/src/tools/memory-edit.ts +47 -3
  336. package/src/tools/memory-search.ts +13 -1
  337. package/src/tools/memory-store.ts +55 -3
  338. package/src/tools/poll-task.ts +20 -1
  339. package/src/tools/send-task.ts +9 -1
  340. package/src/tools/task-action.ts +11 -0
  341. package/src/types.ts +45 -8
  342. package/src/utils/api-drain.ts +24 -0
  343. package/src/utils/constants.ts +57 -16
  344. package/src/utils/credentials.test.ts +31 -1
  345. package/src/utils/credentials.ts +20 -9
  346. package/src/utils/dsh-usage.ts +53 -0
  347. package/src/utils/harness-cli-version.ts +6 -4
  348. package/src/utils/internal-ai/complete-structured.ts +26 -3
  349. package/src/utils/internal-ai/credentials.ts +23 -9
  350. package/src/utils/internal-ai/index.ts +8 -1
  351. package/src/utils/internal-ai/models.ts +34 -8
  352. package/src/utils/internal-ai/summarize-session.ts +22 -8
  353. package/src/utils/pr-body-leaks.ts +172 -0
  354. package/src/utils/secret-scrubber.ts +8 -0
  355. package/src/utils/task-attachment-links.ts +14 -8
  356. package/src/vcs/azure-devops.ts +80 -0
  357. package/src/vcs/index.ts +5 -1
  358. package/src/vcs/types.ts +2 -2
  359. package/src/workflows/recovery.ts +26 -1
  360. package/src/workflows/resume.ts +31 -4
  361. package/src/workflows/task-step-routing.ts +75 -2
  362. package/templates/community/open-prompt-showreel/PLAYBOOK.md +336 -0
  363. package/templates/community/open-prompt-showreel/README.md +33 -0
  364. package/templates/community/open-prompt-showreel/example/tla-races/facts.ts +145 -0
  365. package/templates/community/open-prompt-showreel/example/tla-races/facts.v3.json +140 -0
  366. package/templates/community/open-prompt-showreel/example/tla-races/music.mist-city.json +8 -0
  367. package/templates/community/open-prompt-showreel/example/tla-races/reel.html +805 -0
  368. package/templates/community/open-prompt-showreel/example/tla-races/smoke.sh +48 -0
  369. package/templates/community/open-prompt-showreel/lead-prompt.md +89 -0
  370. package/templates/community/open-prompt-showreel/setup.sh +167 -0
  371. package/templates/community/open-prompt-showreel/skills/motion-design-replication/SKILL.md +85 -0
  372. package/templates/community/open-prompt-showreel/skills/motion-design-video-analysis/SKILL.md +115 -0
  373. package/templates/community/open-prompt-showreel/skills/open-prompt-showreel/SKILL.md +147 -0
  374. package/templates/community/open-prompt-showreel/skills/video-generation/SKILL.md +195 -0
  375. package/templates/community/open-prompt-showreel/tools/fetch-music.sh +65 -0
  376. package/templates/community/open-prompt-showreel/tools/music-analyze.py +69 -0
  377. package/templates/community/open-prompt-showreel/tools/music-current.sh +34 -0
  378. package/templates/community/open-prompt-showreel/tools/music-cut.sh +36 -0
  379. package/templates/community/open-prompt-showreel/tools/music-refine.py +39 -0
  380. package/templates/community/open-prompt-showreel/tools/render.mjs +157 -0
  381. package/templates/community/open-prompt-showreel/tools/sheet.sh +44 -0
  382. package/templates/community/open-prompt-showreel/tools/web-compress.sh +17 -0
  383. package/templates/community/open-prompt-showreel/tools/x-reencode.sh +21 -0
  384. package/templates/extensions/README.md +1 -0
  385. package/templates/extensions/deploy-awareness/README.md +28 -0
  386. package/templates/extensions/deploy-awareness/hooks.ts +152 -0
  387. package/templates/extensions/deploy-awareness/manifest.json +8 -0
  388. package/templates/skills/memory/config.json +2 -2
  389. package/templates/skills/memory/content.md +59 -5
  390. package/templates/skills/swarm-extensions/config.json +1 -1
  391. package/templates/skills/swarm-extensions/content.md +28 -5
  392. package/tsconfig.json +3 -0
  393. package/dist/boot-seeds-gsetbs5y.js +0 -28
  394. package/dist/cli-j490egb5.js +0 -5632
  395. package/dist/cli-tjf4cn8z.js +0 -9119
  396. package/dist/cli-tmqt7dpj.js +0 -572
  397. package/dist/dsh-adapter-mpnzgztj.js +0 -19
  398. package/dist/index-7aj368tw.js +0 -30
@@ -7,6 +7,8 @@ import { CANDIDATE_SET_MULTIPLIER } from "../be/memory/constants";
7
7
  import { listEdgesForAgent } from "../be/memory/edges-store";
8
8
  import { expandCandidatesWithGraph } from "../be/memory/graph-expansion";
9
9
  import { indexMemoryContent } from "../be/memory/index-content";
10
+ import { MemoryKeyError } from "../be/memory/key-guard";
11
+ import { MEMORY_KEY_MAX_LENGTH } from "../be/memory/key-paths";
10
12
  import { refreshLinks } from "../be/memory/link-resolver";
11
13
  import { getLinksForMemory, type MemoryLinksResult } from "../be/memory/links-store";
12
14
  import {
@@ -16,6 +18,7 @@ import {
16
18
  } from "../be/memory/raters/retrieval";
17
19
  import { applyRating, ExplicitSelfDuplicateError } from "../be/memory/raters/store";
18
20
  import {
21
+ RATING_MODEL_MAX_LENGTH,
19
22
  type RatingEvent,
20
23
  REFERENCES_SOURCE_MAX_LENGTH,
21
24
  sanitizeReferencesSource,
@@ -26,7 +29,7 @@ import { getUsefulnessStats } from "../be/memory/usefulness-stats";
26
29
  import { shouldPersistAutomaticTaskMemory } from "../memory/automatic-task-gate";
27
30
  import { buildRecallQuery } from "../memory/recall-query";
28
31
  import { memoryRelevance, SIMILARITY_THRESHOLD } from "../prompts/memories";
29
- import { can } from "../rbac";
32
+ import { can, type RbacPrincipal } from "../rbac";
30
33
  import { AgentMemorySchema, AgentMemoryScopeSchema, AgentMemorySourceSchema } from "../types";
31
34
  import { getRequestAuth } from "../utils/request-auth-context";
32
35
  import { scrubSecrets } from "../utils/secret-scrubber";
@@ -56,6 +59,9 @@ const indexMemory = route({
56
59
  pattern: ["api", "memory", "index"],
57
60
  summary: "Ingest content into memory system (async embedding)",
58
61
  tags: ["Memory"],
62
+ // The gate only bites when the key that lands on the rows (here, `sourcePath`) sits under a
63
+ // lead-only /longterm root; every other ingest passes straight through.
64
+ rbac: { permission: "memory.write.consolidated" },
59
65
  body: z.object({
60
66
  agentId: z.string().optional(),
61
67
  content: z.string().min(1),
@@ -70,7 +76,13 @@ const indexMemory = route({
70
76
  }),
71
77
  responses: {
72
78
  202: { description: "Content queued for embedding", schema: IndexMemoryResponseSchema },
73
- 400: { description: "Validation error" },
79
+ 400: {
80
+ description:
81
+ "Validation error, or a sourcePath under /longterm that is not an allowed memory key",
82
+ },
83
+ 403: {
84
+ description: "sourcePath is under a lead-only /longterm root and the caller is not the lead",
85
+ },
74
86
  },
75
87
  });
76
88
 
@@ -107,6 +119,14 @@ const searchMemory = route({
107
119
  limit: z.number().int().min(1).max(20).default(5),
108
120
  scope: z.enum(["agent", "swarm", "all"]).default("all"),
109
121
  source: z.enum(["manual", "file_index", "session_summary", "task_completion"]).optional(),
122
+ keyPrefix: z
123
+ .string()
124
+ .min(1)
125
+ .max(MEMORY_KEY_MAX_LENGTH)
126
+ .optional()
127
+ .describe(
128
+ "Only return memories whose key starts with this text (literal, case-sensitive), for example '/longterm/facts/'.",
129
+ ),
110
130
  }),
111
131
  responses: {
112
132
  200: {
@@ -496,6 +516,15 @@ const RateEventSchema = z.object({
496
516
  reasoning: z.string().max(500).optional(),
497
517
  taskId: z.string().uuid().optional(),
498
518
  referencesSource: ReferencesSourceSchema.optional(),
519
+ model: z
520
+ .string()
521
+ .trim()
522
+ .min(1)
523
+ .max(RATING_MODEL_MAX_LENGTH)
524
+ .optional()
525
+ .describe(
526
+ 'Optional. Model that produced an `llm` rating, as "<provider>/<model-id>" (e.g. "openrouter/deepseek/deepseek-v4.1-flash"). Stored in memory_rating.model for `llm` events and ignored for `explicit-self`.',
527
+ ),
499
528
  });
500
529
 
501
530
  const rateMemory = route({
@@ -593,6 +622,27 @@ const getMemoryEdges = route({
593
622
 
594
623
  // ─── Handler ─────────────────────────────────────────────────────────────────
595
624
 
625
+ /**
626
+ * Who is calling, in the terms `can()` takes, for the key gate on ingestion. A bound identity (an
627
+ * `aseph_` session token) is honoured as is; otherwise the self-declared X-Agent-ID, the trust model
628
+ * `ensureCatalogWriter` and `ensureConfigAdmin` use. A request with neither is the shared key alone
629
+ * (operator), and `memory.write.consolidated` is lead-only, so it cannot reach the lead-only roots.
630
+ */
631
+ async function ingestPrincipal(
632
+ req: IncomingMessage,
633
+ agentIdHeader: string | undefined,
634
+ ): Promise<RbacPrincipal> {
635
+ const auth = getRequestAuth(req);
636
+ if (auth?.kind === "user") return { kind: "user", userId: auth.userId };
637
+ const agentId = auth?.kind === "agent" ? auth.agentId : agentIdHeader;
638
+ if (agentId) {
639
+ const agent = await getAgentById(agentId);
640
+ return { kind: "agent", agentId, isLead: agent?.isLead ?? false };
641
+ }
642
+ if (auth?.kind === "operator") return { kind: "operator" };
643
+ return { kind: "agent", agentId: "", isLead: false };
644
+ }
645
+
596
646
  export async function handleMemory(
597
647
  req: IncomingMessage,
598
648
  res: ServerResponse,
@@ -638,18 +688,31 @@ export async function handleMemory(
638
688
  (Array.isArray(headerContextKey) ? headerContextKey[0] : headerContextKey) ??
639
689
  undefined;
640
690
 
641
- const { queued, memoryIds, edited } = await indexMemoryContent({
642
- agentId: memoryAgentId,
643
- content,
644
- name,
645
- scope,
646
- source,
647
- sourceTaskId,
648
- sourcePath,
649
- tags,
650
- contextKey: resolvedContextKey,
651
- });
691
+ let result: Awaited<ReturnType<typeof indexMemoryContent>>;
692
+ try {
693
+ result = await indexMemoryContent({
694
+ agentId: memoryAgentId,
695
+ content,
696
+ name,
697
+ scope,
698
+ source,
699
+ sourceTaskId,
700
+ sourcePath,
701
+ tags,
702
+ contextKey: resolvedContextKey,
703
+ // The caller, not the memory's owner (`agentId` in the body can name another agent).
704
+ writer: { principal: await ingestPrincipal(req, myAgentId), source: "http" },
705
+ });
706
+ } catch (err) {
707
+ // sourcePath doubles as the key, so it is held to the same checks as memory-store's `key`.
708
+ if (err instanceof MemoryKeyError) {
709
+ jsonError(res, err.message, err.reason === "forbidden" ? 403 : 400);
710
+ return true;
711
+ }
712
+ throw err;
713
+ }
652
714
 
715
+ const { queued, memoryIds, edited } = result;
653
716
  indexMemory.respond(res, 202, {
654
717
  queued,
655
718
  memoryIds,
@@ -667,7 +730,7 @@ export async function handleMemory(
667
730
  const parsed = await searchMemory.parse(req, res, pathSegments, new URLSearchParams());
668
731
  if (!parsed) return true;
669
732
 
670
- const { query: originalQuery, intent, limit, scope, source } = parsed.body;
733
+ const { query: originalQuery, intent, limit, scope, source, keyPrefix } = parsed.body;
671
734
  const consumptionHeader = req.headers["x-memory-consumption"];
672
735
  const consumptionMode = Array.isArray(consumptionHeader)
673
736
  ? consumptionHeader[0]
@@ -691,12 +754,14 @@ export async function handleMemory(
691
754
  source,
692
755
  isLead: false,
693
756
  queryText: query,
757
+ keyPrefix,
694
758
  });
695
759
  // Default-on 1-hop memory_link neighbor expansion (disable with
696
760
  // MEMORY_GRAPH_EXPANSION=0|false).
697
761
  const expanded = await expandCandidatesWithGraph(candidates, myAgentId, {
698
762
  scope,
699
763
  source,
764
+ keyPrefix,
700
765
  isLead: false,
701
766
  });
702
767
  const resultLimit = Math.min(limit, 20);
@@ -1095,6 +1160,7 @@ export async function handleMemory(
1095
1160
  source: e.source,
1096
1161
  reasoning: e.reasoning,
1097
1162
  ...(e.referencesSource !== undefined ? { referencesSource: e.referencesSource } : {}),
1163
+ ...(e.model !== undefined ? { model: e.model } : {}),
1098
1164
  }));
1099
1165
  const rateContextKeyHeader = req.headers["x-context-key"];
1100
1166
  const rateContextKey = Array.isArray(rateContextKeyHeader)
@@ -128,10 +128,27 @@ function memoryErrorStatus(error: unknown): number | undefined {
128
128
  return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
129
129
  }
130
130
 
131
+ /**
132
+ * A 404 names the model or deployment only when the provider says so: OpenAI
133
+ * answers `model_not_found`, Azure `DeploymentNotFound`. A bare 404 (Azure's
134
+ * `Resource not found`, a proxy page) means the path itself does not exist.
135
+ */
136
+ function notFoundNamesModel(error: unknown): boolean {
137
+ if (typeof error !== "object" || error === null) return false;
138
+ const { code, type, error: body } = error as { code?: unknown; type?: unknown; error?: unknown };
139
+ const bodyMessage =
140
+ typeof body === "object" && body !== null ? (body as { message?: unknown }).message : undefined;
141
+ const text = [code, type, bodyMessage]
142
+ .filter((part): part is string => typeof part === "string")
143
+ .join(" ")
144
+ .toLowerCase();
145
+ return text.includes("model") || text.includes("deployment");
146
+ }
147
+
131
148
  function classifyMemoryError(error: unknown): OnboardingErrorClass {
132
149
  const status = memoryErrorStatus(error);
133
150
  if (status === 401 || status === 403) return "auth";
134
- if (status === 404) return "model";
151
+ if (status === 404) return notFoundNamesModel(error) ? "model" : "endpoint";
135
152
  if (status === 408) return "timeout";
136
153
  const text =
137
154
  error instanceof Error
@@ -157,7 +174,9 @@ function memoryErrorMessage(errorClass: OnboardingErrorClass, status?: number):
157
174
  case "auth":
158
175
  return `The endpoint rejected the key${statusSuffix}.`;
159
176
  case "model":
160
- return `The endpoint could not find the embedding model${statusSuffix}.`;
177
+ return `The endpoint could not find the embedding model or deployment${statusSuffix}.`;
178
+ case "endpoint":
179
+ return `The endpoint path was not found${statusSuffix}. Check the base URL.`;
161
180
  case "timeout":
162
181
  return "The endpoint timed out.";
163
182
  case "network":
package/src/http/poll.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { IncomingMessage, ServerResponse } from "node:http";
2
2
  import { ensure } from "@desplega.ai/business-use";
3
3
  import { z } from "zod";
4
+ import { isApiDraining } from "../be/api-drain";
4
5
  import { canClaim } from "../be/budget-admission";
5
6
  import {
6
7
  type BudgetRefusalContext,
@@ -37,7 +38,7 @@ import { poolTaskRunsOnHarness } from "../be/model-validation";
37
38
  import { touchRuntimeInstance } from "../be/multi-runtime";
38
39
  import { hasCapability } from "../server";
39
40
  import { fetchChannelActivity } from "../slack/channel-activity";
40
- import { telemetry } from "../telemetry";
41
+ import { emitTaskTelemetry, resolveTriggerSurface } from "../telemetry-trigger";
41
42
  import {
42
43
  AgentTaskSchema,
43
44
  BudgetRefusedTriggerSchema,
@@ -123,6 +124,9 @@ const PollTaskOfferedTriggerSchema = z.object({
123
124
  const PollTaskAssignedTriggerSchema = z.object({
124
125
  type: z.literal("task_assigned"),
125
126
  taskId: z.string(),
127
+ // Surface that started the whole task chain (root task's source, mapped to
128
+ // the telemetry catalog). Workers tag their session telemetry with it.
129
+ triggerSurface: z.string().optional(),
126
130
  task: AgentTaskSchema.extend({
127
131
  attachments: z.array(PollTriggerAttachmentSchema),
128
132
  }),
@@ -172,6 +176,9 @@ const pollTriggers = route({
172
176
  path: "/api/poll",
173
177
  pattern: ["api", "poll"],
174
178
  summary: "Poll for triggers (tasks, mentions)",
179
+ description:
180
+ "While the API is draining after SIGTERM it dispatches nothing: the answer is `{ trigger: null }` " +
181
+ "and carries `X-Swarm-Draining: 1`, the signal for a worker to hand off in-flight tasks.",
175
182
  tags: ["Poll"],
176
183
  auth: { apiKey: true, agentId: true },
177
184
  headers: runtimeInstanceHeader("poll for work").extend({
@@ -369,6 +376,13 @@ export async function handlePoll(
369
376
  return { trigger: null };
370
377
  }
371
378
 
379
+ // A draining API dispatches nothing: offers, assignments and pool claims
380
+ // wait for the next API. Workers learn to hand off from the
381
+ // X-Swarm-Draining header the HTTP pipeline adds (src/be/api-drain.ts).
382
+ if (isApiDraining()) {
383
+ return { trigger: null };
384
+ }
385
+
372
386
  // Check for offered tasks first (highest priority for both workers and leads)
373
387
  // Atomically claim the task for review to prevent duplicate processing.
374
388
  // Capacity is checked in the same transaction as the claim: with
@@ -470,7 +484,7 @@ export async function handlePoll(
470
484
  conditions: [{ timeout_ms: 300_000 }], // 5 min: polling interval + queue wait
471
485
  });
472
486
 
473
- telemetry.taskEvent("started", {
487
+ void emitTaskTelemetry("started", {
474
488
  taskId: pendingTask.id,
475
489
  source: pendingTask.source,
476
490
  agentId: myAgentId,
@@ -480,11 +494,18 @@ export async function handlePoll(
480
494
  // Resolve requesting user if available (UNKNOWN sentinel handling
481
495
  // lives in buildTriggerRequestedBy).
482
496
  const assignedRequestedBy = await buildTriggerRequestedBy(pendingTask);
497
+ // The surface that started the whole chain, so the worker can tag
498
+ // its session events with it (workers cannot read the task tree).
499
+ const assignedTriggerSurface = await resolveTriggerSurface(
500
+ pendingTask.id,
501
+ pendingTask.source,
502
+ );
483
503
 
484
504
  return {
485
505
  trigger: {
486
506
  type: "task_assigned",
487
507
  taskId: pendingTask.id,
508
+ triggerSurface: assignedTriggerSurface,
488
509
  task: {
489
510
  ...pendingTask,
490
511
  ...(await claimModelFields(pendingTask, agent)),
@@ -612,17 +633,22 @@ export async function handlePoll(
612
633
  // Post-commit (see the `started` path above): a rolled-back
613
634
  // claim must not report the task as claimed.
614
635
  getDbClient().afterCommit(() => {
615
- telemetry.taskEvent("claimed", {
636
+ void emitTaskTelemetry("claimed", {
616
637
  taskId: claimed.id,
617
638
  source: claimed.source,
618
639
  agentId: myAgentId,
619
640
  });
620
641
  });
621
642
  const claimedRequestedBy = await buildTriggerRequestedBy(claimed);
643
+ const claimedTriggerSurface = await resolveTriggerSurface(
644
+ claimed.id,
645
+ claimed.source,
646
+ );
622
647
  return {
623
648
  trigger: {
624
649
  type: "task_assigned",
625
650
  taskId: claimed.id,
651
+ triggerSurface: claimedTriggerSurface,
626
652
  task: {
627
653
  ...claimed,
628
654
  ...(await claimModelFields(claimed, agent)),
@@ -672,6 +698,7 @@ export async function handlePoll(
672
698
  // Throttled to avoid Slack API rate limits (~50 calls/min).
673
699
  if (
674
700
  result.trigger === null &&
701
+ !isApiDraining() &&
675
702
  process.env.LEAD_MONITOR_CHANNELS === "true" &&
676
703
  Date.now() - lastChannelActivityCheckAt >= CHANNEL_ACTIVITY_INTERVAL_MS
677
704
  ) {
@@ -1,6 +1,29 @@
1
1
  import type { IncomingMessage, ServerResponse } from "node:http";
2
+ import { z } from "zod";
3
+ import { getCombConfig } from "../comb/config";
4
+ import { can } from "../rbac";
2
5
  import bundle from "../realtime/browser.generated.txt" with { type: "text" };
6
+ import { issueRealtimeTicket } from "../realtime/tickets";
7
+ import { getRequestAuth } from "../utils/request-auth-context";
3
8
  import { route } from "./route-def";
9
+ import { jsonError } from "./utils";
10
+
11
+ const realtimeTicketRoute = route({
12
+ method: "post",
13
+ path: "/api/realtime/ticket",
14
+ pattern: ["api", "realtime", "ticket"],
15
+ summary: "Issue a one-shot dashboard realtime ticket",
16
+ tags: ["Rooms"],
17
+ rbac: { permission: "comb.presence" },
18
+ responses: {
19
+ 200: {
20
+ description: "One-shot realtime ticket",
21
+ schema: z.object({ ticket: z.string(), expiresAt: z.number().int() }),
22
+ },
23
+ 403: { description: "Comb presence is not allowed" },
24
+ 404: { description: "Comb is not enabled" },
25
+ },
26
+ });
4
27
 
5
28
  route({
6
29
  method: "get",
@@ -14,6 +37,45 @@ route({
14
37
  },
15
38
  });
16
39
 
40
+ /** `POST /api/realtime/ticket`: a one-shot ticket for a dashboard realtime socket (Comb presence). */
41
+ export async function handleRealtimeTicket(
42
+ req: IncomingMessage,
43
+ res: ServerResponse,
44
+ pathSegments: string[],
45
+ queryParams: URLSearchParams,
46
+ ): Promise<boolean> {
47
+ if (!realtimeTicketRoute.match(req.method, pathSegments)) return false;
48
+ // Comb presence is the only ticket consumer, so the route is off with Comb.
49
+ if (!getCombConfig().enabled) {
50
+ jsonError(res, "Comb is not enabled", 404);
51
+ return true;
52
+ }
53
+ const parsed = await realtimeTicketRoute.parse(req, res, pathSegments, queryParams);
54
+ if (!parsed) return true;
55
+ const auth = getRequestAuth(req);
56
+ if (!auth || auth.kind === "agent") {
57
+ jsonError(res, "Comb presence requires dashboard authentication", 403);
58
+ return true;
59
+ }
60
+ const principal =
61
+ auth.kind === "operator"
62
+ ? ({ kind: "operator" } as const)
63
+ : ({ kind: "user", userId: auth.userId } as const);
64
+ if (
65
+ !can({
66
+ principal,
67
+ verb: "comb.presence",
68
+ resource: { kind: "none" },
69
+ source: "http",
70
+ }).allow
71
+ ) {
72
+ jsonError(res, "Comb presence requires the comb.presence permission", 403);
73
+ return true;
74
+ }
75
+ realtimeTicketRoute.respond(res, 200, issueRealtimeTicket(auth));
76
+ return true;
77
+ }
78
+
17
79
  export async function handleRealtimeAsset(
18
80
  req: IncomingMessage,
19
81
  res: ServerResponse,
@@ -0,0 +1,22 @@
1
+ import type { IncomingMessage } from "node:http";
2
+ import { getAgentById } from "../be/db";
3
+ import type { RbacPrincipal } from "../rbac";
4
+ import { getRequestAuth } from "../utils/request-auth-context";
5
+
6
+ /**
7
+ * The RBAC principal of an HTTP request, for a handler-side `can()` check.
8
+ * Operator and user request auth win over the X-Agent-ID header (an operator
9
+ * bearer with any agent id stays the operator). An agent id that is not
10
+ * registered is a non-lead agent. Null when the request has neither.
11
+ */
12
+ export async function requestPrincipal(
13
+ req: IncomingMessage,
14
+ myAgentId: string | undefined,
15
+ ): Promise<RbacPrincipal | null> {
16
+ const auth = getRequestAuth(req);
17
+ if (auth?.kind === "operator") return { kind: "operator" };
18
+ if (auth?.kind === "user") return { kind: "user", userId: auth.userId };
19
+ if (!myAgentId) return null;
20
+ const agent = await getAgentById(myAgentId);
21
+ return { kind: "agent", agentId: myAgentId, isLead: agent?.isLead ?? false };
22
+ }
@@ -376,13 +376,15 @@ export async function handleSessionData(
376
376
  : (parsed.body.cacheWriteTokens ?? 0);
377
377
 
378
378
  // Keep the adapter's report even when the pricing-table branch replaces
379
- // totalCostUsd with the server's canonical recomputation.
380
- const harnessCostUsd = parsed.body.totalCostUsd;
379
+ // totalCostUsd with the server's canonical recomputation. Harnesses that
380
+ // report tokens but no money (dsh, acp) post 0; storing that as their
381
+ // cost would make every recomputed row read as a 100% drift.
382
+ const harnessCostUsd = parsed.body.totalCostUsd > 0 ? parsed.body.totalCostUsd : null;
381
383
  const recomputed = await recomputeSessionCost(
382
384
  {
383
385
  provider: parsed.body.provider,
384
386
  model,
385
- harnessCostUsd,
387
+ harnessCostUsd: parsed.body.totalCostUsd,
386
388
  inputTokens,
387
389
  outputTokens,
388
390
  cacheReadTokens: cachedInputTokens,
@@ -423,7 +425,7 @@ export async function handleSessionData(
423
425
  });
424
426
  recordSessionCost({
425
427
  totalCostUsd,
426
- harnessCostUsd,
428
+ harnessCostUsd: harnessCostUsd ?? undefined,
427
429
  harness: parsed.body.provider ?? "unknown",
428
430
  model,
429
431
  costSource,
package/src/http/stats.ts CHANGED
@@ -85,6 +85,7 @@ const SwarmMetricsSchema = z.object({
85
85
  sessionLogs: RetentionTableStatsSchema.optional(),
86
86
  agentLog: RetentionTableStatsSchema.optional(),
87
87
  events: RetentionTableStatsSchema.optional(),
88
+ contextVersions: RetentionTableStatsSchema.optional(),
88
89
  }),
89
90
  });
90
91
 
@@ -34,6 +34,8 @@ import {
34
34
  NOT_EXTENSION_AGENT_SQL,
35
35
  } from "../be/db";
36
36
  import { getEmbeddingProvider } from "../be/memory";
37
+ import { getCombServiceUserId } from "../comb/agent-fs";
38
+ import { getCombConfig } from "../comb/config";
37
39
  import { getFileStorageProvider } from "../fs/registry";
38
40
  import { getSlackConfiguration } from "../slack/config";
39
41
  import { getSlackConnectionState } from "../slack/connection-state";
@@ -120,6 +122,16 @@ export const StatusActivitySchema = z.object({
120
122
  });
121
123
  export type StatusActivity = z.infer<typeof StatusActivitySchema>;
122
124
 
125
+ export const StatusCombSchema = z.object({
126
+ enabled: z.boolean(),
127
+ api_url: z.string().nullable(),
128
+ live_url: z.string(),
129
+ org_id: z.string().nullable(),
130
+ drive_id: z.string().nullable(),
131
+ /** agent-fs user id of the swarm service account, which writes Comb's "sent" replies. */
132
+ service_user_id: z.string().nullable(),
133
+ });
134
+
123
135
  /**
124
136
  * Effective telemetry opt-out state (`ANONYMIZED_TELEMETRY`, on by default).
125
137
  * The dashboard reads it to stop its own browser-side notification events when
@@ -135,6 +147,8 @@ export const StatusAgentFsSchema = z.object({
135
147
  base_url: z.string().nullable(),
136
148
  provider_id: z.string(),
137
149
  capabilities: z.record(z.string(), z.unknown()),
150
+ /** Comb, the agent-fs review space in the dashboard. */
151
+ comb: StatusCombSchema,
138
152
  });
139
153
  export type StatusAgentFs = z.infer<typeof StatusAgentFsSchema>;
140
154
 
@@ -686,6 +700,10 @@ export function computeHealth(setup: SetupMilestone[]): StatusHealth {
686
700
  // ─── Public payload builder (also exported for tests) ────────────────────────
687
701
 
688
702
  export async function buildStatusPayload(): Promise<StatusResponse> {
703
+ // step-9: the agent-fs identity lookup (at most 2 s) runs while the DB work below does.
704
+ const combServiceUserId = getCombConfig().enabled
705
+ ? getCombServiceUserId()
706
+ : Promise.resolve(null);
689
707
  const automationSetup = await getAutomationSetupStates();
690
708
  const setup = await buildSetup(automationSetup);
691
709
  const automationInputs = await listEnabledAutomationPreflightInputs();
@@ -694,14 +712,16 @@ export async function buildStatusPayload(): Promise<StatusResponse> {
694
712
  const automations: AutomationStatus[] = automationInputs
695
713
  .map((automation) => toStatus(preflightAutomation(automation, automationSetup)))
696
714
  .sort((a, b) => a.name.localeCompare(b.name) || a.kind.localeCompare(b.kind));
715
+ const activity = await getInstanceActivity();
697
716
  return {
698
717
  identity: buildIdentity(),
699
718
  setup,
700
- activity: await getInstanceActivity(),
719
+ activity,
701
720
  agent_fs: {
702
721
  configured: !!process.env.AGENT_FS_API_URL,
703
722
  base_url: process.env.AGENT_FS_API_URL ?? null,
704
723
  ...getAgentFsStatusProvider(),
724
+ comb: getCombStatus(await combServiceUserId),
705
725
  },
706
726
  automations,
707
727
  health: computeHealth(setup),
@@ -709,6 +729,18 @@ export async function buildStatusPayload(): Promise<StatusResponse> {
709
729
  };
710
730
  }
711
731
 
732
+ function getCombStatus(serviceUserId: string | null): StatusAgentFs["comb"] {
733
+ const comb = getCombConfig();
734
+ return {
735
+ enabled: comb.enabled,
736
+ api_url: comb.apiUrl,
737
+ live_url: comb.liveUrl,
738
+ org_id: comb.orgId,
739
+ drive_id: comb.driveId,
740
+ service_user_id: comb.enabled ? serviceUserId : null,
741
+ };
742
+ }
743
+
712
744
  function getAgentFsStatusProvider(): {
713
745
  provider_id: string;
714
746
  capabilities: Record<string, unknown>;
@@ -735,7 +767,7 @@ const getStatus = route({
735
767
  pattern: ["status"],
736
768
  summary: "Identity + setup readiness + live activity for the swarm dashboard",
737
769
  description:
738
- "Single source of truth consumed by the UI home page. Identity comes from SWARM_* envs; setup milestones each emit `unverified | configured | verified`; automations report `running | needs_setup` from the same runtime preflight used at dispatch; activity counts agents alive in the last 5 min and tasks created in the last 24h; agent_fs reports whether AGENT_FS_API_URL is set; telemetry reports the effective ANONYMIZED_TELEMETRY opt-out state.",
770
+ "Single source of truth consumed by the UI home page. Identity comes from SWARM_* envs; setup milestones each emit `unverified | configured | verified`; automations report `running | needs_setup` from the same runtime preflight used at dispatch; activity counts agents alive in the last 5 min and tasks created in the last 24h; agent_fs reports whether AGENT_FS_API_URL is set, plus the Comb settings (COMB_ENABLED, the browser-facing agent-fs URL, the shared org and drive ids, and the agent-fs user id of the swarm service account); telemetry reports the effective ANONYMIZED_TELEMETRY opt-out state.",
739
771
  tags: ["Status"],
740
772
  responses: {
741
773
  200: { description: "Status payload", schema: StatusResponseSchema },
package/src/http/tasks.ts CHANGED
@@ -26,6 +26,7 @@ import {
26
26
  markSteeringHandled,
27
27
  pauseTask,
28
28
  promoteDraftTask,
29
+ recordTaskProviderIfUnset,
29
30
  resumeTask,
30
31
  settleSupersededTaskDependents,
31
32
  supersedeTask,
@@ -542,7 +543,10 @@ const updateTaskProgressRoute = route({
542
543
  params: z.object({ id: z.string() }),
543
544
  body: z.object({ progress: z.string().min(1) }),
544
545
  responses: {
545
- 200: { description: "Progress updated", schema: z.object({ success: z.literal(true) }) },
546
+ 200: {
547
+ description: "Progress updated; a no-op once the task is terminal",
548
+ schema: z.object({ success: z.literal(true) }),
549
+ },
546
550
  403: { description: "Task is assigned to another agent" },
547
551
  404: { description: "Task not found" },
548
552
  },
@@ -560,6 +564,8 @@ const finishTask = route({
560
564
  output: z.string().optional(),
561
565
  failureReason: z.string().optional(),
562
566
  force: z.boolean().optional(),
567
+ /** Harness that ran the task. Recorded only when no session reported one (spawn failure). */
568
+ provider: ProviderNameSchema.optional(),
563
569
  }),
564
570
  auth: { apiKey: true, agentId: true },
565
571
  responses: {
@@ -651,7 +657,7 @@ const updateTaskVcsRoute = route({
651
657
  tags: ["Tasks"],
652
658
  params: z.object({ id: z.string() }),
653
659
  body: z.object({
654
- vcsProvider: z.enum(["github", "gitlab"]),
660
+ vcsProvider: z.enum(["github", "gitlab", "azure-devops"]),
655
661
  vcsRepo: z.string(),
656
662
  vcsNumber: z.number().int().positive(),
657
663
  vcsUrl: z.string().url(),
@@ -1423,7 +1429,11 @@ export async function handleTasks(
1423
1429
  source: "http",
1424
1430
  });
1425
1431
  if (!decision.allow) return 403;
1426
- await updateTaskProgress(parsed.params.id, parsed.body.progress);
1432
+ // A harness keeps streaming after the agent finishes the task; its
1433
+ // late progress must not overwrite a terminal task's last line.
1434
+ if (!isTerminalTaskStatus(task.status)) {
1435
+ await updateTaskProgress(parsed.params.id, parsed.body.progress);
1436
+ }
1427
1437
  return 200;
1428
1438
  });
1429
1439
 
@@ -1516,6 +1526,10 @@ export async function handleTasks(
1516
1526
 
1517
1527
  const wasPaused = task.wasPaused;
1518
1528
 
1529
+ if (parsed.body.provider && !task.provider) {
1530
+ await recordTaskProviderIfUnset(parsed.params.id, parsed.body.provider);
1531
+ }
1532
+
1519
1533
  let updatedTask: typeof task;
1520
1534
  if (parsed.body.status === "completed") {
1521
1535
  const result = await completeTask(
package/src/http/users.ts CHANGED
@@ -460,7 +460,7 @@ const deleteIdentityRoute = route({
460
460
 
461
461
  // ─── Helpers ─────────────────────────────────────────────────────────────────
462
462
 
463
- const UNMAPPED_KINDS = ["slack", "github", "gitlab", "linear", "kapso"] as const;
463
+ const UNMAPPED_KINDS = ["slack", "github", "gitlab", "azure-devops", "linear", "kapso"] as const;
464
464
 
465
465
  /**
466
466
  * Group the two-key-per-identity kv entries (`<externalId>:meta` json +