@sixb/core 0.2.2 → 0.2.4

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 (1155) hide show
  1. package/dist/actions/index.js +56 -50
  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/cancel.d.ts +1 -1
  9. package/dist/agents/cancel.d.ts.map +1 -1
  10. package/dist/agents/child-question.d.ts +35 -2
  11. package/dist/agents/child-question.d.ts.map +1 -1
  12. package/dist/agents/execution.d.ts +3 -2
  13. package/dist/agents/execution.d.ts.map +1 -1
  14. package/dist/agents/fork.d.ts.map +1 -1
  15. package/dist/agents/ids.d.ts +2 -0
  16. package/dist/agents/ids.d.ts.map +1 -1
  17. package/dist/agents/index.d.ts +4 -4
  18. package/dist/agents/index.d.ts.map +1 -1
  19. package/dist/agents/index.js +91 -76
  20. package/dist/agents/index.js.map +1 -1
  21. package/dist/agents/model-loop.d.ts.map +1 -1
  22. package/dist/agents/request.d.ts +7 -1
  23. package/dist/agents/request.d.ts.map +1 -1
  24. package/dist/agents/run-artifacts.d.ts +73 -10
  25. package/dist/agents/run-artifacts.d.ts.map +1 -1
  26. package/dist/agents/run-session-children.d.ts +9 -0
  27. package/dist/agents/run-session-children.d.ts.map +1 -1
  28. package/dist/agents/run-session-http.d.ts.map +1 -1
  29. package/dist/agents/run-session-serve.d.ts.map +1 -1
  30. package/dist/agents/run-session.d.ts +3 -0
  31. package/dist/agents/run-session.d.ts.map +1 -1
  32. package/dist/agents/streams/index.js +2 -2
  33. package/dist/agents/streams/internal.js +2 -2
  34. package/dist/agents/streams/protocol.d.ts.map +1 -1
  35. package/dist/agents/tool-files.d.ts +1 -1
  36. package/dist/agents/tool-files.d.ts.map +1 -1
  37. package/dist/agents/tool-input-coercion.d.ts +20 -0
  38. package/dist/agents/tool-input-coercion.d.ts.map +1 -0
  39. package/dist/agents/validation.d.ts +1 -1
  40. package/dist/agents/validation.d.ts.map +1 -1
  41. package/dist/artifacts/access.d.ts +37 -17
  42. package/dist/artifacts/access.d.ts.map +1 -1
  43. package/dist/artifacts/canvas-display.d.ts +65 -0
  44. package/dist/artifacts/canvas-display.d.ts.map +1 -0
  45. package/dist/artifacts/canvas.d.ts +6 -1
  46. package/dist/artifacts/canvas.d.ts.map +1 -1
  47. package/dist/artifacts/comment-text.d.ts +19 -0
  48. package/dist/artifacts/comment-text.d.ts.map +1 -0
  49. package/dist/artifacts/comments.d.ts +52 -0
  50. package/dist/artifacts/comments.d.ts.map +1 -0
  51. package/dist/artifacts/errors.d.ts +3 -3
  52. package/dist/artifacts/errors.d.ts.map +1 -1
  53. package/dist/artifacts/events.d.ts +14 -0
  54. package/dist/artifacts/events.d.ts.map +1 -0
  55. package/dist/artifacts/execution.d.ts +129 -22
  56. package/dist/artifacts/execution.d.ts.map +1 -1
  57. package/dist/artifacts/frames/assets.d.ts +12 -1
  58. package/dist/artifacts/frames/assets.d.ts.map +1 -1
  59. package/dist/artifacts/frames/grants.d.ts +8 -5
  60. package/dist/artifacts/frames/grants.d.ts.map +1 -1
  61. package/dist/artifacts/frames/index.d.ts +1 -1
  62. package/dist/artifacts/frames/index.d.ts.map +1 -1
  63. package/dist/artifacts/frames/index.js +32 -964
  64. package/dist/artifacts/frames/index.js.map +4 -8
  65. package/dist/artifacts/frames/kit.d.ts.map +1 -1
  66. package/dist/artifacts/frames/protocol.d.ts +129 -0
  67. package/dist/artifacts/frames/protocol.d.ts.map +1 -1
  68. package/dist/artifacts/frames/runtime.d.ts +24 -7
  69. package/dist/artifacts/frames/runtime.d.ts.map +1 -1
  70. package/dist/artifacts/holders.d.ts +23 -0
  71. package/dist/artifacts/holders.d.ts.map +1 -0
  72. package/dist/artifacts/ids.d.ts +2 -0
  73. package/dist/artifacts/ids.d.ts.map +1 -1
  74. package/dist/artifacts/index.d.ts +6 -4
  75. package/dist/artifacts/index.d.ts.map +1 -1
  76. package/dist/artifacts/index.js +134 -13
  77. package/dist/artifacts/index.js.map +5 -4
  78. package/dist/artifacts/limits.d.ts +24 -3
  79. package/dist/artifacts/limits.d.ts.map +1 -1
  80. package/dist/artifacts/live/board.d.ts +103 -0
  81. package/dist/artifacts/live/board.d.ts.map +1 -0
  82. package/dist/artifacts/live/diff.d.ts +43 -0
  83. package/dist/artifacts/live/diff.d.ts.map +1 -0
  84. package/dist/artifacts/live/document.d.ts +55 -0
  85. package/dist/artifacts/live/document.d.ts.map +1 -0
  86. package/dist/artifacts/live/files.d.ts +16 -0
  87. package/dist/artifacts/live/files.d.ts.map +1 -0
  88. package/dist/artifacts/live/index.d.ts +9 -0
  89. package/dist/artifacts/live/index.d.ts.map +1 -0
  90. package/dist/artifacts/live/index.js +593 -0
  91. package/dist/artifacts/live/index.js.map +10 -0
  92. package/dist/artifacts/live/presence.d.ts +55 -0
  93. package/dist/artifacts/live/presence.d.ts.map +1 -0
  94. package/dist/artifacts/live/protocol.d.ts +109 -0
  95. package/dist/artifacts/live/protocol.d.ts.map +1 -0
  96. package/dist/artifacts/live/protocol.js +21 -0
  97. package/dist/artifacts/live/protocol.js.map +9 -0
  98. package/dist/artifacts/live/server.d.ts +10 -0
  99. package/dist/artifacts/live/server.d.ts.map +1 -0
  100. package/dist/artifacts/live/server.js +86 -0
  101. package/dist/artifacts/live/server.js.map +9 -0
  102. package/dist/artifacts/live/state.d.ts +26 -0
  103. package/dist/artifacts/live/state.d.ts.map +1 -0
  104. package/dist/artifacts/outline.d.ts +11 -0
  105. package/dist/artifacts/outline.d.ts.map +1 -1
  106. package/dist/artifacts/publish/index.d.ts +8 -1
  107. package/dist/artifacts/publish/index.d.ts.map +1 -1
  108. package/dist/artifacts/publish/index.js +62 -34
  109. package/dist/artifacts/publish/index.js.map +1 -1
  110. package/dist/artifacts/publish/merge.d.ts +75 -0
  111. package/dist/artifacts/publish/merge.d.ts.map +1 -0
  112. package/dist/artifacts/publish/previews.d.ts +153 -0
  113. package/dist/artifacts/publish/previews.d.ts.map +1 -0
  114. package/dist/artifacts/publish/publish.d.ts +29 -8
  115. package/dist/artifacts/publish/publish.d.ts.map +1 -1
  116. package/dist/artifacts/publish/query-answers.d.ts +20 -0
  117. package/dist/artifacts/publish/query-answers.d.ts.map +1 -0
  118. package/dist/artifacts/publish/references.d.ts +4 -3
  119. package/dist/artifacts/publish/references.d.ts.map +1 -1
  120. package/dist/artifacts/publish/validate/canvas.d.ts.map +1 -1
  121. package/dist/artifacts/theme.d.ts +5 -1
  122. package/dist/artifacts/theme.d.ts.map +1 -1
  123. package/dist/auth/directory.d.ts +33 -0
  124. package/dist/auth/directory.d.ts.map +1 -0
  125. package/dist/auth/index.js +13 -12
  126. package/dist/auth/index.js.map +1 -1
  127. package/dist/auth/member-events.d.ts +5 -1
  128. package/dist/auth/member-events.d.ts.map +1 -1
  129. package/dist/auth/runtime.d.ts +22 -1
  130. package/dist/auth/runtime.d.ts.map +1 -1
  131. package/dist/auth/strategy.d.ts +2 -2
  132. package/dist/auth/strategy.d.ts.map +1 -1
  133. package/dist/auth/types.d.ts +42 -1
  134. package/dist/auth/types.d.ts.map +1 -1
  135. package/dist/authorization/decision.d.ts +6 -5
  136. package/dist/authorization/decision.d.ts.map +1 -1
  137. package/dist/authorization/event-visibility.d.ts.map +1 -1
  138. package/dist/authorization/index.js +7 -6
  139. package/dist/authorization/index.js.map +1 -1
  140. package/dist/blob-storage/index.js +4 -4
  141. package/dist/blob-storage/index.js.map +1 -1
  142. package/dist/bootstrap/index.js +63 -57
  143. package/dist/bootstrap/index.js.map +2 -2
  144. package/dist/broker/in-memory.d.ts.map +1 -1
  145. package/dist/broker/index.js +1 -1
  146. package/dist/broker/types.d.ts +4 -0
  147. package/dist/broker/types.d.ts.map +1 -1
  148. package/dist/{chunk-s7j8ewqv.js → chunk-0k3r5kb3.js} +257 -43
  149. package/dist/{chunk-s7j8ewqv.js.map → chunk-0k3r5kb3.js.map} +14 -13
  150. package/dist/{chunk-e5wf5vz0.js → chunk-0kgrghqx.js} +13 -1
  151. package/dist/chunk-0kgrghqx.js.map +10 -0
  152. package/dist/{chunk-80gym75n.js → chunk-186k5yz3.js} +1 -1
  153. package/dist/chunk-191jz8a6.js +61 -0
  154. package/dist/chunk-191jz8a6.js.map +10 -0
  155. package/dist/{chunk-mmagke4x.js → chunk-22d3qg4x.js} +2 -2
  156. package/dist/{chunk-mmagke4x.js.map → chunk-22d3qg4x.js.map} +3 -3
  157. package/dist/{chunk-ga63a3dz.js → chunk-2bn6813a.js} +3 -3
  158. package/dist/chunk-2c4j899j.js.map +2 -2
  159. package/dist/{chunk-e6xgz4h4.js → chunk-3014rfjz.js} +197 -18
  160. package/dist/chunk-3014rfjz.js.map +21 -0
  161. package/dist/{chunk-ytzcxtpt.js → chunk-3ba89vm7.js} +1 -1
  162. package/dist/chunk-3hzhcfsv.js +139 -0
  163. package/dist/chunk-3hzhcfsv.js.map +10 -0
  164. package/dist/chunk-3sgvd10b.js +69 -0
  165. package/dist/chunk-3sgvd10b.js.map +10 -0
  166. package/dist/chunk-3z1vxzcm.js +234 -0
  167. package/dist/chunk-3z1vxzcm.js.map +12 -0
  168. package/dist/{chunk-djs3hw9p.js → chunk-3zagkr6w.js} +73 -6
  169. package/dist/chunk-3zagkr6w.js.map +21 -0
  170. package/dist/{chunk-wkq3kvzd.js → chunk-48c1z8nj.js} +6 -6
  171. package/dist/chunk-48c1z8nj.js.map +10 -0
  172. package/dist/{chunk-d04g36fw.js → chunk-5qqmndhm.js} +1 -1
  173. package/dist/{chunk-scyq22td.js → chunk-5rqqp8cr.js} +19 -4
  174. package/dist/chunk-5rqqp8cr.js.map +12 -0
  175. package/dist/chunk-6ef4esq4.js +225 -0
  176. package/dist/chunk-6ef4esq4.js.map +11 -0
  177. package/dist/{chunk-jspskey0.js → chunk-7j4yydm2.js} +67 -45
  178. package/dist/chunk-7j4yydm2.js.map +11 -0
  179. package/dist/chunk-7kpqntgw.js +70 -0
  180. package/dist/chunk-7kpqntgw.js.map +10 -0
  181. package/dist/{chunk-5wtnmpze.js → chunk-7qe46788.js} +1 -1
  182. package/dist/{chunk-31kcqmhf.js → chunk-855w9nvw.js} +1 -1
  183. package/dist/{chunk-e7v3trpz.js → chunk-8a8k38tz.js} +4 -3
  184. package/dist/chunk-8a8k38tz.js.map +10 -0
  185. package/dist/chunk-8bns0y68.js +1322 -0
  186. package/dist/chunk-8bns0y68.js.map +25 -0
  187. package/dist/{chunk-jftd33rc.js → chunk-8t2ynwg0.js} +105 -9
  188. package/dist/chunk-8t2ynwg0.js.map +11 -0
  189. package/dist/{chunk-9whfmsfk.js → chunk-8tqnsx3q.js} +1 -1
  190. package/dist/{chunk-s3we74h8.js → chunk-9nsjjd44.js} +38 -5
  191. package/dist/chunk-9nsjjd44.js.map +12 -0
  192. package/dist/{chunk-hz5d43gn.js → chunk-9vsc919v.js} +14 -6
  193. package/dist/chunk-9vsc919v.js.map +10 -0
  194. package/dist/{chunk-waqk73p1.js → chunk-a6fjkcne.js} +185 -341
  195. package/dist/{chunk-waqk73p1.js.map → chunk-a6fjkcne.js.map} +6 -7
  196. package/dist/chunk-az95tsh3.js.map +2 -2
  197. package/dist/{chunk-s038wa5v.js → chunk-b9qfh2ya.js} +1 -1
  198. package/dist/{chunk-5taem5aw.js → chunk-bc3y6gff.js} +13 -4
  199. package/dist/chunk-bc3y6gff.js.map +10 -0
  200. package/dist/chunk-bz5bnjjt.js +358 -0
  201. package/dist/chunk-bz5bnjjt.js.map +12 -0
  202. package/dist/{chunk-w976a4me.js → chunk-czct88ht.js} +28 -4
  203. package/dist/chunk-czct88ht.js.map +10 -0
  204. package/dist/{chunk-5kyvrtjh.js → chunk-d9xbwh3h.js} +131 -32
  205. package/dist/chunk-d9xbwh3h.js.map +13 -0
  206. package/dist/{chunk-kfee1h52.js → chunk-dfveegqq.js} +28 -8
  207. package/dist/chunk-dfveegqq.js.map +13 -0
  208. package/dist/{chunk-2g0r46hy.js → chunk-dhkc9b23.js} +15 -2
  209. package/dist/chunk-dhkc9b23.js.map +12 -0
  210. package/dist/chunk-dmnd9ea6.js +106 -0
  211. package/dist/chunk-dmnd9ea6.js.map +10 -0
  212. package/dist/{chunk-nz7815t3.js → chunk-e0hnbb1m.js} +27 -2
  213. package/dist/chunk-e0hnbb1m.js.map +14 -0
  214. package/dist/chunk-e91fmg6t.js +288 -0
  215. package/dist/chunk-e91fmg6t.js.map +11 -0
  216. package/dist/{chunk-3sqqhpr7.js → chunk-evj5jxz3.js} +134 -19
  217. package/dist/{chunk-3sqqhpr7.js.map → chunk-evj5jxz3.js.map} +11 -10
  218. package/dist/{chunk-w122ymx4.js → chunk-f6ahf5gf.js} +15 -4
  219. package/dist/{chunk-w122ymx4.js.map → chunk-f6ahf5gf.js.map} +3 -3
  220. package/dist/{chunk-jjmggm9a.js → chunk-fe6r7yhg.js} +1 -1
  221. package/dist/{chunk-165c9wm6.js → chunk-g2ph4873.js} +1 -1
  222. package/dist/{chunk-dsv783c3.js → chunk-gxwy4c3s.js} +203 -57
  223. package/dist/chunk-gxwy4c3s.js.map +47 -0
  224. package/dist/chunk-hgj98cbb.js +22 -0
  225. package/dist/chunk-hgj98cbb.js.map +10 -0
  226. package/dist/chunk-hn2r7z41.js.map +3 -3
  227. package/dist/chunk-hvbvq7p4.js +1553 -0
  228. package/dist/chunk-hvbvq7p4.js.map +18 -0
  229. package/dist/chunk-j0wgh8gv.js +250 -0
  230. package/dist/chunk-j0wgh8gv.js.map +10 -0
  231. package/dist/{chunk-z8fx5cgb.js → chunk-j2zm215x.js} +37 -3
  232. package/dist/chunk-j2zm215x.js.map +12 -0
  233. package/dist/{chunk-j1ny5fwh.js → chunk-k1g14kk3.js} +11 -83
  234. package/dist/{chunk-j1ny5fwh.js.map → chunk-k1g14kk3.js.map} +4 -5
  235. package/dist/chunk-kr6dx38r.js +25 -0
  236. package/dist/chunk-kr6dx38r.js.map +10 -0
  237. package/dist/chunk-m2jerfef.js +474 -0
  238. package/dist/chunk-m2jerfef.js.map +11 -0
  239. package/dist/{chunk-m2vh8gh0.js → chunk-msyevpp3.js} +62 -15
  240. package/dist/{chunk-m2vh8gh0.js.map → chunk-msyevpp3.js.map} +5 -5
  241. package/dist/{chunk-escedwyt.js → chunk-mvz89age.js} +6 -1
  242. package/dist/{chunk-escedwyt.js.map → chunk-mvz89age.js.map} +3 -3
  243. package/dist/chunk-mwcqz3e3.js +30 -0
  244. package/dist/chunk-mwcqz3e3.js.map +10 -0
  245. package/dist/chunk-n2ay51px.js +21 -0
  246. package/dist/chunk-n2ay51px.js.map +10 -0
  247. package/dist/chunk-n4zzaf6q.js.map +1 -1
  248. package/dist/{chunk-gkv8r794.js → chunk-n68vz95m.js} +5 -5
  249. package/dist/{chunk-gkv8r794.js.map → chunk-n68vz95m.js.map} +3 -3
  250. package/dist/{chunk-0j3crh1w.js → chunk-p351afzm.js} +14 -14
  251. package/dist/{chunk-0j3crh1w.js.map → chunk-p351afzm.js.map} +4 -4
  252. package/dist/{chunk-c7cfe31p.js → chunk-p8pgnq8d.js} +16 -16
  253. package/dist/{chunk-c7cfe31p.js.map → chunk-p8pgnq8d.js.map} +1 -1
  254. package/dist/chunk-pk539cwv.js +370 -0
  255. package/dist/chunk-pk539cwv.js.map +11 -0
  256. package/dist/{chunk-jbw70d6t.js → chunk-ppxf7gw2.js} +52 -10
  257. package/dist/chunk-ppxf7gw2.js.map +11 -0
  258. package/dist/{chunk-9x8dybsb.js → chunk-pvpq483h.js} +10 -2
  259. package/dist/chunk-pvpq483h.js.map +10 -0
  260. package/dist/{chunk-4zm1k3xj.js → chunk-r2psmn42.js} +1 -1
  261. package/dist/{chunk-a7aa0nzj.js → chunk-r9rtavg9.js} +14 -14
  262. package/dist/{chunk-a7aa0nzj.js.map → chunk-r9rtavg9.js.map} +1 -1
  263. package/dist/{chunk-w1btn96n.js → chunk-rsrc7vtw.js} +523 -254
  264. package/dist/chunk-rsrc7vtw.js.map +49 -0
  265. package/dist/{chunk-2ajw5rz0.js → chunk-rsxb14an.js} +3 -3
  266. package/dist/{chunk-kkjfve0t.js → chunk-rt9deb92.js} +4 -3
  267. package/dist/{chunk-kkjfve0t.js.map → chunk-rt9deb92.js.map} +3 -3
  268. package/dist/{chunk-r1cxq7vv.js → chunk-rtdrm592.js} +2 -2
  269. package/dist/{chunk-a5v4gjdx.js → chunk-rtm1jq00.js} +460 -227
  270. package/dist/{chunk-a5v4gjdx.js.map → chunk-rtm1jq00.js.map} +25 -22
  271. package/dist/{chunk-4bm0caep.js → chunk-smnt672s.js} +1 -1
  272. package/dist/{chunk-21q0j5f2.js → chunk-stmxh0hv.js} +2 -2
  273. package/dist/{chunk-nh26e7c5.js → chunk-sysnvjce.js} +5 -5
  274. package/dist/{chunk-nh26e7c5.js.map → chunk-sysnvjce.js.map} +3 -3
  275. package/dist/{chunk-7z5rkf0m.js → chunk-t0s7b3d1.js} +4 -3
  276. package/dist/{chunk-7z5rkf0m.js.map → chunk-t0s7b3d1.js.map} +3 -3
  277. package/dist/{chunk-57g0215c.js → chunk-t24yktqr.js} +296 -7
  278. package/dist/{chunk-57g0215c.js.map → chunk-t24yktqr.js.map} +6 -3
  279. package/dist/{chunk-mbc5hvnj.js → chunk-td26wjr5.js} +18 -7
  280. package/dist/{chunk-mbc5hvnj.js.map → chunk-td26wjr5.js.map} +3 -3
  281. package/dist/{chunk-ff5xkv0p.js → chunk-tfzvjdms.js} +1 -1
  282. package/dist/{chunk-f1h34y3r.js → chunk-vepea5c3.js} +6 -6
  283. package/dist/{chunk-f1h34y3r.js.map → chunk-vepea5c3.js.map} +1 -1
  284. package/dist/chunk-vtjzwymr.js +37 -0
  285. package/dist/chunk-vtjzwymr.js.map +10 -0
  286. package/dist/{chunk-twfreyxr.js → chunk-vzkxqf8h.js} +23 -13
  287. package/dist/{chunk-twfreyxr.js.map → chunk-vzkxqf8h.js.map} +6 -6
  288. package/dist/{chunk-eqgr6nsa.js → chunk-w1wq7gfr.js} +983 -185
  289. package/dist/chunk-w1wq7gfr.js.map +75 -0
  290. package/dist/{chunk-6b61s40c.js → chunk-w3t94hm6.js} +1 -1
  291. package/dist/{chunk-fwsvshr5.js → chunk-wa05txmk.js} +20 -7
  292. package/dist/{chunk-fwsvshr5.js.map → chunk-wa05txmk.js.map} +3 -3
  293. package/dist/chunk-whbwf3np.js +12 -0
  294. package/dist/chunk-whbwf3np.js.map +10 -0
  295. package/dist/{chunk-t5608tkq.js → chunk-yv8hv4wq.js} +3 -1
  296. package/dist/{chunk-t5608tkq.js.map → chunk-yv8hv4wq.js.map} +3 -3
  297. package/dist/{chunk-j8thxj7w.js → chunk-yy914zfr.js} +1218 -101
  298. package/dist/chunk-yy914zfr.js.map +30 -0
  299. package/dist/connectors/builders.d.ts +2 -2
  300. package/dist/connectors/builders.d.ts.map +1 -1
  301. package/dist/connectors/connections/access.d.ts +11 -0
  302. package/dist/connectors/connections/access.d.ts.map +1 -0
  303. package/dist/connectors/connections/contracts.d.ts +6 -1
  304. package/dist/connectors/connections/contracts.d.ts.map +1 -1
  305. package/dist/connectors/connections/internal.js +1 -1
  306. package/dist/connectors/connections/runs.d.ts +6 -0
  307. package/dist/connectors/connections/runs.d.ts.map +1 -1
  308. package/dist/connectors/connections/service.d.ts +25 -0
  309. package/dist/connectors/connections/service.d.ts.map +1 -1
  310. package/dist/connectors/connections/views.d.ts +1 -1
  311. package/dist/connectors/connections/views.d.ts.map +1 -1
  312. package/dist/connectors/execution.d.ts.map +1 -1
  313. package/dist/connectors/index.d.ts +1 -1
  314. package/dist/connectors/index.d.ts.map +1 -1
  315. package/dist/connectors/service.d.ts +3 -0
  316. package/dist/connectors/service.d.ts.map +1 -1
  317. package/dist/connectors/types.d.ts +21 -2
  318. package/dist/connectors/types.d.ts.map +1 -1
  319. package/dist/datasets/execution.d.ts +12 -6
  320. package/dist/datasets/execution.d.ts.map +1 -1
  321. package/dist/datasets/ingest-flush-batch.d.ts +59 -0
  322. package/dist/datasets/ingest-flush-batch.d.ts.map +1 -0
  323. package/dist/datasets/ingest-flush-job.d.ts +33 -0
  324. package/dist/datasets/ingest-flush-job.d.ts.map +1 -0
  325. package/dist/datasets/ingest-flush.d.ts +66 -0
  326. package/dist/datasets/ingest-flush.d.ts.map +1 -0
  327. package/dist/datasets/produced-version.d.ts +21 -0
  328. package/dist/datasets/produced-version.d.ts.map +1 -0
  329. package/dist/datasets/write.d.ts +22 -1
  330. package/dist/datasets/write.d.ts.map +1 -1
  331. package/dist/datasets/write.js +8 -4
  332. package/dist/datasets/write.js.map +1 -1
  333. package/dist/deploy/internal.js +5 -4
  334. package/dist/deploy/internal.js.map +4 -4
  335. package/dist/deploy/types.d.ts +2 -3
  336. package/dist/deploy/types.d.ts.map +1 -1
  337. package/dist/error-reporting/capability.d.ts +8 -2
  338. package/dist/error-reporting/capability.d.ts.map +1 -1
  339. package/dist/error-reporting/internal.d.ts +1 -1
  340. package/dist/error-reporting/internal.d.ts.map +1 -1
  341. package/dist/error-reporting/internal.js +17 -5
  342. package/dist/error-reporting/internal.js.map +1 -1
  343. package/dist/error-reporting/reporter.d.ts.map +1 -1
  344. package/dist/error-reporting/reports.d.ts +55 -0
  345. package/dist/error-reporting/reports.d.ts.map +1 -1
  346. package/dist/error-reporting/types.d.ts +82 -1
  347. package/dist/error-reporting/types.d.ts.map +1 -1
  348. package/dist/errors/catalog.d.ts +5 -0
  349. package/dist/errors/catalog.d.ts.map +1 -1
  350. package/dist/errors/internal.js +1 -1
  351. package/dist/events/definitions.d.ts +4 -0
  352. package/dist/events/definitions.d.ts.map +1 -1
  353. package/dist/events/execution.d.ts +1 -0
  354. package/dist/events/execution.d.ts.map +1 -1
  355. package/dist/events/index.d.ts +1 -1
  356. package/dist/events/index.d.ts.map +1 -1
  357. package/dist/events/index.js +5 -5
  358. package/dist/events/scope.d.ts.map +1 -1
  359. package/dist/events/scope.js +1 -1
  360. package/dist/events/selectors/index.js +2 -2
  361. package/dist/events/types/artifacts.d.ts +38 -0
  362. package/dist/events/types/artifacts.d.ts.map +1 -0
  363. package/dist/events/types/index.d.ts +3 -1
  364. package/dist/events/types/index.d.ts.map +1 -1
  365. package/dist/events/types/users.d.ts +5 -2
  366. package/dist/events/types/users.d.ts.map +1 -1
  367. package/dist/execution/agent.js +58 -52
  368. package/dist/execution/agent.js.map +1 -1
  369. package/dist/execution/authorized-object-reader.d.ts +10 -0
  370. package/dist/execution/authorized-object-reader.d.ts.map +1 -1
  371. package/dist/execution/object-reader-clearance.d.ts +6 -0
  372. package/dist/execution/object-reader-clearance.d.ts.map +1 -1
  373. package/dist/execution/object-reader-security.d.ts +9 -2
  374. package/dist/execution/object-reader-security.d.ts.map +1 -1
  375. package/dist/execution/primitive.js +56 -50
  376. package/dist/execution/primitive.js.map +1 -1
  377. package/dist/execution/request.js +50 -44
  378. package/dist/execution/request.js.map +2 -2
  379. package/dist/http/api-routes.d.ts +1 -1
  380. package/dist/http/api-routes.d.ts.map +1 -1
  381. package/dist/http/index.js +1 -1
  382. package/dist/index.d.ts +10 -8
  383. package/dist/index.d.ts.map +1 -1
  384. package/dist/index.js +96 -88
  385. package/dist/index.js.map +1 -1
  386. package/dist/lake-storage/errors.d.ts +15 -0
  387. package/dist/lake-storage/errors.d.ts.map +1 -1
  388. package/dist/lake-storage/index.d.ts +3 -2
  389. package/dist/lake-storage/index.d.ts.map +1 -1
  390. package/dist/lake-storage/index.js +16 -10
  391. package/dist/lake-storage/index.js.map +1 -1
  392. package/dist/lake-storage/maintenance.d.ts +88 -0
  393. package/dist/lake-storage/maintenance.d.ts.map +1 -0
  394. package/dist/lake-storage/merge.d.ts +3 -1
  395. package/dist/lake-storage/merge.d.ts.map +1 -1
  396. package/dist/lake-storage/source-ordering.d.ts +23 -0
  397. package/dist/lake-storage/source-ordering.d.ts.map +1 -1
  398. package/dist/lake-storage/types.d.ts +10 -0
  399. package/dist/lake-storage/types.d.ts.map +1 -1
  400. package/dist/maintenance/heartbeat.d.ts +5 -0
  401. package/dist/maintenance/heartbeat.d.ts.map +1 -0
  402. package/dist/maintenance/index.d.ts +4 -2
  403. package/dist/maintenance/index.d.ts.map +1 -1
  404. package/dist/maintenance/index.js +515 -0
  405. package/dist/maintenance/index.js.map +16 -0
  406. package/dist/maintenance/lake-retention-status.d.ts +36 -0
  407. package/dist/maintenance/lake-retention-status.d.ts.map +1 -0
  408. package/dist/maintenance/lake-retention.d.ts +84 -0
  409. package/dist/maintenance/lake-retention.d.ts.map +1 -0
  410. package/dist/maintenance/loop.d.ts +95 -0
  411. package/dist/maintenance/loop.d.ts.map +1 -0
  412. package/dist/maintenance/ontology-maintenance.d.ts +17 -16
  413. package/dist/maintenance/ontology-maintenance.d.ts.map +1 -1
  414. package/dist/maintenance/passes/cron-pass.d.ts +21 -0
  415. package/dist/maintenance/passes/cron-pass.d.ts.map +1 -0
  416. package/dist/maintenance/passes/directory-pass.d.ts +12 -0
  417. package/dist/maintenance/passes/directory-pass.d.ts.map +1 -0
  418. package/dist/maintenance/passes/ingest-pass.d.ts +26 -0
  419. package/dist/maintenance/passes/ingest-pass.d.ts.map +1 -0
  420. package/dist/maintenance/passes/lake-change-feed.d.ts +38 -0
  421. package/dist/maintenance/passes/lake-change-feed.d.ts.map +1 -0
  422. package/dist/maintenance/passes/lake-retention-pass.d.ts +20 -0
  423. package/dist/maintenance/passes/lake-retention-pass.d.ts.map +1 -0
  424. package/dist/maintenance/passes/ontology-pass.d.ts +8 -0
  425. package/dist/maintenance/passes/ontology-pass.d.ts.map +1 -0
  426. package/dist/maintenance/passes/projections-pass.d.ts +26 -0
  427. package/dist/maintenance/passes/projections-pass.d.ts.map +1 -0
  428. package/dist/maintenance/passes/recovery-pass.d.ts +6 -0
  429. package/dist/maintenance/passes/recovery-pass.d.ts.map +1 -0
  430. package/dist/maintenance/passes/recovery-passes.d.ts +24 -0
  431. package/dist/maintenance/passes/recovery-passes.d.ts.map +1 -0
  432. package/dist/maintenance/passes/runs-pass.d.ts +6 -0
  433. package/dist/maintenance/passes/runs-pass.d.ts.map +1 -0
  434. package/dist/maintenance/passes/triggers-pass.d.ts +41 -0
  435. package/dist/maintenance/passes/triggers-pass.d.ts.map +1 -0
  436. package/dist/maintenance/status.d.ts +19 -0
  437. package/dist/maintenance/status.d.ts.map +1 -0
  438. package/dist/maintenance/types.d.ts +25 -24
  439. package/dist/maintenance/types.d.ts.map +1 -1
  440. package/dist/materialization/model.d.ts +11 -2
  441. package/dist/materialization/model.d.ts.map +1 -1
  442. package/dist/materializer/edits/artifact-refs.d.ts +33 -0
  443. package/dist/materializer/edits/artifact-refs.d.ts.map +1 -0
  444. package/dist/materializer/edits/commit.d.ts.map +1 -1
  445. package/dist/materializer/edits/operations.d.ts +7 -1
  446. package/dist/materializer/edits/operations.d.ts.map +1 -1
  447. package/dist/materializer/edits/plan.d.ts.map +1 -1
  448. package/dist/materializer/execution/work-records.d.ts +6 -0
  449. package/dist/materializer/execution/work-records.d.ts.map +1 -1
  450. package/dist/materializer/index.js +31 -28
  451. package/dist/materializer/index.js.map +1 -1
  452. package/dist/materializer/projections/replacement-plan.d.ts.map +1 -1
  453. package/dist/materializer/shared/normalize.d.ts.map +1 -1
  454. package/dist/materializer/telemetry/plan.d.ts.map +1 -1
  455. package/dist/models/execution/index.js +30 -27
  456. package/dist/models/execution/index.js.map +1 -1
  457. package/dist/models/language-model.d.ts +6 -0
  458. package/dist/models/language-model.d.ts.map +1 -1
  459. package/dist/models/tools.d.ts +2 -0
  460. package/dist/models/tools.d.ts.map +1 -1
  461. package/dist/objects/artifact-refs.d.ts +5 -0
  462. package/dist/objects/artifact-refs.d.ts.map +1 -0
  463. package/dist/objects/index.js +59 -54
  464. package/dist/objects/index.js.map +1 -1
  465. package/dist/objects/materializer-adapter.d.ts +4 -3
  466. package/dist/objects/materializer-adapter.d.ts.map +1 -1
  467. package/dist/objects/object/upsert-batch.d.ts.map +1 -1
  468. package/dist/objects/object/upsert.d.ts.map +1 -1
  469. package/dist/objects/query/index.js +29 -26
  470. package/dist/objects/query/index.js.map +1 -1
  471. package/dist/objects/query/ir.d.ts +3 -1
  472. package/dist/objects/query/ir.d.ts.map +1 -1
  473. package/dist/objects/query/scalar-values.d.ts.map +1 -1
  474. package/dist/objects/runtime-batch.d.ts +2 -0
  475. package/dist/objects/runtime-batch.d.ts.map +1 -1
  476. package/dist/ontology/artifact-ref.d.ts +36 -0
  477. package/dist/ontology/artifact-ref.d.ts.map +1 -0
  478. package/dist/ontology/docs-markdown.d.ts.map +1 -1
  479. package/dist/ontology/index.d.ts +3 -1
  480. package/dist/ontology/index.d.ts.map +1 -1
  481. package/dist/ontology/index.js +8 -5
  482. package/dist/ontology/index.js.map +1 -1
  483. package/dist/ontology/inference/index.d.ts +2 -0
  484. package/dist/ontology/inference/index.d.ts.map +1 -1
  485. package/dist/ontology/internal.js +7 -6
  486. package/dist/ontology/internal.js.map +1 -1
  487. package/dist/ontology/json-schema.d.ts.map +1 -1
  488. package/dist/ontology/primitives.d.ts.map +1 -1
  489. package/dist/ontology/reference-values.d.ts +10 -0
  490. package/dist/ontology/reference-values.d.ts.map +1 -0
  491. package/dist/ontology/refs.d.ts +6 -1
  492. package/dist/ontology/refs.d.ts.map +1 -1
  493. package/dist/ontology/registry.d.ts +9 -1
  494. package/dist/ontology/registry.d.ts.map +1 -1
  495. package/dist/ontology/types.d.ts +2 -1
  496. package/dist/ontology/types.d.ts.map +1 -1
  497. package/dist/ontology/user-ref.d.ts +16 -0
  498. package/dist/ontology/user-ref.d.ts.map +1 -1
  499. package/dist/ontology/validation/normalize.d.ts.map +1 -1
  500. package/dist/ontology/validation/properties.d.ts.map +1 -1
  501. package/dist/ontology/validation/schema.d.ts.map +1 -1
  502. package/dist/pending-tasks.d.ts +17 -0
  503. package/dist/pending-tasks.d.ts.map +1 -0
  504. package/dist/pipelines/index.js +37 -34
  505. package/dist/pipelines/index.js.map +1 -1
  506. package/dist/pipelines/run-dispatch.d.ts +6 -0
  507. package/dist/pipelines/run-dispatch.d.ts.map +1 -1
  508. package/dist/predicates/types.d.ts +4 -0
  509. package/dist/predicates/types.d.ts.map +1 -1
  510. package/dist/projections/builders.d.ts +13 -11
  511. package/dist/projections/builders.d.ts.map +1 -1
  512. package/dist/projections/internal.js +30 -27
  513. package/dist/projections/internal.js.map +1 -1
  514. package/dist/projections/types.d.ts +1 -1
  515. package/dist/projections/types.d.ts.map +1 -1
  516. package/dist/projections/validation.d.ts +2 -2
  517. package/dist/projections/validation.d.ts.map +1 -1
  518. package/dist/queues/in-memory.d.ts +6 -1
  519. package/dist/queues/in-memory.d.ts.map +1 -1
  520. package/dist/queues/index.d.ts +1 -1
  521. package/dist/queues/index.d.ts.map +1 -1
  522. package/dist/queues/index.js +1 -1
  523. package/dist/queues/types.d.ts +55 -2
  524. package/dist/queues/types.d.ts.map +1 -1
  525. package/dist/runtime/create.d.ts +3 -0
  526. package/dist/runtime/create.d.ts.map +1 -1
  527. package/dist/runtime/host.d.ts +22 -5
  528. package/dist/runtime/host.d.ts.map +1 -1
  529. package/dist/runtime/index.d.ts +0 -1
  530. package/dist/runtime/index.d.ts.map +1 -1
  531. package/dist/runtime/internal.d.ts +6 -0
  532. package/dist/runtime/internal.d.ts.map +1 -1
  533. package/dist/runtime/internal.js +52 -31
  534. package/dist/runtime/internal.js.map +1 -1
  535. package/dist/runtime/sixb.d.ts +6 -1
  536. package/dist/runtime/sixb.d.ts.map +1 -1
  537. package/dist/sandboxes/index.js +8 -7
  538. package/dist/sandboxes/index.js.map +1 -1
  539. package/dist/scheduler/index.d.ts +0 -2
  540. package/dist/scheduler/index.d.ts.map +1 -1
  541. package/dist/scheduler/index.js +3 -6
  542. package/dist/scheduler/index.js.map +1 -1
  543. package/dist/schedules/index.js +9 -11
  544. package/dist/schedules/index.js.map +1 -1
  545. package/dist/security/internal.js +1 -1
  546. package/dist/shared/backoff.d.ts +12 -0
  547. package/dist/shared/backoff.d.ts.map +1 -0
  548. package/dist/shared/duration.d.ts +3 -0
  549. package/dist/shared/duration.d.ts.map +1 -0
  550. package/dist/shared/params/artifact-refs.d.ts +19 -0
  551. package/dist/shared/params/artifact-refs.d.ts.map +1 -0
  552. package/dist/shares/guest-name.d.ts +8 -0
  553. package/dist/shares/guest-name.d.ts.map +1 -0
  554. package/dist/shares/internal.d.ts +1 -0
  555. package/dist/shares/internal.d.ts.map +1 -1
  556. package/dist/shares/internal.js +69 -28
  557. package/dist/shares/internal.js.map +3 -3
  558. package/dist/shares/session-protocol.d.ts +13 -0
  559. package/dist/shares/session-protocol.d.ts.map +1 -1
  560. package/dist/storage/action-runs/failure.js +2 -2
  561. package/dist/storage/agents/provider.js +1 -1
  562. package/dist/storage/agents/types.d.ts +1 -1
  563. package/dist/storage/agents/types.d.ts.map +1 -1
  564. package/dist/storage/ai-limits/enforcement.js +2 -2
  565. package/dist/storage/artifacts/errors.d.ts +9 -4
  566. package/dist/storage/artifacts/errors.d.ts.map +1 -1
  567. package/dist/storage/artifacts/in-memory.d.ts +27 -4
  568. package/dist/storage/artifacts/in-memory.d.ts.map +1 -1
  569. package/dist/storage/artifacts/index.d.ts +1 -1
  570. package/dist/storage/artifacts/index.d.ts.map +1 -1
  571. package/dist/storage/artifacts/record.d.ts +39 -2
  572. package/dist/storage/artifacts/record.d.ts.map +1 -1
  573. package/dist/storage/artifacts/types.d.ts +328 -39
  574. package/dist/storage/artifacts/types.d.ts.map +1 -1
  575. package/dist/storage/auth/in-memory/auth-storage.d.ts +2 -1
  576. package/dist/storage/auth/in-memory/auth-storage.d.ts.map +1 -1
  577. package/dist/storage/auth/in-memory/identities.d.ts +4 -0
  578. package/dist/storage/auth/in-memory/identities.d.ts.map +1 -1
  579. package/dist/storage/auth/in-memory/shared.d.ts +3 -1
  580. package/dist/storage/auth/in-memory/shared.d.ts.map +1 -1
  581. package/dist/storage/auth/in-memory/users.d.ts.map +1 -1
  582. package/dist/storage/auth/index.d.ts +1 -1
  583. package/dist/storage/auth/index.d.ts.map +1 -1
  584. package/dist/storage/auth/types.d.ts +39 -0
  585. package/dist/storage/auth/types.d.ts.map +1 -1
  586. package/dist/storage/connector-connections/in-memory.d.ts +1 -1
  587. package/dist/storage/connector-connections/in-memory.d.ts.map +1 -1
  588. package/dist/storage/connector-connections/index.d.ts +1 -1
  589. package/dist/storage/connector-connections/index.d.ts.map +1 -1
  590. package/dist/storage/connector-connections/provider/runs.d.ts.map +1 -1
  591. package/dist/storage/connector-connections/provider/shared.d.ts +12 -2
  592. package/dist/storage/connector-connections/provider/shared.d.ts.map +1 -1
  593. package/dist/storage/connector-connections/provider.d.ts +1 -0
  594. package/dist/storage/connector-connections/provider.d.ts.map +1 -1
  595. package/dist/storage/connector-connections/provider.js +21 -5
  596. package/dist/storage/connector-connections/provider.js.map +5 -5
  597. package/dist/storage/connector-connections/types.d.ts +1 -1
  598. package/dist/storage/connector-connections/types.d.ts.map +1 -1
  599. package/dist/storage/dataset-ingest/codec.d.ts +6 -0
  600. package/dist/storage/dataset-ingest/codec.d.ts.map +1 -0
  601. package/dist/storage/dataset-ingest/in-memory.d.ts +28 -0
  602. package/dist/storage/dataset-ingest/in-memory.d.ts.map +1 -0
  603. package/dist/storage/dataset-ingest/index.d.ts +4 -0
  604. package/dist/storage/dataset-ingest/index.d.ts.map +1 -0
  605. package/dist/storage/dataset-ingest/provider.d.ts +157 -0
  606. package/dist/storage/dataset-ingest/provider.d.ts.map +1 -0
  607. package/dist/storage/dataset-ingest/provider.js +17 -0
  608. package/dist/storage/dataset-ingest/provider.js.map +9 -0
  609. package/dist/storage/dataset-ingest/types.d.ts +188 -0
  610. package/dist/storage/dataset-ingest/types.d.ts.map +1 -0
  611. package/dist/storage/file-upload-sessions/provider.js +12 -11
  612. package/dist/storage/file-upload-sessions/provider.js.map +1 -1
  613. package/dist/storage/in-memory/index.d.ts +12 -0
  614. package/dist/storage/in-memory/index.d.ts.map +1 -1
  615. package/dist/storage/index.d.ts +18 -11
  616. package/dist/storage/index.d.ts.map +1 -1
  617. package/dist/storage/index.js +56 -46
  618. package/dist/storage/index.js.map +1 -1
  619. package/dist/storage/internal.d.ts +4 -1
  620. package/dist/storage/internal.d.ts.map +1 -1
  621. package/dist/storage/internal.js +81 -5
  622. package/dist/storage/internal.js.map +4 -3
  623. package/dist/storage/lake-retention-runs/in-memory.d.ts +11 -0
  624. package/dist/storage/lake-retention-runs/in-memory.d.ts.map +1 -0
  625. package/dist/storage/lake-retention-runs/index.d.ts +3 -0
  626. package/dist/storage/lake-retention-runs/index.d.ts.map +1 -0
  627. package/dist/storage/lake-retention-runs/types.d.ts +21 -0
  628. package/dist/storage/lake-retention-runs/types.d.ts.map +1 -0
  629. package/dist/storage/maintenance-heartbeats/in-memory.d.ts +11 -0
  630. package/dist/storage/maintenance-heartbeats/in-memory.d.ts.map +1 -0
  631. package/dist/storage/maintenance-heartbeats/index.d.ts +3 -0
  632. package/dist/storage/maintenance-heartbeats/index.d.ts.map +1 -0
  633. package/dist/storage/maintenance-heartbeats/record.d.ts +11 -0
  634. package/dist/storage/maintenance-heartbeats/record.d.ts.map +1 -0
  635. package/dist/storage/maintenance-heartbeats/types.d.ts +30 -0
  636. package/dist/storage/maintenance-heartbeats/types.d.ts.map +1 -0
  637. package/dist/storage/objects/in-memory/query.d.ts.map +1 -1
  638. package/dist/storage/objects/in-memory/storage.d.ts +15 -1
  639. package/dist/storage/objects/in-memory/storage.d.ts.map +1 -1
  640. package/dist/storage/objects/read-scope.d.ts.map +1 -1
  641. package/dist/storage/objects/types.d.ts +18 -1
  642. package/dist/storage/objects/types.d.ts.map +1 -1
  643. package/dist/storage/ontology/in-memory/materializations.d.ts.map +1 -1
  644. package/dist/storage/ontology/in-memory/replacement-plans.d.ts.map +1 -1
  645. package/dist/storage/ontology/index.d.ts +1 -1
  646. package/dist/storage/ontology/index.d.ts.map +1 -1
  647. package/dist/storage/ontology/materializations.d.ts +20 -0
  648. package/dist/storage/ontology/materializations.d.ts.map +1 -1
  649. package/dist/storage/ontology/provider-work.d.ts +7 -1
  650. package/dist/storage/ontology/provider-work.d.ts.map +1 -1
  651. package/dist/storage/ontology/provider.js +1 -1
  652. package/dist/storage/pipeline-runs/in-memory.d.ts +8 -2
  653. package/dist/storage/pipeline-runs/in-memory.d.ts.map +1 -1
  654. package/dist/storage/pipeline-runs/index.d.ts +1 -1
  655. package/dist/storage/pipeline-runs/index.d.ts.map +1 -1
  656. package/dist/storage/pipeline-runs/provider.js +1 -1
  657. package/dist/storage/pipeline-runs/transitions.d.ts +2 -2
  658. package/dist/storage/pipeline-runs/transitions.d.ts.map +1 -1
  659. package/dist/storage/pipeline-runs/types.d.ts +26 -6
  660. package/dist/storage/pipeline-runs/types.d.ts.map +1 -1
  661. package/dist/storage/projection-runs/errors.d.ts +6 -0
  662. package/dist/storage/projection-runs/errors.d.ts.map +1 -1
  663. package/dist/storage/projection-runs/in-memory.d.ts +5 -1
  664. package/dist/storage/projection-runs/in-memory.d.ts.map +1 -1
  665. package/dist/storage/projection-runs/index.d.ts +2 -2
  666. package/dist/storage/projection-runs/index.d.ts.map +1 -1
  667. package/dist/storage/projection-runs/lifecycle.d.ts +1 -0
  668. package/dist/storage/projection-runs/lifecycle.d.ts.map +1 -1
  669. package/dist/storage/projection-runs/provider.js +2 -2
  670. package/dist/storage/projection-runs/types.d.ts +16 -0
  671. package/dist/storage/projection-runs/types.d.ts.map +1 -1
  672. package/dist/storage/run-claim.d.ts +132 -0
  673. package/dist/storage/run-claim.d.ts.map +1 -0
  674. package/dist/storage/share-grants/provider.js +3 -3
  675. package/dist/storage/share-sessions/in-memory.d.ts +2 -1
  676. package/dist/storage/share-sessions/in-memory.d.ts.map +1 -1
  677. package/dist/storage/share-sessions/index.d.ts +1 -1
  678. package/dist/storage/share-sessions/index.d.ts.map +1 -1
  679. package/dist/storage/share-sessions/provider.d.ts +1 -1
  680. package/dist/storage/share-sessions/provider.d.ts.map +1 -1
  681. package/dist/storage/share-sessions/provider.js +4 -2
  682. package/dist/storage/share-sessions/provider.js.map +1 -1
  683. package/dist/storage/share-sessions/record.d.ts +2 -1
  684. package/dist/storage/share-sessions/record.d.ts.map +1 -1
  685. package/dist/storage/share-sessions/types.d.ts +17 -1
  686. package/dist/storage/share-sessions/types.d.ts.map +1 -1
  687. package/dist/storage/sync-runs/in-memory.d.ts +10 -2
  688. package/dist/storage/sync-runs/in-memory.d.ts.map +1 -1
  689. package/dist/storage/sync-runs/index.d.ts +1 -1
  690. package/dist/storage/sync-runs/index.d.ts.map +1 -1
  691. package/dist/storage/sync-runs/transitions.d.ts +2 -2
  692. package/dist/storage/sync-runs/transitions.d.ts.map +1 -1
  693. package/dist/storage/sync-runs/types.d.ts +29 -3
  694. package/dist/storage/sync-runs/types.d.ts.map +1 -1
  695. package/dist/storage/types.d.ts +12 -6
  696. package/dist/storage/types.d.ts.map +1 -1
  697. package/dist/storage/webhook-runs/in-memory.d.ts +2 -1
  698. package/dist/storage/webhook-runs/in-memory.d.ts.map +1 -1
  699. package/dist/storage/webhook-runs/index.d.ts +2 -2
  700. package/dist/storage/webhook-runs/index.d.ts.map +1 -1
  701. package/dist/storage/webhook-runs/types.d.ts +33 -2
  702. package/dist/storage/webhook-runs/types.d.ts.map +1 -1
  703. package/dist/storage/workflow-runs/in-memory.d.ts +6 -3
  704. package/dist/storage/workflow-runs/in-memory.d.ts.map +1 -1
  705. package/dist/storage/workflow-runs/index.d.ts +1 -1
  706. package/dist/storage/workflow-runs/index.d.ts.map +1 -1
  707. package/dist/storage/workflow-runs/provider.js +12 -11
  708. package/dist/storage/workflow-runs/provider.js.map +1 -1
  709. package/dist/storage/workflow-runs/types.d.ts +11 -28
  710. package/dist/storage/workflow-runs/types.d.ts.map +1 -1
  711. package/dist/syncs/index.js +38 -35
  712. package/dist/syncs/index.js.map +1 -1
  713. package/dist/syncs/run-dispatch.d.ts +2 -0
  714. package/dist/syncs/run-dispatch.d.ts.map +1 -1
  715. package/dist/testing/ai-model-call-groups-contract.d.ts.map +1 -1
  716. package/dist/testing/artifact-holders-contract.d.ts +15 -0
  717. package/dist/testing/artifact-holders-contract.d.ts.map +1 -0
  718. package/dist/testing/artifact-storage-contract.d.ts.map +1 -1
  719. package/dist/testing/auth-storage-contract.d.ts.map +1 -1
  720. package/dist/testing/broker-contract.d.ts.map +1 -1
  721. package/dist/testing/connector-connection-storage-contract.d.ts +1 -1
  722. package/dist/testing/connector-connection-storage-contract.d.ts.map +1 -1
  723. package/dist/testing/dataset-ingest-storage-contract.d.ts +11 -0
  724. package/dist/testing/dataset-ingest-storage-contract.d.ts.map +1 -0
  725. package/dist/testing/dataset-sequence-contract.d.ts +1 -1
  726. package/dist/testing/dataset-sequence-contract.d.ts.map +1 -1
  727. package/dist/testing/execution.d.ts.map +1 -1
  728. package/dist/testing/index.d.ts +8 -0
  729. package/dist/testing/index.d.ts.map +1 -1
  730. package/dist/testing/index.js +6245 -3192
  731. package/dist/testing/index.js.map +28 -19
  732. package/dist/testing/lake-retention-run-storage-contract.d.ts +9 -0
  733. package/dist/testing/lake-retention-run-storage-contract.d.ts.map +1 -0
  734. package/dist/testing/maintenance-heartbeat-storage-contract.d.ts +9 -0
  735. package/dist/testing/maintenance-heartbeat-storage-contract.d.ts.map +1 -0
  736. package/dist/testing/object-query-contract.d.ts.map +1 -1
  737. package/dist/testing/pipeline-execution.d.ts.map +1 -1
  738. package/dist/testing/pipeline-run-read-contract.d.ts +13 -0
  739. package/dist/testing/pipeline-run-read-contract.d.ts.map +1 -0
  740. package/dist/testing/projection-run-storage-contract.d.ts.map +1 -1
  741. package/dist/testing/queues-contract.d.ts.map +1 -1
  742. package/dist/testing/run-claim-storage-contract.d.ts +12 -0
  743. package/dist/testing/run-claim-storage-contract.d.ts.map +1 -0
  744. package/dist/testing/run-claim.d.ts +30 -0
  745. package/dist/testing/run-claim.d.ts.map +1 -0
  746. package/dist/testing/run-recovery-contract.d.ts +49 -0
  747. package/dist/testing/run-recovery-contract.d.ts.map +1 -0
  748. package/dist/testing/share-session-storage-contract.d.ts.map +1 -1
  749. package/dist/testing/stored-artifacts.d.ts +10 -0
  750. package/dist/testing/stored-artifacts.d.ts.map +1 -0
  751. package/dist/testing/sync-execution.d.ts.map +1 -1
  752. package/dist/testing/webhook-execution.d.ts +1 -1
  753. package/dist/testing/webhook-execution.d.ts.map +1 -1
  754. package/dist/testing/webhook-run-storage-contract.d.ts.map +1 -1
  755. package/dist/users/execution.d.ts +18 -1
  756. package/dist/users/execution.d.ts.map +1 -1
  757. package/dist/users/index.d.ts +1 -1
  758. package/dist/users/index.d.ts.map +1 -1
  759. package/dist/webhooks/delivery-lease.d.ts +13 -0
  760. package/dist/webhooks/delivery-lease.d.ts.map +1 -0
  761. package/dist/webhooks/internal.d.ts +2 -0
  762. package/dist/webhooks/internal.d.ts.map +1 -1
  763. package/dist/webhooks/internal.js +68 -36
  764. package/dist/webhooks/internal.js.map +5 -4
  765. package/dist/webhooks/run-admission.d.ts.map +1 -1
  766. package/dist/workers/index.d.ts +5 -1
  767. package/dist/workers/index.d.ts.map +1 -1
  768. package/dist/workers/index.js +193 -58
  769. package/dist/workers/index.js.map +8 -7
  770. package/dist/workers/job-ids.d.ts +17 -0
  771. package/dist/workers/job-ids.d.ts.map +1 -0
  772. package/dist/workers/lost-projection-runs.d.ts +26 -0
  773. package/dist/workers/lost-projection-runs.d.ts.map +1 -0
  774. package/dist/workers/lost-runs.d.ts +51 -0
  775. package/dist/workers/lost-runs.d.ts.map +1 -0
  776. package/dist/workers/queue-delivery.d.ts.map +1 -1
  777. package/dist/workers/queue-worker.d.ts +1 -2
  778. package/dist/workers/queue-worker.d.ts.map +1 -1
  779. package/dist/workers/queued-run-dispatch.d.ts +90 -0
  780. package/dist/workers/queued-run-dispatch.d.ts.map +1 -0
  781. package/dist/workers/run-lease.d.ts +25 -0
  782. package/dist/workers/run-lease.d.ts.map +1 -0
  783. package/dist/workers/run-worker.d.ts +95 -0
  784. package/dist/workers/run-worker.d.ts.map +1 -0
  785. package/dist/workflows/index.js +64 -58
  786. package/dist/workflows/index.js.map +1 -1
  787. package/dist/workflows/request.d.ts.map +1 -1
  788. package/dist/workflows/run-dispatch.d.ts +6 -1
  789. package/dist/workflows/run-dispatch.d.ts.map +1 -1
  790. package/package.json +41 -3
  791. package/src/actions/request.ts +24 -7
  792. package/src/actions/run/executor.ts +9 -42
  793. package/src/actions/types/context.ts +8 -3
  794. package/src/agents/approval-outcome.ts +2 -2
  795. package/src/agents/cancel.ts +2 -2
  796. package/src/agents/child-question.ts +76 -8
  797. package/src/agents/execution.ts +11 -3
  798. package/src/agents/fork.ts +12 -4
  799. package/src/agents/ids.ts +4 -1
  800. package/src/agents/index.ts +16 -3
  801. package/src/agents/model-loop.ts +3 -1
  802. package/src/agents/request.ts +42 -31
  803. package/src/agents/run-artifacts.ts +290 -46
  804. package/src/agents/run-session-children.ts +33 -0
  805. package/src/agents/run-session-http.ts +5 -0
  806. package/src/agents/run-session-serve.ts +11 -0
  807. package/src/agents/run-session.ts +8 -1
  808. package/src/agents/streams/protocol.ts +5 -10
  809. package/src/agents/tool-files.ts +1 -1
  810. package/src/agents/tool-input-coercion.ts +140 -0
  811. package/src/agents/validation.ts +12 -1
  812. package/src/artifacts/access.ts +71 -28
  813. package/src/artifacts/canvas-display.ts +160 -0
  814. package/src/artifacts/canvas.ts +26 -1
  815. package/src/artifacts/comment-text.ts +32 -0
  816. package/src/artifacts/comments.ts +275 -0
  817. package/src/artifacts/errors.ts +6 -1
  818. package/src/artifacts/events.ts +58 -0
  819. package/src/artifacts/execution.ts +496 -53
  820. package/src/artifacts/frames/assets.ts +20 -1
  821. package/src/artifacts/frames/grants.ts +31 -10
  822. package/src/artifacts/frames/index.ts +2 -0
  823. package/src/artifacts/frames/kit.ts +8 -5
  824. package/src/artifacts/frames/protocol.ts +231 -0
  825. package/src/artifacts/frames/runtime.ts +600 -29
  826. package/src/artifacts/holders.ts +120 -0
  827. package/src/artifacts/ids.ts +8 -0
  828. package/src/artifacts/index.ts +31 -2
  829. package/src/artifacts/limits.ts +28 -4
  830. package/src/artifacts/live/board.ts +759 -0
  831. package/src/artifacts/live/diff.ts +297 -0
  832. package/src/artifacts/live/document.ts +354 -0
  833. package/src/artifacts/live/files.ts +82 -0
  834. package/src/artifacts/live/index.ts +50 -0
  835. package/src/artifacts/live/presence.ts +144 -0
  836. package/src/artifacts/live/protocol.ts +134 -0
  837. package/src/artifacts/live/server.ts +16 -0
  838. package/src/artifacts/live/state.ts +115 -0
  839. package/src/artifacts/outline.ts +12 -0
  840. package/src/artifacts/publish/index.ts +26 -1
  841. package/src/artifacts/publish/merge.ts +271 -0
  842. package/src/artifacts/publish/previews.ts +485 -0
  843. package/src/artifacts/publish/publish.ts +92 -39
  844. package/src/artifacts/publish/query-answers.ts +85 -0
  845. package/src/artifacts/publish/references.ts +10 -4
  846. package/src/artifacts/publish/validate/canvas.ts +133 -1
  847. package/src/artifacts/theme.ts +9 -1
  848. package/src/auth/directory.ts +166 -0
  849. package/src/auth/member-events.ts +10 -3
  850. package/src/auth/runtime.ts +108 -8
  851. package/src/auth/strategy.ts +3 -1
  852. package/src/auth/types.ts +44 -0
  853. package/src/authorization/decision.ts +6 -5
  854. package/src/authorization/event-visibility.ts +4 -0
  855. package/src/broker/in-memory.ts +33 -6
  856. package/src/broker/types.ts +4 -0
  857. package/src/connectors/builders.ts +34 -2
  858. package/src/connectors/connections/access.ts +83 -0
  859. package/src/connectors/connections/contracts.ts +6 -1
  860. package/src/connectors/connections/execution.ts +2 -2
  861. package/src/connectors/connections/runs.ts +51 -2
  862. package/src/connectors/connections/service.ts +208 -41
  863. package/src/connectors/connections/views.ts +11 -4
  864. package/src/connectors/execution.ts +27 -3
  865. package/src/connectors/index.ts +2 -0
  866. package/src/connectors/service.ts +12 -0
  867. package/src/connectors/types.ts +37 -2
  868. package/src/datasets/execution.ts +74 -37
  869. package/src/datasets/ingest-flush-batch.ts +289 -0
  870. package/src/datasets/ingest-flush-job.ts +112 -0
  871. package/src/datasets/ingest-flush.ts +377 -0
  872. package/src/datasets/produced-version.ts +55 -0
  873. package/src/datasets/write.ts +65 -11
  874. package/src/deploy/services.ts +1 -1
  875. package/src/deploy/types.ts +2 -3
  876. package/src/deploy/validation.ts +1 -0
  877. package/src/error-reporting/capability.ts +66 -0
  878. package/src/error-reporting/internal.ts +12 -0
  879. package/src/error-reporting/reporter.ts +11 -35
  880. package/src/error-reporting/reports.ts +167 -0
  881. package/src/error-reporting/types.ts +99 -0
  882. package/src/errors/catalog.ts +6 -0
  883. package/src/events/definitions.ts +14 -0
  884. package/src/events/execution.ts +77 -28
  885. package/src/events/index.ts +3 -0
  886. package/src/events/scope.ts +2 -0
  887. package/src/events/types/artifacts.ts +40 -0
  888. package/src/events/types/index.ts +3 -0
  889. package/src/events/types/users.ts +5 -2
  890. package/src/execution/authorized-object-reader.ts +34 -0
  891. package/src/execution/object-reader-clearance.ts +31 -0
  892. package/src/execution/object-reader-security.ts +33 -13
  893. package/src/http/api-routes.ts +106 -5
  894. package/src/index.ts +22 -4
  895. package/src/lake-storage/errors.ts +21 -0
  896. package/src/lake-storage/index.ts +9 -1
  897. package/src/lake-storage/maintenance.ts +93 -0
  898. package/src/lake-storage/merge.ts +3 -1
  899. package/src/lake-storage/source-ordering.ts +28 -2
  900. package/src/lake-storage/types.ts +14 -0
  901. package/src/maintenance/heartbeat.ts +14 -0
  902. package/src/maintenance/index.ts +5 -3
  903. package/src/maintenance/lake-retention-status.ts +81 -0
  904. package/src/maintenance/lake-retention.ts +347 -0
  905. package/src/maintenance/loop.ts +365 -0
  906. package/src/maintenance/ontology-maintenance.ts +76 -229
  907. package/src/maintenance/passes/cron-pass.ts +217 -0
  908. package/src/maintenance/passes/directory-pass.ts +22 -0
  909. package/src/maintenance/passes/ingest-pass.ts +94 -0
  910. package/src/maintenance/passes/lake-change-feed.ts +112 -0
  911. package/src/maintenance/passes/lake-retention-pass.ts +71 -0
  912. package/src/maintenance/passes/ontology-pass.ts +19 -0
  913. package/src/maintenance/passes/projections-pass.ts +238 -0
  914. package/src/maintenance/passes/recovery-pass.ts +17 -0
  915. package/src/maintenance/passes/recovery-passes.ts +39 -0
  916. package/src/maintenance/passes/runs-pass.ts +12 -0
  917. package/src/maintenance/passes/triggers-pass.ts +332 -0
  918. package/src/maintenance/status.ts +75 -0
  919. package/src/maintenance/types.ts +27 -25
  920. package/src/materialization/model.ts +33 -21
  921. package/src/materializer/README.md +13 -2
  922. package/src/materializer/edits/artifact-refs.ts +140 -0
  923. package/src/materializer/edits/commit.ts +20 -7
  924. package/src/materializer/edits/operations.ts +23 -7
  925. package/src/materializer/edits/plan.ts +2 -0
  926. package/src/materializer/execution/work-records.ts +61 -0
  927. package/src/materializer/projections/replacement-plan.ts +2 -0
  928. package/src/materializer/shared/normalize.ts +14 -0
  929. package/src/materializer/telemetry/plan.ts +2 -0
  930. package/src/models/language-model.ts +6 -0
  931. package/src/models/tools.ts +2 -0
  932. package/src/objects/artifact-refs.ts +34 -0
  933. package/src/objects/materializer-adapter.ts +8 -3
  934. package/src/objects/object/upsert-batch.ts +7 -0
  935. package/src/objects/object/upsert.ts +11 -2
  936. package/src/objects/query/ir.ts +2 -0
  937. package/src/objects/query/scalar-values.ts +5 -3
  938. package/src/objects/runtime-batch.ts +8 -1
  939. package/src/objects/vectors/README.md +4 -4
  940. package/src/ontology/artifact-ref.ts +83 -0
  941. package/src/ontology/docs-markdown.ts +17 -0
  942. package/src/ontology/index.ts +3 -1
  943. package/src/ontology/inference/index.ts +2 -0
  944. package/src/ontology/json-schema.ts +13 -0
  945. package/src/ontology/primitives.ts +14 -0
  946. package/src/ontology/reference-values.ts +62 -0
  947. package/src/ontology/refs.ts +7 -1
  948. package/src/ontology/registry.ts +26 -1
  949. package/src/ontology/types.ts +2 -0
  950. package/src/ontology/user-ref.ts +35 -45
  951. package/src/ontology/validation/normalize.ts +13 -0
  952. package/src/ontology/validation/properties.ts +9 -0
  953. package/src/ontology/validation/schema.ts +12 -0
  954. package/src/pending-tasks.ts +51 -0
  955. package/src/pipelines/run-dispatch.ts +120 -238
  956. package/src/predicates/types.ts +2 -1
  957. package/src/projections/builders.ts +28 -13
  958. package/src/projections/run-dispatch.ts +1 -1
  959. package/src/projections/types.ts +1 -1
  960. package/src/projections/validation.ts +22 -8
  961. package/src/queues/in-memory.ts +50 -3
  962. package/src/queues/index.ts +4 -0
  963. package/src/queues/types.ts +68 -1
  964. package/src/runtime/create.ts +4 -0
  965. package/src/runtime/host.ts +118 -13
  966. package/src/runtime/index.ts +0 -1
  967. package/src/runtime/internal.ts +13 -0
  968. package/src/runtime/ontology-mutations.ts +1 -1
  969. package/src/runtime/sixb.ts +14 -5
  970. package/src/scheduler/index.ts +0 -2
  971. package/src/shared/backoff.ts +34 -0
  972. package/src/shared/duration.ts +15 -0
  973. package/src/shared/params/artifact-refs.ts +42 -0
  974. package/src/shares/compiler.ts +1 -1
  975. package/src/shares/guest-name.ts +20 -0
  976. package/src/shares/internal.ts +1 -0
  977. package/src/shares/session-protocol.ts +63 -0
  978. package/src/storage/agents/types.ts +1 -1
  979. package/src/storage/artifacts/errors.ts +10 -2
  980. package/src/storage/artifacts/in-memory.ts +579 -96
  981. package/src/storage/artifacts/index.ts +22 -1
  982. package/src/storage/artifacts/record.ts +255 -11
  983. package/src/storage/artifacts/types.ts +343 -40
  984. package/src/storage/auth/in-memory/auth-storage.ts +42 -5
  985. package/src/storage/auth/in-memory/identities.ts +16 -0
  986. package/src/storage/auth/in-memory/shared.ts +15 -0
  987. package/src/storage/auth/in-memory/users.ts +17 -16
  988. package/src/storage/auth/index.ts +3 -0
  989. package/src/storage/auth/types.ts +38 -0
  990. package/src/storage/connector-connections/in-memory.ts +4 -1
  991. package/src/storage/connector-connections/index.ts +1 -0
  992. package/src/storage/connector-connections/provider/runs.ts +3 -0
  993. package/src/storage/connector-connections/provider/shared.ts +30 -0
  994. package/src/storage/connector-connections/provider.ts +4 -0
  995. package/src/storage/connector-connections/types.ts +1 -0
  996. package/src/storage/dataset-ingest/codec.ts +90 -0
  997. package/src/storage/dataset-ingest/in-memory.ts +277 -0
  998. package/src/storage/dataset-ingest/index.ts +16 -0
  999. package/src/storage/dataset-ingest/provider.ts +592 -0
  1000. package/src/storage/dataset-ingest/types.ts +191 -0
  1001. package/src/storage/in-memory/index.ts +33 -0
  1002. package/src/storage/index.ts +65 -5
  1003. package/src/storage/internal.ts +20 -0
  1004. package/src/storage/lake-retention-runs/in-memory.ts +22 -0
  1005. package/src/storage/lake-retention-runs/index.ts +2 -0
  1006. package/src/storage/lake-retention-runs/types.ts +19 -0
  1007. package/src/storage/maintenance-heartbeats/in-memory.ts +24 -0
  1008. package/src/storage/maintenance-heartbeats/index.ts +7 -0
  1009. package/src/storage/maintenance-heartbeats/record.ts +50 -0
  1010. package/src/storage/maintenance-heartbeats/types.ts +30 -0
  1011. package/src/storage/objects/in-memory/query.ts +1 -0
  1012. package/src/storage/objects/in-memory/storage.ts +81 -0
  1013. package/src/storage/objects/read-scope.ts +1 -0
  1014. package/src/storage/objects/types.ts +16 -1
  1015. package/src/storage/ontology/in-memory/materializations.ts +8 -0
  1016. package/src/storage/ontology/in-memory/replacement-plans.ts +4 -1
  1017. package/src/storage/ontology/index.ts +2 -0
  1018. package/src/storage/ontology/materializations.ts +18 -0
  1019. package/src/storage/ontology/provider-work.ts +39 -0
  1020. package/src/storage/pipeline-runs/in-memory.ts +97 -24
  1021. package/src/storage/pipeline-runs/index.ts +0 -1
  1022. package/src/storage/pipeline-runs/provider.ts +1 -1
  1023. package/src/storage/pipeline-runs/transitions.ts +7 -4
  1024. package/src/storage/pipeline-runs/types.ts +33 -7
  1025. package/src/storage/projection-runs/errors.ts +10 -0
  1026. package/src/storage/projection-runs/in-memory.ts +56 -1
  1027. package/src/storage/projection-runs/index.ts +2 -1
  1028. package/src/storage/projection-runs/lifecycle.ts +9 -1
  1029. package/src/storage/projection-runs/types.ts +20 -1
  1030. package/src/storage/run-claim.ts +224 -0
  1031. package/src/storage/share-sessions/in-memory.ts +21 -0
  1032. package/src/storage/share-sessions/index.ts +1 -0
  1033. package/src/storage/share-sessions/provider.ts +1 -0
  1034. package/src/storage/share-sessions/record.ts +28 -0
  1035. package/src/storage/share-sessions/types.ts +19 -1
  1036. package/src/storage/sync-runs/in-memory.ts +109 -29
  1037. package/src/storage/sync-runs/index.ts +1 -1
  1038. package/src/storage/sync-runs/transitions.ts +7 -4
  1039. package/src/storage/sync-runs/types.ts +36 -3
  1040. package/src/storage/types.ts +15 -5
  1041. package/src/storage/webhook-runs/in-memory.ts +26 -2
  1042. package/src/storage/webhook-runs/index.ts +3 -1
  1043. package/src/storage/webhook-runs/types.ts +44 -3
  1044. package/src/storage/workflow-runs/in-memory.ts +50 -36
  1045. package/src/storage/workflow-runs/index.ts +0 -2
  1046. package/src/storage/workflow-runs/types.ts +18 -30
  1047. package/src/syncs/run-dispatch.ts +118 -239
  1048. package/src/testing/ai-model-call-groups-contract.ts +2 -1
  1049. package/src/testing/artifact-holders-contract.ts +392 -0
  1050. package/src/testing/artifact-storage-contract.ts +1205 -151
  1051. package/src/testing/auth-storage-contract.ts +228 -1
  1052. package/src/testing/broker-contract.ts +56 -0
  1053. package/src/testing/connector-connection-storage-contract.ts +94 -5
  1054. package/src/testing/dataset-ingest-storage-contract.ts +480 -0
  1055. package/src/testing/dataset-sequence-contract.ts +97 -12
  1056. package/src/testing/execution.ts +23 -0
  1057. package/src/testing/index.ts +31 -0
  1058. package/src/testing/lake-retention-run-storage-contract.ts +75 -0
  1059. package/src/testing/maintenance-heartbeat-storage-contract.ts +99 -0
  1060. package/src/testing/object-query-contract.ts +93 -0
  1061. package/src/testing/pipeline-execution.ts +3 -1
  1062. package/src/testing/pipeline-run-read-contract.ts +123 -0
  1063. package/src/testing/projection-run-storage-contract.ts +113 -0
  1064. package/src/testing/queues-contract.ts +112 -0
  1065. package/src/testing/run-claim-storage-contract.ts +736 -0
  1066. package/src/testing/run-claim.ts +69 -0
  1067. package/src/testing/run-recovery-contract.ts +176 -0
  1068. package/src/testing/share-session-storage-contract.ts +43 -0
  1069. package/src/testing/stored-artifacts.ts +43 -0
  1070. package/src/testing/sync-execution.ts +3 -1
  1071. package/src/testing/webhook-execution.ts +7 -2
  1072. package/src/testing/webhook-run-storage-contract.ts +102 -5
  1073. package/src/users/execution.ts +50 -2
  1074. package/src/users/index.ts +1 -0
  1075. package/src/webhooks/delivery-lease.ts +40 -0
  1076. package/src/webhooks/internal.ts +2 -0
  1077. package/src/webhooks/run-admission.ts +22 -9
  1078. package/src/workers/README.md +169 -0
  1079. package/src/workers/index.ts +9 -1
  1080. package/src/workers/job-ids.ts +31 -0
  1081. package/src/workers/lost-projection-runs.ts +114 -0
  1082. package/src/workers/lost-runs.ts +397 -0
  1083. package/src/workers/queue-delivery.ts +2 -14
  1084. package/src/workers/queue-worker.ts +9 -17
  1085. package/src/workers/queued-run-dispatch.ts +308 -0
  1086. package/src/workers/run-lease.ts +46 -0
  1087. package/src/workers/run-worker.ts +312 -0
  1088. package/src/workers/worker.ts +4 -17
  1089. package/src/workflows/request.ts +2 -0
  1090. package/src/workflows/run-dispatch.ts +22 -4
  1091. package/src/workflows/snapshot.ts +1 -0
  1092. package/dist/chunk-2g0r46hy.js.map +0 -12
  1093. package/dist/chunk-3fqxbn31.js +0 -107
  1094. package/dist/chunk-3fqxbn31.js.map +0 -11
  1095. package/dist/chunk-4s753g3k.js +0 -314
  1096. package/dist/chunk-4s753g3k.js.map +0 -12
  1097. package/dist/chunk-5kyvrtjh.js.map +0 -12
  1098. package/dist/chunk-5taem5aw.js.map +0 -10
  1099. package/dist/chunk-65abf64x.js +0 -13
  1100. package/dist/chunk-65abf64x.js.map +0 -10
  1101. package/dist/chunk-9x8dybsb.js.map +0 -10
  1102. package/dist/chunk-az47zep4.js +0 -41
  1103. package/dist/chunk-az47zep4.js.map +0 -10
  1104. package/dist/chunk-c706qvyc.js +0 -299
  1105. package/dist/chunk-c706qvyc.js.map +0 -11
  1106. package/dist/chunk-djs3hw9p.js.map +0 -20
  1107. package/dist/chunk-dsv783c3.js.map +0 -47
  1108. package/dist/chunk-e5wf5vz0.js.map +0 -10
  1109. package/dist/chunk-e6xgz4h4.js.map +0 -21
  1110. package/dist/chunk-e7v3trpz.js.map +0 -10
  1111. package/dist/chunk-eqgr6nsa.js.map +0 -72
  1112. package/dist/chunk-fb3feg1e.js +0 -298
  1113. package/dist/chunk-fb3feg1e.js.map +0 -12
  1114. package/dist/chunk-hz5d43gn.js.map +0 -10
  1115. package/dist/chunk-j8thxj7w.js.map +0 -22
  1116. package/dist/chunk-jbw70d6t.js.map +0 -10
  1117. package/dist/chunk-jftd33rc.js.map +0 -11
  1118. package/dist/chunk-jspskey0.js.map +0 -10
  1119. package/dist/chunk-kfee1h52.js.map +0 -13
  1120. package/dist/chunk-kwfhd1g0.js +0 -144
  1121. package/dist/chunk-kwfhd1g0.js.map +0 -13
  1122. package/dist/chunk-nz7815t3.js.map +0 -14
  1123. package/dist/chunk-s3we74h8.js.map +0 -12
  1124. package/dist/chunk-scyq22td.js.map +0 -12
  1125. package/dist/chunk-w1btn96n.js.map +0 -44
  1126. package/dist/chunk-w976a4me.js.map +0 -10
  1127. package/dist/chunk-wkq3kvzd.js.map +0 -10
  1128. package/dist/chunk-wrjx1fqz.js +0 -587
  1129. package/dist/chunk-wrjx1fqz.js.map +0 -18
  1130. package/dist/chunk-yw9pyg66.js +0 -143
  1131. package/dist/chunk-yw9pyg66.js.map +0 -11
  1132. package/dist/chunk-z8fx5cgb.js.map +0 -11
  1133. package/dist/scheduler/runtime.d.ts +0 -40
  1134. package/dist/scheduler/runtime.d.ts.map +0 -1
  1135. package/dist/workers/unstarted-run.d.ts +0 -10
  1136. package/dist/workers/unstarted-run.d.ts.map +0 -1
  1137. package/src/scheduler/runtime.ts +0 -214
  1138. package/src/workers/unstarted-run.ts +0 -18
  1139. /package/dist/{chunk-80gym75n.js.map → chunk-186k5yz3.js.map} +0 -0
  1140. /package/dist/{chunk-ga63a3dz.js.map → chunk-2bn6813a.js.map} +0 -0
  1141. /package/dist/{chunk-ytzcxtpt.js.map → chunk-3ba89vm7.js.map} +0 -0
  1142. /package/dist/{chunk-d04g36fw.js.map → chunk-5qqmndhm.js.map} +0 -0
  1143. /package/dist/{chunk-5wtnmpze.js.map → chunk-7qe46788.js.map} +0 -0
  1144. /package/dist/{chunk-31kcqmhf.js.map → chunk-855w9nvw.js.map} +0 -0
  1145. /package/dist/{chunk-9whfmsfk.js.map → chunk-8tqnsx3q.js.map} +0 -0
  1146. /package/dist/{chunk-s038wa5v.js.map → chunk-b9qfh2ya.js.map} +0 -0
  1147. /package/dist/{chunk-jjmggm9a.js.map → chunk-fe6r7yhg.js.map} +0 -0
  1148. /package/dist/{chunk-165c9wm6.js.map → chunk-g2ph4873.js.map} +0 -0
  1149. /package/dist/{chunk-4zm1k3xj.js.map → chunk-r2psmn42.js.map} +0 -0
  1150. /package/dist/{chunk-2ajw5rz0.js.map → chunk-rsxb14an.js.map} +0 -0
  1151. /package/dist/{chunk-r1cxq7vv.js.map → chunk-rtdrm592.js.map} +0 -0
  1152. /package/dist/{chunk-4bm0caep.js.map → chunk-smnt672s.js.map} +0 -0
  1153. /package/dist/{chunk-21q0j5f2.js.map → chunk-stmxh0hv.js.map} +0 -0
  1154. /package/dist/{chunk-ff5xkv0p.js.map → chunk-tfzvjdms.js.map} +0 -0
  1155. /package/dist/{chunk-6b61s40c.js.map → chunk-w3t94hm6.js.map} +0 -0
@@ -4,36 +4,69 @@ import {
4
4
  validateObjectQueryWithAdmission,
5
5
  SYSTEM_PRINCIPAL2,
6
6
  principalsEqual2
7
- } from "./chunk-s7j8ewqv.js";
7
+ } from "./chunk-0k3r5kb3.js";
8
8
  import {
9
9
  resolveRuntimeAuthorizationForProject,
10
10
  AuthorizationError2,
11
11
  isRuntimeAllowed2
12
- } from "./chunk-twfreyxr.js";
12
+ } from "./chunk-vzkxqf8h.js";
13
13
  import {
14
- inferFileMediaType2
14
+ createArtifactId,
15
+ createArtifactCommentId
16
+ } from "./chunk-kr6dx38r.js";
17
+ import {
18
+ inferFileMediaType2,
19
+ isValidFileRef
15
20
  } from "./chunk-wkv3h3q7.js";
21
+ import {
22
+ collectArtifactRefIds
23
+ } from "./chunk-3zagkr6w.js";
24
+ import {
25
+ ArtifactStorageError,
26
+ turnUndoable2
27
+ } from "./chunk-3014rfjz.js";
16
28
  import {
17
29
  ARTIFACT_LIMITS2,
18
- ARTIFACT_STATE_LIMITS2
19
- } from "./chunk-hz5d43gn.js";
30
+ ARTIFACT_STATE_LIMITS2,
31
+ ARTIFACT_HOLDERS_LIMIT2,
32
+ ARTIFACT_COMMENT_LIMITS2
33
+ } from "./chunk-9vsc919v.js";
34
+ import {
35
+ objectBatchKey2
36
+ } from "./chunk-w1wq7gfr.js";
37
+ import {
38
+ objectReadersIn,
39
+ getAuthorizedOntologyView,
40
+ readerClearance
41
+ } from "./chunk-msyevpp3.js";
20
42
  import {
21
- createArtifactId,
22
43
  isArtifactAddress2,
23
- parseArtifactAddress2
24
- } from "./chunk-3fqxbn31.js";
44
+ parseArtifactAddress2,
45
+ CANVAS_FILE2,
46
+ parseCanvas2
47
+ } from "./chunk-bz5bnjjt.js";
25
48
  import {
26
- ARTIFACT_THEME_FILE2,
27
- parseArtifactTheme2,
49
+ isLiveTextPath,
50
+ createArtifactDocument,
51
+ documentFiles2,
52
+ mergeIntoDocument2
53
+ } from "./chunk-m2jerfef.js";
54
+ import {
55
+ BOARD_PREVIEW_JOB2,
56
+ BOARD_PREVIEW_WAIT_MS2,
57
+ canvasArrowLine2,
58
+ canvasItemBox,
59
+ canvasEndBox,
28
60
  ARTIFACT_QUERIES_DIRECTORY,
29
61
  ARTIFACT_QUERY_KINDS,
30
62
  isArtifactQueryName,
31
63
  artifactQueryPath,
32
64
  artifactQueryName2,
33
65
  parseArtifactQuery,
66
+ ARTIFACT_THEME_FILE2,
67
+ parseArtifactTheme2,
68
+ artifactThemeModes2,
34
69
  resolveArtifactAddress2,
35
- CANVAS_FILE2,
36
- parseCanvas2,
37
70
  createHeadingSlugger2,
38
71
  CsvParseError2,
39
72
  parseCsv2,
@@ -47,14 +80,7 @@ import {
47
80
  sheetColumnsProblem,
48
81
  sheetFormulasProblem,
49
82
  sheetChartsProblem
50
- } from "./chunk-waqk73p1.js";
51
- import {
52
- ArtifactStorageError
53
- } from "./chunk-e6xgz4h4.js";
54
- import {
55
- getAuthorizedOntologyView,
56
- readerClearance
57
- } from "./chunk-m2vh8gh0.js";
83
+ } from "./chunk-a6fjkcne.js";
58
84
  import {
59
85
  ArtifactRequestError2,
60
86
  checkArtifactFiles,
@@ -63,8 +89,11 @@ import {
63
89
  decodeHtmlEntities,
64
90
  HTML_ENTRY2,
65
91
  refuseFrameAssetPaths,
66
- readHtmlReferences
67
- } from "./chunk-kwfhd1g0.js";
92
+ readHtmlReferences,
93
+ FRAME_DEFAULT_THEMES2,
94
+ FRAME_ASSETS2,
95
+ serializeArtifactQueryResult2
96
+ } from "./chunk-hvbvq7p4.js";
68
97
  import {
69
98
  ObjectQueryValidationError2,
70
99
  ObjectQueryPlanningError2,
@@ -74,6 +103,9 @@ import {
74
103
  import {
75
104
  AgentRequestError2
76
105
  } from "./chunk-9wr3yajk.js";
106
+ import {
107
+ statFileRef2
108
+ } from "./chunk-a3faa34j.js";
77
109
 
78
110
  // src/agents/thread-access.ts
79
111
  function createAgentThreadAccessRule(runtime, authority, agents) {
@@ -134,8 +166,9 @@ function publicThread(thread) {
134
166
  function createArtifactAccessRule(input) {
135
167
  const { caller } = input;
136
168
  const conversations = new Map;
169
+ const holders = new Map;
137
170
  const conversation = (threadId) => {
138
- if (caller === null || !input.sharing)
171
+ if (caller === null || caller === "guest" || !input.sharing)
139
172
  return Promise.resolve(null);
140
173
  let reads = conversations.get(threadId);
141
174
  if (!reads) {
@@ -144,14 +177,24 @@ function createArtifactAccessRule(input) {
144
177
  }
145
178
  return reads;
146
179
  };
180
+ const throughObjects = (artifact) => {
181
+ let reaches = holders.get(artifact.id);
182
+ if (!reaches) {
183
+ reaches = input.holders(artifact).then((access) => caller === "guest" && access !== null ? "read" : access);
184
+ holders.set(artifact.id, reaches);
185
+ }
186
+ return reaches;
187
+ };
147
188
  const ownAccess = (artifact) => {
148
189
  if (caller === null)
149
190
  return "none";
191
+ if (caller === "guest")
192
+ return;
150
193
  if (caller === "system" || principalsEqual2(caller, artifact.owner))
151
194
  return "owner";
152
- return input.sharing ? undefined : "none";
195
+ return;
153
196
  };
154
- const threadIdsOf = (artifact) => input.storage.listThreadIds({ projectId: input.projectId, id: artifact.id });
197
+ const threadIdsOf = async (artifact) => input.sharing ? input.storage.listThreadIds({ projectId: input.projectId, id: artifact.id }) : [];
155
198
  const accessTo = async (artifact) => {
156
199
  const own = ownAccess(artifact);
157
200
  if (own)
@@ -164,7 +207,7 @@ function createArtifactAccessRule(input) {
164
207
  if (reads === "read")
165
208
  access = "read";
166
209
  }
167
- return access;
210
+ return await throughObjects(artifact) ?? access;
168
211
  };
169
212
  const publishAccess = async (artifact, threadId) => {
170
213
  if (threadId === undefined)
@@ -172,20 +215,764 @@ function createArtifactAccessRule(input) {
172
215
  const own = ownAccess(artifact);
173
216
  if (own)
174
217
  return own;
175
- if (!(await threadIdsOf(artifact)).includes(threadId))
176
- return "none";
177
- const reads = await conversation(threadId);
178
- return reads === null ? "none" : reads;
218
+ const shared = (await threadIdsOf(artifact)).includes(threadId);
219
+ const here = shared ? await conversation(threadId) : null;
220
+ if (here === "update")
221
+ return "update";
222
+ if (await throughObjects(artifact) === "update")
223
+ return "update";
224
+ return here ?? "none";
179
225
  };
180
226
  return { accessTo, publishAccess, conversation };
181
227
  }
182
228
  function assertUpdatable(artifactId, access) {
183
229
  if (access === "none") {
184
- throw new ArtifactRequestError2("not_shared", `[Sixb] Artifact '${artifactId}' is not shared in a conversation you read.`);
230
+ throw new ArtifactRequestError2("not_shared", `[Sixb] Artifact '${artifactId}' is not shared with you.`);
185
231
  }
186
232
  if (access === "read") {
187
- throw new ArtifactRequestError2("read_only", `[Sixb] You read artifact '${artifactId}' as an observer: you cannot change it or keep page data in it.`);
233
+ throw new ArtifactRequestError2("read_only", `[Sixb] You only read artifact '${artifactId}': you cannot change it or keep page data in it.`);
234
+ }
235
+ }
236
+
237
+ // src/artifacts/events.ts
238
+ async function announceArtifactUpdates(events, latest) {
239
+ if (latest.length === 0)
240
+ return;
241
+ await events.emit({
242
+ events: latest.map((version) => ({
243
+ type: "artifact.updated",
244
+ payload: {
245
+ artifactId: version.artifactId,
246
+ version: version.version,
247
+ revision: version.revision,
248
+ frozen: version.frozenAt !== undefined
249
+ },
250
+ idempotencyKey: `artifact.updated:${version.artifactId}:${version.revision}`
251
+ }))
252
+ }, { source: "Sixb" });
253
+ }
254
+ async function announceArtifactComment(events, comment, action) {
255
+ await events.emit({
256
+ events: [
257
+ {
258
+ type: "artifact.commented",
259
+ payload: {
260
+ artifactId: comment.artifactId,
261
+ commentId: comment.id,
262
+ ...comment.parentId === undefined ? {} : { parentId: comment.parentId },
263
+ action
264
+ }
265
+ }
266
+ ]
267
+ }, { source: "Sixb" });
268
+ }
269
+
270
+ // src/artifacts/comments.ts
271
+ var ELEMENT_ADDRESS = /^body(>[a-z][a-z0-9-]*:\d+)*$/;
272
+ var MAX_ELEMENT_ADDRESS_LENGTH = 1024;
273
+ function createArtifactCommentsRuntime(input) {
274
+ const { projectId, events } = input;
275
+ const readable = async (artifactId) => {
276
+ const reached = await input.reach(artifactId);
277
+ if (!reached)
278
+ throw notFound(artifactId);
279
+ if (reached.access === "none") {
280
+ throw new ArtifactRequestError2("not_shared", `[Sixb] Artifact '${artifactId}' is not shared with you.`);
281
+ }
282
+ return reached;
283
+ };
284
+ const managed = async (artifactId, commentId) => {
285
+ const { access } = await readable(artifactId);
286
+ const manager = input.manager();
287
+ const comment = await input.storage().getComment({ projectId, artifactId, id: commentId });
288
+ if (!comment)
289
+ throw commentNotFound(artifactId, commentId);
290
+ const changes = access === "owner" || access === "update";
291
+ const authored = comment.author.type !== "guest" && principalsEqual2(comment.author, manager);
292
+ if (!changes && !authored) {
293
+ throw new ArtifactRequestError2("not_allowed", "[Sixb] Only a comment's author, or whoever may change the artifact, resolves or deletes it.");
294
+ }
295
+ return comment;
296
+ };
297
+ return {
298
+ async listComments(artifactId) {
299
+ const reached = await input.reach(artifactId);
300
+ if (!reached || reached.access === "none")
301
+ return null;
302
+ return input.storage().listComments({ projectId, id: artifactId });
303
+ },
304
+ async addComment(artifactId, comment) {
305
+ const { artifact } = await readable(artifactId);
306
+ const author = await input.author();
307
+ const storage = input.storage();
308
+ const body = comment.body.trim();
309
+ if (body.length === 0 || body.length > ARTIFACT_COMMENT_LIMITS2.maxBodyLength) {
310
+ throw invalid(`A comment holds 1 to ${ARTIFACT_COMMENT_LIMITS2.maxBodyLength} characters of text.`);
311
+ }
312
+ let anchor;
313
+ if (comment.parentId !== undefined) {
314
+ const parent = await storage.getComment({ projectId, artifactId, id: comment.parentId });
315
+ if (!parent)
316
+ throw commentNotFound(artifactId, comment.parentId);
317
+ anchor = parent.anchor;
318
+ } else {
319
+ anchor = await checkAnchor(storage, artifact, comment.anchor ?? {});
320
+ }
321
+ try {
322
+ const created = await storage.createComment({
323
+ projectId,
324
+ artifactId,
325
+ id: createArtifactCommentId(),
326
+ ...comment.parentId === undefined ? {} : { parentId: comment.parentId },
327
+ anchor,
328
+ body,
329
+ author,
330
+ ...comment.origin ? { origin: comment.origin } : {},
331
+ createdAt: new Date
332
+ });
333
+ await announceArtifactComment(events, created, "created");
334
+ return created;
335
+ } catch (error) {
336
+ throw commentRequestError(error);
337
+ }
338
+ },
339
+ async resolveComment(artifactId, commentId, resolved = true) {
340
+ await managed(artifactId, commentId);
341
+ const changed = await input.storage().resolveComment({
342
+ projectId,
343
+ artifactId,
344
+ id: commentId,
345
+ resolved: resolved ? { at: new Date, by: input.manager() } : null
346
+ });
347
+ if (!changed)
348
+ throw commentNotFound(artifactId, commentId);
349
+ await announceArtifactComment(events, changed, resolved ? "resolved" : "reopened");
350
+ return changed;
351
+ },
352
+ async deleteComment(artifactId, commentId) {
353
+ const comment = await managed(artifactId, commentId);
354
+ const deleted = await input.storage().deleteComment({ projectId, artifactId, id: commentId });
355
+ if (!deleted)
356
+ throw commentNotFound(artifactId, commentId);
357
+ await announceArtifactComment(events, comment, "deleted");
358
+ }
359
+ };
360
+ }
361
+ async function checkAnchor(storage, artifact, anchor) {
362
+ const revision = anchor.revision ?? artifact.revision;
363
+ if (!Number.isSafeInteger(revision) || revision < 1 || revision > artifact.revision) {
364
+ throw invalid(`A comment is about a revision of the artifact, 1 to ${artifact.revision}.`);
365
+ }
366
+ if (anchor.element !== undefined && anchor.board === undefined) {
367
+ throw invalid("A comment on an element names the board it is on.");
368
+ }
369
+ if (anchor.element !== undefined && (anchor.element.length > MAX_ELEMENT_ADDRESS_LENGTH || !ELEMENT_ADDRESS.test(anchor.element))) {
370
+ throw invalid(`'${anchor.element}' is no element's address, as a board's elements have.`);
371
+ }
372
+ if (anchor.board !== undefined) {
373
+ const latest = await storage.getVersion({
374
+ projectId: artifact.projectId,
375
+ artifactId: artifact.id,
376
+ version: artifact.latestVersion
377
+ });
378
+ const outline = latest?.outline;
379
+ const shows = outline?.kind === "canvas" && outline.items.some((item) => item.type === "board" && item.id === anchor.board);
380
+ if (!shows)
381
+ throw invalid(`The artifact shows no board '${anchor.board}'.`);
382
+ }
383
+ const { point } = anchor;
384
+ if (point !== undefined && anchor.board === undefined) {
385
+ throw invalid("A comment's point is on the board it names.");
386
+ }
387
+ if (point !== undefined && ![point.x, point.y].every((value) => Number.isFinite(value) && value >= 0 && value <= 1)) {
388
+ throw invalid("A comment's point is on its board: x and y from 0 to 1.");
389
+ }
390
+ const label = anchor.label?.replace(/\s+/g, " ").trim().slice(0, ARTIFACT_COMMENT_LIMITS2.maxLabelLength);
391
+ return {
392
+ ...anchor.board === undefined ? {} : { board: anchor.board },
393
+ ...anchor.element === undefined ? {} : { element: anchor.element },
394
+ ...label ? { label } : {},
395
+ ...point === undefined ? {} : { point: { x: point.x, y: point.y } },
396
+ revision
397
+ };
398
+ }
399
+ function commentRequestError(error) {
400
+ if (!(error instanceof ArtifactStorageError))
401
+ return error;
402
+ switch (error.code) {
403
+ case "artifact_not_found":
404
+ return new ArtifactRequestError2("artifact_not_found", error.message);
405
+ case "comment_not_found":
406
+ return new ArtifactRequestError2("comment_not_found", error.message);
407
+ case "artifact_comments_full":
408
+ return new ArtifactRequestError2("comments_full", error.message);
409
+ default:
410
+ return error;
411
+ }
412
+ }
413
+ function invalid(message) {
414
+ return new ArtifactRequestError2("invalid_comment", `[Sixb] ${message}`);
415
+ }
416
+ function notFound(artifactId) {
417
+ return new ArtifactRequestError2("artifact_not_found", `[Sixb] Artifact '${artifactId}' was not found.`);
418
+ }
419
+ function commentNotFound(artifactId, commentId) {
420
+ return new ArtifactRequestError2("comment_not_found", `[Sixb] Artifact '${artifactId}' has no comment '${commentId}'.`);
421
+ }
422
+
423
+ // src/artifacts/holders.ts
424
+ var HOLDER_PAGE = 100;
425
+ async function* readableHoldings(input) {
426
+ const { runtime, reader, artifactId } = input;
427
+ let after;
428
+ do {
429
+ const page = await input.objects.listArtifactHolders({
430
+ projectId: runtime.projectId,
431
+ artifactId,
432
+ ...after ? { after } : {},
433
+ limit: HOLDER_PAGE
434
+ });
435
+ const objects = await readHolders(reader, page.holders);
436
+ for (const holder of page.holders) {
437
+ const object = objects.get(objectBatchKey2(holder.objectTypeId, holder.primaryId));
438
+ if (!object || !holdsArtifact(runtime, object, holder.propertyId, artifactId))
439
+ continue;
440
+ const edits = isRuntimeAllowed2(runtime, {
441
+ kind: "object.edit",
442
+ objectTypeId: holder.objectTypeId
443
+ });
444
+ yield { ...holder, access: edits ? "update" : "read", object };
445
+ }
446
+ after = page.next;
447
+ } while (after);
448
+ }
449
+ async function readHolders(reader, holders) {
450
+ const byType = new Map;
451
+ for (const { objectTypeId, primaryId } of holders) {
452
+ const primaryIds = byType.get(objectTypeId) ?? new Set;
453
+ byType.set(objectTypeId, primaryIds.add(primaryId));
454
+ }
455
+ const read = new Map;
456
+ for (const [objectTypeId, primaryIds] of byType) {
457
+ try {
458
+ const rows = await reader.getByPrimaryIdBatch({
459
+ items: [...primaryIds].map((primaryId) => ({ objectTypeId, primaryId }))
460
+ });
461
+ for (const [key, row] of rows)
462
+ read.set(key, row);
463
+ } catch (error) {
464
+ if (!(error instanceof AuthorizationError2))
465
+ throw error;
466
+ }
467
+ }
468
+ return read;
469
+ }
470
+ function holdsArtifact(runtime, object, propertyId, artifactId) {
471
+ const property = runtime.ontology.getObjectTypeById(object.objectTypeId)?.properties.find((candidate) => candidate.id === propertyId);
472
+ if (!property)
473
+ return false;
474
+ const held = collectArtifactRefIds(property.schema, object.properties[propertyId], runtime.ontology.getValueTypesById(), new Set);
475
+ return held.has(artifactId);
476
+ }
477
+
478
+ // src/artifacts/live/state.ts
479
+ import * as Y from "yjs";
480
+
481
+ // src/artifacts/live/files.ts
482
+ import { createHash } from "crypto";
483
+ import { posix } from "path";
484
+ var strictUtf8 = new TextDecoder("utf-8", { fatal: true });
485
+ async function readLiveFiles2(blobStorage, files) {
486
+ const read = await Promise.all(files.map(async ({ path, file }) => {
487
+ if (!isLiveTextPath(path) || file.sizeBytes > ARTIFACT_LIMITS2.maxFileBytes) {
488
+ return [path, { file }];
489
+ }
490
+ const bytes = new Uint8Array(await new Response(await blobStorage.open(file.blobId)).arrayBuffer());
491
+ try {
492
+ return [path, { text: strictUtf8.decode(bytes) }];
493
+ } catch {
494
+ return [path, { file }];
495
+ }
496
+ }));
497
+ return new Map(read.sort(([left], [right]) => left < right ? -1 : 1));
498
+ }
499
+ async function storeLiveFiles2(blobStorage, files, known) {
500
+ const byPath = new Map(known.map((entry) => [entry.path, entry.file]));
501
+ return Promise.all([...files].map(async ([path, file]) => {
502
+ if ("file" in file)
503
+ return { path, file: { ...file.file } };
504
+ const body = new TextEncoder().encode(file.text);
505
+ const digest = `sha256:${createHash("sha256").update(body).digest("hex")}`;
506
+ const before = byPath.get(path);
507
+ if (before?.digest === digest)
508
+ return { path, file: { ...before } };
509
+ const fileName = posix.basename(path);
510
+ const stored = await blobStorage.put({
511
+ body,
512
+ expectedSizeBytes: body.byteLength,
513
+ fileName,
514
+ mediaType: before?.mediaType ?? inferFileMediaType2(fileName, body)
515
+ });
516
+ return { path, file: stored };
517
+ }));
518
+ }
519
+ function sameArtifactFiles2(left, right) {
520
+ if (left.length !== right.length)
521
+ return false;
522
+ const digests = new Map(left.map((entry) => [entry.path, entry.file.digest]));
523
+ return right.every((entry) => digests.get(entry.path) === entry.file.digest);
524
+ }
525
+
526
+ // src/artifacts/live/state.ts
527
+ function keepsDocument(kind) {
528
+ return kind === "canvas";
529
+ }
530
+ async function loadArtifactDocument2(blobStorage, artifact, files) {
531
+ const doc = new Y.Doc;
532
+ const stored = artifact.document;
533
+ if (stored?.revision === artifact.revision) {
534
+ Y.applyUpdate(doc, await readDocumentState2(blobStorage, stored.file));
535
+ return doc;
536
+ }
537
+ const clientID = madeClientId(artifact.id, stored, files);
538
+ const live = await readLiveFiles2(blobStorage, files);
539
+ let made;
540
+ if (stored) {
541
+ made = new Y.Doc;
542
+ made.clientID = clientID;
543
+ Y.applyUpdate(made, await readDocumentState2(blobStorage, stored.file));
544
+ mergeIntoDocument2(made, documentFiles2(made), live);
545
+ } else {
546
+ made = createArtifactDocument(artifact.kind, live, { clientID });
547
+ }
548
+ Y.applyUpdate(doc, Y.encodeStateAsUpdate(made));
549
+ made.destroy();
550
+ return doc;
551
+ }
552
+ async function readDocumentState2(blobStorage, document) {
553
+ return new Uint8Array(await new Response(await blobStorage.open(document.blobId)).arrayBuffer());
554
+ }
555
+ async function storeArtifactDocument(blobStorage, doc) {
556
+ const body = Y.encodeStateAsUpdate(doc);
557
+ return blobStorage.put({
558
+ body,
559
+ expectedSizeBytes: body.byteLength,
560
+ fileName: "document.yjs",
561
+ mediaType: "application/octet-stream"
562
+ });
563
+ }
564
+ async function firstArtifactDocument(blobStorage, kind, files) {
565
+ if (!keepsDocument(kind))
566
+ return;
567
+ const doc = createArtifactDocument(kind, await readLiveFiles2(blobStorage, files));
568
+ try {
569
+ return await storeArtifactDocument(blobStorage, doc);
570
+ } finally {
571
+ doc.destroy();
572
+ }
573
+ }
574
+ function madeClientId(artifactId, stored, files) {
575
+ const named = [...files].map(({ path, file }) => `${path}\x00${file.digest}`).sort().join("\x01");
576
+ const from = stored ? `${stored.file.digest}@${stored.revision}` : "";
577
+ let hash = 2166136261;
578
+ for (const char of `${artifactId}\x02${from}\x02${named}`) {
579
+ hash ^= char.codePointAt(0) ?? 0;
580
+ hash = Math.imul(hash, 16777619) >>> 0;
581
+ }
582
+ return hash;
583
+ }
584
+
585
+ // src/artifacts/publish/merge.ts
586
+ import * as Y2 from "yjs";
587
+ var MERGE_ATTEMPTS = 3;
588
+ async function mergeArtifactWrite(context, write) {
589
+ const unmerged = {
590
+ files: write.files,
591
+ ...write.baseRevision === undefined ? {} : { baseRevision: write.baseRevision },
592
+ merged: false
593
+ };
594
+ if (!keepsDocument(write.kind))
595
+ return unmerged;
596
+ const { projectId, storage, blobStorage } = context;
597
+ const artifact = await storage.get({ projectId, id: write.artifactId });
598
+ const latest = artifact && await storage.getVersion({
599
+ projectId,
600
+ artifactId: artifact.id,
601
+ version: artifact.latestVersion
602
+ });
603
+ if (!artifact || !latest || artifact.kind !== write.kind)
604
+ return unmerged;
605
+ const moved = write.baseRevision !== undefined && write.baseRevision !== artifact.revision;
606
+ const doc = await loadArtifactDocument2(blobStorage, artifact, latest.files);
607
+ try {
608
+ let merged = moved;
609
+ if (write.update) {
610
+ Y2.applyUpdate(doc, write.update);
611
+ } else {
612
+ const files = moved ? write.baseFiles ?? await filesAtRevision(storage, projectId, artifact.id, write.baseRevision ?? 0) : write.baseFiles;
613
+ if (moved && !files)
614
+ return unmerged;
615
+ let base = documentFiles2(doc);
616
+ merged = files !== undefined && files !== null && !sameArtifactFiles2(files, latest.files);
617
+ if (merged && files)
618
+ base = await readLiveFiles2(blobStorage, files);
619
+ mergeIntoDocument2(doc, base, await readLiveFiles2(blobStorage, write.files));
620
+ }
621
+ const files = merged || write.update ? await storeLiveFiles2(blobStorage, documentFiles2(doc), [...latest.files, ...write.files]) : write.files;
622
+ const renamed = moved && write.baseTitle !== undefined && write.title === write.baseTitle && artifact.title !== write.title;
623
+ return {
624
+ files,
625
+ baseRevision: artifact.revision,
626
+ merged,
627
+ document: await storeArtifactDocument(blobStorage, doc),
628
+ ...renamed ? { title: artifact.title } : {}
629
+ };
630
+ } finally {
631
+ doc.destroy();
632
+ }
633
+ }
634
+ async function withMergedWrite(context, write, store) {
635
+ for (let attempt = 1;; attempt += 1) {
636
+ const merged = await mergeArtifactWrite(context, write);
637
+ try {
638
+ return await store(merged);
639
+ } catch (error) {
640
+ if (!isMoved(error) || !keepsDocument(write.kind) || attempt === MERGE_ATTEMPTS)
641
+ throw error;
642
+ }
643
+ }
644
+ }
645
+ async function documentHolding(context, artifactId, files) {
646
+ const { projectId, storage, blobStorage } = context;
647
+ const artifact = await storage.get({ projectId, id: artifactId });
648
+ if (!artifact || !keepsDocument(artifact.kind))
649
+ return null;
650
+ const latest = await storage.getVersion({
651
+ projectId,
652
+ artifactId,
653
+ version: artifact.latestVersion
654
+ });
655
+ if (!latest)
656
+ return null;
657
+ const doc = await loadArtifactDocument2(blobStorage, artifact, latest.files);
658
+ try {
659
+ mergeIntoDocument2(doc, documentFiles2(doc), await readLiveFiles2(blobStorage, files));
660
+ return {
661
+ document: await storeArtifactDocument(blobStorage, doc),
662
+ baseRevision: artifact.revision
663
+ };
664
+ } finally {
665
+ doc.destroy();
666
+ }
667
+ }
668
+ async function withDocumentHolding(context, artifactId, files, baseRevision, store) {
669
+ for (let attempt = 1;; attempt += 1) {
670
+ const held = files ? await documentHolding(context, artifactId, files) : null;
671
+ const base = baseRevision ?? held?.baseRevision;
672
+ const fits = held && (baseRevision === undefined || baseRevision === held.baseRevision);
673
+ try {
674
+ return await store({
675
+ ...fits ? { document: held.document } : {},
676
+ ...base === undefined ? {} : { baseRevision: base }
677
+ });
678
+ } catch (error) {
679
+ if (!isMoved(error) || baseRevision !== undefined || !held || attempt === MERGE_ATTEMPTS) {
680
+ throw error;
681
+ }
682
+ }
683
+ }
684
+ }
685
+ async function undoneTurnDocuments(context, turnRunId) {
686
+ const { projectId, storage } = context;
687
+ const documents = {};
688
+ for (const write of await storage.listTurnWrites({ projectId, turnRunId })) {
689
+ if (write.created)
690
+ continue;
691
+ const artifact = await storage.get({ projectId, id: write.artifactId });
692
+ if (!artifact || !keepsDocument(artifact.kind))
693
+ continue;
694
+ const points = await storage.listRestorePoints({ projectId, id: artifact.id });
695
+ const point = points.find((each) => each.turnRunId === turnRunId);
696
+ const target = point && await storage.getVersion({ projectId, artifactId: artifact.id, version: point.version });
697
+ const undoable = turnUndoable2({
698
+ write,
699
+ revision: artifact.revision,
700
+ ...point ? { point } : {},
701
+ ...target ? { target: { frozen: target.frozenAt !== undefined } } : {}
702
+ });
703
+ if (!point || !undoable)
704
+ continue;
705
+ const held = await documentHolding(context, artifact.id, point.files);
706
+ if (held?.baseRevision === artifact.revision)
707
+ documents[artifact.id] = held.document;
708
+ }
709
+ return documents;
710
+ }
711
+ function isMoved(error) {
712
+ return (error instanceof ArtifactRequestError2 || error instanceof ArtifactStorageError) && error.code === "artifact_moved";
713
+ }
714
+ async function filesAtRevision(storage, projectId, artifactId, revision) {
715
+ const point = await storage.getRestorePoint({ projectId, artifactId, revision });
716
+ if (point)
717
+ return point.files;
718
+ const { versions } = await storage.listVersions({ projectId, artifactId, limit: 50 });
719
+ return versions.find((version) => version.revision === revision)?.files ?? null;
720
+ }
721
+
722
+ // src/artifacts/publish/previews.ts
723
+ import { createHash as createHash2 } from "crypto";
724
+
725
+ // src/artifacts/publish/query-answers.ts
726
+ async function answerArtifactQuery(read) {
727
+ try {
728
+ const result = await read();
729
+ if (!result)
730
+ return { error: UNREADABLE };
731
+ return { result: serializeArtifactQueryResult2(result) };
732
+ } catch (error) {
733
+ if (error instanceof ArtifactRequestError2 || error instanceof AuthorizationError2 || error instanceof ObjectQueryExecutionError2) {
734
+ return { error: /[.!?]$/.test(error.message) ? error.message : `${error.message}.` };
735
+ }
736
+ console.warn("[Sixb] A query of an artifact version did not run:", error);
737
+ return { error: UNREADABLE };
738
+ }
739
+ }
740
+ async function answerArtifactQueries2(version, read) {
741
+ const names = version.files.flatMap((file) => {
742
+ const name = artifactQueryName2(file.path);
743
+ return name === undefined ? [] : [name];
744
+ });
745
+ const answers = await Promise.all(names.map(async (name) => [name, await answerArtifactQuery(() => read(name))]));
746
+ return Object.fromEntries(answers);
747
+ }
748
+ function parseArtifactQueryAnswers2(text) {
749
+ let value;
750
+ try {
751
+ value = JSON.parse(text);
752
+ } catch {
753
+ return null;
754
+ }
755
+ if (!isObject(value))
756
+ return null;
757
+ const answers = {};
758
+ for (const [name, answer] of Object.entries(value)) {
759
+ if (!isArtifactQueryName(name) || !isObject(answer))
760
+ return null;
761
+ if ("result" in answer)
762
+ answers[name] = { result: answer.result };
763
+ else if (typeof answer.error === "string")
764
+ answers[name] = { error: answer.error };
765
+ else
766
+ return null;
188
767
  }
768
+ return answers;
769
+ }
770
+ var UNREADABLE = "[Sixb] The query could not be read.";
771
+ function isObject(value) {
772
+ return typeof value === "object" && value !== null && !Array.isArray(value);
773
+ }
774
+
775
+ // src/artifacts/publish/previews.ts
776
+ var BOARD_PREVIEW_MEDIA_TYPES2 = {
777
+ full: "image/png",
778
+ small: "image/webp"
779
+ };
780
+ var SIZES = ["full", "small"];
781
+ var MAX_BOARD_PREVIEW_BYTES2 = 8 * 1024 * 1024;
782
+ var RENDER_KEY_FORMAT = "sixb-board-preview/1";
783
+ function boardRenderKey(input) {
784
+ const { board, files, boardFiles, author, artifactId } = input;
785
+ const loaded = files.filter((entry) => entry.path !== CANVAS_FILE2 && (entry.path === board.file || !boardFiles.has(entry.path))).map((entry) => [entry.path, entry.file.digest]).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0);
786
+ const reader = boardsReadLiveData2({ files }) ? [author.type, author.id] : null;
787
+ return createHash2("sha256").update(JSON.stringify([
788
+ RENDER_KEY_FORMAT,
789
+ frameKitDigest(),
790
+ board.file,
791
+ board.w,
792
+ board.h,
793
+ artifactId,
794
+ reader,
795
+ loaded
796
+ ])).digest("hex");
797
+ }
798
+ function canvasPreviewOutline(outline, themes) {
799
+ return { ...outline, themes: [...themes] };
800
+ }
801
+ function withBoardRenderKeys(version, artifactId) {
802
+ const { outline } = version;
803
+ if (outline.kind !== "canvas")
804
+ return version;
805
+ const boardFiles = new Set(outline.items.flatMap((item) => item.type === "board" ? [item.file] : []));
806
+ return {
807
+ ...version,
808
+ outline: {
809
+ ...outline,
810
+ items: outline.items.map((item) => item.type === "board" ? {
811
+ ...item,
812
+ renderKey: boardRenderKey({
813
+ board: item,
814
+ files: version.files,
815
+ boardFiles,
816
+ author: version.author,
817
+ artifactId
818
+ })
819
+ } : item)
820
+ }
821
+ };
822
+ }
823
+ function boardPreviewsOfCopy(copyId) {
824
+ const renamed = new Map;
825
+ const outlineOf = (version) => {
826
+ if (version.outline.kind !== "canvas")
827
+ return;
828
+ const copied = withBoardRenderKeys(version, copyId);
829
+ if (boardsReadLiveData2(version))
830
+ return copied.outline;
831
+ const source = new Map(previewedBoards(version).boards.map((each) => [each.id, each.renderKey]));
832
+ for (const board of previewedBoards(copied).boards) {
833
+ const from = source.get(board.id);
834
+ if (from)
835
+ renamed.set(from, board.renderKey);
836
+ }
837
+ return copied.outline;
838
+ };
839
+ const carry = async (storage, projectId) => {
840
+ if (renamed.size === 0)
841
+ return;
842
+ const pictures = await storage.listBoardPreviews({ projectId, renderKeys: [...renamed.keys()] });
843
+ const previews = pictures.flatMap((picture) => {
844
+ const renderKey = renamed.get(picture.renderKey);
845
+ return renderKey ? [{ ...picture, renderKey }] : [];
846
+ });
847
+ if (previews.length > 0)
848
+ await storage.putBoardPreviews({ projectId, previews });
849
+ };
850
+ return { outlineOf, carry };
851
+ }
852
+ function previewedBoards(version) {
853
+ const { outline } = version;
854
+ if (outline.kind !== "canvas" || !outline.themes)
855
+ return { boards: [], themes: [] };
856
+ return {
857
+ boards: outline.items.flatMap((item) => item.type === "board" && item.renderKey ? [{ ...item, renderKey: item.renderKey }] : []),
858
+ themes: outline.themes
859
+ };
860
+ }
861
+ function boardsReadLiveData2(version) {
862
+ return version.files.some((file) => artifactQueryName2(file.path) !== undefined);
863
+ }
864
+ async function boardPreviews2(storage, version) {
865
+ const { boards } = previewedBoards(version);
866
+ if (boards.length === 0)
867
+ return new Map;
868
+ const stored = await storage.listBoardPreviews({
869
+ projectId: version.projectId,
870
+ renderKeys: [...new Set(boards.map((board) => board.renderKey))]
871
+ });
872
+ return new Map(boards.map((board) => [
873
+ board.id,
874
+ stored.filter((preview) => preview.renderKey === board.renderKey)
875
+ ]));
876
+ }
877
+ function boardPreview2(pictures, theme, size) {
878
+ return pictures?.find((picture) => picture.theme === theme && picture.size === size);
879
+ }
880
+ function pictured(pictures, theme) {
881
+ return SIZES.every((size) => boardPreview2(pictures, theme, size));
882
+ }
883
+ async function missingBoardPreviews2(storage, version) {
884
+ const { boards, themes } = previewedBoards(version);
885
+ const stored = await boardPreviews2(storage, version);
886
+ return boards.flatMap((board) => {
887
+ const missing = themes.filter((theme) => !pictured(stored.get(board.id), theme));
888
+ return missing.length === 0 ? [] : [{ board, renderKey: board.renderKey, themes: missing }];
889
+ });
890
+ }
891
+ async function boardPreviewStatuses2(storage, version, input) {
892
+ const { boards, themes } = previewedBoards(version);
893
+ const stored = await boardPreviews2(storage, version);
894
+ const waiting = input.renders && input.now.getTime() - version.updatedAt.getTime() < BOARD_PREVIEW_WAIT_MS2;
895
+ return new Map(boards.map((board) => {
896
+ const ready = themes.every((theme) => pictured(stored.get(board.id), theme));
897
+ return [board.id, ready ? "ready" : waiting ? "pending" : "none"];
898
+ }));
899
+ }
900
+ async function storeBoardPreviews2(context, version, previews) {
901
+ if (previews.length === 0)
902
+ return [];
903
+ const { boards, themes } = previewedBoards(version);
904
+ const keys = new Map(boards.map((board) => [board.id, board.renderKey]));
905
+ const createdAt = new Date;
906
+ const checked = await Promise.all(previews.map(async (preview) => {
907
+ const { board, theme, size, file } = preview;
908
+ const refuse = (reason) => ({ refused: { board, theme, size, reason } });
909
+ const renderKey = keys.get(board);
910
+ if (!renderKey || !themes.includes(theme)) {
911
+ return refuse(`the version has no board '${board}' to picture in ${theme} mode`);
912
+ }
913
+ const mediaType = SIZES.includes(size) ? BOARD_PREVIEW_MEDIA_TYPES2[size] : undefined;
914
+ if (!mediaType || !isValidFileRef(file) || file.mediaType !== mediaType) {
915
+ return refuse(`a ${size} picture must be ${mediaType ?? "full or small"}`);
916
+ }
917
+ if (file.sizeBytes > MAX_BOARD_PREVIEW_BYTES2) {
918
+ return refuse(`it is ${file.sizeBytes} bytes, past the ${MAX_BOARD_PREVIEW_BYTES2} kept`);
919
+ }
920
+ if (!await statFileRef2(context.blobStorage, file))
921
+ return refuse("it is not stored");
922
+ return { record: { renderKey, theme, size, file: { ...file }, createdAt } };
923
+ }));
924
+ const records = checked.flatMap((each) => ("record" in each) ? [each.record] : []);
925
+ if (records.length > 0) {
926
+ await context.storage.putBoardPreviews({ projectId: version.projectId, previews: records });
927
+ }
928
+ return checked.flatMap((each) => ("refused" in each) ? [each.refused] : []);
929
+ }
930
+ function boardPreviewsJobId(artifactId) {
931
+ return `art_previews_${artifactId}`;
932
+ }
933
+ async function requestBoardPreviews(input, version, options = {}) {
934
+ if (version.outline.kind !== "canvas")
935
+ return;
936
+ try {
937
+ if ((await missingBoardPreviews2(input.storage, version)).length === 0)
938
+ return;
939
+ const queries = boardsReadLiveData2(version) && !options.withoutAnswers ? await storeQueryAnswers(input, version) : undefined;
940
+ const delayMs = options.delayMs ?? BOARD_PREVIEW_JOB2.settleMs;
941
+ await input.queue.enqueue({
942
+ projectId: version.projectId,
943
+ jobs: [
944
+ {
945
+ id: boardPreviewsJobId(version.artifactId),
946
+ replace: true,
947
+ type: "agent.artifact-previews.requested",
948
+ payload: {
949
+ artifactId: version.artifactId,
950
+ version: version.version,
951
+ updatedAt: version.updatedAt.toISOString(),
952
+ ...queries ? { queries } : {}
953
+ },
954
+ availableAt: new Date(Date.now() + delayMs).toISOString()
955
+ }
956
+ ]
957
+ });
958
+ } catch (error) {
959
+ console.error(`[Sixb] Could not ask for the previews of version ${version.version} of '${version.artifactId}'; its boards show their outlines.`, error);
960
+ }
961
+ }
962
+ async function storeQueryAnswers(input, version) {
963
+ const answers = await answerArtifactQueries2(version, input.query);
964
+ const body = new TextEncoder().encode(JSON.stringify(answers));
965
+ return input.blobStorage.put({
966
+ body,
967
+ expectedSizeBytes: body.byteLength,
968
+ fileName: `${version.artifactId}-r${version.revision}-queries.json`,
969
+ mediaType: "application/json"
970
+ });
971
+ }
972
+ var kitDigest;
973
+ function frameKitDigest() {
974
+ kitDigest ??= createHash2("sha256").update(JSON.stringify([FRAME_ASSETS2, FRAME_DEFAULT_THEMES2])).digest("hex");
975
+ return kitDigest;
189
976
  }
190
977
 
191
978
  // src/artifacts/run-query.ts
@@ -509,6 +1296,9 @@ async function resolveReferences(context, found) {
509
1296
  const target = await version;
510
1297
  if (!target)
511
1298
  throw invalidArtifact(`${where}: \u201C${record.title}\u201D has no version ${number}.`);
1299
+ if (address.version !== undefined && !target.frozenAt) {
1300
+ throw invalidArtifact(`${where} pins version ${number} of \u201C${record.title}\u201D, which is still open and changes with every write. Write artifact:${record.id} without @${number} to follow its latest version; a version can be pinned once someone creates it.`);
1301
+ }
512
1302
  const result = resolveArtifactAddress2(address, { kind: record.kind, ...target });
513
1303
  if ("problem" in result) {
514
1304
  throw invalidArtifact(`${where}: \u201C${target.title}\u201D ${result.problem}.`);
@@ -536,7 +1326,7 @@ async function brokenDependents(context, artifact, version) {
536
1326
  continue;
537
1327
  broken.push({
538
1328
  code: "reference_broken",
539
- message: `\u201C${dependent.title}\u201D (${dependent.artifactId}) ${reference.as === "embed" ? "shows" : "links to"} ${reference.address}, but version ${version.version} ${result.problem}. Publish its next version with an address that resolves, or restore what it names.`
1329
+ message: `\u201C${dependent.title}\u201D (${dependent.artifactId}) ${reference.as === "embed" ? "shows" : "links to"} ${reference.address}, but version ${version.version} ${result.problem}. Update it with an address that resolves, or restore what it names.`
540
1330
  });
541
1331
  }
542
1332
  if (broken.length === 0)
@@ -555,7 +1345,7 @@ function ownArtifacts(author) {
555
1345
  }
556
1346
 
557
1347
  // src/artifacts/publish/validate/canvas.ts
558
- import { posix } from "path";
1348
+ import { posix as posix2 } from "path";
559
1349
  async function validateCanvas(blobStorage, files) {
560
1350
  const byPath = new Map(files.map((file) => [file.path, file]));
561
1351
  const canvasFile = byPath.get(CANVAS_FILE2);
@@ -573,7 +1363,7 @@ async function validateCanvas(blobStorage, files) {
573
1363
  references.push({ address: item.src, as: "embed", at: item.id });
574
1364
  if (item.type !== "board")
575
1365
  continue;
576
- const file = byPath.get(posix.normalize(item.file));
1366
+ const file = byPath.get(posix2.normalize(item.file));
577
1367
  if (!file) {
578
1368
  throw invalidArtifact(`${CANVAS_FILE2} board '${item.id}' shows '${item.file}', which is not one of the canvas's files.`);
579
1369
  }
@@ -594,14 +1384,18 @@ async function validateCanvas(blobStorage, files) {
594
1384
  const named = { id: item.id, ...title ? { title } : {} };
595
1385
  if (item.type === "board") {
596
1386
  return [
597
- { ...named, type: "board", file: posix.normalize(item.file), w: item.w, h: item.h }
1387
+ { ...named, type: "board", file: posix2.normalize(item.file), w: item.w, h: item.h }
598
1388
  ];
599
1389
  }
600
1390
  return item.type === "section" ? [{ ...named, type: "section" }] : [];
601
1391
  })
602
1392
  },
603
1393
  references,
604
- warnings: layoutWarnings(canvas)
1394
+ warnings: [
1395
+ ...layoutWarnings(canvas),
1396
+ ...overprintWarnings(canvas),
1397
+ ...crossingArrowWarnings(canvas)
1398
+ ]
605
1399
  };
606
1400
  }
607
1401
  var overlaps = (a, b) => a.x < b.x + b.w && b.x < a.x + a.w && a.y < b.y + b.h && b.y < a.y + a.h;
@@ -634,9 +1428,102 @@ function layoutWarnings(canvas) {
634
1428
  }
635
1429
  return warnings;
636
1430
  }
1431
+ var MAX_OVERPRINTS = 12;
1432
+ function overprintWarnings(canvas) {
1433
+ const worded = canvas.items.flatMap((item) => {
1434
+ if (item.type !== "text" && item.type !== "note")
1435
+ return [];
1436
+ const box = canvasItemBox(item);
1437
+ return box ? [{ item, box }] : [];
1438
+ });
1439
+ const pairs = worded.flatMap((first, index) => worded.slice(index + 1).filter((second) => intersects(first.box, second.box)).map((second) => [first.item, second.item]));
1440
+ const warnings = pairs.slice(0, MAX_OVERPRINTS).map(([first, second]) => ({
1441
+ code: "canvas_text_overlap",
1442
+ part: first.id,
1443
+ message: `${first.type === "note" ? "Note" : "Text"} '${first.id}' and ${second.type} '${second.id}' are drawn over each other, so neither reads: move one clear of the other.`
1444
+ }));
1445
+ const more = pairs.length - warnings.length;
1446
+ if (more > 0) {
1447
+ warnings.push({
1448
+ code: "canvas_text_overlap",
1449
+ message: `${more} more pair${more === 1 ? " is" : "s are"} drawn over each other.`
1450
+ });
1451
+ }
1452
+ return warnings;
1453
+ }
1454
+ function intersects(a, b) {
1455
+ return a.x < b.x + b.width && b.x < a.x + a.width && a.y < b.y + b.height && b.y < a.y + a.height;
1456
+ }
1457
+ var MAX_CROSSING_ARROWS = 12;
1458
+ var MAX_CROSSED_ITEMS = 3;
1459
+ function crossingArrowWarnings(canvas) {
1460
+ const boxes = new Map(canvas.items.flatMap((item) => {
1461
+ const box = canvasItemBox(item);
1462
+ return box ? [[item.id, box]] : [];
1463
+ }));
1464
+ const crossable = canvas.items.filter((item) => item.type !== "arrow" && item.type !== "section");
1465
+ const crossing = canvas.items.flatMap((arrow) => {
1466
+ if (arrow.type !== "arrow")
1467
+ return [];
1468
+ const from = canvasEndBox(arrow.from, boxes);
1469
+ const to = canvasEndBox(arrow.to, boxes);
1470
+ if (!from || !to)
1471
+ return [];
1472
+ const { start, end } = canvasArrowLine2(from, to);
1473
+ const crossed = crossable.filter((item) => {
1474
+ const box = boxes.get(item.id);
1475
+ return item.id !== arrow.from && item.id !== arrow.to && box && crosses(start, end, box);
1476
+ });
1477
+ return crossed.length === 0 ? [] : [{ arrow, crossed }];
1478
+ });
1479
+ const warnings = crossing.slice(0, MAX_CROSSING_ARROWS).map(({ arrow, crossed }) => {
1480
+ const named = crossed.slice(0, MAX_CROSSED_ITEMS).map((item) => `${item.type} '${item.id}'`);
1481
+ const more = crossed.length - named.length;
1482
+ return {
1483
+ code: "canvas_arrow_crosses",
1484
+ part: arrow.id,
1485
+ message: `Arrow '${arrow.id}' is drawn across ${named.join(", ")}${more > 0 ? ` and ${more} more` : ""}: join neighbours in a row with arrows, and let a sequence that wraps to the next row read on without one.`
1486
+ };
1487
+ });
1488
+ const more = crossing.length - warnings.length;
1489
+ if (more > 0) {
1490
+ warnings.push({
1491
+ code: "canvas_arrow_crosses",
1492
+ message: `${more} more arrow${more === 1 ? " is" : "s are"} drawn across other items.`
1493
+ });
1494
+ }
1495
+ return warnings;
1496
+ }
1497
+ function crosses(start, end, box) {
1498
+ const dx = end.x - start.x;
1499
+ const dy = end.y - start.y;
1500
+ let enter = 0;
1501
+ let leave = 1;
1502
+ const edges = [
1503
+ [-dx, start.x - box.x],
1504
+ [dx, box.x + box.width - start.x],
1505
+ [-dy, start.y - box.y],
1506
+ [dy, box.y + box.height - start.y]
1507
+ ];
1508
+ for (const [direction, room] of edges) {
1509
+ if (direction === 0) {
1510
+ if (room <= 0)
1511
+ return false;
1512
+ continue;
1513
+ }
1514
+ const at = room / direction;
1515
+ if (direction < 0)
1516
+ enter = Math.max(enter, at);
1517
+ else
1518
+ leave = Math.min(leave, at);
1519
+ if (enter >= leave)
1520
+ return false;
1521
+ }
1522
+ return true;
1523
+ }
637
1524
 
638
1525
  // src/artifacts/publish/validate/document.ts
639
- import { posix as posix2 } from "path";
1526
+ import { posix as posix3 } from "path";
640
1527
  var DOCUMENT_ENTRY = "document.md";
641
1528
  async function validateDocument(blobStorage, files) {
642
1529
  const entry = files.find((file) => file.path === DOCUMENT_ENTRY);
@@ -704,7 +1591,7 @@ function checkImage(source, paths) {
704
1591
  if (source === "" || source.startsWith("//") || /^[a-z][a-z\d+.-]*:/i.test(source)) {
705
1592
  throw invalidArtifact(`${DOCUMENT_ENTRY} shows the image '${source}'. Images must be files in the artifact, by their relative path, or another artifact's address, such as artifact:art_k3m9q2x7tp#chart=revenue.`);
706
1593
  }
707
- const path = posix2.normalize(safeDecodeUri(source.split(/[?#]/)[0] ?? ""));
1594
+ const path = posix3.normalize(safeDecodeUri(source.split(/[?#]/)[0] ?? ""));
708
1595
  if (!paths.has(path)) {
709
1596
  throw invalidArtifact(`${DOCUMENT_ENTRY} shows the image '${source}', which is not one of the artifact's files.`);
710
1597
  }
@@ -774,7 +1661,7 @@ async function validatePage(blobStorage, files) {
774
1661
  }
775
1662
 
776
1663
  // src/artifacts/publish/validate/sheet.ts
777
- import { posix as posix3 } from "path";
1664
+ import { posix as posix4 } from "path";
778
1665
  async function validateSheet(blobStorage, files, queries) {
779
1666
  const byPath = new Map(files.map((file) => [file.path, file]));
780
1667
  const workbookFile = byPath.get(WORKBOOK_FILE2);
@@ -934,7 +1821,7 @@ function cellProblem(value, format, byPath) {
934
1821
  case "link":
935
1822
  return /^https?:\/\/[^\s]+$/i.test(value.trim()) ? undefined : "is not a link: write a full https:// address, or another artifact's address.";
936
1823
  case "image": {
937
- const imagePath = posix3.normalize(value.trim());
1824
+ const imagePath = posix4.normalize(value.trim());
938
1825
  return byPath.has(imagePath) ? undefined : "is not one of the artifact's files: add the image to the artifact and give its relative path, or give another artifact's address.";
939
1826
  }
940
1827
  case "boolean":
@@ -1014,6 +1901,10 @@ async function validateSlides(blobStorage, files) {
1014
1901
 
1015
1902
  // src/artifacts/publish/publish.ts
1016
1903
  var CREATE_ATTEMPTS = 3;
1904
+ var LIVE_BOARD_PREVIEWS = {
1905
+ code: "canvas_previews_show_author_data",
1906
+ message: "Its boards read live data, so each board's preview shows the data its author can see, to everyone who can open the canvas, until they open the board."
1907
+ };
1017
1908
  async function publishArtifact2(context, input, access) {
1018
1909
  const prepared = await prepareArtifactVersion2(context, input);
1019
1910
  const stored = await storeArtifactVersion2(context, prepared, access);
@@ -1022,39 +1913,42 @@ async function publishArtifact2(context, input, access) {
1022
1913
  async function prepareArtifactVersion2(context, input) {
1023
1914
  const title = checkTitle(input.title);
1024
1915
  await checkArtifactFiles(context.blobStorage, input.files);
1025
- if (input.kind !== "file")
1026
- await checkTheme(context.blobStorage, input.files);
1916
+ const theme = input.kind === "file" ? undefined : await readTheme(context.blobStorage, input.files);
1027
1917
  const queries = await checkArtifactQueries(context.blobStorage, input.kind, input.files, input.checkQuery);
1028
1918
  const validated = await validateKind(context.blobStorage, input.kind, input.files, queries);
1029
1919
  const readable = input.readable ?? ownArtifacts(input.author);
1030
1920
  const references = await resolveReferences(referenceContext(context, { readable, artifactId: input.artifactId }), validated.references ?? []);
1031
1921
  return {
1032
1922
  ...input.artifactId ? { artifactId: input.artifactId } : {},
1033
- ...input.baseVersion === undefined ? {} : { baseVersion: input.baseVersion },
1923
+ ...input.baseRevision === undefined ? {} : { baseRevision: input.baseRevision },
1924
+ ...input.turnRunId === undefined ? {} : { turnRunId: input.turnRunId },
1925
+ ...input.document ? { document: input.document } : {},
1034
1926
  kind: input.kind,
1035
1927
  owner: input.owner ?? input.author,
1036
1928
  readable,
1037
- warnings: validated.warnings ?? [],
1929
+ warnings: [
1930
+ ...validated.warnings ?? [],
1931
+ ...input.kind === "canvas" && queries.size > 0 ? [LIVE_BOARD_PREVIEWS] : []
1932
+ ],
1038
1933
  version: {
1039
1934
  title,
1040
1935
  entry: validated.entry,
1041
1936
  files: input.files.map(({ path, file }) => ({ path, file: { ...file } })),
1042
- outline: validated.outline,
1937
+ outline: validated.outline.kind === "canvas" ? canvasPreviewOutline(validated.outline, artifactThemeModes2(theme)) : validated.outline,
1043
1938
  references,
1044
1939
  author: input.author,
1045
1940
  ...input.origin ? { origin: input.origin } : {},
1046
- createdAt: new Date
1941
+ updatedAt: new Date
1047
1942
  }
1048
1943
  };
1049
1944
  }
1050
1945
  async function storeArtifactVersion2(context, prepared, access) {
1051
1946
  const { artifactId } = prepared;
1052
- if (!artifactId) {
1053
- return createArtifact(context, prepared.kind, prepared.owner, prepared.version);
1054
- }
1947
+ if (!artifactId)
1948
+ return createArtifact(context, prepared);
1055
1949
  const artifact = await context.storage.get({ projectId: context.projectId, id: artifactId });
1056
1950
  if (!artifact)
1057
- throw notFound(artifactId);
1951
+ throw notFound2(artifactId);
1058
1952
  assertUpdatable(artifactId, await access(artifact));
1059
1953
  return publishVersion(context, artifactId, prepared);
1060
1954
  }
@@ -1097,13 +1991,14 @@ async function validateKind(blobStorage, kind, files, queries) {
1097
1991
  throw invalidArtifact(`'${kind}' is not a kind of artifact.`);
1098
1992
  }
1099
1993
  }
1100
- async function checkTheme(blobStorage, files) {
1994
+ async function readTheme(blobStorage, files) {
1101
1995
  const themeFile = files.find((file) => file.path === ARTIFACT_THEME_FILE2);
1102
1996
  if (!themeFile)
1103
1997
  return;
1104
1998
  const parsed = parseArtifactTheme2(await readArtifactText(blobStorage, themeFile, ARTIFACT_LIMITS2.maxThemeBytes));
1105
1999
  if ("error" in parsed)
1106
2000
  throw invalidArtifact(parsed.error);
2001
+ return parsed.theme;
1107
2002
  }
1108
2003
  function checkTitle(value) {
1109
2004
  const title = typeof value === "string" ? value.trim() : "";
@@ -1121,34 +2016,44 @@ async function publishVersion(context, artifactId, prepared) {
1121
2016
  projectId: context.projectId,
1122
2017
  artifactId,
1123
2018
  kind: prepared.kind,
1124
- version: prepared.version,
1125
- ...prepared.baseVersion === undefined ? {} : { baseVersion: prepared.baseVersion }
2019
+ version: withBoardRenderKeys(prepared.version, artifactId),
2020
+ ...prepared.baseRevision === undefined ? {} : { baseRevision: prepared.baseRevision },
2021
+ ...prepared.turnRunId === undefined ? {} : { turnRunId: prepared.turnRunId },
2022
+ ...prepared.document ? { document: prepared.document } : {}
1126
2023
  });
1127
2024
  } catch (error) {
1128
- if (error instanceof ArtifactStorageError && error.code === "artifact_not_found") {
1129
- throw new ArtifactRequestError2("artifact_not_found", error.message);
1130
- }
1131
- if (error instanceof ArtifactStorageError && error.code === "artifact_kind_mismatch") {
1132
- throw new ArtifactRequestError2("artifact_kind_mismatch", error.message);
1133
- }
1134
- if (error instanceof ArtifactStorageError && error.code === "artifact_moved") {
1135
- throw new ArtifactRequestError2("artifact_moved", error.message, error.latest);
1136
- }
1137
- throw error;
2025
+ throw artifactRequestError(error);
1138
2026
  }
1139
2027
  }
1140
- function notFound(artifactId) {
2028
+ function artifactRequestError(error) {
2029
+ if (!(error instanceof ArtifactStorageError))
2030
+ return error;
2031
+ switch (error.code) {
2032
+ case "artifact_not_found":
2033
+ case "artifact_kind_mismatch":
2034
+ case "restore_point_not_found":
2035
+ return new ArtifactRequestError2(error.code, error.message);
2036
+ case "artifact_moved":
2037
+ return new ArtifactRequestError2("artifact_moved", error.message, error.latest);
2038
+ default:
2039
+ return error;
2040
+ }
2041
+ }
2042
+ function notFound2(artifactId) {
1141
2043
  return new ArtifactRequestError2("artifact_not_found", `[Sixb] Artifact '${artifactId}' was not found.`);
1142
2044
  }
1143
- async function createArtifact(context, kind, owner, version) {
2045
+ async function createArtifact(context, prepared) {
1144
2046
  for (let attempt = 1;; attempt += 1) {
2047
+ const id = createArtifactId();
1145
2048
  try {
1146
2049
  return await context.storage.create({
1147
2050
  projectId: context.projectId,
1148
- id: createArtifactId(),
1149
- kind,
1150
- owner,
1151
- version
2051
+ id,
2052
+ kind: prepared.kind,
2053
+ owner: prepared.owner,
2054
+ version: withBoardRenderKeys(prepared.version, id),
2055
+ ...prepared.turnRunId === undefined ? {} : { turnRunId: prepared.turnRunId },
2056
+ ...prepared.document ? { document: prepared.document } : {}
1152
2057
  });
1153
2058
  } catch (error) {
1154
2059
  const collided = error instanceof ArtifactStorageError && error.code === "artifact_exists";
@@ -1166,13 +2071,29 @@ function publisherOf(artifacts) {
1166
2071
  throw new Error("[Sixb] These artifacts are not a Sixb runtime's.");
1167
2072
  return publisher;
1168
2073
  }
1169
- function artifactAccessRule2(artifacts, storage) {
1170
- return publisherOf(artifacts).rule(storage);
2074
+ function artifactAccessRule2(artifacts) {
2075
+ return publisherOf(artifacts).rule();
2076
+ }
2077
+ function artifactTransactionRules(artifacts) {
2078
+ return publisherOf(artifacts).transactionRules();
1171
2079
  }
1172
2080
  function artifactQueryChecker2(artifacts) {
1173
2081
  return publisherOf(artifacts).checkQuery;
1174
2082
  }
1175
- function createRuntimeArtifactAccessRule(runtime, storage = runtime.storage) {
2083
+ function artifactPreviewRequester(artifacts) {
2084
+ return publisherOf(artifacts).requestPreviews;
2085
+ }
2086
+ function writeLiveArtifact2(artifacts, artifactId, write) {
2087
+ return publisherOf(artifacts).writeLive(artifactId, write);
2088
+ }
2089
+ function createRuntimeArtifactAccessRule(runtime) {
2090
+ return accessRuleIn(runtime, runtime.storage, runtime.objectReader);
2091
+ }
2092
+ async function transactionArtifactAccessRules(runtime) {
2093
+ const readerIn = await objectReadersIn(runtime.objectReader);
2094
+ return (tx) => accessRuleIn(runtime, tx, readerIn(tx.objects));
2095
+ }
2096
+ function accessRuleIn(runtime, storage, reader) {
1176
2097
  const artifacts = storage.artifacts;
1177
2098
  if (!artifacts) {
1178
2099
  throw new ArtifactRequestError2("storage_unavailable", "[Sixb] Artifacts need storage that supports them.");
@@ -1182,16 +2103,46 @@ function createRuntimeArtifactAccessRule(runtime, storage = runtime.storage) {
1182
2103
  return createArtifactAccessRule({
1183
2104
  storage: artifacts,
1184
2105
  projectId: runtime.projectId,
1185
- caller: authority.type === "unrestricted" ? "system" : authority.type === "principal" ? authority.context.principal : null,
2106
+ caller: authority.type === "unrestricted" ? "system" : authority.type === "principal" ? authority.context.principal : authority.type === "delegated" ? "guest" : null,
1186
2107
  sharing: authority.type === "principal" && authority.ref.credential?.type === "session",
1187
2108
  conversation: async (threadId) => {
1188
2109
  if (await threads.read(threadId))
1189
2110
  return "update";
1190
2111
  return isRuntimeAllowed2(runtime, { kind: "agentThreads.observe" }) ? "read" : null;
2112
+ },
2113
+ holders: async (artifact) => {
2114
+ let access = null;
2115
+ const holdings = readableHoldings({
2116
+ runtime,
2117
+ reader,
2118
+ objects: storage.objects,
2119
+ artifactId: artifact.id
2120
+ });
2121
+ for await (const holding of holdings) {
2122
+ if (holding.access === "update")
2123
+ return "update";
2124
+ access = "read";
2125
+ }
2126
+ return access;
1191
2127
  }
1192
2128
  });
1193
2129
  }
1194
- function createArtifactsRuntime(runtime, blobStorage) {
2130
+ async function updatableArtifactIds(runtime, artifactIds) {
2131
+ const ids = [...new Set(artifactIds)];
2132
+ const storage = runtime.storage.artifacts;
2133
+ if (ids.length === 0 || !storage)
2134
+ return new Set;
2135
+ const rule = createRuntimeArtifactAccessRule(runtime);
2136
+ const updatable = await Promise.all(ids.map(async (id) => {
2137
+ const artifact = await storage.get({ projectId: runtime.projectId, id });
2138
+ if (!artifact)
2139
+ return [];
2140
+ const access = await rule.accessTo(artifact);
2141
+ return access === "owner" || access === "update" ? [id] : [];
2142
+ }));
2143
+ return new Set(updatable.flat());
2144
+ }
2145
+ function createArtifactsRuntime(runtime, blobStorage, options = {}) {
1195
2146
  const authority = resolveRuntimeAuthorizationForProject(runtime);
1196
2147
  const caller = authority.type === "principal" ? authority.context.principal : authority.type === "unrestricted" ? SYSTEM_PRINCIPAL2 : null;
1197
2148
  const requireStorage = () => {
@@ -1203,12 +2154,28 @@ function createArtifactsRuntime(runtime, blobStorage) {
1203
2154
  };
1204
2155
  const requireCaller = () => {
1205
2156
  if (!caller) {
1206
- throw new ArtifactRequestError2("not_allowed", "[Sixb] This caller cannot publish artifacts.");
2157
+ throw new ArtifactRequestError2("not_allowed", authority.type === "delegated" ? "[Sixb] A shared link's guest reads its artifacts and comments on them, nothing more." : "[Sixb] This caller cannot publish artifacts.");
1207
2158
  }
1208
2159
  return caller;
1209
2160
  };
1210
- const rule = (storage) => createRuntimeArtifactAccessRule(runtime, storage);
2161
+ const commentAuthor = async () => {
2162
+ if (authority.type !== "delegated" || !authority.delegation)
2163
+ return requireCaller();
2164
+ return sharedLinkGuest(runtime, authority.delegation);
2165
+ };
2166
+ const rule = () => createRuntimeArtifactAccessRule(runtime);
1211
2167
  const checkQuery = createArtifactQueryChecker(runtime);
2168
+ const requestPreviews = async (version, requestOptions) => {
2169
+ const storage = runtime.storage.artifacts;
2170
+ if (!options.rendersBoardPreviews || !storage)
2171
+ return;
2172
+ await requestBoardPreviews({
2173
+ storage,
2174
+ queue: runtime.queues.agents,
2175
+ blobStorage,
2176
+ query: (name) => artifacts.query(version.artifactId, name, { version: version.version })
2177
+ }, version, requestOptions);
2178
+ };
1212
2179
  const reach = async (artifactId) => {
1213
2180
  const artifact = await requireStorage().get({ projectId: runtime.projectId, id: artifactId });
1214
2181
  return artifact ? { artifact, access: await rule().accessTo(artifact) } : null;
@@ -1232,16 +2199,38 @@ function createArtifactsRuntime(runtime, blobStorage) {
1232
2199
  const requireUpdatable = async (artifactId) => {
1233
2200
  const reached = await reach(artifactId);
1234
2201
  if (!reached)
1235
- throw notFound2(artifactId);
2202
+ throw notFound3(artifactId);
1236
2203
  assertUpdatable(artifactId, reached.access);
1237
2204
  return reached.artifact;
1238
2205
  };
1239
- const store = (prepared) => runtime.storage.transaction(async (tx) => {
1240
- const storage = tx.artifacts;
1241
- if (!storage)
1242
- throw new Error("[Sixb] Storage transactions hold no artifacts.");
1243
- return storeArtifactVersion2({ projectId: runtime.projectId, storage, blobStorage }, prepared, (artifact) => rule(tx).publishAccess(artifact));
1244
- });
2206
+ const store = async (prepared) => {
2207
+ const ruleIn = await transactionArtifactAccessRules(runtime);
2208
+ return runtime.storage.transaction(async (tx) => {
2209
+ const storage = tx.artifacts;
2210
+ if (!storage)
2211
+ throw new Error("[Sixb] Storage transactions hold no artifacts.");
2212
+ return storeArtifactVersion2({ projectId: runtime.projectId, storage, blobStorage }, prepared, (artifact) => ruleIn(tx).publishAccess(artifact));
2213
+ });
2214
+ };
2215
+ const change = async (artifactId, write) => {
2216
+ const author = requireCaller();
2217
+ requireStorage();
2218
+ const ruleIn = await transactionArtifactAccessRules(runtime);
2219
+ return runtime.storage.transaction(async (tx) => {
2220
+ const storage = tx.artifacts;
2221
+ if (!storage)
2222
+ throw new Error("[Sixb] Storage transactions hold no artifacts.");
2223
+ const artifact = await storage.get({ projectId: runtime.projectId, id: artifactId });
2224
+ if (!artifact)
2225
+ throw notFound3(artifactId);
2226
+ assertUpdatable(artifactId, await ruleIn(tx).publishAccess(artifact));
2227
+ try {
2228
+ return await write(storage, author);
2229
+ } catch (error) {
2230
+ throw artifactRequestError(error);
2231
+ }
2232
+ });
2233
+ };
1245
2234
  const contentFiles = async (input) => {
1246
2235
  if (!input.queries)
1247
2236
  return input.files;
@@ -1262,34 +2251,121 @@ function createArtifactsRuntime(runtime, blobStorage) {
1262
2251
  }
1263
2252
  return files;
1264
2253
  };
2254
+ const write = async (input) => {
2255
+ const author = requireCaller();
2256
+ const context = { projectId: runtime.projectId, storage: requireStorage(), blobStorage };
2257
+ return withMergedWrite(context, input, async (merged) => {
2258
+ const prepared = await prepareArtifactVersion2(context, {
2259
+ artifactId: input.artifactId,
2260
+ kind: input.kind,
2261
+ title: merged.title ?? input.title,
2262
+ files: merged.files,
2263
+ ...merged.baseRevision === undefined ? {} : { baseRevision: merged.baseRevision },
2264
+ ...merged.document ? { document: merged.document } : {},
2265
+ author,
2266
+ readable: readableBy(rule()),
2267
+ checkQuery
2268
+ });
2269
+ const stored = await store(prepared);
2270
+ await announceArtifactUpdates(runtime.events, [stored.version]);
2271
+ await requestPreviews(stored.version);
2272
+ return {
2273
+ ...stored,
2274
+ warnings: await artifactVersionWarnings2(context, prepared, stored),
2275
+ ...merged.merged ? { merged: true } : {}
2276
+ };
2277
+ });
2278
+ };
2279
+ const writeLive = async (artifactId, input) => {
2280
+ const artifact = await requireUpdatable(artifactId);
2281
+ if (!keepsDocument(artifact.kind)) {
2282
+ throw invalidArtifact(`Artifact '${artifactId}' is a ${artifact.kind}, which is not edited live: publish its files.`);
2283
+ }
2284
+ return write({ artifactId, kind: artifact.kind, ...input });
2285
+ };
1265
2286
  const artifacts = {
2287
+ ...createArtifactCommentsRuntime({
2288
+ projectId: runtime.projectId,
2289
+ storage: requireStorage,
2290
+ events: runtime.events,
2291
+ author: commentAuthor,
2292
+ manager: requireCaller,
2293
+ reach
2294
+ }),
1266
2295
  async create(input) {
1267
2296
  const author = requireCaller();
1268
- return publishArtifact2({ projectId: runtime.projectId, storage: requireStorage(), blobStorage }, {
2297
+ const files = await contentFiles(input);
2298
+ const document = await firstArtifactDocument(blobStorage, input.kind, files);
2299
+ const published = await publishArtifact2({ projectId: runtime.projectId, storage: requireStorage(), blobStorage }, {
1269
2300
  kind: input.kind,
1270
2301
  title: input.title,
1271
- files: await contentFiles(input),
2302
+ files,
2303
+ ...document ? { document } : {},
1272
2304
  author,
1273
2305
  readable: readableBy(rule()),
1274
2306
  checkQuery
1275
2307
  }, (artifact) => rule().publishAccess(artifact));
2308
+ await requestPreviews(published.version);
2309
+ return published;
1276
2310
  },
1277
- async publish(artifactId, input) {
1278
- const author = requireCaller();
2311
+ async update(artifactId, input) {
1279
2312
  await requireUpdatable(artifactId);
1280
- const context = { projectId: runtime.projectId, storage: requireStorage(), blobStorage };
1281
- const prepared = await prepareArtifactVersion2(context, {
2313
+ return write({
1282
2314
  artifactId,
1283
2315
  kind: input.kind,
1284
- title: input.title,
1285
2316
  files: await contentFiles(input),
1286
- ...input.baseVersion === undefined ? {} : { baseVersion: input.baseVersion },
1287
- author,
1288
- readable: readableBy(rule()),
1289
- checkQuery
2317
+ ...input.baseRevision === undefined ? {} : { baseRevision: input.baseRevision },
2318
+ ...input.baseFiles === undefined ? {} : { baseFiles: input.baseFiles },
2319
+ title: input.title,
2320
+ ...input.baseTitle === undefined ? {} : { baseTitle: input.baseTitle }
2321
+ });
2322
+ },
2323
+ async freeze(artifactId, input = {}) {
2324
+ const frozenAt = new Date;
2325
+ const frozen = await change(artifactId, (storage, author) => storage.freeze({
2326
+ projectId: runtime.projectId,
2327
+ artifactId,
2328
+ ...input.baseRevision === undefined ? {} : { baseRevision: input.baseRevision },
2329
+ frozenAt,
2330
+ frozenBy: author
2331
+ }));
2332
+ if (frozen.version.frozenAt?.getTime() === frozenAt.getTime()) {
2333
+ await announceArtifactUpdates(runtime.events, [frozen.version]);
2334
+ }
2335
+ return frozen;
2336
+ },
2337
+ async listRestorePoints(artifactId) {
2338
+ if (!await getReadable(artifactId))
2339
+ return null;
2340
+ return requireStorage().listRestorePoints({ projectId: runtime.projectId, id: artifactId });
2341
+ },
2342
+ async getRestorePoint(artifactId, revision) {
2343
+ if (!await getReadable(artifactId))
2344
+ return null;
2345
+ return requireStorage().getRestorePoint({
2346
+ projectId: runtime.projectId,
2347
+ artifactId,
2348
+ revision
1290
2349
  });
1291
- const stored = await store(prepared);
1292
- return { ...stored, warnings: await artifactVersionWarnings2(context, prepared, stored) };
2350
+ },
2351
+ async restore(artifactId, revision, input = {}) {
2352
+ const context = { projectId: runtime.projectId, storage: requireStorage(), blobStorage };
2353
+ const point = await context.storage.getRestorePoint({
2354
+ projectId: runtime.projectId,
2355
+ artifactId,
2356
+ revision
2357
+ });
2358
+ const restored = await withDocumentHolding(context, artifactId, point?.files ?? null, input.baseRevision, (held) => change(artifactId, (storage, author) => storage.restoreTo({
2359
+ projectId: runtime.projectId,
2360
+ artifactId,
2361
+ revision,
2362
+ ...held,
2363
+ author,
2364
+ restoredAt: new Date
2365
+ })));
2366
+ await announceArtifactUpdates(runtime.events, [restored.version]);
2367
+ await requestPreviews(restored.version, boardsReadLiveData2(restored.version) ? { withoutAnswers: true } : {});
2368
+ return restored;
1293
2369
  },
1294
2370
  async access(artifactId) {
1295
2371
  return (await reach(artifactId))?.access ?? null;
@@ -1309,6 +2385,23 @@ function createArtifactsRuntime(runtime, blobStorage) {
1309
2385
  ...input.offset === undefined ? {} : { offset: input.offset }
1310
2386
  });
1311
2387
  },
2388
+ async holders(artifactId) {
2389
+ if (!await getReadable(artifactId))
2390
+ return null;
2391
+ const holders = [];
2392
+ const holdings = readableHoldings({
2393
+ runtime,
2394
+ reader: runtime.objectReader,
2395
+ objects: runtime.storage.objects,
2396
+ artifactId
2397
+ });
2398
+ for await (const holding of holdings) {
2399
+ if (holders.length === ARTIFACT_HOLDERS_LIMIT2)
2400
+ return { holders, hasMore: true };
2401
+ holders.push(holderObject(runtime, holding));
2402
+ }
2403
+ return { holders, hasMore: false };
2404
+ },
1312
2405
  async getVersion(artifactId, version) {
1313
2406
  return (await readVersion(artifactId, version))?.version ?? null;
1314
2407
  },
@@ -1380,7 +2473,13 @@ function createArtifactsRuntime(runtime, blobStorage) {
1380
2473
  };
1381
2474
  }
1382
2475
  };
1383
- publishers.set(artifacts, { rule, checkQuery });
2476
+ publishers.set(artifacts, {
2477
+ rule,
2478
+ transactionRules: () => transactionArtifactAccessRules(runtime),
2479
+ checkQuery,
2480
+ requestPreviews,
2481
+ writeLive
2482
+ });
1384
2483
  return artifacts;
1385
2484
  }
1386
2485
  function stateKey(key) {
@@ -1409,10 +2508,28 @@ function queryFile(query) {
1409
2508
  facets: query.facets.map((facet) => ({ propertyId: facet.property.id, limit: facet.limit }))
1410
2509
  };
1411
2510
  }
1412
- function notFound2(artifactId) {
2511
+ function holderObject(runtime, holding) {
2512
+ const { objectTypeId, primaryId, propertyId, object } = holding;
2513
+ const titleId = runtime.ontology.getObjectTypeById(objectTypeId)?.search?.title;
2514
+ const value = titleId === undefined ? undefined : object.properties[titleId];
2515
+ const title = typeof value === "string" || typeof value === "number" ? String(value).trim() : "";
2516
+ return { objectTypeId, primaryId, propertyId, ...title ? { title } : {} };
2517
+ }
2518
+ async function sharedLinkGuest(runtime, delegation) {
2519
+ const session = await runtime.storage.shareSessions?.getById({
2520
+ projectId: runtime.projectId,
2521
+ id: delegation.sessionId
2522
+ });
2523
+ const name = session?.grantId === delegation.grantId ? session.guestName : undefined;
2524
+ if (!name) {
2525
+ throw new ArtifactRequestError2("name_required", "[Sixb] A shared link's guest gives their name before they comment.");
2526
+ }
2527
+ return { type: "guest", id: delegation.sessionId, name };
2528
+ }
2529
+ function notFound3(artifactId) {
1413
2530
  return new ArtifactRequestError2("artifact_not_found", `[Sixb] Artifact '${artifactId}' was not found.`);
1414
2531
  }
1415
2532
 
1416
- export { createAgentThreadAccessRule, assertConversationThread2, conversationThreadId2, agentThreadViews, publishArtifact2, prepareArtifactVersion2, storeArtifactVersion2, artifactVersionWarnings2, artifactAccessRule2, artifactQueryChecker2, createRuntimeArtifactAccessRule, createArtifactsRuntime };
2533
+ export { createAgentThreadAccessRule, assertConversationThread2, conversationThreadId2, agentThreadViews, announceArtifactUpdates, readLiveFiles2, storeLiveFiles2, sameArtifactFiles2, loadArtifactDocument2, readDocumentState2, firstArtifactDocument, withMergedWrite, undoneTurnDocuments, answerArtifactQueries2, parseArtifactQueryAnswers2, BOARD_PREVIEW_MEDIA_TYPES2, MAX_BOARD_PREVIEW_BYTES2, boardRenderKey, boardPreviewsOfCopy, boardsReadLiveData2, boardPreviews2, boardPreview2, missingBoardPreviews2, boardPreviewStatuses2, storeBoardPreviews2, publishArtifact2, prepareArtifactVersion2, storeArtifactVersion2, artifactVersionWarnings2, artifactAccessRule2, artifactTransactionRules, artifactQueryChecker2, artifactPreviewRequester, writeLiveArtifact2, createRuntimeArtifactAccessRule, transactionArtifactAccessRules, updatableArtifactIds, createArtifactsRuntime };
1417
2534
 
1418
- //# debugId=A6E54FAFBD1DE5DC64756E2164756E21
2535
+ //# debugId=AA04267CD72FF03864756E2164756E21