@desplega.ai/agent-swarm 2.13.3 → 2.13.5

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 (424) hide show
  1. package/dist/acp-adapter-tbt61zkm.js +17 -0
  2. package/dist/{acp-targets-k8xs4tj8.js → acp-targets-w8dbs4nr.js} +10 -10
  3. package/dist/{actions-pg5fxjer.js → actions-8zrcbjrx.js} +237 -27
  4. package/dist/{agent-fs-provision-vbk3fppw.js → agent-fs-provision-cbt2ttds.js} +4 -4
  5. package/dist/{amp-adapter-adbhxsz9.js → amp-adapter-8x6zp8w4.js} +3 -3
  6. package/dist/{anthropic-messages-88b7s3n9.js → anthropic-messages-vdd1zmha.js} +10 -10
  7. package/dist/{app-b267ggx1.js → app-zfa9dwjw.js} +7 -7
  8. package/dist/{approval-notifications-evc1a9z5.js → approval-notifications-rv92zmza.js} +8 -8
  9. package/dist/{assistant-wgz2ab84.js → assistant-q7s7rm1q.js} +25 -25
  10. package/dist/{boot-args-schema-6tpk28j4.js → boot-args-schema-g27kpzr1.js} +1 -1
  11. package/dist/{boot-reembed-r1zyvefv.js → boot-reembed-1mjs52nt.js} +1 -1
  12. package/dist/{boot-reembed-ankp369c.js → boot-reembed-m62dpdkg.js} +1 -1
  13. package/dist/{boot-scrub-sweep-cgb6r5bd.js → boot-scrub-sweep-ss1vcamw.js} +2 -2
  14. package/dist/{boot-seeds-bjceqg7b.js → boot-seeds-hwnvgbb3.js} +4 -4
  15. package/dist/{boxd-hr8rsxzq.js → boxd-y0szhp0g.js} +2 -2
  16. package/dist/{claude-adapter-knztdnff.js → claude-adapter-0rjmbhjk.js} +9 -9
  17. package/dist/{claude-managed-adapter-qwejzqkk.js → claude-managed-adapter-6k032agg.js} +4 -4
  18. package/dist/{claude-managed-setup-0vgz4d1j.js → claude-managed-setup-6czvve8q.js} +5 -5
  19. package/dist/{claude-sdk-session-c3g6dv0g.js → claude-sdk-session-pr0znb81.js} +12671 -11885
  20. package/dist/{cli-2v4xxnx2.js → cli-0h8skzss.js} +1 -1
  21. package/dist/{cli-7fa6yv98.js → cli-0qt3epg4.js} +7 -7
  22. package/dist/{cli-aytna2fm.js → cli-19d6v8er.js} +7 -7
  23. package/dist/{cli-8m6gqnf1.js → cli-1jq2em7b.js} +4 -4
  24. package/dist/{cli-fp65jdp2.js → cli-1kvcsd2f.js} +219 -155
  25. package/dist/{cli-8fj8yfmk.js → cli-2vp0z049.js} +1 -1
  26. package/dist/{cli-61p7ty8d.js → cli-2wzkvfgm.js} +3 -3
  27. package/dist/{cli-tjf1bh1v.js → cli-34fygf87.js} +6 -4
  28. package/dist/{cli-czeh7x13.js → cli-3860pmrq.js} +4 -4
  29. package/dist/{cli-dq30fq3q.js → cli-3vw6dd4g.js} +2 -2
  30. package/dist/{cli-4dyhzhpx.js → cli-4gaf3tx5.js} +1 -1
  31. package/dist/{cli-3mf04tkh.js → cli-4vynxtrb.js} +1 -1
  32. package/dist/{cli-hpxcfvdm.js → cli-55h8m1x3.js} +10 -7
  33. package/dist/{cli-hxj888w3.js → cli-5n9w2xzx.js} +2 -2
  34. package/dist/{cli-50whymxq.js → cli-5tq15aa7.js} +2 -2
  35. package/dist/{cli-8sayvj48.js → cli-5web09sb.js} +3 -3
  36. package/dist/{cli-gc715jrc.js → cli-69zzpjgh.js} +1 -1
  37. package/dist/{cli-vgh5adn9.js → cli-6msnpj1z.js} +8 -8
  38. package/dist/{cli-f8rcvf2x.js → cli-7r9tvk8v.js} +76 -3
  39. package/dist/{cli-fbmgpt72.js → cli-7ypg8hka.js} +3 -3
  40. package/dist/{cli-xc8m5cjn.js → cli-887vhew6.js} +3 -3
  41. package/dist/{cli-q8aq48v1.js → cli-8b4rpnwj.js} +1 -1
  42. package/dist/{cli-pzsedyb0.js → cli-8pd1t17c.js} +14 -14
  43. package/dist/{cli-je587f74.js → cli-94gx6ze9.js} +1 -1
  44. package/dist/{cli-h9d3sdnc.js → cli-94mxerrp.js} +1 -1
  45. package/dist/{cli-ef590376.js → cli-9n6g14vs.js} +3 -3
  46. package/dist/{cli-80d5g0fa.js → cli-abby987g.js} +3 -3
  47. package/dist/{cli-grk77aen.js → cli-avax5mp9.js} +2 -2
  48. package/dist/{cli-hd2a204w.js → cli-b42yfn17.js} +14 -14
  49. package/dist/{cli-gkjw33x5.js → cli-b9ygp1kz.js} +2 -2
  50. package/dist/{cli-bh53ppqm.js → cli-bvamr9g0.js} +4 -4
  51. package/dist/{cli-ka4tqjzd.js → cli-ced4azn1.js} +15 -12
  52. package/dist/{cli-v1v49t36.js → cli-cmbb2t8a.js} +3 -3
  53. package/dist/{cli-hhb8kbwd.js → cli-cp163xga.js} +31 -16
  54. package/dist/{cli-55fqpd9q.js → cli-ebpq3c5z.js} +8 -8
  55. package/dist/{cli-9gmkw6xn.js → cli-ehg90jd1.js} +128 -48
  56. package/dist/{cli-jg5txpm6.js → cli-emdfd8fh.js} +75 -1
  57. package/dist/{cli-gxqwm3k3.js → cli-evy3egte.js} +104 -10
  58. package/dist/{cli-a21cwm89.js → cli-ewk3sg68.js} +3 -3
  59. package/dist/{cli-syqcny89.js → cli-f7b9nyvk.js} +9 -9
  60. package/dist/{cli-268b3dgn.js → cli-f9xw9pr4.js} +5 -5
  61. package/dist/{cli-61fzwtjk.js → cli-ffn0a515.js} +9 -9
  62. package/dist/{cli-ya1cj689.js → cli-fw67mnyc.js} +1 -1
  63. package/dist/{cli-dqgnbnxs.js → cli-grbngev5.js} +6 -1
  64. package/dist/{cli-sy2ge2ye.js → cli-hd5bm1e1.js} +4 -4
  65. package/dist/{cli-rfejbpe1.js → cli-htb5bpz2.js} +1 -1
  66. package/dist/{cli-w24741sm.js → cli-j69pzrrz.js} +7 -7
  67. package/dist/{cli-g4dhd3pr.js → cli-jdq3jmny.js} +6 -23
  68. package/dist/{cli-hv3820ez.js → cli-k0nebh10.js} +1 -1
  69. package/dist/{cli-d2epqm0y.js → cli-kezzteka.js} +1 -1
  70. package/dist/{cli-h0ewec3d.js → cli-kr0jpw9c.js} +1 -1
  71. package/dist/{cli-t25rq8mg.js → cli-ks06cd0n.js} +40 -11
  72. package/dist/{cli-1gnf5c7x.js → cli-kwj3131p.js} +1 -1
  73. package/dist/{cli-wtffytm8.js → cli-m8f4379k.js} +3 -3
  74. package/dist/{cli-43dsqhcp.js → cli-n79j1vxc.js} +4 -4
  75. package/dist/{cli-b768ek79.js → cli-nrt048ys.js} +1 -0
  76. package/dist/{cli-h3drhntp.js → cli-pedm2kht.js} +2 -2
  77. package/dist/{cli-eds5xnsz.js → cli-phmy14hb.js} +2 -2
  78. package/dist/{cli-7kv5d674.js → cli-prz1p3ft.js} +5 -5
  79. package/dist/{cli-nbawx3s0.js → cli-q1h041y8.js} +6 -6
  80. package/dist/{cli-cah298e5.js → cli-q41qar56.js} +104 -119
  81. package/dist/{cli-kwm1bek7.js → cli-qmx8bnt4.js} +2 -2
  82. package/dist/{cli-1wew39p0.js → cli-qrvk9nka.js} +28 -19
  83. package/dist/{cli-v8rpjrnx.js → cli-r3dxpmyt.js} +1 -1
  84. package/dist/{cli-0j4qmc80.js → cli-ryem5cfq.js} +8 -8
  85. package/dist/{cli-8pnawt98.js → cli-s8dhq7rj.js} +5 -5
  86. package/dist/{cli-zkbz8m2q.js → cli-sejvnjvw.js} +3 -2
  87. package/dist/{cli-at67kvnp.js → cli-srktrbby.js} +1 -1
  88. package/dist/{cli-wsnradtk.js → cli-srre41gb.js} +2 -2
  89. package/dist/{cli-r6xnchva.js → cli-t0n9svkb.js} +7 -7
  90. package/dist/{cli-y0q92v4r.js → cli-t879ww0y.js} +2 -2
  91. package/dist/{cli-eetzmsy5.js → cli-t9pzz2eq.js} +2 -2
  92. package/dist/{cli-xwsm6xkr.js → cli-tgc1kgg3.js} +1 -1
  93. package/dist/{cli-dw43pnzp.js → cli-tt7dkwjj.js} +7 -7
  94. package/dist/{cli-y754psdt.js → cli-tvyt8w6n.js} +5 -5
  95. package/dist/cli-v09eza21.js +1907 -0
  96. package/dist/{cli-mgr3gatr.js → cli-vbge4rsp.js} +4 -4
  97. package/dist/{cli-ppf9ap9n.js → cli-vcpyttcw.js} +1 -1
  98. package/dist/{cli-1606qw3n.js → cli-wzecestt.js} +1100 -432
  99. package/dist/{cli-5basv0e7.js → cli-x2adbg4j.js} +71 -9
  100. package/dist/{cli-vx9acp12.js → cli-ybte1fqc.js} +1 -1
  101. package/dist/{cli-vdfngx2g.js → cli-ywy8yz6t.js} +2 -2
  102. package/dist/{cli-cpkxh68d.js → cli-z1vam71h.js} +2 -2
  103. package/dist/{cli-djwt4mtn.js → cli-z3x7h79n.js} +15 -9
  104. package/dist/cli-z40t85ms.js +27 -0
  105. package/dist/{cli-ea367bdn.js → cli-zbbtp02a.js} +104 -27
  106. package/dist/{cli-88np9va3.js → cli-zntvmqmm.js} +2 -2
  107. package/dist/{cli-snwz16eg.js → cli-zxa1vmx7.js} +2 -2
  108. package/dist/{cli-50wa8k4h.js → cli-zy9bb22b.js} +1 -2
  109. package/dist/{cli-e4gx499y.js → cli-zzq96q57.js} +273 -106
  110. package/dist/cli.js +21 -21
  111. package/dist/{codex-adapter-493vb8cv.js → codex-adapter-bn7eaxk5.js} +8 -8
  112. package/dist/{codex-hook-ej8hn6z5.js → codex-hook-nnmezjg9.js} +3 -3
  113. package/dist/{codex-login-ven5cz5j.js → codex-login-ktfg1cxk.js} +1 -1
  114. package/dist/{codex-session-runner-ps5m4z1g.js → codex-session-runner-j1e9hffc.js} +9 -9
  115. package/dist/{commands-shktk0b8.js → commands-amhpafrr.js} +3 -3
  116. package/dist/{controller-wn3vd217.js → controller-tw7g10j2.js} +4 -4
  117. package/dist/{controllers-connect-yft057ws.js → controllers-connect-2ssqz7f4.js} +25 -25
  118. package/dist/core-bwp98v4w.js +42 -0
  119. package/dist/{cursor-adapter-8fpm4dng.js → cursor-adapter-d6knjmwa.js} +2 -2
  120. package/dist/{db-0ezhdhz5.js → db-fd6xxm77.js} +3 -3
  121. package/dist/{db-84pz2w5c.js → db-sc59379z.js} +2 -2
  122. package/dist/{devin-adapter-fs90ab4v.js → devin-adapter-3bp6rape.js} +1 -1
  123. package/dist/{dispatcher-h2rz69f6.js → dispatcher-a2gdqz8c.js} +22 -22
  124. package/dist/{docker-1h33jvh9.js → docker-a59g3ebm.js} +2 -2
  125. package/dist/{dsh-adapter-g9yqv09y.js → dsh-adapter-43ygwqn7.js} +2 -2
  126. package/dist/{e2b-jnk0yeva.js → e2b-cn7cvjqy.js} +3 -3
  127. package/dist/{e2b-y7e5kmzf.js → e2b-qnxyfea6.js} +3 -3
  128. package/dist/{easter-egg-3d-m41ad78v.js → easter-egg-3d-a0pphy71.js} +1 -1
  129. package/dist/{embedding-space-yam9zwzj.js → embedding-space-qepzrach.js} +6 -6
  130. package/dist/{embeddings-g2be0y8q.js → embeddings-d7vr881x.js} +1 -1
  131. package/dist/{event-bus-08t2b4y2.js → event-bus-7gbsr0g4.js} +1 -1
  132. package/dist/{execute-hhdejgzf.js → execute-6afts2bn.js} +1 -1
  133. package/dist/{external-channel-kjt2yzfj.js → external-channel-881zq1x4.js} +2 -2
  134. package/dist/fx-adapter-cr2hq17y.js +20 -0
  135. package/dist/grok-adapter-ayddnbsc.js +20 -0
  136. package/dist/handlers-7ghs84x2.js +41 -0
  137. package/dist/{heartbeat-2e5jdexj.js → heartbeat-4c022m6a.js} +25 -25
  138. package/dist/{hook-acg9saz7.js → hook-4k84x499.js} +6 -6
  139. package/dist/{hook-34s8cmgn.js → hook-a7eh6zty.js} +9 -9
  140. package/dist/{http-ra2zr2f8.js → http-6aw5wanc.js} +456 -1864
  141. package/dist/{index-mbpxhc4w.js → index-126v2d0t.js} +1 -4
  142. package/dist/index-dtt0d634.js +44 -0
  143. package/dist/index-hmszyqkk.js +42 -0
  144. package/dist/index-j6rm1rtn.js +39 -0
  145. package/dist/{index-9q42cr54.js → index-rwwhsmjg.js} +1 -1
  146. package/dist/{index-93bw5wds.js → index-xhad0n8m.js} +1 -1
  147. package/dist/{index-2z1z7qx6.js → index-yq9hhhhy.js} +26 -26
  148. package/dist/{index-9r4j0a60.js → index-z2g9469g.js} +410 -27
  149. package/dist/{k8s-8326q0rq.js → k8s-36gfn847.js} +2 -2
  150. package/dist/{keepalive-vjnnqbkm.js → keepalive-zhbmztqw.js} +5 -5
  151. package/dist/lead-g2j4q39z.js +83 -0
  152. package/dist/{maintenance-px2g599e.js → maintenance-rsp0591h.js} +1 -1
  153. package/dist/{node-2wfcey7d.js → node-0as4n1ef.js} +3 -3
  154. package/dist/{node-zd6shky9.js → node-dhxbt01p.js} +3 -3
  155. package/dist/{node-z67yjre7.js → node-rxte5hc6.js} +290 -70
  156. package/dist/{node-hjn5n1yp.js → node-t0ct2zpw.js} +3 -5
  157. package/dist/{oauth-refresh-sweep-nkykf09m.js → oauth-refresh-sweep-w3cqmxq7.js} +4 -4
  158. package/dist/{object-webhooks-gt9xnq21.js → object-webhooks-331hay92.js} +7 -7
  159. package/dist/{onboard-1f134p65.js → onboard-n2w80m2n.js} +7 -7
  160. package/dist/{opencode-adapter-94976yab.js → opencode-adapter-z98127cz.js} +8 -8
  161. package/dist/{otel-impl-5d4p2fqs.js → otel-impl-xsk35tvf.js} +2 -2
  162. package/dist/{pending-vkk0vx6n.js → pending-2e6trkxd.js} +23 -23
  163. package/dist/{pi-mono-adapter-cyzdv5er.js → pi-mono-adapter-wh6yndtm.js} +13 -13
  164. package/dist/{pricing-refresh-jtmjwss9.js → pricing-refresh-9355dj1t.js} +2 -2
  165. package/dist/{rbac-roles-yd1fgpsn.js → rbac-roles-58y3m912.js} +3 -3
  166. package/dist/{rbac-roles-1fvmdyeb.js → rbac-roles-8eajw4s6.js} +6 -4
  167. package/dist/{render-v2-kb5s3vx4.js → render-v2-7gskkmd4.js} +7 -7
  168. package/dist/{resume-z1vs44n5.js → resume-0drnmpja.js} +10 -10
  169. package/dist/{runtime-gk6ct7r7.js → runtime-d2tcmqte.js} +1 -1
  170. package/dist/{session-access-nz6nre4d.js → session-access-0ztys6bd.js} +5 -5
  171. package/dist/{session-source-backfill-wb60zjkd.js → session-source-backfill-cdm5s046.js} +3 -3
  172. package/dist/{setup-2x8g8j4s.js → setup-pqwb9tcc.js} +1 -1
  173. package/dist/thread-buffer-epx3san4.js +42 -0
  174. package/dist/{tree-visibility-ts3z30kw.js → tree-visibility-rwz67mje.js} +2 -2
  175. package/dist/{user-merge-jobs-zetg26e0.js → user-merge-jobs-mxrhamwt.js} +3 -3
  176. package/dist/{virtual-modules-674fka8x.js → virtual-modules-71y1gsmg.js} +3 -3
  177. package/dist/{work-objects-w52yyjxm.js → work-objects-3k4ykt9j.js} +25 -25
  178. package/dist/worker-09gqn9xy.js +83 -0
  179. package/dist/{worker-follow-up-dyfxyjbj.js → worker-follow-up-y0h64xpr.js} +22 -22
  180. package/dist/{x-asbrnafg.js → x-d27jj7z7.js} +2 -2
  181. package/openapi.json +861 -33
  182. package/package.json +4 -4
  183. package/src/apps/sync.ts +20 -5
  184. package/src/azure-devops/boards-sync.ts +1 -1
  185. package/src/be/db/approvals.ts +2 -0
  186. package/src/be/db/runtime.ts +5 -0
  187. package/src/be/db/script-run-sources.ts +17 -0
  188. package/src/be/db/slack-trees.ts +12 -1
  189. package/src/be/db/tasks/read.ts +25 -1
  190. package/src/be/db/tasks/write.ts +47 -12
  191. package/src/be/db/users/avatar.ts +12 -0
  192. package/src/be/db-retention.ts +1 -1
  193. package/src/be/db.ts +149 -67
  194. package/src/be/design-system.ts +63 -0
  195. package/src/be/migrations/342_script_run_sources.sql +20 -0
  196. package/src/be/migrations/344_user_avatar.sql +4 -0
  197. package/src/be/migrations/345_task_status_kind.sql +6 -0
  198. package/src/be/migrations/runner.ts +8 -0
  199. package/src/be/migrations/script-run-sources.ts +51 -0
  200. package/src/be/primitives/object-embed.ts +2 -2
  201. package/src/be/primitives/objects.ts +2 -2
  202. package/src/be/rbac-roles.ts +2 -0
  203. package/src/be/runtime-pools/supervisor.ts +1 -0
  204. package/src/be/scripts/typecheck.ts +5 -3
  205. package/src/be/seed-scripts/catalog/design-system-seed.ts +158 -0
  206. package/src/be/seed-scripts/index.ts +9 -0
  207. package/src/be/swarm-config-guard.ts +25 -1
  208. package/src/bitbucket/handlers.ts +1 -1
  209. package/src/commands/credential-outcome-report.ts +96 -0
  210. package/src/commands/onboard/agent-fs-version.ts +1 -1
  211. package/src/commands/runner.ts +49 -3
  212. package/src/event-waits/github.ts +39 -6
  213. package/src/event-waits/index.ts +4 -2
  214. package/src/event-waits/types.ts +10 -3
  215. package/src/extensions/contract-types.generated.ts +1 -1
  216. package/src/github/app.ts +177 -13
  217. package/src/github/handlers.ts +7 -2
  218. package/src/github/pull-request-state.ts +100 -11
  219. package/src/gitlab/handlers.ts +2 -2
  220. package/src/heartbeat/heartbeat.ts +24 -5
  221. package/src/http/all-routes.ts +1 -0
  222. package/src/http/api-keys.ts +26 -0
  223. package/src/http/approval-chat-answer.ts +99 -0
  224. package/src/http/approval-requests.ts +280 -225
  225. package/src/http/asset-key-write.ts +45 -0
  226. package/src/http/assets.ts +4 -3
  227. package/src/http/design-system.ts +103 -0
  228. package/src/http/github-token.ts +27 -6
  229. package/src/http/index.ts +10 -6
  230. package/src/http/pages-public.ts +25 -10
  231. package/src/http/pages.ts +21 -10
  232. package/src/http/person-responder.ts +28 -0
  233. package/src/http/schedules.ts +6 -6
  234. package/src/http/sessions.ts +7 -2
  235. package/src/http/tasks.ts +23 -5
  236. package/src/http/users.ts +5 -0
  237. package/src/http/webhooks.ts +19 -1
  238. package/src/http/workflows.ts +5 -10
  239. package/src/integrations/chat-sdk/adapters.ts +33 -3
  240. package/src/integrations/chat-sdk/commands.ts +3 -1
  241. package/src/integrations/chat-sdk/inbound.ts +6 -18
  242. package/src/integrations/chat-sdk/mentions.ts +188 -0
  243. package/src/integrations/chat-sdk/outbound.ts +20 -3
  244. package/src/integrations/chat-sdk/router.ts +8 -0
  245. package/src/integrations/chat-sdk/telegram-thread.ts +12 -0
  246. package/src/jira/adf.ts +35 -9
  247. package/src/jira/sync.ts +1 -1
  248. package/src/kv-reserved-namespaces.ts +5 -0
  249. package/src/linear/sync.ts +5 -3
  250. package/src/pages/page-head.ts +11 -1
  251. package/src/prompts/session-templates.ts +1 -0
  252. package/src/providers/acp-targets.ts +2 -2
  253. package/src/providers/amp-adapter.ts +1 -1
  254. package/src/providers/claude-adapter.ts +5 -0
  255. package/src/providers/claude-sdk-session.ts +5 -0
  256. package/src/providers/dsh-adapter.ts +48 -13
  257. package/src/providers/runtime-dependencies.ts +1 -1
  258. package/src/rbac/legacy-policy.ts +4 -0
  259. package/src/rbac/permissions.ts +8 -0
  260. package/src/scheduler/deferred-task-waits.ts +74 -13
  261. package/src/scheduler/index.ts +1 -0
  262. package/src/scheduler/scheduler.test.ts +32 -1
  263. package/src/scheduler/scheduler.ts +24 -1
  264. package/src/script-workflows/executor.ts +6 -0
  265. package/src/script-workflows/supervisor.ts +2 -1
  266. package/src/scripts-runtime/sdk-allowlist.ts +2 -0
  267. package/src/scripts-runtime/swarm-sdk.ts +20 -24
  268. package/src/scripts-runtime/types/stdlib.d.ts +12 -2
  269. package/src/scripts-runtime/types/swarm-extension.d.ts +19 -2
  270. package/src/scripts-runtime/types/swarm-sdk.d.ts +12 -2
  271. package/src/server.ts +2 -0
  272. package/src/slack/actions.ts +4 -1
  273. package/src/slack/approval-actions.ts +148 -0
  274. package/src/slack/approval-buttons.ts +28 -0
  275. package/src/slack/render-v2.ts +148 -7
  276. package/src/tests/api-drain-worker-e2e.test.ts +0 -2
  277. package/src/tests/approval-auto-cancellation-migration.test.ts +8 -19
  278. package/src/tests/approval-card-resolution.test.ts +2 -17
  279. package/src/tests/approval-requests-notifications.test.ts +41 -27
  280. package/src/tests/approval-requests.test.ts +137 -369
  281. package/src/tests/apps-sync-engine.test.ts +5 -3
  282. package/src/tests/apps-table-filters-migration.test.ts +44 -25
  283. package/src/tests/bitbucket-handlers.test.ts +2 -0
  284. package/src/tests/chat-sdk-commands.test.ts +1 -0
  285. package/src/tests/chat-sdk-mentions.test.ts +183 -0
  286. package/src/tests/claude-adapter.test.ts +35 -0
  287. package/src/tests/codex-adapter.test.ts +3 -92
  288. package/src/tests/codex-gpt6-release.test.ts +0 -9
  289. package/src/tests/codex-oauth-credential-info.test.ts +35 -18
  290. package/src/tests/codex-oauth.test.ts +0 -6
  291. package/src/tests/codex-pool.test.ts +5 -214
  292. package/src/tests/codex-rate-limit-parse.test.ts +0 -7
  293. package/src/tests/codex-swarm-events.test.ts +11 -54
  294. package/src/tests/create-page-tool.test.ts +5 -0
  295. package/src/tests/db-client-busy-retry.test.ts +49 -16
  296. package/src/tests/defer-task.test.ts +1 -0
  297. package/src/tests/dsh-adapter.test.ts +53 -1
  298. package/src/tests/e2e-shards.test.ts +9 -9
  299. package/src/tests/enabled-tools.test.ts +0 -2
  300. package/src/tests/fixtures/base-prompt-baseline.json +6 -6
  301. package/src/tests/fixtures/compiled-source-schema-boot.ts +24 -0
  302. package/src/tests/fixtures/secret-corpus.ts +43 -1
  303. package/src/tests/github-app-worker-auth-helper.test.ts +147 -1
  304. package/src/tests/gitlab-handlers.test.ts +2 -0
  305. package/src/tests/heartbeat-jev-gate.test.ts +9 -241
  306. package/src/tests/heartbeat-reroute-decision.test.ts +2 -0
  307. package/src/tests/heartbeat-stall-thresholds.test.ts +174 -0
  308. package/src/tests/heartbeat-supersede-resume.test.ts +2 -0
  309. package/src/tests/heartbeat.test.ts +1 -0
  310. package/src/tests/jira-adf.test.ts +42 -2
  311. package/src/tests/key-usage-selection.test.ts +302 -0
  312. package/src/tests/memory-e2e.test.ts +34 -103
  313. package/src/tests/memory-key-paths.test.ts +5 -0
  314. package/src/tests/memory-rater-llm.test.ts +33 -149
  315. package/src/tests/memory-store.test.ts +24 -125
  316. package/src/tests/memory.test.ts +31 -100
  317. package/src/tests/merge-gate-detect-changes.test.ts +314 -16
  318. package/src/tests/migration-342-script-run-sources.test.ts +196 -0
  319. package/src/tests/migration-bunfs-compat.test.ts +129 -9
  320. package/src/tests/otel-service-name.test.ts +0 -9
  321. package/src/tests/otel-session-cost-metrics.test.ts +1 -38
  322. package/src/tests/pool-session-logs.test.ts +8 -42
  323. package/src/tests/pre-push-affected-tests.test.ts +106 -0
  324. package/src/tests/prompt-template-session.test.ts +3 -0
  325. package/src/tests/rbac-e2e-helpers.test.ts +10 -4
  326. package/src/tests/rbac-e2e-helpers.ts +13 -4
  327. package/src/tests/rbac-roles.test.ts +2 -0
  328. package/src/tests/runner-api-drain.test.ts +2 -17
  329. package/src/tests/runner-terminal-window-report.test.ts +132 -0
  330. package/src/tests/runtime-e2b-pools.test.ts +7 -1
  331. package/src/tests/runtime-supervisor-failures.test.ts +1 -0
  332. package/src/tests/sandboxed-process.test.ts +26 -21
  333. package/src/tests/schedule-http-triage-tools.test.ts +12 -9
  334. package/src/tests/schedule-target-type.test.ts +4 -1
  335. package/src/tests/scheduled-tasks.test.ts +14 -51
  336. package/src/tests/script-connections.test.ts +2 -0
  337. package/src/tests/script-executor-conformance.test.ts +4 -48
  338. package/src/tests/script-executor-quickjs-pool.test.ts +9 -7
  339. package/src/tests/script-native-startup.test.ts +21 -25
  340. package/src/tests/script-runs-retention.test.ts +43 -16
  341. package/src/tests/script-workflows-runtime-e2e.test.ts +56 -22
  342. package/src/tests/scripts-http.test.ts +9 -3
  343. package/src/tests/sdk-allowlist.test.ts +26 -13
  344. package/src/tests/sdk-store-progress-skipped.test.ts +12 -5
  345. package/src/tests/secret-rules.test.ts +38 -2
  346. package/src/tests/secret-scrub-gate.test.ts +7 -0
  347. package/src/tests/secret-scrubber.test.ts +62 -2
  348. package/src/tests/seed-scripts.test.ts +2 -2
  349. package/src/tests/session-logs.test.ts +1 -260
  350. package/src/tests/slack-render-v2.test.ts +5 -148
  351. package/src/tests/system-one-hosts-ui-mirror.test.ts +1 -0
  352. package/src/tests/task-cascade-fail.test.ts +1 -0
  353. package/src/tests/task-supersede-resume.test.ts +1 -0
  354. package/src/tests/test-proc.ts +5 -2
  355. package/src/tests/vcs-azure-devops.test.ts +10 -0
  356. package/src/tests/vcs-provider.test.ts +8 -0
  357. package/src/tests/window-stream-reporter.test.ts +122 -0
  358. package/src/tests/workflow-agent-task-retry.test.ts +1 -3
  359. package/src/tests/workflow-cascade-cancel.test.ts +1 -0
  360. package/src/tests/workflow-retry-v2.test.ts +34 -43
  361. package/src/tests/workflow-retry-validation.test.ts +8 -48
  362. package/src/tests/worktree-reaper.test.ts +2 -2
  363. package/src/themes/design-system.ts +163 -0
  364. package/src/themes/page-theme.ts +28 -19
  365. package/src/tools/cancel-task.ts +2 -2
  366. package/src/tools/chat-post.ts +7 -3
  367. package/src/tools/create-page.ts +3 -0
  368. package/src/tools/defer-task.ts +7 -2
  369. package/src/tools/design-system.ts +102 -0
  370. package/src/tools/get-task-details.ts +8 -4
  371. package/src/tools/get-tasks.ts +13 -2
  372. package/src/tools/manage-user.ts +9 -0
  373. package/src/tools/mcp-servers/mcp-server-get.ts +1 -1
  374. package/src/tools/mcp-servers/mcp-server-list.ts +1 -1
  375. package/src/tools/register-chat-channel.ts +11 -2
  376. package/src/tools/skills/skill-get-file.ts +1 -1
  377. package/src/tools/skills/skill-get.ts +1 -1
  378. package/src/tools/skills/skill-list.ts +1 -1
  379. package/src/tools/skills/skill-search.ts +1 -1
  380. package/src/tools/store-progress.ts +5 -3
  381. package/src/tools/utils.ts +49 -4
  382. package/src/tools/workflows/get-workflow-run.ts +1 -1
  383. package/src/tools/workflows/get-workflow.ts +1 -1
  384. package/src/tools/workflows/list-workflow-runs.ts +1 -1
  385. package/src/tools/workflows/list-workflows.ts +1 -1
  386. package/src/types.ts +158 -0
  387. package/src/utils/constants.ts +12 -0
  388. package/src/utils/credentials.ts +42 -5
  389. package/src/utils/error-tracker.ts +6 -0
  390. package/src/utils/key-usage.ts +114 -0
  391. package/src/utils/sandboxed-process.ts +1 -0
  392. package/src/utils/secret-rules.generated.ts +149 -149
  393. package/src/utils/secret-scrubber.ts +111 -5
  394. package/src/vcs/azure-devops.ts +22 -1
  395. package/src/vcs/index.ts +3 -1
  396. package/src/workflows/approval-inline.ts +122 -0
  397. package/src/workflows/approval-notifications.ts +7 -2
  398. package/src/workflows/engine.ts +6 -5
  399. package/src/workflows/executors/agent-task.ts +14 -0
  400. package/src/workflows/executors/system-one-providers.ts +23 -0
  401. package/src/workflows/resume.ts +5 -2
  402. package/templates/skills/apps/SKILL.md +2 -0
  403. package/templates/skills/apps/content.md +2 -0
  404. package/templates/skills/boards-and-sheets/content.md +4 -2
  405. package/templates/skills/pages/content.md +41 -8
  406. package/templates/skills/swarm-docs/content.md +6 -0
  407. package/templates/skills/swarm-scripts/SKILL.md +1 -0
  408. package/templates/skills/swarm-scripts/content.md +1 -0
  409. package/templates/skills/workflow-iterate/content.md +1 -1
  410. package/dist/acp-adapter-t2q6nsqv.js +0 -17
  411. package/dist/cli-kh973792.js +0 -98
  412. package/dist/core-nheayfgm.js +0 -42
  413. package/dist/fx-adapter-8g7xsp8q.js +0 -20
  414. package/dist/grok-adapter-ztk2zkz1.js +0 -20
  415. package/dist/handlers-9ywssz71.js +0 -41
  416. package/dist/index-6mgbdtv1.js +0 -44
  417. package/dist/index-hqdsn2t2.js +0 -39
  418. package/dist/index-st231bqv.js +0 -40
  419. package/dist/lead-mk0xkth2.js +0 -82
  420. package/dist/thread-buffer-d50rqpev.js +0 -42
  421. package/dist/worker-662x1vse.js +0 -82
  422. package/src/tests/apps-table-selection-migration.test.ts +0 -95
  423. package/src/tests/extensions-example-heartbeat-remediate.test.ts +0 -69
  424. package/src/tests/extensions-example-rewrite-and-suppress.test.ts +0 -70
@@ -12,7 +12,7 @@
12
12
  * by feeding the parsed object directly into `buildRatingsFromLlm`),
13
13
  * and assert `agent_memory.alpha/beta` move + `memory_rating` rows are
14
14
  * written.
15
- * 4. Negative path: `MEMORY_RATERS` unset → no `/api/memory/rate` call.
15
+ * 4. Empty rating batches do not send requests.
16
16
  */
17
17
  import { afterAll, beforeAll, beforeEach, describe, expect, test } from "bun:test";
18
18
  import { randomUUID } from "node:crypto";
@@ -233,21 +233,33 @@ describe("buildRatingsFromLlm", () => {
233
233
  describe("postRatings model forwarding", () => {
234
234
  test("sends model in the POST body only when the event carries one", async () => {
235
235
  let sent: { events: Array<Record<string, unknown>> } | null = null;
236
- const fetchImpl = (async (_url: string, init?: RequestInit) => {
236
+ const fetchImpl = (async (url: string, init?: RequestInit) => {
237
+ expect(url).toBe("http://localhost:3013/api/memory/rate");
238
+ expect(init?.method).toBe("POST");
239
+ expect(init?.headers).toEqual({
240
+ "Content-Type": "application/json",
241
+ "X-Agent-ID": "agent-1",
242
+ Authorization: "Bearer k",
243
+ });
237
244
  sent = JSON.parse(String(init?.body));
238
245
  return new Response(JSON.stringify({ applied: 2, rejected: [] }), { status: 200 });
239
246
  }) as unknown as typeof fetch;
240
- await postRatings({
247
+ const result = await postRatings({
241
248
  apiUrl: "http://localhost:3013",
242
249
  apiKey: "k",
243
250
  agentId: "agent-1",
251
+ taskId: "task-1",
244
252
  events: [
245
253
  { memoryId: "m1", signal: 1, weight: 0.8, source: "llm", model: "p/m" },
246
254
  { memoryId: "m2", signal: 1, weight: 0.8, source: "llm" },
247
255
  ],
248
256
  fetchImpl,
249
257
  });
250
- expect(sent!.events[0]).toMatchObject({ memoryId: "m1", model: "p/m" });
258
+ expect(result).toEqual({ ok: true, status: 200 });
259
+ expect(sent!.events).toEqual([
260
+ { memoryId: "m1", signal: 1, weight: 0.8, source: "llm", model: "p/m", taskId: "task-1" },
261
+ { memoryId: "m2", signal: 1, weight: 0.8, source: "llm", taskId: "task-1" },
262
+ ]);
251
263
  expect("model" in sent!.events[1]!).toBe(false);
252
264
  });
253
265
  });
@@ -587,7 +599,7 @@ describe("LlmRater.rate(ctx) — per-memory path with MockLlmRaterClient", () =>
587
599
 
588
600
  // ─────────────────────────────────────────────────────────────────────────────
589
601
  // 3. HTTP integration — hook-piggyback dry-run.
590
- // 4. Negative path — MEMORY_RATERS unset → no rate call.
602
+ // 4. Empty rating batches do not send requests.
591
603
  // ─────────────────────────────────────────────────────────────────────────────
592
604
 
593
605
  let TEST_PORT = 0;
@@ -848,43 +860,22 @@ describe("HTTP integration: hook-piggyback dry-run", () => {
848
860
  expect(await getRatings(taskB)).toHaveLength(1);
849
861
  });
850
862
 
851
- test("negative path: simulated hook with MEMORY_RATERS unset → no /api/memory/rate call", async () => {
852
- const m = await makeMemory("piggyback-negative");
853
- await insertRetrieval(taskA, m.id);
854
-
855
- const prev = process.env.MEMORY_RATERS;
856
- delete process.env.MEMORY_RATERS;
857
- try {
858
- // Mirror the hook's gate: when isLlmRaterEnabled() is false, the hook
859
- // never calls fetchRetrievalsForTask / generateObject / postRatings —
860
- // it falls back to the existing summary-only path.
861
- let postCalled = false;
862
- const fakeFetch: typeof fetch = async () => {
863
- postCalled = true;
864
- return new Response("{}", { status: 200 });
865
- };
866
- if (!isLlmRaterEnabled()) {
867
- // No call at all — assertion is "we did not invoke postRatings".
868
- expect(postCalled).toBe(false);
869
- }
870
- // Sanity: if we DID call postRatings, nothing got applied because no events.
871
- const r = await postRatings({
872
- apiUrl: BASE,
873
- apiKey: API_KEY,
874
- agentId: agentA,
875
- taskId: taskA,
876
- events: [],
877
- fetchImpl: fakeFetch,
878
- });
879
- expect(r.ok).toBe(true);
880
- expect(postCalled).toBe(false); // events=[] short-circuits before fetch
881
- } finally {
882
- if (prev !== undefined) process.env.MEMORY_RATERS = prev;
883
- }
884
-
885
- // No memory_rating rows for taskA in this test.
886
- expect(await getRatings(taskA)).toHaveLength(0);
887
- expect(await readPosterior(m.id)).toEqual({ alpha: 1.0, beta: 1.0 });
863
+ test("postRatings with no events does not fetch", async () => {
864
+ let postCalled = false;
865
+ const fakeFetch: typeof fetch = async () => {
866
+ postCalled = true;
867
+ return new Response("{}", { status: 200 });
868
+ };
869
+ const result = await postRatings({
870
+ apiUrl: BASE,
871
+ apiKey: API_KEY,
872
+ agentId: agentA,
873
+ taskId: taskA,
874
+ events: [],
875
+ fetchImpl: fakeFetch,
876
+ });
877
+ expect(result).toEqual({ ok: true, status: 0 });
878
+ expect(postCalled).toBe(false);
888
879
  });
889
880
 
890
881
  test("postRatings logs but does not throw on 4xx (best-effort)", async () => {
@@ -911,111 +902,4 @@ describe("HTTP integration: hook-piggyback dry-run", () => {
911
902
  // Posterior unchanged — 400 means nothing was applied.
912
903
  expect(await readPosterior(m.id)).toEqual({ alpha: 1.0, beta: 1.0 });
913
904
  });
914
-
915
- test("OPENROUTER_API_KEY unset → hook is a no-op (no fetch, no index, no rate POST)", async () => {
916
- const m = await makeMemory("piggyback-openrouter-unset");
917
- await insertRetrieval(taskA, m.id);
918
-
919
- // Mirror the hook's outer gate exactly: when OPENROUTER_API_KEY is unset,
920
- // the entire summary + rating block must early-return. No call to
921
- // /api/memory/index, no call to /api/memory/rate, no LLM invocation.
922
- const prev = process.env.OPENROUTER_API_KEY;
923
- delete process.env.OPENROUTER_API_KEY;
924
- try {
925
- let anyFetchCalled = false;
926
- const fakeFetch: typeof fetch = async () => {
927
- anyFetchCalled = true;
928
- return new Response("{}", { status: 200 });
929
- };
930
-
931
- const skip = !process.env.OPENROUTER_API_KEY;
932
- expect(skip).toBe(true);
933
-
934
- // The hook block is entirely guarded — no fetch, no postRatings.
935
- // We never reach fetchRetrievalsForTask or postRatings, so neither is
936
- // exercised in this branch.
937
- if (!skip) {
938
- // Unreachable in this test — defensive assertion only.
939
- await fetchRetrievalsForTask({
940
- apiUrl: BASE,
941
- apiKey: API_KEY,
942
- agentId: agentA,
943
- taskId: taskA,
944
- fetchImpl: fakeFetch,
945
- });
946
- }
947
- expect(anyFetchCalled).toBe(false);
948
- } finally {
949
- if (prev !== undefined) process.env.OPENROUTER_API_KEY = prev;
950
- }
951
-
952
- // No memory_rating rows for taskA, posterior unchanged.
953
- expect(await getRatings(taskA)).toHaveLength(0);
954
- expect(await readPosterior(m.id)).toEqual({ alpha: 1.0, beta: 1.0 });
955
- });
956
-
957
- test("happy path: mocked generateObject result → postRatings called with expected events", async () => {
958
- const useful = await makeMemory("happy-useful");
959
- const misleading = await makeMemory("happy-misleading");
960
-
961
- await insertRetrieval(taskB, useful.id);
962
- await insertRetrieval(taskB, misleading.id);
963
-
964
- const retrievals = await fetchRetrievalsForTask({
965
- apiUrl: BASE,
966
- apiKey: API_KEY,
967
- agentId: agentA,
968
- taskId: taskB,
969
- });
970
- expect(retrievals).toHaveLength(2);
971
-
972
- // Stand in for `const { object } = await generateObject(...)` — the AI
973
- // SDK guarantees `object` is already validated against the Zod schema.
974
- const generateObjectResult: {
975
- object: { summary: string; ratings: Array<{ id: string; score: number; reasoning: string }> };
976
- } = {
977
- object: {
978
- summary: "Two patterns surfaced; one was misleading.",
979
- ratings: [
980
- { id: useful.id, score: 1, reasoning: "directly answered" },
981
- { id: misleading.id, score: 0, reasoning: "contradicted the docs" },
982
- ],
983
- },
984
- };
985
-
986
- // Schema gate is implicit in the SDK, but assert here so a future schema
987
- // change doesn't silently make this test pass on garbage data.
988
- const validated = SummaryWithRatingsSchema.parse(generateObjectResult.object);
989
-
990
- const events = buildRatingsFromLlm(validated.ratings, retrievals);
991
- expect(events).toHaveLength(2);
992
- const usefulEvent = events.find((e) => e.memoryId === useful.id)!;
993
- const misleadingEvent = events.find((e) => e.memoryId === misleading.id)!;
994
- expect(usefulEvent.signal).toBeCloseTo(1, 6);
995
- expect(misleadingEvent.signal).toBeCloseTo(-1, 6);
996
- expect(usefulEvent.source).toBe("llm");
997
- expect(misleadingEvent.source).toBe("llm");
998
-
999
- // Track that postRatings actually attempts the POST with our events.
1000
- let postedEvents: RatingEvent[] | null = null;
1001
- const trackingFetch: typeof fetch = async (url, init) => {
1002
- if (typeof url === "string" && url.endsWith("/api/memory/rate")) {
1003
- const body = JSON.parse(String(init?.body ?? "{}"));
1004
- postedEvents = body.events;
1005
- }
1006
- return new Response("{}", { status: 200 });
1007
- };
1008
- const r = await postRatings({
1009
- apiUrl: BASE,
1010
- apiKey: API_KEY,
1011
- agentId: agentA,
1012
- taskId: taskB,
1013
- events,
1014
- fetchImpl: trackingFetch,
1015
- });
1016
- expect(r.ok).toBe(true);
1017
- expect(postedEvents).not.toBeNull();
1018
- expect(postedEvents!).toHaveLength(2);
1019
- expect(postedEvents!.map((e) => e.memoryId).sort()).toEqual([useful.id, misleading.id].sort());
1020
- });
1021
905
  });
@@ -137,7 +137,22 @@ describe("SqliteMemoryStore", () => {
137
137
  totalChunks: 2,
138
138
  })),
139
139
  );
140
- await expect(store.storeBatch([{ ...input, content: "new" }])).rejects.toThrow();
140
+ await store.whenFtsPopulated();
141
+ const counts = () =>
142
+ getDbClient().get(
143
+ `SELECT (SELECT COUNT(*) FROM agent_memory) AS memories,
144
+ (SELECT COUNT(*) FROM agent_memory_version) AS versions,
145
+ (SELECT COUNT(*) FROM memory_fts) AS fts`,
146
+ );
147
+ const before = await counts();
148
+ // The first insert succeeds before the existing document rejects the second.
149
+ await expect(
150
+ store.storeBatch([
151
+ { ...input, key: "/test/rewrite-transient", content: "transient" },
152
+ { ...input, content: "new" },
153
+ ]),
154
+ ).rejects.toThrow("UNIQUE constraint failed");
155
+ expect(await counts()).toEqual(before);
141
156
  for (const chunk of chunks) expect(await store.peek(chunk.id)).not.toBeNull();
142
157
  expect(await store.deleteBySourcePath(key, agentA)).toBe(2);
143
158
  const replacement = await store.storeBatch([{ ...input, content: "new" }]);
@@ -218,22 +233,6 @@ describe("SqliteMemoryStore", () => {
218
233
  });
219
234
 
220
235
  describe("store()", () => {
221
- test("creates memory with correct fields", async () => {
222
- const memory = await store.store({
223
- agentId: agentA,
224
- scope: "agent",
225
- name: "test memory",
226
- content: "test content",
227
- source: "manual",
228
- });
229
- expect(memory.id).toBeDefined();
230
- expect(memory.agentId).toBe(agentA);
231
- expect(memory.scope).toBe("agent");
232
- expect(memory.name).toBe("test memory");
233
- expect(memory.content).toBe("test content");
234
- expect(memory.source).toBe("manual");
235
- });
236
-
237
236
  test("task_completion → expiresAt ≈ now + 7d", async () => {
238
237
  const before = Date.now();
239
238
  const memory = await store.store({
@@ -249,6 +248,9 @@ describe("SqliteMemoryStore", () => {
249
248
  const expectedMax = Date.now() + 7 * 86400000 + 5000;
250
249
  expect(expires).toBeGreaterThan(expectedMin);
251
250
  expect(expires).toBeLessThan(expectedMax);
251
+ expect(
252
+ await getDbClient().get("SELECT expiresAt FROM agent_memory WHERE id = ?", [memory.id]),
253
+ ).toEqual({ expiresAt: memory.expiresAt });
252
254
  });
253
255
 
254
256
  test("session_summary → expiresAt ≈ now + 3d", async () => {
@@ -274,18 +276,9 @@ describe("SqliteMemoryStore", () => {
274
276
  source: "manual",
275
277
  });
276
278
  expect(memory.expiresAt).toBeNull();
277
- });
278
- });
279
-
280
- describe("storeBatch()", () => {
281
- test("atomically stores multiple memories", async () => {
282
- const memories = await store.storeBatch([
283
- { agentId: agentA, scope: "agent", name: "batch1", content: "c1", source: "manual" },
284
- { agentId: agentA, scope: "agent", name: "batch2", content: "c2", source: "manual" },
285
- ]);
286
- expect(memories).toHaveLength(2);
287
- expect(memories[0]!.name).toBe("batch1");
288
- expect(memories[1]!.name).toBe("batch2");
279
+ expect(
280
+ await getDbClient().get("SELECT expiresAt FROM agent_memory WHERE id = ?", [memory.id]),
281
+ ).toEqual({ expiresAt: null });
289
282
  });
290
283
  });
291
284
 
@@ -491,6 +484,7 @@ describe("SqliteMemoryStore", () => {
491
484
  await getDbClient().run("DELETE FROM memory_vec WHERE memory_id = ?", [raw.id]);
492
485
 
493
486
  const freshStore = new SqliteMemoryStore();
487
+ await freshStore.whenFtsPopulated();
494
488
  const health = freshStore.getHealth();
495
489
 
496
490
  expect(health.counts.missingFromVec).toBe(0);
@@ -527,6 +521,7 @@ describe("SqliteMemoryStore", () => {
527
521
  `);
528
522
 
529
523
  const freshStore = new SqliteMemoryStore();
524
+ await freshStore.whenFtsPopulated();
530
525
  const health = freshStore.getHealth();
531
526
 
532
527
  expect(health.sqliteVec.schema).toContain("distance_metric=cosine");
@@ -554,102 +549,6 @@ describe("SqliteMemoryStore", () => {
554
549
  });
555
550
  });
556
551
 
557
- describe("deleteBySourcePath()", () => {
558
- test("removes all matching memories", async () => {
559
- const path = "/test/delete-path.ts";
560
- await store.store({
561
- agentId: agentA,
562
- scope: "agent",
563
- name: "chunk1",
564
- content: "c1",
565
- source: "file_index",
566
- sourcePath: path,
567
- });
568
- await store.store({
569
- agentId: agentA,
570
- scope: "agent",
571
- name: "chunk2",
572
- content: "c2",
573
- source: "file_index",
574
- sourcePath: path,
575
- });
576
-
577
- const deleted = await store.deleteBySourcePath(path, agentA);
578
- expect(deleted).toBe(2);
579
- });
580
- });
581
-
582
- describe("updateEmbedding()", () => {
583
- test("sets embedding and model", async () => {
584
- const memory = await store.store({
585
- agentId: agentA,
586
- scope: "agent",
587
- name: "embed test",
588
- content: "embeddable",
589
- source: "manual",
590
- });
591
- await store.updateEmbedding(
592
- memory.id,
593
- new Float32Array([1, 2, 3]),
594
- "openai/text-embedding-3-small",
595
- );
596
-
597
- const updated = await store.peek(memory.id);
598
- expect(updated!.embeddingModel).toBe("openai/text-embedding-3-small");
599
- });
600
- });
601
-
602
- describe("getStats()", () => {
603
- test("returns correct counts", async () => {
604
- const statsAgent = "cccc0000-0000-4000-8000-000000000003";
605
- await createAgent({ id: statsAgent, name: "Stats Agent", isLead: false, status: "idle" });
606
-
607
- await store.store({
608
- agentId: statsAgent,
609
- scope: "agent",
610
- name: "s1",
611
- content: "c1",
612
- source: "manual",
613
- });
614
- await store.store({
615
- agentId: statsAgent,
616
- scope: "swarm",
617
- name: "s2",
618
- content: "c2",
619
- source: "task_completion",
620
- });
621
- await store.store({
622
- agentId: statsAgent,
623
- scope: "agent",
624
- name: "s3",
625
- content: "c3",
626
- source: "manual",
627
- });
628
-
629
- const stats = await store.getStats(statsAgent);
630
- expect(stats.total).toBe(3);
631
- expect(stats.bySource.manual).toBe(2);
632
- expect(stats.bySource.task_completion).toBe(1);
633
- expect(stats.byScope.agent).toBe(2);
634
- expect(stats.byScope.swarm).toBe(1);
635
- });
636
- });
637
-
638
- describe("listForReembedding()", () => {
639
- test("returns id and content", async () => {
640
- const all = await store.listForReembedding();
641
- expect(all.length).toBeGreaterThan(0);
642
- expect(all[0]).toHaveProperty("id");
643
- expect(all[0]).toHaveProperty("content");
644
- });
645
-
646
- test("filters by agentId", async () => {
647
- const filtered = await store.listForReembedding({ agentId: agentA });
648
- expect(filtered.every((_m) => true)).toBe(true); // just verifying it doesn't throw
649
- expect(filtered.length).toBeGreaterThan(0);
650
- });
651
- });
652
-
653
552
  describe("purgeExpired()", () => {
654
553
  const purgeAgent = "cccc0000-0000-4000-8000-000000000003";
655
554
 
@@ -292,26 +292,6 @@ describe("Memory System", () => {
292
292
  });
293
293
 
294
294
  describe("store.get (getMemoryById)", () => {
295
- test("returns existing memory", async () => {
296
- const created = await store.store({
297
- agentId: agentA,
298
- scope: "agent",
299
- name: "Findable",
300
- content: "Find me",
301
- source: "manual",
302
- });
303
-
304
- const found = await store.get(created.id);
305
- expect(found).not.toBeNull();
306
- expect(found!.id).toBe(created.id);
307
- expect(found!.name).toBe("Findable");
308
- });
309
-
310
- test("returns null for non-existent ID", async () => {
311
- const found = await store.get("00000000-0000-0000-0000-000000000000");
312
- expect(found).toBeNull();
313
- });
314
-
315
295
  test("updates accessedAt on retrieval", async () => {
316
296
  const created = await store.store({
317
297
  agentId: agentA,
@@ -321,16 +301,18 @@ describe("Memory System", () => {
321
301
  source: "manual",
322
302
  });
323
303
 
324
- // Force a tiny delay so timestamps differ
325
- const start = performance.now();
326
- while (performance.now() - start < 5) {
327
- /* spin */
328
- }
329
-
330
- const found = await store.get(created.id);
331
- expect(found).not.toBeNull();
332
- // accessedAt should be updated (may or may not differ depending on timing)
333
- expect(found!.accessedAt).toBeDefined();
304
+ const stale = "2000-01-01T00:00:00.000Z";
305
+ await getDbClient().run("UPDATE agent_memory SET accessedAt = ? WHERE id = ?", [
306
+ stale,
307
+ created.id,
308
+ ]);
309
+ const before = Date.now();
310
+ expect(await store.get(created.id)).not.toBeNull();
311
+ // get() returns the old row. Inspect the committed update without another access.
312
+ const persisted = await store.peek(created.id);
313
+ expect(persisted!.accessedAt).not.toBe(stale);
314
+ expect(Date.parse(persisted!.accessedAt)).toBeGreaterThanOrEqual(before);
315
+ expect(Date.parse(persisted!.accessedAt)).toBeLessThanOrEqual(Date.now());
334
316
  });
335
317
  });
336
318
 
@@ -344,20 +326,24 @@ describe("Memory System", () => {
344
326
  source: "manual",
345
327
  });
346
328
 
329
+ const unembedded = await getDbClient().get<{ embedding: Buffer | null }>(
330
+ "SELECT embedding FROM agent_memory WHERE id = ?",
331
+ [memory.id],
332
+ );
333
+ expect(unembedded!.embedding).toBeNull();
347
334
  const embedding = new Float32Array([0.1, 0.2, 0.3, -0.5]);
348
335
  await store.updateEmbedding(memory.id, embedding, "test-model");
349
336
 
350
337
  // Read back the raw row to check embedding
351
- const row = (await getDbClient().get<{ embedding: Buffer | null }>(
352
- "SELECT embedding FROM agent_memory WHERE id = ?",
338
+ const row = (await getDbClient().get<{ embedding: Buffer | null; embeddingModel: string }>(
339
+ "SELECT embedding, embeddingModel FROM agent_memory WHERE id = ?",
353
340
  [memory.id],
354
341
  ))!;
355
342
  expect(row.embedding).not.toBeNull();
343
+ expect(row.embeddingModel).toBe("test-model");
356
344
 
357
345
  const restored = deserializeEmbedding(row.embedding!);
358
- expect(restored.length).toBe(4);
359
- expect(restored[0]).toBeCloseTo(0.1, 5);
360
- expect(restored[3]).toBeCloseTo(-0.5, 5);
346
+ expect(restored).toEqual(embedding);
361
347
  });
362
348
  });
363
349
 
@@ -569,29 +555,6 @@ describe("Memory System", () => {
569
555
  });
570
556
  });
571
557
 
572
- describe("store.delete (deleteMemory)", () => {
573
- test("deletes existing memory", async () => {
574
- const memory = await store.store({
575
- agentId: agentA,
576
- scope: "agent",
577
- name: "To Delete",
578
- content: "Delete me",
579
- source: "manual",
580
- });
581
-
582
- const deleted = await store.delete(memory.id);
583
- expect(deleted).toBe(true);
584
-
585
- const found = await store.get(memory.id);
586
- expect(found).toBeNull();
587
- });
588
-
589
- test("returns false for non-existent memory", async () => {
590
- const deleted = await store.delete("00000000-0000-0000-0000-000000000000");
591
- expect(deleted).toBe(false);
592
- });
593
- });
594
-
595
558
  describe("store.deleteBySourcePath (deleteMemoriesBySourcePath)", () => {
596
559
  test("deletes all chunks for a source path", async () => {
597
560
  const path = "/workspace/personal/memory/to-reindex.md";
@@ -645,12 +608,20 @@ describe("Memory System", () => {
645
608
  content: "Content",
646
609
  source: "manual",
647
610
  });
611
+ await store.store({
612
+ agentId: statsAgent,
613
+ scope: "agent",
614
+ name: "Stat 4",
615
+ content: "Content",
616
+ source: "task_completion",
617
+ });
648
618
 
649
619
  const stats = await store.getStats(statsAgent);
650
- expect(stats.total).toBe(3);
620
+ expect(stats.total).toBe(4);
651
621
  expect(stats.bySource.manual).toBe(2);
652
622
  expect(stats.bySource.file_index).toBe(1);
653
- expect(stats.byScope.agent).toBe(2);
623
+ expect(stats.bySource.task_completion).toBe(1);
624
+ expect(stats.byScope.agent).toBe(3);
654
625
  expect(stats.byScope.swarm).toBe(1);
655
626
  expect(stats.withEmbeddings).toBe(0);
656
627
  expect(stats.expired).toBe(0);
@@ -768,45 +739,5 @@ describe("Memory System", () => {
768
739
  expect(m.totalChunks).toBe(chunks.length);
769
740
  }
770
741
  });
771
-
772
- test("memory created without embedding has null embedding in DB", async () => {
773
- const memory = await store.store({
774
- agentId: ingestAgent,
775
- content: "No embedding needed",
776
- name: "no-embed",
777
- scope: "agent",
778
- source: "manual",
779
- });
780
-
781
- const row = (await getDbClient().get<{ embedding: Buffer | null }>(
782
- "SELECT embedding FROM agent_memory WHERE id = ?",
783
- [memory.id],
784
- ))!;
785
- expect(row.embedding).toBeNull();
786
- });
787
-
788
- test("store.updateEmbedding stores and retrieves correctly", async () => {
789
- const memory = await store.store({
790
- agentId: ingestAgent,
791
- content: "Embed me",
792
- name: "embed-update",
793
- scope: "agent",
794
- source: "manual",
795
- });
796
-
797
- const embedding = new Float32Array([0.5, -0.3, 0.8]);
798
- await store.updateEmbedding(memory.id, embedding, "test-model");
799
-
800
- const row = (await getDbClient().get<{ embedding: Buffer | null }>(
801
- "SELECT embedding FROM agent_memory WHERE id = ?",
802
- [memory.id],
803
- ))!;
804
- expect(row.embedding).not.toBeNull();
805
-
806
- const restored = deserializeEmbedding(row.embedding!);
807
- expect(restored[0]).toBeCloseTo(0.5, 5);
808
- expect(restored[1]).toBeCloseTo(-0.3, 5);
809
- expect(restored[2]).toBeCloseTo(0.8, 5);
810
- });
811
742
  });
812
743
  });