@sixb/core 0.2.2 → 0.2.3

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 (1119) hide show
  1. package/dist/actions/index.js +55 -49
  2. package/dist/actions/index.js.map +1 -1
  3. package/dist/actions/request.d.ts.map +1 -1
  4. package/dist/actions/run/executor.d.ts +0 -2
  5. package/dist/actions/run/executor.d.ts.map +1 -1
  6. package/dist/actions/types/context.d.ts +5 -1
  7. package/dist/actions/types/context.d.ts.map +1 -1
  8. package/dist/agents/execution.d.ts +2 -1
  9. package/dist/agents/execution.d.ts.map +1 -1
  10. package/dist/agents/fork.d.ts.map +1 -1
  11. package/dist/agents/index.d.ts +1 -1
  12. package/dist/agents/index.d.ts.map +1 -1
  13. package/dist/agents/index.js +82 -75
  14. package/dist/agents/index.js.map +1 -1
  15. package/dist/agents/request.d.ts +7 -1
  16. package/dist/agents/request.d.ts.map +1 -1
  17. package/dist/agents/run-artifacts.d.ts +73 -10
  18. package/dist/agents/run-artifacts.d.ts.map +1 -1
  19. package/dist/agents/run-session-http.d.ts.map +1 -1
  20. package/dist/agents/run-session-serve.d.ts.map +1 -1
  21. package/dist/agents/run-session.d.ts +3 -0
  22. package/dist/agents/run-session.d.ts.map +1 -1
  23. package/dist/agents/streams/index.js +2 -2
  24. package/dist/agents/streams/internal.js +2 -2
  25. package/dist/agents/streams/protocol.d.ts.map +1 -1
  26. package/dist/agents/validation.d.ts +1 -1
  27. package/dist/agents/validation.d.ts.map +1 -1
  28. package/dist/artifacts/access.d.ts +37 -17
  29. package/dist/artifacts/access.d.ts.map +1 -1
  30. package/dist/artifacts/canvas-display.d.ts +65 -0
  31. package/dist/artifacts/canvas-display.d.ts.map +1 -0
  32. package/dist/artifacts/canvas.d.ts +6 -1
  33. package/dist/artifacts/canvas.d.ts.map +1 -1
  34. package/dist/artifacts/comment-text.d.ts +19 -0
  35. package/dist/artifacts/comment-text.d.ts.map +1 -0
  36. package/dist/artifacts/comments.d.ts +52 -0
  37. package/dist/artifacts/comments.d.ts.map +1 -0
  38. package/dist/artifacts/errors.d.ts +3 -3
  39. package/dist/artifacts/errors.d.ts.map +1 -1
  40. package/dist/artifacts/events.d.ts +14 -0
  41. package/dist/artifacts/events.d.ts.map +1 -0
  42. package/dist/artifacts/execution.d.ts +129 -22
  43. package/dist/artifacts/execution.d.ts.map +1 -1
  44. package/dist/artifacts/frames/assets.d.ts +12 -1
  45. package/dist/artifacts/frames/assets.d.ts.map +1 -1
  46. package/dist/artifacts/frames/grants.d.ts +8 -5
  47. package/dist/artifacts/frames/grants.d.ts.map +1 -1
  48. package/dist/artifacts/frames/index.d.ts +1 -1
  49. package/dist/artifacts/frames/index.d.ts.map +1 -1
  50. package/dist/artifacts/frames/index.js +32 -964
  51. package/dist/artifacts/frames/index.js.map +4 -8
  52. package/dist/artifacts/frames/kit.d.ts.map +1 -1
  53. package/dist/artifacts/frames/protocol.d.ts +78 -0
  54. package/dist/artifacts/frames/protocol.d.ts.map +1 -1
  55. package/dist/artifacts/frames/runtime.d.ts +17 -7
  56. package/dist/artifacts/frames/runtime.d.ts.map +1 -1
  57. package/dist/artifacts/holders.d.ts +23 -0
  58. package/dist/artifacts/holders.d.ts.map +1 -0
  59. package/dist/artifacts/ids.d.ts +2 -0
  60. package/dist/artifacts/ids.d.ts.map +1 -1
  61. package/dist/artifacts/index.d.ts +6 -4
  62. package/dist/artifacts/index.d.ts.map +1 -1
  63. package/dist/artifacts/index.js +108 -13
  64. package/dist/artifacts/index.js.map +5 -4
  65. package/dist/artifacts/limits.d.ts +24 -3
  66. package/dist/artifacts/limits.d.ts.map +1 -1
  67. package/dist/artifacts/live/board.d.ts +103 -0
  68. package/dist/artifacts/live/board.d.ts.map +1 -0
  69. package/dist/artifacts/live/diff.d.ts +43 -0
  70. package/dist/artifacts/live/diff.d.ts.map +1 -0
  71. package/dist/artifacts/live/document.d.ts +55 -0
  72. package/dist/artifacts/live/document.d.ts.map +1 -0
  73. package/dist/artifacts/live/files.d.ts +16 -0
  74. package/dist/artifacts/live/files.d.ts.map +1 -0
  75. package/dist/artifacts/live/index.d.ts +9 -0
  76. package/dist/artifacts/live/index.d.ts.map +1 -0
  77. package/dist/artifacts/live/index.js +593 -0
  78. package/dist/artifacts/live/index.js.map +10 -0
  79. package/dist/artifacts/live/presence.d.ts +55 -0
  80. package/dist/artifacts/live/presence.d.ts.map +1 -0
  81. package/dist/artifacts/live/protocol.d.ts +109 -0
  82. package/dist/artifacts/live/protocol.d.ts.map +1 -0
  83. package/dist/artifacts/live/protocol.js +21 -0
  84. package/dist/artifacts/live/protocol.js.map +9 -0
  85. package/dist/artifacts/live/server.d.ts +10 -0
  86. package/dist/artifacts/live/server.d.ts.map +1 -0
  87. package/dist/artifacts/live/server.js +86 -0
  88. package/dist/artifacts/live/server.js.map +9 -0
  89. package/dist/artifacts/live/state.d.ts +26 -0
  90. package/dist/artifacts/live/state.d.ts.map +1 -0
  91. package/dist/artifacts/outline.d.ts +11 -0
  92. package/dist/artifacts/outline.d.ts.map +1 -1
  93. package/dist/artifacts/publish/index.d.ts +8 -1
  94. package/dist/artifacts/publish/index.d.ts.map +1 -1
  95. package/dist/artifacts/publish/index.js +61 -33
  96. package/dist/artifacts/publish/index.js.map +1 -1
  97. package/dist/artifacts/publish/merge.d.ts +75 -0
  98. package/dist/artifacts/publish/merge.d.ts.map +1 -0
  99. package/dist/artifacts/publish/previews.d.ts +153 -0
  100. package/dist/artifacts/publish/previews.d.ts.map +1 -0
  101. package/dist/artifacts/publish/publish.d.ts +29 -8
  102. package/dist/artifacts/publish/publish.d.ts.map +1 -1
  103. package/dist/artifacts/publish/query-answers.d.ts +20 -0
  104. package/dist/artifacts/publish/query-answers.d.ts.map +1 -0
  105. package/dist/artifacts/publish/references.d.ts +4 -3
  106. package/dist/artifacts/publish/references.d.ts.map +1 -1
  107. package/dist/artifacts/publish/validate/canvas.d.ts.map +1 -1
  108. package/dist/artifacts/theme.d.ts +5 -1
  109. package/dist/artifacts/theme.d.ts.map +1 -1
  110. package/dist/auth/directory.d.ts +33 -0
  111. package/dist/auth/directory.d.ts.map +1 -0
  112. package/dist/auth/index.js +13 -12
  113. package/dist/auth/index.js.map +1 -1
  114. package/dist/auth/member-events.d.ts +5 -1
  115. package/dist/auth/member-events.d.ts.map +1 -1
  116. package/dist/auth/runtime.d.ts +22 -1
  117. package/dist/auth/runtime.d.ts.map +1 -1
  118. package/dist/auth/strategy.d.ts +2 -2
  119. package/dist/auth/strategy.d.ts.map +1 -1
  120. package/dist/auth/types.d.ts +42 -1
  121. package/dist/auth/types.d.ts.map +1 -1
  122. package/dist/authorization/decision.d.ts +6 -5
  123. package/dist/authorization/decision.d.ts.map +1 -1
  124. package/dist/authorization/event-visibility.d.ts.map +1 -1
  125. package/dist/authorization/index.js +7 -6
  126. package/dist/authorization/index.js.map +1 -1
  127. package/dist/blob-storage/index.js +4 -4
  128. package/dist/blob-storage/index.js.map +1 -1
  129. package/dist/bootstrap/index.js +62 -56
  130. package/dist/bootstrap/index.js.map +2 -2
  131. package/dist/broker/in-memory.d.ts.map +1 -1
  132. package/dist/broker/index.js +1 -1
  133. package/dist/broker/types.d.ts +4 -0
  134. package/dist/broker/types.d.ts.map +1 -1
  135. package/dist/{chunk-s7j8ewqv.js → chunk-0k3r5kb3.js} +257 -43
  136. package/dist/{chunk-s7j8ewqv.js.map → chunk-0k3r5kb3.js.map} +14 -13
  137. package/dist/{chunk-e5wf5vz0.js → chunk-0kgrghqx.js} +13 -1
  138. package/dist/chunk-0kgrghqx.js.map +10 -0
  139. package/dist/{chunk-80gym75n.js → chunk-186k5yz3.js} +1 -1
  140. package/dist/chunk-191jz8a6.js +61 -0
  141. package/dist/chunk-191jz8a6.js.map +10 -0
  142. package/dist/{chunk-mmagke4x.js → chunk-22d3qg4x.js} +2 -2
  143. package/dist/{chunk-mmagke4x.js.map → chunk-22d3qg4x.js.map} +3 -3
  144. package/dist/{chunk-m2vh8gh0.js → chunk-26qet7wh.js} +62 -15
  145. package/dist/{chunk-m2vh8gh0.js.map → chunk-26qet7wh.js.map} +5 -5
  146. package/dist/{chunk-eqgr6nsa.js → chunk-2by73sm2.js} +982 -184
  147. package/dist/chunk-2by73sm2.js.map +75 -0
  148. package/dist/chunk-2c4j899j.js.map +2 -2
  149. package/dist/{chunk-e6xgz4h4.js → chunk-3014rfjz.js} +197 -18
  150. package/dist/chunk-3014rfjz.js.map +21 -0
  151. package/dist/chunk-38yvdqzd.js +70 -0
  152. package/dist/chunk-38yvdqzd.js.map +10 -0
  153. package/dist/{chunk-ytzcxtpt.js → chunk-3ba89vm7.js} +1 -1
  154. package/dist/chunk-3hzhcfsv.js +139 -0
  155. package/dist/chunk-3hzhcfsv.js.map +10 -0
  156. package/dist/chunk-3sgvd10b.js +69 -0
  157. package/dist/chunk-3sgvd10b.js.map +10 -0
  158. package/dist/{chunk-djs3hw9p.js → chunk-3zagkr6w.js} +73 -6
  159. package/dist/chunk-3zagkr6w.js.map +21 -0
  160. package/dist/{chunk-wkq3kvzd.js → chunk-48c1z8nj.js} +6 -6
  161. package/dist/chunk-48c1z8nj.js.map +10 -0
  162. package/dist/{chunk-3sqqhpr7.js → chunk-4j0sagwv.js} +134 -19
  163. package/dist/{chunk-3sqqhpr7.js.map → chunk-4j0sagwv.js.map} +11 -10
  164. package/dist/{chunk-d04g36fw.js → chunk-5qqmndhm.js} +1 -1
  165. package/dist/{chunk-scyq22td.js → chunk-5rqqp8cr.js} +19 -4
  166. package/dist/chunk-5rqqp8cr.js.map +12 -0
  167. package/dist/{chunk-f1h34y3r.js → chunk-6gtxshcc.js} +6 -6
  168. package/dist/{chunk-f1h34y3r.js.map → chunk-6gtxshcc.js.map} +1 -1
  169. package/dist/{chunk-jspskey0.js → chunk-7j4yydm2.js} +67 -45
  170. package/dist/chunk-7j4yydm2.js.map +11 -0
  171. package/dist/{chunk-5wtnmpze.js → chunk-7qe46788.js} +1 -1
  172. package/dist/{chunk-31kcqmhf.js → chunk-855w9nvw.js} +1 -1
  173. package/dist/{chunk-e7v3trpz.js → chunk-8a8k38tz.js} +4 -3
  174. package/dist/chunk-8a8k38tz.js.map +10 -0
  175. package/dist/{chunk-2ajw5rz0.js → chunk-8p7bze4c.js} +3 -3
  176. package/dist/{chunk-jftd33rc.js → chunk-8t2ynwg0.js} +105 -9
  177. package/dist/chunk-8t2ynwg0.js.map +11 -0
  178. package/dist/{chunk-9whfmsfk.js → chunk-8tqnsx3q.js} +1 -1
  179. package/dist/{chunk-s3we74h8.js → chunk-9nsjjd44.js} +38 -5
  180. package/dist/chunk-9nsjjd44.js.map +12 -0
  181. package/dist/{chunk-hz5d43gn.js → chunk-9vsc919v.js} +14 -6
  182. package/dist/chunk-9vsc919v.js.map +10 -0
  183. package/dist/{chunk-waqk73p1.js → chunk-a6fjkcne.js} +185 -341
  184. package/dist/{chunk-waqk73p1.js.map → chunk-a6fjkcne.js.map} +6 -7
  185. package/dist/{chunk-s038wa5v.js → chunk-b9qfh2ya.js} +1 -1
  186. package/dist/{chunk-5taem5aw.js → chunk-bc3y6gff.js} +13 -4
  187. package/dist/chunk-bc3y6gff.js.map +10 -0
  188. package/dist/{chunk-w1btn96n.js → chunk-bkmnd7zq.js} +523 -254
  189. package/dist/chunk-bkmnd7zq.js.map +49 -0
  190. package/dist/chunk-bz5bnjjt.js +358 -0
  191. package/dist/chunk-bz5bnjjt.js.map +12 -0
  192. package/dist/{chunk-w976a4me.js → chunk-czct88ht.js} +28 -4
  193. package/dist/chunk-czct88ht.js.map +10 -0
  194. package/dist/{chunk-5kyvrtjh.js → chunk-d9xbwh3h.js} +131 -32
  195. package/dist/chunk-d9xbwh3h.js.map +13 -0
  196. package/dist/{chunk-kfee1h52.js → chunk-dfveegqq.js} +28 -8
  197. package/dist/chunk-dfveegqq.js.map +13 -0
  198. package/dist/{chunk-2g0r46hy.js → chunk-dhkc9b23.js} +15 -2
  199. package/dist/chunk-dhkc9b23.js.map +12 -0
  200. package/dist/chunk-dmnd9ea6.js +106 -0
  201. package/dist/chunk-dmnd9ea6.js.map +10 -0
  202. package/dist/{chunk-nz7815t3.js → chunk-e0hnbb1m.js} +27 -2
  203. package/dist/chunk-e0hnbb1m.js.map +14 -0
  204. package/dist/chunk-e91fmg6t.js +288 -0
  205. package/dist/chunk-e91fmg6t.js.map +11 -0
  206. package/dist/{chunk-a5v4gjdx.js → chunk-e9w4mgdh.js} +308 -220
  207. package/dist/{chunk-a5v4gjdx.js.map → chunk-e9w4mgdh.js.map} +21 -19
  208. package/dist/{chunk-w122ymx4.js → chunk-f6ahf5gf.js} +15 -4
  209. package/dist/{chunk-w122ymx4.js.map → chunk-f6ahf5gf.js.map} +3 -3
  210. package/dist/{chunk-jjmggm9a.js → chunk-fe6r7yhg.js} +1 -1
  211. package/dist/{chunk-165c9wm6.js → chunk-g2ph4873.js} +1 -1
  212. package/dist/chunk-hgj98cbb.js +22 -0
  213. package/dist/chunk-hgj98cbb.js.map +10 -0
  214. package/dist/{chunk-mbc5hvnj.js → chunk-hkaa807g.js} +18 -7
  215. package/dist/{chunk-mbc5hvnj.js.map → chunk-hkaa807g.js.map} +3 -3
  216. package/dist/chunk-hn2r7z41.js.map +3 -3
  217. package/dist/chunk-j0wgh8gv.js +250 -0
  218. package/dist/chunk-j0wgh8gv.js.map +10 -0
  219. package/dist/{chunk-z8fx5cgb.js → chunk-j2zm215x.js} +37 -3
  220. package/dist/chunk-j2zm215x.js.map +12 -0
  221. package/dist/{chunk-j1ny5fwh.js → chunk-k1g14kk3.js} +11 -83
  222. package/dist/{chunk-j1ny5fwh.js.map → chunk-k1g14kk3.js.map} +4 -5
  223. package/dist/{chunk-ga63a3dz.js → chunk-k66rp2hr.js} +3 -3
  224. package/dist/chunk-kr6dx38r.js +25 -0
  225. package/dist/chunk-kr6dx38r.js.map +10 -0
  226. package/dist/{chunk-a7aa0nzj.js → chunk-kv0kvknv.js} +14 -14
  227. package/dist/{chunk-a7aa0nzj.js.map → chunk-kv0kvknv.js.map} +1 -1
  228. package/dist/chunk-m2jerfef.js +474 -0
  229. package/dist/chunk-m2jerfef.js.map +11 -0
  230. package/dist/chunk-m7b9q5dk.js +234 -0
  231. package/dist/chunk-m7b9q5dk.js.map +12 -0
  232. package/dist/{chunk-escedwyt.js → chunk-mvz89age.js} +6 -1
  233. package/dist/{chunk-escedwyt.js.map → chunk-mvz89age.js.map} +3 -3
  234. package/dist/chunk-mwcqz3e3.js +30 -0
  235. package/dist/chunk-mwcqz3e3.js.map +10 -0
  236. package/dist/chunk-n2ay51px.js +21 -0
  237. package/dist/chunk-n2ay51px.js.map +10 -0
  238. package/dist/{chunk-gkv8r794.js → chunk-n68vz95m.js} +5 -5
  239. package/dist/{chunk-gkv8r794.js.map → chunk-n68vz95m.js.map} +3 -3
  240. package/dist/{chunk-0j3crh1w.js → chunk-p351afzm.js} +14 -14
  241. package/dist/{chunk-0j3crh1w.js.map → chunk-p351afzm.js.map} +4 -4
  242. package/dist/chunk-pk539cwv.js +370 -0
  243. package/dist/chunk-pk539cwv.js.map +11 -0
  244. package/dist/{chunk-jbw70d6t.js → chunk-ppxf7gw2.js} +52 -10
  245. package/dist/chunk-ppxf7gw2.js.map +11 -0
  246. package/dist/{chunk-9x8dybsb.js → chunk-pvpq483h.js} +10 -2
  247. package/dist/chunk-pvpq483h.js.map +10 -0
  248. package/dist/chunk-qafng88v.js +225 -0
  249. package/dist/chunk-qafng88v.js.map +11 -0
  250. package/dist/chunk-qds484t8.js +1363 -0
  251. package/dist/chunk-qds484t8.js.map +18 -0
  252. package/dist/{chunk-4zm1k3xj.js → chunk-r2psmn42.js} +1 -1
  253. package/dist/{chunk-kkjfve0t.js → chunk-rt9deb92.js} +4 -3
  254. package/dist/{chunk-kkjfve0t.js.map → chunk-rt9deb92.js.map} +3 -3
  255. package/dist/{chunk-r1cxq7vv.js → chunk-rtdrm592.js} +2 -2
  256. package/dist/{chunk-c7cfe31p.js → chunk-s5n9617r.js} +15 -15
  257. package/dist/{chunk-c7cfe31p.js.map → chunk-s5n9617r.js.map} +1 -1
  258. package/dist/{chunk-4bm0caep.js → chunk-smnt672s.js} +1 -1
  259. package/dist/{chunk-21q0j5f2.js → chunk-stmxh0hv.js} +2 -2
  260. package/dist/{chunk-nh26e7c5.js → chunk-sysnvjce.js} +5 -5
  261. package/dist/{chunk-nh26e7c5.js.map → chunk-sysnvjce.js.map} +3 -3
  262. package/dist/{chunk-57g0215c.js → chunk-t24yktqr.js} +296 -7
  263. package/dist/{chunk-57g0215c.js.map → chunk-t24yktqr.js.map} +6 -3
  264. package/dist/{chunk-ff5xkv0p.js → chunk-tfzvjdms.js} +1 -1
  265. package/dist/chunk-tqa68kj7.js +1322 -0
  266. package/dist/chunk-tqa68kj7.js.map +25 -0
  267. package/dist/chunk-vtjzwymr.js +37 -0
  268. package/dist/chunk-vtjzwymr.js.map +10 -0
  269. package/dist/{chunk-twfreyxr.js → chunk-vzkxqf8h.js} +23 -13
  270. package/dist/{chunk-twfreyxr.js.map → chunk-vzkxqf8h.js.map} +6 -6
  271. package/dist/{chunk-6b61s40c.js → chunk-w3t94hm6.js} +1 -1
  272. package/dist/{chunk-j8thxj7w.js → chunk-w9s23r24.js} +1218 -101
  273. package/dist/chunk-w9s23r24.js.map +30 -0
  274. package/dist/{chunk-fwsvshr5.js → chunk-wa05txmk.js} +20 -7
  275. package/dist/{chunk-fwsvshr5.js.map → chunk-wa05txmk.js.map} +3 -3
  276. package/dist/chunk-whbwf3np.js +12 -0
  277. package/dist/chunk-whbwf3np.js.map +10 -0
  278. package/dist/{chunk-t5608tkq.js → chunk-yv8hv4wq.js} +3 -1
  279. package/dist/{chunk-t5608tkq.js.map → chunk-yv8hv4wq.js.map} +3 -3
  280. package/dist/{chunk-dsv783c3.js → chunk-z0t4p2sk.js} +169 -53
  281. package/dist/{chunk-dsv783c3.js.map → chunk-z0t4p2sk.js.map} +7 -7
  282. package/dist/connectors/builders.d.ts +2 -2
  283. package/dist/connectors/builders.d.ts.map +1 -1
  284. package/dist/connectors/connections/access.d.ts +11 -0
  285. package/dist/connectors/connections/access.d.ts.map +1 -0
  286. package/dist/connectors/connections/contracts.d.ts +6 -1
  287. package/dist/connectors/connections/contracts.d.ts.map +1 -1
  288. package/dist/connectors/connections/internal.js +1 -1
  289. package/dist/connectors/connections/runs.d.ts +6 -0
  290. package/dist/connectors/connections/runs.d.ts.map +1 -1
  291. package/dist/connectors/connections/service.d.ts +25 -0
  292. package/dist/connectors/connections/service.d.ts.map +1 -1
  293. package/dist/connectors/connections/views.d.ts +1 -1
  294. package/dist/connectors/connections/views.d.ts.map +1 -1
  295. package/dist/connectors/execution.d.ts.map +1 -1
  296. package/dist/connectors/index.d.ts +1 -1
  297. package/dist/connectors/index.d.ts.map +1 -1
  298. package/dist/connectors/service.d.ts +3 -0
  299. package/dist/connectors/service.d.ts.map +1 -1
  300. package/dist/connectors/types.d.ts +21 -2
  301. package/dist/connectors/types.d.ts.map +1 -1
  302. package/dist/datasets/execution.d.ts +12 -6
  303. package/dist/datasets/execution.d.ts.map +1 -1
  304. package/dist/datasets/ingest-flush-batch.d.ts +59 -0
  305. package/dist/datasets/ingest-flush-batch.d.ts.map +1 -0
  306. package/dist/datasets/ingest-flush-job.d.ts +33 -0
  307. package/dist/datasets/ingest-flush-job.d.ts.map +1 -0
  308. package/dist/datasets/ingest-flush.d.ts +66 -0
  309. package/dist/datasets/ingest-flush.d.ts.map +1 -0
  310. package/dist/datasets/produced-version.d.ts +21 -0
  311. package/dist/datasets/produced-version.d.ts.map +1 -0
  312. package/dist/datasets/write.d.ts +22 -1
  313. package/dist/datasets/write.d.ts.map +1 -1
  314. package/dist/datasets/write.js +8 -4
  315. package/dist/datasets/write.js.map +1 -1
  316. package/dist/deploy/internal.js +5 -4
  317. package/dist/deploy/internal.js.map +4 -4
  318. package/dist/deploy/types.d.ts +2 -3
  319. package/dist/deploy/types.d.ts.map +1 -1
  320. package/dist/error-reporting/capability.d.ts +8 -2
  321. package/dist/error-reporting/capability.d.ts.map +1 -1
  322. package/dist/error-reporting/internal.d.ts +1 -1
  323. package/dist/error-reporting/internal.d.ts.map +1 -1
  324. package/dist/error-reporting/internal.js +17 -5
  325. package/dist/error-reporting/internal.js.map +1 -1
  326. package/dist/error-reporting/reporter.d.ts.map +1 -1
  327. package/dist/error-reporting/reports.d.ts +55 -0
  328. package/dist/error-reporting/reports.d.ts.map +1 -1
  329. package/dist/error-reporting/types.d.ts +82 -1
  330. package/dist/error-reporting/types.d.ts.map +1 -1
  331. package/dist/errors/catalog.d.ts +5 -0
  332. package/dist/errors/catalog.d.ts.map +1 -1
  333. package/dist/errors/internal.js +1 -1
  334. package/dist/events/definitions.d.ts +4 -0
  335. package/dist/events/definitions.d.ts.map +1 -1
  336. package/dist/events/execution.d.ts +1 -0
  337. package/dist/events/execution.d.ts.map +1 -1
  338. package/dist/events/index.d.ts +1 -1
  339. package/dist/events/index.d.ts.map +1 -1
  340. package/dist/events/index.js +5 -5
  341. package/dist/events/scope.d.ts.map +1 -1
  342. package/dist/events/scope.js +1 -1
  343. package/dist/events/selectors/index.js +2 -2
  344. package/dist/events/types/artifacts.d.ts +38 -0
  345. package/dist/events/types/artifacts.d.ts.map +1 -0
  346. package/dist/events/types/index.d.ts +3 -1
  347. package/dist/events/types/index.d.ts.map +1 -1
  348. package/dist/events/types/users.d.ts +5 -2
  349. package/dist/events/types/users.d.ts.map +1 -1
  350. package/dist/execution/agent.js +57 -51
  351. package/dist/execution/agent.js.map +1 -1
  352. package/dist/execution/authorized-object-reader.d.ts +10 -0
  353. package/dist/execution/authorized-object-reader.d.ts.map +1 -1
  354. package/dist/execution/object-reader-clearance.d.ts +6 -0
  355. package/dist/execution/object-reader-clearance.d.ts.map +1 -1
  356. package/dist/execution/object-reader-security.d.ts +9 -2
  357. package/dist/execution/object-reader-security.d.ts.map +1 -1
  358. package/dist/execution/primitive.js +55 -49
  359. package/dist/execution/primitive.js.map +1 -1
  360. package/dist/execution/request.js +49 -43
  361. package/dist/execution/request.js.map +2 -2
  362. package/dist/http/api-routes.d.ts +1 -1
  363. package/dist/http/api-routes.d.ts.map +1 -1
  364. package/dist/http/index.js +1 -1
  365. package/dist/index.d.ts +10 -8
  366. package/dist/index.d.ts.map +1 -1
  367. package/dist/index.js +95 -87
  368. package/dist/index.js.map +1 -1
  369. package/dist/lake-storage/errors.d.ts +15 -0
  370. package/dist/lake-storage/errors.d.ts.map +1 -1
  371. package/dist/lake-storage/index.d.ts +3 -2
  372. package/dist/lake-storage/index.d.ts.map +1 -1
  373. package/dist/lake-storage/index.js +16 -10
  374. package/dist/lake-storage/index.js.map +1 -1
  375. package/dist/lake-storage/maintenance.d.ts +88 -0
  376. package/dist/lake-storage/maintenance.d.ts.map +1 -0
  377. package/dist/lake-storage/merge.d.ts +3 -1
  378. package/dist/lake-storage/merge.d.ts.map +1 -1
  379. package/dist/lake-storage/source-ordering.d.ts +23 -0
  380. package/dist/lake-storage/source-ordering.d.ts.map +1 -1
  381. package/dist/lake-storage/types.d.ts +10 -0
  382. package/dist/lake-storage/types.d.ts.map +1 -1
  383. package/dist/maintenance/heartbeat.d.ts +5 -0
  384. package/dist/maintenance/heartbeat.d.ts.map +1 -0
  385. package/dist/maintenance/index.d.ts +4 -2
  386. package/dist/maintenance/index.d.ts.map +1 -1
  387. package/dist/maintenance/index.js +515 -0
  388. package/dist/maintenance/index.js.map +16 -0
  389. package/dist/maintenance/lake-retention-status.d.ts +36 -0
  390. package/dist/maintenance/lake-retention-status.d.ts.map +1 -0
  391. package/dist/maintenance/lake-retention.d.ts +84 -0
  392. package/dist/maintenance/lake-retention.d.ts.map +1 -0
  393. package/dist/maintenance/loop.d.ts +95 -0
  394. package/dist/maintenance/loop.d.ts.map +1 -0
  395. package/dist/maintenance/ontology-maintenance.d.ts +17 -16
  396. package/dist/maintenance/ontology-maintenance.d.ts.map +1 -1
  397. package/dist/maintenance/passes/cron-pass.d.ts +21 -0
  398. package/dist/maintenance/passes/cron-pass.d.ts.map +1 -0
  399. package/dist/maintenance/passes/directory-pass.d.ts +12 -0
  400. package/dist/maintenance/passes/directory-pass.d.ts.map +1 -0
  401. package/dist/maintenance/passes/ingest-pass.d.ts +26 -0
  402. package/dist/maintenance/passes/ingest-pass.d.ts.map +1 -0
  403. package/dist/maintenance/passes/lake-change-feed.d.ts +38 -0
  404. package/dist/maintenance/passes/lake-change-feed.d.ts.map +1 -0
  405. package/dist/maintenance/passes/lake-retention-pass.d.ts +20 -0
  406. package/dist/maintenance/passes/lake-retention-pass.d.ts.map +1 -0
  407. package/dist/maintenance/passes/ontology-pass.d.ts +8 -0
  408. package/dist/maintenance/passes/ontology-pass.d.ts.map +1 -0
  409. package/dist/maintenance/passes/projections-pass.d.ts +26 -0
  410. package/dist/maintenance/passes/projections-pass.d.ts.map +1 -0
  411. package/dist/maintenance/passes/recovery-pass.d.ts +6 -0
  412. package/dist/maintenance/passes/recovery-pass.d.ts.map +1 -0
  413. package/dist/maintenance/passes/recovery-passes.d.ts +24 -0
  414. package/dist/maintenance/passes/recovery-passes.d.ts.map +1 -0
  415. package/dist/maintenance/passes/runs-pass.d.ts +6 -0
  416. package/dist/maintenance/passes/runs-pass.d.ts.map +1 -0
  417. package/dist/maintenance/passes/triggers-pass.d.ts +41 -0
  418. package/dist/maintenance/passes/triggers-pass.d.ts.map +1 -0
  419. package/dist/maintenance/status.d.ts +19 -0
  420. package/dist/maintenance/status.d.ts.map +1 -0
  421. package/dist/maintenance/types.d.ts +25 -24
  422. package/dist/maintenance/types.d.ts.map +1 -1
  423. package/dist/materialization/model.d.ts +11 -2
  424. package/dist/materialization/model.d.ts.map +1 -1
  425. package/dist/materializer/edits/artifact-refs.d.ts +33 -0
  426. package/dist/materializer/edits/artifact-refs.d.ts.map +1 -0
  427. package/dist/materializer/edits/commit.d.ts.map +1 -1
  428. package/dist/materializer/edits/operations.d.ts +7 -1
  429. package/dist/materializer/edits/operations.d.ts.map +1 -1
  430. package/dist/materializer/edits/plan.d.ts.map +1 -1
  431. package/dist/materializer/execution/work-records.d.ts +6 -0
  432. package/dist/materializer/execution/work-records.d.ts.map +1 -1
  433. package/dist/materializer/index.js +30 -27
  434. package/dist/materializer/index.js.map +1 -1
  435. package/dist/materializer/projections/replacement-plan.d.ts.map +1 -1
  436. package/dist/materializer/shared/normalize.d.ts.map +1 -1
  437. package/dist/materializer/telemetry/plan.d.ts.map +1 -1
  438. package/dist/models/execution/index.js +29 -26
  439. package/dist/models/execution/index.js.map +1 -1
  440. package/dist/objects/artifact-refs.d.ts +5 -0
  441. package/dist/objects/artifact-refs.d.ts.map +1 -0
  442. package/dist/objects/index.js +58 -53
  443. package/dist/objects/index.js.map +1 -1
  444. package/dist/objects/materializer-adapter.d.ts +4 -3
  445. package/dist/objects/materializer-adapter.d.ts.map +1 -1
  446. package/dist/objects/object/upsert-batch.d.ts.map +1 -1
  447. package/dist/objects/object/upsert.d.ts.map +1 -1
  448. package/dist/objects/query/index.js +28 -25
  449. package/dist/objects/query/index.js.map +1 -1
  450. package/dist/objects/query/ir.d.ts +3 -1
  451. package/dist/objects/query/ir.d.ts.map +1 -1
  452. package/dist/objects/query/scalar-values.d.ts.map +1 -1
  453. package/dist/objects/runtime-batch.d.ts +2 -0
  454. package/dist/objects/runtime-batch.d.ts.map +1 -1
  455. package/dist/ontology/artifact-ref.d.ts +36 -0
  456. package/dist/ontology/artifact-ref.d.ts.map +1 -0
  457. package/dist/ontology/docs-markdown.d.ts.map +1 -1
  458. package/dist/ontology/index.d.ts +3 -1
  459. package/dist/ontology/index.d.ts.map +1 -1
  460. package/dist/ontology/index.js +8 -5
  461. package/dist/ontology/index.js.map +1 -1
  462. package/dist/ontology/inference/index.d.ts +2 -0
  463. package/dist/ontology/inference/index.d.ts.map +1 -1
  464. package/dist/ontology/internal.js +7 -6
  465. package/dist/ontology/internal.js.map +1 -1
  466. package/dist/ontology/json-schema.d.ts.map +1 -1
  467. package/dist/ontology/primitives.d.ts.map +1 -1
  468. package/dist/ontology/reference-values.d.ts +10 -0
  469. package/dist/ontology/reference-values.d.ts.map +1 -0
  470. package/dist/ontology/refs.d.ts +6 -1
  471. package/dist/ontology/refs.d.ts.map +1 -1
  472. package/dist/ontology/registry.d.ts +9 -1
  473. package/dist/ontology/registry.d.ts.map +1 -1
  474. package/dist/ontology/types.d.ts +2 -1
  475. package/dist/ontology/types.d.ts.map +1 -1
  476. package/dist/ontology/user-ref.d.ts +16 -0
  477. package/dist/ontology/user-ref.d.ts.map +1 -1
  478. package/dist/ontology/validation/normalize.d.ts.map +1 -1
  479. package/dist/ontology/validation/properties.d.ts.map +1 -1
  480. package/dist/ontology/validation/schema.d.ts.map +1 -1
  481. package/dist/pending-tasks.d.ts +17 -0
  482. package/dist/pending-tasks.d.ts.map +1 -0
  483. package/dist/pipelines/index.js +36 -33
  484. package/dist/pipelines/index.js.map +1 -1
  485. package/dist/pipelines/run-dispatch.d.ts +6 -0
  486. package/dist/pipelines/run-dispatch.d.ts.map +1 -1
  487. package/dist/predicates/types.d.ts +4 -0
  488. package/dist/predicates/types.d.ts.map +1 -1
  489. package/dist/projections/builders.d.ts +13 -11
  490. package/dist/projections/builders.d.ts.map +1 -1
  491. package/dist/projections/internal.js +29 -26
  492. package/dist/projections/internal.js.map +1 -1
  493. package/dist/projections/types.d.ts +1 -1
  494. package/dist/projections/types.d.ts.map +1 -1
  495. package/dist/projections/validation.d.ts +2 -2
  496. package/dist/projections/validation.d.ts.map +1 -1
  497. package/dist/queues/in-memory.d.ts +6 -1
  498. package/dist/queues/in-memory.d.ts.map +1 -1
  499. package/dist/queues/index.d.ts +1 -1
  500. package/dist/queues/index.d.ts.map +1 -1
  501. package/dist/queues/index.js +1 -1
  502. package/dist/queues/types.d.ts +55 -2
  503. package/dist/queues/types.d.ts.map +1 -1
  504. package/dist/runtime/create.d.ts +3 -0
  505. package/dist/runtime/create.d.ts.map +1 -1
  506. package/dist/runtime/host.d.ts +22 -5
  507. package/dist/runtime/host.d.ts.map +1 -1
  508. package/dist/runtime/index.d.ts +0 -1
  509. package/dist/runtime/index.d.ts.map +1 -1
  510. package/dist/runtime/internal.d.ts +6 -0
  511. package/dist/runtime/internal.d.ts.map +1 -1
  512. package/dist/runtime/internal.js +51 -30
  513. package/dist/runtime/internal.js.map +1 -1
  514. package/dist/runtime/sixb.d.ts +6 -1
  515. package/dist/runtime/sixb.d.ts.map +1 -1
  516. package/dist/sandboxes/index.js +8 -7
  517. package/dist/sandboxes/index.js.map +1 -1
  518. package/dist/scheduler/index.d.ts +0 -2
  519. package/dist/scheduler/index.d.ts.map +1 -1
  520. package/dist/scheduler/index.js +3 -6
  521. package/dist/scheduler/index.js.map +1 -1
  522. package/dist/schedules/index.js +9 -11
  523. package/dist/schedules/index.js.map +1 -1
  524. package/dist/security/internal.js +1 -1
  525. package/dist/shared/backoff.d.ts +12 -0
  526. package/dist/shared/backoff.d.ts.map +1 -0
  527. package/dist/shared/duration.d.ts +3 -0
  528. package/dist/shared/duration.d.ts.map +1 -0
  529. package/dist/shared/params/artifact-refs.d.ts +19 -0
  530. package/dist/shared/params/artifact-refs.d.ts.map +1 -0
  531. package/dist/shares/guest-name.d.ts +8 -0
  532. package/dist/shares/guest-name.d.ts.map +1 -0
  533. package/dist/shares/internal.d.ts +1 -0
  534. package/dist/shares/internal.d.ts.map +1 -1
  535. package/dist/shares/internal.js +68 -27
  536. package/dist/shares/internal.js.map +3 -3
  537. package/dist/shares/session-protocol.d.ts +13 -0
  538. package/dist/shares/session-protocol.d.ts.map +1 -1
  539. package/dist/storage/action-runs/failure.js +2 -2
  540. package/dist/storage/ai-limits/enforcement.js +2 -2
  541. package/dist/storage/artifacts/errors.d.ts +9 -4
  542. package/dist/storage/artifacts/errors.d.ts.map +1 -1
  543. package/dist/storage/artifacts/in-memory.d.ts +27 -4
  544. package/dist/storage/artifacts/in-memory.d.ts.map +1 -1
  545. package/dist/storage/artifacts/index.d.ts +1 -1
  546. package/dist/storage/artifacts/index.d.ts.map +1 -1
  547. package/dist/storage/artifacts/record.d.ts +39 -2
  548. package/dist/storage/artifacts/record.d.ts.map +1 -1
  549. package/dist/storage/artifacts/types.d.ts +328 -39
  550. package/dist/storage/artifacts/types.d.ts.map +1 -1
  551. package/dist/storage/auth/in-memory/auth-storage.d.ts +2 -1
  552. package/dist/storage/auth/in-memory/auth-storage.d.ts.map +1 -1
  553. package/dist/storage/auth/in-memory/identities.d.ts +4 -0
  554. package/dist/storage/auth/in-memory/identities.d.ts.map +1 -1
  555. package/dist/storage/auth/in-memory/shared.d.ts +3 -1
  556. package/dist/storage/auth/in-memory/shared.d.ts.map +1 -1
  557. package/dist/storage/auth/in-memory/users.d.ts.map +1 -1
  558. package/dist/storage/auth/index.d.ts +1 -1
  559. package/dist/storage/auth/index.d.ts.map +1 -1
  560. package/dist/storage/auth/types.d.ts +39 -0
  561. package/dist/storage/auth/types.d.ts.map +1 -1
  562. package/dist/storage/connector-connections/in-memory.d.ts +1 -1
  563. package/dist/storage/connector-connections/in-memory.d.ts.map +1 -1
  564. package/dist/storage/connector-connections/index.d.ts +1 -1
  565. package/dist/storage/connector-connections/index.d.ts.map +1 -1
  566. package/dist/storage/connector-connections/provider/runs.d.ts.map +1 -1
  567. package/dist/storage/connector-connections/provider/shared.d.ts +12 -2
  568. package/dist/storage/connector-connections/provider/shared.d.ts.map +1 -1
  569. package/dist/storage/connector-connections/provider.d.ts +1 -0
  570. package/dist/storage/connector-connections/provider.d.ts.map +1 -1
  571. package/dist/storage/connector-connections/provider.js +21 -5
  572. package/dist/storage/connector-connections/provider.js.map +5 -5
  573. package/dist/storage/connector-connections/types.d.ts +1 -1
  574. package/dist/storage/connector-connections/types.d.ts.map +1 -1
  575. package/dist/storage/dataset-ingest/codec.d.ts +6 -0
  576. package/dist/storage/dataset-ingest/codec.d.ts.map +1 -0
  577. package/dist/storage/dataset-ingest/in-memory.d.ts +28 -0
  578. package/dist/storage/dataset-ingest/in-memory.d.ts.map +1 -0
  579. package/dist/storage/dataset-ingest/index.d.ts +4 -0
  580. package/dist/storage/dataset-ingest/index.d.ts.map +1 -0
  581. package/dist/storage/dataset-ingest/provider.d.ts +157 -0
  582. package/dist/storage/dataset-ingest/provider.d.ts.map +1 -0
  583. package/dist/storage/dataset-ingest/provider.js +17 -0
  584. package/dist/storage/dataset-ingest/provider.js.map +9 -0
  585. package/dist/storage/dataset-ingest/types.d.ts +188 -0
  586. package/dist/storage/dataset-ingest/types.d.ts.map +1 -0
  587. package/dist/storage/file-upload-sessions/provider.js +12 -11
  588. package/dist/storage/file-upload-sessions/provider.js.map +1 -1
  589. package/dist/storage/in-memory/index.d.ts +12 -0
  590. package/dist/storage/in-memory/index.d.ts.map +1 -1
  591. package/dist/storage/index.d.ts +18 -11
  592. package/dist/storage/index.d.ts.map +1 -1
  593. package/dist/storage/index.js +55 -45
  594. package/dist/storage/index.js.map +1 -1
  595. package/dist/storage/internal.d.ts +4 -1
  596. package/dist/storage/internal.d.ts.map +1 -1
  597. package/dist/storage/internal.js +81 -5
  598. package/dist/storage/internal.js.map +4 -3
  599. package/dist/storage/lake-retention-runs/in-memory.d.ts +11 -0
  600. package/dist/storage/lake-retention-runs/in-memory.d.ts.map +1 -0
  601. package/dist/storage/lake-retention-runs/index.d.ts +3 -0
  602. package/dist/storage/lake-retention-runs/index.d.ts.map +1 -0
  603. package/dist/storage/lake-retention-runs/types.d.ts +21 -0
  604. package/dist/storage/lake-retention-runs/types.d.ts.map +1 -0
  605. package/dist/storage/maintenance-heartbeats/in-memory.d.ts +11 -0
  606. package/dist/storage/maintenance-heartbeats/in-memory.d.ts.map +1 -0
  607. package/dist/storage/maintenance-heartbeats/index.d.ts +3 -0
  608. package/dist/storage/maintenance-heartbeats/index.d.ts.map +1 -0
  609. package/dist/storage/maintenance-heartbeats/record.d.ts +11 -0
  610. package/dist/storage/maintenance-heartbeats/record.d.ts.map +1 -0
  611. package/dist/storage/maintenance-heartbeats/types.d.ts +30 -0
  612. package/dist/storage/maintenance-heartbeats/types.d.ts.map +1 -0
  613. package/dist/storage/objects/in-memory/query.d.ts.map +1 -1
  614. package/dist/storage/objects/in-memory/storage.d.ts +15 -1
  615. package/dist/storage/objects/in-memory/storage.d.ts.map +1 -1
  616. package/dist/storage/objects/read-scope.d.ts.map +1 -1
  617. package/dist/storage/objects/types.d.ts +18 -1
  618. package/dist/storage/objects/types.d.ts.map +1 -1
  619. package/dist/storage/ontology/in-memory/materializations.d.ts.map +1 -1
  620. package/dist/storage/ontology/in-memory/replacement-plans.d.ts.map +1 -1
  621. package/dist/storage/ontology/index.d.ts +1 -1
  622. package/dist/storage/ontology/index.d.ts.map +1 -1
  623. package/dist/storage/ontology/materializations.d.ts +20 -0
  624. package/dist/storage/ontology/materializations.d.ts.map +1 -1
  625. package/dist/storage/ontology/provider-work.d.ts +7 -1
  626. package/dist/storage/ontology/provider-work.d.ts.map +1 -1
  627. package/dist/storage/ontology/provider.js +1 -1
  628. package/dist/storage/pipeline-runs/in-memory.d.ts +8 -2
  629. package/dist/storage/pipeline-runs/in-memory.d.ts.map +1 -1
  630. package/dist/storage/pipeline-runs/index.d.ts +1 -1
  631. package/dist/storage/pipeline-runs/index.d.ts.map +1 -1
  632. package/dist/storage/pipeline-runs/provider.js +1 -1
  633. package/dist/storage/pipeline-runs/transitions.d.ts +2 -2
  634. package/dist/storage/pipeline-runs/transitions.d.ts.map +1 -1
  635. package/dist/storage/pipeline-runs/types.d.ts +26 -6
  636. package/dist/storage/pipeline-runs/types.d.ts.map +1 -1
  637. package/dist/storage/projection-runs/errors.d.ts +6 -0
  638. package/dist/storage/projection-runs/errors.d.ts.map +1 -1
  639. package/dist/storage/projection-runs/in-memory.d.ts +5 -1
  640. package/dist/storage/projection-runs/in-memory.d.ts.map +1 -1
  641. package/dist/storage/projection-runs/index.d.ts +2 -2
  642. package/dist/storage/projection-runs/index.d.ts.map +1 -1
  643. package/dist/storage/projection-runs/lifecycle.d.ts +1 -0
  644. package/dist/storage/projection-runs/lifecycle.d.ts.map +1 -1
  645. package/dist/storage/projection-runs/provider.js +2 -2
  646. package/dist/storage/projection-runs/types.d.ts +16 -0
  647. package/dist/storage/projection-runs/types.d.ts.map +1 -1
  648. package/dist/storage/run-claim.d.ts +132 -0
  649. package/dist/storage/run-claim.d.ts.map +1 -0
  650. package/dist/storage/share-grants/provider.js +3 -3
  651. package/dist/storage/share-sessions/in-memory.d.ts +2 -1
  652. package/dist/storage/share-sessions/in-memory.d.ts.map +1 -1
  653. package/dist/storage/share-sessions/index.d.ts +1 -1
  654. package/dist/storage/share-sessions/index.d.ts.map +1 -1
  655. package/dist/storage/share-sessions/provider.d.ts +1 -1
  656. package/dist/storage/share-sessions/provider.d.ts.map +1 -1
  657. package/dist/storage/share-sessions/provider.js +4 -2
  658. package/dist/storage/share-sessions/provider.js.map +1 -1
  659. package/dist/storage/share-sessions/record.d.ts +2 -1
  660. package/dist/storage/share-sessions/record.d.ts.map +1 -1
  661. package/dist/storage/share-sessions/types.d.ts +17 -1
  662. package/dist/storage/share-sessions/types.d.ts.map +1 -1
  663. package/dist/storage/sync-runs/in-memory.d.ts +10 -2
  664. package/dist/storage/sync-runs/in-memory.d.ts.map +1 -1
  665. package/dist/storage/sync-runs/index.d.ts +1 -1
  666. package/dist/storage/sync-runs/index.d.ts.map +1 -1
  667. package/dist/storage/sync-runs/transitions.d.ts +2 -2
  668. package/dist/storage/sync-runs/transitions.d.ts.map +1 -1
  669. package/dist/storage/sync-runs/types.d.ts +29 -3
  670. package/dist/storage/sync-runs/types.d.ts.map +1 -1
  671. package/dist/storage/types.d.ts +12 -6
  672. package/dist/storage/types.d.ts.map +1 -1
  673. package/dist/storage/webhook-runs/in-memory.d.ts +2 -1
  674. package/dist/storage/webhook-runs/in-memory.d.ts.map +1 -1
  675. package/dist/storage/webhook-runs/index.d.ts +2 -2
  676. package/dist/storage/webhook-runs/index.d.ts.map +1 -1
  677. package/dist/storage/webhook-runs/types.d.ts +33 -2
  678. package/dist/storage/webhook-runs/types.d.ts.map +1 -1
  679. package/dist/storage/workflow-runs/in-memory.d.ts +6 -3
  680. package/dist/storage/workflow-runs/in-memory.d.ts.map +1 -1
  681. package/dist/storage/workflow-runs/index.d.ts +1 -1
  682. package/dist/storage/workflow-runs/index.d.ts.map +1 -1
  683. package/dist/storage/workflow-runs/provider.js +12 -11
  684. package/dist/storage/workflow-runs/provider.js.map +1 -1
  685. package/dist/storage/workflow-runs/types.d.ts +11 -28
  686. package/dist/storage/workflow-runs/types.d.ts.map +1 -1
  687. package/dist/syncs/index.js +37 -34
  688. package/dist/syncs/index.js.map +1 -1
  689. package/dist/syncs/run-dispatch.d.ts +2 -0
  690. package/dist/syncs/run-dispatch.d.ts.map +1 -1
  691. package/dist/testing/ai-model-call-groups-contract.d.ts.map +1 -1
  692. package/dist/testing/artifact-holders-contract.d.ts +15 -0
  693. package/dist/testing/artifact-holders-contract.d.ts.map +1 -0
  694. package/dist/testing/artifact-storage-contract.d.ts.map +1 -1
  695. package/dist/testing/auth-storage-contract.d.ts.map +1 -1
  696. package/dist/testing/broker-contract.d.ts.map +1 -1
  697. package/dist/testing/connector-connection-storage-contract.d.ts +1 -1
  698. package/dist/testing/connector-connection-storage-contract.d.ts.map +1 -1
  699. package/dist/testing/dataset-ingest-storage-contract.d.ts +11 -0
  700. package/dist/testing/dataset-ingest-storage-contract.d.ts.map +1 -0
  701. package/dist/testing/dataset-sequence-contract.d.ts +1 -1
  702. package/dist/testing/dataset-sequence-contract.d.ts.map +1 -1
  703. package/dist/testing/execution.d.ts.map +1 -1
  704. package/dist/testing/index.d.ts +8 -0
  705. package/dist/testing/index.d.ts.map +1 -1
  706. package/dist/testing/index.js +6244 -3191
  707. package/dist/testing/index.js.map +28 -19
  708. package/dist/testing/lake-retention-run-storage-contract.d.ts +9 -0
  709. package/dist/testing/lake-retention-run-storage-contract.d.ts.map +1 -0
  710. package/dist/testing/maintenance-heartbeat-storage-contract.d.ts +9 -0
  711. package/dist/testing/maintenance-heartbeat-storage-contract.d.ts.map +1 -0
  712. package/dist/testing/object-query-contract.d.ts.map +1 -1
  713. package/dist/testing/pipeline-execution.d.ts.map +1 -1
  714. package/dist/testing/pipeline-run-read-contract.d.ts +13 -0
  715. package/dist/testing/pipeline-run-read-contract.d.ts.map +1 -0
  716. package/dist/testing/projection-run-storage-contract.d.ts.map +1 -1
  717. package/dist/testing/queues-contract.d.ts.map +1 -1
  718. package/dist/testing/run-claim-storage-contract.d.ts +12 -0
  719. package/dist/testing/run-claim-storage-contract.d.ts.map +1 -0
  720. package/dist/testing/run-claim.d.ts +30 -0
  721. package/dist/testing/run-claim.d.ts.map +1 -0
  722. package/dist/testing/run-recovery-contract.d.ts +49 -0
  723. package/dist/testing/run-recovery-contract.d.ts.map +1 -0
  724. package/dist/testing/share-session-storage-contract.d.ts.map +1 -1
  725. package/dist/testing/stored-artifacts.d.ts +10 -0
  726. package/dist/testing/stored-artifacts.d.ts.map +1 -0
  727. package/dist/testing/sync-execution.d.ts.map +1 -1
  728. package/dist/testing/webhook-execution.d.ts +1 -1
  729. package/dist/testing/webhook-execution.d.ts.map +1 -1
  730. package/dist/testing/webhook-run-storage-contract.d.ts.map +1 -1
  731. package/dist/users/execution.d.ts +18 -1
  732. package/dist/users/execution.d.ts.map +1 -1
  733. package/dist/users/index.d.ts +1 -1
  734. package/dist/users/index.d.ts.map +1 -1
  735. package/dist/webhooks/delivery-lease.d.ts +13 -0
  736. package/dist/webhooks/delivery-lease.d.ts.map +1 -0
  737. package/dist/webhooks/internal.d.ts +2 -0
  738. package/dist/webhooks/internal.d.ts.map +1 -1
  739. package/dist/webhooks/internal.js +67 -35
  740. package/dist/webhooks/internal.js.map +5 -4
  741. package/dist/webhooks/run-admission.d.ts.map +1 -1
  742. package/dist/workers/index.d.ts +5 -1
  743. package/dist/workers/index.d.ts.map +1 -1
  744. package/dist/workers/index.js +193 -58
  745. package/dist/workers/index.js.map +8 -7
  746. package/dist/workers/job-ids.d.ts +17 -0
  747. package/dist/workers/job-ids.d.ts.map +1 -0
  748. package/dist/workers/lost-projection-runs.d.ts +26 -0
  749. package/dist/workers/lost-projection-runs.d.ts.map +1 -0
  750. package/dist/workers/lost-runs.d.ts +51 -0
  751. package/dist/workers/lost-runs.d.ts.map +1 -0
  752. package/dist/workers/queue-delivery.d.ts.map +1 -1
  753. package/dist/workers/queue-worker.d.ts +1 -2
  754. package/dist/workers/queue-worker.d.ts.map +1 -1
  755. package/dist/workers/queued-run-dispatch.d.ts +90 -0
  756. package/dist/workers/queued-run-dispatch.d.ts.map +1 -0
  757. package/dist/workers/run-lease.d.ts +25 -0
  758. package/dist/workers/run-lease.d.ts.map +1 -0
  759. package/dist/workers/run-worker.d.ts +95 -0
  760. package/dist/workers/run-worker.d.ts.map +1 -0
  761. package/dist/workflows/index.js +63 -57
  762. package/dist/workflows/index.js.map +1 -1
  763. package/dist/workflows/request.d.ts.map +1 -1
  764. package/dist/workflows/run-dispatch.d.ts +6 -1
  765. package/dist/workflows/run-dispatch.d.ts.map +1 -1
  766. package/package.json +41 -3
  767. package/src/actions/request.ts +24 -7
  768. package/src/actions/run/executor.ts +9 -42
  769. package/src/actions/types/context.ts +8 -3
  770. package/src/agents/execution.ts +10 -2
  771. package/src/agents/fork.ts +12 -4
  772. package/src/agents/index.ts +7 -1
  773. package/src/agents/request.ts +42 -31
  774. package/src/agents/run-artifacts.ts +290 -46
  775. package/src/agents/run-session-http.ts +4 -0
  776. package/src/agents/run-session-serve.ts +10 -0
  777. package/src/agents/run-session.ts +8 -1
  778. package/src/agents/streams/protocol.ts +5 -10
  779. package/src/agents/validation.ts +3 -0
  780. package/src/artifacts/access.ts +71 -28
  781. package/src/artifacts/canvas-display.ts +160 -0
  782. package/src/artifacts/canvas.ts +26 -1
  783. package/src/artifacts/comment-text.ts +32 -0
  784. package/src/artifacts/comments.ts +275 -0
  785. package/src/artifacts/errors.ts +6 -1
  786. package/src/artifacts/events.ts +58 -0
  787. package/src/artifacts/execution.ts +496 -53
  788. package/src/artifacts/frames/assets.ts +20 -1
  789. package/src/artifacts/frames/grants.ts +31 -10
  790. package/src/artifacts/frames/index.ts +2 -0
  791. package/src/artifacts/frames/kit.ts +8 -5
  792. package/src/artifacts/frames/protocol.ts +149 -0
  793. package/src/artifacts/frames/runtime.ts +317 -29
  794. package/src/artifacts/holders.ts +120 -0
  795. package/src/artifacts/ids.ts +8 -0
  796. package/src/artifacts/index.ts +28 -2
  797. package/src/artifacts/limits.ts +28 -4
  798. package/src/artifacts/live/board.ts +759 -0
  799. package/src/artifacts/live/diff.ts +297 -0
  800. package/src/artifacts/live/document.ts +354 -0
  801. package/src/artifacts/live/files.ts +82 -0
  802. package/src/artifacts/live/index.ts +50 -0
  803. package/src/artifacts/live/presence.ts +144 -0
  804. package/src/artifacts/live/protocol.ts +134 -0
  805. package/src/artifacts/live/server.ts +16 -0
  806. package/src/artifacts/live/state.ts +115 -0
  807. package/src/artifacts/outline.ts +12 -0
  808. package/src/artifacts/publish/index.ts +26 -1
  809. package/src/artifacts/publish/merge.ts +271 -0
  810. package/src/artifacts/publish/previews.ts +485 -0
  811. package/src/artifacts/publish/publish.ts +92 -39
  812. package/src/artifacts/publish/query-answers.ts +85 -0
  813. package/src/artifacts/publish/references.ts +10 -4
  814. package/src/artifacts/publish/validate/canvas.ts +133 -1
  815. package/src/artifacts/theme.ts +9 -1
  816. package/src/auth/directory.ts +166 -0
  817. package/src/auth/member-events.ts +10 -3
  818. package/src/auth/runtime.ts +108 -8
  819. package/src/auth/strategy.ts +3 -1
  820. package/src/auth/types.ts +44 -0
  821. package/src/authorization/decision.ts +6 -5
  822. package/src/authorization/event-visibility.ts +4 -0
  823. package/src/broker/in-memory.ts +33 -6
  824. package/src/broker/types.ts +4 -0
  825. package/src/connectors/builders.ts +34 -2
  826. package/src/connectors/connections/access.ts +83 -0
  827. package/src/connectors/connections/contracts.ts +6 -1
  828. package/src/connectors/connections/execution.ts +2 -2
  829. package/src/connectors/connections/runs.ts +51 -2
  830. package/src/connectors/connections/service.ts +208 -41
  831. package/src/connectors/connections/views.ts +11 -4
  832. package/src/connectors/execution.ts +27 -3
  833. package/src/connectors/index.ts +2 -0
  834. package/src/connectors/service.ts +12 -0
  835. package/src/connectors/types.ts +37 -2
  836. package/src/datasets/execution.ts +74 -37
  837. package/src/datasets/ingest-flush-batch.ts +289 -0
  838. package/src/datasets/ingest-flush-job.ts +112 -0
  839. package/src/datasets/ingest-flush.ts +377 -0
  840. package/src/datasets/produced-version.ts +55 -0
  841. package/src/datasets/write.ts +65 -11
  842. package/src/deploy/services.ts +1 -1
  843. package/src/deploy/types.ts +2 -3
  844. package/src/deploy/validation.ts +1 -0
  845. package/src/error-reporting/capability.ts +66 -0
  846. package/src/error-reporting/internal.ts +12 -0
  847. package/src/error-reporting/reporter.ts +11 -35
  848. package/src/error-reporting/reports.ts +167 -0
  849. package/src/error-reporting/types.ts +99 -0
  850. package/src/errors/catalog.ts +6 -0
  851. package/src/events/definitions.ts +14 -0
  852. package/src/events/execution.ts +77 -28
  853. package/src/events/index.ts +3 -0
  854. package/src/events/scope.ts +2 -0
  855. package/src/events/types/artifacts.ts +40 -0
  856. package/src/events/types/index.ts +3 -0
  857. package/src/events/types/users.ts +5 -2
  858. package/src/execution/authorized-object-reader.ts +34 -0
  859. package/src/execution/object-reader-clearance.ts +31 -0
  860. package/src/execution/object-reader-security.ts +33 -13
  861. package/src/http/api-routes.ts +105 -4
  862. package/src/index.ts +22 -4
  863. package/src/lake-storage/errors.ts +21 -0
  864. package/src/lake-storage/index.ts +9 -1
  865. package/src/lake-storage/maintenance.ts +93 -0
  866. package/src/lake-storage/merge.ts +3 -1
  867. package/src/lake-storage/source-ordering.ts +28 -2
  868. package/src/lake-storage/types.ts +14 -0
  869. package/src/maintenance/heartbeat.ts +14 -0
  870. package/src/maintenance/index.ts +5 -3
  871. package/src/maintenance/lake-retention-status.ts +81 -0
  872. package/src/maintenance/lake-retention.ts +347 -0
  873. package/src/maintenance/loop.ts +365 -0
  874. package/src/maintenance/ontology-maintenance.ts +76 -229
  875. package/src/maintenance/passes/cron-pass.ts +217 -0
  876. package/src/maintenance/passes/directory-pass.ts +22 -0
  877. package/src/maintenance/passes/ingest-pass.ts +94 -0
  878. package/src/maintenance/passes/lake-change-feed.ts +112 -0
  879. package/src/maintenance/passes/lake-retention-pass.ts +71 -0
  880. package/src/maintenance/passes/ontology-pass.ts +19 -0
  881. package/src/maintenance/passes/projections-pass.ts +238 -0
  882. package/src/maintenance/passes/recovery-pass.ts +17 -0
  883. package/src/maintenance/passes/recovery-passes.ts +39 -0
  884. package/src/maintenance/passes/runs-pass.ts +12 -0
  885. package/src/maintenance/passes/triggers-pass.ts +332 -0
  886. package/src/maintenance/status.ts +75 -0
  887. package/src/maintenance/types.ts +27 -25
  888. package/src/materialization/model.ts +33 -21
  889. package/src/materializer/README.md +13 -2
  890. package/src/materializer/edits/artifact-refs.ts +140 -0
  891. package/src/materializer/edits/commit.ts +20 -7
  892. package/src/materializer/edits/operations.ts +23 -7
  893. package/src/materializer/edits/plan.ts +2 -0
  894. package/src/materializer/execution/work-records.ts +61 -0
  895. package/src/materializer/projections/replacement-plan.ts +2 -0
  896. package/src/materializer/shared/normalize.ts +14 -0
  897. package/src/materializer/telemetry/plan.ts +2 -0
  898. package/src/objects/artifact-refs.ts +34 -0
  899. package/src/objects/materializer-adapter.ts +8 -3
  900. package/src/objects/object/upsert-batch.ts +7 -0
  901. package/src/objects/object/upsert.ts +11 -2
  902. package/src/objects/query/ir.ts +2 -0
  903. package/src/objects/query/scalar-values.ts +5 -3
  904. package/src/objects/runtime-batch.ts +8 -1
  905. package/src/objects/vectors/README.md +4 -4
  906. package/src/ontology/artifact-ref.ts +83 -0
  907. package/src/ontology/docs-markdown.ts +17 -0
  908. package/src/ontology/index.ts +3 -1
  909. package/src/ontology/inference/index.ts +2 -0
  910. package/src/ontology/json-schema.ts +13 -0
  911. package/src/ontology/primitives.ts +14 -0
  912. package/src/ontology/reference-values.ts +62 -0
  913. package/src/ontology/refs.ts +7 -1
  914. package/src/ontology/registry.ts +26 -1
  915. package/src/ontology/types.ts +2 -0
  916. package/src/ontology/user-ref.ts +35 -45
  917. package/src/ontology/validation/normalize.ts +13 -0
  918. package/src/ontology/validation/properties.ts +9 -0
  919. package/src/ontology/validation/schema.ts +12 -0
  920. package/src/pending-tasks.ts +51 -0
  921. package/src/pipelines/run-dispatch.ts +120 -238
  922. package/src/predicates/types.ts +2 -1
  923. package/src/projections/builders.ts +28 -13
  924. package/src/projections/run-dispatch.ts +1 -1
  925. package/src/projections/types.ts +1 -1
  926. package/src/projections/validation.ts +22 -8
  927. package/src/queues/in-memory.ts +50 -3
  928. package/src/queues/index.ts +4 -0
  929. package/src/queues/types.ts +68 -1
  930. package/src/runtime/create.ts +4 -0
  931. package/src/runtime/host.ts +118 -13
  932. package/src/runtime/index.ts +0 -1
  933. package/src/runtime/internal.ts +13 -0
  934. package/src/runtime/ontology-mutations.ts +1 -1
  935. package/src/runtime/sixb.ts +14 -5
  936. package/src/scheduler/index.ts +0 -2
  937. package/src/shared/backoff.ts +34 -0
  938. package/src/shared/duration.ts +15 -0
  939. package/src/shared/params/artifact-refs.ts +42 -0
  940. package/src/shares/compiler.ts +1 -1
  941. package/src/shares/guest-name.ts +20 -0
  942. package/src/shares/internal.ts +1 -0
  943. package/src/shares/session-protocol.ts +63 -0
  944. package/src/storage/artifacts/errors.ts +10 -2
  945. package/src/storage/artifacts/in-memory.ts +579 -96
  946. package/src/storage/artifacts/index.ts +22 -1
  947. package/src/storage/artifacts/record.ts +255 -11
  948. package/src/storage/artifacts/types.ts +343 -40
  949. package/src/storage/auth/in-memory/auth-storage.ts +42 -5
  950. package/src/storage/auth/in-memory/identities.ts +16 -0
  951. package/src/storage/auth/in-memory/shared.ts +15 -0
  952. package/src/storage/auth/in-memory/users.ts +17 -16
  953. package/src/storage/auth/index.ts +3 -0
  954. package/src/storage/auth/types.ts +38 -0
  955. package/src/storage/connector-connections/in-memory.ts +4 -1
  956. package/src/storage/connector-connections/index.ts +1 -0
  957. package/src/storage/connector-connections/provider/runs.ts +3 -0
  958. package/src/storage/connector-connections/provider/shared.ts +30 -0
  959. package/src/storage/connector-connections/provider.ts +4 -0
  960. package/src/storage/connector-connections/types.ts +1 -0
  961. package/src/storage/dataset-ingest/codec.ts +90 -0
  962. package/src/storage/dataset-ingest/in-memory.ts +277 -0
  963. package/src/storage/dataset-ingest/index.ts +16 -0
  964. package/src/storage/dataset-ingest/provider.ts +592 -0
  965. package/src/storage/dataset-ingest/types.ts +191 -0
  966. package/src/storage/in-memory/index.ts +33 -0
  967. package/src/storage/index.ts +65 -5
  968. package/src/storage/internal.ts +20 -0
  969. package/src/storage/lake-retention-runs/in-memory.ts +22 -0
  970. package/src/storage/lake-retention-runs/index.ts +2 -0
  971. package/src/storage/lake-retention-runs/types.ts +19 -0
  972. package/src/storage/maintenance-heartbeats/in-memory.ts +24 -0
  973. package/src/storage/maintenance-heartbeats/index.ts +7 -0
  974. package/src/storage/maintenance-heartbeats/record.ts +50 -0
  975. package/src/storage/maintenance-heartbeats/types.ts +30 -0
  976. package/src/storage/objects/in-memory/query.ts +1 -0
  977. package/src/storage/objects/in-memory/storage.ts +81 -0
  978. package/src/storage/objects/read-scope.ts +1 -0
  979. package/src/storage/objects/types.ts +16 -1
  980. package/src/storage/ontology/in-memory/materializations.ts +8 -0
  981. package/src/storage/ontology/in-memory/replacement-plans.ts +4 -1
  982. package/src/storage/ontology/index.ts +2 -0
  983. package/src/storage/ontology/materializations.ts +18 -0
  984. package/src/storage/ontology/provider-work.ts +39 -0
  985. package/src/storage/pipeline-runs/in-memory.ts +97 -24
  986. package/src/storage/pipeline-runs/index.ts +0 -1
  987. package/src/storage/pipeline-runs/provider.ts +1 -1
  988. package/src/storage/pipeline-runs/transitions.ts +7 -4
  989. package/src/storage/pipeline-runs/types.ts +33 -7
  990. package/src/storage/projection-runs/errors.ts +10 -0
  991. package/src/storage/projection-runs/in-memory.ts +56 -1
  992. package/src/storage/projection-runs/index.ts +2 -1
  993. package/src/storage/projection-runs/lifecycle.ts +9 -1
  994. package/src/storage/projection-runs/types.ts +20 -1
  995. package/src/storage/run-claim.ts +224 -0
  996. package/src/storage/share-sessions/in-memory.ts +21 -0
  997. package/src/storage/share-sessions/index.ts +1 -0
  998. package/src/storage/share-sessions/provider.ts +1 -0
  999. package/src/storage/share-sessions/record.ts +28 -0
  1000. package/src/storage/share-sessions/types.ts +19 -1
  1001. package/src/storage/sync-runs/in-memory.ts +109 -29
  1002. package/src/storage/sync-runs/index.ts +1 -1
  1003. package/src/storage/sync-runs/transitions.ts +7 -4
  1004. package/src/storage/sync-runs/types.ts +36 -3
  1005. package/src/storage/types.ts +15 -5
  1006. package/src/storage/webhook-runs/in-memory.ts +26 -2
  1007. package/src/storage/webhook-runs/index.ts +3 -1
  1008. package/src/storage/webhook-runs/types.ts +44 -3
  1009. package/src/storage/workflow-runs/in-memory.ts +50 -36
  1010. package/src/storage/workflow-runs/index.ts +0 -2
  1011. package/src/storage/workflow-runs/types.ts +18 -30
  1012. package/src/syncs/run-dispatch.ts +118 -239
  1013. package/src/testing/ai-model-call-groups-contract.ts +2 -1
  1014. package/src/testing/artifact-holders-contract.ts +392 -0
  1015. package/src/testing/artifact-storage-contract.ts +1205 -151
  1016. package/src/testing/auth-storage-contract.ts +228 -1
  1017. package/src/testing/broker-contract.ts +56 -0
  1018. package/src/testing/connector-connection-storage-contract.ts +94 -5
  1019. package/src/testing/dataset-ingest-storage-contract.ts +480 -0
  1020. package/src/testing/dataset-sequence-contract.ts +97 -12
  1021. package/src/testing/execution.ts +23 -0
  1022. package/src/testing/index.ts +31 -0
  1023. package/src/testing/lake-retention-run-storage-contract.ts +75 -0
  1024. package/src/testing/maintenance-heartbeat-storage-contract.ts +99 -0
  1025. package/src/testing/object-query-contract.ts +93 -0
  1026. package/src/testing/pipeline-execution.ts +3 -1
  1027. package/src/testing/pipeline-run-read-contract.ts +123 -0
  1028. package/src/testing/projection-run-storage-contract.ts +113 -0
  1029. package/src/testing/queues-contract.ts +112 -0
  1030. package/src/testing/run-claim-storage-contract.ts +736 -0
  1031. package/src/testing/run-claim.ts +69 -0
  1032. package/src/testing/run-recovery-contract.ts +176 -0
  1033. package/src/testing/share-session-storage-contract.ts +43 -0
  1034. package/src/testing/stored-artifacts.ts +43 -0
  1035. package/src/testing/sync-execution.ts +3 -1
  1036. package/src/testing/webhook-execution.ts +7 -2
  1037. package/src/testing/webhook-run-storage-contract.ts +102 -5
  1038. package/src/users/execution.ts +50 -2
  1039. package/src/users/index.ts +1 -0
  1040. package/src/webhooks/delivery-lease.ts +40 -0
  1041. package/src/webhooks/internal.ts +2 -0
  1042. package/src/webhooks/run-admission.ts +22 -9
  1043. package/src/workers/README.md +169 -0
  1044. package/src/workers/index.ts +9 -1
  1045. package/src/workers/job-ids.ts +31 -0
  1046. package/src/workers/lost-projection-runs.ts +114 -0
  1047. package/src/workers/lost-runs.ts +397 -0
  1048. package/src/workers/queue-delivery.ts +2 -14
  1049. package/src/workers/queue-worker.ts +9 -17
  1050. package/src/workers/queued-run-dispatch.ts +308 -0
  1051. package/src/workers/run-lease.ts +46 -0
  1052. package/src/workers/run-worker.ts +312 -0
  1053. package/src/workers/worker.ts +4 -17
  1054. package/src/workflows/request.ts +2 -0
  1055. package/src/workflows/run-dispatch.ts +22 -4
  1056. package/src/workflows/snapshot.ts +1 -0
  1057. package/dist/chunk-2g0r46hy.js.map +0 -12
  1058. package/dist/chunk-3fqxbn31.js +0 -107
  1059. package/dist/chunk-3fqxbn31.js.map +0 -11
  1060. package/dist/chunk-4s753g3k.js +0 -314
  1061. package/dist/chunk-4s753g3k.js.map +0 -12
  1062. package/dist/chunk-5kyvrtjh.js.map +0 -12
  1063. package/dist/chunk-5taem5aw.js.map +0 -10
  1064. package/dist/chunk-65abf64x.js +0 -13
  1065. package/dist/chunk-65abf64x.js.map +0 -10
  1066. package/dist/chunk-9x8dybsb.js.map +0 -10
  1067. package/dist/chunk-az47zep4.js +0 -41
  1068. package/dist/chunk-az47zep4.js.map +0 -10
  1069. package/dist/chunk-c706qvyc.js +0 -299
  1070. package/dist/chunk-c706qvyc.js.map +0 -11
  1071. package/dist/chunk-djs3hw9p.js.map +0 -20
  1072. package/dist/chunk-e5wf5vz0.js.map +0 -10
  1073. package/dist/chunk-e6xgz4h4.js.map +0 -21
  1074. package/dist/chunk-e7v3trpz.js.map +0 -10
  1075. package/dist/chunk-eqgr6nsa.js.map +0 -72
  1076. package/dist/chunk-fb3feg1e.js +0 -298
  1077. package/dist/chunk-fb3feg1e.js.map +0 -12
  1078. package/dist/chunk-hz5d43gn.js.map +0 -10
  1079. package/dist/chunk-j8thxj7w.js.map +0 -22
  1080. package/dist/chunk-jbw70d6t.js.map +0 -10
  1081. package/dist/chunk-jftd33rc.js.map +0 -11
  1082. package/dist/chunk-jspskey0.js.map +0 -10
  1083. package/dist/chunk-kfee1h52.js.map +0 -13
  1084. package/dist/chunk-kwfhd1g0.js +0 -144
  1085. package/dist/chunk-kwfhd1g0.js.map +0 -13
  1086. package/dist/chunk-nz7815t3.js.map +0 -14
  1087. package/dist/chunk-s3we74h8.js.map +0 -12
  1088. package/dist/chunk-scyq22td.js.map +0 -12
  1089. package/dist/chunk-w1btn96n.js.map +0 -44
  1090. package/dist/chunk-w976a4me.js.map +0 -10
  1091. package/dist/chunk-wkq3kvzd.js.map +0 -10
  1092. package/dist/chunk-wrjx1fqz.js +0 -587
  1093. package/dist/chunk-wrjx1fqz.js.map +0 -18
  1094. package/dist/chunk-yw9pyg66.js +0 -143
  1095. package/dist/chunk-yw9pyg66.js.map +0 -11
  1096. package/dist/chunk-z8fx5cgb.js.map +0 -11
  1097. package/dist/scheduler/runtime.d.ts +0 -40
  1098. package/dist/scheduler/runtime.d.ts.map +0 -1
  1099. package/dist/workers/unstarted-run.d.ts +0 -10
  1100. package/dist/workers/unstarted-run.d.ts.map +0 -1
  1101. package/src/scheduler/runtime.ts +0 -214
  1102. package/src/workers/unstarted-run.ts +0 -18
  1103. /package/dist/{chunk-80gym75n.js.map → chunk-186k5yz3.js.map} +0 -0
  1104. /package/dist/{chunk-ytzcxtpt.js.map → chunk-3ba89vm7.js.map} +0 -0
  1105. /package/dist/{chunk-d04g36fw.js.map → chunk-5qqmndhm.js.map} +0 -0
  1106. /package/dist/{chunk-5wtnmpze.js.map → chunk-7qe46788.js.map} +0 -0
  1107. /package/dist/{chunk-31kcqmhf.js.map → chunk-855w9nvw.js.map} +0 -0
  1108. /package/dist/{chunk-2ajw5rz0.js.map → chunk-8p7bze4c.js.map} +0 -0
  1109. /package/dist/{chunk-9whfmsfk.js.map → chunk-8tqnsx3q.js.map} +0 -0
  1110. /package/dist/{chunk-s038wa5v.js.map → chunk-b9qfh2ya.js.map} +0 -0
  1111. /package/dist/{chunk-jjmggm9a.js.map → chunk-fe6r7yhg.js.map} +0 -0
  1112. /package/dist/{chunk-165c9wm6.js.map → chunk-g2ph4873.js.map} +0 -0
  1113. /package/dist/{chunk-ga63a3dz.js.map → chunk-k66rp2hr.js.map} +0 -0
  1114. /package/dist/{chunk-4zm1k3xj.js.map → chunk-r2psmn42.js.map} +0 -0
  1115. /package/dist/{chunk-r1cxq7vv.js.map → chunk-rtdrm592.js.map} +0 -0
  1116. /package/dist/{chunk-4bm0caep.js.map → chunk-smnt672s.js.map} +0 -0
  1117. /package/dist/{chunk-21q0j5f2.js.map → chunk-stmxh0hv.js.map} +0 -0
  1118. /package/dist/{chunk-ff5xkv0p.js.map → chunk-tfzvjdms.js.map} +0 -0
  1119. /package/dist/{chunk-6b61s40c.js.map → chunk-w3t94hm6.js.map} +0 -0
@@ -1,14 +1,21 @@
1
1
  import { describe, expect, test } from "bun:test"
2
- import { ARTIFACT_STATE_LIMITS } from "../artifacts/limits"
2
+ import {
3
+ ARTIFACT_COMMENT_LIMITS,
4
+ ARTIFACT_RESTORE_POINTS,
5
+ ARTIFACT_STATE_LIMITS,
6
+ } from "../artifacts/limits"
3
7
  import type { Principal } from "../auth"
4
8
  import type { FileRef } from "../blob-storage"
5
9
  import {
10
+ type ArtifactCommentAuthor,
6
11
  type ArtifactFrameGrantRecord,
7
12
  type ArtifactStorage,
8
13
  ArtifactStorageError,
9
14
  type ArtifactStorageErrorCode,
10
15
  type ArtifactVersionInput,
16
+ type CreateArtifactCommentInput,
11
17
  type CreateArtifactInput,
18
+ type PublishArtifactVersionInput,
12
19
  } from "../storage/artifacts"
13
20
  import type { Storage } from "../storage/types"
14
21
 
@@ -49,7 +56,7 @@ export function runArtifactStorageContractSuite<TStorage extends ArtifactStorage
49
56
  }
50
57
 
51
58
  describe(label, () => {
52
- test("creates an artifact with its first version and reads both back", async () => {
59
+ test("creates an artifact with its first version, open, and reads both back", async () => {
53
60
  await withStorage(async (artifacts) => {
54
61
  const created = await artifacts.create(createInput())
55
62
 
@@ -60,6 +67,7 @@ export function runArtifactStorageContractSuite<TStorage extends ArtifactStorage
60
67
  title: "Q3 report",
61
68
  owner,
62
69
  latestVersion: 1,
70
+ revision: 1,
63
71
  createdAt: t0,
64
72
  updatedAt: t0,
65
73
  })
@@ -67,8 +75,11 @@ export function runArtifactStorageContractSuite<TStorage extends ArtifactStorage
67
75
  projectId,
68
76
  artifactId: "art_report",
69
77
  version: 1,
78
+ revision: 1,
70
79
  ...versionInput(),
80
+ createdAt: t0,
71
81
  })
82
+ expect(created.version).not.toHaveProperty("frozenAt")
72
83
  expect(await artifacts.get({ projectId, id: "art_report" })).toEqual(created.artifact)
73
84
  expect(
74
85
  await artifacts.getVersion({ projectId, artifactId: "art_report", version: 1 })
@@ -85,23 +96,119 @@ export function runArtifactStorageContractSuite<TStorage extends ArtifactStorage
85
96
  })
86
97
  })
87
98
 
88
- test("numbers versions in order and makes the newest the latest", async () => {
99
+ // Regression proof: append a version on every write in a provider's `publish`; the second
100
+ // write is then version 2.
101
+ test("replaces the open version's content in place, one revision at a time", async () => {
89
102
  await withStorage(async (artifacts) => {
90
103
  await artifacts.create(createInput())
91
104
  const second = await artifacts.publish(
92
- publishInput({ title: "Q3 report, revised", createdAt: at(1) })
105
+ publishInput({ title: "Q3 report, revised", author: otherOwner, updatedAt: at(1) })
93
106
  )
94
- const third = await artifacts.publish(publishInput({ createdAt: at(2) }))
107
+ const third = await artifacts.publish(publishInput({ origin: undefined, updatedAt: at(2) }))
95
108
 
96
- expect(second.version.version).toBe(2)
97
- expect(third.version.version).toBe(3)
98
- expect(third.artifact).toMatchObject({ latestVersion: 3, updatedAt: at(2), createdAt: t0 })
99
- expect(second.artifact.title).toBe("Q3 report, revised")
100
- expect((await artifacts.get({ projectId, id: "art_report" }))?.title).toBe("Q3 report")
109
+ expect(second.version).toMatchObject({
110
+ version: 1,
111
+ revision: 2,
112
+ title: "Q3 report, revised",
113
+ author: otherOwner,
114
+ createdAt: t0,
115
+ updatedAt: at(1),
116
+ })
117
+ expect(third.artifact).toMatchObject({
118
+ latestVersion: 1,
119
+ revision: 3,
120
+ title: "Q3 report",
121
+ createdAt: t0,
122
+ updatedAt: at(2),
123
+ })
124
+ // The last write's author and origin are the version's: it had none.
125
+ expect(third.version).toMatchObject({ version: 1, revision: 3, author: owner })
126
+ expect(third.version).not.toHaveProperty("origin")
127
+ expect(
128
+ await artifacts.getVersion({ projectId, artifactId: "art_report", version: 1 })
129
+ ).toEqual(third.version)
130
+ expect((await artifacts.listVersions({ projectId, artifactId: "art_report" })).total).toBe(
131
+ 1
132
+ )
101
133
  })
102
134
  })
103
135
 
104
- test("keeps the kind fixed and refuses versions for a missing artifact", async () => {
136
+ // Regression proof: write in place whatever the latest version is in a provider's `publish`;
137
+ // the frozen version then changes.
138
+ test("freezes the latest version, and the next write opens the next one", async () => {
139
+ await withStorage(async (artifacts) => {
140
+ await artifacts.create(createInput())
141
+ const frozen = await artifacts.freeze({
142
+ projectId,
143
+ artifactId: "art_report",
144
+ baseRevision: 1,
145
+ frozenAt: at(1),
146
+ frozenBy: otherOwner,
147
+ })
148
+ expect(frozen.artifact).toMatchObject({ latestVersion: 1, revision: 2, updatedAt: at(1) })
149
+ // Who froze it is kept beside who wrote it.
150
+ expect(frozen.version).toMatchObject({
151
+ version: 1,
152
+ revision: 2,
153
+ author: owner,
154
+ frozenAt: at(1),
155
+ frozenBy: otherOwner,
156
+ })
157
+
158
+ // A write made before the freeze is told who created the version since.
159
+ // Reproduce by leaving `frozenBy` out of a provider's `assertBase`.
160
+ const moved = await artifacts
161
+ .publish({ ...publishInput({ updatedAt: at(2) }), baseRevision: 1 })
162
+ .catch((error: unknown) => error)
163
+ expect(moved).toMatchObject({
164
+ code: "artifact_moved",
165
+ latest: { version: 1, revision: 2, author: owner, frozenBy: otherOwner },
166
+ })
167
+ expect((moved as Error).message).toContain("which user 'usr_other' created")
168
+
169
+ // Freezing a frozen version changes nothing, from any base.
170
+ expect(
171
+ await artifacts.freeze({
172
+ projectId,
173
+ artifactId: "art_report",
174
+ baseRevision: 1,
175
+ frozenAt: at(2),
176
+ frozenBy: otherOwner,
177
+ })
178
+ ).toEqual(frozen)
179
+
180
+ const opened = await artifacts.publish(publishInput({ title: "Draft", updatedAt: at(3) }))
181
+ expect(opened.version).toMatchObject({
182
+ version: 2,
183
+ revision: 3,
184
+ title: "Draft",
185
+ createdAt: at(3),
186
+ updatedAt: at(3),
187
+ })
188
+ expect(opened.version).not.toHaveProperty("frozenAt")
189
+ expect(opened.version).not.toHaveProperty("frozenBy")
190
+ expect(opened.artifact).toMatchObject({ latestVersion: 2, revision: 3, title: "Draft" })
191
+
192
+ // The next write replaces version 2, and version 1 stays as it was frozen.
193
+ const replaced = await artifacts.publish(publishInput({ title: "Final", updatedAt: at(4) }))
194
+ expect(replaced.version).toMatchObject({ version: 2, revision: 4, title: "Final" })
195
+ expect(
196
+ await artifacts.getVersion({ projectId, artifactId: "art_report", version: 1 })
197
+ ).toEqual(frozen.version)
198
+
199
+ await expectArtifactError(
200
+ artifacts.freeze({
201
+ projectId,
202
+ artifactId: "art_missing",
203
+ frozenAt: at(5),
204
+ frozenBy: otherOwner,
205
+ }),
206
+ "artifact_not_found"
207
+ )
208
+ })
209
+ })
210
+
211
+ test("keeps the kind fixed and refuses writes to a missing artifact", async () => {
105
212
  await withStorage(async (artifacts) => {
106
213
  await artifacts.create(createInput())
107
214
 
@@ -117,22 +224,22 @@ export function runArtifactStorageContractSuite<TStorage extends ArtifactStorage
117
224
  artifacts.publish({ ...publishInput(), projectId: otherProjectId }),
118
225
  "artifact_not_found"
119
226
  )
120
- expect((await artifacts.get({ projectId, id: "art_report" }))?.latestVersion).toBe(1)
227
+ expect((await artifacts.get({ projectId, id: "art_report" }))?.revision).toBe(1)
121
228
  })
122
229
  })
123
230
 
124
- test("publishes from a base version, and refuses one the artifact has moved past", async () => {
231
+ test("writes from a base revision, and refuses one the artifact has moved past", async () => {
125
232
  await withStorage(async (artifacts) => {
126
233
  await artifacts.create(createInput())
127
234
  const edited = await artifacts.publish({
128
- ...publishInput({ author: otherOwner, origin: undefined, createdAt: at(1) }),
129
- baseVersion: 1,
235
+ ...publishInput({ author: otherOwner, origin: undefined, updatedAt: at(1) }),
236
+ baseRevision: 1,
130
237
  })
131
- expect(edited.version.version).toBe(2)
238
+ expect(edited.artifact.revision).toBe(2)
132
239
 
133
- // A second save from version 1 would replace version 2's changes unseen.
240
+ // A second save from revision 1 would replace revision 2's changes unseen.
134
241
  const error = await artifacts
135
- .publish({ ...publishInput({ createdAt: at(2) }), baseVersion: 1 })
242
+ .publish({ ...publishInput({ updatedAt: at(2) }), baseRevision: 1 })
136
243
  .then(
137
244
  () => null,
138
245
  (caught: unknown) => caught
@@ -140,28 +247,40 @@ export function runArtifactStorageContractSuite<TStorage extends ArtifactStorage
140
247
  expect(error).toBeInstanceOf(ArtifactStorageError)
141
248
  expect(error).toMatchObject({
142
249
  code: "artifact_moved",
143
- latest: { version: 2, author: otherOwner },
250
+ latest: { version: 1, revision: 2, author: otherOwner },
144
251
  })
145
- expect((await artifacts.get({ projectId, id: "art_report" }))?.latestVersion).toBe(2)
252
+ expect((await artifacts.get({ projectId, id: "art_report" }))?.revision).toBe(2)
253
+
254
+ // A freeze moves it too: nobody freezes content they never saw.
255
+ await expectArtifactError(
256
+ artifacts.freeze({
257
+ projectId,
258
+ artifactId: "art_report",
259
+ baseRevision: 1,
260
+ frozenAt: at(2),
261
+ frozenBy: otherOwner,
262
+ }),
263
+ "artifact_moved"
264
+ )
146
265
 
147
- // Of two publishes racing from one base, one is stored and the other finds it moved. This
266
+ // Of two writes racing from one base, one is stored and the other finds it moved. This
148
267
  // fixes the outcome only: the in-memory and SQLite storages run each call whole under
149
268
  // their own lock, so the race cannot fail there. Postgres proves its row lock in
150
269
  // `storage/pg/tests/pg-artifact-storage.e2e.ts`.
151
270
  const raced = await Promise.allSettled([
152
- artifacts.publish({ ...publishInput({ createdAt: at(3) }), baseVersion: 2 }),
153
- artifacts.publish({ ...publishInput({ createdAt: at(4) }), baseVersion: 2 }),
271
+ artifacts.publish({ ...publishInput({ updatedAt: at(3) }), baseRevision: 2 }),
272
+ artifacts.publish({ ...publishInput({ updatedAt: at(4) }), baseRevision: 2 }),
154
273
  ])
155
274
  expect(raced.filter((result) => result.status === "fulfilled")).toHaveLength(1)
156
275
  const refused = raced.find((result) => result.status === "rejected")
157
276
  expect(refused?.status === "rejected" && refused.reason).toMatchObject({
158
277
  code: "artifact_moved",
159
- latest: { version: 3 },
278
+ latest: { revision: 3 },
160
279
  })
161
- // Without a base, a publish is stored over whatever is latest.
162
- expect((await artifacts.publish(publishInput({ createdAt: at(5) }))).version.version).toBe(
163
- 4
164
- )
280
+ // Without a base, a write is stored over whatever is latest.
281
+ expect(
282
+ (await artifacts.publish(publishInput({ updatedAt: at(5) }))).artifact.revision
283
+ ).toBe(4)
165
284
  })
166
285
  })
167
286
 
@@ -190,7 +309,14 @@ export function runArtifactStorageContractSuite<TStorage extends ArtifactStorage
190
309
  expect(created.version).not.toHaveProperty("origin")
191
310
  expect(
192
311
  await artifacts.getVersion({ projectId, artifactId: "art_report", version: 1 })
193
- ).toEqual({ projectId, artifactId: "art_report", version: 1, ...version })
312
+ ).toEqual({
313
+ projectId,
314
+ artifactId: "art_report",
315
+ version: 1,
316
+ revision: 1,
317
+ ...version,
318
+ createdAt: t0,
319
+ })
194
320
  })
195
321
  })
196
322
 
@@ -233,9 +359,18 @@ export function runArtifactStorageContractSuite<TStorage extends ArtifactStorage
233
359
  // A longer id that starts with the same letters is another artifact.
234
360
  await create("art_longer", ["artifact:art_numbersx#chart=revenue"])
235
361
  await create("art_elsewhere", ["artifact:art_numbers"], otherProjectId)
236
- // Only the latest version counts: this one dropped its reference.
362
+ // Only the latest version counts: this one dropped its reference, frozen before.
237
363
  await create("art_dropped", ["artifact:art_numbers#Summary"])
238
- await artifacts.publish(publishInput({ createdAt: at(1) }, "art_dropped"))
364
+ await artifacts.freeze({
365
+ projectId,
366
+ artifactId: "art_dropped",
367
+ frozenAt: at(1),
368
+ frozenBy: otherOwner,
369
+ })
370
+ await artifacts.publish(publishInput({ updatedAt: at(2) }, "art_dropped"))
371
+ // And this one dropped it from its open version.
372
+ await create("art_rewritten", ["artifact:art_numbers"])
373
+ await artifacts.publish(publishInput({ updatedAt: at(2) }, "art_rewritten"))
239
374
 
240
375
  const referencing = await artifacts.listReferencingVersions({
241
376
  projectId,
@@ -296,19 +431,26 @@ export function runArtifactStorageContractSuite<TStorage extends ArtifactStorage
296
431
  await withStorage(async (artifacts) => {
297
432
  await artifacts.create(createInput({ id: "art_a" }))
298
433
  await artifacts.create(
299
- createInput({ id: "art_b", version: versionInput({ createdAt: at(1) }) })
434
+ createInput({ id: "art_b", version: versionInput({ updatedAt: at(1) }) })
300
435
  )
301
436
  await artifacts.create(
302
- createInput({ id: "art_c", version: versionInput({ createdAt: at(2) }) })
437
+ createInput({ id: "art_c", version: versionInput({ updatedAt: at(2) }) })
303
438
  )
304
- await artifacts.publish(publishInput({ createdAt: at(3) }, "art_a"))
439
+ await artifacts.publish(publishInput({ updatedAt: at(3) }, "art_a"))
440
+ // A freeze is a change too.
441
+ await artifacts.freeze({
442
+ projectId,
443
+ artifactId: "art_b",
444
+ frozenAt: at(4),
445
+ frozenBy: otherOwner,
446
+ })
305
447
 
306
448
  const all = await artifacts.list({ projectId })
307
- expect(all.artifacts.map((artifact) => artifact.id)).toEqual(["art_a", "art_c", "art_b"])
449
+ expect(all.artifacts.map((artifact) => artifact.id)).toEqual(["art_b", "art_a", "art_c"])
308
450
  expect(all).toMatchObject({ total: 3, hasMore: false })
309
451
 
310
452
  const page = await artifacts.list({ projectId, limit: 2, offset: 1 })
311
- expect(page.artifacts.map((artifact) => artifact.id)).toEqual(["art_c", "art_b"])
453
+ expect(page.artifacts.map((artifact) => artifact.id)).toEqual(["art_a", "art_c"])
312
454
  expect(page).toMatchObject({ total: 3, hasMore: false })
313
455
  expect((await artifacts.list({ projectId, limit: 1 })).hasMore).toBe(true)
314
456
  })
@@ -322,7 +464,7 @@ export function runArtifactStorageContractSuite<TStorage extends ArtifactStorage
322
464
  createInput({
323
465
  id: "art_deck_b",
324
466
  kind: "slides",
325
- version: versionInput({ createdAt: at(1) }),
467
+ version: versionInput({ updatedAt: at(1) }),
326
468
  })
327
469
  )
328
470
  const decks = await artifacts.list({ projectId, kind: "slides", limit: 1 })
@@ -350,7 +492,7 @@ export function runArtifactStorageContractSuite<TStorage extends ArtifactStorage
350
492
  )
351
493
  await artifacts.publish(
352
494
  publishInput(
353
- { origin: { threadId: "thr_3", runId: "run_3" }, createdAt: at(1) },
495
+ { origin: { threadId: "thr_3", runId: "run_3" }, updatedAt: at(1) },
354
496
  "art_api"
355
497
  )
356
498
  )
@@ -370,16 +512,16 @@ export function runArtifactStorageContractSuite<TStorage extends ArtifactStorage
370
512
 
371
513
  // Regression proof: drop `sharedIn` from the in-memory publish, or the link insert from a SQL
372
514
  // provider's; the revised artifact is then not shared in thr_2.
373
- test("shares an artifact in each thread a version came from", async () => {
515
+ test("shares an artifact in each thread a write came from, after the next write too", async () => {
374
516
  await withStorage(async (artifacts) => {
375
517
  await artifacts.create(createInput({ id: "art_mine" }))
376
518
  await artifacts.publish(
377
519
  publishInput(
378
- { origin: { threadId: "thr_2", runId: "run_2" }, createdAt: at(1) },
520
+ { origin: { threadId: "thr_2", runId: "run_2" }, updatedAt: at(1) },
379
521
  "art_mine"
380
522
  )
381
523
  )
382
- await artifacts.publish(publishInput({ origin: undefined, createdAt: at(2) }, "art_mine"))
524
+ await artifacts.publish(publishInput({ origin: undefined, updatedAt: at(2) }, "art_mine"))
383
525
  expect(await artifacts.listThreadIds({ projectId, id: "art_mine" })).toEqual([
384
526
  "thr_1",
385
527
  "thr_2",
@@ -399,44 +541,485 @@ export function runArtifactStorageContractSuite<TStorage extends ArtifactStorage
399
541
  })
400
542
  })
401
543
 
402
- // Regression proof: keep every link in a provider's `deleteVersionsByOrigin`; thr_2 then keeps
403
- // sharing art_mine with nothing from it left.
404
- test("unshares an artifact from a retried run's thread once nothing from there remains", async () => {
544
+ // Regression proof: take a restore point on every write of a turn in a provider's `publish`;
545
+ // the turn then keeps three, the last two of its own content.
546
+ test("keeps a restore point before a turn's first write to an artifact, once per turn", async () => {
405
547
  await withStorage(async (artifacts) => {
406
- await artifacts.create(createInput({ id: "art_mine" }))
407
- await artifacts.publish(
408
- publishInput(
409
- { origin: { threadId: "thr_2", runId: "run_2" }, createdAt: at(1) },
410
- "art_mine"
411
- )
548
+ await artifacts.create(createInput({ version: versionInput({ origin: undefined }) }))
549
+ await artifacts.publish({
550
+ ...publishInput({ title: "First", updatedAt: at(1) }),
551
+ turnRunId: "run_1",
552
+ })
553
+ await artifacts.publish({
554
+ ...publishInput({ title: "Second", updatedAt: at(2) }),
555
+ turnRunId: "run_1",
556
+ })
557
+ // A sub-agent of the turn writes as the turn.
558
+ await artifacts.publish({
559
+ ...publishInput({
560
+ title: "Third",
561
+ origin: { threadId: "thr_1", runId: "run_child" },
562
+ updatedAt: at(3),
563
+ }),
564
+ turnRunId: "run_1",
565
+ })
566
+
567
+ const points = await artifacts.listRestorePoints({ projectId, id: "art_report" })
568
+ expect(points).toEqual([
569
+ {
570
+ projectId,
571
+ artifactId: "art_report",
572
+ revision: 1,
573
+ version: 1,
574
+ frozen: false,
575
+ ...versionInput({ origin: undefined }),
576
+ reason: "turn",
577
+ turnRunId: "run_1",
578
+ createdAt: at(1),
579
+ },
580
+ ])
581
+ expect(
582
+ await artifacts.getRestorePoint({ projectId, artifactId: "art_report", revision: 1 })
583
+ ).toEqual(points[0] ?? null)
584
+ expect(
585
+ await artifacts.getRestorePoint({ projectId, artifactId: "art_report", revision: 2 })
586
+ ).toBeNull()
587
+
588
+ // Writes outside a turn keep none; a created artifact has nothing to go back to.
589
+ await artifacts.publish(publishInput({ updatedAt: at(4) }))
590
+ await artifacts.create({ ...createInput({ id: "art_new" }), turnRunId: "run_2" })
591
+ expect(await artifacts.listRestorePoints({ projectId, id: "art_new" })).toEqual([])
592
+
593
+ // Another turn keeps its own, of the frozen version it opens the next one past.
594
+ await artifacts.freeze({
595
+ projectId,
596
+ artifactId: "art_report",
597
+ frozenAt: at(5),
598
+ frozenBy: otherOwner,
599
+ })
600
+ await artifacts.publish({ ...publishInput({ updatedAt: at(6) }), turnRunId: "run_3" })
601
+ const [newest] = await artifacts.listRestorePoints({ projectId, id: "art_report" })
602
+ expect(newest).toMatchObject({
603
+ revision: 6,
604
+ version: 1,
605
+ frozen: true,
606
+ title: "Q3 report",
607
+ turnRunId: "run_3",
608
+ })
609
+
610
+ expect(await artifacts.listTurnWrites({ projectId, turnRunId: "run_1" })).toEqual([
611
+ { artifactId: "art_report", created: false, revision: 4, writes: 3 },
612
+ ])
613
+ expect(await artifacts.listTurnWrites({ projectId, turnRunId: "run_2" })).toEqual([
614
+ { artifactId: "art_new", created: true, revision: 1, writes: 1 },
615
+ ])
616
+ expect(
617
+ await artifacts.listTurnWrites({ projectId: otherProjectId, turnRunId: "run_1" })
618
+ ).toEqual([])
619
+ })
620
+ })
621
+
622
+ // Regression proof: drop the prune after the insert in a provider's restore point; the
623
+ // artifact then keeps one more.
624
+ test(`keeps an artifact's last ${ARTIFACT_RESTORE_POINTS} restore points`, async () => {
625
+ await withStorage(async (artifacts) => {
626
+ await artifacts.create(createInput())
627
+ for (let turn = 1; turn <= ARTIFACT_RESTORE_POINTS + 1; turn++) {
628
+ await artifacts.publish({
629
+ ...publishInput({ updatedAt: at(turn) }),
630
+ turnRunId: `run_${turn}`,
631
+ })
632
+ }
633
+
634
+ const points = await artifacts.listRestorePoints({ projectId, id: "art_report" })
635
+ expect(points).toHaveLength(ARTIFACT_RESTORE_POINTS)
636
+ expect(points[0]?.revision).toBe(ARTIFACT_RESTORE_POINTS + 1)
637
+ expect(points.at(-1)?.revision).toBe(2)
638
+ })
639
+ })
640
+
641
+ test("restores a restore point into the latest version, keeping what it replaces", async () => {
642
+ await withStorage(async (artifacts) => {
643
+ await artifacts.create(createInput())
644
+ await artifacts.publish({
645
+ ...publishInput({ title: "Agent's", updatedAt: at(1) }),
646
+ turnRunId: "run_1",
647
+ })
648
+
649
+ const restored = await artifacts.restoreTo({
650
+ projectId,
651
+ artifactId: "art_report",
652
+ revision: 1,
653
+ baseRevision: 2,
654
+ author: otherOwner,
655
+ restoredAt: at(2),
656
+ })
657
+ expect(restored.artifact).toMatchObject({
658
+ latestVersion: 1,
659
+ revision: 3,
660
+ title: "Q3 report",
661
+ updatedAt: at(2),
662
+ })
663
+ expect(restored.version).toMatchObject({
664
+ version: 1,
665
+ revision: 3,
666
+ title: "Q3 report",
667
+ author: otherOwner,
668
+ updatedAt: at(2),
669
+ })
670
+ expect(restored.version).not.toHaveProperty("origin")
671
+
672
+ // The restore can be undone: what it replaced is a restore point too.
673
+ const [before] = await artifacts.listRestorePoints({ projectId, id: "art_report" })
674
+ expect(before).toMatchObject({
675
+ revision: 2,
676
+ title: "Agent's",
677
+ reason: "restore",
678
+ createdAt: at(2),
679
+ })
680
+ expect(before).not.toHaveProperty("turnRunId")
681
+
682
+ // A frozen version stays: restoring opens the next one.
683
+ await artifacts.freeze({
684
+ projectId,
685
+ artifactId: "art_report",
686
+ frozenAt: at(3),
687
+ frozenBy: otherOwner,
688
+ })
689
+ const reopened = await artifacts.restoreTo({
690
+ projectId,
691
+ artifactId: "art_report",
692
+ revision: 2,
693
+ author: owner,
694
+ restoredAt: at(4),
695
+ })
696
+ expect(reopened.version).toMatchObject({ version: 2, revision: 5, title: "Agent's" })
697
+ expect(
698
+ (await artifacts.getVersion({ projectId, artifactId: "art_report", version: 1 }))
699
+ ?.frozenAt
700
+ ).toEqual(at(3))
701
+
702
+ await expectArtifactError(
703
+ artifacts.restoreTo({
704
+ projectId,
705
+ artifactId: "art_report",
706
+ revision: 9,
707
+ author: owner,
708
+ restoredAt: at(5),
709
+ }),
710
+ "restore_point_not_found"
412
711
  )
712
+ await expectArtifactError(
713
+ artifacts.restoreTo({
714
+ projectId,
715
+ artifactId: "art_report",
716
+ revision: 1,
717
+ baseRevision: 4,
718
+ author: owner,
719
+ restoredAt: at(5),
720
+ }),
721
+ "artifact_moved"
722
+ )
723
+ await expectArtifactError(
724
+ artifacts.restoreTo({
725
+ projectId,
726
+ artifactId: "art_missing",
727
+ revision: 1,
728
+ author: owner,
729
+ restoredAt: at(5),
730
+ }),
731
+ "artifact_not_found"
732
+ )
733
+ })
734
+ })
735
+
736
+ // Regression proof: skip the revision check in a provider's `undoTurnWrites`; the person's
737
+ // edit to art_edited is then lost.
738
+ test("undoes a retried turn's writes to what nobody changed since", async () => {
739
+ await withStorage(async (artifacts) => {
740
+ const turn = { threadId: "thr_turn", runId: "run_turn" }
741
+ const write = (artifactId: string, overrides: Partial<ArtifactVersionInput> = {}) =>
742
+ artifacts.publish({
743
+ ...publishInput(
744
+ { title: "Turn's", origin: turn, updatedAt: at(1), ...overrides },
745
+ artifactId
746
+ ),
747
+ turnRunId: "run_turn",
748
+ })
749
+
750
+ // Replaced in place: back to what it held, by whoever wrote it.
751
+ await artifacts.create(
752
+ createInput({ id: "art_open", version: versionInput({ author: otherOwner }) })
753
+ )
754
+ await write("art_open")
755
+ await write("art_open", { title: "Turn's again", updatedAt: at(2) })
756
+
757
+ // Opened past a frozen version: the version it opened goes.
758
+ await artifacts.create(createInput({ id: "art_frozen" }))
759
+ await artifacts.freeze({
760
+ projectId,
761
+ artifactId: "art_frozen",
762
+ frozenAt: at(1),
763
+ frozenBy: otherOwner,
764
+ })
765
+ await write("art_frozen")
766
+
767
+ // Changed since by someone else: it keeps the change.
768
+ await artifacts.create(createInput({ id: "art_edited" }))
769
+ await write("art_edited")
413
770
  await artifacts.publish(
414
- publishInput(
415
- { origin: { threadId: "thr_3", runId: "run_3" }, createdAt: at(2) },
416
- "art_mine"
417
- )
771
+ publishInput({ title: "Person's", origin: undefined, updatedAt: at(3) }, "art_edited")
772
+ )
773
+
774
+ // Created by the turn: it goes, with its frame grants, unless changed since.
775
+ await artifacts.create({
776
+ ...createInput({ id: "art_created", version: versionInput({ origin: turn }) }),
777
+ turnRunId: "run_turn",
778
+ })
779
+ await artifacts.createFrameGrant(frameGrant("a", { artifactId: "art_created" }))
780
+ await artifacts.create({
781
+ ...createInput({ id: "art_kept", version: versionInput({ origin: turn }) }),
782
+ turnRunId: "run_turn",
783
+ })
784
+ await artifacts.freeze({
785
+ projectId,
786
+ artifactId: "art_kept",
787
+ frozenAt: at(3),
788
+ frozenBy: otherOwner,
789
+ })
790
+
791
+ expect(
792
+ await artifacts.undoTurnWrites({ projectId: otherProjectId, turnRunId: "run_turn" })
793
+ ).toEqual({ restored: [], deleted: [] })
794
+ const undone = await artifacts.undoTurnWrites({ projectId, turnRunId: "run_turn" })
795
+
796
+ expect(undone.deleted).toEqual(["art_created"])
797
+ expect(undone.restored.map(({ artifact }) => artifact.id).sort()).toEqual([
798
+ "art_frozen",
799
+ "art_open",
800
+ ])
801
+
802
+ const open = await artifacts.getVersion({ projectId, artifactId: "art_open", version: 1 })
803
+ expect(open).toMatchObject({
804
+ title: "Q3 report",
805
+ author: otherOwner,
806
+ origin: agentRun,
807
+ revision: 4,
808
+ updatedAt: t0,
809
+ createdAt: t0,
810
+ })
811
+ expect(await artifacts.get({ projectId, id: "art_open" })).toMatchObject({
812
+ title: "Q3 report",
813
+ latestVersion: 1,
814
+ revision: 4,
815
+ updatedAt: t0,
816
+ })
817
+ expect(undone.restored.find(({ artifact }) => artifact.id === "art_open")?.version).toEqual(
818
+ open ?? undefined
418
819
  )
820
+
821
+ expect(await artifacts.get({ projectId, id: "art_frozen" })).toMatchObject({
822
+ latestVersion: 1,
823
+ revision: 4,
824
+ updatedAt: at(1),
825
+ })
826
+ expect(
827
+ await artifacts.getVersion({ projectId, artifactId: "art_frozen", version: 2 })
828
+ ).toBeNull()
829
+ expect(
830
+ await artifacts.getVersion({ projectId, artifactId: "art_frozen", version: 1 })
831
+ ).toMatchObject({ revision: 4, frozenAt: at(1) })
832
+ // A version number is never reused: an address that named version 2 never lands on other content.
833
+ expect(
834
+ (await artifacts.publish(publishInput({ updatedAt: at(4) }, "art_frozen"))).version
835
+ .version
836
+ ).toBe(3)
837
+
838
+ expect(await artifacts.get({ projectId, id: "art_edited" })).toMatchObject({
839
+ title: "Person's",
840
+ revision: 3,
841
+ })
842
+ expect(await artifacts.get({ projectId, id: "art_created" })).toBeNull()
843
+ expect(await artifacts.findFrameGrant({ projectId, tokenHash: "a".repeat(64) })).toBeNull()
844
+ expect(await artifacts.get({ projectId, id: "art_kept" })).not.toBeNull()
845
+
846
+ // Undone to it, the turn's restore point is gone; one it was not undone to stays.
847
+ expect(await artifacts.listRestorePoints({ projectId, id: "art_open" })).toEqual([])
848
+ expect(
849
+ (await artifacts.listRestorePoints({ projectId, id: "art_edited" })).map(
850
+ (point) => point.turnRunId
851
+ )
852
+ ).toEqual(["run_turn"])
853
+ expect(await artifacts.listTurnWrites({ projectId, turnRunId: "run_turn" })).toEqual([])
854
+ // A second retry finds nothing left to undo.
855
+ expect(await artifacts.undoTurnWrites({ projectId, turnRunId: "run_turn" })).toEqual({
856
+ restored: [],
857
+ deleted: [],
858
+ })
859
+ })
860
+ })
861
+
862
+ // Regression proof: compare the artifact's revision with the turn's last write alone, as
863
+ // providers once did; the version created between the turn's writes is rewritten, and the
864
+ // person's save between them is lost with no restore point of it.
865
+ test("keeps what anyone changed between two of a turn's writes", async () => {
866
+ await withStorage(async (artifacts) => {
867
+ const write = (artifactId: string, updatedAt: Date) =>
868
+ artifacts.publish({
869
+ ...publishInput(
870
+ { title: "Turn's", origin: { threadId: "thr_turn", runId: "run_turn" }, updatedAt },
871
+ artifactId
872
+ ),
873
+ turnRunId: "run_turn",
874
+ })
875
+
876
+ // Someone created version 1 between the turn's writes: the second opened version 2.
877
+ await artifacts.create(createInput({ id: "art_created_between" }))
878
+ await write("art_created_between", at(1))
879
+ await artifacts.freeze({
880
+ projectId,
881
+ artifactId: "art_created_between",
882
+ frozenAt: at(2),
883
+ frozenBy: otherOwner,
884
+ })
885
+ await write("art_created_between", at(3))
886
+
887
+ // Someone saved between them, and the turn wrote again on top.
888
+ await artifacts.create(createInput({ id: "art_saved_between" }))
889
+ await write("art_saved_between", at(1))
419
890
  await artifacts.publish(
420
891
  publishInput(
421
- { origin: { threadId: "thr_3", runId: "run_4" }, createdAt: at(3) },
422
- "art_mine"
892
+ { title: "Person's", origin: undefined, updatedAt: at(2) },
893
+ "art_saved_between"
423
894
  )
424
895
  )
896
+ await write("art_saved_between", at(3))
897
+
898
+ expect(await artifacts.listTurnWrites({ projectId, turnRunId: "run_turn" })).toEqual([
899
+ { artifactId: "art_created_between", created: false, revision: 4, writes: 2 },
900
+ { artifactId: "art_saved_between", created: false, revision: 4, writes: 2 },
901
+ ])
902
+ expect(await artifacts.undoTurnWrites({ projectId, turnRunId: "run_turn" })).toEqual({
903
+ restored: [],
904
+ deleted: [],
905
+ })
425
906
 
426
- // A retried turn takes back what it published, and the link it alone made.
427
- await artifacts.deleteVersionsByOrigin({ projectId, runId: "run_2" })
907
+ // Version 1 stays as its creator created it, and version 2 stays open.
908
+ expect(
909
+ await artifacts.getVersion({ projectId, artifactId: "art_created_between", version: 1 })
910
+ ).toMatchObject({ title: "Turn's", frozenAt: at(2), frozenBy: otherOwner })
911
+ expect(await artifacts.get({ projectId, id: "art_created_between" })).toMatchObject({
912
+ latestVersion: 2,
913
+ revision: 4,
914
+ })
915
+ // The turn's write on top of the save stays, and the turn's restore point with it.
916
+ expect(await artifacts.get({ projectId, id: "art_saved_between" })).toMatchObject({
917
+ title: "Turn's",
918
+ revision: 4,
919
+ })
920
+ expect(
921
+ (await artifacts.listRestorePoints({ projectId, id: "art_saved_between" })).map(
922
+ (point) => point.turnRunId
923
+ )
924
+ ).toEqual(["run_turn"])
925
+ })
926
+ })
927
+
928
+ // Regression proofs: keep every link in a provider's `undoTurnWrites`, and thr_5 keeps sharing
929
+ // art_undone with nothing from it left; drop every link the turn made, and art_mine, kept
930
+ // because someone wrote it since, vanishes from thr_2, which made it.
931
+ test("unshares an undone artifact from the threads only a retried turn shared it in", async () => {
932
+ await withStorage(async (artifacts) => {
933
+ await artifacts.create(createInput({ id: "art_mine" }))
934
+ await artifacts.publish({
935
+ ...publishInput(
936
+ { origin: { threadId: "thr_2", runId: "run_2" }, updatedAt: at(1) },
937
+ "art_mine"
938
+ ),
939
+ turnRunId: "run_2",
940
+ })
941
+ await artifacts.publish({
942
+ ...publishInput(
943
+ { origin: { threadId: "thr_3", runId: "run_3" }, updatedAt: at(2) },
944
+ "art_mine"
945
+ ),
946
+ turnRunId: "run_3",
947
+ })
948
+ await artifacts.publish({
949
+ ...publishInput(
950
+ { origin: { threadId: "thr_3", runId: "run_4" }, updatedAt: at(3) },
951
+ "art_mine"
952
+ ),
953
+ turnRunId: "run_4",
954
+ })
955
+
956
+ // Changed since, the artifact keeps the link the retried turn made: it stays in the
957
+ // conversation that made it.
958
+ await artifacts.undoTurnWrites({ projectId, turnRunId: "run_2" })
428
959
  expect(await artifacts.listThreadIds({ projectId, id: "art_mine" })).toEqual([
429
960
  "thr_1",
961
+ "thr_2",
430
962
  "thr_3",
431
963
  ])
432
- expect((await artifacts.list({ projectId, threadId: "thr_2" })).total).toBe(0)
433
964
 
434
- // Another turn's version from thr_3 keeps it shared there.
435
- await artifacts.deleteVersionsByOrigin({ projectId, runId: "run_3" })
965
+ // Undone, it would leave the threads the turn shared it in; this one made no link.
966
+ await artifacts.undoTurnWrites({ projectId, turnRunId: "run_4" })
436
967
  expect(await artifacts.listThreadIds({ projectId, id: "art_mine" })).toEqual([
437
968
  "thr_1",
969
+ "thr_2",
438
970
  "thr_3",
439
971
  ])
972
+
973
+ // Undone, an artifact the turn alone shared in thr_5 leaves it.
974
+ await artifacts.create(
975
+ createInput({ id: "art_undone", version: versionInput({ origin: undefined }) })
976
+ )
977
+ await artifacts.publish({
978
+ ...publishInput(
979
+ { origin: { threadId: "thr_5", runId: "run_5" }, updatedAt: at(4) },
980
+ "art_undone"
981
+ ),
982
+ turnRunId: "run_5",
983
+ })
984
+ expect(await artifacts.listThreadIds({ projectId, id: "art_undone" })).toEqual(["thr_5"])
985
+ await artifacts.undoTurnWrites({ projectId, turnRunId: "run_5" })
986
+ expect(await artifacts.listThreadIds({ projectId, id: "art_undone" })).toEqual([])
987
+ expect((await artifacts.list({ projectId, threadId: "thr_5" })).total).toBe(0)
988
+ })
989
+ })
990
+
991
+ test("gives a copied version the outline the copy asks for, and the source keeps its own", async () => {
992
+ await withStorage(async (artifacts) => {
993
+ await artifacts.create(createInput())
994
+ await artifacts.freeze({
995
+ projectId,
996
+ artifactId: "art_report",
997
+ frozenAt: at(1),
998
+ frozenBy: otherOwner,
999
+ })
1000
+ await artifacts.publish(publishInput({ title: "Second", updatedAt: at(2) }))
1001
+ const renamed = { kind: "document" as const, headings: [] }
1002
+ const seen: string[] = []
1003
+
1004
+ await artifacts.copy({
1005
+ projectId,
1006
+ sourceId: "art_report",
1007
+ id: "art_copy",
1008
+ owner: otherOwner,
1009
+ threadId: "thr_fork",
1010
+ // Asked of each version as the copy holds it: under the copy's id.
1011
+ outlineOf: (version) => {
1012
+ seen.push(`${version.artifactId}@${version.version}`)
1013
+ return version.version === 2 ? renamed : undefined
1014
+ },
1015
+ })
1016
+
1017
+ expect(seen.sort()).toEqual(["art_copy@1", "art_copy@2"])
1018
+ const outline = async (artifactId: string, version: number) =>
1019
+ (await artifacts.getVersion({ projectId, artifactId, version }))?.outline
1020
+ expect(await outline("art_copy", 2)).toEqual(renamed)
1021
+ expect(await outline("art_copy", 1)).toEqual(versionInput().outline)
1022
+ expect(await outline("art_report", 2)).toEqual(versionInput().outline)
440
1023
  })
441
1024
  })
442
1025
 
@@ -445,27 +1028,43 @@ export function runArtifactStorageContractSuite<TStorage extends ArtifactStorage
445
1028
  test("copies an artifact with every version under its number, shared in one thread", async () => {
446
1029
  await withStorage(async (artifacts) => {
447
1030
  await artifacts.create(createInput())
1031
+ await artifacts.freeze({
1032
+ projectId,
1033
+ artifactId: "art_report",
1034
+ frozenAt: at(1),
1035
+ frozenBy: otherOwner,
1036
+ })
448
1037
  await artifacts.publish(
449
- publishInput({ title: "Second", author: otherOwner, createdAt: at(1) })
1038
+ publishInput({ title: "Second", author: otherOwner, updatedAt: at(2) })
450
1039
  )
451
- await artifacts.publish(publishInput({ title: "Third", createdAt: at(2) }))
452
- // Version 4 was a retried turn's: the copy numbers its next version 5, as the source does.
453
- await artifacts.publish(
454
- publishInput({
1040
+ await artifacts.freeze({
1041
+ projectId,
1042
+ artifactId: "art_report",
1043
+ frozenAt: at(3),
1044
+ frozenBy: otherOwner,
1045
+ })
1046
+ // Version 3 was a retried turn's: the copy numbers its next version 4, as the source does.
1047
+ await artifacts.publish({
1048
+ ...publishInput({
455
1049
  title: "Retried",
456
1050
  origin: { threadId: "thr_1", runId: "run_9" },
457
- createdAt: at(3),
458
- })
1051
+ updatedAt: at(4),
1052
+ }),
1053
+ turnRunId: "run_9",
1054
+ })
1055
+ await artifacts.undoTurnWrites({ projectId, turnRunId: "run_9" })
1056
+ await artifacts.publish(
1057
+ publishInput({ title: "Third", origin: undefined, updatedAt: at(5) })
459
1058
  )
460
- await artifacts.deleteVersionsByOrigin({ projectId, runId: "run_9" })
461
1059
 
1060
+ const source = await artifacts.get({ projectId, id: "art_report" })
462
1061
  const copy = await artifacts.copy({
463
1062
  projectId,
464
1063
  sourceId: "art_report",
465
1064
  id: "art_copy",
466
1065
  owner: otherOwner,
467
1066
  threadId: "thr_fork",
468
- copiedAt: at(5),
1067
+ copiedAt: at(6),
469
1068
  })
470
1069
  expect(copy).toEqual({
471
1070
  projectId,
@@ -473,35 +1072,53 @@ export function runArtifactStorageContractSuite<TStorage extends ArtifactStorage
473
1072
  kind: "document",
474
1073
  title: "Third",
475
1074
  owner: otherOwner,
476
- latestVersion: 3,
1075
+ latestVersion: 4,
1076
+ revision: source?.revision ?? 0,
477
1077
  createdAt: t0,
478
- updatedAt: at(2),
1078
+ updatedAt: at(5),
479
1079
  })
480
1080
 
481
1081
  const { versions } = await artifacts.listVersions({ projectId, artifactId: "art_copy" })
482
- expect(versions.map(({ version, title, author }) => ({ version, title, author }))).toEqual([
483
- { version: 3, title: "Third", author: owner },
484
- { version: 2, title: "Second", author: otherOwner },
485
- { version: 1, title: "Q3 report", author: owner },
1082
+ expect(
1083
+ versions.map(({ version, title, author, frozenAt }) => ({
1084
+ version,
1085
+ title,
1086
+ author,
1087
+ frozenAt,
1088
+ }))
1089
+ ).toEqual([
1090
+ { version: 4, title: "Third", author: owner, frozenAt: undefined },
1091
+ { version: 2, title: "Second", author: otherOwner, frozenAt: at(3) },
1092
+ { version: 1, title: "Q3 report", author: owner, frozenAt: at(1) },
486
1093
  ])
487
1094
  // Without an origin, a retry of the source's turns never takes the copy's versions.
488
1095
  expect(versions.every((version) => version.origin === undefined)).toBe(true)
489
- const source = await artifacts.getVersion({
1096
+ const latest = await artifacts.getVersion({
490
1097
  projectId,
491
1098
  artifactId: "art_report",
492
- version: 3,
1099
+ version: 4,
493
1100
  })
494
- expect(versions[0]?.files).toEqual(source?.files ?? [])
1101
+ expect(versions[0]?.files).toEqual(latest?.files ?? [])
1102
+ expect(versions[0]?.revision).toBe(latest?.revision ?? 0)
1103
+ // Restore points stay with the source.
1104
+ expect(await artifacts.listRestorePoints({ projectId, id: "art_copy" })).toEqual([])
495
1105
 
496
1106
  expect(await artifacts.listThreadIds({ projectId, id: "art_copy" })).toEqual(["thr_fork"])
497
1107
  expect(await artifacts.listThreadIds({ projectId, id: "art_report" })).toEqual(["thr_1"])
498
1108
 
499
1109
  // A turn in the fork revises the copy, and a retry of it keeps the copy shared there.
500
- const revised = await artifacts.publish(
501
- publishInput({ origin: { threadId: "thr_fork", runId: "run_fork" } }, "art_copy")
502
- )
1110
+ await artifacts.freeze({
1111
+ projectId,
1112
+ artifactId: "art_copy",
1113
+ frozenAt: at(7),
1114
+ frozenBy: otherOwner,
1115
+ })
1116
+ const revised = await artifacts.publish({
1117
+ ...publishInput({ origin: { threadId: "thr_fork", runId: "run_fork" } }, "art_copy"),
1118
+ turnRunId: "run_fork",
1119
+ })
503
1120
  expect(revised.version.version).toBe(5)
504
- await artifacts.deleteVersionsByOrigin({ projectId, runId: "run_fork" })
1121
+ await artifacts.undoTurnWrites({ projectId, turnRunId: "run_fork" })
505
1122
  expect(await artifacts.listThreadIds({ projectId, id: "art_copy" })).toEqual(["thr_fork"])
506
1123
 
507
1124
  await expectArtifactError(
@@ -528,11 +1145,389 @@ export function runArtifactStorageContractSuite<TStorage extends ArtifactStorage
528
1145
  })
529
1146
  })
530
1147
 
1148
+ // Regression proof: in a provider's write of the latest content, store the document without
1149
+ // its revision, or move the revision without one; a document left behind then reads as the
1150
+ // content's, and its readers miss what the write changed.
1151
+ test("keeps the document each content write stores at its revision, and leaves one behind without", async () => {
1152
+ await withStorage(async (artifacts) => {
1153
+ const first = fileRef("1", "application/octet-stream")
1154
+ const second = fileRef("2", "application/octet-stream")
1155
+ const restored = fileRef("3", "application/octet-stream")
1156
+ const undone = fileRef("4", "application/octet-stream")
1157
+ const get = async (id = "art_report") => artifacts.get({ projectId, id })
1158
+
1159
+ const created = await artifacts.create({ ...createInput(), document: first })
1160
+ expect(created.artifact.document).toEqual({ file: first, revision: 1 })
1161
+ expect((await get())?.document).toEqual({ file: first, revision: 1 })
1162
+
1163
+ // A freeze keeps the content, and the document holds it still; the next write opens a
1164
+ // version and replaces the document.
1165
+ const frozen = await artifacts.freeze({
1166
+ projectId,
1167
+ artifactId: "art_report",
1168
+ frozenAt: at(1),
1169
+ frozenBy: owner,
1170
+ })
1171
+ expect(frozen.artifact.document).toEqual({ file: first, revision: 2 })
1172
+ const published = await artifacts.publish({
1173
+ ...publishInput({ updatedAt: at(2) }),
1174
+ turnRunId: "run_turn",
1175
+ document: second,
1176
+ })
1177
+ expect(published.artifact).toMatchObject({
1178
+ latestVersion: 2,
1179
+ revision: 3,
1180
+ document: { file: second, revision: 3 },
1181
+ })
1182
+
1183
+ // A copy shares the document. A write without one leaves it behind, at the revision whose
1184
+ // content it holds, and a freeze does not bring it forward.
1185
+ await artifacts.copy({
1186
+ projectId,
1187
+ sourceId: "art_report",
1188
+ id: "art_copy",
1189
+ owner,
1190
+ threadId: "thr_fork",
1191
+ })
1192
+ expect((await get("art_copy"))?.document).toEqual({ file: second, revision: 3 })
1193
+ await artifacts.publish(publishInput({ updatedAt: at(3) }, "art_copy"))
1194
+ await artifacts.freeze({
1195
+ projectId,
1196
+ artifactId: "art_copy",
1197
+ frozenAt: at(4),
1198
+ frozenBy: owner,
1199
+ })
1200
+ expect(await get("art_copy")).toMatchObject({
1201
+ revision: 5,
1202
+ document: { file: second, revision: 3 },
1203
+ })
1204
+
1205
+ // A restore and an undo store the document given for what they put back, or leave it.
1206
+ const [point] = await artifacts.listRestorePoints({ projectId, id: "art_report" })
1207
+ const back = await artifacts.restoreTo({
1208
+ projectId,
1209
+ artifactId: "art_report",
1210
+ revision: point?.revision ?? 0,
1211
+ author: owner,
1212
+ restoredAt: at(4),
1213
+ document: restored,
1214
+ })
1215
+ expect(back.artifact.document).toEqual({ file: restored, revision: back.artifact.revision })
1216
+ const again = await artifacts.restoreTo({
1217
+ projectId,
1218
+ artifactId: "art_report",
1219
+ revision: back.artifact.revision - 1,
1220
+ author: owner,
1221
+ restoredAt: at(5),
1222
+ })
1223
+ expect(again.artifact.document).toEqual({
1224
+ file: restored,
1225
+ revision: back.artifact.revision,
1226
+ })
1227
+
1228
+ await artifacts.create(createInput({ id: "art_turn" }))
1229
+ await artifacts.publish({
1230
+ ...publishInput({ updatedAt: at(6) }, "art_turn"),
1231
+ turnRunId: "run_undo",
1232
+ document: second,
1233
+ })
1234
+ const result = await artifacts.undoTurnWrites({
1235
+ projectId,
1236
+ turnRunId: "run_undo",
1237
+ documents: { art_turn: undone },
1238
+ })
1239
+ expect(result.restored.map(({ artifact }) => artifact.document)).toEqual([
1240
+ { file: undone, revision: 3 },
1241
+ ])
1242
+ expect((await get("art_turn"))?.document).toEqual({ file: undone, revision: 3 })
1243
+ })
1244
+ })
1245
+
1246
+ // Regression proof: drop the `othersCommented` check from a provider's `undoTurnWrites`; the
1247
+ // retry deletes art_reviewed, and the other person's comment goes with it.
1248
+ test("keeps an artifact a retried turn created once anyone but its requester commented on it", async () => {
1249
+ await withStorage(async (artifacts) => {
1250
+ const turn = { threadId: "thr_turn", runId: "run_turn" }
1251
+ const created = (id: string) =>
1252
+ artifacts.create({
1253
+ ...createInput({ id, version: versionInput({ origin: turn }) }),
1254
+ turnRunId: "run_turn",
1255
+ })
1256
+ const comment = (
1257
+ artifactId: string,
1258
+ id: string,
1259
+ author: Principal,
1260
+ origin?: { readonly threadId: string; readonly runId: string }
1261
+ ) =>
1262
+ artifacts.createComment({
1263
+ projectId,
1264
+ artifactId,
1265
+ id,
1266
+ anchor: { revision: 1 },
1267
+ body: `Comment ${id}`,
1268
+ author,
1269
+ ...(origin ? { origin } : {}),
1270
+ createdAt: at(2),
1271
+ })
1272
+
1273
+ // Commented by the requester, and by the turn for them: it goes all the same.
1274
+ await created("art_mine")
1275
+ await comment("art_mine", "cmt_own", owner)
1276
+ await comment("art_mine", "cmt_turn", owner, turn)
1277
+
1278
+ // Commented by someone else: kept, with their comment.
1279
+ await created("art_reviewed")
1280
+ await comment("art_reviewed", "cmt_other", otherOwner)
1281
+
1282
+ const undone = await artifacts.undoTurnWrites({
1283
+ projectId,
1284
+ turnRunId: "run_turn",
1285
+ requester: owner,
1286
+ })
1287
+
1288
+ expect(undone).toEqual({ restored: [], deleted: ["art_mine"] })
1289
+ expect(await artifacts.get({ projectId, id: "art_mine" })).toBeNull()
1290
+ expect(
1291
+ (await artifacts.listComments({ projectId, id: "art_reviewed" })).map(({ id }) => id)
1292
+ ).toEqual(["cmt_other"])
1293
+ })
1294
+ })
1295
+
1296
+ test("keeps comments and their replies, oldest first, and resolves and deletes them", async () => {
1297
+ await withStorage(async (artifacts) => {
1298
+ await artifacts.create(createInput())
1299
+ const comment = (id: string, overrides: Partial<CreateArtifactCommentInput> = {}) =>
1300
+ artifacts.createComment({
1301
+ projectId,
1302
+ artifactId: "art_report",
1303
+ id,
1304
+ anchor: {
1305
+ board: "welcome",
1306
+ element: "body>main:0>h1:0",
1307
+ label: "Welcome",
1308
+ point: { x: 0.25, y: 0.5 },
1309
+ revision: 1,
1310
+ },
1311
+ body: `Comment ${id}`,
1312
+ author: otherOwner,
1313
+ createdAt: at(1),
1314
+ ...overrides,
1315
+ })
1316
+
1317
+ const first = await comment("cmt_b")
1318
+ expect(first).toEqual({
1319
+ projectId,
1320
+ artifactId: "art_report",
1321
+ id: "cmt_b",
1322
+ anchor: {
1323
+ board: "welcome",
1324
+ element: "body>main:0>h1:0",
1325
+ label: "Welcome",
1326
+ point: { x: 0.25, y: 0.5 },
1327
+ revision: 1,
1328
+ },
1329
+ body: "Comment cmt_b",
1330
+ author: otherOwner,
1331
+ createdAt: at(1),
1332
+ })
1333
+ // At the same time: as they were made. A reply takes its own anchor.
1334
+ await comment("cmt_a", { anchor: { revision: 2 } })
1335
+ await comment("cmt_reply", {
1336
+ parentId: "cmt_b",
1337
+ author: owner,
1338
+ origin: { threadId: "thr_1", runId: "run_1" },
1339
+ createdAt: at(2),
1340
+ })
1341
+ expect(
1342
+ (await artifacts.listComments({ projectId, id: "art_report" })).map((each) => [
1343
+ each.id,
1344
+ each.parentId,
1345
+ each.anchor,
1346
+ ])
1347
+ ).toEqual([
1348
+ ["cmt_b", undefined, first.anchor],
1349
+ ["cmt_a", undefined, { revision: 2 }],
1350
+ ["cmt_reply", "cmt_b", first.anchor],
1351
+ ])
1352
+ // The Agent's run that wrote a comment for its author is kept with it.
1353
+ expect(
1354
+ (await artifacts.getComment({ projectId, artifactId: "art_report", id: "cmt_reply" }))
1355
+ ?.origin
1356
+ ).toEqual({ threadId: "thr_1", runId: "run_1" })
1357
+ expect(first).not.toHaveProperty("origin")
1358
+
1359
+ // Resolved, then opened again.
1360
+ const resolved = await artifacts.resolveComment({
1361
+ projectId,
1362
+ artifactId: "art_report",
1363
+ id: "cmt_b",
1364
+ resolved: { at: at(3), by: owner },
1365
+ })
1366
+ expect(resolved).toMatchObject({ id: "cmt_b", resolvedAt: at(3), resolvedBy: owner })
1367
+ expect(
1368
+ await artifacts.getComment({ projectId, artifactId: "art_report", id: "cmt_b" })
1369
+ ).toEqual(resolved)
1370
+ const reopened = await artifacts.resolveComment({
1371
+ projectId,
1372
+ artifactId: "art_report",
1373
+ id: "cmt_b",
1374
+ resolved: null,
1375
+ })
1376
+ expect(reopened).toEqual(first)
1377
+ expect(
1378
+ await artifacts.resolveComment({
1379
+ projectId,
1380
+ artifactId: "art_report",
1381
+ id: "cmt_missing",
1382
+ resolved: null,
1383
+ })
1384
+ ).toBeNull()
1385
+
1386
+ // Deleted with its replies.
1387
+ expect(
1388
+ await artifacts.deleteComment({ projectId, artifactId: "art_report", id: "cmt_b" })
1389
+ ).toBe(true)
1390
+ expect(
1391
+ await artifacts.deleteComment({ projectId, artifactId: "art_report", id: "cmt_b" })
1392
+ ).toBe(false)
1393
+ expect(
1394
+ (await artifacts.listComments({ projectId, id: "art_report" })).map(({ id }) => id)
1395
+ ).toEqual(["cmt_a"])
1396
+ })
1397
+ })
1398
+
1399
+ // Regression proof: let a provider take a reply to a reply; the thread then nests, which the
1400
+ // panel cannot show.
1401
+ test("refuses a reply to no comment or to a reply, and a comment past the limit", async () => {
1402
+ await withStorage(async (artifacts) => {
1403
+ await artifacts.create(createInput())
1404
+ const comment = (id: string, parentId?: string) =>
1405
+ artifacts.createComment({
1406
+ projectId,
1407
+ artifactId: "art_report",
1408
+ id,
1409
+ ...(parentId ? { parentId } : {}),
1410
+ anchor: { revision: 1 },
1411
+ body: "Hm",
1412
+ author: owner,
1413
+ createdAt: at(1),
1414
+ })
1415
+ const code = (promise: Promise<unknown>) =>
1416
+ promise.then(
1417
+ () => null,
1418
+ (error: unknown) => (error instanceof ArtifactStorageError ? error.code : error)
1419
+ )
1420
+
1421
+ expect(
1422
+ await code(
1423
+ artifacts.createComment({
1424
+ projectId,
1425
+ artifactId: "art_missing",
1426
+ id: "cmt_x",
1427
+ anchor: { revision: 1 },
1428
+ body: "Hm",
1429
+ author: owner,
1430
+ createdAt: at(1),
1431
+ })
1432
+ )
1433
+ ).toBe("artifact_not_found")
1434
+ await comment("cmt_0")
1435
+ await comment("cmt_reply", "cmt_0")
1436
+ expect(await code(comment("cmt_y", "cmt_missing"))).toBe("comment_not_found")
1437
+ expect(await code(comment("cmt_z", "cmt_reply"))).toBe("comment_not_found")
1438
+
1439
+ for (let index = 2; index < ARTIFACT_COMMENT_LIMITS.maxComments; index += 1) {
1440
+ await comment(`cmt_${index}`)
1441
+ }
1442
+ expect(await code(comment("cmt_over"))).toBe("artifact_comments_full")
1443
+ })
1444
+ })
1445
+
1446
+ // Regression proof: drop the guests' count from a provider's createComment; the guest past
1447
+ // the cap is then stored.
1448
+ test("keeps a guest's comment under the name they gave, up to what guests may write", async () => {
1449
+ await withStorage(async (artifacts) => {
1450
+ await artifacts.create(createInput())
1451
+ const guest = { type: "guest" as const, id: "shs_visitor", name: "Ava Martin" }
1452
+ const comment = (id: string, author: ArtifactCommentAuthor) =>
1453
+ artifacts.createComment({
1454
+ projectId,
1455
+ artifactId: "art_report",
1456
+ id,
1457
+ anchor: { revision: 1 },
1458
+ body: "Hm",
1459
+ author,
1460
+ createdAt: at(1),
1461
+ })
1462
+
1463
+ expect((await comment("cmt_guest_0", guest)).author).toEqual(guest)
1464
+ expect(
1465
+ await artifacts.getComment({ projectId, artifactId: "art_report", id: "cmt_guest_0" })
1466
+ ).toMatchObject({ author: guest })
1467
+
1468
+ for (let index = 1; index < ARTIFACT_COMMENT_LIMITS.maxGuestComments; index += 1) {
1469
+ await comment(`cmt_guest_${index}`, { ...guest, id: `shs_visitor_${index % 3}` })
1470
+ }
1471
+ const refused = await comment("cmt_guest_over", guest).then(
1472
+ () => null,
1473
+ (error: unknown) => (error instanceof ArtifactStorageError ? error.code : error)
1474
+ )
1475
+ expect(refused).toBe("artifact_comments_full")
1476
+
1477
+ // Members keep their room.
1478
+ expect((await comment("cmt_member", owner)).author).toEqual(owner)
1479
+ expect(await artifacts.listComments({ projectId, id: "art_report" })).toHaveLength(
1480
+ ARTIFACT_COMMENT_LIMITS.maxGuestComments + 1
1481
+ )
1482
+ })
1483
+ })
1484
+
1485
+ test("deletes an artifact's comments with it, and copies none", async () => {
1486
+ await withStorage(async (artifacts) => {
1487
+ await artifacts.create(createInput())
1488
+ await artifacts.createComment({
1489
+ projectId,
1490
+ artifactId: "art_report",
1491
+ id: "cmt_1",
1492
+ anchor: { revision: 1 },
1493
+ body: "Hm",
1494
+ author: owner,
1495
+ createdAt: at(1),
1496
+ })
1497
+ await artifacts.copy({
1498
+ projectId,
1499
+ sourceId: "art_report",
1500
+ id: "art_copy",
1501
+ owner,
1502
+ threadId: "thr_fork",
1503
+ })
1504
+ expect(await artifacts.listComments({ projectId, id: "art_copy" })).toEqual([])
1505
+
1506
+ await artifacts.delete({ projectId, id: "art_report" })
1507
+ expect(await artifacts.listComments({ projectId, id: "art_report" })).toEqual([])
1508
+ expect(
1509
+ await artifacts.getComment({ projectId, artifactId: "art_report", id: "cmt_1" })
1510
+ ).toBeNull()
1511
+ })
1512
+ })
1513
+
531
1514
  test("lists versions newest first, a page at a time", async () => {
532
1515
  await withStorage(async (artifacts) => {
533
1516
  await artifacts.create(createInput())
534
- await artifacts.publish(publishInput({ createdAt: at(1) }))
535
- await artifacts.publish(publishInput({ createdAt: at(2) }))
1517
+ await artifacts.freeze({
1518
+ projectId,
1519
+ artifactId: "art_report",
1520
+ frozenAt: at(1),
1521
+ frozenBy: otherOwner,
1522
+ })
1523
+ await artifacts.publish(publishInput({ updatedAt: at(2) }))
1524
+ await artifacts.freeze({
1525
+ projectId,
1526
+ artifactId: "art_report",
1527
+ frozenAt: at(3),
1528
+ frozenBy: otherOwner,
1529
+ })
1530
+ await artifacts.publish(publishInput({ updatedAt: at(4) }))
536
1531
 
537
1532
  const all = await artifacts.listVersions({ projectId, artifactId: "art_report" })
538
1533
  expect(all.versions.map((version) => version.version)).toEqual([3, 2, 1])
@@ -554,10 +1549,10 @@ export function runArtifactStorageContractSuite<TStorage extends ArtifactStorage
554
1549
  })
555
1550
  })
556
1551
 
557
- test("deletes an artifact with every version", async () => {
1552
+ test("deletes an artifact with every version and restore point", async () => {
558
1553
  await withStorage(async (artifacts) => {
559
1554
  await artifacts.create(createInput())
560
- await artifacts.publish(publishInput({ createdAt: at(1) }))
1555
+ await artifacts.publish({ ...publishInput({ updatedAt: at(1) }), turnRunId: "run_1" })
561
1556
 
562
1557
  expect(await artifacts.delete({ projectId: otherProjectId, id: "art_report" })).toBe(false)
563
1558
  expect(await artifacts.delete({ projectId, id: "art_report" })).toBe(true)
@@ -569,61 +1564,8 @@ export function runArtifactStorageContractSuite<TStorage extends ArtifactStorage
569
1564
 
570
1565
  // The id is free again, and numbering starts over for the new artifact.
571
1566
  expect((await artifacts.create(createInput())).version.version).toBe(1)
572
- })
573
- })
574
-
575
- test("deletes a run's versions, repoints latest, and never reuses a number", async () => {
576
- await withStorage(async (artifacts) => {
577
- await artifacts.create(
578
- createInput({ version: versionInput({ origin: { threadId: "thr_1", runId: "run_0" } }) })
579
- )
580
- await artifacts.publish(
581
- publishInput({
582
- title: "Kept",
583
- createdAt: at(1),
584
- origin: { threadId: "thr_1", runId: "run_0" },
585
- })
586
- )
587
- await artifacts.publish(publishInput({ title: "Retried", createdAt: at(2) }))
588
- await artifacts.create(
589
- createInput({ id: "art_new_in_run", version: versionInput({ createdAt: at(2) }) })
590
- )
591
- await artifacts.create(
592
- createInput({
593
- id: "art_other_run",
594
- version: versionInput({ origin: { threadId: "thr_1", runId: "run_9" } }),
595
- })
596
- )
597
- await artifacts.createFrameGrant(frameGrant("a"))
598
- await artifacts.createFrameGrant(frameGrant("b", { artifactId: "art_new_in_run" }))
599
-
600
- expect(
601
- await artifacts.deleteVersionsByOrigin({ projectId: otherProjectId, runId: "run_1" })
602
- ).toBe(0)
603
- expect(await artifacts.deleteVersionsByOrigin({ projectId, runId: "run_1" })).toBe(2)
604
-
605
- expect(await artifacts.get({ projectId, id: "art_report" })).toMatchObject({
606
- title: "Kept",
607
- latestVersion: 2,
608
- updatedAt: at(1),
609
- })
610
- expect(
611
- await artifacts.getVersion({ projectId, artifactId: "art_report", version: 3 })
612
- ).toBeNull()
613
- expect(await artifacts.get({ projectId, id: "art_new_in_run" })).toBeNull()
614
- expect(await artifacts.get({ projectId, id: "art_other_run" })).not.toBeNull()
615
- // A deleted artifact's frame grants go with it; a kept one's stay. To see this fail, delete
616
- // the artifact from the map alone in `InMemoryArtifactStorage.deleteVersionsByOrigin`.
617
- expect(await artifacts.findFrameGrant({ projectId, tokenHash: "b".repeat(64) })).toBeNull()
618
- expect(
619
- await artifacts.findFrameGrant({ projectId, tokenHash: "a".repeat(64) })
620
- ).not.toBeNull()
621
-
622
- // Version 3 belonged to the retried run; the next one is 4, so an address pinned to @3
623
- // can never land on different content.
624
- expect((await artifacts.publish(publishInput({ createdAt: at(3) }))).version.version).toBe(
625
- 4
626
- )
1567
+ expect(await artifacts.listRestorePoints({ projectId, id: "art_report" })).toEqual([])
1568
+ expect(await artifacts.listTurnWrites({ projectId, turnRunId: "run_1" })).toEqual([])
627
1569
  })
628
1570
  })
629
1571
 
@@ -728,6 +1670,82 @@ export function runArtifactStorageContractSuite<TStorage extends ArtifactStorage
728
1670
  })
729
1671
  })
730
1672
 
1673
+ test("keeps a board's pictures by render key, mode, and size, the first one kept staying", async () => {
1674
+ await withStorage(async (artifacts) => {
1675
+ const welcome = "a".repeat(64)
1676
+ const region = "b".repeat(64)
1677
+ const picture = (
1678
+ renderKey: string,
1679
+ theme: "light" | "dark",
1680
+ size: "full" | "small",
1681
+ seed: string,
1682
+ createdAt = t0
1683
+ ) => ({
1684
+ renderKey,
1685
+ theme,
1686
+ size,
1687
+ file: fileRef(seed, size === "full" ? "image/png" : "image/webp"),
1688
+ createdAt,
1689
+ })
1690
+ await artifacts.putBoardPreviews({
1691
+ projectId,
1692
+ previews: [
1693
+ picture(region, "light", "full", "1"),
1694
+ picture(welcome, "dark", "small", "2"),
1695
+ picture(welcome, "light", "full", "3"),
1696
+ picture(welcome, "light", "small", "5"),
1697
+ ],
1698
+ })
1699
+
1700
+ // A key names what the board shows: a second picture of it is of the same page.
1701
+ await artifacts.putBoardPreviews({
1702
+ projectId,
1703
+ previews: [picture(welcome, "light", "full", "4", at(1))],
1704
+ })
1705
+
1706
+ expect(
1707
+ await artifacts.listBoardPreviews({ projectId, renderKeys: [region, welcome, "c"] })
1708
+ ).toEqual([
1709
+ { projectId, ...picture(welcome, "dark", "small", "2") },
1710
+ { projectId, ...picture(welcome, "light", "full", "3") },
1711
+ { projectId, ...picture(welcome, "light", "small", "5") },
1712
+ { projectId, ...picture(region, "light", "full", "1") },
1713
+ ])
1714
+ expect(await artifacts.listBoardPreviews({ projectId, renderKeys: [region] })).toHaveLength(
1715
+ 1
1716
+ )
1717
+ expect(await artifacts.listBoardPreviews({ projectId, renderKeys: [] })).toEqual([])
1718
+ expect(
1719
+ await artifacts.listBoardPreviews({ projectId: otherProjectId, renderKeys: [welcome] })
1720
+ ).toEqual([])
1721
+ })
1722
+ })
1723
+
1724
+ test("keeps a board's pictures when an artifact that showed it is deleted", async () => {
1725
+ await withStorage(async (artifacts) => {
1726
+ // Another version, of this artifact or a copy, may show the same board.
1727
+ await artifacts.create(createInput())
1728
+ const renderKey = "a".repeat(64)
1729
+ await artifacts.putBoardPreviews({
1730
+ projectId,
1731
+ previews: [
1732
+ {
1733
+ renderKey,
1734
+ theme: "light",
1735
+ size: "full",
1736
+ file: fileRef("1", "image/png"),
1737
+ createdAt: t0,
1738
+ },
1739
+ ],
1740
+ })
1741
+
1742
+ expect(await artifacts.delete({ projectId, id: "art_report" })).toBe(true)
1743
+ expect(
1744
+ await artifacts.listBoardPreviews({ projectId, renderKeys: [renderKey] })
1745
+ ).toHaveLength(1)
1746
+ })
1747
+ })
1748
+
731
1749
  test("rolls back with its containing storage transaction", async () => {
732
1750
  await withStorage(async (artifacts, storage) => {
733
1751
  await artifacts.create(createInput())
@@ -736,9 +1754,30 @@ export function runArtifactStorageContractSuite<TStorage extends ArtifactStorage
736
1754
  await expect(
737
1755
  storage.transaction(async (tx) => {
738
1756
  if (!tx.artifacts) throw new Error("Expected artifact storage in the transaction.")
739
- await tx.artifacts.publish(publishInput({ createdAt: at(1) }))
1757
+ await tx.artifacts.publish({
1758
+ ...publishInput({ updatedAt: at(1) }),
1759
+ turnRunId: "run_1",
1760
+ })
1761
+ await tx.artifacts.freeze({
1762
+ projectId,
1763
+ artifactId: "art_report",
1764
+ frozenAt: at(1),
1765
+ frozenBy: otherOwner,
1766
+ })
740
1767
  await tx.artifacts.create(createInput({ id: "art_rolled_back" }))
741
1768
  await tx.artifacts.createFrameGrant(frameGrant("a"))
1769
+ await tx.artifacts.putBoardPreviews({
1770
+ projectId,
1771
+ previews: [
1772
+ {
1773
+ renderKey: "a".repeat(64),
1774
+ theme: "light",
1775
+ size: "full",
1776
+ file: fileRef("1", "image/png"),
1777
+ createdAt: t0,
1778
+ },
1779
+ ],
1780
+ })
742
1781
  await tx.artifacts.setState({
743
1782
  projectId,
744
1783
  artifactId: "art_report",
@@ -747,21 +1786,27 @@ export function runArtifactStorageContractSuite<TStorage extends ArtifactStorage
747
1786
  value: "450",
748
1787
  updatedAt: at(1),
749
1788
  })
750
- expect((await tx.artifacts.get({ projectId, id: "art_report" }))?.latestVersion).toBe(2)
1789
+ expect((await tx.artifacts.get({ projectId, id: "art_report" }))?.revision).toBe(3)
751
1790
  throw rollback
752
1791
  })
753
1792
  ).rejects.toBe(rollback)
754
1793
 
755
- expect((await artifacts.get({ projectId, id: "art_report" }))?.latestVersion).toBe(1)
1794
+ expect((await artifacts.get({ projectId, id: "art_report" }))?.revision).toBe(1)
756
1795
  expect(await artifacts.get({ projectId, id: "art_rolled_back" })).toBeNull()
1796
+ // To see this fail, leave restore points out of `InMemoryArtifactStorage.restore`.
1797
+ expect(await artifacts.listRestorePoints({ projectId, id: "art_report" })).toEqual([])
757
1798
  // To see this fail, leave frame grants out of `InMemoryArtifactStorage.restore`.
758
1799
  expect(await artifacts.findFrameGrant({ projectId, tokenHash: "a".repeat(64) })).toBeNull()
1800
+ // To see this fail, leave board previews out of `InMemoryArtifactStorage.restore`.
1801
+ expect(
1802
+ await artifacts.listBoardPreviews({ projectId, renderKeys: ["a".repeat(64)] })
1803
+ ).toEqual([])
759
1804
  // To see this fail, leave state out of `InMemoryArtifactStorage.restore`.
760
1805
  expect(
761
1806
  await artifacts.listState({ projectId, artifactId: "art_report", principal: owner })
762
1807
  ).toEqual([])
763
- expect((await artifacts.publish(publishInput({ createdAt: at(2) }))).version.version).toBe(
764
- 2
1808
+ expect((await artifacts.publish(publishInput({ updatedAt: at(2) }))).version).toMatchObject(
1809
+ { version: 1, revision: 2 }
765
1810
  )
766
1811
  })
767
1812
  })
@@ -791,11 +1836,14 @@ function createInput(overrides: Partial<CreateArtifactInput> = {}): CreateArtifa
791
1836
  }
792
1837
  }
793
1838
 
794
- function publishInput(overrides: Partial<ArtifactVersionInput> = {}, artifactId = "art_report") {
1839
+ function publishInput(
1840
+ overrides: Partial<ArtifactVersionInput> = {},
1841
+ artifactId = "art_report"
1842
+ ): PublishArtifactVersionInput {
795
1843
  return {
796
1844
  projectId,
797
1845
  artifactId,
798
- kind: "document" as const,
1846
+ kind: "document",
799
1847
  version: versionInput({ origin: agentRun, ...overrides }),
800
1848
  }
801
1849
  }
@@ -809,7 +1857,7 @@ function versionInput(overrides: Partial<ArtifactVersionInput> = {}): ArtifactVe
809
1857
  references: [],
810
1858
  author: owner,
811
1859
  origin: agentRun,
812
- createdAt: t0,
1860
+ updatedAt: t0,
813
1861
  ...overrides,
814
1862
  }
815
1863
  if (input.origin) return input
@@ -826,8 +1874,14 @@ function frameGrant(
826
1874
  tokenHash: seed.repeat(64).slice(0, 64),
827
1875
  artifactId: "art_report",
828
1876
  version: 1,
1877
+ filesDigest: "f".repeat(64),
829
1878
  targets: [
830
- { address: "artifact:art_other/figures/revenue.svg", artifactId: "art_other", version: 3 },
1879
+ { address: "artifact:art_other@3/figures/revenue.svg", artifactId: "art_other", version: 3 },
1880
+ {
1881
+ address: "artifact:art_other/figures/cost.svg",
1882
+ artifactId: "art_other",
1883
+ version: "latest",
1884
+ },
831
1885
  ],
832
1886
  createdAt: t0,
833
1887
  expiresAt: at(60),