@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
@@ -28,6 +28,7 @@ import type { User } from "../types";
28
28
  import { setRequestAuth } from "../utils/request-auth-context";
29
29
  import { refreshSecretScrubberCache } from "../utils/secret-scrubber";
30
30
  import {
31
+ type BundleFixture,
31
32
  loadBundleFixture,
32
33
  resetFixtureCatalog,
33
34
  useFixtureCatalog,
@@ -126,6 +127,19 @@ async function install(
126
127
  });
127
128
  }
128
129
 
130
+ async function installInline(
131
+ bundle: BundleFixture,
132
+ agentId?: string,
133
+ asUser?: string,
134
+ ): Promise<TestResponse> {
135
+ return dispatch("/api/extensions/install", {
136
+ method: "POST",
137
+ agentId,
138
+ asUser,
139
+ body: JSON.stringify({ manifest: bundle.manifest, files: bundle.files }),
140
+ });
141
+ }
142
+
129
143
  /** Replace the `minimal` catalog entry with a changed hooks file, as a new template release would. */
130
144
  async function useChangedMinimal(suffix: string): Promise<void> {
131
145
  const bundle = await loadBundleFixture("minimal");
@@ -176,6 +190,7 @@ beforeEach(async () => {
176
190
  await stopExtensionRuntime();
177
191
  await getDbClient().run("DELETE FROM extensions");
178
192
  await useFixtureCatalog(CATALOG_FIXTURES);
193
+ delete process.env.EXTENSION_ALLOW_INLINE_INSTALL;
179
194
  });
180
195
 
181
196
  describe("/api/extensions HTTP", () => {
@@ -654,21 +669,133 @@ export default extension;
654
669
  expect((await (await dispatch("/api/extensions")).json()).extensions).toEqual([]);
655
670
  });
656
671
 
657
- test("inline bundles are rejected before anything is stored", async () => {
672
+ test("inline bundles are rejected for every caller while the flag is off", async () => {
658
673
  const bundle = await loadBundleFixture("minimal");
659
- for (const body of [bundle, { template: "minimal", files: bundle.files }]) {
660
- const response = await dispatch("/api/extensions/install", {
661
- method: "POST",
662
- body: JSON.stringify(body),
663
- });
664
- expect(response.status).toBe(400);
665
- const json = await response.json();
666
- expect(json.error).toBe("inline_install_disabled");
667
- expect(json.message).toContain("template");
674
+ const bodies = [bundle, { template: "minimal", files: bundle.files }];
675
+ for (const flag of [undefined, "false"]) {
676
+ if (flag === undefined) delete process.env.EXTENSION_ALLOW_INLINE_INSTALL;
677
+ else process.env.EXTENSION_ALLOW_INLINE_INSTALL = flag;
678
+ for (const agentId of [undefined, leadId, workerId]) {
679
+ for (const body of bodies) {
680
+ const response = await dispatch("/api/extensions/install", {
681
+ method: "POST",
682
+ agentId,
683
+ body: JSON.stringify(body),
684
+ });
685
+ expect(response.status).toBe(400);
686
+ const json = await response.json();
687
+ expect(json.error).toBe("inline_install_disabled");
688
+ expect(json.message).toContain("EXTENSION_ALLOW_INLINE_INSTALL");
689
+ expect(json.message).toContain("template");
690
+ }
691
+ }
668
692
  }
669
693
  expect(await getExtensionByName("minimal")).toBeNull();
670
694
  });
671
695
 
696
+ test("with the flag on, a lead installs an inline bundle that lands disabled and stays staged on update", async () => {
697
+ process.env.EXTENSION_ALLOW_INLINE_INSTALL = "true";
698
+ const bundle = await loadBundleFixture("with-assets");
699
+ const installed = await installInline(bundle, leadId);
700
+ expect(installed.status).toBe(200);
701
+ const body = await installed.json();
702
+ expect(body.extension).toMatchObject({
703
+ name: "with-assets",
704
+ enabled: false,
705
+ status: "disabled",
706
+ version: 1,
707
+ createdByAgentId: leadId,
708
+ });
709
+ expect(body.assets).toMatchObject({
710
+ created: expect.arrayContaining([
711
+ { kind: "script", name: "with-assets-echo" },
712
+ { kind: "schedule", name: "with-assets-hourly" },
713
+ ]),
714
+ });
715
+ // Not a catalog template: only the fixtures registered in beforeEach are listed.
716
+ const catalog = (await (await dispatch("/api/extensions/catalog")).json()).extensions as Array<{
717
+ name: string;
718
+ }>;
719
+ expect(catalog.map((item) => item.name)).not.toContain("with-assets");
720
+
721
+ // Enabling goes through the existing path: a human enable activates the inline bundle.
722
+ const id = (body.extension as { id: string }).id;
723
+ expect((await dispatch(`/api/extensions/${id}/enable`, { method: "POST" })).status).toBe(200);
724
+ expect(await getExtensionByName("with-assets")).toMatchObject({ enabled: true });
725
+
726
+ // A lead's inline update of the enabled extension is stored but never goes live.
727
+ bundle.files["hooks.ts"] += "\n// updated inline by a lead\n";
728
+ const updated = await installInline(bundle, leadId);
729
+ expect(updated.status).toBe(200);
730
+ expect((await updated.json()).extension).toMatchObject({
731
+ version: 2,
732
+ activeVersion: 1,
733
+ enabled: true,
734
+ });
735
+
736
+ // The script and schedule live outside the extensions table: remove them with the extension.
737
+ expect((await dispatch(`/api/extensions/${id}/disable`, { method: "POST" })).status).toBe(200);
738
+ expect((await dispatch(`/api/extensions/${id}`, { method: "DELETE" })).status).toBe(200);
739
+ });
740
+
741
+ test("with the flag on, operators and dashboard users install inline and workers get 403", async () => {
742
+ process.env.EXTENSION_ALLOW_INLINE_INSTALL = "true";
743
+ const minimal = await loadBundleFixture("minimal");
744
+ const postLogger = await loadBundleFixture("post-logger");
745
+ expect((await installInline(minimal)).status).toBe(200);
746
+ expect((await installInline(postLogger, undefined, "user-1")).status).toBe(200);
747
+ expect(await getExtensionByName("minimal")).toMatchObject({ enabled: false });
748
+ expect(await getExtensionByName("post-logger")).toMatchObject({ enabled: false });
749
+ await getDbClient().run("DELETE FROM extensions");
750
+
751
+ const denied = await installInline(minimal, workerId);
752
+ expect(denied.status).toBe(403);
753
+ expect(denied.text).toContain("lead agent, operator, or user");
754
+ expect(await getExtensionByName("minimal")).toBeNull();
755
+
756
+ // A worker may update its own catalog draft, but not by sending code inline.
757
+ expect((await install("minimal", workerId)).status).toBe(200);
758
+ minimal.files["hooks.ts"] += "\n// worker inline update\n";
759
+ expect((await installInline(minimal, workerId)).status).toBe(403);
760
+ expect(await getExtensionByName("minimal")).toMatchObject({ version: 1 });
761
+ });
762
+
763
+ test("with the flag on, inline installs reject malformed bodies and run the catalog validation", async () => {
764
+ process.env.EXTENSION_ALLOW_INLINE_INSTALL = "true";
765
+ const minimal = await loadBundleFixture("minimal");
766
+ const post = async (body: unknown) =>
767
+ dispatch("/api/extensions/install", { method: "POST", body: JSON.stringify(body) });
768
+
769
+ const both = await post({ template: "minimal", ...minimal });
770
+ expect(both.status).toBe(400);
771
+ expect(both.text).toContain("mutually exclusive");
772
+ const noFiles = await post({ manifest: minimal.manifest });
773
+ expect(noFiles.status).toBe(400);
774
+ expect(noFiles.text).toContain("files is required");
775
+ const empty = await post({});
776
+ expect(empty.status).toBe(400);
777
+ expect(empty.text).toContain("provide either template");
778
+
779
+ const extra = await installInline({
780
+ manifest: minimal.manifest,
781
+ files: { ...minimal.files, "stray.ts": "export {};" },
782
+ });
783
+ expect(extra.status).toBe(400);
784
+ expect(((await extra.json()).diagnostics as string[]).join("\n")).toContain("stray.ts");
785
+ const badImport = await installInline(await loadBundleFixture("bad-import"));
786
+ expect(badImport.status).toBe(400);
787
+ const diagnostics = (await badImport.json()).diagnostics as string[];
788
+ expect(diagnostics.join("\n")).toContain("node:fs");
789
+ expect((await dispatch("/api/extensions")).text).not.toContain("bad-import");
790
+ });
791
+
792
+ test("with the flag on, catalog installs behave as before", async () => {
793
+ process.env.EXTENSION_ALLOW_INLINE_INSTALL = "true";
794
+ expect((await install("minimal", workerId)).status).toBe(200);
795
+ expect(await getExtensionByName("minimal")).toMatchObject({ createdByAgentId: workerId });
796
+ expect((await install("not-in-catalog", leadId)).status).toBe(404);
797
+ });
798
+
672
799
  test("unknown templates return 404", async () => {
673
800
  const response = await install("not-in-catalog");
674
801
  expect(response.status).toBe(404);
@@ -177,6 +177,7 @@ beforeEach(async () => {
177
177
  await stopExtensionRuntime();
178
178
  await getDbClient().run("DELETE FROM extensions");
179
179
  await useFixtureCatalog(["minimal", "post-logger"]);
180
+ delete process.env.EXTENSION_ALLOW_INLINE_INSTALL;
180
181
  });
181
182
 
182
183
  describe("extension MCP HTTP proxy tools", () => {
@@ -186,6 +187,7 @@ describe("extension MCP HTTP proxy tools", () => {
186
187
  export default async (_args: unknown, ctx: ScriptContext) => {
187
188
  await ctx.swarm.extension_catalog({});
188
189
  await ctx.swarm.extension_install({ template: "minimal", config: { label: "a" } });
190
+ await ctx.swarm.extension_install({ manifest: {}, files: { "hooks.ts": "" } });
189
191
  const id = "00000000-0000-4000-8000-000000000001";
190
192
  await ctx.swarm.extension_enable({ id });
191
193
  await ctx.swarm.extension_activate_version({ id, version: 1 });
@@ -290,6 +292,32 @@ describe("extension MCP HTTP proxy tools", () => {
290
292
  expect(enabledOnly.structuredContent).toMatchObject({ success: true, extensions: [] });
291
293
  });
292
294
 
295
+ test("extension-install sends an inline bundle only for leads and only with the flag on", async () => {
296
+ const tools = buildToolServer();
297
+ const bundle = await loadBundleFixture("minimal");
298
+ const inline = { manifest: bundle.manifest, files: bundle.files };
299
+
300
+ const off = (await tools.install.handler(inline, meta(leadId))) as ToolResult;
301
+ expect(off.isError).toBe(true);
302
+ expect(JSON.stringify(off.structuredContent)).toContain("inline_install_disabled");
303
+
304
+ process.env.EXTENSION_ALLOW_INLINE_INSTALL = "true";
305
+ const worker = (await tools.install.handler(inline, meta(workerId))) as ToolResult;
306
+ expect(worker.isError).toBe(true);
307
+ expect(JSON.stringify(worker.structuredContent)).toContain("Forbidden");
308
+ expect(await getDbClient().query("SELECT id FROM extensions")).toEqual([]);
309
+
310
+ const lead = (await tools.install.handler(inline, meta(leadId))) as ToolResult;
311
+ expect(lead.isError).toBe(false);
312
+ expect(lead.structuredContent).toMatchObject({
313
+ success: true,
314
+ name: "minimal",
315
+ createdByAgentId: leadId,
316
+ enabled: false,
317
+ status: "disabled",
318
+ });
319
+ });
320
+
293
321
  test("extension-install rejects templates missing from the catalog", async () => {
294
322
  const tools = buildToolServer();
295
323
  const result = (await tools.install.handler(
@@ -0,0 +1,226 @@
1
+ import { Database } from "bun:sqlite";
2
+ import { afterAll, beforeAll, describe, expect, test } from "bun:test";
3
+ import { unlink } from "node:fs/promises";
4
+ import { join } from "node:path";
5
+ import { Readable } from "node:stream";
6
+ import { closeDb, getDb, initDb } from "../be/db";
7
+ import { runMigrations } from "../be/migrations/runner";
8
+ import { handleFavorites } from "../http/favorites";
9
+ import { getPathSegments, parseQueryParams } from "../http/utils";
10
+ import { setRequestAuth } from "../utils/request-auth-context";
11
+
12
+ // Migration 192 adds the Comb pin item type `agent-fs-path` to user_favorites.
13
+
14
+ const TEST_DB_PATH = "./test-favorites-agent-fs-path.sqlite";
15
+ const MIGRATIONS_DIR = join(import.meta.dir, "../be/migrations");
16
+
17
+ async function removeDb(path: string): Promise<void> {
18
+ for (const suffix of ["", "-wal", "-shm"]) {
19
+ try {
20
+ await unlink(`${path}${suffix}`);
21
+ } catch {}
22
+ }
23
+ }
24
+
25
+ function jsonReq(method: string, url: string, body?: unknown) {
26
+ const raw = body === undefined ? "" : JSON.stringify(body);
27
+ const req = Readable.from(raw ? [Buffer.from(raw)] : []) as Readable & {
28
+ method: string;
29
+ url: string;
30
+ headers: Record<string, string>;
31
+ };
32
+ req.method = method;
33
+ req.url = url;
34
+ req.headers = { "content-type": "application/json" };
35
+ setRequestAuth(req, { kind: "operator", fingerprint: "op:test-comb-pins" });
36
+ return req;
37
+ }
38
+
39
+ async function call(method: string, url: string, body?: unknown) {
40
+ const req = jsonReq(method, url, body);
41
+ let statusCode = 200;
42
+ const chunks: string[] = [];
43
+ const res = {
44
+ setHeader: () => {},
45
+ writeHead: (code: number) => {
46
+ statusCode = code;
47
+ },
48
+ end: (chunk?: string) => {
49
+ if (chunk) chunks.push(chunk);
50
+ },
51
+ };
52
+ await handleFavorites(
53
+ req,
54
+ res as never,
55
+ getPathSegments(req.url),
56
+ parseQueryParams(req.url),
57
+ undefined,
58
+ );
59
+ return { statusCode, body: chunks.length > 0 ? JSON.parse(chunks.join("")) : null };
60
+ }
61
+
62
+ describe("favorites: agent-fs-path item type (fresh DB)", () => {
63
+ beforeAll(async () => {
64
+ await removeDb(TEST_DB_PATH);
65
+ initDb(TEST_DB_PATH);
66
+ });
67
+
68
+ afterAll(async () => {
69
+ closeDb();
70
+ await removeDb(TEST_DB_PATH);
71
+ });
72
+
73
+ test("PUT pins a folder and a file, GET lists them back", async () => {
74
+ for (const itemId of ["org/drive/comb-qa/", "org/drive/comb-qa/my notes 100%.md"]) {
75
+ const put = await call("PUT", "/api/favorites", {
76
+ itemType: "agent-fs-path",
77
+ itemId,
78
+ favorite: true,
79
+ });
80
+ expect(put).toMatchObject({
81
+ statusCode: 200,
82
+ body: { favorite: true, itemType: "agent-fs-path", itemId },
83
+ });
84
+ }
85
+
86
+ const list = await call("GET", "/api/favorites?itemType=agent-fs-path");
87
+ expect(list.statusCode).toBe(200);
88
+ expect([...list.body.favoriteIds].sort()).toEqual([
89
+ "org/drive/comb-qa/",
90
+ "org/drive/comb-qa/my notes 100%.md",
91
+ ]);
92
+ for (const row of list.body.favorites) expect(row.itemType).toBe("agent-fs-path");
93
+
94
+ // Other item types do not see the pins.
95
+ expect((await call("GET", "/api/favorites?itemType=page")).body.favoriteIds).toEqual([]);
96
+ });
97
+
98
+ test("PUT with favorite=false unpins", async () => {
99
+ await call("PUT", "/api/favorites", {
100
+ itemType: "agent-fs-path",
101
+ itemId: "org/drive/comb-qa/",
102
+ favorite: false,
103
+ });
104
+ const list = await call("GET", "/api/favorites?itemType=agent-fs-path");
105
+ expect(list.body.favoriteIds).toEqual(["org/drive/comb-qa/my notes 100%.md"]);
106
+ });
107
+
108
+ test("GET lists pins newest first", async () => {
109
+ const db = getDb();
110
+ const ids = ["org/drive/order/a.md", "org/drive/order/b.md", "org/drive/order/c.md"];
111
+ for (const [i, itemId] of ids.entries()) {
112
+ await call("PUT", "/api/favorites", { itemType: "agent-fs-path", itemId, favorite: true });
113
+ db.run(
114
+ "UPDATE user_favorites SET lastUpdatedAt = ? WHERE itemType = 'agent-fs-path' AND itemId = ?",
115
+ [`2030-01-0${i + 1}T00:00:00.000Z`, itemId],
116
+ );
117
+ }
118
+ const list = await call("GET", "/api/favorites?itemType=agent-fs-path");
119
+ const listed = list.body.favoriteIds.filter((id: string) => id.startsWith("org/drive/order/"));
120
+ expect(listed).toEqual([...ids].reverse());
121
+ });
122
+
123
+ test("an unknown item type is still rejected", async () => {
124
+ const put = await call("PUT", "/api/favorites", {
125
+ itemType: "agent-fs-file",
126
+ itemId: "org/drive/a.md",
127
+ favorite: true,
128
+ });
129
+ expect(put.statusCode).toBe(400);
130
+ const list = await call("GET", "/api/favorites?itemType=agent-fs-file");
131
+ expect(list.statusCode).toBe(400);
132
+ });
133
+ });
134
+
135
+ describe("migration 192 (existing DB)", () => {
136
+ // In memory: the full migration chain on a file DB passed the 10 s test timeout on a loaded CI shard.
137
+ test("keeps every favorite row and the indexes, and widens the CHECK", async () => {
138
+ const db = new Database(":memory:");
139
+ try {
140
+ runMigrations(db);
141
+
142
+ // Roll back to the pre-192 shape: re-run 116 on the empty table (it
143
+ // rebuilds user_favorites with the old CHECK and the same indexes).
144
+ db.exec(await Bun.file(join(MIGRATIONS_DIR, "116_favorite_principal_scope.sql")).text());
145
+ db.run("DELETE FROM _migrations WHERE version = 192");
146
+ expect(() =>
147
+ db.run(
148
+ "INSERT INTO user_favorites (favoriteScope, itemType, itemId) VALUES ('operator:x', 'agent-fs-path', 'o/d/a.md')",
149
+ ),
150
+ ).toThrow(/CHECK constraint failed/);
151
+
152
+ db.run("INSERT INTO users (id, name) VALUES ('user-1', 'Pin User')");
153
+ const insert = db.prepare(
154
+ `INSERT INTO user_favorites
155
+ (id, favoriteScope, userId, itemType, itemId, createdAt, lastUpdatedAt, created_by, updated_by)
156
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,
157
+ );
158
+ // Page, workflow, and schedule favorites for a user scope and the
159
+ // operator scope, with distinct timestamps and audit values per row.
160
+ let n = 0;
161
+ for (const [scope, userId] of [
162
+ ["user:user-1", "user-1"],
163
+ ["operator", null],
164
+ ] as const) {
165
+ for (const itemType of ["page", "workflow", "schedule"]) {
166
+ n++;
167
+ insert.run(
168
+ `fav-${n}`,
169
+ scope,
170
+ userId,
171
+ itemType,
172
+ `${itemType}-${n}`,
173
+ `2026-09-0${n}T00:00:00.000Z`,
174
+ `2026-09-1${n}T00:00:00.000Z`,
175
+ n % 2 ? "op:abc" : null,
176
+ n % 3 ? userId : null,
177
+ );
178
+ }
179
+ }
180
+ const before = db.query("SELECT * FROM user_favorites ORDER BY id").all();
181
+ expect(before).toHaveLength(6);
182
+
183
+ runMigrations(db);
184
+
185
+ expect(db.query("SELECT version FROM _migrations WHERE version = 192").get()).not.toBeNull();
186
+ expect(db.query("SELECT * FROM user_favorites ORDER BY id").all()).toEqual(before);
187
+
188
+ const indexes = db
189
+ .query<{ name: string; unique: number }, []>("PRAGMA index_list(user_favorites)")
190
+ .all();
191
+ expect(indexes.map((index) => index.name)).toEqual(
192
+ expect.arrayContaining([
193
+ "idx_user_favorites_scope_type",
194
+ "idx_user_favorites_user_type",
195
+ "idx_user_favorites_item",
196
+ ]),
197
+ );
198
+ // The UNIQUE (favoriteScope, itemType, itemId) constraint survives.
199
+ const unique = indexes
200
+ .filter((index) => index.unique === 1)
201
+ .map((index) =>
202
+ db
203
+ .query<{ name: string }, []>(`PRAGMA index_info("${index.name}")`)
204
+ .all()
205
+ .map((column) => column.name),
206
+ );
207
+ expect(unique).toContainEqual(["favoriteScope", "itemType", "itemId"]);
208
+
209
+ // The new type is accepted, an unknown type is still rejected.
210
+ db.run(
211
+ "INSERT INTO user_favorites (favoriteScope, itemType, itemId) VALUES ('operator', 'agent-fs-path', 'o/d/comb-qa/')",
212
+ );
213
+ expect(() =>
214
+ db.run(
215
+ "INSERT INTO user_favorites (favoriteScope, itemType, itemId) VALUES ('operator', 'bogus', 'x')",
216
+ ),
217
+ ).toThrow(/CHECK constraint failed/);
218
+
219
+ // The user FK still cascades.
220
+ db.run("DELETE FROM users WHERE id = 'user-1'");
221
+ expect(db.query("SELECT id FROM user_favorites WHERE userId = 'user-1'").all()).toEqual([]);
222
+ } finally {
223
+ db.close();
224
+ }
225
+ });
226
+ });
@@ -523,6 +523,30 @@ describe("memory rater config reload", () => {
523
523
  });
524
524
  });
525
525
 
526
+ describe("agent-scoped PI_CODEMODE_MODELS reaches the worker env", () => {
527
+ // The server merges global, agent and repo rows into /api/config/resolved
528
+ // (getResolvedConfig); the worker applies the result to process.env, which
529
+ // the pi adapter reads when the next task's session starts. PI_CODEMODE and
530
+ // PI_TOOL_DEFERRAL take the same path and are covered below.
531
+ const saved = process.env.PI_CODEMODE_MODELS;
532
+ afterEach(() => {
533
+ if (saved === undefined) delete process.env.PI_CODEMODE_MODELS;
534
+ else process.env.PI_CODEMODE_MODELS = saved;
535
+ });
536
+
537
+ test("the row lands in process.env and is reported as changed", async () => {
538
+ delete process.env.PI_CODEMODE_MODELS;
539
+ mockResponsesByAgentId.set("pi-pilot-agent", {
540
+ status: 200,
541
+ body: { configs: [{ key: "PI_CODEMODE_MODELS", value: "true" }] },
542
+ });
543
+ const result = await fetchResolvedEnv(testUrl, "key", "pi-pilot-agent");
544
+ const changed = applyResolvedEnvToProcessEnv(result.env);
545
+ expect(changed).toContain("PI_CODEMODE_MODELS");
546
+ expect(process.env.PI_CODEMODE_MODELS).toBe("true");
547
+ });
548
+ });
549
+
526
550
  describe("deleting a reloadable config row", () => {
527
551
  // One key per test: the runner remembers each overridden key's boot value
528
552
  // for the life of the process.
@@ -0,0 +1,129 @@
1
+ {
2
+ "id": "a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1",
3
+ "eventType": "ms.vss-code.git-pullrequest-comment-event",
4
+ "publisherId": "tfs",
5
+ "message": {
6
+ "text": "Jamal Hartnett has edited a pull request comment",
7
+ "html": "Jamal Hartnett has <a href=\"https://fabrikam.visualstudio.com/DefaultCollection/_git/Fabrikam/pullrequest/1?discussionId=5\">edited</a> a pull request comment",
8
+ "markdown": "Jamal Hartnett has [edited](https://fabrikam.visualstudio.com/DefaultCollection/_git/Fabrikam/pullrequest/1?discussionId=5) a pull request comment"
9
+ },
10
+ "detailedMessage": {
11
+ "text": "Jamal Hartnett has edited a pull request comment\r\nThis is my comment.\r\n",
12
+ "html": "Jamal Hartnett has <a href=\"https://fabrikam.visualstudio.com/DefaultCollection/_git/Fabrikam/pullrequest/1?discussionId=5\">edited</a> a pull request comment<p>This is my comment.</p>",
13
+ "markdown": "Jamal Hartnett has [edited](https://fabrikam.visualstudio.com/DefaultCollection/_git/Fabrikam/pullrequest/1?discussionId=5) a pull request comment\r\nThis is my comment.\r\n"
14
+ },
15
+ "resource": {
16
+ "comment": {
17
+ "id": 2,
18
+ "parentCommentId": 1,
19
+ "author": {
20
+ "displayName": "Jamal Hartnett",
21
+ "url": "https://fabrikam.vssps.visualstudio.com/_apis/Identities/11bb11bb-cc22-dd33-ee44-55ff55ff55ff",
22
+ "id": "11bb11bb-cc22-dd33-ee44-55ff55ff55ff",
23
+ "uniqueName": "fabrikamfiber4@hotmail.com",
24
+ "imageUrl": "https://fabrikam.visualstudio.com/DefaultCollection/_api/_common/identityImage?id=11bb11bb-cc22-dd33-ee44-55ff55ff55ff"
25
+ },
26
+ "content": "This is my comment.",
27
+ "publishedDate": "2024-06-17T11:22:33.456789Z",
28
+ "lastUpdatedDate": "2024-06-17T16:58:33.123889Z",
29
+ "lastContentUpdatedDate": "2024-06-17T16:58:33.123889Z",
30
+ "commentType": "text",
31
+ "_links": {
32
+ "self": {
33
+ "href": "https://fabrikam.visualstudio.com/DefaultCollection/_apis/git/repositories/c2c2c2c2-dddd-eeee-ffff-a3a3a3a3a3a3/pullRequests/1/threads/5/comments/2"
34
+ },
35
+ "repository": {
36
+ "href": "http://joscol2/DefaultCollection/ebed510c-62eb-474b-965f-fd151ebb82e4/_apis/git/repositories/c2c2c2c2-dddd-eeee-ffff-a3a3a3a3a3a3"
37
+ },
38
+ "threads": {
39
+ "href": "https://fabrikam.visualstudio.com/DefaultCollection/_apis/git/repositories/c2c2c2c2-dddd-eeee-ffff-a3a3a3a3a3a3/pullRequests/1/threads/5"
40
+ }
41
+ }
42
+ },
43
+ "pullRequest": {
44
+ "repository": {
45
+ "id": "c2c2c2c2-dddd-eeee-ffff-a3a3a3a3a3a3",
46
+ "name": "Fabrikam",
47
+ "url": "https://fabrikam.visualstudio.com/DefaultCollection/_apis/git/repositories/c2c2c2c2-dddd-eeee-ffff-a3a3a3a3a3a3",
48
+ "project": {
49
+ "id": "d3d3d3d3-eeee-ffff-aaaa-b4b4b4b4b4b4",
50
+ "name": "Fabrikam",
51
+ "url": "https://fabrikam.visualstudio.com/DefaultCollection/_apis/projects/d3d3d3d3-eeee-ffff-aaaa-b4b4b4b4b4b4",
52
+ "state": "wellFormed",
53
+ "visibility": "unchanged",
54
+ "lastUpdateTime": "0001-01-01T00:00:00"
55
+ },
56
+ "defaultBranch": "refs/heads/main",
57
+ "remoteUrl": "https://fabrikam.visualstudio.com/DefaultCollection/_git/Fabrikam"
58
+ },
59
+ "pullRequestId": 1,
60
+ "status": "active",
61
+ "createdBy": {
62
+ "displayName": "Jamal Hartnett",
63
+ "url": "https://fabrikam.vssps.visualstudio.com/_apis/Identities/11bb11bb-cc22-dd33-ee44-55ff55ff55ff",
64
+ "id": "11bb11bb-cc22-dd33-ee44-55ff55ff55ff",
65
+ "uniqueName": "fabrikamfiber4@hotmail.com",
66
+ "imageUrl": "https://fabrikam.visualstudio.com/DefaultCollection/_api/_common/identityImage?id=11bb11bb-cc22-dd33-ee44-55ff55ff55ff"
67
+ },
68
+ "creationDate": "2024-06-17T11:22:33.456789Z",
69
+ "title": "my first pull request",
70
+ "description": " - test2\r\n",
71
+ "sourceRefName": "refs/heads/mytopic",
72
+ "targetRefName": "refs/heads/main",
73
+ "mergeStatus": "succeeded",
74
+ "mergeId": "e4e4e4e4-ffff-aaaa-bbbb-c5c5c5c5c5c5",
75
+ "lastMergeSourceCommit": {
76
+ "commitId": "4444eeee455ff5aaaaabb66ccccccccc7777cccc",
77
+ "url": "https://fabrikam.visualstudio.com/DefaultCollection/_apis/git/repositories/c2c2c2c2-dddd-eeee-ffff-a3a3a3a3a3a3/commits/4444eeee455ff5aaaaabb66ccccccccc7777cccc"
78
+ },
79
+ "lastMergeTargetCommit": {
80
+ "commitId": "5555ffff566aa6bbbbbcc77ddddddd888888dddd",
81
+ "url": "https://fabrikam.visualstudio.com/DefaultCollection/_apis/git/repositories/c2c2c2c2-dddd-eeee-ffff-a3a3a3a3a3a3/commits/5555ffff566aa6bbbbbcc77ddddddd888888dddd"
82
+ },
83
+ "lastMergeCommit": {
84
+ "commitId": "6666aaaa677bb7cccccdd88eeeeeee999999eeee",
85
+ "url": "https://fabrikam.visualstudio.com/DefaultCollection/_apis/git/repositories/c2c2c2c2-dddd-eeee-ffff-a3a3a3a3a3a3/commits/6666aaaa677bb7cccccdd88eeeeeee999999eeee"
86
+ },
87
+ "reviewers": [
88
+ {
89
+ "reviewerUrl": null,
90
+ "vote": 0,
91
+ "displayName": "[Mobile]\\Mobile Team",
92
+ "url": "https://fabrikam.vssps.visualstudio.com/_apis/Identities/22cc22cc-dd33-ee44-ff55-66aa66aa66aa",
93
+ "id": "22cc22cc-dd33-ee44-ff55-66aa66aa66aa",
94
+ "uniqueName": "azure-devops:///Classification/TeamProject/22cc22cc-dd33-ee44-ff55-66aa66aa66aa\\Mobile Team",
95
+ "imageUrl": "https://fabrikam.visualstudio.com/DefaultCollection/_api/_common/identityImage?id=22cc22cc-dd33-ee44-ff55-66aa66aa66aa",
96
+ "isContainer": true
97
+ }
98
+ ],
99
+ "commits": [
100
+ {
101
+ "commitId": "6666aaaa677bb7cccccdd88eeeeeee999999eeee",
102
+ "url": "https://fabrikam.visualstudio.com/DefaultCollection/_apis/git/repositories/c2c2c2c2-dddd-eeee-ffff-a3a3a3a3a3a3/commits/6666aaaa677bb7cccccdd88eeeeeee999999eeee"
103
+ }
104
+ ],
105
+ "url": "https://fabrikam.visualstudio.com/DefaultCollection/_apis/git/repositories/c2c2c2c2-dddd-eeee-ffff-a3a3a3a3a3a3/pullRequests/1",
106
+ "_links": {
107
+ "web": {
108
+ "href": "https://fabrikam.visualstudio.com/DefaultCollection/_git/Fabrikam/pullrequest/1#view=discussion"
109
+ },
110
+ "statuses": {
111
+ "href": "https://fabrikam.visualstudio.com/DefaultCollection/_apis/git/repositories/c2c2c2c2-dddd-eeee-ffff-a3a3a3a3a3a3/pullRequests/1/statuses"
112
+ }
113
+ }
114
+ }
115
+ },
116
+ "resourceVersion": "2.0",
117
+ "resourceContainers": {
118
+ "collection": {
119
+ "id": "b1b1b1b1-cccc-dddd-eeee-f2f2f2f2f2f2"
120
+ },
121
+ "account": {
122
+ "id": "bbbb1b1b-cc2c-dd3d-ee4e-ffffff5f5f5f"
123
+ },
124
+ "project": {
125
+ "id": "00aa00aa-bb11-cc22-dd33-44ee44ee44ee"
126
+ }
127
+ },
128
+ "createdDate": "2024-07-17T21:34:22.338Z"
129
+ }