@sixb/core 0.1.25 → 0.1.26

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 (446) hide show
  1. package/dist/actions/index.js +35 -35
  2. package/dist/agents/attachment-keys.d.ts +25 -0
  3. package/dist/agents/attachment-keys.d.ts.map +1 -0
  4. package/dist/agents/cancel.d.ts +12 -0
  5. package/dist/agents/cancel.d.ts.map +1 -1
  6. package/dist/agents/children.d.ts.map +1 -1
  7. package/dist/agents/dispatch.d.ts +1 -9
  8. package/dist/agents/dispatch.d.ts.map +1 -1
  9. package/dist/agents/execution.d.ts +5 -0
  10. package/dist/agents/execution.d.ts.map +1 -1
  11. package/dist/agents/index.d.ts +31 -6
  12. package/dist/agents/index.d.ts.map +1 -1
  13. package/dist/agents/index.js +154 -66
  14. package/dist/agents/index.js.map +1 -1
  15. package/dist/agents/model-loop.d.ts +3 -5
  16. package/dist/agents/model-loop.d.ts.map +1 -1
  17. package/dist/agents/model-routing.d.ts +4 -1
  18. package/dist/agents/model-routing.d.ts.map +1 -1
  19. package/dist/agents/request.d.ts +9 -1
  20. package/dist/agents/request.d.ts.map +1 -1
  21. package/dist/agents/run-after-finish.d.ts +11 -0
  22. package/dist/agents/run-after-finish.d.ts.map +1 -0
  23. package/dist/agents/run-artifacts.d.ts +56 -0
  24. package/dist/agents/run-artifacts.d.ts.map +1 -0
  25. package/dist/agents/run-events.d.ts +49 -0
  26. package/dist/agents/run-events.d.ts.map +1 -0
  27. package/dist/agents/run-fence.d.ts +38 -0
  28. package/dist/agents/run-fence.d.ts.map +1 -0
  29. package/dist/agents/run-liveness.d.ts +36 -0
  30. package/dist/agents/run-liveness.d.ts.map +1 -0
  31. package/dist/agents/run-plan.d.ts +110 -0
  32. package/dist/agents/run-plan.d.ts.map +1 -0
  33. package/dist/agents/run-session-children.d.ts +89 -0
  34. package/dist/agents/run-session-children.d.ts.map +1 -0
  35. package/dist/agents/run-session-http.d.ts +37 -0
  36. package/dist/agents/run-session-http.d.ts.map +1 -0
  37. package/dist/agents/run-session-serve.d.ts +24 -0
  38. package/dist/agents/run-session-serve.d.ts.map +1 -0
  39. package/dist/agents/run-session-wire.d.ts +31 -0
  40. package/dist/agents/run-session-wire.d.ts.map +1 -0
  41. package/dist/agents/run-session.d.ts +239 -0
  42. package/dist/agents/run-session.d.ts.map +1 -0
  43. package/dist/agents/run-token.d.ts +40 -0
  44. package/dist/agents/run-token.d.ts.map +1 -0
  45. package/dist/agents/run-tools.d.ts +68 -0
  46. package/dist/agents/run-tools.d.ts.map +1 -0
  47. package/dist/agents/run-turn.d.ts +59 -0
  48. package/dist/agents/run-turn.d.ts.map +1 -0
  49. package/dist/agents/streams/index.js +1 -1
  50. package/dist/agents/streams/internal.d.ts +1 -1
  51. package/dist/agents/streams/internal.d.ts.map +1 -1
  52. package/dist/agents/streams/internal.js +2 -4
  53. package/dist/agents/streams/internal.js.map +1 -1
  54. package/dist/agents/streams/protocol.d.ts +1 -96
  55. package/dist/agents/streams/protocol.d.ts.map +1 -1
  56. package/dist/agents/subagent-runs.d.ts +7 -1
  57. package/dist/agents/subagent-runs.d.ts.map +1 -1
  58. package/dist/agents/tool-files.d.ts +34 -0
  59. package/dist/agents/tool-files.d.ts.map +1 -0
  60. package/dist/agents/workflow-node-session.d.ts +99 -0
  61. package/dist/agents/workflow-node-session.d.ts.map +1 -0
  62. package/dist/artifacts/frames/index.js +1 -1
  63. package/dist/artifacts/frames/index.js.map +1 -1
  64. package/dist/artifacts/index.js.map +1 -1
  65. package/dist/artifacts/publish/index.d.ts +1 -1
  66. package/dist/artifacts/publish/index.d.ts.map +1 -1
  67. package/dist/artifacts/publish/index.js +19 -19
  68. package/dist/auth/index.js +8 -8
  69. package/dist/authorization/index.js +4 -4
  70. package/dist/bootstrap/index.js +45 -43
  71. package/dist/bootstrap/index.js.map +2 -2
  72. package/dist/{chunk-2fn60nvs.js → chunk-06sg8s4z.js} +2 -2
  73. package/dist/{chunk-2fn60nvs.js.map → chunk-06sg8s4z.js.map} +1 -1
  74. package/dist/chunk-07kkp2e1.js.map +1 -1
  75. package/dist/{chunk-9ntbsnke.js → chunk-0bc3w0zq.js} +7 -7
  76. package/dist/{chunk-9ntbsnke.js.map → chunk-0bc3w0zq.js.map} +2 -2
  77. package/dist/{chunk-d2m879s4.js → chunk-0kk2wt0h.js} +27 -27
  78. package/dist/chunk-0kk2wt0h.js.map +12 -0
  79. package/dist/chunk-16a9dmfy.js.map +1 -1
  80. package/dist/chunk-18sk89cg.js.map +2 -2
  81. package/dist/{chunk-3qms4nax.js → chunk-1vg43g9q.js} +20 -20
  82. package/dist/{chunk-3qms4nax.js.map → chunk-1vg43g9q.js.map} +4 -4
  83. package/dist/{chunk-hqsp2sx4.js → chunk-1xvqgg88.js} +31 -33
  84. package/dist/{chunk-hqsp2sx4.js.map → chunk-1xvqgg88.js.map} +6 -6
  85. package/dist/chunk-2adz0h75.js.map +1 -1
  86. package/dist/{chunk-fm62y49k.js → chunk-2pk5hjj9.js} +5 -3
  87. package/dist/{chunk-fm62y49k.js.map → chunk-2pk5hjj9.js.map} +5 -5
  88. package/dist/{chunk-vrf90dkv.js → chunk-2vjnyz1s.js} +1 -1
  89. package/dist/{chunk-vrf90dkv.js.map → chunk-2vjnyz1s.js.map} +1 -1
  90. package/dist/{chunk-4f3ydv7t.js → chunk-315qye3g.js} +1 -1
  91. package/dist/{chunk-4f3ydv7t.js.map → chunk-315qye3g.js.map} +1 -1
  92. package/dist/{chunk-rap5w0x0.js → chunk-31khg3g0.js} +1 -1
  93. package/dist/{chunk-rap5w0x0.js.map → chunk-31khg3g0.js.map} +1 -1
  94. package/dist/chunk-45ngkxkp.js.map +1 -1
  95. package/dist/chunk-48jezz3j.js.map +1 -1
  96. package/dist/{chunk-vr3j63jq.js → chunk-4jq2bg8t.js} +78 -78
  97. package/dist/{chunk-vr3j63jq.js.map → chunk-4jq2bg8t.js.map} +4 -4
  98. package/dist/chunk-4ymrcdbm.js.map +1 -1
  99. package/dist/chunk-58geavnf.js.map +1 -1
  100. package/dist/{chunk-6y0mkhex.js → chunk-59kf345w.js} +2 -2
  101. package/dist/{chunk-6y0mkhex.js.map → chunk-59kf345w.js.map} +1 -1
  102. package/dist/{chunk-3p93tb91.js → chunk-6qn7nmd3.js} +102 -102
  103. package/dist/{chunk-3p93tb91.js.map → chunk-6qn7nmd3.js.map} +4 -4
  104. package/dist/chunk-73j0v4qv.js +355 -0
  105. package/dist/chunk-73j0v4qv.js.map +13 -0
  106. package/dist/{chunk-2gjj5dx3.js → chunk-78ymxrn0.js} +1 -1
  107. package/dist/{chunk-6bkbyer5.js → chunk-7ex2p3zp.js} +3 -3
  108. package/dist/{chunk-6bkbyer5.js.map → chunk-7ex2p3zp.js.map} +1 -1
  109. package/dist/{chunk-5tfev0fv.js → chunk-7hf6tkgs.js} +167 -167
  110. package/dist/{chunk-5tfev0fv.js.map → chunk-7hf6tkgs.js.map} +4 -4
  111. package/dist/{chunk-8z4726jz.js → chunk-7wn5z7mq.js} +10 -10
  112. package/dist/{chunk-8z4726jz.js.map → chunk-7wn5z7mq.js.map} +2 -2
  113. package/dist/{chunk-6n69k945.js → chunk-8mb7mt8n.js} +2 -2
  114. package/dist/chunk-8ncg20rd.js.map +1 -1
  115. package/dist/{chunk-68wghpdf.js → chunk-8v5a54qz.js} +50 -11
  116. package/dist/{chunk-68wghpdf.js.map → chunk-8v5a54qz.js.map} +3 -3
  117. package/dist/{chunk-gqm0b7vd.js → chunk-8v6xzwgr.js} +92 -76
  118. package/dist/{chunk-gqm0b7vd.js.map → chunk-8v6xzwgr.js.map} +6 -6
  119. package/dist/{chunk-m36fw8ft.js → chunk-8wsjr52f.js} +1 -1
  120. package/dist/{chunk-vd1rk42q.js → chunk-8xnz9vvp.js} +4 -4
  121. package/dist/{chunk-vd1rk42q.js.map → chunk-8xnz9vvp.js.map} +1 -1
  122. package/dist/chunk-9mab3dvg.js.map +1 -1
  123. package/dist/chunk-9tc8dxmn.js.map +1 -1
  124. package/dist/chunk-9x8dybsb.js.map +2 -2
  125. package/dist/chunk-a3faa34j.js.map +1 -1
  126. package/dist/{chunk-62a63pr6.js → chunk-axb4ss9a.js} +7 -7
  127. package/dist/{chunk-62a63pr6.js.map → chunk-axb4ss9a.js.map} +2 -2
  128. package/dist/{chunk-z3ryd53f.js → chunk-b6ghvap7.js} +35 -11
  129. package/dist/{chunk-z3ryd53f.js.map → chunk-b6ghvap7.js.map} +3 -3
  130. package/dist/{chunk-sqfvnvqj.js → chunk-c14ap3s9.js} +2 -2
  131. package/dist/{chunk-sqfvnvqj.js.map → chunk-c14ap3s9.js.map} +1 -1
  132. package/dist/{chunk-661ezhks.js → chunk-cbcgs9f7.js} +87 -8
  133. package/dist/chunk-cbcgs9f7.js.map +11 -0
  134. package/dist/chunk-cwdzcv37.js.map +1 -1
  135. package/dist/{chunk-bab05bhg.js → chunk-dgtd0836.js} +1 -1
  136. package/dist/{chunk-1j6j0rht.js → chunk-e24fvw8g.js} +1 -1
  137. package/dist/{chunk-1j6j0rht.js.map → chunk-e24fvw8g.js.map} +1 -1
  138. package/dist/chunk-e5wf5vz0.js.map +1 -1
  139. package/dist/chunk-eptrvnby.js.map +1 -1
  140. package/dist/chunk-ey1nk510.js.map +1 -1
  141. package/dist/{chunk-j936th07.js → chunk-fakrpfy3.js} +58 -58
  142. package/dist/{chunk-j936th07.js.map → chunk-fakrpfy3.js.map} +5 -5
  143. package/dist/chunk-fb3feg1e.js.map +1 -1
  144. package/dist/chunk-ff5xkv0p.js.map +1 -1
  145. package/dist/chunk-fntqb7qy.js.map +1 -1
  146. package/dist/{chunk-7ny9mjgm.js → chunk-ft3w5ahs.js} +1 -1
  147. package/dist/chunk-g663fahq.js.map +1 -1
  148. package/dist/{chunk-cdk3egjj.js → chunk-h1na2cxc.js} +1 -1
  149. package/dist/{chunk-cdk3egjj.js.map → chunk-h1na2cxc.js.map} +1 -1
  150. package/dist/chunk-hn2r7z41.js.map +1 -1
  151. package/dist/{chunk-24bqx0dx.js → chunk-hn76sanm.js} +1 -1
  152. package/dist/{chunk-24bqx0dx.js.map → chunk-hn76sanm.js.map} +1 -1
  153. package/dist/chunk-jmfet9r4.js.map +1 -1
  154. package/dist/{chunk-bnr4a734.js → chunk-jn3ysaf2.js} +24 -22
  155. package/dist/{chunk-bnr4a734.js.map → chunk-jn3ysaf2.js.map} +5 -5
  156. package/dist/{chunk-4y26vs3v.js → chunk-jspskey0.js} +16 -3
  157. package/dist/chunk-jspskey0.js.map +10 -0
  158. package/dist/{chunk-r6szek0x.js → chunk-jt3r6thp.js} +2 -135
  159. package/dist/chunk-jt3r6thp.js.map +10 -0
  160. package/dist/chunk-kfee1h52.js.map +1 -1
  161. package/dist/{chunk-qx00vjrj.js → chunk-kwfhd1g0.js} +23 -23
  162. package/dist/{chunk-qx00vjrj.js.map → chunk-kwfhd1g0.js.map} +4 -4
  163. package/dist/chunk-m427qgq0.js.map +1 -1
  164. package/dist/chunk-mbsbxarb.js.map +1 -1
  165. package/dist/{chunk-et017krg.js → chunk-mdxmt0n3.js} +8657 -8704
  166. package/dist/{chunk-et017krg.js.map → chunk-mdxmt0n3.js.map} +37 -37
  167. package/dist/chunk-mmagke4x.js.map +1 -1
  168. package/dist/{chunk-2x19q6k6.js → chunk-mqx25wwh.js} +319 -154
  169. package/dist/chunk-mqx25wwh.js.map +18 -0
  170. package/dist/chunk-mzx71snp.js.map +1 -1
  171. package/dist/chunk-n8q5j6y5.js.map +1 -1
  172. package/dist/chunk-npcr0228.js.map +1 -1
  173. package/dist/{chunk-m2nevja0.js → chunk-phm3c7b9.js} +1 -1
  174. package/dist/{chunk-m2nevja0.js.map → chunk-phm3c7b9.js.map} +1 -1
  175. package/dist/chunk-qf954wje.js.map +1 -1
  176. package/dist/{chunk-65pyhyas.js → chunk-qgvbxfqv.js} +6 -8
  177. package/dist/{chunk-65pyhyas.js.map → chunk-qgvbxfqv.js.map} +2 -2
  178. package/dist/{chunk-hk38wahh.js → chunk-qst145py.js} +4 -4
  179. package/dist/{chunk-hk38wahh.js.map → chunk-qst145py.js.map} +1 -1
  180. package/dist/{chunk-c844dkwd.js → chunk-qtzftvxa.js} +4 -5
  181. package/dist/{chunk-c844dkwd.js.map → chunk-qtzftvxa.js.map} +2 -2
  182. package/dist/chunk-ratkv4zc.js +3 -0
  183. package/dist/chunk-ratkv4zc.js.map +9 -0
  184. package/dist/{chunk-nzapm6p0.js → chunk-s3we74h8.js} +1 -2
  185. package/dist/chunk-s3we74h8.js.map +12 -0
  186. package/dist/{chunk-0xmt5p5y.js → chunk-t3brw0wd.js} +1 -2
  187. package/dist/{chunk-0xmt5p5y.js.map → chunk-t3brw0wd.js.map} +2 -2
  188. package/dist/chunk-t5608tkq.js.map +1 -1
  189. package/dist/chunk-tdxfsg1c.js.map +1 -1
  190. package/dist/{chunk-1t6k1avb.js → chunk-tnhqtfea.js} +1 -1
  191. package/dist/chunk-vhbw5sqm.js.map +1 -1
  192. package/dist/{chunk-rp9wwk7b.js → chunk-vx4e4zv4.js} +30 -30
  193. package/dist/{chunk-rp9wwk7b.js.map → chunk-vx4e4zv4.js.map} +4 -4
  194. package/dist/chunk-waqk73p1.js.map +1 -1
  195. package/dist/chunk-x0v3jd47.js.map +1 -1
  196. package/dist/{chunk-yecwnwpq.js → chunk-xm8qgbqm.js} +58 -29
  197. package/dist/{chunk-yecwnwpq.js.map → chunk-xm8qgbqm.js.map} +7 -7
  198. package/dist/{chunk-97wr6p2g.js → chunk-y7j6x4h0.js} +8 -8
  199. package/dist/{chunk-97wr6p2g.js.map → chunk-y7j6x4h0.js.map} +4 -4
  200. package/dist/{chunk-xe0732g0.js → chunk-yavhtnac.js} +12 -8
  201. package/dist/{chunk-xe0732g0.js.map → chunk-yavhtnac.js.map} +4 -4
  202. package/dist/chunk-yd00vzqr.js +3394 -0
  203. package/dist/chunk-yd00vzqr.js.map +37 -0
  204. package/dist/{chunk-n9w3n38q.js → chunk-ye5c8016.js} +54 -8
  205. package/dist/chunk-ye5c8016.js.map +23 -0
  206. package/dist/chunk-yw9pyg66.js.map +1 -1
  207. package/dist/{chunk-nydf3dbe.js → chunk-z9mg7wya.js} +37 -20
  208. package/dist/chunk-z9mg7wya.js.map +13 -0
  209. package/dist/chunk-zbc929zg.js.map +1 -1
  210. package/dist/chunk-zhh1jd89.js +290 -0
  211. package/dist/chunk-zhh1jd89.js.map +10 -0
  212. package/dist/connectors/connections/authorizations.d.ts +2 -2
  213. package/dist/connectors/connections/authorizations.d.ts.map +1 -1
  214. package/dist/connectors/connections/service.d.ts.map +1 -1
  215. package/dist/connectors/connections/tokens.d.ts +2 -2
  216. package/dist/connectors/connections/tokens.d.ts.map +1 -1
  217. package/dist/connectors/connections/validation.d.ts +5 -0
  218. package/dist/connectors/connections/validation.d.ts.map +1 -1
  219. package/dist/connectors/types.d.ts +9 -2
  220. package/dist/connectors/types.d.ts.map +1 -1
  221. package/dist/datasets/write.js +3 -3
  222. package/dist/deploy/internal.js +2 -5
  223. package/dist/deploy/internal.js.map +3 -3
  224. package/dist/deploy/types.d.ts +0 -2
  225. package/dist/deploy/types.d.ts.map +1 -1
  226. package/dist/execution/agent.d.ts +2 -2
  227. package/dist/execution/agent.d.ts.map +1 -1
  228. package/dist/execution/agent.js +38 -38
  229. package/dist/execution/agent.js.map +1 -1
  230. package/dist/execution/primitive.js +35 -35
  231. package/dist/execution/request.js +37 -37
  232. package/dist/execution/request.js.map +2 -2
  233. package/dist/http/api-routes.d.ts +12 -11
  234. package/dist/http/api-routes.d.ts.map +1 -1
  235. package/dist/http/index.js +1 -1
  236. package/dist/index.d.ts +3 -3
  237. package/dist/index.d.ts.map +1 -1
  238. package/dist/index.js +53 -51
  239. package/dist/index.js.map +1 -1
  240. package/dist/lake-storage/index.js +3 -3
  241. package/dist/logging/internal.js +1 -1
  242. package/dist/materializer/index.js +17 -17
  243. package/dist/models/execution/errors.d.ts +5 -0
  244. package/dist/models/execution/errors.d.ts.map +1 -1
  245. package/dist/models/execution/index.d.ts +2 -1
  246. package/dist/models/execution/index.d.ts.map +1 -1
  247. package/dist/models/execution/index.js +55 -50
  248. package/dist/models/execution/index.js.map +1 -1
  249. package/dist/models/execution/model-call-recorder.d.ts +7 -2
  250. package/dist/models/execution/model-call-recorder.d.ts.map +1 -1
  251. package/dist/models/execution.d.ts.map +1 -1
  252. package/dist/models/language-call.d.ts +51 -0
  253. package/dist/models/language-call.d.ts.map +1 -0
  254. package/dist/objects/index.js +35 -35
  255. package/dist/objects/query/index.js +17 -17
  256. package/dist/ontology/docs-markdown.d.ts.map +1 -1
  257. package/dist/ontology/index.d.ts +1 -1
  258. package/dist/ontology/index.d.ts.map +1 -1
  259. package/dist/ontology/index.js +4 -4
  260. package/dist/ontology/internal.js +8 -275
  261. package/dist/ontology/internal.js.map +3 -4
  262. package/dist/ontology/user-ref.d.ts +21 -3
  263. package/dist/ontology/user-ref.d.ts.map +1 -1
  264. package/dist/pipelines/index.js +19 -19
  265. package/dist/projections/builders.d.ts +13 -2
  266. package/dist/projections/builders.d.ts.map +1 -1
  267. package/dist/projections/index.d.ts +1 -1
  268. package/dist/projections/index.d.ts.map +1 -1
  269. package/dist/projections/internal.js +17 -17
  270. package/dist/projections/types.d.ts +7 -0
  271. package/dist/projections/types.d.ts.map +1 -1
  272. package/dist/projections/validation.d.ts +2 -0
  273. package/dist/projections/validation.d.ts.map +1 -1
  274. package/dist/query.js +2 -2
  275. package/dist/queues/in-memory.d.ts +0 -1
  276. package/dist/queues/in-memory.d.ts.map +1 -1
  277. package/dist/queues/index.d.ts +1 -1
  278. package/dist/queues/index.d.ts.map +1 -1
  279. package/dist/queues/index.js +1 -1
  280. package/dist/queues/types.d.ts +0 -8
  281. package/dist/queues/types.d.ts.map +1 -1
  282. package/dist/runtime/internal.js +23 -23
  283. package/dist/runtime/internal.js.map +1 -1
  284. package/dist/sandboxes/configuration.d.ts +4 -6
  285. package/dist/sandboxes/configuration.d.ts.map +1 -1
  286. package/dist/sandboxes/environment.d.ts.map +1 -1
  287. package/dist/sandboxes/exec.d.ts +5 -3
  288. package/dist/sandboxes/exec.d.ts.map +1 -1
  289. package/dist/sandboxes/guest-credentials.d.ts +61 -0
  290. package/dist/sandboxes/guest-credentials.d.ts.map +1 -0
  291. package/dist/sandboxes/index.d.ts +2 -0
  292. package/dist/sandboxes/index.d.ts.map +1 -1
  293. package/dist/sandboxes/index.js +23 -9
  294. package/dist/sandboxes/index.js.map +1 -1
  295. package/dist/sandboxes/sandbox.d.ts +18 -4
  296. package/dist/sandboxes/sandbox.d.ts.map +1 -1
  297. package/dist/security/internal.js +1 -1
  298. package/dist/security/internal.js.map +1 -1
  299. package/dist/shares/internal.js +17 -17
  300. package/dist/shares/internal.js.map +1 -1
  301. package/dist/storage/agents/in-memory.d.ts +3 -1
  302. package/dist/storage/agents/in-memory.d.ts.map +1 -1
  303. package/dist/storage/agents/index.d.ts +1 -1
  304. package/dist/storage/agents/index.d.ts.map +1 -1
  305. package/dist/storage/agents/provider.d.ts +6 -0
  306. package/dist/storage/agents/provider.d.ts.map +1 -1
  307. package/dist/storage/agents/provider.js +8 -2
  308. package/dist/storage/agents/provider.js.map +1 -1
  309. package/dist/storage/agents/types.d.ts +63 -7
  310. package/dist/storage/agents/types.d.ts.map +1 -1
  311. package/dist/storage/ai-cost/provider.js +2 -2
  312. package/dist/storage/connector-connections/provider.js.map +1 -1
  313. package/dist/storage/file-upload-sessions/provider.js +9 -9
  314. package/dist/storage/index.d.ts +1 -1
  315. package/dist/storage/index.d.ts.map +1 -1
  316. package/dist/storage/index.js +15 -15
  317. package/dist/storage/ontology/provider.js +1 -1
  318. package/dist/storage/share-grants/provider.js +3 -3
  319. package/dist/storage/types.d.ts +1 -1
  320. package/dist/storage/types.d.ts.map +1 -1
  321. package/dist/storage/workflow-runs/provider.js +9 -9
  322. package/dist/syncs/index.js +20 -20
  323. package/dist/testing/agent-storage-contract.d.ts.map +1 -1
  324. package/dist/testing/index.d.ts +2 -0
  325. package/dist/testing/index.d.ts.map +1 -1
  326. package/dist/testing/index.js +677 -352
  327. package/dist/testing/index.js.map +9 -7
  328. package/dist/testing/queues-contract.d.ts.map +1 -1
  329. package/dist/testing/sandbox-credentials-contract.d.ts +27 -0
  330. package/dist/testing/sandbox-credentials-contract.d.ts.map +1 -0
  331. package/dist/testing/sandboxes-contract.d.ts.map +1 -1
  332. package/dist/testing/users.d.ts +20 -0
  333. package/dist/testing/users.d.ts.map +1 -0
  334. package/dist/users/execution.d.ts +6 -2
  335. package/dist/users/execution.d.ts.map +1 -1
  336. package/dist/users/index.d.ts +1 -1
  337. package/dist/users/index.d.ts.map +1 -1
  338. package/dist/webhooks/internal.js +17 -17
  339. package/dist/webhooks/internal.js.map +1 -1
  340. package/dist/workers/index.js.map +1 -1
  341. package/dist/workflows/index.js +41 -39
  342. package/dist/workflows/index.js.map +1 -1
  343. package/package.json +1 -1
  344. package/src/agents/README.md +136 -0
  345. package/src/agents/attachment-keys.ts +83 -0
  346. package/src/agents/cancel.ts +16 -1
  347. package/src/agents/children.ts +5 -3
  348. package/src/agents/dispatch.ts +6 -58
  349. package/src/agents/execution.ts +18 -0
  350. package/src/agents/index.ts +127 -21
  351. package/src/agents/model-loop.ts +23 -73
  352. package/src/agents/model-routing.ts +7 -2
  353. package/src/agents/request.ts +69 -20
  354. package/src/agents/run-after-finish.ts +133 -0
  355. package/src/agents/run-artifacts.ts +257 -0
  356. package/src/agents/run-events.ts +302 -0
  357. package/src/agents/run-fence.ts +71 -0
  358. package/src/agents/run-liveness.ts +122 -0
  359. package/src/agents/run-plan.ts +316 -0
  360. package/src/agents/run-session-children.ts +303 -0
  361. package/src/agents/run-session-http.ts +397 -0
  362. package/src/agents/run-session-serve.ts +479 -0
  363. package/src/agents/run-session-wire.ts +189 -0
  364. package/src/agents/run-session.ts +802 -0
  365. package/src/agents/run-token.ts +124 -0
  366. package/src/agents/run-tools.ts +180 -0
  367. package/src/agents/run-turn.ts +265 -0
  368. package/src/agents/streams/internal.ts +0 -1
  369. package/src/agents/streams/protocol.ts +0 -292
  370. package/src/agents/subagent-runs.ts +19 -1
  371. package/src/agents/tool-files.ts +225 -0
  372. package/src/agents/workflow-node-session.ts +387 -0
  373. package/src/artifacts/publish/index.ts +1 -0
  374. package/src/connectors/connections/authorizations.ts +3 -2
  375. package/src/connectors/connections/service.ts +5 -1
  376. package/src/connectors/connections/tokens.ts +41 -5
  377. package/src/connectors/connections/validation.ts +21 -0
  378. package/src/connectors/types.ts +12 -2
  379. package/src/deploy/types.ts +0 -2
  380. package/src/deploy/validation.ts +1 -4
  381. package/src/execution/agent.ts +2 -2
  382. package/src/execution/authorized-object-reader.ts +28 -1
  383. package/src/http/api-routes.ts +114 -27
  384. package/src/index.ts +3 -1
  385. package/src/models/execution/README.md +15 -1
  386. package/src/models/execution/errors.ts +14 -0
  387. package/src/models/execution/index.ts +2 -1
  388. package/src/models/execution/model-call-recorder.ts +12 -10
  389. package/src/models/execution.ts +9 -11
  390. package/src/models/language-call.ts +247 -0
  391. package/src/ontology/docs-markdown.ts +14 -0
  392. package/src/ontology/index.ts +1 -1
  393. package/src/ontology/user-ref.ts +40 -6
  394. package/src/projections/builders.ts +48 -4
  395. package/src/projections/index.ts +1 -0
  396. package/src/projections/registry.ts +1 -0
  397. package/src/projections/revision.ts +10 -0
  398. package/src/projections/types.ts +8 -0
  399. package/src/projections/validation.ts +52 -6
  400. package/src/queues/in-memory.ts +0 -5
  401. package/src/queues/index.ts +0 -2
  402. package/src/queues/types.ts +0 -13
  403. package/src/runtime/host.ts +1 -1
  404. package/src/sandboxes/README.md +17 -6
  405. package/src/sandboxes/configuration.ts +7 -9
  406. package/src/sandboxes/environment.ts +1 -0
  407. package/src/sandboxes/exec.ts +17 -9
  408. package/src/sandboxes/guest-credentials.ts +262 -0
  409. package/src/sandboxes/index.ts +14 -0
  410. package/src/sandboxes/sandbox.ts +19 -4
  411. package/src/storage/agents/in-memory.ts +53 -0
  412. package/src/storage/agents/index.ts +2 -0
  413. package/src/storage/agents/provider.ts +56 -11
  414. package/src/storage/agents/types.ts +59 -7
  415. package/src/storage/index.ts +2 -0
  416. package/src/storage/types.ts +1 -0
  417. package/src/testing/agent-storage-contract.ts +175 -2
  418. package/src/testing/ai-model-call-groups-contract.ts +0 -1
  419. package/src/testing/index.ts +5 -0
  420. package/src/testing/queues-contract.ts +0 -16
  421. package/src/testing/sandbox-credentials-contract.ts +284 -0
  422. package/src/testing/sandboxes-contract.ts +21 -0
  423. package/src/testing/users.ts +39 -0
  424. package/src/users/execution.ts +33 -7
  425. package/src/users/index.ts +7 -1
  426. package/dist/agents/api-gateway.d.ts +0 -26
  427. package/dist/agents/api-gateway.d.ts.map +0 -1
  428. package/dist/chunk-2x19q6k6.js.map +0 -17
  429. package/dist/chunk-4y26vs3v.js.map +0 -10
  430. package/dist/chunk-661ezhks.js.map +0 -11
  431. package/dist/chunk-d2m879s4.js.map +0 -12
  432. package/dist/chunk-n9w3n38q.js.map +0 -23
  433. package/dist/chunk-nydf3dbe.js.map +0 -13
  434. package/dist/chunk-nzapm6p0.js.map +0 -12
  435. package/dist/chunk-r6szek0x.js.map +0 -10
  436. package/dist/chunk-vabga7fk.js +0 -176
  437. package/dist/chunk-vabga7fk.js.map +0 -12
  438. package/dist/chunk-vpgwq5nf.js +0 -810
  439. package/dist/chunk-vpgwq5nf.js.map +0 -21
  440. package/src/agents/api-gateway.ts +0 -68
  441. /package/dist/{chunk-2gjj5dx3.js.map → chunk-78ymxrn0.js.map} +0 -0
  442. /package/dist/{chunk-6n69k945.js.map → chunk-8mb7mt8n.js.map} +0 -0
  443. /package/dist/{chunk-m36fw8ft.js.map → chunk-8wsjr52f.js.map} +0 -0
  444. /package/dist/{chunk-bab05bhg.js.map → chunk-dgtd0836.js.map} +0 -0
  445. /package/dist/{chunk-7ny9mjgm.js.map → chunk-ft3w5ahs.js.map} +0 -0
  446. /package/dist/{chunk-1t6k1avb.js.map → chunk-tnhqtfea.js.map} +0 -0
@@ -6,29 +6,30 @@ import"../chunk-c0vk1djt.js";
6
6
  import {
7
7
  validateObjectQuery2,
8
8
  AuthStorageError2,
9
+ toUserProfile,
9
10
  SYSTEM_PRINCIPAL2
10
- } from "../chunk-gqm0b7vd.js";
11
+ } from "../chunk-8v6xzwgr.js";
11
12
  import"../chunk-vhbw5sqm.js";
12
13
  import {
13
14
  agentServiceAccountId2,
14
15
  MAX_OBJECT_READ_FACETS2,
15
16
  defineProjection2
16
- } from "../chunk-n9w3n38q.js";
17
- import"../chunk-4y26vs3v.js";
17
+ } from "../chunk-ye5c8016.js";
18
+ import"../chunk-jspskey0.js";
18
19
  import {
19
20
  compileSelectedObjectReadScope2,
20
21
  compileConditionalObjectReadScope2
21
- } from "../chunk-rap5w0x0.js";
22
+ } from "../chunk-31khg3g0.js";
22
23
  import {
23
24
  blobIdFromDigest2
24
25
  } from "../chunk-wkv3h3q7.js";
25
26
  import {
26
27
  UNIQUE_VALUE_KEY_VERSION
27
- } from "../chunk-65pyhyas.js";
28
+ } from "../chunk-qgvbxfqv.js";
28
29
  import"../chunk-73v685wb.js";
29
30
  import {
30
31
  ref2
31
- } from "../chunk-bab05bhg.js";
32
+ } from "../chunk-dgtd0836.js";
32
33
  import {
33
34
  OntologyRegistry2,
34
35
  defineObjectType2,
@@ -37,7 +38,7 @@ import {
37
38
  link2,
38
39
  valueTypeRef2,
39
40
  stringEnum2
40
- } from "../chunk-cdk3egjj.js";
41
+ } from "../chunk-h1na2cxc.js";
41
42
  import {
42
43
  createEventId2
43
44
  } from "../chunk-zrvhsq7f.js";
@@ -46,15 +47,15 @@ import"../chunk-pdt5cw8z.js";
46
47
  import"../chunk-tdxfsg1c.js";
47
48
  import {
48
49
  AgentStorageError2
49
- } from "../chunk-nydf3dbe.js";
50
- import"../chunk-0xmt5p5y.js";
50
+ } from "../chunk-z9mg7wya.js";
51
+ import"../chunk-t3brw0wd.js";
51
52
  import {
52
53
  aiLimitCalendarMonth2
53
54
  } from "../chunk-4ymrcdbm.js";
54
55
  import {
55
56
  DEFAULT_FILE_UPLOAD_TERMINAL_SESSION_TTL_MS2
56
57
  } from "../chunk-h89wz928.js";
57
- import"../chunk-24bqx0dx.js";
58
+ import"../chunk-hn76sanm.js";
58
59
  import {
59
60
  ArtifactStorageError
60
61
  } from "../chunk-fe8zwt8b.js";
@@ -80,8 +81,8 @@ import {
80
81
  WorkflowInterventionError2,
81
82
  InMemoryStorage2,
82
83
  migrateStorage2
83
- } from "../chunk-68wghpdf.js";
84
- import"../chunk-hqsp2sx4.js";
84
+ } from "../chunk-8v5a54qz.js";
85
+ import"../chunk-1xvqgg88.js";
85
86
  import"../chunk-2adz0h75.js";
86
87
  import"../chunk-mmagke4x.js";
87
88
  import"../chunk-hn2r7z41.js";
@@ -89,18 +90,18 @@ import"../chunk-g663fahq.js";
89
90
  import"../chunk-jmfet9r4.js";
90
91
  import"../chunk-qf954wje.js";
91
92
  import"../chunk-x0v3jd47.js";
92
- import"../chunk-97wr6p2g.js";
93
+ import"../chunk-y7j6x4h0.js";
93
94
  import {
94
95
  ProjectionRegistry2,
95
96
  createLinkScopeFingerprint2,
96
97
  createOntologyMaterializer2
97
- } from "../chunk-xe0732g0.js";
98
+ } from "../chunk-yavhtnac.js";
98
99
  import {
99
100
  bindModelExecutionAttempt,
100
101
  isBoundSixb
101
- } from "../chunk-et017krg.js";
102
+ } from "../chunk-mdxmt0n3.js";
102
103
  import"../chunk-48jezz3j.js";
103
- import"../chunk-vr3j63jq.js";
104
+ import"../chunk-4jq2bg8t.js";
104
105
  import {
105
106
  planObjectQuery2,
106
107
  executeObjectQuery2,
@@ -108,48 +109,51 @@ import {
108
109
  existsObjects2,
109
110
  facetObjects2,
110
111
  executeObjectQueryLinks2
111
- } from "../chunk-hk38wahh.js";
112
- import"../chunk-z3ryd53f.js";
113
- import"../chunk-r6szek0x.js";
112
+ } from "../chunk-qst145py.js";
113
+ import"../chunk-b6ghvap7.js";
114
+ import"../chunk-jt3r6thp.js";
114
115
  import"../chunk-3fqxbn31.js";
115
116
  import"../chunk-waqk73p1.js";
116
- import"../chunk-qx00vjrj.js";
117
- import"../chunk-8z4726jz.js";
117
+ import"../chunk-kwfhd1g0.js";
118
+ import"../chunk-7wn5z7mq.js";
118
119
  import"../chunk-dp0cdtj2.js";
119
120
  import"../chunk-sgx82nnt.js";
120
121
  import"../chunk-8ncg20rd.js";
121
122
  import"../chunk-5a4a52tq.js";
122
- import"../chunk-vrf90dkv.js";
123
+ import"../chunk-2vjnyz1s.js";
123
124
  import {
124
125
  col2,
125
126
  defineDataset2,
126
127
  change2
127
- } from "../chunk-c844dkwd.js";
128
+ } from "../chunk-qtzftvxa.js";
128
129
  import {
129
130
  writeDataset2
130
- } from "../chunk-6y0mkhex.js";
131
- import"../chunk-2gjj5dx3.js";
132
- import"../chunk-3qms4nax.js";
131
+ } from "../chunk-59kf345w.js";
132
+ import"../chunk-mqx25wwh.js";
133
+ import"../chunk-78ymxrn0.js";
134
+ import"../chunk-1vg43g9q.js";
133
135
  import"../chunk-m427qgq0.js";
134
136
  import {
135
137
  SixbHost2
136
- } from "../chunk-yecwnwpq.js";
138
+ } from "../chunk-xm8qgbqm.js";
137
139
  import"../chunk-45ngkxkp.js";
138
140
  import"../chunk-t5608tkq.js";
139
141
  import"../chunk-9mab3dvg.js";
140
- import"../chunk-3p93tb91.js";
141
- import"../chunk-sqfvnvqj.js";
142
+ import"../chunk-6qn7nmd3.js";
143
+ import"../chunk-c14ap3s9.js";
142
144
  import"../chunk-fb3feg1e.js";
143
145
  import"../chunk-yw9pyg66.js";
144
- import"../chunk-5tfev0fv.js";
146
+ import"../chunk-7hf6tkgs.js";
145
147
  import {
146
148
  projectAgentThreadModelContext2
147
- } from "../chunk-vpgwq5nf.js";
149
+ } from "../chunk-yd00vzqr.js";
148
150
  import"../chunk-fntqb7qy.js";
149
- import"../chunk-661ezhks.js";
151
+ import"../chunk-ratkv4zc.js";
152
+ import"../chunk-zhh1jd89.js";
153
+ import"../chunk-cbcgs9f7.js";
150
154
  import {
151
155
  workflowAgentStepActorId2
152
- } from "../chunk-vd1rk42q.js";
156
+ } from "../chunk-8xnz9vvp.js";
153
157
  import {
154
158
  BrokerError2,
155
159
  InMemoryBroker2
@@ -157,44 +161,43 @@ import {
157
161
  import {
158
162
  QueueError2,
159
163
  InMemoryQueues2
160
- } from "../chunk-nzapm6p0.js";
161
- import"../chunk-2fn60nvs.js";
162
- import"../chunk-vabga7fk.js";
163
- import"../chunk-rp9wwk7b.js";
164
- import"../chunk-m2nevja0.js";
164
+ } from "../chunk-s3we74h8.js";
165
+ import"../chunk-06sg8s4z.js";
166
+ import"../chunk-73j0v4qv.js";
167
+ import"../chunk-vx4e4zv4.js";
168
+ import"../chunk-phm3c7b9.js";
165
169
  import"../chunk-c69nj7se.js";
166
- import"../chunk-bnr4a734.js";
170
+ import"../chunk-jn3ysaf2.js";
167
171
  import {
168
172
  createTestingScope
169
- } from "../chunk-7ny9mjgm.js";
170
- import"../chunk-m36fw8ft.js";
171
- import"../chunk-62a63pr6.js";
173
+ } from "../chunk-ft3w5ahs.js";
174
+ import"../chunk-8wsjr52f.js";
175
+ import"../chunk-axb4ss9a.js";
172
176
  import {
173
177
  SandboxNotRunningError2
174
- } from "../chunk-d2m879s4.js";
175
- import"../chunk-6bkbyer5.js";
176
- import"../chunk-9ntbsnke.js";
178
+ } from "../chunk-0kk2wt0h.js";
179
+ import"../chunk-7ex2p3zp.js";
180
+ import"../chunk-0bc3w0zq.js";
177
181
  import {
178
182
  restoreTrustedPrimitiveExecutionScope
179
- } from "../chunk-1j6j0rht.js";
183
+ } from "../chunk-e24fvw8g.js";
180
184
  import"../chunk-07kkp2e1.js";
181
- import"../chunk-2x19q6k6.js";
182
- import"../chunk-1t6k1avb.js";
185
+ import"../chunk-tnhqtfea.js";
183
186
  import {
184
187
  LakeStorageError2
185
188
  } from "../chunk-65abf64x.js";
186
189
  import"../chunk-npcr0228.js";
187
- import"../chunk-fm62y49k.js";
190
+ import"../chunk-2pk5hjj9.js";
188
191
  import {
189
192
  AiUsageStorageError2
190
193
  } from "../chunk-pgrf64hp.js";
191
194
  import {
192
195
  ActionRunError2
193
196
  } from "../chunk-3gbefjg5.js";
194
- import"../chunk-6n69k945.js";
197
+ import"../chunk-8mb7mt8n.js";
195
198
  import {
196
199
  ObjectQueryPlanningError2
197
- } from "../chunk-j936th07.js";
200
+ } from "../chunk-fakrpfy3.js";
198
201
  import {
199
202
  UniqueValueViolationError2,
200
203
  MaterializationConflictError2
@@ -2442,7 +2445,6 @@ function subagentInput(parentExecutionToken, overrides = {}) {
2442
2445
  reasoning: "medium",
2443
2446
  task: "Research the open orders.",
2444
2447
  toolNames: ["search_orders"],
2445
- maxSteps: 25,
2446
2448
  files: [{ path: "reports/orders.csv", fileRef: testFileRef("orders.csv") }]
2447
2449
  },
2448
2450
  thread: { id: `thread_${id}`, create: true },
@@ -2897,6 +2899,42 @@ function runAgentStorageContractSuite(label, options) {
2897
2899
  await expect5(storage.threads.getById({ projectId: "nope", id: "thr_1" })).resolves.toBeNull();
2898
2900
  });
2899
2901
  });
2902
+ test5("keeps a thread that runs on its owner's computer, and its turns' place", async () => {
2903
+ await withStorage(async (storage, fixture) => {
2904
+ const thread = await storage.threads.create(threadInput({ runsOn: "computer" }));
2905
+ expect5(thread.runsOn).toBe("computer");
2906
+ await expect5(storage.threads.getById({ projectId: projectId5, id: thread.id })).resolves.toMatchObject({
2907
+ runsOn: "computer"
2908
+ });
2909
+ const cloud = await storage.threads.create(threadInput({ id: "thr_cloud" }));
2910
+ expect5(cloud).not.toHaveProperty("runsOn");
2911
+ const spec = { model: { provider: "test", modelId: "large" }, runsOn: "computer" };
2912
+ await createRun(storage, fixture, runInput2({ id: "run_1", spec }));
2913
+ expect5((await storage.runs.getById({ projectId: projectId5, id: "run_1" }))?.spec).toEqual(spec);
2914
+ await expectAgentError2(createRun(storage, fixture, runInput2({
2915
+ id: "run_2",
2916
+ threadId: "thr_cloud",
2917
+ spec: { ...spec, runsOn: "laptop" }
2918
+ })), "invalid_input");
2919
+ });
2920
+ });
2921
+ test5("names the computer a computer's thread runs on, which only a move changes", async () => {
2922
+ await withStorage(async (storage) => {
2923
+ await storage.threads.create(threadInput({ runsOn: "computer" }));
2924
+ await storage.threads.create(threadInput({ id: "thr_cloud" }));
2925
+ const thread = { projectId: projectId5, id: "thr_1" };
2926
+ await expect5(storage.threads.assignComputer({ ...thread, computerId: "laptop", ifUnassigned: true })).resolves.toMatchObject({ computerId: "laptop" });
2927
+ await expect5(storage.threads.assignComputer({ ...thread, computerId: "desktop", ifUnassigned: true })).resolves.toMatchObject({ computerId: "laptop" });
2928
+ await storage.threads.assignComputer({ ...thread, computerId: "desktop" });
2929
+ await expect5(storage.threads.getById(thread)).resolves.toMatchObject({
2930
+ computerId: "desktop"
2931
+ });
2932
+ await expectAgentError2(storage.threads.assignComputer({ projectId: projectId5, id: "thr_cloud", computerId: "laptop" }), "invalid_input");
2933
+ await expectAgentError2(storage.threads.assignComputer({ projectId: projectId5, id: "thr_none", computerId: "laptop" }), "thread_not_found");
2934
+ await expectAgentError2(storage.threads.assignComputer({ ...thread, computerId: " " }), "invalid_input");
2935
+ expect5(await storage.threads.getById({ projectId: projectId5, id: "thr_cloud" })).not.toHaveProperty("computerId");
2936
+ });
2937
+ });
2900
2938
  test5("reads several threads at once, in the order asked", async () => {
2901
2939
  await withStorage(async (storage) => {
2902
2940
  const first = await storage.threads.create(threadInput());
@@ -3544,6 +3582,13 @@ function runAgentStorageContractSuite(label, options) {
3544
3582
  status: "succeeded",
3545
3583
  result: { text: " " }
3546
3584
  }), "invalid_input");
3585
+ await expectAgentError2(storage.runs.finish({
3586
+ projectId: projectId5,
3587
+ id: "child_1",
3588
+ executionToken: "child_token",
3589
+ status: "succeeded",
3590
+ result: { text: "Three open orders.", unread: [{ id: "m1", text: "Skip Globex." }] }
3591
+ }), "invalid_input");
3547
3592
  await expectAgentError2(storage.runs.finish({
3548
3593
  projectId: projectId5,
3549
3594
  id: "child_1",
@@ -3619,10 +3664,17 @@ function runAgentStorageContractSuite(label, options) {
3619
3664
  queueLeaseExpiresAt: at2("2026-06-23T10:02:30.000Z")
3620
3665
  });
3621
3666
  expect5(older.execution?.queueLeaseExpiresAt.toISOString()).toBe("2026-06-23T10:03:00.000Z");
3667
+ await expectAgentError2(storage.runs.reclaim({
3668
+ projectId: projectId5,
3669
+ id: "run_1",
3670
+ execution: execution("exec_2", at2("2026-06-23T10:04:00.000Z")),
3671
+ ifLapsedBy: at2("2026-06-23T10:02:59.000Z")
3672
+ }), "invalid_state");
3622
3673
  const reclaimed = await storage.runs.reclaim({
3623
3674
  projectId: projectId5,
3624
3675
  id: "run_1",
3625
- execution: execution("exec_2", at2("2026-06-23T10:04:00.000Z"))
3676
+ execution: execution("exec_2", at2("2026-06-23T10:04:00.000Z")),
3677
+ ifLapsedBy: at2("2026-06-23T10:03:00.000Z")
3626
3678
  });
3627
3679
  expect5(reclaimed).toMatchObject({ status: "running", attempt: 2 });
3628
3680
  expect5(reclaimed.execution?.token).toBe("exec_2");
@@ -3640,6 +3692,45 @@ function runAgentStorageContractSuite(label, options) {
3640
3692
  }), "execution_lost");
3641
3693
  });
3642
3694
  });
3695
+ test5("records a running run's cancel once, survives a reclaim, and leaves other states", async () => {
3696
+ await withStorage(async (storage, fixture) => {
3697
+ await storage.threads.create(threadInput());
3698
+ const queued = await createRun(storage, fixture, runInput2({ id: "run_queued" }));
3699
+ expect5((await storage.runs.requestCancel({ projectId: projectId5, id: queued.id })).cancelRequestedAt).toBeUndefined();
3700
+ await storage.threads.create(threadInput({ id: "thread_2" }));
3701
+ await createAndStartRun(storage, fixture, runInput2({
3702
+ id: "run_1",
3703
+ threadId: "thread_2",
3704
+ execution: execution("exec_1", at2("2026-06-23T10:02:00.000Z"))
3705
+ }));
3706
+ const first = await storage.runs.requestCancel({
3707
+ projectId: projectId5,
3708
+ id: "run_1",
3709
+ at: at2("2026-06-23T10:01:00.000Z")
3710
+ });
3711
+ expect5(first.cancelRequestedAt?.toISOString()).toBe("2026-06-23T10:01:00.000Z");
3712
+ const again = await storage.runs.requestCancel({
3713
+ projectId: projectId5,
3714
+ id: "run_1",
3715
+ at: at2("2026-06-23T10:01:30.000Z")
3716
+ });
3717
+ expect5(again.cancelRequestedAt?.toISOString()).toBe("2026-06-23T10:01:00.000Z");
3718
+ const renewed = await storage.runs.confirmExecutionOwnership({
3719
+ projectId: projectId5,
3720
+ id: "run_1",
3721
+ executionToken: "exec_1",
3722
+ queueLeaseExpiresAt: at2("2026-06-23T10:03:00.000Z")
3723
+ });
3724
+ expect5(renewed.cancelRequestedAt?.toISOString()).toBe("2026-06-23T10:01:00.000Z");
3725
+ const reclaimed = await storage.runs.reclaim({
3726
+ projectId: projectId5,
3727
+ id: "run_1",
3728
+ execution: execution("exec_2", at2("2026-06-23T10:04:00.000Z"))
3729
+ });
3730
+ expect5(reclaimed.cancelRequestedAt?.toISOString()).toBe("2026-06-23T10:01:00.000Z");
3731
+ await expectAgentError2(storage.runs.requestCancel({ projectId: projectId5, id: "run_missing" }), "run_not_found");
3732
+ });
3733
+ });
3643
3734
  test5("does not alias stored run records to callers", async () => {
3644
3735
  await withStorage(async (storage, fixture) => {
3645
3736
  await storage.threads.create(threadInput());
@@ -3928,6 +4019,29 @@ function runAgentStorageContractSuite(label, options) {
3928
4019
  });
3929
4020
  });
3930
4021
  });
4022
+ test5("deletes a run's messages for a fencing run only while it runs under its token", async () => {
4023
+ await withStorage(async (storage, fixture) => {
4024
+ await storage.threads.create(threadInput());
4025
+ await createAndStartRun(storage, fixture, runInput2({ id: "run_1", execution: execution("exec_1") }));
4026
+ await storage.messages.append({
4027
+ id: "msg_asst_1",
4028
+ projectId: projectId5,
4029
+ threadId: "thr_1",
4030
+ runId: "run_1",
4031
+ role: "assistant",
4032
+ parts: [{ type: "text", text: "Hi." }]
4033
+ });
4034
+ const remove = (executionToken) => storage.messages.deleteByRunId({
4035
+ projectId: projectId5,
4036
+ threadId: "thr_1",
4037
+ runId: "run_1",
4038
+ fence: { runId: "run_1", executionToken }
4039
+ });
4040
+ await expectAgentError2(remove("exec_stale"), "execution_lost");
4041
+ expect5(await storage.messages.getById({ projectId: projectId5, id: "msg_asst_1" })).not.toBeNull();
4042
+ await expect5(remove("exec_1")).resolves.toBe(1);
4043
+ });
4044
+ });
3931
4045
  test5("counts only the messages the conversation shows", async () => {
3932
4046
  await withStorage(async (storage, fixture) => {
3933
4047
  await storage.threads.create(threadInput());
@@ -4139,7 +4253,7 @@ function runAgentStorageContractSuite(label, options) {
4139
4253
  executionToken: "exec_2",
4140
4254
  status: "failed"
4141
4255
  });
4142
- await expectAgentError2(storage.checkpoints.create(checkpointInput()), "invalid_state");
4256
+ await expectAgentError2(storage.checkpoints.create(checkpointInput()), "execution_lost");
4143
4257
  expect5(await storage.checkpoints.getLatest({ projectId: projectId5, threadId: "thr_1" })).toBeNull();
4144
4258
  });
4145
4259
  });
@@ -6403,8 +6517,7 @@ async function seed(storage) {
6403
6517
  spec: {
6404
6518
  model: { provider: "child-provider", modelId: "small" },
6405
6519
  task: "Research",
6406
- toolNames: [],
6407
- maxSteps: 25
6520
+ toolNames: []
6408
6521
  },
6409
6522
  thread: { id: "child_thread", create: true },
6410
6523
  trigger: { id: "child_task", parts: [{ type: "text", text: "Research" }] },
@@ -20934,15 +21047,6 @@ function runQueueContractSuite(label, options) {
20934
21047
  }
20935
21048
  ]
20936
21049
  });
20937
- await queues.agentChildren.enqueue({
20938
- projectId: "project-a",
20939
- jobs: [
20940
- {
20941
- type: "agent.subagent-run.requested",
20942
- payload: { runId: "child-run-1" }
20943
- }
20944
- ]
20945
- });
20946
21050
  const crossLane = await queues.pipelines.claim({
20947
21051
  projectId: "project-a",
20948
21052
  workerId: "pipeline-worker-1",
@@ -20963,11 +21067,6 @@ function runQueueContractSuite(label, options) {
20963
21067
  workerId: "agent-worker-1",
20964
21068
  limit: 10
20965
21069
  });
20966
- const childLane = await queues.agentChildren.claim({
20967
- projectId: "project-a",
20968
- workerId: "child-agent-worker-1",
20969
- limit: 10
20970
- });
20971
21070
  const sameLane = await queues.syncRuns.claim({
20972
21071
  projectId: "project-a",
20973
21072
  workerId: "sync-worker-1",
@@ -20984,8 +21083,6 @@ function runQueueContractSuite(label, options) {
20984
21083
  type: "agent.run.requested",
20985
21084
  payload: { runId: "agent-run-1" }
20986
21085
  });
20987
- expect30(childLane).toHaveLength(1);
20988
- expect30(childLane[0]?.job.payload.runId).toBe("child-run-1");
20989
21086
  expect30(sameLane).toHaveLength(1);
20990
21087
  });
20991
21088
  });
@@ -21204,14 +21301,207 @@ function runQueueContractSuite(label, options) {
21204
21301
  });
21205
21302
  });
21206
21303
  }
21304
+ // src/testing/sandbox-credentials-contract.ts
21305
+ import { afterAll, beforeAll, describe as describe30, expect as expect31, test as test31 } from "bun:test";
21306
+ import { randomUUID } from "crypto";
21307
+ function runSandboxCredentialsContractSuite(label, options) {
21308
+ describe30(label, () => {
21309
+ let server;
21310
+ let origin;
21311
+ let otherServer;
21312
+ let otherOrigin;
21313
+ let factory;
21314
+ const received = [];
21315
+ const listen = () => Bun.serve({
21316
+ hostname: "0.0.0.0",
21317
+ port: 0,
21318
+ fetch: (request) => {
21319
+ received.push(request.headers.get("authorization"));
21320
+ return Response.json({
21321
+ method: request.method,
21322
+ path: new URL(request.url).pathname,
21323
+ authorization: request.headers.get("authorization")
21324
+ });
21325
+ }
21326
+ });
21327
+ const originOf = ({ port }) => options.originFor?.(port ?? 0) ?? `http://127.0.0.1:${port}`;
21328
+ beforeAll(async () => {
21329
+ server = listen();
21330
+ otherServer = listen();
21331
+ origin = originOf(server);
21332
+ otherOrigin = originOf(otherServer);
21333
+ factory = await options.createFactory();
21334
+ expect31(factory.supportsRequestCredentials).toBe(true);
21335
+ });
21336
+ afterAll(() => {
21337
+ server.stop(true);
21338
+ otherServer.stop(true);
21339
+ });
21340
+ const credential = (secret, overrides = {}) => ({
21341
+ origin,
21342
+ path: { prefix: "/api/" },
21343
+ method: ["GET", "POST"],
21344
+ headers: { Authorization: `Bearer ${secret}` },
21345
+ ...overrides
21346
+ });
21347
+ async function withSandbox(credentials, use) {
21348
+ const sandbox = await factory.create({
21349
+ network: {
21350
+ mode: "restricted",
21351
+ allow: [
21352
+ { name: "credentials-suite", origin },
21353
+ { name: "credentials-suite-other", origin: otherOrigin }
21354
+ ]
21355
+ },
21356
+ requestCredentials: credentials
21357
+ });
21358
+ try {
21359
+ await use(sandbox);
21360
+ } finally {
21361
+ await sandbox.destroy();
21362
+ }
21363
+ }
21364
+ test31("a command reaches the origin with the credential added", async () => {
21365
+ const secret = `suite-${randomUUID()}`;
21366
+ await withSandbox([credential(secret)], async (sandbox) => {
21367
+ const seen = await request(sandbox, origin, "/api/whoami");
21368
+ expect31(seen).toEqual({
21369
+ method: "GET",
21370
+ path: "/api/whoami",
21371
+ authorization: `Bearer ${secret}`
21372
+ });
21373
+ });
21374
+ });
21375
+ test31("only a request the credential matches gets it, replacing the command's own", async () => {
21376
+ const secret = `suite-${randomUUID()}`;
21377
+ await withSandbox([credential(secret)], async (sandbox) => {
21378
+ expect31((await request(sandbox, origin, "/health")).authorization).toBeNull();
21379
+ expect31((await request(sandbox, origin, "/api/x", { method: "DELETE" })).authorization).toBeNull();
21380
+ const forged = await request(sandbox, origin, "/api/x", { authorization: "Bearer guest" });
21381
+ expect31(forged.authorization).toBe(`Bearer ${secret}`);
21382
+ });
21383
+ });
21384
+ test31("a credential reaches its own origin alone, whatever the paths it shares", async () => {
21385
+ const secret = `suite-${randomUUID()}`;
21386
+ const otherSecret = `suite-${randomUUID()}`;
21387
+ const credentials = [
21388
+ credential(secret),
21389
+ credential(otherSecret, { origin: otherOrigin, path: { prefix: "/api/v2/" } })
21390
+ ];
21391
+ await withSandbox(credentials, async (sandbox) => {
21392
+ const authorization = async (on, path) => (await request(sandbox, on, path)).authorization;
21393
+ expect31(await authorization(origin, "/api/v2/x")).toBe(`Bearer ${secret}`);
21394
+ expect31(await authorization(otherOrigin, "/api/v2/x")).toBe(`Bearer ${otherSecret}`);
21395
+ expect31(await authorization(otherOrigin, "/api/x")).toBeNull();
21396
+ });
21397
+ });
21398
+ test31("setRequestCredentials replaces the credentials, and an empty list removes them", async () => {
21399
+ const first = `suite-${randomUUID()}`;
21400
+ const second = `suite-${randomUUID()}`;
21401
+ await withSandbox([credential(first)], async (sandbox) => {
21402
+ if (!sandbox.setRequestCredentials)
21403
+ throw new Error("setRequestCredentials is missing");
21404
+ await sandbox.setRequestCredentials([credential(second)]);
21405
+ expect31((await request(sandbox, origin, "/api/x")).authorization).toBe(`Bearer ${second}`);
21406
+ await sandbox.setRequestCredentials([]);
21407
+ expect31((await request(sandbox, origin, "/api/x")).authorization).toBeNull();
21408
+ });
21409
+ });
21410
+ test31.skipIf(options.separatesSandboxes === false)("a sandbox's commands can't use another sandbox's credentials", async () => {
21411
+ const secretA = `suite-${randomUUID()}`;
21412
+ const secretB = `suite-${randomUUID()}`;
21413
+ await withSandbox([credential(secretA)], async (a) => {
21414
+ if (!a.credentialedUrl)
21415
+ throw new Error("credentialedUrl is missing");
21416
+ const address = a.credentialedUrl(origin);
21417
+ await withSandbox([credential(secretB)], async (b) => {
21418
+ const result = await send(b, address, "/api/whoami");
21419
+ expect31(result.stdout).not.toContain(secretA);
21420
+ expect31(result.stderr).not.toContain(secretA);
21421
+ });
21422
+ });
21423
+ expect31(received).not.toContain(`Bearer ${secretA}`);
21424
+ });
21425
+ test31("nothing a command can read holds the credential", async () => {
21426
+ const secret = `suite-${randomUUID()}`;
21427
+ await withSandbox([credential(secret)], async (sandbox) => {
21428
+ const looked = await sandbox.runCommand("bash", [
21429
+ "-c",
21430
+ [
21431
+ "env",
21432
+ "ps -eo args 2>/dev/null",
21433
+ "cat /proc/*/environ /proc/*/cmdline 2>/dev/null | tr '\\0' '\\n'",
21434
+ "find . -type f -exec cat {} + 2>/dev/null",
21435
+ ...(options.privatePaths ?? []).map((path) => `find '${path}' -type f -exec cat {} + 2>/dev/null`)
21436
+ ].join("; ")
21437
+ ]);
21438
+ expect31(looked.stdout.length).toBeGreaterThan(0);
21439
+ expect31(looked.stdout).not.toContain(secret);
21440
+ expect31(looked.stderr).not.toContain(secret);
21441
+ });
21442
+ });
21443
+ });
21444
+ }
21445
+ async function request(sandbox, origin, path, options = {}) {
21446
+ if (!sandbox.credentialedUrl)
21447
+ throw new Error("credentialedUrl is missing");
21448
+ const address = sandbox.credentialedUrl(origin);
21449
+ const result = await send(sandbox, address, path, options);
21450
+ if (result.exitCode !== 0) {
21451
+ throw new Error(`a request through ${address} failed: ${result.stderr.trim() || result.exitCode}`);
21452
+ }
21453
+ return JSON.parse(result.stdout);
21454
+ }
21455
+ function send(sandbox, address, path, options = {}) {
21456
+ return sandbox.runCommand("sh", ["-c", REQUEST_SCRIPT], {
21457
+ env: {
21458
+ SUITE_ADDRESS: address,
21459
+ SUITE_PATH: path,
21460
+ SUITE_METHOD: options.method ?? "GET",
21461
+ SUITE_AUTHORIZATION: options.authorization ?? "",
21462
+ SUITE_FETCH: FETCH_PROGRAM
21463
+ }
21464
+ });
21465
+ }
21466
+ var REQUEST_SCRIPT = `set -eu
21467
+ if command -v curl >/dev/null 2>&1; then
21468
+ set -- -sS -m 10 -X "$SUITE_METHOD"
21469
+ [ -z "$SUITE_AUTHORIZATION" ] || set -- "$@" -H "Authorization: $SUITE_AUTHORIZATION"
21470
+ case "$SUITE_ADDRESS" in
21471
+ unix:*) exec curl "$@" --unix-socket "\${SUITE_ADDRESS#unix:}" "http://localhost$SUITE_PATH" ;;
21472
+ *) exec curl "$@" "\${SUITE_ADDRESS%/}$SUITE_PATH" ;;
21473
+ esac
21474
+ elif command -v bun >/dev/null 2>&1; then
21475
+ exec bun -e "$SUITE_FETCH"
21476
+ else
21477
+ exec node --input-type=module -e "$SUITE_FETCH"
21478
+ fi`;
21479
+ var FETCH_PROGRAM = `const { SUITE_ADDRESS: address, SUITE_PATH: path, SUITE_METHOD: method } = process.env
21480
+ const headers = process.env.SUITE_AUTHORIZATION ? { authorization: process.env.SUITE_AUTHORIZATION } : {}
21481
+ if (!address.startsWith("unix:")) {
21482
+ console.log(await (await fetch(address.replace(/\\/+$/, "") + path, { method, headers })).text())
21483
+ } else if (typeof Bun !== "undefined") {
21484
+ console.log(await (await fetch("http://localhost" + path, { method, headers, unix: address.slice(5) })).text())
21485
+ } else {
21486
+ const http = await import("node:http")
21487
+ console.log(await new Promise((resolve, reject) => {
21488
+ const sent = http.request({ socketPath: address.slice(5), path, method, headers: { ...headers, host: "localhost" } }, (response) => {
21489
+ let body = ""
21490
+ response.on("data", (chunk) => { body += chunk })
21491
+ response.on("end", () => resolve(body))
21492
+ })
21493
+ sent.on("error", reject)
21494
+ sent.end()
21495
+ }))
21496
+ }`;
21207
21497
  // src/testing/sandboxes-contract.ts
21208
- import { afterEach as afterEach2, beforeEach as beforeEach2, describe as describe30, expect as expect31, test as test31 } from "bun:test";
21498
+ import { afterEach as afterEach2, beforeEach as beforeEach2, describe as describe31, expect as expect32, test as test32 } from "bun:test";
21209
21499
  import { realpath } from "fs/promises";
21210
21500
  var SLEEP_BUDGET_SECONDS = 5;
21211
21501
  function runSandboxesContractSuite(label, options) {
21212
21502
  const shortTimeoutMs = options.shortTimeoutMs ?? 200;
21213
21503
  const capabilities = options.capabilities ?? {};
21214
- describe30(label, () => {
21504
+ describe31(label, () => {
21215
21505
  let factory;
21216
21506
  beforeEach2(async () => {
21217
21507
  factory = await options.createFactory();
@@ -21219,74 +21509,74 @@ function runSandboxesContractSuite(label, options) {
21219
21509
  afterEach2(async () => {
21220
21510
  await options.teardown?.(factory);
21221
21511
  });
21222
- describe30("lifecycle", () => {
21223
- test31("create returns a running sandbox with a non-empty id", async () => {
21512
+ describe31("lifecycle", () => {
21513
+ test32("create returns a running sandbox with a non-empty id", async () => {
21224
21514
  const sandbox = await factory.create();
21225
21515
  try {
21226
- expect31(sandbox.status).toBe("running");
21227
- expect31(sandbox.id.length).toBeGreaterThan(0);
21228
- expect31(sandbox.workingDirectory.length).toBeGreaterThan(0);
21516
+ expect32(sandbox.status).toBe("running");
21517
+ expect32(sandbox.id.length).toBeGreaterThan(0);
21518
+ expect32(sandbox.workingDirectory.length).toBeGreaterThan(0);
21229
21519
  } finally {
21230
21520
  await sandbox.destroy();
21231
21521
  }
21232
21522
  });
21233
- test31("runCommand returns exit code 0 and captured stdout for echo", async () => {
21523
+ test32("runCommand returns exit code 0 and captured stdout for echo", async () => {
21234
21524
  const sandbox = await factory.create();
21235
21525
  try {
21236
21526
  const result = await sandbox.runCommand("echo", ["hello"]);
21237
- expect31(result.exitCode).toBe(0);
21238
- expect31(result.stdout.trim()).toBe("hello");
21239
- expect31(result.stderr).toBe("");
21240
- expect31(result.durationMs).toBeGreaterThanOrEqual(0);
21241
- expect31(result.timedOut).not.toBe(true);
21527
+ expect32(result.exitCode).toBe(0);
21528
+ expect32(result.stdout.trim()).toBe("hello");
21529
+ expect32(result.stderr).toBe("");
21530
+ expect32(result.durationMs).toBeGreaterThanOrEqual(0);
21531
+ expect32(result.timedOut).not.toBe(true);
21242
21532
  } finally {
21243
21533
  await sandbox.destroy();
21244
21534
  }
21245
21535
  });
21246
- test31("nonexistent binary resolves with non-zero exit code", async () => {
21536
+ test32("nonexistent binary resolves with non-zero exit code", async () => {
21247
21537
  const sandbox = await factory.create();
21248
21538
  try {
21249
21539
  const result = await sandbox.runCommand("does-not-exist-xyz-sixb-test", []);
21250
- expect31(result.exitCode).not.toBe(0);
21540
+ expect32(result.exitCode).not.toBe(0);
21251
21541
  } finally {
21252
21542
  await sandbox.destroy();
21253
21543
  }
21254
21544
  });
21255
- test31("captures stdout and stderr as separate streams", async () => {
21545
+ test32("captures stdout and stderr as separate streams", async () => {
21256
21546
  const sandbox = await factory.create();
21257
21547
  try {
21258
21548
  const result = await sandbox.runCommand("/bin/sh", [
21259
21549
  "-c",
21260
21550
  "echo out-line; echo err-line >&2; exit 0"
21261
21551
  ]);
21262
- expect31(result.exitCode).toBe(0);
21263
- expect31(result.stdout).toContain("out-line");
21264
- expect31(result.stderr).toContain("err-line");
21265
- expect31(result.stdout).not.toContain("err-line");
21266
- expect31(result.stderr).not.toContain("out-line");
21552
+ expect32(result.exitCode).toBe(0);
21553
+ expect32(result.stdout).toContain("out-line");
21554
+ expect32(result.stderr).toContain("err-line");
21555
+ expect32(result.stdout).not.toContain("err-line");
21556
+ expect32(result.stderr).not.toContain("out-line");
21267
21557
  } finally {
21268
21558
  await sandbox.destroy();
21269
21559
  }
21270
21560
  });
21271
- test31("stop transitions status and rejects subsequent runCommand", async () => {
21561
+ test32("stop transitions status and rejects subsequent runCommand", async () => {
21272
21562
  const sandbox = await factory.create();
21273
21563
  try {
21274
21564
  await sandbox.stop();
21275
- expect31(sandbox.status).toBe("stopped");
21276
- await expect31(sandbox.runCommand("echo", ["nope"])).rejects.toBeInstanceOf(SandboxNotRunningError2);
21565
+ expect32(sandbox.status).toBe("stopped");
21566
+ await expect32(sandbox.runCommand("echo", ["nope"])).rejects.toBeInstanceOf(SandboxNotRunningError2);
21277
21567
  } finally {
21278
21568
  await sandbox.destroy();
21279
21569
  }
21280
21570
  });
21281
- test31("destroy is idempotent", async () => {
21571
+ test32("destroy is idempotent", async () => {
21282
21572
  const sandbox = await factory.create();
21283
21573
  await sandbox.destroy();
21284
21574
  await sandbox.destroy();
21285
- await expect31(sandbox.runCommand("echo", ["x"])).rejects.toBeInstanceOf(SandboxNotRunningError2);
21575
+ await expect32(sandbox.runCommand("echo", ["x"])).rejects.toBeInstanceOf(SandboxNotRunningError2);
21286
21576
  });
21287
21577
  });
21288
- describe30("working directory", () => {
21289
- test31.each([
21578
+ describe31("working directory", () => {
21579
+ test32.each([
21290
21580
  [".", "root"],
21291
21581
  ["nested", "child"],
21292
21582
  ["./nested/..", "root"]
@@ -21298,50 +21588,50 @@ function runSandboxesContractSuite(label, options) {
21298
21588
  { path: "nested/cwd-probe.txt", contents: "child" }
21299
21589
  ]);
21300
21590
  const result = await sandbox.runCommand("cat", ["cwd-probe.txt"], { cwd });
21301
- expect31(result.exitCode).toBe(0);
21302
- expect31(result.stdout).toBe(expected);
21591
+ expect32(result.exitCode).toBe(0);
21592
+ expect32(result.stdout).toBe(expected);
21303
21593
  const next = await sandbox.runCommand("cat", ["cwd-probe.txt"]);
21304
- expect31(next.exitCode).toBe(0);
21305
- expect31(next.stdout).toBe("root");
21594
+ expect32(next.exitCode).toBe(0);
21595
+ expect32(next.stdout).toBe("root");
21306
21596
  } finally {
21307
21597
  await sandbox.destroy();
21308
21598
  }
21309
21599
  });
21310
- test31("pwd reflects the configured workingDirectory", async () => {
21600
+ test32("pwd reflects the configured workingDirectory", async () => {
21311
21601
  const sandbox = await factory.create();
21312
21602
  try {
21313
21603
  const result = await sandbox.runCommand("pwd");
21314
21604
  const expected = await realpath(sandbox.workingDirectory);
21315
- expect31(result.exitCode).toBe(0);
21316
- expect31(result.stdout.trim()).toBe(expected);
21605
+ expect32(result.exitCode).toBe(0);
21606
+ expect32(result.stdout.trim()).toBe(expected);
21317
21607
  } finally {
21318
21608
  await sandbox.destroy();
21319
21609
  }
21320
21610
  });
21321
- test31("per-call cwd overrides the sandbox-level workingDirectory", async () => {
21611
+ test32("per-call cwd overrides the sandbox-level workingDirectory", async () => {
21322
21612
  const sandbox = await factory.create();
21323
21613
  try {
21324
21614
  const expected = await realpath("/tmp");
21325
21615
  const result = await sandbox.runCommand("pwd", [], { cwd: "/tmp" });
21326
- expect31(result.exitCode).toBe(0);
21327
- expect31(result.stdout.trim()).toBe(expected);
21616
+ expect32(result.exitCode).toBe(0);
21617
+ expect32(result.stdout.trim()).toBe(expected);
21328
21618
  } finally {
21329
21619
  await sandbox.destroy();
21330
21620
  }
21331
21621
  });
21332
21622
  });
21333
- describe30("env merging", () => {
21334
- test31("sandbox-level env is visible to commands", async () => {
21623
+ describe31("env merging", () => {
21624
+ test32("sandbox-level env is visible to commands", async () => {
21335
21625
  const sandbox = await factory.create({ env: { SIXB_TEST_A: "alpha" } });
21336
21626
  try {
21337
21627
  const result = await sandbox.runCommand("printenv", ["SIXB_TEST_A"]);
21338
- expect31(result.exitCode).toBe(0);
21339
- expect31(result.stdout.trim()).toBe("alpha");
21628
+ expect32(result.exitCode).toBe(0);
21629
+ expect32(result.stdout.trim()).toBe("alpha");
21340
21630
  } finally {
21341
21631
  await sandbox.destroy();
21342
21632
  }
21343
21633
  });
21344
- test31("per-call env wins on collision and adds new keys", async () => {
21634
+ test32("per-call env wins on collision and adds new keys", async () => {
21345
21635
  const sandbox = await factory.create({
21346
21636
  env: { SIXB_TEST_A: "alpha", SIXB_TEST_B: "beta" }
21347
21637
  });
@@ -21355,14 +21645,14 @@ function runSandboxesContractSuite(label, options) {
21355
21645
  const c = await sandbox.runCommand("printenv", ["SIXB_TEST_C"], {
21356
21646
  env: { SIXB_TEST_A: "alpha2", SIXB_TEST_C: "gamma" }
21357
21647
  });
21358
- expect31(a.stdout.trim()).toBe("alpha2");
21359
- expect31(b.stdout.trim()).toBe("beta");
21360
- expect31(c.stdout.trim()).toBe("gamma");
21648
+ expect32(a.stdout.trim()).toBe("alpha2");
21649
+ expect32(b.stdout.trim()).toBe("beta");
21650
+ expect32(c.stdout.trim()).toBe("gamma");
21361
21651
  } finally {
21362
21652
  await sandbox.destroy();
21363
21653
  }
21364
21654
  });
21365
- test31("host secrets are not leaked into the sandbox", async () => {
21655
+ test32("host secrets are not leaked into the sandbox", async () => {
21366
21656
  const secretKey = "SIXB_HOST_SECRET_DO_NOT_LEAK";
21367
21657
  const previous = process.env[secretKey];
21368
21658
  process.env[secretKey] = "host-only-value";
@@ -21370,8 +21660,8 @@ function runSandboxesContractSuite(label, options) {
21370
21660
  const sandbox = await factory.create();
21371
21661
  try {
21372
21662
  const result = await sandbox.runCommand("printenv", [secretKey]);
21373
- expect31(result.exitCode).not.toBe(0);
21374
- expect31(result.stdout).not.toContain("host-only-value");
21663
+ expect32(result.exitCode).not.toBe(0);
21664
+ expect32(result.stdout).not.toContain("host-only-value");
21375
21665
  } finally {
21376
21666
  await sandbox.destroy();
21377
21667
  }
@@ -21384,8 +21674,8 @@ function runSandboxesContractSuite(label, options) {
21384
21674
  }
21385
21675
  });
21386
21676
  });
21387
- describe30("timeout and abort", () => {
21388
- test31("a per-call timeout overrides the sandbox's, marks the result timedOut, and exits non-zero", async () => {
21677
+ describe31("timeout and abort", () => {
21678
+ test32("a per-call timeout overrides the sandbox's, marks the result timedOut, and exits non-zero", async () => {
21389
21679
  const sandbox = await factory.create({ timeout: SLEEP_BUDGET_SECONDS * 2 * 1000 });
21390
21680
  try {
21391
21681
  const start = Date.now();
@@ -21393,14 +21683,14 @@ function runSandboxesContractSuite(label, options) {
21393
21683
  timeout: shortTimeoutMs
21394
21684
  });
21395
21685
  const elapsed = Date.now() - start;
21396
- expect31(result.timedOut).toBe(true);
21397
- expect31(result.exitCode).not.toBe(0);
21398
- expect31(elapsed).toBeLessThan(SLEEP_BUDGET_SECONDS * 1000);
21686
+ expect32(result.timedOut).toBe(true);
21687
+ expect32(result.exitCode).not.toBe(0);
21688
+ expect32(elapsed).toBeLessThan(SLEEP_BUDGET_SECONDS * 1000);
21399
21689
  } finally {
21400
21690
  await sandbox.destroy();
21401
21691
  }
21402
21692
  });
21403
- test31("abort signal aborts an in-flight command", async () => {
21693
+ test32("abort signal aborts an in-flight command", async () => {
21404
21694
  const sandbox = await factory.create();
21405
21695
  try {
21406
21696
  const ac = new AbortController;
@@ -21410,15 +21700,30 @@ function runSandboxesContractSuite(label, options) {
21410
21700
  signal: ac.signal
21411
21701
  });
21412
21702
  const elapsed = Date.now() - start;
21413
- expect31(result.exitCode).not.toBe(0);
21414
- expect31(elapsed).toBeLessThan(SLEEP_BUDGET_SECONDS * 1000);
21703
+ expect32(result.exitCode).not.toBe(0);
21704
+ expect32(elapsed).toBeLessThan(SLEEP_BUDGET_SECONDS * 1000);
21705
+ } finally {
21706
+ await sandbox.destroy();
21707
+ }
21708
+ });
21709
+ test32("abort stops a shell and the commands it started", async () => {
21710
+ const sandbox = await factory.create();
21711
+ try {
21712
+ const ac = new AbortController;
21713
+ setTimeout(() => ac.abort(), shortTimeoutMs);
21714
+ const start = Date.now();
21715
+ const result = await sandbox.runCommand("sh", ["-c", `sleep ${SLEEP_BUDGET_SECONDS} && echo finished`], { signal: ac.signal });
21716
+ const elapsed = Date.now() - start;
21717
+ expect32(result.exitCode).not.toBe(0);
21718
+ expect32(result.stdout).not.toContain("finished");
21719
+ expect32(elapsed).toBeLessThan(SLEEP_BUDGET_SECONDS * 1000);
21415
21720
  } finally {
21416
21721
  await sandbox.destroy();
21417
21722
  }
21418
21723
  });
21419
21724
  });
21420
- describe30("file materialization", () => {
21421
- test31("writeFiles materializes files a subsequent command can read", async () => {
21725
+ describe31("file materialization", () => {
21726
+ test32("writeFiles materializes files a subsequent command can read", async () => {
21422
21727
  const sandbox = await factory.create();
21423
21728
  try {
21424
21729
  const flat = `${sandbox.workingDirectory}/materialized.txt`;
@@ -21428,32 +21733,32 @@ function runSandboxesContractSuite(label, options) {
21428
21733
  { path: nested, contents: "nested-contents" }
21429
21734
  ]);
21430
21735
  const flatResult = await sandbox.runCommand("cat", [flat]);
21431
- expect31(flatResult.exitCode).toBe(0);
21432
- expect31(flatResult.stdout).toContain("flat-contents");
21736
+ expect32(flatResult.exitCode).toBe(0);
21737
+ expect32(flatResult.stdout).toContain("flat-contents");
21433
21738
  const nestedResult = await sandbox.runCommand("cat", [nested]);
21434
- expect31(nestedResult.exitCode).toBe(0);
21435
- expect31(nestedResult.stdout).toContain("nested-contents");
21739
+ expect32(nestedResult.exitCode).toBe(0);
21740
+ expect32(nestedResult.stdout).toContain("nested-contents");
21436
21741
  } finally {
21437
21742
  await sandbox.destroy();
21438
21743
  }
21439
21744
  });
21440
- test31("writeFiles round-trips binary contents faithfully", async () => {
21745
+ test32("writeFiles round-trips binary contents faithfully", async () => {
21441
21746
  const sandbox = await factory.create();
21442
21747
  try {
21443
21748
  const path = `${sandbox.workingDirectory}/binary.dat`;
21444
21749
  const bytes = new Uint8Array([0, 1, 254, 255, 10, 127]);
21445
21750
  await sandbox.writeFiles([{ path, contents: bytes }]);
21446
21751
  const size = await sandbox.runCommand("wc", ["-c", path]);
21447
- expect31(size.exitCode).toBe(0);
21448
- expect31(size.stdout.trim().split(/\s+/)[0]).toBe(String(bytes.length));
21752
+ expect32(size.exitCode).toBe(0);
21753
+ expect32(size.stdout.trim().split(/\s+/)[0]).toBe(String(bytes.length));
21449
21754
  const hex = await sandbox.runCommand("od", ["-An", "-v", "-tx1", path]);
21450
- expect31(hex.exitCode).toBe(0);
21451
- expect31(hex.stdout.replace(/\s+/g, " ").trim()).toBe("00 01 fe ff 0a 7f");
21755
+ expect32(hex.exitCode).toBe(0);
21756
+ expect32(hex.stdout.replace(/\s+/g, " ").trim()).toBe("00 01 fe ff 0a 7f");
21452
21757
  } finally {
21453
21758
  await sandbox.destroy();
21454
21759
  }
21455
21760
  });
21456
- test31("writeFiles applies an explicit file mode", async () => {
21761
+ test32("writeFiles applies an explicit file mode", async () => {
21457
21762
  const sandbox = await factory.create();
21458
21763
  try {
21459
21764
  const path = `${sandbox.workingDirectory}/run.sh`;
@@ -21461,25 +21766,25 @@ function runSandboxesContractSuite(label, options) {
21461
21766
  echo ran
21462
21767
  `, mode: 493 }]);
21463
21768
  const result = await sandbox.runCommand("/bin/sh", ["-c", `test -x ${path} && echo yes`]);
21464
- expect31(result.exitCode).toBe(0);
21465
- expect31(result.stdout).toContain("yes");
21769
+ expect32(result.exitCode).toBe(0);
21770
+ expect32(result.stdout).toContain("yes");
21466
21771
  } finally {
21467
21772
  await sandbox.destroy();
21468
21773
  }
21469
21774
  });
21470
- test31("writeFiles after stop rejects", async () => {
21775
+ test32("writeFiles after stop rejects", async () => {
21471
21776
  const sandbox = await factory.create();
21472
21777
  await sandbox.stop();
21473
21778
  try {
21474
- await expect31(sandbox.writeFiles([{ path: `${sandbox.workingDirectory}/x.txt`, contents: "x" }])).rejects.toThrow(SandboxNotRunningError2);
21779
+ await expect32(sandbox.writeFiles([{ path: `${sandbox.workingDirectory}/x.txt`, contents: "x" }])).rejects.toThrow(SandboxNotRunningError2);
21475
21780
  } finally {
21476
21781
  await sandbox.destroy();
21477
21782
  }
21478
21783
  });
21479
21784
  });
21480
21785
  if (capabilities.networkBlocking) {
21481
- describe30("network isolation", () => {
21482
- test31('network.mode="none" blocks outbound DNS / TCP', async () => {
21786
+ describe31("network isolation", () => {
21787
+ test32('network.mode="none" blocks outbound DNS / TCP', async () => {
21483
21788
  const sandbox = await factory.create({ network: { mode: "none" } });
21484
21789
  try {
21485
21790
  const result = await sandbox.runCommand("curl", [
@@ -21488,12 +21793,12 @@ echo ran
21488
21793
  "2",
21489
21794
  "https://example.com"
21490
21795
  ]);
21491
- expect31(result.exitCode).not.toBe(0);
21796
+ expect32(result.exitCode).not.toBe(0);
21492
21797
  } finally {
21493
21798
  await sandbox.destroy();
21494
21799
  }
21495
21800
  });
21496
- test31('network.mode="all" permits outbound traffic', async () => {
21801
+ test32('network.mode="all" permits outbound traffic', async () => {
21497
21802
  const sandbox = await factory.create({ network: { mode: "all" } });
21498
21803
  try {
21499
21804
  const result = await sandbox.runCommand("curl", [
@@ -21502,7 +21807,7 @@ echo ran
21502
21807
  "5",
21503
21808
  "https://example.com"
21504
21809
  ]);
21505
- expect31(result.exitCode).not.toBe(6);
21810
+ expect32(result.exitCode).not.toBe(6);
21506
21811
  } finally {
21507
21812
  await sandbox.destroy();
21508
21813
  }
@@ -21510,28 +21815,28 @@ echo ran
21510
21815
  });
21511
21816
  }
21512
21817
  if (capabilities.readOnlyEnforcement) {
21513
- describe30("filesystem isolation", () => {
21514
- test31("writing inside readWritePaths succeeds", async () => {
21818
+ describe31("filesystem isolation", () => {
21819
+ test32("writing inside readWritePaths succeeds", async () => {
21515
21820
  const sandbox = await factory.create();
21516
21821
  try {
21517
21822
  const result = await sandbox.runCommand("/bin/sh", [
21518
21823
  "-c",
21519
21824
  `echo content > ${sandbox.workingDirectory}/probe.txt && cat ${sandbox.workingDirectory}/probe.txt`
21520
21825
  ]);
21521
- expect31(result.exitCode).toBe(0);
21522
- expect31(result.stdout.trim()).toBe("content");
21826
+ expect32(result.exitCode).toBe(0);
21827
+ expect32(result.stdout.trim()).toBe("content");
21523
21828
  } finally {
21524
21829
  await sandbox.destroy();
21525
21830
  }
21526
21831
  });
21527
- test31("writing outside readWritePaths fails", async () => {
21832
+ test32("writing outside readWritePaths fails", async () => {
21528
21833
  const sandbox = await factory.create();
21529
21834
  try {
21530
21835
  const result = await sandbox.runCommand("/bin/sh", [
21531
21836
  "-c",
21532
21837
  "echo nope > /etc/sixb-sandbox-must-not-write"
21533
21838
  ]);
21534
- expect31(result.exitCode).not.toBe(0);
21839
+ expect32(result.exitCode).not.toBe(0);
21535
21840
  } finally {
21536
21841
  await sandbox.destroy();
21537
21842
  }
@@ -21541,7 +21846,7 @@ echo ran
21541
21846
  });
21542
21847
  }
21543
21848
  // src/testing/share-grant-storage-contract.ts
21544
- import { describe as describe31, expect as expect32, test as test32 } from "bun:test";
21849
+ import { describe as describe32, expect as expect33, test as test33 } from "bun:test";
21545
21850
  var projectId21 = "share-grant-contract";
21546
21851
  var createdAt3 = new Date("2026-08-19T12:00:00.000Z");
21547
21852
  var expiresAt2 = new Date("2026-08-20T12:00:00.000Z");
@@ -21554,8 +21859,8 @@ function runShareGrantStorageContractSuite(label, options) {
21554
21859
  await options.cleanup?.(storage);
21555
21860
  }
21556
21861
  };
21557
- describe31(label, () => {
21558
- test32("stores derived authority and returns defensive copies", async () => {
21862
+ describe32(label, () => {
21863
+ test33("stores derived authority and returns defensive copies", async () => {
21559
21864
  await withStorage(async (storage) => {
21560
21865
  const input = grantInput();
21561
21866
  const created = await storage.create(input);
@@ -21574,7 +21879,7 @@ function runShareGrantStorageContractSuite(label, options) {
21574
21879
  viewGrant.selection.roots[0].anchor.primaryId = "mutated-result";
21575
21880
  });
21576
21881
  const stored = await storage.getById({ projectId: projectId21, id: "shr_1" });
21577
- expect32(stored).toMatchObject({
21882
+ expect33(stored).toMatchObject({
21578
21883
  id: "shr_1",
21579
21884
  target: { objectTypeId: "Report", primaryId: "report-1" },
21580
21885
  issuedBy: { type: "user", id: "usr_1" },
@@ -21583,30 +21888,30 @@ function runShareGrantStorageContractSuite(label, options) {
21583
21888
  createdAt: createdAt3,
21584
21889
  expiresAt: expiresAt2
21585
21890
  });
21586
- expect32(stored?.authorityDigest).toMatch(/^[0-9a-f]{64}$/);
21587
- expect32(stored?.tokenHash).toBe("a".repeat(64));
21891
+ expect33(stored?.authorityDigest).toMatch(/^[0-9a-f]{64}$/);
21892
+ expect33(stored?.tokenHash).toBe("a".repeat(64));
21588
21893
  });
21589
21894
  });
21590
- test32("enforces id and token-hash uniqueness per project", async () => {
21895
+ test33("enforces id and token-hash uniqueness per project", async () => {
21591
21896
  await withStorage(async (storage) => {
21592
21897
  await storage.create(grantInput());
21593
- await expect32(storage.create(grantInput({ tokenHash: "b".repeat(64) }))).rejects.toMatchObject({ code: "duplicate" });
21594
- await expect32(storage.create(grantInput({ id: "shr_2" }))).rejects.toMatchObject({
21898
+ await expect33(storage.create(grantInput({ tokenHash: "b".repeat(64) }))).rejects.toMatchObject({ code: "duplicate" });
21899
+ await expect33(storage.create(grantInput({ id: "shr_2" }))).rejects.toMatchObject({
21595
21900
  code: "duplicate"
21596
21901
  });
21597
- await expect32(storage.create(grantInput({ projectId: "other-project" }))).resolves.toMatchObject({ id: "shr_1", projectId: "other-project" });
21902
+ await expect33(storage.create(grantInput({ projectId: "other-project" }))).resolves.toMatchObject({ id: "shr_1", projectId: "other-project" });
21598
21903
  });
21599
21904
  });
21600
- test32("reads several grants at once, in the order asked", async () => {
21905
+ test33("reads several grants at once, in the order asked", async () => {
21601
21906
  await withStorage(async (storage) => {
21602
21907
  const first = await storage.create(grantInput());
21603
21908
  const second = await storage.create(grantInput({ id: "shr_2", tokenHash: "b".repeat(64), definitionId: "invoice" }));
21604
21909
  await storage.create(grantInput({ id: "shr_3", projectId: "other-project" }));
21605
- await expect32(storage.getByIds({ projectId: projectId21, ids: ["shr_2", "missing", "shr_1", "shr_2", "shr_3"] })).resolves.toEqual([second, first]);
21606
- await expect32(storage.getByIds({ projectId: projectId21, ids: [] })).resolves.toEqual([]);
21910
+ await expect33(storage.getByIds({ projectId: projectId21, ids: ["shr_2", "missing", "shr_1", "shr_2", "shr_3"] })).resolves.toEqual([second, first]);
21911
+ await expect33(storage.getByIds({ projectId: projectId21, ids: [] })).resolves.toEqual([]);
21607
21912
  });
21608
21913
  });
21609
- test32("lists a bounded deterministic page with total and hasMore", async () => {
21914
+ test33("lists a bounded deterministic page with total and hasMore", async () => {
21610
21915
  await withStorage(async (storage) => {
21611
21916
  await storage.create(grantInput({ id: "shr_a", tokenHash: "b".repeat(64) }));
21612
21917
  await storage.create(grantInput({ id: "shr_z", tokenHash: "c".repeat(64) }));
@@ -21615,19 +21920,19 @@ function runShareGrantStorageContractSuite(label, options) {
21615
21920
  tokenHash: "d".repeat(64),
21616
21921
  createdAt: new Date("2026-08-19T13:00:00.000Z")
21617
21922
  }));
21618
- await expect32(storage.list({ projectId: projectId21, now: createdAt3, limit: 2, offset: 0 })).resolves.toMatchObject({
21923
+ await expect33(storage.list({ projectId: projectId21, now: createdAt3, limit: 2, offset: 0 })).resolves.toMatchObject({
21619
21924
  grants: [{ id: "shr_newer" }, { id: "shr_z" }],
21620
21925
  total: 3,
21621
21926
  hasMore: true
21622
21927
  });
21623
- await expect32(storage.list({ projectId: projectId21, now: createdAt3, limit: 2, offset: 2 })).resolves.toMatchObject({
21928
+ await expect33(storage.list({ projectId: projectId21, now: createdAt3, limit: 2, offset: 2 })).resolves.toMatchObject({
21624
21929
  grants: [{ id: "shr_a" }],
21625
21930
  total: 3,
21626
21931
  hasMore: false
21627
21932
  });
21628
21933
  });
21629
21934
  });
21630
- test32("filters by project, definition, target, expiry instant, and revocation", async () => {
21935
+ test33("filters by project, definition, target, expiry instant, and revocation", async () => {
21631
21936
  await withStorage(async (storage) => {
21632
21937
  await storage.create(grantInput({ id: "active", tokenHash: "b".repeat(64) }));
21633
21938
  await storage.create(grantInput({
@@ -21658,7 +21963,7 @@ function runShareGrantStorageContractSuite(label, options) {
21658
21963
  target: { objectTypeId: "Report", primaryId: "report-1" },
21659
21964
  now
21660
21965
  };
21661
- await expect32(storage.list(filter)).resolves.toMatchObject({
21966
+ await expect33(storage.list(filter)).resolves.toMatchObject({
21662
21967
  grants: [{ id: "active" }],
21663
21968
  total: 1,
21664
21969
  hasMore: false
@@ -21668,7 +21973,7 @@ function runShareGrantStorageContractSuite(label, options) {
21668
21973
  includeExpired: true,
21669
21974
  includeRevoked: true
21670
21975
  });
21671
- expect32(allStates.grants.map((grant) => grant.id)).toEqual([
21976
+ expect33(allStates.grants.map((grant) => grant.id)).toEqual([
21672
21977
  "revoked",
21673
21978
  "expires-now",
21674
21979
  "expired",
@@ -21676,7 +21981,7 @@ function runShareGrantStorageContractSuite(label, options) {
21676
21981
  ]);
21677
21982
  });
21678
21983
  });
21679
- test32("keeps the first concurrent revocation and makes later calls idempotent", async () => {
21984
+ test33("keeps the first concurrent revocation and makes later calls idempotent", async () => {
21680
21985
  await withStorage(async (storage) => {
21681
21986
  await storage.create(grantInput());
21682
21987
  const left = {
@@ -21692,12 +21997,12 @@ function runShareGrantStorageContractSuite(label, options) {
21692
21997
  revokedBy: { type: "system", id: "system" }
21693
21998
  };
21694
21999
  const [first, second] = await Promise.all([storage.revoke(left), storage.revoke(right)]);
21695
- expect32(first).toEqual(second);
21696
- expect32(await storage.revoke({ ...right, revokedAt: new Date("2026-08-19T15:00:00.000Z") })).toEqual(first);
21697
- await expect32(storage.revoke({ ...left, id: "missing" })).resolves.toBeNull();
22000
+ expect33(first).toEqual(second);
22001
+ expect33(await storage.revoke({ ...right, revokedAt: new Date("2026-08-19T15:00:00.000Z") })).toEqual(first);
22002
+ await expect33(storage.revoke({ ...left, id: "missing" })).resolves.toBeNull();
21698
22003
  });
21699
22004
  });
21700
- test32("rejects invalid records and list windows consistently", async () => {
22005
+ test33("rejects invalid records and list windows consistently", async () => {
21701
22006
  await withStorage(async (storage) => {
21702
22007
  const foreignAuthority = grantInput().authoritySnapshot;
21703
22008
  const foreignViewGrant = foreignAuthority.access.grants[0];
@@ -21722,33 +22027,33 @@ function runShareGrantStorageContractSuite(label, options) {
21722
22027
  grantInput({ authoritySnapshot: foreignAuthority })
21723
22028
  ];
21724
22029
  for (const input of invalid) {
21725
- await expect32(storage.create(input)).rejects.toMatchObject({ code: "invalid_input" });
22030
+ await expect33(storage.create(input)).rejects.toMatchObject({ code: "invalid_input" });
21726
22031
  }
21727
- await expect32(storage.create(null)).rejects.toMatchObject({
22032
+ await expect33(storage.create(null)).rejects.toMatchObject({
21728
22033
  code: "invalid_input"
21729
22034
  });
21730
- await expect32(storage.getById(null)).rejects.toMatchObject({
22035
+ await expect33(storage.getById(null)).rejects.toMatchObject({
21731
22036
  code: "invalid_input"
21732
22037
  });
21733
- await expect32(storage.list({ projectId: projectId21, now: createdAt3, limit: 201 })).rejects.toMatchObject({ code: "invalid_input" });
21734
- await expect32(storage.list({ projectId: projectId21, now: new Date("invalid") })).rejects.toMatchObject({
22038
+ await expect33(storage.list({ projectId: projectId21, now: createdAt3, limit: 201 })).rejects.toMatchObject({ code: "invalid_input" });
22039
+ await expect33(storage.list({ projectId: projectId21, now: new Date("invalid") })).rejects.toMatchObject({
21735
22040
  code: "invalid_input"
21736
22041
  });
21737
22042
  });
21738
22043
  });
21739
- test32("rejects a revocation before creation without changing the grant", async () => {
22044
+ test33("rejects a revocation before creation without changing the grant", async () => {
21740
22045
  await withStorage(async (storage) => {
21741
22046
  await storage.create(grantInput());
21742
- await expect32(storage.revoke({
22047
+ await expect33(storage.revoke({
21743
22048
  projectId: projectId21,
21744
22049
  id: "shr_1",
21745
22050
  revokedAt: new Date("2026-08-19T11:59:59.999Z"),
21746
22051
  revokedBy: { type: "user", id: "usr_1" }
21747
22052
  })).rejects.toMatchObject({ code: "invalid_input" });
21748
22053
  const unchanged = await storage.getById({ projectId: projectId21, id: "shr_1" });
21749
- expect32(unchanged).not.toBeNull();
21750
- expect32(unchanged).not.toHaveProperty("revokedAt");
21751
- expect32(unchanged).not.toHaveProperty("revokedBy");
22054
+ expect33(unchanged).not.toBeNull();
22055
+ expect33(unchanged).not.toHaveProperty("revokedAt");
22056
+ expect33(unchanged).not.toHaveProperty("revokedBy");
21752
22057
  });
21753
22058
  });
21754
22059
  });
@@ -21802,11 +22107,11 @@ function attemptMutation(mutate) {
21802
22107
  try {
21803
22108
  mutate();
21804
22109
  } catch (error) {
21805
- expect32(error).toBeInstanceOf(TypeError);
22110
+ expect33(error).toBeInstanceOf(TypeError);
21806
22111
  }
21807
22112
  }
21808
22113
  // src/testing/share-session-storage-contract.ts
21809
- import { describe as describe32, expect as expect33, test as test33 } from "bun:test";
22114
+ import { describe as describe33, expect as expect34, test as test34 } from "bun:test";
21810
22115
  var projectId22 = "share-session-contract";
21811
22116
  var createdAt4 = new Date("2026-08-20T12:00:00.000Z");
21812
22117
  var expiresAt3 = new Date("2026-08-20T12:05:00.000Z");
@@ -21820,8 +22125,8 @@ function runShareSessionStorageContractSuite(label, options) {
21820
22125
  await options.cleanup?.(storage);
21821
22126
  }
21822
22127
  };
21823
- describe32(label, () => {
21824
- test33("stores normalized records and returns defensive copies", async () => {
22128
+ describe33(label, () => {
22129
+ test34("stores normalized records and returns defensive copies", async () => {
21825
22130
  await withStorage(async (storage) => {
21826
22131
  const input = sessionInput3();
21827
22132
  const created = await storage.create(input);
@@ -21829,66 +22134,66 @@ function runShareSessionStorageContractSuite(label, options) {
21829
22134
  input.expiresAt.setUTCFullYear(2040);
21830
22135
  input.absoluteExpiresAt.setUTCFullYear(2040);
21831
22136
  created.createdAt.setUTCFullYear(2041);
21832
- await expect33(storage.getById({ projectId: projectId22, id: "shs_1" })).resolves.toEqual(sessionInput3());
22137
+ await expect34(storage.getById({ projectId: projectId22, id: "shs_1" })).resolves.toEqual(sessionInput3());
21833
22138
  });
21834
22139
  });
21835
- test33("scopes identity and token-hash uniqueness to one project", async () => {
22140
+ test34("scopes identity and token-hash uniqueness to one project", async () => {
21836
22141
  await withStorage(async (storage) => {
21837
22142
  await storage.create(sessionInput3());
21838
22143
  await storage.create(sessionInput3({ projectId: "other-project" }));
21839
- await expect33(storage.create(sessionInput3({ tokenHash: "b".repeat(64) }))).rejects.toMatchObject({ code: "duplicate" });
21840
- await expect33(storage.create(sessionInput3({ id: "shs_2" }))).rejects.toMatchObject({
22144
+ await expect34(storage.create(sessionInput3({ tokenHash: "b".repeat(64) }))).rejects.toMatchObject({ code: "duplicate" });
22145
+ await expect34(storage.create(sessionInput3({ id: "shs_2" }))).rejects.toMatchObject({
21841
22146
  code: "duplicate"
21842
22147
  });
21843
- await expect33(storage.getById({ projectId: "other-project", id: "shs_1" })).resolves.toMatchObject({ projectId: "other-project" });
22148
+ await expect34(storage.getById({ projectId: "other-project", id: "shs_1" })).resolves.toMatchObject({ projectId: "other-project" });
21844
22149
  });
21845
22150
  });
21846
- test33("rejects a session whose Share grant does not exist", async () => {
22151
+ test34("rejects a session whose Share grant does not exist", async () => {
21847
22152
  await withStorage(async (storage) => {
21848
- await expect33(storage.create(sessionInput3({ grantId: "missing" }))).rejects.toMatchObject({
22153
+ await expect34(storage.create(sessionInput3({ grantId: "missing" }))).rejects.toMatchObject({
21849
22154
  code: "invalid_input"
21850
22155
  });
21851
22156
  });
21852
22157
  });
21853
- test33("authenticates exact session identity and active deadlines", async () => {
22158
+ test34("authenticates exact session identity and active deadlines", async () => {
21854
22159
  await withStorage(async (storage) => {
21855
22160
  await storage.create(sessionInput3());
21856
22161
  const valid = renewalInput({ expiresAt: new Date("2026-08-20T12:10:00.000Z") });
21857
- await expect33(storage.renewIfValid({ ...valid, now: new Date(expiresAt3) })).resolves.toBeNull();
21858
- await expect33(storage.renewIfValid(valid)).resolves.toMatchObject({
22162
+ await expect34(storage.renewIfValid({ ...valid, now: new Date(expiresAt3) })).resolves.toBeNull();
22163
+ await expect34(storage.renewIfValid(valid)).resolves.toMatchObject({
21859
22164
  id: "shs_1",
21860
22165
  expiresAt: new Date("2026-08-20T12:10:00.000Z")
21861
22166
  });
21862
- await expect33(storage.renewIfValid({ ...valid, id: "missing" })).resolves.toBeNull();
21863
- await expect33(storage.renewIfValid({ ...valid, grantId: "shr_other" })).resolves.toBeNull();
21864
- await expect33(storage.renewIfValid({ ...valid, tokenHash: "b".repeat(64) })).resolves.toBeNull();
21865
- await expect33(storage.renewIfValid({ ...valid, now: new Date("2026-08-20T11:59:59.999Z") })).resolves.toBeNull();
22167
+ await expect34(storage.renewIfValid({ ...valid, id: "missing" })).resolves.toBeNull();
22168
+ await expect34(storage.renewIfValid({ ...valid, grantId: "shr_other" })).resolves.toBeNull();
22169
+ await expect34(storage.renewIfValid({ ...valid, tokenHash: "b".repeat(64) })).resolves.toBeNull();
22170
+ await expect34(storage.renewIfValid({ ...valid, now: new Date("2026-08-20T11:59:59.999Z") })).resolves.toBeNull();
21866
22171
  });
21867
22172
  });
21868
- test33("never shortens, resurrects, or exceeds the absolute deadline", async () => {
22173
+ test34("never shortens, resurrects, or exceeds the absolute deadline", async () => {
21869
22174
  await withStorage(async (storage) => {
21870
22175
  await storage.create(sessionInput3());
21871
- await expect33(storage.renewIfValid(renewalInput({ expiresAt: new Date("2026-08-20T12:04:00.000Z") }))).resolves.toMatchObject({ expiresAt: expiresAt3 });
21872
- await expect33(storage.renewIfValid(renewalInput({ expiresAt: new Date("2026-08-20T13:00:00.000Z") }))).resolves.toMatchObject({ expiresAt: absoluteExpiresAt });
21873
- await expect33(storage.renewIfValid(renewalInput({
22176
+ await expect34(storage.renewIfValid(renewalInput({ expiresAt: new Date("2026-08-20T12:04:00.000Z") }))).resolves.toMatchObject({ expiresAt: expiresAt3 });
22177
+ await expect34(storage.renewIfValid(renewalInput({ expiresAt: new Date("2026-08-20T13:00:00.000Z") }))).resolves.toMatchObject({ expiresAt: absoluteExpiresAt });
22178
+ await expect34(storage.renewIfValid(renewalInput({
21874
22179
  now: new Date(absoluteExpiresAt),
21875
22180
  expiresAt: new Date("2026-08-20T13:00:00.000Z")
21876
22181
  }))).resolves.toBeNull();
21877
22182
  });
21878
22183
  });
21879
- test33("keeps concurrent renewals monotonic", async () => {
22184
+ test34("keeps concurrent renewals monotonic", async () => {
21880
22185
  await withStorage(async (storage) => {
21881
22186
  await storage.create(sessionInput3());
21882
22187
  await Promise.all([
21883
22188
  storage.renewIfValid(renewalInput({ expiresAt: new Date("2026-08-20T12:09:00.000Z") })),
21884
22189
  storage.renewIfValid(renewalInput({ expiresAt: new Date("2026-08-20T12:14:00.000Z") }))
21885
22190
  ]);
21886
- await expect33(storage.getById({ projectId: projectId22, id: "shs_1" })).resolves.toMatchObject({
22191
+ await expect34(storage.getById({ projectId: projectId22, id: "shs_1" })).resolves.toMatchObject({
21887
22192
  expiresAt: new Date("2026-08-20T12:14:00.000Z")
21888
22193
  });
21889
22194
  });
21890
22195
  });
21891
- test33("keeps the first concurrent revocation and blocks renewal", async () => {
22196
+ test34("keeps the first concurrent revocation and blocks renewal", async () => {
21892
22197
  await withStorage(async (storage) => {
21893
22198
  await storage.create(sessionInput3());
21894
22199
  const left = {
@@ -21902,13 +22207,13 @@ function runShareSessionStorageContractSuite(label, options) {
21902
22207
  revokedAt: new Date("2026-08-20T12:03:00.000Z")
21903
22208
  };
21904
22209
  const [first, second] = await Promise.all([storage.revoke(left), storage.revoke(right)]);
21905
- expect33(first).toEqual(second);
21906
- await expect33(storage.revoke(right)).resolves.toEqual(first);
21907
- await expect33(storage.renewIfValid(renewalInput())).resolves.toBeNull();
21908
- await expect33(storage.revoke({ ...left, id: "missing" })).resolves.toBeNull();
22210
+ expect34(first).toEqual(second);
22211
+ await expect34(storage.revoke(right)).resolves.toEqual(first);
22212
+ await expect34(storage.renewIfValid(renewalInput())).resolves.toBeNull();
22213
+ await expect34(storage.revoke({ ...left, id: "missing" })).resolves.toBeNull();
21909
22214
  });
21910
22215
  });
21911
- test33("rejects malformed inputs and impossible timestamps consistently", async () => {
22216
+ test34("rejects malformed inputs and impossible timestamps consistently", async () => {
21912
22217
  await withStorage(async (storage) => {
21913
22218
  const invalid = [
21914
22219
  sessionInput3({ id: "" }),
@@ -21921,26 +22226,26 @@ function runShareSessionStorageContractSuite(label, options) {
21921
22226
  sessionInput3({ absoluteExpiresAt: new Date("2026-08-20T12:04:00.000Z") })
21922
22227
  ];
21923
22228
  for (const input of invalid) {
21924
- await expect33(storage.create(input)).rejects.toMatchObject({ code: "invalid_input" });
22229
+ await expect34(storage.create(input)).rejects.toMatchObject({ code: "invalid_input" });
21925
22230
  }
21926
- await expect33(storage.create(null)).rejects.toMatchObject({
22231
+ await expect34(storage.create(null)).rejects.toMatchObject({
21927
22232
  code: "invalid_input"
21928
22233
  });
21929
- await expect33(storage.getById(null)).rejects.toMatchObject({
22234
+ await expect34(storage.getById(null)).rejects.toMatchObject({
21930
22235
  code: "invalid_input"
21931
22236
  });
21932
- await expect33(storage.renewIfValid(renewalInput({ expiresAt: new Date("2026-08-20T12:01:00.000Z") }))).rejects.toMatchObject({ code: "invalid_input" });
22237
+ await expect34(storage.renewIfValid(renewalInput({ expiresAt: new Date("2026-08-20T12:01:00.000Z") }))).rejects.toMatchObject({ code: "invalid_input" });
21933
22238
  });
21934
22239
  });
21935
- test33("rejects revocation before creation without changing the session", async () => {
22240
+ test34("rejects revocation before creation without changing the session", async () => {
21936
22241
  await withStorage(async (storage) => {
21937
22242
  await storage.create(sessionInput3());
21938
- await expect33(storage.revoke({
22243
+ await expect34(storage.revoke({
21939
22244
  projectId: projectId22,
21940
22245
  id: "shs_1",
21941
22246
  revokedAt: new Date("2026-08-20T11:59:59.999Z")
21942
22247
  })).rejects.toMatchObject({ code: "invalid_input" });
21943
- expect33(await storage.getById({ projectId: projectId22, id: "shs_1" })).not.toHaveProperty("revokedAt");
22248
+ expect34(await storage.getById({ projectId: projectId22, id: "shs_1" })).not.toHaveProperty("revokedAt");
21944
22249
  });
21945
22250
  });
21946
22251
  });
@@ -22012,7 +22317,7 @@ async function startTestSyncRun(storage, input) {
22012
22317
  });
22013
22318
  }
22014
22319
  // src/testing/unique-values-contract.ts
22015
- import { expect as expect34, test as test34 } from "bun:test";
22320
+ import { expect as expect35, test as test35 } from "bun:test";
22016
22321
  var PROJECT = "unique-values-contract";
22017
22322
  var Person = defineObjectType2({
22018
22323
  id: "UniqueContractPerson",
@@ -22063,40 +22368,40 @@ function runUniqueValuesContractSuite(name, provider) {
22063
22368
  await provider.cleanup?.(storage);
22064
22369
  }
22065
22370
  }
22066
- test34(`${name} refuses a value another object holds and keeps the first object`, async () => {
22371
+ test35(`${name} refuses a value another object holds and keeps the first object`, async () => {
22067
22372
  await withStorage(async (storage) => {
22068
22373
  const edits = editor(storage);
22069
22374
  await edits.commit([create("a", { email: "ada@example.com" })]);
22070
22375
  await edits.commit([create("b", { email: "bob@example.com" })]);
22071
22376
  const refused = await edits.commit([create("c", { email: "ada@example.com" })]).catch((error) => error);
22072
- expect34(refused).toBeInstanceOf(UniqueValueViolationError2);
22073
- expect34(refused).toMatchObject({
22377
+ expect35(refused).toBeInstanceOf(UniqueValueViolationError2);
22378
+ expect35(refused).toMatchObject({
22074
22379
  objectTypeId: Person.id,
22075
22380
  propertyId: "email",
22076
22381
  holderPrimaryId: "a",
22077
22382
  claimantPrimaryId: "c"
22078
22383
  });
22079
- expect34(String(refused.message)).toBe(`[Sixb] Another '${Person.id}' object already has this 'email'.`);
22080
- expect34(await person(storage, "a")).toMatchObject({ properties: { email: "ada@example.com" } });
22081
- expect34(await person(storage, "c")).toBeNull();
22384
+ expect35(String(refused.message)).toBe(`[Sixb] Another '${Person.id}' object already has this 'email'.`);
22385
+ expect35(await person(storage, "a")).toMatchObject({ properties: { email: "ada@example.com" } });
22386
+ expect35(await person(storage, "c")).toBeNull();
22082
22387
  });
22083
22388
  });
22084
- test34(`${name} finds the object holding a value`, async () => {
22389
+ test35(`${name} finds the object holding a value`, async () => {
22085
22390
  await withStorage(async (storage) => {
22086
22391
  await editor(storage).commit([
22087
22392
  create("a", { email: "ada@example.com" }),
22088
22393
  create("b", { email: "bob@example.com" })
22089
22394
  ]);
22090
- expect34(await holderOf(storage, "email", "ada@example.com")).toMatchObject({
22395
+ expect35(await holderOf(storage, "email", "ada@example.com")).toMatchObject({
22091
22396
  objectTypeId: Person.id,
22092
22397
  primaryId: "a",
22093
22398
  properties: { email: "ada@example.com" }
22094
22399
  });
22095
- expect34(await holderOf(storage, "email", "nobody@example.com")).toBeNull();
22096
- expect34(await holderOf(storage, "email", "ADA@example.com")).toBeNull();
22400
+ expect35(await holderOf(storage, "email", "nobody@example.com")).toBeNull();
22401
+ expect35(await holderOf(storage, "email", "ADA@example.com")).toBeNull();
22097
22402
  });
22098
22403
  });
22099
- test34(`${name} finds a holder only within a selected read scope that selects its value`, async () => {
22404
+ test35(`${name} finds a holder only within a selected read scope that selects its value`, async () => {
22100
22405
  await withStorage(async (storage) => {
22101
22406
  await editor(storage).commit([
22102
22407
  create("a", { email: "ada@example.com", name: "Ada" }),
@@ -22122,31 +22427,31 @@ function runUniqueValuesContractSuite(name, provider) {
22122
22427
  valueKey
22123
22428
  });
22124
22429
  const selected = scoped(["id", "email"]);
22125
- expect34(await lookup(selected, "ada@example.com")).toMatchObject({ primaryId: "a" });
22126
- expect34(await lookup(selected, "bob@example.com")).toBeNull();
22127
- expect34(await lookup(scoped(["id", "name"]), "ada@example.com")).toBeNull();
22430
+ expect35(await lookup(selected, "ada@example.com")).toMatchObject({ primaryId: "a" });
22431
+ expect35(await lookup(selected, "bob@example.com")).toBeNull();
22432
+ expect35(await lookup(scoped(["id", "name"]), "ada@example.com")).toBeNull();
22128
22433
  });
22129
22434
  });
22130
- test34(`${name} fails a commit that expected a value no object holds once one does`, async () => {
22435
+ test35(`${name} fails a commit that expected a value no object holds once one does`, async () => {
22131
22436
  await withStorage(async (storage) => {
22132
22437
  const edits = editor(storage);
22133
22438
  const unclaimed = [
22134
22439
  { objectTypeId: Person.id, propertyId: "email", valueKey: "x@example.com" }
22135
22440
  ];
22136
22441
  await edits.commit([create("a", { email: "x@example.com" })], unclaimed);
22137
- await expect34(edits.commit([create("b", { email: "y@example.com" })], unclaimed)).rejects.toMatchObject({ kind: "expectation" });
22138
- expect34(await person(storage, "b")).toBeNull();
22442
+ await expect35(edits.commit([create("b", { email: "y@example.com" })], unclaimed)).rejects.toMatchObject({ kind: "expectation" });
22443
+ expect35(await person(storage, "b")).toBeNull();
22139
22444
  });
22140
22445
  });
22141
- test34(`${name} lets any number of objects hold null or no value`, async () => {
22446
+ test35(`${name} lets any number of objects hold null or no value`, async () => {
22142
22447
  await withStorage(async (storage) => {
22143
22448
  const edits = editor(storage);
22144
22449
  await edits.commit([create("a", { email: null }), create("b", {}), create("c", {})]);
22145
22450
  await edits.commit([create("d", { email: null })]);
22146
- expect34(await person(storage, "d")).not.toBeNull();
22451
+ expect35(await person(storage, "d")).not.toBeNull();
22147
22452
  });
22148
22453
  });
22149
- test34(`${name} moves values between objects within one commit`, async () => {
22454
+ test35(`${name} moves values between objects within one commit`, async () => {
22150
22455
  await withStorage(async (storage) => {
22151
22456
  const edits = editor(storage);
22152
22457
  await edits.commit([
@@ -22160,15 +22465,15 @@ function runUniqueValuesContractSuite(name, provider) {
22160
22465
  setEmail("b", "2@example.com"),
22161
22466
  setEmail("c", "1@example.com")
22162
22467
  ]);
22163
- expect34(await emails(storage, ["a", "b", "c"])).toEqual([
22468
+ expect35(await emails(storage, ["a", "b", "c"])).toEqual([
22164
22469
  "3@example.com",
22165
22470
  "2@example.com",
22166
22471
  "1@example.com"
22167
22472
  ]);
22168
- await expect34(edits.commit([create("d", { email: "3@example.com" })])).rejects.toBeInstanceOf(UniqueValueViolationError2);
22473
+ await expect35(edits.commit([create("d", { email: "3@example.com" })])).rejects.toBeInstanceOf(UniqueValueViolationError2);
22169
22474
  });
22170
22475
  });
22171
- test34(`${name} frees a value that an update, a delete or an unset gives up`, async () => {
22476
+ test35(`${name} frees a value that an update, a delete or an unset gives up`, async () => {
22172
22477
  await withStorage(async (storage) => {
22173
22478
  const edits = editor(storage);
22174
22479
  await edits.commit([
@@ -22193,24 +22498,24 @@ function runUniqueValuesContractSuite(name, provider) {
22193
22498
  create("e", { email: "2@example.com" }),
22194
22499
  create("f", { email: "3@example.com" })
22195
22500
  ]);
22196
- expect34(await emails(storage, ["d", "e", "f"])).toEqual([
22501
+ expect35(await emails(storage, ["d", "e", "f"])).toEqual([
22197
22502
  "1@example.com",
22198
22503
  "2@example.com",
22199
22504
  "3@example.com"
22200
22505
  ]);
22201
22506
  });
22202
22507
  });
22203
- test34(`${name} refuses a restore that takes back a value given away`, async () => {
22508
+ test35(`${name} refuses a restore that takes back a value given away`, async () => {
22204
22509
  await withStorage(async (storage) => {
22205
22510
  const edits = editor(storage);
22206
22511
  await publish(storage, 1, [entry("p", "p@example.com")]);
22207
22512
  await edits.commit([{ id: "delete", kind: "object.delete", ref: personRef("p") }]);
22208
22513
  await edits.commit([create("a", { email: "p@example.com" })]);
22209
- await expect34(edits.commit([{ id: "restore", kind: "object.restore", ref: personRef("p") }])).rejects.toBeInstanceOf(UniqueValueViolationError2);
22210
- expect34(await person(storage, "p")).toBeNull();
22514
+ await expect35(edits.commit([{ id: "restore", kind: "object.restore", ref: personRef("p") }])).rejects.toBeInstanceOf(UniqueValueViolationError2);
22515
+ expect35(await person(storage, "p")).toBeNull();
22211
22516
  });
22212
22517
  });
22213
- test34(`${name} fails only the colliding item of a continue-mode batch`, async () => {
22518
+ test35(`${name} fails only the colliding item of a continue-mode batch`, async () => {
22214
22519
  await withStorage(async (storage) => {
22215
22520
  const edits = editor(storage);
22216
22521
  await edits.commit([create("a", { email: "a@example.com" })]);
@@ -22226,13 +22531,13 @@ function runUniqueValuesContractSuite(name, provider) {
22226
22531
  objectTypeId: Person.id,
22227
22532
  propertyId: "email"
22228
22533
  };
22229
- expect34(result.outcomes.map((outcome) => outcome.ok ? "ok" : outcome.error)).toEqual([
22534
+ expect35(result.outcomes.map((outcome) => outcome.ok ? "ok" : outcome.error)).toEqual([
22230
22535
  "ok",
22231
22536
  refused,
22232
22537
  refused,
22233
22538
  "ok"
22234
22539
  ]);
22235
- expect34(await emails(storage, ["b", "c", "d", "e"])).toEqual([
22540
+ expect35(await emails(storage, ["b", "c", "d", "e"])).toEqual([
22236
22541
  "b@example.com",
22237
22542
  undefined,
22238
22543
  undefined,
@@ -22240,7 +22545,7 @@ function runUniqueValuesContractSuite(name, provider) {
22240
22545
  ]);
22241
22546
  });
22242
22547
  });
22243
- test34(`${name} lets a continue-mode group swap values as a whole`, async () => {
22548
+ test35(`${name} lets a continue-mode group swap values as a whole`, async () => {
22244
22549
  await withStorage(async (storage) => {
22245
22550
  const edits = editor(storage);
22246
22551
  await edits.commit([
@@ -22252,21 +22557,21 @@ function runUniqueValuesContractSuite(name, provider) {
22252
22557
  setEmail("b", "1@example.com"),
22253
22558
  { ...setEmail("b", "2@example.com"), id: "email-b-again" }
22254
22559
  ], [["email-a", "email-b"]]);
22255
- expect34(result.outcomes.map((outcome) => outcome.ok)).toEqual([true, true, false]);
22256
- expect34(await emails(storage, ["a", "b"])).toEqual(["2@example.com", "1@example.com"]);
22560
+ expect35(result.outcomes.map((outcome) => outcome.ok)).toEqual([true, true, false]);
22561
+ expect35(await emails(storage, ["a", "b"])).toEqual(["2@example.com", "1@example.com"]);
22257
22562
  });
22258
22563
  });
22259
- test34(`${name} refuses two objects claiming one value in the same commit`, async () => {
22564
+ test35(`${name} refuses two objects claiming one value in the same commit`, async () => {
22260
22565
  await withStorage(async (storage) => {
22261
22566
  const edits = editor(storage);
22262
- await expect34(edits.commit([
22567
+ await expect35(edits.commit([
22263
22568
  create("a", { email: "x@example.com" }),
22264
22569
  create("b", { email: "x@example.com" })
22265
22570
  ])).rejects.toBeInstanceOf(UniqueValueViolationError2);
22266
- expect34(await person(storage, "a")).toBeNull();
22571
+ expect35(await person(storage, "a")).toBeNull();
22267
22572
  });
22268
22573
  });
22269
- test34(`${name} compares values exactly and keys user references by id`, async () => {
22574
+ test35(`${name} compares values exactly and keys user references by id`, async () => {
22270
22575
  await withStorage(async (storage) => {
22271
22576
  await createUsers(storage, ["usr_1", "usr_2"]);
22272
22577
  const edits = editor(storage);
@@ -22274,10 +22579,10 @@ function runUniqueValuesContractSuite(name, provider) {
22274
22579
  create("a", { email: "Ada@example.com", user: { type: "user", id: "usr_1" } }),
22275
22580
  create("b", { email: "ada@example.com", user: { type: "user", id: "usr_2" } })
22276
22581
  ]);
22277
- await expect34(edits.commit([create("c", { user: { id: "usr_1", type: "user" } })])).rejects.toMatchObject({ propertyId: "user", holderPrimaryId: "a" });
22582
+ await expect35(edits.commit([create("c", { user: { id: "usr_1", type: "user" } })])).rejects.toMatchObject({ propertyId: "user", holderPrimaryId: "a" });
22278
22583
  });
22279
22584
  });
22280
- test34(`${name} keeps the values of each concrete type apart`, async () => {
22585
+ test35(`${name} keeps the values of each concrete type apart`, async () => {
22281
22586
  await withStorage(async (storage) => {
22282
22587
  const edits = editor(storage);
22283
22588
  await edits.commit([
@@ -22289,7 +22594,7 @@ function runUniqueValuesContractSuite(name, provider) {
22289
22594
  properties: { id: "a", email: "same@example.com" }
22290
22595
  }
22291
22596
  ]);
22292
- await expect34(edits.commit([
22597
+ await expect35(edits.commit([
22293
22598
  {
22294
22599
  id: "employee",
22295
22600
  kind: "object.create",
@@ -22297,14 +22602,14 @@ function runUniqueValuesContractSuite(name, provider) {
22297
22602
  properties: { id: "b", email: "same@example.com" }
22298
22603
  }
22299
22604
  ])).rejects.toMatchObject({ objectTypeId: Employee.id, holderPrimaryId: "a" });
22300
- expect34(await holderOf(storage, "email", "same@example.com")).toMatchObject({
22605
+ expect35(await holderOf(storage, "email", "same@example.com")).toMatchObject({
22301
22606
  objectTypeId: Person.id
22302
22607
  });
22303
22608
  });
22304
22609
  });
22305
22610
  const waitForLockWait = provider.waitForLockWait;
22306
22611
  if (waitForLockWait) {
22307
- test34(`${name} gives a value to one of two concurrent commits`, async () => {
22612
+ test35(`${name} gives a value to one of two concurrent commits`, async () => {
22308
22613
  await withStorage(async (storage) => {
22309
22614
  const paused = pauseBeforeFinalize2(storage);
22310
22615
  const first = editor(paused.storage).commit([create("a", { email: "race@example.com" })]);
@@ -22312,12 +22617,12 @@ function runUniqueValuesContractSuite(name, provider) {
22312
22617
  const second = editor(storage).commit([create("b", { email: "race@example.com" })]).catch((error) => error);
22313
22618
  await waitForLockWait(storage, second);
22314
22619
  paused.release();
22315
- await expect34(first).resolves.toMatchObject({ created: true });
22316
- expect34(await second).toBeInstanceOf(UniqueValueViolationError2);
22317
- expect34(await person(storage, "b")).toBeNull();
22620
+ await expect35(first).resolves.toMatchObject({ created: true });
22621
+ expect35(await second).toBeInstanceOf(UniqueValueViolationError2);
22622
+ expect35(await person(storage, "b")).toBeNull();
22318
22623
  });
22319
22624
  });
22320
- test34(`${name} prepares a property again when a write commits during its backfill`, async () => {
22625
+ test35(`${name} prepares a property again when a write commits during its backfill`, async () => {
22321
22626
  await withStorage(async (storage) => {
22322
22627
  await migrateStorage2(storage, { projectId: PROJECT, ontology: plainOntology });
22323
22628
  await editor(storage, plainOntology).commit([create("a", { email: "a@example.com" })]);
@@ -22327,62 +22632,62 @@ function runUniqueValuesContractSuite(name, provider) {
22327
22632
  await editor(storage).commit([unsetEmail("a")]);
22328
22633
  paused.release();
22329
22634
  await preparing;
22330
- expect34(await holderOf(storage, "email", "a@example.com")).toBeNull();
22635
+ expect35(await holderOf(storage, "email", "a@example.com")).toBeNull();
22331
22636
  await editor(storage).commit([create("b", { email: "a@example.com" })]);
22332
22637
  }, { prepared: false });
22333
22638
  });
22334
22639
  }
22335
- test34(`${name} fails a publication whose objects share a value and keeps the previous one`, async () => {
22640
+ test35(`${name} fails a publication whose objects share a value and keeps the previous one`, async () => {
22336
22641
  await withStorage(async (storage) => {
22337
22642
  await publish(storage, 1, [entry("p-1", "1@example.com"), entry("p-2", "2@example.com")]);
22338
22643
  const refused = await publish(storage, 2, [
22339
22644
  entry("p-1", "same@example.com"),
22340
22645
  entry("p-2", "same@example.com")
22341
22646
  ]).catch((error) => error);
22342
- expect34(refused).toBeInstanceOf(UniqueValueViolationError2);
22343
- expect34(refused).toMatchObject({ holderPrimaryId: "p-1", claimantPrimaryId: "p-2" });
22344
- expect34(await emails(storage, ["p-1", "p-2"])).toEqual(["1@example.com", "2@example.com"]);
22647
+ expect35(refused).toBeInstanceOf(UniqueValueViolationError2);
22648
+ expect35(refused).toMatchObject({ holderPrimaryId: "p-1", claimantPrimaryId: "p-2" });
22649
+ expect35(await emails(storage, ["p-1", "p-2"])).toEqual(["1@example.com", "2@example.com"]);
22345
22650
  });
22346
22651
  });
22347
- test34(`${name} fails a publication that takes a value an edit gave to another object`, async () => {
22652
+ test35(`${name} fails a publication that takes a value an edit gave to another object`, async () => {
22348
22653
  await withStorage(async (storage) => {
22349
22654
  const edits = editor(storage);
22350
22655
  await publish(storage, 1, [entry("p-1", "1@example.com")]);
22351
22656
  await edits.commit([create("edited", { email: "taken@example.com" })]);
22352
22657
  await edits.commit([setEmail("p-1", "override@example.com")]);
22353
- await expect34(publish(storage, 2, [entry("p-1", "1@example.com"), entry("p-2", "taken@example.com")])).rejects.toMatchObject({ holderPrimaryId: "edited", claimantPrimaryId: "p-2" });
22354
- await expect34(publish(storage, 3, [entry("p-1", "1@example.com"), entry("p-3", "override@example.com")])).rejects.toMatchObject({ holderPrimaryId: "p-1", claimantPrimaryId: "p-3" });
22658
+ await expect35(publish(storage, 2, [entry("p-1", "1@example.com"), entry("p-2", "taken@example.com")])).rejects.toMatchObject({ holderPrimaryId: "edited", claimantPrimaryId: "p-2" });
22659
+ await expect35(publish(storage, 3, [entry("p-1", "1@example.com"), entry("p-3", "override@example.com")])).rejects.toMatchObject({ holderPrimaryId: "p-1", claimantPrimaryId: "p-3" });
22355
22660
  await publish(storage, 4, [entry("p-1", "1@example.com"), entry("p-3", "1@example.com")]);
22356
- expect34(await emails(storage, ["p-1", "p-3"])).toEqual([
22661
+ expect35(await emails(storage, ["p-1", "p-3"])).toEqual([
22357
22662
  "override@example.com",
22358
22663
  "1@example.com"
22359
22664
  ]);
22360
22665
  });
22361
22666
  });
22362
- test34(`${name} swaps values in a publication planned one row at a time`, async () => {
22667
+ test35(`${name} swaps values in a publication planned one row at a time`, async () => {
22363
22668
  await withStorage(async (storage) => {
22364
22669
  await publish(storage, 1, [entry("p-1", "1@example.com"), entry("p-2", "2@example.com")]);
22365
22670
  await publish(storage, 2, [entry("p-1", "2@example.com"), entry("p-2", "1@example.com")]);
22366
- expect34(await emails(storage, ["p-1", "p-2"])).toEqual(["2@example.com", "1@example.com"]);
22671
+ expect35(await emails(storage, ["p-1", "p-2"])).toEqual(["2@example.com", "1@example.com"]);
22367
22672
  });
22368
22673
  });
22369
- test34(`${name} keys integers beyond 2^53 too`, async () => {
22674
+ test35(`${name} keys integers beyond 2^53 too`, async () => {
22370
22675
  await withStorage(async (storage) => {
22371
22676
  const edits = editor(storage);
22372
22677
  await edits.commit([create("a", { badge: 2 ** 60 })]);
22373
- await expect34(edits.commit([create("b", { badge: 2 ** 60 })])).rejects.toMatchObject({
22678
+ await expect35(edits.commit([create("b", { badge: 2 ** 60 })])).rejects.toMatchObject({
22374
22679
  propertyId: "badge",
22375
22680
  holderPrimaryId: "a"
22376
22681
  });
22377
22682
  });
22378
22683
  });
22379
22684
  if (!provider.preparesOnClaim) {
22380
- test34(`${name} refuses a claim on a property no preparation built`, async () => {
22685
+ test35(`${name} refuses a claim on a property no preparation built`, async () => {
22381
22686
  await withStorage(async (storage) => {
22382
- await expect34(editor(storage).commit([create("a", { email: "a@example.com" })])).rejects.toThrow(`[Sixb] Unique property '${Person.id}.email' is not prepared. Run \`sixb db migrate\`.`);
22687
+ await expect35(editor(storage).commit([create("a", { email: "a@example.com" })])).rejects.toThrow(`[Sixb] Unique property '${Person.id}.email' is not prepared. Run \`sixb db migrate\`.`);
22383
22688
  }, { prepared: false });
22384
22689
  });
22385
- test34(`${name} refuses a claim on a property prepared with keys of another kind`, async () => {
22690
+ test35(`${name} refuses a claim on a property prepared with keys of another kind`, async () => {
22386
22691
  await withStorage(async (storage) => {
22387
22692
  const textBadges = new OntologyRegistry2({
22388
22693
  sources: [
@@ -22397,12 +22702,12 @@ function runUniqueValuesContractSuite(name, provider) {
22397
22702
  ]
22398
22703
  });
22399
22704
  const write = () => editor(storage, textBadges).commit([create("a", { badge: "B-1" })]);
22400
- await expect34(write()).rejects.toThrow(`[Sixb] Unique property '${Person.id}.badge' is not prepared. Run \`sixb db migrate\`.`);
22705
+ await expect35(write()).rejects.toThrow(`[Sixb] Unique property '${Person.id}.badge' is not prepared. Run \`sixb db migrate\`.`);
22401
22706
  await migrateStorage2(storage, { projectId: PROJECT, ontology: textBadges });
22402
22707
  await write();
22403
22708
  });
22404
22709
  });
22405
- test34(`${name} refuses a claim on a property prepared with an older key version`, async () => {
22710
+ test35(`${name} refuses a claim on a property prepared with an older key version`, async () => {
22406
22711
  await withStorage(async (storage) => {
22407
22712
  await storage.ontology.uniqueValues.markPrepared({
22408
22713
  projectId: PROJECT,
@@ -22413,16 +22718,16 @@ function runUniqueValuesContractSuite(name, provider) {
22413
22718
  preparedAt: "2026-03-01T00:00:00.000Z"
22414
22719
  });
22415
22720
  const write = () => editor(storage).commit([create("a", { email: "a@example.com" })]);
22416
- await expect34(write()).rejects.toThrow(`[Sixb] Unique property '${Person.id}.email' is not prepared. Run \`sixb db migrate\`.`);
22721
+ await expect35(write()).rejects.toThrow(`[Sixb] Unique property '${Person.id}.email' is not prepared. Run \`sixb db migrate\`.`);
22417
22722
  await migrateStorage2(storage, { projectId: PROJECT, ontology: ontology4 });
22418
22723
  await write();
22419
22724
  });
22420
22725
  });
22421
22726
  }
22422
- test34(`${name} prepares a property again when its keys change kind`, async () => {
22727
+ test35(`${name} prepares a property again when its keys change kind`, async () => {
22423
22728
  await withStorage(async (storage) => {
22424
22729
  const kindOf = async () => (await storage.ontology.uniqueValues.listPrepared({ projectId: PROJECT })).find((prepared) => prepared.objectTypeId === Person.id && prepared.propertyId === "badge")?.keyKind;
22425
- expect34(await kindOf()).toBe("integer");
22730
+ expect35(await kindOf()).toBe("integer");
22426
22731
  const Badge = defineValueType2({ id: "Badge", name: "Badge", schema: "userRef" });
22427
22732
  const userBadges = new OntologyRegistry2({
22428
22733
  sources: [
@@ -22437,10 +22742,10 @@ function runUniqueValuesContractSuite(name, provider) {
22437
22742
  ]
22438
22743
  });
22439
22744
  await migrateStorage2(storage, { projectId: PROJECT, ontology: userBadges });
22440
- expect34(await kindOf()).toBe("userRef");
22745
+ expect35(await kindOf()).toBe("userRef");
22441
22746
  });
22442
22747
  });
22443
- test34(`${name} prepares a property that becomes unique over existing objects`, async () => {
22748
+ test35(`${name} prepares a property that becomes unique over existing objects`, async () => {
22444
22749
  await withStorage(async (storage) => {
22445
22750
  await migrateStorage2(storage, { projectId: PROJECT, ontology: plainOntology });
22446
22751
  const plain = editor(storage, plainOntology);
@@ -22450,13 +22755,13 @@ function runUniqueValuesContractSuite(name, provider) {
22450
22755
  create("c", {})
22451
22756
  ]);
22452
22757
  await migrateStorage2(storage, { projectId: PROJECT, ontology: ontology4 });
22453
- await expect34(editor(storage).commit([create("d", { email: "a@example.com" })])).rejects.toMatchObject({ holderPrimaryId: "a", claimantPrimaryId: "d" });
22758
+ await expect35(editor(storage).commit([create("d", { email: "a@example.com" })])).rejects.toMatchObject({ holderPrimaryId: "a", claimantPrimaryId: "d" });
22454
22759
  await migrateStorage2(storage, { projectId: PROJECT, ontology: plainOntology });
22455
22760
  await plain.commit([create("d", { email: "a@example.com" })]);
22456
- await expect34(migrateStorage2(storage, { projectId: PROJECT, ontology: ontology4 })).rejects.toThrow(`[Sixb] Cannot make '${Person.id}.email' unique: objects 'a' and 'd' share a value. Fix the data, then start again.`);
22761
+ await expect35(migrateStorage2(storage, { projectId: PROJECT, ontology: ontology4 })).rejects.toThrow(`[Sixb] Cannot make '${Person.id}.email' unique: objects 'a' and 'd' share a value. Fix the data, then start again.`);
22457
22762
  await plain.commit([setEmail("d", "d@example.com")]);
22458
22763
  await migrateStorage2(storage, { projectId: PROJECT, ontology: ontology4 });
22459
- await expect34(editor(storage).commit([create("e", { email: "d@example.com" })])).rejects.toMatchObject({ holderPrimaryId: "d" });
22764
+ await expect35(editor(storage).commit([create("e", { email: "d@example.com" })])).rejects.toMatchObject({ holderPrimaryId: "d" });
22460
22765
  });
22461
22766
  });
22462
22767
  }
@@ -22670,6 +22975,24 @@ function pauseBeforeFinalize2(storage) {
22670
22975
  });
22671
22976
  return { storage: paused, reached: reached.promise, release: () => released.resolve() };
22672
22977
  }
22978
+ // src/testing/users.ts
22979
+ async function seedTestUsers(host, users) {
22980
+ const store = host.storage.auth?.users;
22981
+ if (!store) {
22982
+ throw new Error("[Sixb] seedTestUsers needs storage with auth, such as InMemoryStorage.");
22983
+ }
22984
+ const seededAt = Date.now();
22985
+ const profiles = [];
22986
+ for (const [index, user] of users.entries()) {
22987
+ const record = await store.create({
22988
+ ...user,
22989
+ projectId: host.id,
22990
+ createdAt: new Date(seededAt + index)
22991
+ });
22992
+ profiles.push(toUserProfile(record));
22993
+ }
22994
+ return profiles;
22995
+ }
22673
22996
  // src/testing/webhook-execution.ts
22674
22997
  async function createTestWebhookExecution(executions, input) {
22675
22998
  const executionId = input.executionId ?? `test_webhook_execution:${input.runId}`;
@@ -22702,7 +23025,7 @@ async function startTestWebhookRun(storage, input) {
22702
23025
  return storage.webhookRuns.start({ ...input, executionId });
22703
23026
  }
22704
23027
  // src/testing/webhook-run-storage-contract.ts
22705
- import { describe as describe33, expect as expect35, test as test35 } from "bun:test";
23028
+ import { describe as describe34, expect as expect36, test as test36 } from "bun:test";
22706
23029
  var projectId23 = "webhook-contract";
22707
23030
  var route = "/api/webhooks/github/events";
22708
23031
  var bodySha256 = "0".repeat(64);
@@ -22729,11 +23052,11 @@ function runWebhookRunStorageContractSuite(label, options) {
22729
23052
  await options.cleanup?.(storage);
22730
23053
  }
22731
23054
  };
22732
- describe33(label, () => {
22733
- test35("round-trips the immutable execution and delivery identity", async () => {
23055
+ describe34(label, () => {
23056
+ test36("round-trips the immutable execution and delivery identity", async () => {
22734
23057
  await withStorage(async (storage) => {
22735
23058
  const run = await startTestWebhookRun(storage, runInput3("delivery-1", "provider-1"));
22736
- expect35(run).toMatchObject({
23059
+ expect36(run).toMatchObject({
22737
23060
  id: "delivery-1",
22738
23061
  projectId: projectId23,
22739
23062
  executionId: "test_webhook_execution:delivery-1",
@@ -22745,7 +23068,7 @@ function runWebhookRunStorageContractSuite(label, options) {
22745
23068
  requestBodySha256: bodySha256,
22746
23069
  idempotencyKey: "provider-1"
22747
23070
  });
22748
- await expect35(storage.webhookRuns.getByDelivery({
23071
+ await expect36(storage.webhookRuns.getByDelivery({
22749
23072
  projectId: projectId23,
22750
23073
  connectorId: "github",
22751
23074
  webhookId: "events",
@@ -22753,21 +23076,21 @@ function runWebhookRunStorageContractSuite(label, options) {
22753
23076
  })).resolves.toEqual(run);
22754
23077
  });
22755
23078
  });
22756
- test35("rejects missing or mismatched execution authority", async () => {
23079
+ test36("rejects missing or mismatched execution authority", async () => {
22757
23080
  await withStorage(async (storage) => {
22758
23081
  const missing = runInput3("missing-execution");
22759
- await expect35(storage.webhookRuns.start({ ...missing, executionId: "missing" })).rejects.toMatchObject({ code: "invalid_execution" });
23082
+ await expect36(storage.webhookRuns.start({ ...missing, executionId: "missing" })).rejects.toMatchObject({ code: "invalid_execution" });
22760
23083
  await storage.executions.create(disabledRequestExecution("wrong-execution"));
22761
- await expect35(storage.webhookRuns.start({ ...missing, executionId: "wrong-execution" })).rejects.toMatchObject({ code: "invalid_execution" });
23084
+ await expect36(storage.webhookRuns.start({ ...missing, executionId: "wrong-execution" })).rejects.toMatchObject({ code: "invalid_execution" });
22762
23085
  });
22763
23086
  });
22764
- test35("enforces one run per provider delivery key", async () => {
23087
+ test36("enforces one run per provider delivery key", async () => {
22765
23088
  await withStorage(async (storage) => {
22766
23089
  await startTestWebhookRun(storage, runInput3("delivery-first", "provider-shared"));
22767
- await expect35(startTestWebhookRun(storage, runInput3("delivery-second", "provider-shared"))).rejects.toMatchObject({ code: "duplicate_run" });
23090
+ await expect36(startTestWebhookRun(storage, runInput3("delivery-second", "provider-shared"))).rejects.toMatchObject({ code: "duplicate_run" });
22768
23091
  });
22769
23092
  });
22770
- test35("restarts only retryable failures without changing execution identity", async () => {
23093
+ test36("restarts only retryable failures without changing execution identity", async () => {
22771
23094
  await withStorage(async (storage) => {
22772
23095
  const started = await startTestWebhookRun(storage, runInput3("delivery-retry", "provider-retry"));
22773
23096
  await storage.webhookRuns.finish({
@@ -22779,21 +23102,21 @@ function runWebhookRunStorageContractSuite(label, options) {
22779
23102
  error: retryableFailure
22780
23103
  });
22781
23104
  const restarted = await storage.webhookRuns.restart({ projectId: projectId23, id: started.id });
22782
- expect35(restarted).toMatchObject({
23105
+ expect36(restarted).toMatchObject({
22783
23106
  id: started.id,
22784
23107
  executionId: started.executionId,
22785
23108
  status: "running"
22786
23109
  });
22787
- expect35(restarted.finishedAt).toBeUndefined();
22788
- expect35(restarted.responseStatus).toBeUndefined();
22789
- expect35(restarted.error).toBeUndefined();
23110
+ expect36(restarted.finishedAt).toBeUndefined();
23111
+ expect36(restarted.responseStatus).toBeUndefined();
23112
+ expect36(restarted.error).toBeUndefined();
22790
23113
  await storage.webhookRuns.finish({
22791
23114
  projectId: projectId23,
22792
23115
  id: started.id,
22793
23116
  status: "succeeded",
22794
23117
  responseStatus: 202
22795
23118
  });
22796
- await expect35(storage.webhookRuns.restart({ projectId: projectId23, id: started.id })).rejects.toMatchObject({ code: "invalid_transition" });
23119
+ await expect36(storage.webhookRuns.restart({ projectId: projectId23, id: started.id })).rejects.toMatchObject({ code: "invalid_transition" });
22797
23120
  const rejected = await startTestWebhookRun(storage, runInput3("delivery-rejected"));
22798
23121
  await storage.webhookRuns.finish({
22799
23122
  projectId: projectId23,
@@ -22803,10 +23126,10 @@ function runWebhookRunStorageContractSuite(label, options) {
22803
23126
  responseStatus: 422,
22804
23127
  error: rejectedFailure
22805
23128
  });
22806
- await expect35(storage.webhookRuns.restart({ projectId: projectId23, id: rejected.id })).rejects.toMatchObject({ code: "invalid_transition" });
23129
+ await expect36(storage.webhookRuns.restart({ projectId: projectId23, id: rejected.id })).rejects.toMatchObject({ code: "invalid_transition" });
22807
23130
  });
22808
23131
  });
22809
- test35("persists a validated, detached failure through get and list", async () => {
23132
+ test36("persists a validated, detached failure through get and list", async () => {
22810
23133
  await withStorage(async (storage) => {
22811
23134
  const run = await startTestWebhookRun(storage, runInput3("failed-run", "failed-key"));
22812
23135
  const failedRunFailure = {
@@ -22833,21 +23156,21 @@ function runWebhookRunStorageContractSuite(label, options) {
22833
23156
  error: mutableFailure
22834
23157
  });
22835
23158
  mutableFailure.details.runId = "mutated-after-write";
22836
- expect35(finished.error).toEqual(failedRunFailure);
22837
- await expect35(storage.webhookRuns.getById({ projectId: projectId23, id: run.id })).resolves.toMatchObject({
23159
+ expect36(finished.error).toEqual(failedRunFailure);
23160
+ await expect36(storage.webhookRuns.getById({ projectId: projectId23, id: run.id })).resolves.toMatchObject({
22838
23161
  error: failedRunFailure
22839
23162
  });
22840
- await expect35(storage.webhookRuns.list({
23163
+ await expect36(storage.webhookRuns.list({
22841
23164
  projectId: projectId23,
22842
23165
  statuses: ["failed"],
22843
23166
  idempotencyKey: "failed-key"
22844
23167
  })).resolves.toMatchObject({ runs: [{ id: run.id, error: failedRunFailure }], total: 1 });
22845
23168
  });
22846
23169
  });
22847
- test35("rejects failures outside the Webhook run contract without finishing", async () => {
23170
+ test36("rejects failures outside the Webhook run contract without finishing", async () => {
22848
23171
  await withStorage(async (storage) => {
22849
23172
  const run = await startTestWebhookRun(storage, runInput3("invalid-failure"));
22850
- await expect35(storage.webhookRuns.finish({
23173
+ await expect36(storage.webhookRuns.finish({
22851
23174
  projectId: projectId23,
22852
23175
  id: run.id,
22853
23176
  status: "failed",
@@ -22855,8 +23178,8 @@ function runWebhookRunStorageContractSuite(label, options) {
22855
23178
  error: { ...retryableFailure, code: "runtime.cancelled" }
22856
23179
  })).rejects.toThrow("code is not allowed by this failure contract");
22857
23180
  const unchanged = await storage.webhookRuns.getById({ projectId: projectId23, id: run.id });
22858
- expect35(unchanged?.status).toBe("running");
22859
- expect35(unchanged?.error).toBeUndefined();
23181
+ expect36(unchanged?.status).toBe("running");
23182
+ expect36(unchanged?.error).toBeUndefined();
22860
23183
  });
22861
23184
  });
22862
23185
  });
@@ -22886,7 +23209,7 @@ function disabledRequestExecution(id) {
22886
23209
  };
22887
23210
  }
22888
23211
  // src/testing/workflow-intervention-storage-contract.ts
22889
- import { describe as describe34, expect as expect36, test as test36 } from "bun:test";
23212
+ import { describe as describe35, expect as expect37, test as test37 } from "bun:test";
22890
23213
  var projectId24 = "workflow-intervention-contract";
22891
23214
  function runWorkflowInterventionStorageContractSuite(label, options) {
22892
23215
  const withStorage = async (run) => {
@@ -22897,8 +23220,8 @@ function runWorkflowInterventionStorageContractSuite(label, options) {
22897
23220
  await options.cleanup?.(storage);
22898
23221
  }
22899
23222
  };
22900
- describe34(label, () => {
22901
- test36("creates pending interventions and supports filtered paging", async () => {
23223
+ describe35(label, () => {
23224
+ test37("creates pending interventions and supports filtered paging", async () => {
22902
23225
  await withStorage(async (storage) => {
22903
23226
  await storage.create(interventionInput({ id: "intervention-1", requestedAt: at7("10:00") }));
22904
23227
  await storage.create(interventionInput({
@@ -22922,26 +23245,26 @@ function runWorkflowInterventionStorageContractSuite(label, options) {
22922
23245
  order: "asc",
22923
23246
  limit: 1
22924
23247
  });
22925
- expect36(stored).toMatchObject({
23248
+ expect37(stored).toMatchObject({
22926
23249
  id: "intervention-1",
22927
23250
  status: "pending",
22928
23251
  input: { draftId: "draft-1" },
22929
23252
  defaultResponse: { decision: "approve" }
22930
23253
  });
22931
- expect36(stored?.requestedAt.toISOString()).toBe(at7("10:00").toISOString());
22932
- expect36(page.total).toBe(1);
22933
- expect36(page.hasMore).toBe(false);
22934
- expect36(page.interventions.map((intervention) => intervention.id)).toEqual([
23254
+ expect37(stored?.requestedAt.toISOString()).toBe(at7("10:00").toISOString());
23255
+ expect37(page.total).toBe(1);
23256
+ expect37(page.hasMore).toBe(false);
23257
+ expect37(page.interventions.map((intervention) => intervention.id)).toEqual([
22935
23258
  "intervention-1"
22936
23259
  ]);
22937
- await expect36(storage.list({ projectId: projectId24, statuses: [] })).resolves.toEqual({
23260
+ await expect37(storage.list({ projectId: projectId24, statuses: [] })).resolves.toEqual({
22938
23261
  interventions: [],
22939
23262
  hasMore: false,
22940
23263
  total: 0
22941
23264
  });
22942
23265
  });
22943
23266
  });
22944
- test36("submits, cancels, expires, and rejects invalid transitions", async () => {
23267
+ test37("submits, cancels, expires, and rejects invalid transitions", async () => {
22945
23268
  await withStorage(async (storage) => {
22946
23269
  await storage.create(interventionInput({ id: "submit-me" }));
22947
23270
  const submitted = await storage.submit({
@@ -22960,26 +23283,26 @@ function runWorkflowInterventionStorageContractSuite(label, options) {
22960
23283
  });
22961
23284
  await storage.create(interventionInput({ id: "expire-me" }));
22962
23285
  const expired = await storage.expire({ projectId: projectId24, id: "expire-me", expiredAt: at7("13:00") });
22963
- expect36(submitted).toMatchObject({
23286
+ expect37(submitted).toMatchObject({
22964
23287
  status: "submitted",
22965
23288
  response: { decision: "approve", reviewerNote: "Looks good." },
22966
23289
  submittedBy: { type: "user", id: "usr_1" }
22967
23290
  });
22968
- expect36(submitted.submittedAt?.toISOString()).toBe(at7("12:00").toISOString());
22969
- expect36(cancelled).toMatchObject({
23291
+ expect37(submitted.submittedAt?.toISOString()).toBe(at7("12:00").toISOString());
23292
+ expect37(cancelled).toMatchObject({
22970
23293
  status: "cancelled",
22971
23294
  cancelledBy: { type: "system", id: "workflow-timeout" }
22972
23295
  });
22973
- expect36(cancelled.cancelledAt?.toISOString()).toBe(at7("12:30").toISOString());
22974
- expect36(expired.status).toBe("expired");
22975
- expect36(expired.expiredAt?.toISOString()).toBe(at7("13:00").toISOString());
22976
- await expect36(storage.cancel({ projectId: projectId24, id: "submit-me" })).rejects.toBeInstanceOf(WorkflowInterventionError2);
22977
- await expect36(storage.submit({ projectId: projectId24, id: "missing", response: {} })).rejects.toBeInstanceOf(WorkflowInterventionError2);
22978
- await expect36(storage.create(interventionInput({ id: "submit-me" }))).rejects.toBeInstanceOf(WorkflowInterventionError2);
22979
- await expect36(storage.create(interventionInput({ id: "bad-index", nodeIndex: -1 }))).rejects.toBeInstanceOf(WorkflowInterventionError2);
23296
+ expect37(cancelled.cancelledAt?.toISOString()).toBe(at7("12:30").toISOString());
23297
+ expect37(expired.status).toBe("expired");
23298
+ expect37(expired.expiredAt?.toISOString()).toBe(at7("13:00").toISOString());
23299
+ await expect37(storage.cancel({ projectId: projectId24, id: "submit-me" })).rejects.toBeInstanceOf(WorkflowInterventionError2);
23300
+ await expect37(storage.submit({ projectId: projectId24, id: "missing", response: {} })).rejects.toBeInstanceOf(WorkflowInterventionError2);
23301
+ await expect37(storage.create(interventionInput({ id: "submit-me" }))).rejects.toBeInstanceOf(WorkflowInterventionError2);
23302
+ await expect37(storage.create(interventionInput({ id: "bad-index", nodeIndex: -1 }))).rejects.toBeInstanceOf(WorkflowInterventionError2);
22980
23303
  });
22981
23304
  });
22982
- test36("persists submitting and cancelling principals as { type, id }", async () => {
23305
+ test37("persists submitting and cancelling principals as { type, id }", async () => {
22983
23306
  await withStorage(async (storage) => {
22984
23307
  const principals = [
22985
23308
  { type: "user", id: "usr_1" },
@@ -23006,14 +23329,14 @@ function runWorkflowInterventionStorageContractSuite(label, options) {
23006
23329
  for (const principal of principals) {
23007
23330
  const submitted = await storage.getById({ projectId: projectId24, id: `submit-${principal.type}` });
23008
23331
  const cancelled = await storage.getById({ projectId: projectId24, id: `cancel-${principal.type}` });
23009
- expect36(submitted?.submittedBy).toStrictEqual(principal);
23010
- expect36(cancelled?.cancelledBy).toStrictEqual(principal);
23332
+ expect37(submitted?.submittedBy).toStrictEqual(principal);
23333
+ expect37(cancelled?.cancelledBy).toStrictEqual(principal);
23011
23334
  }
23012
23335
  const anonymous = await storage.getById({ projectId: projectId24, id: "anonymous" });
23013
- expect36(anonymous?.submittedBy).toBeUndefined();
23014
- expect36(anonymous?.cancelledBy).toBeUndefined();
23336
+ expect37(anonymous?.submittedBy).toBeUndefined();
23337
+ expect37(anonymous?.cancelledBy).toBeUndefined();
23015
23338
  const listed = await storage.list({ projectId: projectId24, statuses: ["submitted"], order: "asc" });
23016
- expect36(listed.interventions.flatMap((intervention) => intervention.submittedBy ? [intervention.submittedBy] : [])).toStrictEqual([...principals]);
23339
+ expect37(listed.interventions.flatMap((intervention) => intervention.submittedBy ? [intervention.submittedBy] : [])).toStrictEqual([...principals]);
23017
23340
  });
23018
23341
  });
23019
23342
  });
@@ -23086,6 +23409,7 @@ export {
23086
23409
  runOntologyStorageContractSuite,
23087
23410
  runProjectionRunStorageContractSuite,
23088
23411
  runQueueContractSuite,
23412
+ runSandboxCredentialsContractSuite,
23089
23413
  runSandboxesContractSuite,
23090
23414
  runShareGrantStorageContractSuite,
23091
23415
  runShareSessionStorageContractSuite,
@@ -23094,10 +23418,11 @@ export {
23094
23418
  runWorkflowInterventionStorageContractSuite,
23095
23419
  seedAiCostStorageContractUsage,
23096
23420
  seedAiUsageStorageContractExecutions,
23421
+ seedTestUsers,
23097
23422
  startTestPipelineRun,
23098
23423
  startTestProjectionRun,
23099
23424
  startTestSyncRun,
23100
23425
  startTestWebhookRun
23101
23426
  };
23102
23427
 
23103
- //# debugId=D566F21ED4BE115364756E2164756E21
23428
+ //# debugId=490BDE87BE4ADA8D64756E2164756E21