@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
@@ -0,0 +1,30 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/agents/thread-access.ts", "../src/artifacts/access.ts", "../src/artifacts/events.ts", "../src/artifacts/comments.ts", "../src/artifacts/holders.ts", "../src/artifacts/live/state.ts", "../src/artifacts/live/files.ts", "../src/artifacts/publish/merge.ts", "../src/artifacts/publish/previews.ts", "../src/artifacts/publish/query-answers.ts", "../src/artifacts/run-query.ts", "../src/artifacts/publish/queries.ts", "../src/artifacts/publish/references.ts", "../src/artifacts/publish/validate/canvas.ts", "../src/artifacts/publish/validate/document.ts", "../src/artifacts/publish/validate/file.ts", "../src/artifacts/publish/validate/page.ts", "../src/artifacts/publish/validate/sheet.ts", "../src/artifacts/publish/validate/slides.ts", "../src/artifacts/publish/publish.ts", "../src/artifacts/execution.ts"],
4
+ "sourcesContent": [
5
+ "import { type Principal, principalsEqual, SYSTEM_PRINCIPAL, type UserPrincipal } from \"../auth\"\nimport { isRuntimeAllowed } from \"../authorization\"\nimport type { resolveRuntimeAuthorizationForProject } from \"../execution/authorization\"\nimport type { SixbRuntimeContext } from \"../runtime/types\"\nimport type { AgentStorage, AgentThreadRecord } from \"../storage/agents\"\nimport { AgentRequestError } from \"./errors\"\n\n/** How the caller takes part in a conversation: its owner, or a user its owner added. */\nexport type AgentThreadAccess = \"owner\" | \"participant\"\n\n/** A user the thread's owner added, who reads the conversation and talks in it. */\nexport interface AgentThreadParticipant {\n readonly principal: UserPrincipal\n readonly addedAt: Date\n readonly addedBy: Principal\n}\n\n/** A thread as the runtime returns it: the stored record with the users taking part in it. */\nexport interface AgentThreadView extends AgentThreadRecord {\n readonly participants: readonly AgentThreadParticipant[]\n}\n\n/** A thread the caller can read, and how it takes part in it. */\nexport interface ReadableAgentThread {\n readonly thread: AgentThreadView\n readonly access: AgentThreadAccess\n}\n\ntype RuntimeAuthority = ReturnType<typeof resolveRuntimeAuthorizationForProject>\n\n/**\n * The one rule for who reads a conversation through `sixb.agent`.\n *\n * The caller needs `can.run(agent)`, then must own the thread or take part in it. Code without a\n * caller (authorization disabled, or system code) reads every thread as its owner. A shared link,\n * a delegated execution or a denied caller reads none. An observer reads every thread through\n * `sixb.agent.observed` instead, without ever being its owner or a participant.\n *\n * A sub-agent's thread is read exactly when its conversation is, with the caller's access there:\n * whoever stops reading the conversation stops reading its children with it.\n */\nexport interface AgentThreadAccessRule {\n /** Who acts: the signed-in principal, or the system principal for code without a caller. */\n readonly caller: Principal\n /** The thread and how the caller takes part in it; `null` when it cannot read it. */\n read(threadId: string): Promise<ReadableAgentThread | null>\n}\n\nexport function createAgentThreadAccessRule(\n runtime: SixbRuntimeContext,\n authority: RuntimeAuthority,\n /** Where threads are read, the project's storage when omitted: a transaction's decides in it. */\n agents?: AgentStorage\n): AgentThreadAccessRule {\n const caller = authority.type === \"principal\" ? authority.context.principal : SYSTEM_PRINCIPAL\n const blocked = authority.type === \"denied\" || authority.type === \"delegated\"\n\n const accessIn = (thread: AgentThreadView): AgentThreadAccess | null => {\n if (blocked || !isRuntimeAllowed(runtime, { kind: \"agent.run\" })) return null\n if (authority.type !== \"principal\") return \"owner\"\n if (principalsEqual(caller, thread.ownerPrincipal)) return \"owner\"\n\n return thread.participants.some((participant) => principalsEqual(participant.principal, caller))\n ? \"participant\"\n : null\n }\n\n const read = async (threadId: string): Promise<ReadableAgentThread | null> => {\n if (blocked) return null\n\n const storage = agents ?? runtime.storage.agents\n const getById = (id: string) => storage?.threads.getById({ projectId: runtime.projectId, id })\n const stored = await getById(threadId)\n if (!stored) return null\n\n // One level only: a child's parent is always a conversation, as storage admits no other.\n const conversation = stored.parent ? await getById(stored.parent.threadId) : stored\n if (conversation?.kind !== \"conversation\") return null\n\n const [thread, readThrough = thread] = await agentThreadViews(\n runtime,\n conversation === stored ? [stored] : [stored, conversation],\n storage\n )\n const access = readThrough ? accessIn(readThrough) : null\n return thread && access ? { thread, access } : null\n }\n\n return { caller, read }\n}\n\n/** Refuse what only a conversation takes: a message, a fork, a participant, a mode, a sandbox. */\nexport function assertConversationThread(thread: Pick<AgentThreadRecord, \"id\" | \"kind\">): void {\n if (thread.kind === \"conversation\") return\n throw new AgentRequestError(\n \"thread_not_conversation\",\n `[Sixb] Agent thread '${thread.id}' is a sub-agent's: it is read through its conversation and takes no change of its own.`\n )\n}\n\n/**\n * The conversation a thread belongs to: the thread itself, or a sub-agent's parent. What a child\n * publishes, and the thread its sandbox names, are its conversation's.\n */\nexport function conversationThreadId(thread: Pick<AgentThreadRecord, \"id\" | \"parent\">): string {\n return thread.parent?.threadId ?? thread.id\n}\n\n/** Stored threads as the runtime returns them, with their participants and no execution tokens. */\nexport async function agentThreadViews(\n runtime: SixbRuntimeContext,\n threads: readonly AgentThreadRecord[],\n agents: AgentStorage | undefined = runtime.storage.agents\n): Promise<readonly AgentThreadView[]> {\n const participants =\n threads.length === 0\n ? []\n : ((await agents?.threads.listParticipants({\n projectId: runtime.projectId,\n threadIds: threads.map((thread) => thread.id),\n })) ?? [])\n\n return threads.map((thread) => ({\n ...publicThread(thread),\n participants: participants\n .filter((participant) => participant.threadId === thread.id)\n .map(({ principal, addedAt, addedBy }) => ({ principal, addedAt, addedBy })),\n }))\n}\n\n/** Execution ownership tokens never leave the storage/worker boundary. */\nfunction publicThread(thread: AgentThreadRecord): AgentThreadRecord {\n if (!thread.sandboxState) return thread\n\n const { name, status, initialized } = thread.sandboxState\n return { ...thread, sandboxState: { name, status, initialized } }\n}\n",
6
+ "import { type Principal, principalsEqual } from \"../auth\"\nimport type { ArtifactRecord, ArtifactStorage } from \"../storage/artifacts/types\"\nimport { ArtifactRequestError } from \"./errors\"\n\n/**\n * What the caller may do with an artifact.\n *\n * - `owner`: everything, deleting it included.\n * - `update`: read every version and publish the next one, as the owner, a participant of a\n * conversation that shares it, or someone who edits an object that holds it.\n * - `read`: read every version, as someone who observes a conversation that shares it, or reads\n * an object that holds it.\n * - `none`: nothing; the artifact exists but is not shared with the caller.\n */\nexport type ArtifactAccess = \"owner\" | \"update\" | \"read\" | \"none\"\n\n/** How the caller reads a conversation: talking in it, only observing it, or not at all. */\nexport type ConversationAccess = \"update\" | \"read\" | null\n\n/**\n * How the caller reaches an artifact through the objects that hold it: editing one, only reading\n * one, or through none.\n */\nexport type HolderAccess = \"update\" | \"read\" | null\n\n/**\n * The one rule for who reaches an artifact.\n *\n * Its owner reaches it, and code without a caller reaches every artifact. Anyone else reaches an\n * artifact through what shares it, and gets the most any of them gives:\n *\n * - a conversation they read, which shares the artifact the Agent published a version in, or a\n * fork of it copied: whoever owns or takes part in it may update the artifact, and an observer\n * only reads it. Only a signed-in session reaches what conversations share.\n * - an object that holds it in a property: whoever reads the object and that property reads the\n * artifact, and may update it when they may also edit the object's type. Every credential\n * reaches what objects hold, an access token included.\n *\n * A shared link's visitor, a guest, reaches only what the objects their link shares hold, and only\n * reads it: their link shows objects, it never lets them change one. The artifact is shared whole,\n * at every version, whatever published each one. A caller that reaches no artifact gets `none`.\n *\n * A rule reads how the caller reaches each conversation and each artifact's holders once, so it\n * lives for one operation.\n */\nexport interface ArtifactAccessRule {\n accessTo(artifact: ArtifactRecord): Promise<ArtifactAccess>\n /**\n * What the caller may do when publishing the artifact's next version from a conversation, or\n * outside any without `threadId`. A version published in a conversation shares the artifact\n * there: that is how sharing starts. Its owner, and whoever may update it through an object,\n * publish from any conversation. Anyone else publishes from a conversation only when it already\n * shares the artifact, with the access they have there, so a version never shares someone else's\n * artifact in another conversation.\n */\n publishAccess(artifact: ArtifactRecord, threadId?: string): Promise<ArtifactAccess>\n /** How the caller reads the artifacts a conversation shares. */\n conversation(threadId: string): Promise<ConversationAccess>\n}\n\nexport function createArtifactAccessRule(input: {\n readonly storage: ArtifactStorage\n readonly projectId: string\n /**\n * `system` for code without a caller, `guest` for a shared link's visitor, `null` for a caller\n * that reaches no artifact.\n */\n readonly caller: Principal | \"system\" | \"guest\" | null\n /** `false` unless the caller signed in with a session: anything else reaches no conversation. */\n readonly sharing: boolean\n /** How the caller reads a conversation, by the thread-access rule. */\n readonly conversation: (threadId: string) => Promise<ConversationAccess>\n /** How the caller reaches the artifact through the objects that hold it. */\n readonly holders: (artifact: ArtifactRecord) => Promise<HolderAccess>\n}): ArtifactAccessRule {\n const { caller } = input\n const conversations = new Map<string, Promise<ConversationAccess>>()\n const holders = new Map<string, Promise<HolderAccess>>()\n\n const conversation = (threadId: string): Promise<ConversationAccess> => {\n if (caller === null || caller === \"guest\" || !input.sharing) return Promise.resolve(null)\n\n let reads = conversations.get(threadId)\n if (!reads) {\n reads = input.conversation(threadId)\n conversations.set(threadId, reads)\n }\n return reads\n }\n\n const throughObjects = (artifact: ArtifactRecord): Promise<HolderAccess> => {\n let reaches = holders.get(artifact.id)\n if (!reaches) {\n // A guest only reads, whatever their objects' type would let a member do.\n reaches = input\n .holders(artifact)\n .then((access) => (caller === \"guest\" && access !== null ? \"read\" : access))\n holders.set(artifact.id, reaches)\n }\n return reaches\n }\n\n /** `owner` or `none` when the answer needs no other source; `undefined` when it does. */\n const ownAccess = (artifact: ArtifactRecord): ArtifactAccess | undefined => {\n if (caller === null) return \"none\"\n if (caller === \"guest\") return undefined\n if (caller === \"system\" || principalsEqual(caller, artifact.owner)) return \"owner\"\n return undefined\n }\n\n const threadIdsOf = async (artifact: ArtifactRecord): Promise<readonly string[]> =>\n input.sharing\n ? input.storage.listThreadIds({ projectId: input.projectId, id: artifact.id })\n : []\n\n const accessTo = async (artifact: ArtifactRecord): Promise<ArtifactAccess> => {\n const own = ownAccess(artifact)\n if (own) return own\n\n let access: ArtifactAccess = \"none\"\n for (const threadId of await threadIdsOf(artifact)) {\n const reads = await conversation(threadId)\n if (reads === \"update\") return \"update\"\n if (reads === \"read\") access = \"read\"\n }\n\n // Objects come last: each holder is an object read again as the caller, which costs more\n // than a conversation's participants.\n return (await throughObjects(artifact)) ?? access\n }\n\n const publishAccess = async (\n artifact: ArtifactRecord,\n threadId?: string\n ): Promise<ArtifactAccess> => {\n if (threadId === undefined) return accessTo(artifact)\n\n const own = ownAccess(artifact)\n if (own) return own\n\n const shared = (await threadIdsOf(artifact)).includes(threadId)\n const here = shared ? await conversation(threadId) : null\n if (here === \"update\") return \"update\"\n\n // Whoever may update it through an object writes it from any conversation, as its owner does.\n if ((await throughObjects(artifact)) === \"update\") return \"update\"\n return here ?? \"none\"\n }\n\n return { accessTo, publishAccess, conversation }\n}\n\n/** Refuses an artifact the caller may not update: `not_shared`, or `read_only` for a reader. */\nexport function assertUpdatable(artifactId: string, access: ArtifactAccess): void {\n if (access === \"none\") {\n throw new ArtifactRequestError(\n \"not_shared\",\n `[Sixb] Artifact '${artifactId}' is not shared with you.`\n )\n }\n\n if (access === \"read\") {\n throw new ArtifactRequestError(\n \"read_only\",\n `[Sixb] You only read artifact '${artifactId}': you cannot change it or keep page data in it.`\n )\n }\n}\n",
7
+ "import type { DomainEventLog } from \"../events/service\"\nimport type { ArtifactCommentRecord, ArtifactVersionRecord } from \"../storage/artifacts/types\"\n\n/**\n * Tells whoever reads each artifact that its latest version changed, as `artifact.updated`. The\n * writes are stored by now, so `emit` never fails them: an event lost on the way only leaves a\n * viewer showing what it read until it reads again.\n */\nexport async function announceArtifactUpdates(\n events: Pick<DomainEventLog, \"emit\">,\n latest: readonly ArtifactVersionRecord[]\n): Promise<void> {\n if (latest.length === 0) return\n\n await events.emit(\n {\n events: latest.map((version) => ({\n type: \"artifact.updated\" as const,\n payload: {\n artifactId: version.artifactId,\n version: version.version,\n revision: version.revision,\n frozen: version.frozenAt !== undefined,\n },\n // A revision changes once: announcing it again is the same event.\n idempotencyKey: `artifact.updated:${version.artifactId}:${version.revision}`,\n })),\n },\n { source: \"Sixb\" }\n )\n}\n\n/**\n * Tells whoever reads the artifact that one of its comments changed, as `artifact.commented`.\n * The change is stored by now, so `emit` never fails it.\n */\nexport async function announceArtifactComment(\n events: Pick<DomainEventLog, \"emit\">,\n comment: Pick<ArtifactCommentRecord, \"artifactId\" | \"id\" | \"parentId\">,\n action: \"created\" | \"resolved\" | \"reopened\" | \"deleted\"\n): Promise<void> {\n await events.emit(\n {\n events: [\n {\n type: \"artifact.commented\" as const,\n payload: {\n artifactId: comment.artifactId,\n commentId: comment.id,\n ...(comment.parentId === undefined ? {} : { parentId: comment.parentId }),\n action,\n },\n },\n ],\n },\n { source: \"Sixb\" }\n )\n}\n",
8
+ "import type { Principal } from \"../auth\"\nimport { principalsEqual } from \"../auth\"\nimport type { DomainEventLog } from \"../events/service\"\nimport { ArtifactStorageError } from \"../storage/artifacts/errors\"\nimport type {\n ArtifactCommentAnchor,\n ArtifactCommentAuthor,\n ArtifactCommentRecord,\n ArtifactOrigin,\n ArtifactRecord,\n ArtifactStorage,\n} from \"../storage/artifacts/types\"\nimport type { ArtifactAccess } from \"./access\"\nimport { ArtifactRequestError } from \"./errors\"\nimport { announceArtifactComment } from \"./events\"\nimport { createArtifactCommentId } from \"./ids\"\nimport { ARTIFACT_COMMENT_LIMITS } from \"./limits\"\n\n// Comments on an artifact: whoever reads it reads and adds them, a shared link's guest included;\n// their author, or whoever may change the artifact, resolves or deletes them, and only the latter a\n// guest's. Each change is announced to its readers.\n\n/** A comment to add, or a reply. */\nexport interface ArtifactCommentInput {\n /** Plain text. */\n readonly body: string\n /**\n * What it is about: a canvas's board by its item id, an element of the board by the address\n * `boardElements` gives it, with its first words as `label`, or, without, the artifact. At the\n * revision its author saw, the artifact's by default. A reply is about what it replies to.\n */\n readonly anchor?: Partial<ArtifactCommentAnchor>\n /** The comment this one replies to. */\n readonly parentId?: string\n /** The Agent's run that writes it for the caller, and that run's conversation. */\n readonly origin?: ArtifactOrigin\n}\n\n/** The comment methods of the artifacts runtime. */\nexport interface ArtifactCommentsRuntime {\n /** Every comment and reply, oldest first; `null` when the caller cannot read the artifact. */\n listComments(artifactId: string): Promise<ArtifactCommentRecord[] | null>\n /**\n * Adds a comment, or a reply, authored by the caller, who must read the artifact. A shared link's\n * guest writes it under the name they gave, and is refused with `name_required` until they give\n * one. Throws `invalid_comment` for words or an anchor that will not do, `comment_not_found` for\n * a reply to no comment, and `comments_full`.\n */\n addComment(artifactId: string, input: ArtifactCommentInput): Promise<ArtifactCommentRecord>\n /**\n * Marks a comment resolved, or opens it again. Its author or whoever may change the artifact\n * may: anyone else, and every guest, is refused with `not_allowed`.\n */\n resolveComment(\n artifactId: string,\n commentId: string,\n resolved?: boolean\n ): Promise<ArtifactCommentRecord>\n /** Deletes a comment and its replies, as `resolveComment` allows. */\n deleteComment(artifactId: string, commentId: string): Promise<void>\n}\n\n/** An element's address, as `boardElements` writes it, and the longest one a comment keeps. */\nconst ELEMENT_ADDRESS = /^body(>[a-z][a-z0-9-]*:\\d+)*$/\nconst MAX_ELEMENT_ADDRESS_LENGTH = 1024\n\nexport function createArtifactCommentsRuntime(input: {\n readonly projectId: string\n readonly storage: () => ArtifactStorage\n readonly events: Pick<DomainEventLog, \"emit\">\n /** Who writes a comment the caller adds. */\n readonly author: () => Promise<ArtifactCommentAuthor>\n /** Who resolves or deletes one; throws `not_allowed` for a caller who never may. */\n readonly manager: () => Principal\n readonly reach: (\n artifactId: string\n ) => Promise<{ readonly artifact: ArtifactRecord; readonly access: ArtifactAccess } | null>\n}): ArtifactCommentsRuntime {\n const { projectId, events } = input\n\n /** The artifact the caller reads; refused with why otherwise. */\n const readable = async (artifactId: string) => {\n const reached = await input.reach(artifactId)\n if (!reached) throw notFound(artifactId)\n if (reached.access === \"none\") {\n throw new ArtifactRequestError(\n \"not_shared\",\n `[Sixb] Artifact '${artifactId}' is not shared with you.`\n )\n }\n return reached\n }\n\n /** A comment the caller may resolve or delete: theirs, or one on an artifact they may change. */\n const managed = async (artifactId: string, commentId: string) => {\n const { access } = await readable(artifactId)\n const manager = input.manager()\n const comment = await input.storage().getComment({ projectId, artifactId, id: commentId })\n if (!comment) throw commentNotFound(artifactId, commentId)\n\n // A guest's comment is managed by those who may change the artifact, never by a guest.\n const changes = access === \"owner\" || access === \"update\"\n const authored = comment.author.type !== \"guest\" && principalsEqual(comment.author, manager)\n if (!changes && !authored) {\n throw new ArtifactRequestError(\n \"not_allowed\",\n \"[Sixb] Only a comment's author, or whoever may change the artifact, resolves or deletes it.\"\n )\n }\n return comment\n }\n\n return {\n async listComments(artifactId) {\n const reached = await input.reach(artifactId)\n if (!reached || reached.access === \"none\") return null\n return input.storage().listComments({ projectId, id: artifactId })\n },\n\n async addComment(artifactId, comment) {\n const { artifact } = await readable(artifactId)\n const author = await input.author()\n const storage = input.storage()\n\n const body = comment.body.trim()\n if (body.length === 0 || body.length > ARTIFACT_COMMENT_LIMITS.maxBodyLength) {\n throw invalid(\n `A comment holds 1 to ${ARTIFACT_COMMENT_LIMITS.maxBodyLength} characters of text.`\n )\n }\n\n // A reply is about what it replies to.\n let anchor: ArtifactCommentAnchor\n if (comment.parentId !== undefined) {\n const parent = await storage.getComment({ projectId, artifactId, id: comment.parentId })\n if (!parent) throw commentNotFound(artifactId, comment.parentId)\n anchor = parent.anchor\n } else {\n anchor = await checkAnchor(storage, artifact, comment.anchor ?? {})\n }\n\n try {\n const created = await storage.createComment({\n projectId,\n artifactId,\n id: createArtifactCommentId(),\n ...(comment.parentId === undefined ? {} : { parentId: comment.parentId }),\n anchor,\n body,\n author,\n ...(comment.origin ? { origin: comment.origin } : {}),\n createdAt: new Date(),\n })\n await announceArtifactComment(events, created, \"created\")\n return created\n } catch (error) {\n throw commentRequestError(error)\n }\n },\n\n async resolveComment(artifactId, commentId, resolved = true) {\n await managed(artifactId, commentId)\n const changed = await input.storage().resolveComment({\n projectId,\n artifactId,\n id: commentId,\n resolved: resolved ? { at: new Date(), by: input.manager() } : null,\n })\n if (!changed) throw commentNotFound(artifactId, commentId)\n\n await announceArtifactComment(events, changed, resolved ? \"resolved\" : \"reopened\")\n return changed\n },\n\n async deleteComment(artifactId, commentId) {\n const comment = await managed(artifactId, commentId)\n const deleted = await input.storage().deleteComment({ projectId, artifactId, id: commentId })\n if (!deleted) throw commentNotFound(artifactId, commentId)\n\n await announceArtifactComment(events, comment, \"deleted\")\n },\n }\n}\n\n/**\n * The anchor as it is kept: a board the canvas's latest version shows, an element's address\n * under it, its label cut to length, and a revision the artifact has had.\n */\nasync function checkAnchor(\n storage: ArtifactStorage,\n artifact: ArtifactRecord,\n anchor: Partial<ArtifactCommentAnchor>\n): Promise<ArtifactCommentAnchor> {\n const revision = anchor.revision ?? artifact.revision\n if (!Number.isSafeInteger(revision) || revision < 1 || revision > artifact.revision) {\n throw invalid(`A comment is about a revision of the artifact, 1 to ${artifact.revision}.`)\n }\n\n if (anchor.element !== undefined && anchor.board === undefined) {\n throw invalid(\"A comment on an element names the board it is on.\")\n }\n if (\n anchor.element !== undefined &&\n (anchor.element.length > MAX_ELEMENT_ADDRESS_LENGTH || !ELEMENT_ADDRESS.test(anchor.element))\n ) {\n throw invalid(`'${anchor.element}' is no element's address, as a board's elements have.`)\n }\n if (anchor.board !== undefined) {\n const latest = await storage.getVersion({\n projectId: artifact.projectId,\n artifactId: artifact.id,\n version: artifact.latestVersion,\n })\n const outline = latest?.outline\n const shows =\n outline?.kind === \"canvas\" &&\n outline.items.some((item) => item.type === \"board\" && item.id === anchor.board)\n if (!shows) throw invalid(`The artifact shows no board '${anchor.board}'.`)\n }\n\n const { point } = anchor\n if (point !== undefined && anchor.board === undefined) {\n throw invalid(\"A comment's point is on the board it names.\")\n }\n if (\n point !== undefined &&\n ![point.x, point.y].every((value) => Number.isFinite(value) && value >= 0 && value <= 1)\n ) {\n throw invalid(\"A comment's point is on its board: x and y from 0 to 1.\")\n }\n\n const label = anchor.label\n ?.replace(/\\s+/g, \" \")\n .trim()\n .slice(0, ARTIFACT_COMMENT_LIMITS.maxLabelLength)\n return {\n ...(anchor.board === undefined ? {} : { board: anchor.board }),\n ...(anchor.element === undefined ? {} : { element: anchor.element }),\n ...(label ? { label } : {}),\n ...(point === undefined ? {} : { point: { x: point.x, y: point.y } }),\n revision,\n }\n}\n\nfunction commentRequestError(error: unknown): unknown {\n if (!(error instanceof ArtifactStorageError)) return error\n switch (error.code) {\n case \"artifact_not_found\":\n return new ArtifactRequestError(\"artifact_not_found\", error.message)\n case \"comment_not_found\":\n return new ArtifactRequestError(\"comment_not_found\", error.message)\n case \"artifact_comments_full\":\n return new ArtifactRequestError(\"comments_full\", error.message)\n default:\n return error\n }\n}\n\nfunction invalid(message: string): ArtifactRequestError {\n return new ArtifactRequestError(\"invalid_comment\", `[Sixb] ${message}`)\n}\n\nfunction notFound(artifactId: string): ArtifactRequestError {\n return new ArtifactRequestError(\n \"artifact_not_found\",\n `[Sixb] Artifact '${artifactId}' was not found.`\n )\n}\n\nfunction commentNotFound(artifactId: string, commentId: string): ArtifactRequestError {\n return new ArtifactRequestError(\n \"comment_not_found\",\n `[Sixb] Artifact '${artifactId}' has no comment '${commentId}'.`\n )\n}\n",
9
+ "/**\n * The objects that hold an artifact, as one caller reads them.\n *\n * The holder index (`ObjectStorage.listArtifactHolders`) is unscoped, and nothing rewrites it when\n * the ontology changes, so a row is never trusted as it is: each holder is read again through the\n * caller's object reader, as a file an object holds is opened. The object must be one they read,\n * the property one they are cleared for, and its value must still hold the artifact. Whoever may\n * also edit the object's type may update the artifact.\n */\nimport { isRuntimeAllowed } from \"../authorization\"\nimport { AuthorizationError } from \"../authorization/errors\"\nimport type { AuthorizedObjectReader } from \"../execution/authorized-object-reader\"\nimport { collectArtifactRefIds } from \"../ontology/artifact-ref\"\nimport type { SixbRuntimeContext } from \"../runtime/types\"\nimport type { ObjectRow, ObjectStorage } from \"../storage\"\nimport { objectBatchKey } from \"../storage/objects/keys\"\nimport type { ArtifactHolder } from \"../storage/ontology\"\n\n/** One object property that holds the artifact, as the caller reads it. */\nexport interface ArtifactHolding extends ArtifactHolder {\n /** `update` when the caller may edit the object's type, `read` otherwise. */\n readonly access: \"update\" | \"read\"\n /** The object, as the caller reads it. */\n readonly object: ObjectRow\n}\n\n/** How many index rows each read takes: an artifact is rarely held by more objects than this. */\nconst HOLDER_PAGE = 100\n\n/**\n * The holdings of the artifact that the caller reads, in the index's order. Each page of holders\n * is read with one object read per type; stop iterating to stop reading.\n */\nexport async function* readableHoldings(input: {\n readonly runtime: SixbRuntimeContext\n /** The caller's reader, reading from the same storage as `objects`. */\n readonly reader: AuthorizedObjectReader\n readonly objects: Pick<ObjectStorage, \"listArtifactHolders\">\n readonly artifactId: string\n}): AsyncGenerator<ArtifactHolding> {\n const { runtime, reader, artifactId } = input\n let after: ArtifactHolder | undefined\n\n do {\n const page = await input.objects.listArtifactHolders({\n projectId: runtime.projectId,\n artifactId,\n ...(after ? { after } : {}),\n limit: HOLDER_PAGE,\n })\n\n const objects = await readHolders(reader, page.holders)\n for (const holder of page.holders) {\n const object = objects.get(objectBatchKey(holder.objectTypeId, holder.primaryId))\n if (!object || !holdsArtifact(runtime, object, holder.propertyId, artifactId)) continue\n\n const edits = isRuntimeAllowed(runtime, {\n kind: \"object.edit\",\n objectTypeId: holder.objectTypeId,\n })\n yield { ...holder, access: edits ? \"update\" : \"read\", object }\n }\n\n after = page.next\n } while (after)\n}\n\n/**\n * The holders' objects the caller reads, keyed by `objectBatchKey`. A type they cannot view reads\n * nothing, and an object their view condition hides is absent.\n */\nasync function readHolders(\n reader: AuthorizedObjectReader,\n holders: readonly ArtifactHolder[]\n): Promise<ReadonlyMap<string, ObjectRow>> {\n // An object that holds the artifact under several properties is read once.\n const byType = new Map<string, Set<string>>()\n for (const { objectTypeId, primaryId } of holders) {\n const primaryIds = byType.get(objectTypeId) ?? new Set()\n byType.set(objectTypeId, primaryIds.add(primaryId))\n }\n\n const read = new Map<string, ObjectRow>()\n for (const [objectTypeId, primaryIds] of byType) {\n try {\n const rows = await reader.getByPrimaryIdBatch({\n items: [...primaryIds].map((primaryId) => ({ objectTypeId, primaryId })),\n })\n for (const [key, row] of rows) read.set(key, row)\n } catch (error) {\n if (!(error instanceof AuthorizationError)) throw error\n }\n }\n\n return read\n}\n\n/**\n * Whether the property, as the caller reads it, still holds the artifact. One the caller is not\n * cleared for comes back without its value, and one the type no longer declares holds nothing.\n */\nfunction holdsArtifact(\n runtime: SixbRuntimeContext,\n object: ObjectRow,\n propertyId: string,\n artifactId: string\n): boolean {\n const property = runtime.ontology\n .getObjectTypeById(object.objectTypeId)\n ?.properties.find((candidate) => candidate.id === propertyId)\n if (!property) return false\n\n const held = collectArtifactRefIds(\n property.schema,\n object.properties[propertyId],\n runtime.ontology.getValueTypesById(),\n new Set()\n )\n return held.has(artifactId)\n}\n",
10
+ "import * as Y from \"yjs\"\nimport type { BlobStorage, FileRef } from \"../../blob-storage/types\"\nimport type { ArtifactDocument, ArtifactFile, ArtifactRecord } from \"../../storage/artifacts/types\"\nimport type { ArtifactKind } from \"../kinds\"\nimport { createArtifactDocument, documentFiles, mergeIntoDocument } from \"./document\"\nimport { readLiveFiles } from \"./files\"\n\n// An artifact's document as storage keeps it: its whole Yjs state in one blob, replaced by every\n// write. Everyone who loads it, a server holding it live or a write merging into it, continues\n// the same history, so their changes merge as Yjs merges concurrent edits.\n\n/** Whether a kind is edited live, and so keeps its content as a document. */\nexport function keepsDocument(kind: ArtifactKind): boolean {\n return kind === \"canvas\"\n}\n\n/**\n * The artifact's document, holding `files`, its latest version's.\n *\n * - The one storage keeps, when it holds the artifact's revision.\n * - One storage left behind, written without a document since: that one, then the change from what\n * it holds to `files`.\n * - None yet: one built from `files`.\n *\n * The last two are made under a client id named by what they start from and the files, so that\n * whoever makes one, wherever, makes the same history; the next write stores it. The document's\n * own changes are made under a fresh id.\n */\nexport async function loadArtifactDocument(\n blobStorage: Pick<BlobStorage, \"open\">,\n artifact: Pick<ArtifactRecord, \"id\" | \"kind\" | \"revision\" | \"document\">,\n files: readonly ArtifactFile[]\n): Promise<Y.Doc> {\n const doc = new Y.Doc()\n const stored = artifact.document\n if (stored?.revision === artifact.revision) {\n Y.applyUpdate(doc, await readDocumentState(blobStorage, stored.file))\n return doc\n }\n\n const clientID = madeClientId(artifact.id, stored, files)\n const live = await readLiveFiles(blobStorage, files)\n let made: Y.Doc\n if (stored) {\n made = new Y.Doc()\n made.clientID = clientID\n Y.applyUpdate(made, await readDocumentState(blobStorage, stored.file))\n mergeIntoDocument(made, documentFiles(made), live)\n } else {\n made = createArtifactDocument(artifact.kind, live, { clientID })\n }\n\n Y.applyUpdate(doc, Y.encodeStateAsUpdate(made))\n made.destroy()\n return doc\n}\n\n/** The encoded state storage keeps of an artifact's document. */\nexport async function readDocumentState(\n blobStorage: Pick<BlobStorage, \"open\">,\n document: FileRef\n): Promise<Uint8Array> {\n return new Uint8Array(await new Response(await blobStorage.open(document.blobId)).arrayBuffer())\n}\n\n/** Stores a document's whole state, for the write that holds its content. */\nexport async function storeArtifactDocument(\n blobStorage: Pick<BlobStorage, \"put\">,\n doc: Y.Doc\n): Promise<FileRef> {\n const body = Y.encodeStateAsUpdate(doc)\n return blobStorage.put({\n body,\n expectedSizeBytes: body.byteLength,\n fileName: \"document.yjs\",\n mediaType: \"application/octet-stream\",\n })\n}\n\n/** The document of a new artifact's first version, for a kind that keeps one. */\nexport async function firstArtifactDocument(\n blobStorage: Pick<BlobStorage, \"open\" | \"put\">,\n kind: ArtifactKind,\n files: readonly ArtifactFile[]\n): Promise<FileRef | undefined> {\n if (!keepsDocument(kind)) return undefined\n const doc = createArtifactDocument(kind, await readLiveFiles(blobStorage, files))\n try {\n return await storeArtifactDocument(blobStorage, doc)\n } finally {\n doc.destroy()\n }\n}\n\n/**\n * A Yjs client id named by what a document is made from: FNV-1a over the artifact, the document\n * left behind, if any, and each file's path and digest.\n */\nfunction madeClientId(\n artifactId: string,\n stored: ArtifactDocument | undefined,\n files: readonly ArtifactFile[]\n): number {\n const named = [...files]\n .map(({ path, file }) => `${path}\\u0000${file.digest}`)\n .sort()\n .join(\"\\u0001\")\n const from = stored ? `${stored.file.digest}@${stored.revision}` : \"\"\n let hash = 0x811c9dc5\n for (const char of `${artifactId}\\u0002${from}\\u0002${named}`) {\n hash ^= char.codePointAt(0) ?? 0\n hash = Math.imul(hash, 0x01000193) >>> 0\n }\n return hash\n}\n",
11
+ "import { createHash } from \"node:crypto\"\nimport { posix } from \"node:path\"\nimport { inferFileMediaType } from \"../../blob-storage/media-type\"\nimport type { BlobStorage } from \"../../blob-storage/types\"\nimport type { ArtifactFile } from \"../../storage/artifacts/types\"\nimport { ARTIFACT_LIMITS } from \"../limits\"\nimport { isLiveTextPath, type LiveFile, type LiveFiles } from \"./document\"\n\n// A version's files as the live layer reads them, and back. Reading takes each text file's words\n// from blob storage; storing puts back only the texts that changed, so a write keeps the\n// references of every file it did not touch.\n\nconst strictUtf8 = new TextDecoder(\"utf-8\", { fatal: true })\n\n/**\n * A version's files as text where their path says they are and their bytes are UTF-8 text no\n * larger than a file may be; any other is held as its reference.\n */\nexport async function readLiveFiles(\n blobStorage: Pick<BlobStorage, \"open\">,\n files: readonly ArtifactFile[]\n): Promise<Map<string, LiveFile>> {\n const read = await Promise.all(\n files.map(async ({ path, file }): Promise<[string, LiveFile]> => {\n if (!isLiveTextPath(path) || file.sizeBytes > ARTIFACT_LIMITS.maxFileBytes) {\n return [path, { file }]\n }\n\n const bytes = new Uint8Array(\n await new Response(await blobStorage.open(file.blobId)).arrayBuffer()\n )\n try {\n return [path, { text: strictUtf8.decode(bytes) }]\n } catch {\n return [path, { file }]\n }\n })\n )\n return new Map(read.sort(([left], [right]) => (left < right ? -1 : 1)))\n}\n\n/**\n * Files to publish from what the live layer holds: a text that `known` already holds at its path\n * keeps its reference, and any other is stored, with the media type its path had.\n */\nexport async function storeLiveFiles(\n blobStorage: Pick<BlobStorage, \"put\">,\n files: LiveFiles,\n known: readonly ArtifactFile[]\n): Promise<ArtifactFile[]> {\n const byPath = new Map(known.map((entry) => [entry.path, entry.file]))\n\n return Promise.all(\n [...files].map(async ([path, file]): Promise<ArtifactFile> => {\n if (\"file\" in file) return { path, file: { ...file.file } }\n\n const body = new TextEncoder().encode(file.text)\n const digest = `sha256:${createHash(\"sha256\").update(body).digest(\"hex\")}`\n const before = byPath.get(path)\n if (before?.digest === digest) return { path, file: { ...before } }\n\n const fileName = posix.basename(path)\n const stored = await blobStorage.put({\n body,\n expectedSizeBytes: body.byteLength,\n fileName,\n mediaType: before?.mediaType ?? inferFileMediaType(fileName, body),\n })\n return { path, file: stored }\n })\n )\n}\n\n/** Whether two sets of files are the same files, path by path and byte for byte. */\nexport function sameArtifactFiles(\n left: readonly ArtifactFile[],\n right: readonly ArtifactFile[]\n): boolean {\n if (left.length !== right.length) return false\n const digests = new Map(left.map((entry) => [entry.path, entry.file.digest]))\n return right.every((entry) => digests.get(entry.path) === entry.file.digest)\n}\n",
12
+ "import * as Y from \"yjs\"\nimport type { BlobStorage, FileRef } from \"../../blob-storage/types\"\nimport { ArtifactStorageError } from \"../../storage/artifacts/errors\"\nimport { turnUndoable } from \"../../storage/artifacts/record\"\nimport type { ArtifactFile, ArtifactStorage } from \"../../storage/artifacts/types\"\nimport { ArtifactRequestError } from \"../errors\"\nimport type { ArtifactKind } from \"../kinds\"\nimport { documentFiles, type LiveFiles, mergeIntoDocument } from \"../live/document\"\nimport { readLiveFiles, sameArtifactFiles, storeLiveFiles } from \"../live/files\"\nimport { keepsDocument, loadArtifactDocument, storeArtifactDocument } from \"../live/state\"\n\n// A canvas is edited by many at once, and keeps its content as a Yjs document (see\n// ../live/state.ts). Every write to one is made into that document: a live editor's as the Yjs\n// update it holds, any other as the changes from the files it was made from to its own. A write\n// made from an earlier revision is so merged, not refused, and whatever was written meanwhile\n// stays. Any other kind keeps the conflict check.\n\n/** How many times a merged write starts over when another lands between its merge and its store. */\nconst MERGE_ATTEMPTS = 3\n\n/** A write to an artifact, made from the files of `baseRevision`. */\nexport interface ArtifactWrite {\n readonly artifactId: string\n readonly kind: ArtifactKind\n readonly files: readonly ArtifactFile[]\n readonly baseRevision?: number\n /** The files of `baseRevision`, when the writer holds them; otherwise looked up. */\n readonly baseFiles?: readonly ArtifactFile[]\n /** The title it writes, and the one of `baseRevision`: a title given since stays unless it changes it. */\n readonly title?: string\n readonly baseTitle?: string\n /**\n * The artifact's document as a live editor holds it, encoded as a Yjs update: merged into the\n * stored one, whose files the write then holds.\n */\n readonly update?: Uint8Array\n}\n\n/** A write as it is stored: merged when the artifact moved past its base. */\nexport interface MergedArtifactWrite {\n readonly files: readonly ArtifactFile[]\n readonly baseRevision?: number\n /** It was merged with what others wrote since its base. */\n readonly merged: boolean\n /** The document that holds the write's content, for a kind that keeps one. */\n readonly document?: FileRef\n /** The title to keep instead of the write's: one given since its base, which it did not change. */\n readonly title?: string\n}\n\n/**\n * The write to store. One to a canvas is made into the artifact's document, which is stored with\n * it, and is based on the latest revision; one that moved past its base is merged into what the\n * latest version holds now. A write whose base files are not known is left as it is, for the\n * conflict check to refuse.\n */\nexport async function mergeArtifactWrite(\n context: {\n readonly projectId: string\n readonly storage: ArtifactStorage\n readonly blobStorage: Pick<BlobStorage, \"open\" | \"put\">\n },\n write: ArtifactWrite\n): Promise<MergedArtifactWrite> {\n const unmerged = {\n files: write.files,\n ...(write.baseRevision === undefined ? {} : { baseRevision: write.baseRevision }),\n merged: false,\n }\n if (!keepsDocument(write.kind)) return unmerged\n\n const { projectId, storage, blobStorage } = context\n const artifact = await storage.get({ projectId, id: write.artifactId })\n const latest =\n artifact &&\n (await storage.getVersion({\n projectId,\n artifactId: artifact.id,\n version: artifact.latestVersion,\n }))\n if (!artifact || !latest || artifact.kind !== write.kind) return unmerged\n\n const moved = write.baseRevision !== undefined && write.baseRevision !== artifact.revision\n const doc = await loadArtifactDocument(blobStorage, artifact, latest.files)\n try {\n let merged = moved\n if (write.update) {\n Y.applyUpdate(doc, write.update)\n } else {\n // The changes from the files it was made from. Those the writer names are its base, even\n // at the latest revision: an Agent's copy may hold less than the version it was installed\n // at, which merged others' words in, and a diff from the version would take them out.\n const files = moved\n ? (write.baseFiles ??\n (await filesAtRevision(storage, projectId, artifact.id, write.baseRevision ?? 0)))\n : write.baseFiles\n if (moved && !files) return unmerged\n\n // Made from what the latest version holds, as after a freeze: nothing to merge with.\n let base: LiveFiles = documentFiles(doc)\n merged = files !== undefined && files !== null && !sameArtifactFiles(files, latest.files)\n if (merged && files) base = await readLiveFiles(blobStorage, files)\n mergeIntoDocument(doc, base, await readLiveFiles(blobStorage, write.files))\n }\n\n // Merged, the write holds what the document holds; otherwise it is stored as it was made.\n // What the write and the latest version both hold keeps its reference, the write's first.\n const files =\n merged || write.update\n ? await storeLiveFiles(blobStorage, documentFiles(doc), [...latest.files, ...write.files])\n : write.files\n const renamed =\n moved &&\n write.baseTitle !== undefined &&\n write.title === write.baseTitle &&\n artifact.title !== write.title\n return {\n files,\n baseRevision: artifact.revision,\n merged,\n document: await storeArtifactDocument(blobStorage, doc),\n ...(renamed ? { title: artifact.title } : {}),\n }\n } finally {\n doc.destroy()\n }\n}\n\n/**\n * Runs a write, merged as {@link mergeArtifactWrite} merges it, and starts over when another write\n * lands between the merge and the store: `store` then fails with `artifact_moved`, which a merged\n * kind never shows its writer.\n */\nexport async function withMergedWrite<T>(\n context: MergeContext,\n write: ArtifactWrite,\n store: (merged: MergedArtifactWrite) => Promise<T>\n): Promise<T> {\n for (let attempt = 1; ; attempt += 1) {\n const merged = await mergeArtifactWrite(context, write)\n try {\n return await store(merged)\n } catch (error) {\n if (!isMoved(error) || !keepsDocument(write.kind) || attempt === MERGE_ATTEMPTS) throw error\n }\n }\n}\n\ntype MergeContext = Parameters<typeof mergeArtifactWrite>[0]\n\n/**\n * The artifact's document once it holds `files` again, as a restore or an undo puts them back:\n * the change to them, made into its stored document, and the revision that is based on. Null for\n * a kind that keeps no document, or without the artifact.\n */\nexport async function documentHolding(\n context: MergeContext,\n artifactId: string,\n files: readonly ArtifactFile[]\n): Promise<{ readonly document: FileRef; readonly baseRevision: number } | null> {\n const { projectId, storage, blobStorage } = context\n const artifact = await storage.get({ projectId, id: artifactId })\n if (!artifact || !keepsDocument(artifact.kind)) return null\n const latest = await storage.getVersion({\n projectId,\n artifactId,\n version: artifact.latestVersion,\n })\n if (!latest) return null\n\n const doc = await loadArtifactDocument(blobStorage, artifact, latest.files)\n try {\n mergeIntoDocument(doc, documentFiles(doc), await readLiveFiles(blobStorage, files))\n return {\n document: await storeArtifactDocument(blobStorage, doc),\n baseRevision: artifact.revision,\n }\n } finally {\n doc.destroy()\n }\n}\n\n/**\n * Runs a write that puts `files` back, with the document that holds them, based on the revision\n * it was made at; it starts over when another write lands first. A caller's own `baseRevision`\n * is kept, and the write then refused past it, as it would be without a document.\n */\nexport async function withDocumentHolding<T>(\n context: MergeContext,\n artifactId: string,\n files: readonly ArtifactFile[] | null,\n baseRevision: number | undefined,\n store: (held: { readonly document?: FileRef; readonly baseRevision?: number }) => Promise<T>\n): Promise<T> {\n for (let attempt = 1; ; attempt += 1) {\n const held = files ? await documentHolding(context, artifactId, files) : null\n const base = baseRevision ?? held?.baseRevision\n const fits = held && (baseRevision === undefined || baseRevision === held.baseRevision)\n try {\n return await store({\n ...(fits ? { document: held.document } : {}),\n ...(base === undefined ? {} : { baseRevision: base }),\n })\n } catch (error) {\n if (!isMoved(error) || baseRevision !== undefined || !held || attempt === MERGE_ATTEMPTS) {\n throw error\n }\n }\n }\n}\n\n/**\n * The documents of the canvases a retry of a turn puts back, by id: each one the undo will put\n * back, as the turn's restore point holds it. Made before the undo, at the revision it requires,\n * so the undo can store them: one written meanwhile is not undone, and its document goes unused.\n */\nexport async function undoneTurnDocuments(\n context: MergeContext,\n turnRunId: string\n): Promise<Record<string, FileRef>> {\n const { projectId, storage } = context\n const documents: Record<string, FileRef> = {}\n\n for (const write of await storage.listTurnWrites({ projectId, turnRunId })) {\n if (write.created) continue\n const artifact = await storage.get({ projectId, id: write.artifactId })\n if (!artifact || !keepsDocument(artifact.kind)) continue\n\n // Undone by the rule the undo applies, at the revision it will find.\n const points = await storage.listRestorePoints({ projectId, id: artifact.id })\n const point = points.find((each) => each.turnRunId === turnRunId)\n const target =\n point &&\n (await storage.getVersion({ projectId, artifactId: artifact.id, version: point.version }))\n const undoable = turnUndoable({\n write,\n revision: artifact.revision,\n ...(point ? { point } : {}),\n ...(target ? { target: { frozen: target.frozenAt !== undefined } } : {}),\n })\n if (!point || !undoable) continue\n\n const held = await documentHolding(context, artifact.id, point.files)\n if (held?.baseRevision === artifact.revision) documents[artifact.id] = held.document\n }\n return documents\n}\n\nfunction isMoved(error: unknown): boolean {\n return (\n (error instanceof ArtifactRequestError || error instanceof ArtifactStorageError) &&\n error.code === \"artifact_moved\"\n )\n}\n\n/**\n * The files the artifact held at a revision, when something still holds them: its latest version,\n * one of its versions, or a restore point. Null for a revision since replaced.\n */\nasync function filesAtRevision(\n storage: ArtifactStorage,\n projectId: string,\n artifactId: string,\n revision: number\n): Promise<readonly ArtifactFile[] | null> {\n const point = await storage.getRestorePoint({ projectId, artifactId, revision })\n if (point) return point.files\n\n const { versions } = await storage.listVersions({ projectId, artifactId, limit: 50 })\n return versions.find((version) => version.revision === revision)?.files ?? null\n}\n",
13
+ "import { createHash } from \"node:crypto\"\nimport type { Principal } from \"../../auth\"\nimport { statFileRef } from \"../../blob-storage/file-content\"\nimport type { BlobStorage, FileRef } from \"../../blob-storage/types\"\nimport { isValidFileRef } from \"../../blob-storage/validation\"\nimport type { AgentQueueJob, Queue } from \"../../queues\"\nimport type {\n ArtifactBoardPreviewRecord,\n ArtifactBoardPreviewSize,\n ArtifactFile,\n ArtifactStorage,\n ArtifactVersionRecord,\n} from \"../../storage/artifacts/types\"\nimport { CANVAS_FILE } from \"../canvas\"\nimport { BOARD_PREVIEW_JOB, BOARD_PREVIEW_WAIT_MS } from \"../canvas-display\"\nimport { FRAME_ASSETS } from \"../frames/assets\"\nimport { FRAME_DEFAULT_THEMES } from \"../frames/kit\"\nimport type { ArtifactOutline, CanvasOutline, CanvasOutlineItem } from \"../outline\"\nimport { type ArtifactQueryResult, artifactQueryName } from \"../queries\"\nimport type { ArtifactThemeMode } from \"../theme\"\nimport { answerArtifactQueries } from \"./query-answers\"\n\n// A canvas's boards are pages, and a hundred pages cannot all run at once: the app shows each as\n// a picture until it is read. The picture is derived data, kept apart from the version by what it\n// shows, its render key, so a version that keeps a board as it was keeps its picture.\n//\n// Whoever publishes a version may render its pictures, as the Agent's layout check does; what is\n// still missing is rendered by the agent worker in a blank sandbox. Either way the board runs with\n// the data its version's author can see: never more.\n\n/** A board's picture in one mode and size, as its renderer hands it over. */\nexport interface BoardPreviewInput {\n /** The board's id in the version. */\n readonly board: string\n readonly theme: ArtifactThemeMode\n readonly size: ArtifactBoardPreviewSize\n /** A PNG at full size, a WebP when small. */\n readonly file: FileRef\n}\n\n/** What each size of picture is stored as. */\nexport const BOARD_PREVIEW_MEDIA_TYPES: Readonly<Record<ArtifactBoardPreviewSize, string>> = {\n full: \"image/png\",\n small: \"image/webp\",\n}\n\nconst SIZES: readonly ArtifactBoardPreviewSize[] = [\"full\", \"small\"]\n\n/** A board of a version whose picture is missing, in either size, in some of its modes. */\nexport interface MissingBoardPreview {\n readonly board: CanvasOutlineBoard\n readonly renderKey: string\n readonly themes: readonly ArtifactThemeMode[]\n}\n\n/** Whether a board's picture can be shown, will be, or will not come. */\nexport type BoardPreviewStatus = \"ready\" | \"pending\" | \"none\"\n\nexport type CanvasOutlineBoard = Extract<CanvasOutlineItem, { readonly type: \"board\" }>\n\n/** Asks for what is missing of a stored version's pictures; see {@link requestBoardPreviews}. */\nexport type BoardPreviewRequester = (\n version: ArtifactVersionRecord,\n options?: BoardPreviewRequestOptions\n) => Promise<void>\n\nexport interface BoardPreviewRequestOptions {\n /**\n * How long the worker waits before it renders: by default `BOARD_PREVIEW_JOB.settleMs`, so a\n * canvas being edited is rendered once it rests. Longer when the publisher renders the pictures\n * itself, as the Agent's layout check does.\n */\n readonly delayMs?: number\n /**\n * Leaves the version's queries unanswered: the worker then pictures only the boards that read\n * none, and a board that reads one keeps its outline.\n */\n readonly withoutAnswers?: boolean\n}\n\n/**\n * The largest picture of a board kept. Most boards' full pictures are far smaller, but a busy\n * board as wide as 8000 pixels can pass it: that picture is not kept, and the board shows its\n * outline in that size.\n */\nexport const MAX_BOARD_PREVIEW_BYTES = 8 * 1024 * 1024\n\nconst RENDER_KEY_FORMAT = \"sixb-board-preview/1\"\n\n/**\n * What a board's picture is of, as a SHA-256: its HTML and size, every file it could load (each\n * of the version's but `canvas.json` and the other boards' HTML), the frame's kit, runtime and\n * themes it runs in, and its artifact. `theme.json` is one of the files, so the modes and tokens it\n * sets are in the key too.\n *\n * Naming the artifact keeps each artifact's pictures its own: whoever may hand over a picture for\n * one may already change its boards, but not another's. Who saves the version does not count: a\n * person moving a note, or an Agent turn someone else asked for, keeps the pictures of the boards\n * it left as they were.\n *\n * When the version holds queries the picture shows its author's data: the key names the author\n * too, so a version saved by someone else renders their data, not the previous author's.\n */\nexport function boardRenderKey(input: {\n readonly board: Pick<CanvasOutlineBoard, \"file\" | \"w\" | \"h\">\n readonly files: readonly ArtifactFile[]\n /** Every board's HTML file in the version: the others are not this board's to load. */\n readonly boardFiles: ReadonlySet<string>\n readonly author: Principal\n readonly artifactId: string\n}): string {\n const { board, files, boardFiles, author, artifactId } = input\n\n const loaded = files\n .filter(\n (entry) =>\n entry.path !== CANVAS_FILE && (entry.path === board.file || !boardFiles.has(entry.path))\n )\n .map((entry) => [entry.path, entry.file.digest] as const)\n .sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0))\n\n const reader = boardsReadLiveData({ files }) ? [author.type, author.id] : null\n\n return createHash(\"sha256\")\n .update(\n JSON.stringify([\n RENDER_KEY_FORMAT,\n frameKitDigest(),\n board.file,\n board.w,\n board.h,\n artifactId,\n reader,\n loaded,\n ])\n )\n .digest(\"hex\")\n}\n\n/** A canvas's outline with the modes its boards are pictured in. */\nexport function canvasPreviewOutline(\n outline: CanvasOutline,\n themes: readonly ArtifactThemeMode[]\n): CanvasOutline {\n return { ...outline, themes: [...themes] }\n}\n\n/**\n * A version with each of its canvas's boards named by its render key, for the artifact it is\n * stored in. Any other kind stays as it is.\n */\nexport function withBoardRenderKeys<\n TVersion extends Pick<ArtifactVersionRecord, \"outline\" | \"files\" | \"author\">,\n>(version: TVersion, artifactId: string): TVersion {\n const { outline } = version\n if (outline.kind !== \"canvas\") return version\n\n const boardFiles = new Set(\n outline.items.flatMap((item) => (item.type === \"board\" ? [item.file] : []))\n )\n return {\n ...version,\n outline: {\n ...outline,\n items: outline.items.map((item) =>\n item.type === \"board\"\n ? {\n ...item,\n renderKey: boardRenderKey({\n board: item,\n files: version.files,\n boardFiles,\n author: version.author,\n artifactId,\n }),\n }\n : item\n ),\n },\n }\n}\n\n/**\n * What a copy of an artifact, such as a forked conversation's, does with its canvases' pictures.\n * Each board is named anew for the copy. A board kept from a static version keeps the source's\n * pictures under its new name: it is the same page. A board that shows its author's data gets\n * none, and runs live for the copy's readers.\n */\nexport function boardPreviewsOfCopy(copyId: string): {\n /** The outline each copied version takes; see `CopyArtifactInput.outlineOf`. */\n readonly outlineOf: (version: ArtifactVersionRecord) => ArtifactOutline | undefined\n /** Keeps the static boards' pictures under their new names, once the copy is stored. */\n readonly carry: (\n storage: Pick<ArtifactStorage, \"listBoardPreviews\" | \"putBoardPreviews\">,\n projectId: string\n ) => Promise<void>\n} {\n const renamed = new Map<string, string>()\n\n const outlineOf = (version: ArtifactVersionRecord): ArtifactOutline | undefined => {\n if (version.outline.kind !== \"canvas\") return undefined\n\n const copied = withBoardRenderKeys(version, copyId)\n if (boardsReadLiveData(version)) return copied.outline\n\n const source = new Map(previewedBoards(version).boards.map((each) => [each.id, each.renderKey]))\n for (const board of previewedBoards(copied).boards) {\n const from = source.get(board.id)\n if (from) renamed.set(from, board.renderKey)\n }\n\n return copied.outline\n }\n\n const carry = async (\n storage: Pick<ArtifactStorage, \"listBoardPreviews\" | \"putBoardPreviews\">,\n projectId: string\n ) => {\n if (renamed.size === 0) return\n\n const pictures = await storage.listBoardPreviews({ projectId, renderKeys: [...renamed.keys()] })\n const previews = pictures.flatMap((picture) => {\n const renderKey = renamed.get(picture.renderKey)\n return renderKey ? [{ ...picture, renderKey }] : []\n })\n\n if (previews.length > 0) await storage.putBoardPreviews({ projectId, previews })\n }\n\n return { outlineOf, carry }\n}\n\n/** The boards of a version with a render key, and the modes each has a picture in. */\nfunction previewedBoards(version: ArtifactVersionRecord): {\n readonly boards: readonly (CanvasOutlineBoard & { readonly renderKey: string })[]\n readonly themes: readonly ArtifactThemeMode[]\n} {\n const { outline } = version\n if (outline.kind !== \"canvas\" || !outline.themes) return { boards: [], themes: [] }\n\n return {\n boards: outline.items.flatMap((item) =>\n item.type === \"board\" && item.renderKey ? [{ ...item, renderKey: item.renderKey }] : []\n ),\n themes: outline.themes,\n }\n}\n\n/** Whether a version holds queries: its boards then show its author's data. */\nexport function boardsReadLiveData(version: Pick<ArtifactVersionRecord, \"files\">): boolean {\n return version.files.some((file) => artifactQueryName(file.path) !== undefined)\n}\n\n/** The pictures a version's boards have, by board id: each in its modes and sizes. */\nexport async function boardPreviews(\n storage: Pick<ArtifactStorage, \"listBoardPreviews\">,\n version: ArtifactVersionRecord\n): Promise<ReadonlyMap<string, readonly ArtifactBoardPreviewRecord[]>> {\n const { boards } = previewedBoards(version)\n if (boards.length === 0) return new Map()\n\n const stored = await storage.listBoardPreviews({\n projectId: version.projectId,\n renderKeys: [...new Set(boards.map((board) => board.renderKey))],\n })\n\n return new Map(\n boards.map((board) => [\n board.id,\n stored.filter((preview) => preview.renderKey === board.renderKey),\n ])\n )\n}\n\n/** A board's picture in one mode and size, among its pictures. */\nexport function boardPreview(\n pictures: readonly ArtifactBoardPreviewRecord[] | undefined,\n theme: ArtifactThemeMode,\n size: ArtifactBoardPreviewSize\n): ArtifactBoardPreviewRecord | undefined {\n return pictures?.find((picture) => picture.theme === theme && picture.size === size)\n}\n\n/** Whether a board has its pictures in a mode: both sizes, which its renderer takes together. */\nfunction pictured(\n pictures: readonly ArtifactBoardPreviewRecord[] | undefined,\n theme: ArtifactThemeMode\n): boolean {\n return SIZES.every((size) => boardPreview(pictures, theme, size))\n}\n\n/** The boards of a version still without a picture in one of its modes, in the canvas's order. */\nexport async function missingBoardPreviews(\n storage: Pick<ArtifactStorage, \"listBoardPreviews\">,\n version: ArtifactVersionRecord\n): Promise<readonly MissingBoardPreview[]> {\n const { boards, themes } = previewedBoards(version)\n const stored = await boardPreviews(storage, version)\n\n return boards.flatMap((board) => {\n const missing = themes.filter((theme) => !pictured(stored.get(board.id), theme))\n return missing.length === 0 ? [] : [{ board, renderKey: board.renderKey, themes: missing }]\n })\n}\n\n/**\n * Each board's picture as a reader asks for it: `ready` in every mode, `pending` while one may\n * still come, `none` when nothing will render it: a project without sandboxes, a version from\n * before pictures, or one written longer ago than the wait.\n */\nexport async function boardPreviewStatuses(\n storage: Pick<ArtifactStorage, \"listBoardPreviews\">,\n version: ArtifactVersionRecord,\n input: { readonly renders: boolean; readonly now: Date }\n): Promise<ReadonlyMap<string, BoardPreviewStatus>> {\n const { boards, themes } = previewedBoards(version)\n const stored = await boardPreviews(storage, version)\n const waiting =\n input.renders && input.now.getTime() - version.updatedAt.getTime() < BOARD_PREVIEW_WAIT_MS\n\n return new Map(\n boards.map((board) => {\n const ready = themes.every((theme) => pictured(stored.get(board.id), theme))\n return [board.id, ready ? \"ready\" : waiting ? \"pending\" : \"none\"] as const\n })\n )\n}\n\n/** A picture that was not kept, and why, in words for whoever handed it over. */\nexport interface RefusedBoardPreview {\n readonly board: string\n readonly theme: ArtifactThemeMode\n readonly size: ArtifactBoardPreviewSize\n readonly reason: string\n}\n\n/**\n * Keeps pictures of a stored version's boards, each under its board's render key. Who may hand\n * them over is the caller's decision: only whoever rendered them with the author's data. Each\n * picture stands alone: one for a board or a mode the version has no picture for, in another\n * format than its size's, past the size limit, or not stored, is left out and returned, and the\n * others are kept.\n */\nexport async function storeBoardPreviews(\n context: {\n readonly storage: Pick<ArtifactStorage, \"putBoardPreviews\">\n readonly blobStorage: Pick<BlobStorage, \"stat\">\n },\n version: ArtifactVersionRecord,\n previews: readonly BoardPreviewInput[]\n): Promise<readonly RefusedBoardPreview[]> {\n if (previews.length === 0) return []\n\n const { boards, themes } = previewedBoards(version)\n const keys = new Map(boards.map((board) => [board.id, board.renderKey]))\n const createdAt = new Date()\n\n const checked = await Promise.all(\n previews.map(async (preview) => {\n const { board, theme, size, file } = preview\n const refuse = (reason: string) => ({ refused: { board, theme, size, reason } })\n\n const renderKey = keys.get(board)\n if (!renderKey || !themes.includes(theme)) {\n return refuse(`the version has no board '${board}' to picture in ${theme} mode`)\n }\n\n const mediaType = SIZES.includes(size) ? BOARD_PREVIEW_MEDIA_TYPES[size] : undefined\n if (!mediaType || !isValidFileRef(file) || file.mediaType !== mediaType) {\n return refuse(`a ${size} picture must be ${mediaType ?? \"full or small\"}`)\n }\n if (file.sizeBytes > MAX_BOARD_PREVIEW_BYTES) {\n return refuse(`it is ${file.sizeBytes} bytes, past the ${MAX_BOARD_PREVIEW_BYTES} kept`)\n }\n if (!(await statFileRef(context.blobStorage, file))) return refuse(\"it is not stored\")\n\n return { record: { renderKey, theme, size, file: { ...file }, createdAt } }\n })\n )\n\n const records = checked.flatMap((each) => (\"record\" in each ? [each.record] : []))\n if (records.length > 0) {\n await context.storage.putBoardPreviews({ projectId: version.projectId, previews: records })\n }\n\n return checked.flatMap((each) => (\"refused\" in each ? [each.refused] : []))\n}\n\n/**\n * One job per artifact. Each write that asks replaces the job still waiting, so a canvas edited\n * live, written back every few seconds, waits for one job, which renders its latest revision once\n * it rests, never each state it went through.\n */\nexport function boardPreviewsJobId(artifactId: string): string {\n return `art_previews_${artifactId}`\n}\n\n/**\n * Asks the agent worker to render what a stored version's boards still miss, `delayMs` from now,\n * in the artifact's one job: it takes the place of any asked for an earlier revision. Nothing is\n * asked when nothing is missing.\n *\n * Boards that read queries show their author's data, so the version's queries are answered now,\n * by `query`, as whoever just published it, and the job carries the answers: kept as a blob only\n * the job names. A query that fails is answered as its rejection. Only the write that asks last\n * has its answers rendered: those of a job it replaced are never read.\n *\n * The version exists by now and its pictures are derived from it, so a request that fails is\n * reported, not thrown: the publish succeeded, and the viewer shows the boards' outlines instead.\n */\nexport async function requestBoardPreviews(\n input: {\n readonly storage: Pick<ArtifactStorage, \"listBoardPreviews\">\n readonly queue: Pick<Queue<AgentQueueJob>, \"enqueue\">\n readonly blobStorage: Pick<BlobStorage, \"put\">\n /** Runs one of the version's queries as its publisher. */\n readonly query: (name: string) => Promise<ArtifactQueryResult | null>\n },\n version: ArtifactVersionRecord,\n options: BoardPreviewRequestOptions = {}\n): Promise<void> {\n if (version.outline.kind !== \"canvas\") return\n\n try {\n if ((await missingBoardPreviews(input.storage, version)).length === 0) return\n\n const queries =\n boardsReadLiveData(version) && !options.withoutAnswers\n ? await storeQueryAnswers(input, version)\n : undefined\n\n const delayMs = options.delayMs ?? BOARD_PREVIEW_JOB.settleMs\n await input.queue.enqueue({\n projectId: version.projectId,\n jobs: [\n {\n id: boardPreviewsJobId(version.artifactId),\n replace: true,\n type: \"agent.artifact-previews.requested\",\n payload: {\n artifactId: version.artifactId,\n version: version.version,\n updatedAt: version.updatedAt.toISOString(),\n ...(queries ? { queries } : {}),\n },\n availableAt: new Date(Date.now() + delayMs).toISOString(),\n },\n ],\n })\n } catch (error) {\n console.error(\n `[Sixb] Could not ask for the previews of version ${version.version} of '${version.artifactId}'; its boards show their outlines.`,\n error\n )\n }\n}\n\n/** The version's query answers, as its publisher reads them, as a JSON blob. */\nasync function storeQueryAnswers(\n input: {\n readonly blobStorage: Pick<BlobStorage, \"put\">\n readonly query: (name: string) => Promise<ArtifactQueryResult | null>\n },\n version: ArtifactVersionRecord\n): Promise<FileRef> {\n const answers = await answerArtifactQueries(version, input.query)\n const body = new TextEncoder().encode(JSON.stringify(answers))\n\n return input.blobStorage.put({\n body,\n expectedSizeBytes: body.byteLength,\n fileName: `${version.artifactId}-r${version.revision}-queries.json`,\n mediaType: \"application/json\",\n })\n}\n\nlet kitDigest: string | undefined\n\n/** What a board runs with besides its own files: a new kit renders it anew. */\nfunction frameKitDigest(): string {\n kitDigest ??= createHash(\"sha256\")\n .update(JSON.stringify([FRAME_ASSETS, FRAME_DEFAULT_THEMES]))\n .digest(\"hex\")\n return kitDigest\n}\n",
14
+ "import { AuthorizationError } from \"../../authorization/errors\"\nimport { ObjectQueryExecutionError } from \"../../objects/query/errors\"\nimport type { ArtifactVersionRecord } from \"../../storage/artifacts/types\"\nimport { ArtifactRequestError } from \"../errors\"\nimport { type ArtifactQueryResult, artifactQueryName, isArtifactQueryName } from \"../queries\"\nimport { serializeArtifactQueryResult } from \"../serialize-query\"\n\n// A page opened outside the app, by the Agent's layout check or to picture a canvas's boards, reads\n// its queries from answers read beforehand: each as the query route serves it to whoever read it,\n// or why it failed for them, which the page's `sixb.query` rejects with.\n\n/** What `sixb.query(name)` reads in a page opened outside the app. */\nexport type ArtifactQueryAnswer = { readonly result: unknown } | { readonly error: string }\n\n/** A version's query answers by name. */\nexport type ArtifactQueryAnswers = Readonly<Record<string, ArtifactQueryAnswer>>\n\n/**\n * One query's answer, as `read` reads it: its result serialized as the route serves it, or a\n * refusal in the words the API gives a reader. Any other failure stays internal.\n */\nexport async function answerArtifactQuery(\n read: () => Promise<ArtifactQueryResult | null>\n): Promise<ArtifactQueryAnswer> {\n try {\n const result = await read()\n if (!result) return { error: UNREADABLE }\n\n return { result: serializeArtifactQueryResult(result) }\n } catch (error) {\n if (\n error instanceof ArtifactRequestError ||\n error instanceof AuthorizationError ||\n error instanceof ObjectQueryExecutionError\n ) {\n return { error: /[.!?]$/.test(error.message) ? error.message : `${error.message}.` }\n }\n\n console.warn(\"[Sixb] A query of an artifact version did not run:\", error)\n return { error: UNREADABLE }\n }\n}\n\n/** Every query a version holds, each answered by `read`: as whoever it reads as. */\nexport async function answerArtifactQueries(\n version: Pick<ArtifactVersionRecord, \"files\">,\n read: (name: string) => Promise<ArtifactQueryResult | null>\n): Promise<ArtifactQueryAnswers> {\n const names = version.files.flatMap((file) => {\n const name = artifactQueryName(file.path)\n return name === undefined ? [] : [name]\n })\n\n const answers = await Promise.all(\n names.map(async (name) => [name, await answerArtifactQuery(() => read(name))] as const)\n )\n return Object.fromEntries(answers)\n}\n\n/** Answers kept as JSON, or `null` when the text holds none. */\nexport function parseArtifactQueryAnswers(text: string): ArtifactQueryAnswers | null {\n let value: unknown\n try {\n value = JSON.parse(text)\n } catch {\n return null\n }\n if (!isObject(value)) return null\n\n const answers: Record<string, ArtifactQueryAnswer> = {}\n for (const [name, answer] of Object.entries(value)) {\n if (!isArtifactQueryName(name) || !isObject(answer)) return null\n\n if (\"result\" in answer) answers[name] = { result: answer.result }\n else if (typeof answer.error === \"string\") answers[name] = { error: answer.error }\n else return null\n }\n return answers\n}\n\nconst UNREADABLE = \"[Sixb] The query could not be read.\"\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n}\n",
15
+ "import { getAuthorizedOntologyView } from \"../execution/authorized-object-reader\"\nimport type { AuthorizedOntologyView } from \"../objects/authorized-ontology-view\"\nimport { ObjectQueryPlanningError, ObjectQueryValidationError } from \"../objects/query/errors\"\nimport type { ObjectExpansion } from \"../objects/query/ir\"\nimport { type ValidatedObjectQuery, validateObjectQuery } from \"../objects/query/validate\"\nimport type { Schema, ValueType } from \"../ontology/types\"\nimport type { SixbRuntimeContext } from \"../runtime/types\"\nimport type { ObjectRow } from \"../storage/objects/types\"\nimport { ArtifactRequestError } from \"./errors\"\nimport { ARTIFACT_LIMITS } from \"./limits\"\nimport type {\n ArtifactQuery,\n ArtifactQueryProperty,\n ArtifactQueryResult,\n ArtifactQuerySchema,\n ArtifactQueryShape,\n} from \"./queries\"\n\n/** Rows read per call to the reader, so a large result never comes back in one response. */\nconst PAGE_SIZE = 1_000\n\n/**\n * Runs one of a version's queries as the runtime's caller, through their object reader: what they\n * cannot view refuses the query, and what they are not cleared for is left out of each row.\n *\n * The query was valid when it was published, but the ontology may have changed since: a query\n * that no longer validates, or no longer plans, is `query_invalid`. Rows are read a page at a\n * time, up to `ARTIFACT_LIMITS.maxQueryRows`, within any `limit` the query declares.\n */\nexport async function runArtifactQuery(\n runtime: Pick<SixbRuntimeContext, \"ontology\" | \"objectReader\">,\n name: string,\n query: ArtifactQuery\n): Promise<ArtifactQueryResult> {\n try {\n const shape = describeArtifactQuery(runtime, query)\n\n if (query.kind === \"facets\") {\n const { total, facets } = await runtime.objectReader.facet({\n query: query.query,\n facets: query.facets,\n })\n return { kind: \"facets\", total, facets, ...shape }\n }\n\n return { kind: \"objects\", ...(await readRows(runtime, query.query)), ...shape }\n } catch (error) {\n throw queryInvalid(name, error)\n }\n}\n\n/**\n * What a query returns and reads, and what its rows hold as the runtime's caller may view them. It\n * throws what validating the query throws.\n */\nexport function describeArtifactQuery(\n runtime: Pick<SixbRuntimeContext, \"ontology\" | \"objectReader\">,\n query: ArtifactQuery\n): ArtifactQueryShape {\n const validated = validateObjectQuery(query.query, { ontology: runtime.ontology })\n\n return {\n resultObjectTypeIds: [...validated.result.objectTypeIds],\n readObjectTypeIds: [...validated.touchedObjectTypeIds],\n schema: artifactQuerySchema(getAuthorizedOntologyView(runtime.objectReader), validated),\n }\n}\n\n/**\n * The properties of the types a validated query returns, and of those each link it expands on its\n * rows reaches, read from `view`: a reader is never told of a property their view leaves out. A\n * type the view leaves out adds none. Only the outermost expansions are read, where normalization\n * puts every expansion of the rows; one nested in another is not.\n */\nexport function artifactQuerySchema(\n view: AuthorizedOntologyView,\n validated: ValidatedObjectQuery\n): ArtifactQuerySchema {\n const valueTypes = view.getValueTypesById()\n const results = validated.result.objectTypeIds\n const root = validated.query\n\n const links: Record<string, { properties: Record<string, ArtifactQueryProperty> }> = {}\n for (const expansion of root.kind === \"expand\" ? root.expansions : []) {\n links[expansion.linkId] = {\n properties: propertiesOf(view, expansionTargets(view, results, expansion), valueTypes),\n }\n }\n\n return { properties: propertiesOf(view, results, valueTypes), links }\n}\n\nfunction propertiesOf(\n view: AuthorizedOntologyView,\n objectTypeIds: readonly string[],\n valueTypes: ReadonlyMap<string, ValueType>\n): Record<string, ArtifactQueryProperty> {\n const properties: Record<string, ArtifactQueryProperty> = {}\n\n for (const objectTypeId of objectTypeIds) {\n for (const property of view.getObjectTypeById(objectTypeId)?.properties ?? []) {\n properties[property.id] ??= queryProperty(property.schema, valueTypes)\n }\n }\n\n return properties\n}\n\n/** What an expansion reaches from the rows, as the validator resolves it, within the view. */\nfunction expansionTargets(\n view: AuthorizedOntologyView,\n results: readonly string[],\n expansion: ObjectExpansion\n): string[] {\n const targets = new Set<string>()\n\n if (expansion.direction === \"outgoing\") {\n for (const objectTypeId of results) {\n const link = view\n .getObjectTypeById(objectTypeId)\n ?.links.find((candidate) => candidate.id === expansion.linkId)\n if (!link || link.targetObjectTypeId === \"*\") continue\n\n for (const target of [link.targetObjectTypeId].flat()) targets.add(target)\n }\n return [...targets]\n }\n\n const sources =\n expansion.sourceObjectTypeId === undefined\n ? view.listObjectTypes()\n : [view.getObjectTypeById(expansion.sourceObjectTypeId)].filter((type) => type !== null)\n\n for (const source of sources) {\n const link = source.links.find((candidate) => candidate.id === expansion.linkId)\n if (!link) continue\n\n const reaches =\n link.targetObjectTypeId === \"*\" ||\n results.some((result) => view.isValidLinkTarget(link.targetObjectTypeId, result))\n if (reaches) targets.add(source.id)\n }\n return [...targets]\n}\n\n/** A property's schema as a value of a row holds it: a value type's resolved to its own. */\nfunction queryProperty(\n schema: Schema,\n valueTypes: ReadonlyMap<string, ValueType>,\n depth = 0\n): ArtifactQueryProperty {\n if (typeof schema === \"string\") return { type: schema }\n\n switch (schema.type) {\n case \"valueTypeRef\": {\n const named = valueTypes.get(schema.valueTypeId)?.schema ?? schema._resolved\n // A value type naming itself, through others or not, holds what nothing else says.\n return named && depth < 8 ? queryProperty(named, valueTypes, depth + 1) : { type: \"object\" }\n }\n case \"enum\":\n return { type: \"enum\", valueType: schema.valueType }\n default:\n return { type: schema.type }\n }\n}\n\nasync function readRows(\n runtime: Pick<SixbRuntimeContext, \"objectReader\">,\n query: ArtifactQuery[\"query\"]\n): Promise<{ objects: ObjectRow[]; total: number; truncated: boolean }> {\n const objects: ObjectRow[] = []\n let total = 0\n let pageToken: string | undefined\n\n for (;;) {\n // The last page asks only for what fits under the cap, and says whether more remain.\n const pageSize = Math.min(PAGE_SIZE, ARTIFACT_LIMITS.maxQueryRows - objects.length)\n const first = pageToken === undefined\n\n const page = await runtime.objectReader.executeQuery({\n query: { kind: \"page\", input: query, pageSize, ...(pageToken ? { pageToken } : {}) },\n ...(first ? { includeTotal: true } : {}),\n })\n\n if (first) total = page.total ?? page.objects.length\n objects.push(...page.objects)\n\n if (!page.hasMore || page.nextPageToken === undefined) {\n return { objects, total, truncated: false }\n }\n if (objects.length >= ARTIFACT_LIMITS.maxQueryRows) {\n return { objects, total, truncated: true }\n }\n\n pageToken = page.nextPageToken\n }\n}\n\n/** A query the ontology no longer admits, in the words validation gives; anything else as is. */\nfunction queryInvalid(name: string, error: unknown): unknown {\n if (!(error instanceof ObjectQueryValidationError || error instanceof ObjectQueryPlanningError)) {\n return error\n }\n\n const issues = error.issues.map((issue) => `${issue.path}: ${issue.message}`).join(\"; \")\n const problem =\n error instanceof ObjectQueryValidationError\n ? \"no longer matches the ontology\"\n : \"can no longer run\"\n\n return new ArtifactRequestError(\"query_invalid\", `[Sixb] Query '${name}' ${problem}: ${issues}`)\n}\n",
16
+ "import { isRuntimeAllowed } from \"../../authorization\"\nimport { AuthorizationError } from \"../../authorization/errors\"\nimport { readerClearance } from \"../../execution/authorized-object-reader\"\nimport type { PropertyClearance } from \"../../objects/property-clearance\"\nimport {\n ObjectQueryExecutionError,\n ObjectQueryPlanningError,\n ObjectQueryValidationError,\n} from \"../../objects/query/errors\"\nimport type { ObjectExpansion, ObjectQuery } from \"../../objects/query/ir\"\nimport { normalizeObjectQuery } from \"../../objects/query/normalize\"\nimport {\n type ObjectQuerySemanticAdmission,\n validateObjectQueryWithAdmission,\n} from \"../../objects/query/validate\"\nimport type { OntologyRegistry } from \"../../ontology\"\nimport type { SixbRuntimeContext } from \"../../runtime/types\"\nimport type { ArtifactFile } from \"../../storage/artifacts/types\"\nimport type { ArtifactKind } from \"../kinds\"\nimport { ARTIFACT_LIMITS } from \"../limits\"\nimport {\n ARTIFACT_QUERIES_DIRECTORY,\n ARTIFACT_QUERY_KINDS,\n type ArtifactQuery,\n artifactQueryName,\n type CheckedArtifactQuery,\n parseArtifactQuery,\n} from \"../queries\"\nimport { describeArtifactQuery } from \"../run-query\"\nimport { type ArtifactBlobStorage, invalidArtifact, readArtifactText } from \"./files\"\n\n/**\n * Admits a query as the version's author: it throws what running it as them would throw, and\n * refuses one that would return what they cannot read; it returns what the query returns and what\n * its rows hold as they see them. A version is refused when its author could not run one of its\n * queries, so a query never reads what whoever wrote it cannot. Each reader still runs it with\n * their own rights.\n */\nexport type ArtifactQueryChecker = (query: ArtifactQuery) => Promise<CheckedArtifactQuery>\n\n/**\n * The checker for the runtime's caller. Running the query once, as cheaply as its kind allows,\n * is the check: validation against the ontology, `can.view` on every type it reads, clearance for\n * every marked property it filters, sorts or facets on, and the caller's share scope all apply\n * there, as they do when it is read.\n *\n * What the rows carry is checked after: a read leaves out a marked property its reader is not\n * cleared for, and the member profiles of a reader who may not view them, so running the query\n * admits one that returns them. A reader's rows reach the page's code, which its author wrote, so\n * the query may return only what the author can read. Facets return counts, never a property.\n */\nexport function createArtifactQueryChecker(\n runtime: Pick<\n SixbRuntimeContext,\n \"objectReader\" | \"ontology\" | \"projectId\" | \"runtimeAuthorization\" | \"authorization\"\n >\n): ArtifactQueryChecker {\n return async (query) => {\n const shape = describeArtifactQuery(runtime, query)\n\n if (query.kind === \"facets\") {\n await runtime.objectReader.facet({ query: query.query, facets: query.facets })\n return { kind: query.kind, ...shape }\n }\n\n await runtime.objectReader.exists({ query: query.query })\n\n const clearance = await readerClearance(runtime.objectReader)\n if (clearance) assertReturnsReadable(query.query, runtime.ontology, clearance)\n\n // The reader attaches profiles only for an authority that may view the directory.\n if (!isRuntimeAllowed(runtime, { kind: \"users.view\" })) assertExpandsNoUsers(query.query)\n\n return { kind: query.kind, ...shape }\n }\n}\n\n/** A query that would return what its author cannot read, at `at` in the query. */\nclass UnreadableReturnError extends AuthorizationError {\n constructor(\n grantKey: string,\n readonly at: string,\n message: string\n ) {\n super(grantKey, message)\n }\n}\n\n/**\n * Refuses a query whose rows would carry a property its author cannot read: one of the result's,\n * those the outermost `project` lists or every one without it, or one of an object an `expand`\n * attaches, which no projection narrows.\n *\n * A `project` counts only under nothing but expansions, sorts and limits. Under a filter, a\n * traversal or a set operand it may not shape the rows, so the query then returns every property.\n */\nfunction assertReturnsReadable(\n query: ObjectQuery,\n ontology: OntologyRegistry,\n clearance: PropertyClearance\n): void {\n const { normalized, resultObjectTypeIds, expansions } = returnedShape(query, ontology)\n const project = outermostProject(normalized)\n\n for (const objectTypeId of resultObjectTypeIds) {\n const propertyIds = project?.properties ?? propertiesOf(ontology, objectTypeId)\n const unreadable = firstUnreadable(clearance, objectTypeId, propertyIds)\n if (!unreadable) continue\n\n const returns = `returns '${unreadable.propertyId}' on '${objectTypeId}', which you are not cleared to read`\n throw project\n ? new UnreadableReturnError(\n `clearance:marking:${unreadable.marking}`,\n `${project.at}.properties[${unreadable.index}]`,\n `[Sixb] ${returns}: list only the properties you can read.`\n )\n : new UnreadableReturnError(\n `clearance:marking:${unreadable.marking}`,\n \"$\",\n `[Sixb] ${returns}: add a \"project\" node that lists only the properties you can read.`\n )\n }\n\n for (const expansion of expansions) {\n for (const objectTypeId of expansion.objectTypeIds) {\n const unreadable = firstUnreadable(\n clearance,\n objectTypeId,\n propertiesOf(ontology, objectTypeId)\n )\n if (!unreadable) continue\n\n throw new UnreadableReturnError(\n `clearance:marking:${unreadable.marking}`,\n expansion.at,\n `[Sixb] expands '${expansion.linkId}' to '${objectTypeId}', whose '${unreadable.propertyId}' you are not cleared to read: an expansion returns every property, so leave it out, or read '${objectTypeId}' in a query of its own with a \"project\" node.`\n )\n }\n }\n}\n\n/**\n * Refuses a query that expands member profiles, for an author who may not view them. Only the\n * outermost expand names them, at its rows or under its expansions, once normalized.\n */\nfunction assertExpandsNoUsers(query: ObjectQuery): void {\n const normalized = normalizeObjectQuery(query)\n if (normalized.kind !== \"expand\") return\n\n const expanded = firstUserExpansion(normalized.users, normalized.expansions, \"$\")\n if (!expanded) return\n\n throw new UnreadableReturnError(\n \"view:users\",\n expanded.at,\n `[Sixb] returns the member profiles '${expanded.propertyId}' refers to, which you are not allowed to view: leave '${expanded.propertyId}' out of \"users\".`\n )\n}\n\nfunction firstUserExpansion(\n users: readonly string[] | undefined,\n expansions: readonly ObjectExpansion[],\n at: string\n): { readonly propertyId: string; readonly at: string } | undefined {\n const [propertyId] = users ?? []\n if (propertyId !== undefined) return { propertyId, at: `${at}.users[0]` }\n\n for (const [index, expansion] of expansions.entries()) {\n const path = at === \"$\" ? `$.expansions[${index}]` : `${at}.expand[${index}]`\n const found = firstUserExpansion(expansion.users, expansion.expand ?? [], path)\n if (found) return found\n }\n\n return undefined\n}\n\nfunction propertiesOf(ontology: OntologyRegistry, objectTypeId: string): readonly string[] {\n return ontology.resolveObjectType(objectTypeId).properties.map((property) => property.id)\n}\n\nfunction firstUnreadable(\n clearance: PropertyClearance,\n objectTypeId: string,\n propertyIds: readonly string[]\n): { readonly propertyId: string; readonly index: number; readonly marking: string } | undefined {\n for (const [index, propertyId] of propertyIds.entries()) {\n const marking = clearance.missingMarking(objectTypeId, propertyId)\n if (marking !== undefined) return { propertyId, index, marking }\n }\n\n return undefined\n}\n\n/**\n * The query as it runs, the object types it returns, and those each expansion attaches, at any\n * depth. Validation resolves an expansion's targets, so a recording admission reads them there:\n * a set operand's expansions are among them too.\n */\nfunction returnedShape(query: ObjectQuery, ontology: OntologyRegistry) {\n const expansions: { readonly at: string; readonly linkId: string; objectTypeIds: string[] }[] = []\n\n const state = Object.freeze({})\n const recorder: ObjectQuerySemanticAdmission = {\n empty: () => state,\n source: () => ({ state }),\n property: () => undefined,\n edge: (input) => {\n if (input.use === \"expand\") {\n expansions.push({\n at: input.path,\n linkId: input.linkId,\n objectTypeIds: [...input.result.objectTypeIds],\n })\n }\n return { state }\n },\n set: () => state,\n }\n\n const validated = validateObjectQueryWithAdmission(query, { ontology }, recorder)\n return {\n normalized: validated.query,\n resultObjectTypeIds: validated.result.objectTypeIds,\n expansions,\n }\n}\n\n/** The `project` that shapes the rows, through the nodes that keep them as they are. */\nfunction outermostProject(\n query: ObjectQuery,\n at = \"$\"\n): { readonly properties: readonly string[]; readonly at: string } | undefined {\n switch (query.kind) {\n case \"project\":\n return query.properties ? { properties: query.properties, at } : undefined\n case \"expand\":\n case \"limit\":\n case \"sort\":\n return outermostProject(query.input, `${at}.input`)\n default:\n return undefined\n }\n}\n\n/**\n * Checks the `queries/` files of a version: their names and number, their shape, then each one as\n * its author through `checker`, and returns what each check learned by query name, for the kind's\n * own check. Fails closed: a version that holds a query is refused without one. A file artifact is\n * delivered as it is, so its one file is never read as a query.\n */\nexport async function checkArtifactQueries(\n blobStorage: ArtifactBlobStorage,\n kind: ArtifactKind,\n files: readonly ArtifactFile[],\n checker: ArtifactQueryChecker | undefined\n): Promise<ReadonlyMap<string, CheckedArtifactQuery>> {\n const checked = new Map<string, CheckedArtifactQuery>()\n if (kind === \"file\") return checked\n\n const queries = files.filter((file) => file.path.startsWith(ARTIFACT_QUERIES_DIRECTORY))\n const [first] = queries\n if (!first) return checked\n\n if (!ARTIFACT_QUERY_KINDS.includes(kind)) {\n throw invalidArtifact(\n `'${first.path}': a ${kind} runs no query. A document shows a live sheet instead.`\n )\n }\n\n if (queries.length > ARTIFACT_LIMITS.maxQueries) {\n throw invalidArtifact(\n `A version holds at most ${ARTIFACT_LIMITS.maxQueries} queries; this one has ${queries.length}.`\n )\n }\n\n if (!checker) {\n throw invalidArtifact(\n `'${first.path}' is a query, and this publish has no way to check it as its author.`\n )\n }\n\n // One at a time, so the same version is always refused for the same query.\n for (const file of queries) {\n const name = artifactQueryName(file.path)\n if (!name) {\n throw invalidArtifact(\n `'${file.path}' is not a query: name it queries/<name>.json, with lowercase letters, digits and hyphens, at most 64 characters.`\n )\n }\n\n const text = await readArtifactText(blobStorage, file, ARTIFACT_LIMITS.maxQueryBytes)\n const parsed = parseArtifactQuery(file.path, text)\n if (\"error\" in parsed) throw invalidArtifact(parsed.error)\n\n try {\n checked.set(name, await checker(parsed.query))\n } catch (error) {\n throw refusal(file.path, parsed, error)\n }\n }\n\n return checked\n}\n\n/**\n * Why the author cannot run the query, naming the file and, for a problem in the query, where it\n * is in the file. A query's own paths start at the query, which a request holds under `query`;\n * a facet's paths are the file's already.\n */\nfunction refusal(\n path: string,\n parsed: { readonly query: ArtifactQuery; readonly at: \"$\" | \"$.query\" },\n error: unknown\n): unknown {\n const inFile = (issuePath: string) =>\n parsed.query.kind === \"facets\" && issuePath.startsWith(\"$.facets\")\n ? issuePath\n : `${parsed.at}${issuePath.slice(1)}`\n\n if (error instanceof UnreadableReturnError) {\n return invalidArtifact(\n `${path}: ${inFile(error.at)}: ${error.message.replace(/^\\[Sixb\\]\\s*/, \"\")}`\n )\n }\n\n if (error instanceof ObjectQueryValidationError || error instanceof ObjectQueryPlanningError) {\n const issues = error.issues.map((issue) => `${inFile(issue.path)}: ${issue.message}`)\n return invalidArtifact(`${path}: ${issues.join(\"; \")}`)\n }\n\n if (error instanceof AuthorizationError || error instanceof ObjectQueryExecutionError) {\n return invalidArtifact(`${path}: ${error.message.replace(/^\\[Sixb\\]\\s*/, \"\")}`)\n }\n\n return error\n}\n",
17
+ "import { type Principal, principalsEqual } from \"../../auth\"\nimport type {\n ArtifactRecord,\n ArtifactStorage,\n ArtifactVersionRecord,\n} from \"../../storage/artifacts/types\"\nimport { parseArtifactAddress } from \"../address\"\nimport { ARTIFACT_LIMITS } from \"../limits\"\nimport type { ArtifactReference } from \"../references\"\nimport { resolveArtifactAddress } from \"../resolve\"\nimport type { ArtifactWarning } from \"../warnings\"\nimport { invalidArtifact } from \"./files\"\n\n/** An address a validator found in a version, before it is resolved. */\nexport type FoundReference = Omit<ArtifactReference, \"resolvedVersion\">\n\ninterface ReferenceContext {\n readonly projectId: string\n readonly storage: ArtifactStorage\n /** Whether an address may name this artifact: one whoever publishes can read. */\n readonly readable: (artifact: ArtifactRecord) => Promise<boolean>\n /** The artifact being published, which an address may not name. */\n readonly artifactId?: string\n}\n\n/**\n * Resolves every address a version uses against what its author can read, recording the version\n * each one resolved to. An address that resolves to nothing refuses the version, saying where it\n * is and what the target has instead, and so does one pinned to a version still open: a pin names\n * content that never changes.\n */\nexport async function resolveReferences(\n context: ReferenceContext,\n found: readonly FoundReference[]\n): Promise<ArtifactReference[]> {\n if (found.length > ARTIFACT_LIMITS.maxReferences) {\n throw invalidArtifact(\n `A version may refer to at most ${ARTIFACT_LIMITS.maxReferences} artifacts; this one has ${found.length} addresses.`\n )\n }\n const artifacts = new Map<string, Promise<ArtifactRecord | null>>()\n const versions = new Map<string, Promise<ArtifactVersionRecord | null>>()\n const resolved: ArtifactReference[] = []\n for (const reference of found) {\n const where = reference.at\n ? `In '${reference.at}', '${reference.address}'`\n : `'${reference.address}'`\n const address = parseArtifactAddress(reference.address)\n if (!address) {\n throw invalidArtifact(\n `${where} is not an artifact address: write artifact:<id>[@<version>][/<file>][#<part>], such as artifact:art_k3m9q2x7tp#chart=revenue.`\n )\n }\n if (address.artifactId === context.artifactId) {\n throw invalidArtifact(\n `${where} names the artifact being published. Link to one of its sections with #<slug> instead.`\n )\n }\n let artifact = artifacts.get(address.artifactId)\n if (!artifact) {\n artifact = context.storage\n .get({ projectId: context.projectId, id: address.artifactId })\n .then(async (record) => (record && (await context.readable(record)) ? record : null))\n artifacts.set(address.artifactId, artifact)\n }\n const record = await artifact\n if (!record) {\n throw invalidArtifact(`${where} names no artifact you can read.`)\n }\n const number = address.version ?? record.latestVersion\n const key = `${record.id}@${number}`\n let version = versions.get(key)\n if (!version) {\n version = context.storage.getVersion({\n projectId: context.projectId,\n artifactId: record.id,\n version: number,\n })\n versions.set(key, version)\n }\n const target = await version\n if (!target) throw invalidArtifact(`${where}: “${record.title}” has no version ${number}.`)\n if (address.version !== undefined && !target.frozenAt) {\n throw invalidArtifact(\n `${where} pins version ${number} of “${record.title}”, 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.`\n )\n }\n const result = resolveArtifactAddress(address, { kind: record.kind, ...target })\n if (\"problem\" in result) {\n throw invalidArtifact(`${where}: “${target.title}” ${result.problem}.`)\n }\n resolved.push({ ...reference, resolvedVersion: target.version })\n }\n return resolved\n}\n\n/**\n * The artifacts a write breaks: each one whose latest version follows this artifact's latest and\n * names something this version no longer has. Only artifacts the author can read are named,\n * and only those the version breaks are checked: most dependents cost no read.\n */\nexport async function brokenDependents(\n context: ReferenceContext,\n artifact: ArtifactRecord,\n version: ArtifactVersionRecord\n): Promise<ArtifactWarning[]> {\n const dependents = await context.storage.listReferencingVersions({\n projectId: context.projectId,\n artifactId: artifact.id,\n })\n const warnings: ArtifactWarning[] = []\n for (const dependent of dependents) {\n if (dependent.artifactId === artifact.id) continue\n\n const broken: ArtifactWarning[] = []\n for (const reference of dependent.references) {\n const address = parseArtifactAddress(reference.address)\n // A pinned address keeps showing the version it names.\n if (address?.artifactId !== artifact.id || address.version !== undefined) continue\n const result = resolveArtifactAddress(address, { kind: artifact.kind, ...version })\n if (!(\"problem\" in result)) continue\n broken.push({\n code: \"reference_broken\",\n message: `“${dependent.title}” (${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.`,\n })\n }\n if (broken.length === 0) continue\n\n const owner = await context.storage.get({\n projectId: context.projectId,\n id: dependent.artifactId,\n })\n if (owner && (await context.readable(owner))) warnings.push(...broken)\n }\n return warnings\n}\n\n/** What its author reads when nothing else is said: their own artifacts, or all for system code. */\nexport function ownArtifacts(author: Principal): (artifact: ArtifactRecord) => Promise<boolean> {\n return async (artifact) => author.type === \"system\" || principalsEqual(author, artifact.owner)\n}\n",
18
+ "import { posix } from \"node:path\"\nimport type { ArtifactFile } from \"../../../storage/artifacts/types\"\nimport { CANVAS_FILE, type Canvas, parseCanvas } from \"../../canvas\"\nimport {\n type CanvasBox,\n type CanvasPoint,\n canvasArrowLine,\n canvasEndBox,\n canvasItemBox,\n} from \"../../canvas-display\"\nimport { ARTIFACT_LIMITS } from \"../../limits\"\nimport type { CanvasOutline, CanvasOutlineItem } from \"../../outline\"\nimport type { ArtifactWarning } from \"../../warnings\"\nimport { type ArtifactBlobStorage, invalidArtifact, readArtifactText } from \"../files\"\nimport type { FoundReference } from \"../references\"\nimport { readHtmlReferences, refuseFrameAssetPaths } from \"./html\"\n\n/**\n * Reads a canvas: `canvas.json`, then each board's HTML, which must be one of the version's files.\n * The addresses its embeds show and its boards use are returned to resolve, each at its item's id.\n * Boards that overlap, and notes or text drawn over a board, are warnings: the reader sees a page\n * covered.\n */\nexport async function validateCanvas(\n blobStorage: ArtifactBlobStorage,\n files: readonly ArtifactFile[]\n): Promise<{\n readonly entry: string\n readonly outline: CanvasOutline\n readonly references: readonly FoundReference[]\n readonly warnings: readonly ArtifactWarning[]\n}> {\n const byPath = new Map(files.map((file) => [file.path, file]))\n const canvasFile = byPath.get(CANVAS_FILE)\n if (!canvasFile) {\n throw invalidArtifact(\n `A canvas is '${CANVAS_FILE}', listing its items, with the HTML files its boards show beside it.`\n )\n }\n refuseFrameAssetPaths(files, \"the canvas\")\n const parsed = parseCanvas(\n await readArtifactText(blobStorage, canvasFile, ARTIFACT_LIMITS.maxCanvasBytes)\n )\n if (\"error\" in parsed) throw invalidArtifact(parsed.error)\n const { canvas } = parsed\n\n const references: FoundReference[] = []\n for (const item of canvas.items) {\n if (item.type === \"embed\") references.push({ address: item.src, as: \"embed\", at: item.id })\n if (item.type !== \"board\") continue\n const file = byPath.get(posix.normalize(item.file))\n if (!file) {\n throw invalidArtifact(\n `${CANVAS_FILE} board '${item.id}' shows '${item.file}', which is not one of the canvas's files.`\n )\n }\n const rewriter = new HTMLRewriter()\n const { references: found, refusal } = readHtmlReferences(rewriter, () => item.id, item.file)\n rewriter.transform(await readArtifactText(blobStorage, file, ARTIFACT_LIMITS.maxBoardBytes))\n const refused = refusal()\n if (refused) throw invalidArtifact(`Board '${item.id}': ${refused}`)\n references.push(...found)\n }\n\n return {\n entry: CANVAS_FILE,\n outline: {\n kind: \"canvas\",\n items: canvas.items.flatMap((item): CanvasOutlineItem[] => {\n const title = item.type === \"board\" || item.type === \"section\" ? item.title : undefined\n const named = { id: item.id, ...(title ? { title } : {}) }\n if (item.type === \"board\") {\n return [\n { ...named, type: \"board\", file: posix.normalize(item.file), w: item.w, h: item.h },\n ]\n }\n return item.type === \"section\" ? [{ ...named, type: \"section\" }] : []\n }),\n },\n references,\n warnings: [\n ...layoutWarnings(canvas),\n ...overprintWarnings(canvas),\n ...crossingArrowWarnings(canvas),\n ],\n }\n}\n\ninterface Box {\n readonly x: number\n readonly y: number\n readonly w: number\n readonly h: number\n}\n\nconst overlaps = (a: Box, b: Box) =>\n a.x < b.x + b.w && b.x < a.x + a.w && a.y < b.y + b.h && b.y < a.y + a.h\n\n/**\n * What covers a board on the canvas: another board over it, or a note or a text whose top left\n * corner lands on it. A note's height follows its text, so only its corner is sure; a section\n * holds boards on purpose.\n */\nfunction layoutWarnings(canvas: Canvas): ArtifactWarning[] {\n const boards = canvas.items.flatMap((item) => (item.type === \"board\" ? [item] : []))\n const warnings: ArtifactWarning[] = []\n boards.forEach((board, index) => {\n for (const other of boards.slice(index + 1)) {\n if (!overlaps(board, other)) continue\n warnings.push({\n code: \"canvas_overlap\",\n part: board.id,\n message: `Boards '${board.id}' and '${other.id}' overlap, so one covers the other's page: leave 80 pixels between boards in a row and 160 between rows.`,\n })\n }\n })\n for (const item of canvas.items) {\n if (item.type !== \"note\" && item.type !== \"text\") continue\n const corner = { x: item.x, y: item.y, w: 1, h: 1 }\n const board = boards.find((candidate) => overlaps(candidate, corner))\n if (!board) continue\n warnings.push({\n code: \"canvas_covers_board\",\n part: item.id,\n message: `${item.type === \"note\" ? \"Note\" : \"Text\"} '${item.id}' sits on board '${board.id}' and covers its page: put it beside the board, and an arrow to it when it is about the board.`,\n })\n }\n return warnings\n}\n\n/** The most pairs of words drawn over each other warned of one by one. */\nconst MAX_OVERPRINTS = 12\n\n/**\n * Texts and notes drawn over each other, as the app draws them: a title's box reckoned from its\n * words and size, lines and all, so a subtitle placed under where a large title ends is caught.\n */\nfunction overprintWarnings(canvas: Canvas): ArtifactWarning[] {\n const worded = canvas.items.flatMap((item) => {\n if (item.type !== \"text\" && item.type !== \"note\") return []\n const box = canvasItemBox(item)\n return box ? [{ item, box }] : []\n })\n\n const pairs = worded.flatMap((first, index) =>\n worded\n .slice(index + 1)\n .filter((second) => intersects(first.box, second.box))\n .map((second) => [first.item, second.item] as const)\n )\n\n const warnings: ArtifactWarning[] = pairs.slice(0, MAX_OVERPRINTS).map(([first, second]) => ({\n code: \"canvas_text_overlap\",\n part: first.id,\n 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.`,\n }))\n const more = pairs.length - warnings.length\n if (more > 0) {\n warnings.push({\n code: \"canvas_text_overlap\",\n message: `${more} more pair${more === 1 ? \" is\" : \"s are\"} drawn over each other.`,\n })\n }\n return warnings\n}\n\n/** Whether two boxes share some area: touching edges do not. */\nfunction intersects(a: CanvasBox, b: CanvasBox): boolean {\n 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\n}\n\n/** The most arrows warned of one by one, and items named for one arrow. */\nconst MAX_CROSSING_ARROWS = 12\nconst MAX_CROSSED_ITEMS = 3\n\n/**\n * Arrows drawn across other items: the straight line the app draws, from the edge of one end's box\n * to the edge of the other's, through a board, a note, a shape, a text, or an embed. Sections hold\n * what their arrows join, so an arrow crosses them on purpose. A row that wraps to the next is the\n * usual cause: its last item's arrow runs back across the row to the next one's first.\n */\nfunction crossingArrowWarnings(canvas: Canvas): ArtifactWarning[] {\n const boxes = new Map(\n canvas.items.flatMap((item) => {\n const box = canvasItemBox(item)\n return box ? [[item.id, box] as const] : []\n })\n )\n const crossable = canvas.items.filter((item) => item.type !== \"arrow\" && item.type !== \"section\")\n\n const crossing = canvas.items.flatMap((arrow) => {\n if (arrow.type !== \"arrow\") return []\n const from = canvasEndBox(arrow.from, boxes)\n const to = canvasEndBox(arrow.to, boxes)\n if (!from || !to) return []\n\n const { start, end } = canvasArrowLine(from, to)\n const crossed = crossable.filter((item) => {\n const box = boxes.get(item.id)\n return item.id !== arrow.from && item.id !== arrow.to && box && crosses(start, end, box)\n })\n return crossed.length === 0 ? [] : [{ arrow, crossed }]\n })\n\n const warnings: ArtifactWarning[] = crossing\n .slice(0, MAX_CROSSING_ARROWS)\n .map(({ arrow, crossed }) => {\n const named = crossed.slice(0, MAX_CROSSED_ITEMS).map((item) => `${item.type} '${item.id}'`)\n const more = crossed.length - named.length\n return {\n code: \"canvas_arrow_crosses\",\n part: arrow.id,\n 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.`,\n }\n })\n const more = crossing.length - warnings.length\n if (more > 0) {\n warnings.push({\n code: \"canvas_arrow_crosses\",\n message: `${more} more arrow${more === 1 ? \" is\" : \"s are\"} drawn across other items.`,\n })\n }\n return warnings\n}\n\n/** Whether the segment from `start` to `end` passes through the inside of a box. */\nfunction crosses(start: CanvasPoint, end: CanvasPoint, box: CanvasBox): boolean {\n // Liang-Barsky: clip the segment to the box, and see whether anything of it is left inside.\n const dx = end.x - start.x\n const dy = end.y - start.y\n let enter = 0\n let leave = 1\n const edges: readonly (readonly [number, number])[] = [\n [-dx, start.x - box.x],\n [dx, box.x + box.width - start.x],\n [-dy, start.y - box.y],\n [dy, box.y + box.height - start.y],\n ]\n for (const [direction, room] of edges) {\n if (direction === 0) {\n if (room <= 0) return false\n continue\n }\n const at = room / direction\n if (direction < 0) enter = Math.max(enter, at)\n else leave = Math.min(leave, at)\n if (enter >= leave) return false\n }\n return true\n}\n",
19
+ "import { posix } from \"node:path\"\nimport type { ArtifactFile } from \"../../../storage/artifacts/types\"\nimport { isArtifactAddress } from \"../../address\"\nimport { decodeHtmlEntities } from \"../../html\"\nimport { ARTIFACT_LIMITS } from \"../../limits\"\nimport { createHeadingSlugger, type DocumentHeading, type DocumentOutline } from \"../../outline\"\nimport { type ArtifactBlobStorage, invalidArtifact, readArtifactText } from \"../files\"\nimport type { FoundReference } from \"../references\"\n\n/** The file a document renders from. */\nexport const DOCUMENT_ENTRY = \"document.md\"\n\n/**\n * Reads a document's Markdown: its headings become the outline, and every image must be a file in\n * the version or an `artifact:` address, so the document renders the same wherever it is opened.\n * The addresses it shows and links to are returned with the section each sits in, to resolve.\n */\nexport async function validateDocument(\n blobStorage: ArtifactBlobStorage,\n files: readonly ArtifactFile[]\n): Promise<{\n readonly entry: string\n readonly outline: DocumentOutline\n readonly references: readonly FoundReference[]\n}> {\n const entry = files.find((file) => file.path === DOCUMENT_ENTRY)\n if (!entry) throw invalidArtifact(`A document needs its Markdown in '${DOCUMENT_ENTRY}'.`)\n const markdown = await readArtifactText(blobStorage, entry, ARTIFACT_LIMITS.maxDocumentBytes)\n\n // The same options the docs site renders with, so headings and images read the same way.\n const html = Bun.markdown.html(markdown, {\n tables: true,\n strikethrough: true,\n tasklists: true,\n autolinks: true,\n })\n const headings: { depth: number; text: string }[] = []\n const images: string[] = []\n // Each address with the index of the heading it follows, -1 before the first.\n const addresses: { address: string; as: \"embed\" | \"link\"; heading: number }[] = []\n let heading: { depth: number; text: string } | null = null\n new HTMLRewriter()\n .on(\"h1, h2, h3, h4, h5, h6\", {\n element(element) {\n heading = { depth: Number(element.tagName.slice(1)), text: \"\" }\n headings.push(heading)\n element.onEndTag(() => {\n heading = null\n })\n },\n text(chunk) {\n if (heading) heading.text += chunk.text\n },\n })\n .on(\"img\", {\n element(element) {\n const source = decodeHtmlEntities(element.getAttribute(\"src\") ?? \"\")\n if (isArtifactAddress(source)) {\n addresses.push({ address: source.trim(), as: \"embed\", heading: headings.length - 1 })\n } else {\n images.push(source)\n }\n },\n })\n .on(\"a\", {\n element(element) {\n const href = decodeHtmlEntities(element.getAttribute(\"href\") ?? \"\")\n if (isArtifactAddress(href)) {\n addresses.push({ address: href.trim(), as: \"link\", heading: headings.length - 1 })\n }\n },\n })\n .transform(html)\n\n const paths = new Set(files.map((file) => file.path))\n for (const source of images) checkImage(source, paths)\n\n const slug = createHeadingSlugger()\n const outlined = headings.map(({ depth, text }): DocumentHeading => {\n const plain = decodeHtmlEntities(text).replace(/\\s+/g, \" \").trim()\n return { depth, text: plain, slug: slug(plain) }\n })\n return {\n entry: DOCUMENT_ENTRY,\n outline: { kind: \"document\", headings: outlined },\n references: addresses.map(({ address, as, heading: index }) => ({\n address,\n as,\n at: outlined[index]?.slug ?? \"\",\n })),\n }\n}\n\nfunction checkImage(source: string, paths: ReadonlySet<string>): void {\n if (source === \"\" || source.startsWith(\"//\") || /^[a-z][a-z\\d+.-]*:/i.test(source)) {\n throw invalidArtifact(\n `${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.`\n )\n }\n const path = posix.normalize(safeDecodeUri(source.split(/[?#]/)[0] ?? \"\"))\n if (!paths.has(path)) {\n throw invalidArtifact(\n `${DOCUMENT_ENTRY} shows the image '${source}', which is not one of the artifact's files.`\n )\n }\n}\n\nfunction safeDecodeUri(value: string): string {\n try {\n return decodeURI(value)\n } catch {\n return value\n }\n}\n",
20
+ "import { inferFileMediaType } from \"../../../blob-storage/media-type\"\nimport type { ArtifactFile } from \"../../../storage/artifacts/types\"\nimport type { FileOutline } from \"../../outline\"\nimport { invalidArtifact } from \"../files\"\n\n/** A file artifact is one file of any type, delivered as it is. */\nexport function validateFileArtifact(files: readonly ArtifactFile[]): {\n readonly entry: string\n readonly outline: FileOutline\n} {\n const [file] = files\n if (!file || files.length > 1) {\n throw invalidArtifact(`A file artifact holds exactly one file; this one has ${files.length}.`)\n }\n return {\n entry: file.path,\n outline: { kind: \"file\", mediaType: file.file.mediaType ?? inferFileMediaType(file.path) },\n }\n}\n",
21
+ "import type { ArtifactFile } from \"../../../storage/artifacts/types\"\nimport { decodeHtmlEntities } from \"../../html\"\nimport { ARTIFACT_LIMITS } from \"../../limits\"\nimport type { PageOutline } from \"../../outline\"\nimport { type ArtifactBlobStorage, invalidArtifact, readArtifactText } from \"../files\"\nimport type { FoundReference } from \"../references\"\nimport { HTML_ENTRY, readHtmlReferences, refuseFrameAssetPaths } from \"./html\"\n\n/**\n * Reads a page: `index.html` and the files it loads beside it, its scripts, styles, images, and\n * data. Its `<title>`, else its first `<h1>`, becomes its title in the outline. The `artifact:`\n * addresses it uses are returned to resolve, as a deck's are.\n */\nexport async function validatePage(\n blobStorage: ArtifactBlobStorage,\n files: readonly ArtifactFile[]\n): Promise<{\n readonly entry: string\n readonly outline: PageOutline\n readonly references: readonly FoundReference[]\n}> {\n const entry = files.find((file) => file.path === HTML_ENTRY)\n if (!entry) {\n throw invalidArtifact(\n `A page needs '${HTML_ENTRY}', the page itself; put its scripts, styles, and data beside it.`\n )\n }\n refuseFrameAssetPaths(files, \"the page\")\n const html = await readArtifactText(blobStorage, entry, ARTIFACT_LIMITS.maxPageBytes)\n\n let title = \"\"\n let heading = \"\"\n let readingHeading = false\n const rewriter = new HTMLRewriter()\n .on(\"title\", {\n text(chunk) {\n title += chunk.text\n },\n })\n .on(\"h1\", {\n element(element) {\n if (heading || readingHeading) return\n readingHeading = true\n element.onEndTag(() => {\n readingHeading = false\n heading ||= \" \"\n })\n },\n text(chunk) {\n if (readingHeading) heading += chunk.text\n },\n })\n const { references, refusal } = readHtmlReferences(rewriter, () => \"\")\n rewriter.transform(html)\n\n const refused = refusal()\n if (refused) throw invalidArtifact(refused)\n const plain = (text: string) => decodeHtmlEntities(text).replace(/\\s+/g, \" \").trim()\n const named = plain(title) || plain(heading)\n return {\n entry: HTML_ENTRY,\n outline: { kind: \"page\", ...(named ? { title: named.slice(0, 200) } : {}) },\n references,\n }\n}\n",
22
+ "import { posix } from \"node:path\"\nimport type { ArtifactFile } from \"../../../storage/artifacts/types\"\nimport { isArtifactAddress } from \"../../address\"\nimport { CsvParseError, type CsvTable, parseCsv } from \"../../csv\"\nimport { evaluateComputedColumns } from \"../../formula\"\nimport { ARTIFACT_LIMITS } from \"../../limits\"\nimport { liveSheetColumns } from \"../../live-sheet\"\nimport type { SheetOutline } from \"../../outline\"\nimport { artifactQueryPath, type CheckedArtifactQuery } from \"../../queries\"\nimport { sheetChartsProblem, sheetColumnsProblem, sheetFormulasProblem } from \"../../sheet-rules\"\nimport type { ArtifactWarning } from \"../../warnings\"\nimport {\n parseSheetDate,\n parseSheetNumber,\n parseWorkbook,\n type SheetColumnFormat,\n sheetFilePath,\n WORKBOOK_FILE,\n type Workbook,\n type WorkbookSheet,\n} from \"../../workbook\"\nimport { type ArtifactBlobStorage, invalidArtifact, readArtifactText } from \"../files\"\nimport type { FoundReference } from \"../references\"\n\n/**\n * Reads a sheet: `workbook.json`, then each sheet's CSV against it. Every cell of a typed column\n * must read as its type, every formula must compute its column, and every chart must name columns\n * its sheet has, so the grid formats and the charts draw the same wherever the sheet is opened.\n * Rows a formula computes to an error are warnings: the version publishes, and the grid shows them.\n *\n * A live sheet is checked against `queries`, what checking the version's queries as its author\n * learned: its query returns rows, and its columns show properties those rows hold, so its rules\n * hold as a CSV sheet's do. Its rows are each reader's, so no cell is checked.\n */\nexport async function validateSheet(\n blobStorage: ArtifactBlobStorage,\n files: readonly ArtifactFile[],\n queries: ReadonlyMap<string, CheckedArtifactQuery>\n): Promise<{\n readonly entry: string\n readonly outline: SheetOutline\n readonly references: readonly FoundReference[]\n readonly warnings: readonly ArtifactWarning[]\n}> {\n const byPath = new Map(files.map((file) => [file.path, file]))\n const workbookFile = byPath.get(WORKBOOK_FILE)\n if (!workbookFile) {\n throw invalidArtifact(\n `A sheet is a directory: '${WORKBOOK_FILE}' listing its sheets, and one CSV per sheet under sheets/. A single CSV publishes as a file.`\n )\n }\n const parsed = parseWorkbook(\n await readArtifactText(blobStorage, workbookFile, ARTIFACT_LIMITS.maxWorkbookBytes)\n )\n if (\"error\" in parsed) throw invalidArtifact(parsed.error)\n const { workbook } = parsed\n\n const declared = new Set(workbook.sheets.map((sheet) => sheetFilePath(sheet.name)))\n const stray = files.find((file) => file.path.startsWith(\"sheets/\") && !declared.has(file.path))\n if (stray) {\n throw invalidArtifact(\n `'${stray.path}' is not a sheet in ${WORKBOOK_FILE}: list it in \"sheets\", or move it out of sheets/.`\n )\n }\n\n const tables = new Map<string, CsvTable>()\n const references: FoundReference[] = []\n const warnings: ArtifactWarning[] = []\n const sheets: WorkbookSheet[] = []\n for (const sheet of workbook.sheets) {\n if (sheet.live) {\n const live = liveSheet(byPath, sheet, queries.get(sheet.live.query))\n sheets.push(live.sheet)\n tables.set(sheet.name, live.table)\n continue\n }\n\n const table = await readSheet(blobStorage, byPath, sheet, references)\n sheets.push(sheet)\n tables.set(sheet.name, table)\n warnings.push(...computeSheet(sheet, table))\n }\n\n // A live sheet's charts plot the columns it lays out, typed as its query's rows are.\n const laidOut: Workbook = { ...workbook, sheets }\n const charts = sheetChartsProblem(laidOut, tables)\n if (charts) throw invalidArtifact(charts)\n\n return {\n entry: WORKBOOK_FILE,\n outline: {\n kind: \"sheet\",\n sheets: workbook.sheets.map((sheet) => {\n const table = tables.get(sheet.name)\n return {\n name: sheet.name,\n rows: table?.rows.length ?? 0,\n columns: [...(table?.header ?? [])],\n ...(sheet.live ? { query: sheet.live.query } : {}),\n }\n }),\n charts: workbook.charts.map((chart) => chart.name),\n },\n references,\n warnings,\n }\n}\n\n/**\n * A live sheet laid out against its query as the author reads it, and its header as the table a\n * CSV would hold, with no rows: the rules a CSV sheet keeps are checked on it.\n */\nfunction liveSheet(\n byPath: ReadonlyMap<string, ArtifactFile>,\n sheet: WorkbookSheet,\n checked: CheckedArtifactQuery | undefined\n): { readonly sheet: WorkbookSheet; readonly table: CsvTable } {\n const query = sheet.live?.query\n const csv = sheetFilePath(sheet.name)\n if (byPath.has(csv)) {\n throw invalidArtifact(\n `Sheet '${sheet.name}' reads its rows from query '${query}', so it has no '${csv}': remove the CSV, or \"query\" to show it.`\n )\n }\n\n if (!checked || query === undefined) {\n throw invalidArtifact(\n `Sheet '${sheet.name}' reads query '${query}', which the version does not have: add '${artifactQueryPath(query ?? \"\")}'.`\n )\n }\n if (checked.kind === \"facets\") {\n throw invalidArtifact(\n `Sheet '${sheet.name}' reads query '${query}', which counts facets: a sheet shows rows. A page shows facets; give the sheet a query of rows.`\n )\n }\n\n const layout = liveSheetColumns(sheet, checked.schema)\n if (layout.problem) throw invalidArtifact(layout.problem)\n\n const table = { header: layout.columns.map((column) => column.name), rows: [] }\n const problem =\n sheetColumnsProblem(layout.sheet, table) ?? sheetFormulasProblem(layout.sheet, table)\n if (problem) throw invalidArtifact(problem)\n\n return { sheet: layout.sheet, table }\n}\n\nasync function readSheet(\n blobStorage: ArtifactBlobStorage,\n byPath: ReadonlyMap<string, ArtifactFile>,\n sheet: WorkbookSheet,\n references: FoundReference[]\n): Promise<CsvTable> {\n const path = sheetFilePath(sheet.name)\n const file = byPath.get(path)\n if (!file) throw invalidArtifact(`Sheet '${sheet.name}' needs its values in '${path}'.`)\n\n if (file.file.sizeBytes > ARTIFACT_LIMITS.maxSheetFileBytes) {\n throw invalidArtifact(\n `'${path}' is ${megabytes(file.file.sizeBytes)} MB; a sheet's values may be at most ${megabytes(ARTIFACT_LIMITS.maxSheetFileBytes)} MB, which is what the viewer reads. Split it into several sheets, or publish the CSV as a file.`\n )\n }\n let table: CsvTable\n try {\n table = parseCsv(await readArtifactText(blobStorage, file, ARTIFACT_LIMITS.maxSheetFileBytes))\n } catch (error) {\n if (error instanceof CsvParseError) throw invalidArtifact(`'${path}': ${error.message}`)\n throw error\n }\n\n const columns = sheetColumnsProblem(sheet, table)\n if (columns) throw invalidArtifact(columns)\n\n const { header } = table\n for (const [column, format] of Object.entries(sheet.columns)) {\n const index = header.indexOf(column)\n if (format.type === \"link\" || format.type === \"image\") {\n // A link or image may be another artifact's address, resolved with the rest.\n for (const [rowIndex, row] of table.rows.entries()) {\n const value = row[index]?.trim() ?? \"\"\n if (!isArtifactAddress(value)) continue\n references.push({\n address: value,\n as: format.type === \"image\" ? \"embed\" : \"link\",\n at: `${sheet.name}!${columnLetter(index)}${rowIndex + 2}`,\n })\n }\n }\n if (format.formula) {\n checkComputedValues(path, table, index, column)\n continue\n }\n checkColumn(path, table, index, column, format, byPath)\n }\n return table\n}\n\n/** A computed column's values come from its formula: the CSV leaves them empty. */\nfunction checkComputedValues(path: string, table: CsvTable, index: number, column: string): void {\n for (const [rowIndex, row] of table.rows.entries()) {\n const value = row[index] ?? \"\"\n if (value.trim()) {\n throw invalidArtifact(\n `'${path}' row ${rowIndex + 2}, column '${column}': ${JSON.stringify(value)} is in a computed column; leave its values empty, and its formula fills them.`\n )\n }\n }\n}\n\n/**\n * Checks each computed column's formula against the sheet's columns and computes them all, so a\n * formula that can't compute refuses the version and one that computes to an error in some rows\n * warns.\n */\nfunction computeSheet(sheet: WorkbookSheet, table: CsvTable): ArtifactWarning[] {\n const formulas = sheetFormulasProblem(sheet, table)\n if (formulas) throw invalidArtifact(formulas)\n\n const computed = evaluateComputedColumns(sheet, table)\n return [...computed.errors].map(([column, errors]) => ({\n code: \"sheet_formula_error\",\n part: sheet.name,\n message: `Sheet '${sheet.name}' column '${column}' computes to ${errors.code} in ${errors.count === 1 ? \"1 row\" : `${errors.count} rows`}, the first row ${errors.firstRow + 2}. IFERROR gives those rows a value.`,\n }))\n}\n\nfunction checkColumn(\n path: string,\n table: CsvTable,\n index: number,\n column: string,\n format: SheetColumnFormat,\n byPath: ReadonlyMap<string, ArtifactFile>\n): void {\n for (const [rowIndex, row] of table.rows.entries()) {\n const value = row[index] ?? \"\"\n if (!value.trim() || isArtifactAddress(value)) continue\n const problem = cellProblem(value, format, byPath)\n if (problem) {\n throw invalidArtifact(\n `'${path}' row ${rowIndex + 2}, column '${column}': ${JSON.stringify(value)} ${problem}`\n )\n }\n }\n}\n\nfunction cellProblem(\n value: string,\n format: SheetColumnFormat,\n byPath: ReadonlyMap<string, ArtifactFile>\n): string | undefined {\n switch (format.type) {\n case \"number\":\n case \"currency\":\n return parseSheetNumber(value) === undefined\n ? \"is not a number: write plain digits, such as 4120000 or -3.5, with no symbols or separators.\"\n : undefined\n case \"percent\":\n return parseSheetNumber(value) === undefined\n ? \"is not a number: write a percent as a fraction, such as 0.351 for 35.1%.\"\n : undefined\n case \"date\":\n return parseSheetDate(value) === undefined\n ? \"is not a date: write YYYY-MM-DD, or an ISO 8601 date and time.\"\n : undefined\n case \"link\":\n return /^https?:\\/\\/[^\\s]+$/i.test(value.trim())\n ? undefined\n : \"is not a link: write a full https:// address, or another artifact's address.\"\n case \"image\": {\n const imagePath = posix.normalize(value.trim())\n return byPath.has(imagePath)\n ? undefined\n : \"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.\"\n }\n case \"boolean\":\n return /^(true|false)$/i.test(value.trim())\n ? undefined\n : \"is not true or false: write true or false, or leave the cell empty.\"\n case \"text\":\n case \"tag\":\n return undefined\n }\n}\n\n/** A column's letter as a spreadsheet shows it: A, Z, AA. */\nfunction columnLetter(index: number): string {\n let letters = \"\"\n for (let rest = index + 1; rest > 0; rest = Math.floor((rest - 1) / 26)) {\n letters = String.fromCharCode(65 + ((rest - 1) % 26)) + letters\n }\n return letters\n}\n\nfunction megabytes(bytes: number): string {\n return (bytes / (1024 * 1024)).toFixed(1).replace(/\\.0$/, \"\")\n}\n",
23
+ "import type { ArtifactFile } from \"../../../storage/artifacts/types\"\nimport { decodeHtmlEntities } from \"../../html\"\nimport { ARTIFACT_LIMITS } from \"../../limits\"\nimport type { SlidesOutline } from \"../../outline\"\nimport { type ArtifactBlobStorage, invalidArtifact, readArtifactText } from \"../files\"\nimport type { FoundReference } from \"../references\"\nimport { HTML_ENTRY, readHtmlReferences, refuseFrameAssetPaths } from \"./html\"\n\n/**\n * Reads a deck: `index.html` with one `<section class=\"slide\">` per 1280×720 slide, and the files\n * it loads beside it. Each slide's first heading becomes its title in the outline. The `artifact:`\n * addresses it uses are returned with the slide each is on, to resolve.\n */\nexport async function validateSlides(\n blobStorage: ArtifactBlobStorage,\n files: readonly ArtifactFile[]\n): Promise<{\n readonly entry: string\n readonly outline: SlidesOutline\n readonly references: readonly FoundReference[]\n}> {\n const entry = files.find((file) => file.path === HTML_ENTRY)\n if (!entry) {\n throw invalidArtifact(\n `A deck needs '${HTML_ENTRY}' with one <section class=\"slide\"> per slide.`\n )\n }\n refuseFrameAssetPaths(files, \"the deck\")\n const html = await readArtifactText(blobStorage, entry, ARTIFACT_LIMITS.maxDeckBytes)\n\n const slides: { title: string; heading: boolean }[] = []\n const at = () => String(Math.max(1, slides.length))\n // The heading being read, if it is the first of the current slide.\n let reading: { title: string; heading: boolean } | null = null\n const rewriter = new HTMLRewriter()\n .on(\"section\", {\n element(element) {\n const classes = (element.getAttribute(\"class\") ?? \"\").split(/\\s+/)\n if (classes.includes(\"slide\")) slides.push({ title: \"\", heading: false })\n },\n })\n .on(\"h1, h2, h3\", {\n element(element) {\n const slide = slides.at(-1)\n if (!slide || slide.heading) return\n slide.heading = true\n reading = slide\n element.onEndTag(() => {\n reading = null\n })\n },\n text(chunk) {\n if (reading) reading.title += chunk.text\n },\n })\n const { references, refusal } = readHtmlReferences(rewriter, at)\n rewriter.transform(html)\n\n const refused = refusal()\n if (refused) throw invalidArtifact(refused)\n if (slides.length === 0) {\n throw invalidArtifact(\n `${HTML_ENTRY} has no slides: put each slide in a <section class=\"slide\">.`\n )\n }\n if (slides.length > ARTIFACT_LIMITS.maxSlides) {\n throw invalidArtifact(\n `A deck holds at most ${ARTIFACT_LIMITS.maxSlides} slides; this one has ${slides.length}.`\n )\n }\n return {\n entry: HTML_ENTRY,\n outline: {\n kind: \"slides\",\n slides: slides.map(({ title }) => {\n const plain = decodeHtmlEntities(title).replace(/\\s+/g, \" \").trim()\n return plain ? { title: plain } : {}\n }),\n },\n references,\n }\n}\n",
24
+ "import type { Principal } from \"../../auth\"\nimport type { FileRef } from \"../../blob-storage\"\nimport { ArtifactStorageError } from \"../../storage/artifacts/errors\"\nimport type {\n ArtifactFile,\n ArtifactOrigin,\n ArtifactRecord,\n ArtifactStorage,\n ArtifactVersionInput,\n ArtifactVersionRecord,\n PublishedArtifactVersion,\n} from \"../../storage/artifacts/types\"\nimport { type ArtifactAccess, assertUpdatable } from \"../access\"\nimport { ArtifactRequestError } from \"../errors\"\nimport { createArtifactId } from \"../ids\"\nimport type { ArtifactKind } from \"../kinds\"\nimport { ARTIFACT_LIMITS } from \"../limits\"\nimport type { ArtifactOutline } from \"../outline\"\nimport type { CheckedArtifactQuery } from \"../queries\"\nimport {\n ARTIFACT_THEME_FILE,\n type ArtifactTheme,\n artifactThemeModes,\n parseArtifactTheme,\n} from \"../theme\"\nimport type { ArtifactWarning } from \"../warnings\"\nimport {\n type ArtifactBlobStorage,\n checkArtifactFiles,\n invalidArtifact,\n readArtifactText,\n} from \"./files\"\nimport { canvasPreviewOutline, withBoardRenderKeys } from \"./previews\"\nimport { type ArtifactQueryChecker, checkArtifactQueries } from \"./queries\"\nimport {\n brokenDependents,\n type FoundReference,\n ownArtifacts,\n resolveReferences,\n} from \"./references\"\nimport { validateCanvas } from \"./validate/canvas\"\nimport { validateDocument } from \"./validate/document\"\nimport { validateFileArtifact } from \"./validate/file\"\nimport { validatePage } from \"./validate/page\"\nimport { validateSheet } from \"./validate/sheet\"\nimport { validateSlides } from \"./validate/slides\"\n\nexport interface PublishArtifactContext {\n readonly projectId: string\n readonly storage: ArtifactStorage\n readonly blobStorage: ArtifactBlobStorage\n}\n\nexport interface PublishArtifactInput {\n /**\n * Writes this artifact's latest version: its open version, or the next one when it is frozen.\n * Without it, a new artifact is created.\n */\n readonly artifactId?: string\n readonly kind: ArtifactKind\n readonly title: string\n readonly files: readonly ArtifactFile[]\n /** Publishes the version, and owns the artifact when this creates it unless `owner` says. */\n readonly author: Principal\n /** Owns the artifact when this creates it: a conversation's owner, for an Agent turn in it. */\n readonly owner?: Principal\n /**\n * Whether an address in the version may name this artifact: one the author can read. Defaults to\n * the author's own artifacts.\n */\n readonly readable?: (artifact: ArtifactRecord) => Promise<boolean>\n /**\n * Checks each of the version's queries as the author, so none reads what they cannot. Without\n * it, a version that holds a query is refused.\n */\n readonly checkQuery?: ArtifactQueryChecker\n readonly origin?: ArtifactOrigin\n /** The revision this content was made from: publishing fails with `artifact_moved` past it. */\n readonly baseRevision?: number\n /**\n * The Agent turn that publishes: its first write to an artifact keeps a restore point, and a\n * retry of the turn undoes what it wrote.\n */\n readonly turnRunId?: string\n /** The content as the artifact's Yjs document, stored with it, for a kind edited live. */\n readonly document?: FileRef\n}\n\n/**\n * What the author may do with the artifact a version is published to, as the access rule's\n * `publishAccess` answers it from where the version is stored: a transaction's storage, for a\n * caller that stores in one. Storing refuses `none` with `not_shared` and `read` with `read_only`.\n */\nexport type PublishAccess = (artifact: ArtifactRecord) => Promise<ArtifactAccess>\n\nexport interface PublishedArtifact {\n readonly artifact: ArtifactRecord\n readonly version: ArtifactVersionRecord\n readonly warnings: readonly ArtifactWarning[]\n /** The write was merged with what others wrote since its base revision, as a canvas's is. */\n readonly merged?: true\n}\n\nconst CREATE_ATTEMPTS = 3\n\n/** A reader sees a board's picture until they open it, and the picture was taken as its author. */\nconst LIVE_BOARD_PREVIEWS: ArtifactWarning = {\n code: \"canvas_previews_show_author_data\",\n message:\n \"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.\",\n}\n\n/** A version checked against its kind and with its addresses resolved, ready to store. */\nexport interface PreparedArtifactVersion {\n readonly artifactId?: string\n readonly baseRevision?: number\n readonly turnRunId?: string\n readonly document?: FileRef\n readonly kind: ArtifactKind\n /** Owns the artifact when this version creates it. */\n readonly owner: Principal\n readonly readable: (artifact: ArtifactRecord) => Promise<boolean>\n readonly version: ArtifactVersionInput\n /** What its kind's check found worth fixing in a version it accepts. */\n readonly warnings: readonly ArtifactWarning[]\n}\n\n/**\n * Validates a version against its kind and stores it. Who may publish is the caller's decision:\n * this checks only what the version holds.\n */\nexport async function publishArtifact(\n context: PublishArtifactContext,\n input: PublishArtifactInput,\n access: PublishAccess\n): Promise<PublishedArtifact> {\n const prepared = await prepareArtifactVersion(context, input)\n const stored = await storeArtifactVersion(context, prepared, access)\n return { ...stored, warnings: await artifactVersionWarnings(context, prepared, stored) }\n}\n\n/**\n * Everything publishing checks before it stores: the title, the files, the theme, every query, run\n * once as the author, the kind's own format, and every address, resolved against what the author\n * can read. It reads the files back and parses them, so a caller that stores inside a\n * transaction prepares outside it.\n */\nexport async function prepareArtifactVersion(\n context: PublishArtifactContext,\n input: PublishArtifactInput\n): Promise<PreparedArtifactVersion> {\n const title = checkTitle(input.title)\n await checkArtifactFiles(context.blobStorage, input.files)\n const theme =\n input.kind === \"file\" ? undefined : await readTheme(context.blobStorage, input.files)\n\n // The queries first: a live sheet's columns are checked against what its query returns.\n const queries = await checkArtifactQueries(\n context.blobStorage,\n input.kind,\n input.files,\n input.checkQuery\n )\n const validated = await validateKind(context.blobStorage, input.kind, input.files, queries)\n\n const readable = input.readable ?? ownArtifacts(input.author)\n const references = await resolveReferences(\n referenceContext(context, { readable, artifactId: input.artifactId }),\n validated.references ?? []\n )\n\n return {\n ...(input.artifactId ? { artifactId: input.artifactId } : {}),\n ...(input.baseRevision === undefined ? {} : { baseRevision: input.baseRevision }),\n ...(input.turnRunId === undefined ? {} : { turnRunId: input.turnRunId }),\n ...(input.document ? { document: input.document } : {}),\n kind: input.kind,\n owner: input.owner ?? input.author,\n readable,\n warnings: [\n ...(validated.warnings ?? []),\n ...(input.kind === \"canvas\" && queries.size > 0 ? [LIVE_BOARD_PREVIEWS] : []),\n ],\n version: {\n title,\n entry: validated.entry,\n files: input.files.map(({ path, file }) => ({ path, file: { ...file } })),\n // A canvas's boards are shown as pictures until they are read, in the modes a reader sees;\n // each is named by what it shows once the version has its artifact.\n outline:\n validated.outline.kind === \"canvas\"\n ? canvasPreviewOutline(validated.outline, artifactThemeModes(theme))\n : validated.outline,\n references,\n author: input.author,\n ...(input.origin ? { origin: input.origin } : {}),\n updatedAt: new Date(),\n },\n }\n}\n\n/**\n * Stores a prepared version: as its artifact's latest version, or the first of a new artifact. A\n * write to an artifact is refused unless `access` says its author may update it: a caller that\n * stores inside a transaction answers it from there, so the check and the write see the same\n * artifact.\n */\nexport async function storeArtifactVersion(\n context: PublishArtifactContext,\n prepared: PreparedArtifactVersion,\n access: PublishAccess\n): Promise<PublishedArtifactVersion> {\n const { artifactId } = prepared\n if (!artifactId) return createArtifact(context, prepared)\n\n const artifact = await context.storage.get({ projectId: context.projectId, id: artifactId })\n if (!artifact) throw notFound(artifactId)\n assertUpdatable(artifactId, await access(artifact))\n\n return publishVersion(context, artifactId, prepared)\n}\n\n/**\n * What is worth fixing in a stored version: what its kind's check found, then what it breaks in\n * other artifacts that show it. A new artifact breaks nothing: no other artifact could name it\n * yet. The version is stored by now, so a failed check only loses those warnings.\n */\nexport async function artifactVersionWarnings(\n context: PublishArtifactContext,\n prepared: PreparedArtifactVersion,\n stored: PublishedArtifactVersion\n): Promise<readonly ArtifactWarning[]> {\n if (!prepared.artifactId) return prepared.warnings\n try {\n return [\n ...prepared.warnings,\n ...(await brokenDependents(\n referenceContext(context, prepared),\n stored.artifact,\n stored.version\n )),\n ]\n } catch (error) {\n console.warn(\n `[Sixb] Could not check which artifacts version ${stored.version.version} of '${stored.artifact.id}' breaks:`,\n error\n )\n return prepared.warnings\n }\n}\n\nfunction referenceContext(\n context: PublishArtifactContext,\n input: {\n readonly readable: (artifact: ArtifactRecord) => Promise<boolean>\n readonly artifactId?: string\n }\n) {\n return {\n projectId: context.projectId,\n storage: context.storage,\n readable: input.readable,\n ...(input.artifactId ? { artifactId: input.artifactId } : {}),\n }\n}\n\nasync function validateKind(\n blobStorage: ArtifactBlobStorage,\n kind: ArtifactKind,\n files: readonly ArtifactFile[],\n queries: ReadonlyMap<string, CheckedArtifactQuery>\n): Promise<{\n readonly entry: string\n readonly outline: ArtifactOutline\n readonly references?: readonly FoundReference[]\n readonly warnings?: readonly ArtifactWarning[]\n}> {\n switch (kind) {\n case \"document\":\n return validateDocument(blobStorage, files)\n case \"file\":\n return validateFileArtifact(files)\n case \"sheet\":\n return validateSheet(blobStorage, files, queries)\n case \"slides\":\n return validateSlides(blobStorage, files)\n case \"page\":\n return validatePage(blobStorage, files)\n case \"canvas\":\n return validateCanvas(blobStorage, files)\n default:\n // A caller past the API's schema, such as a script on the SDK, can name any kind.\n throw invalidArtifact(`'${kind satisfies never}' is not a kind of artifact.`)\n }\n}\n\n/** The version's `theme.json`, refused when it is not one; none without the file. */\nasync function readTheme(\n blobStorage: ArtifactBlobStorage,\n files: readonly ArtifactFile[]\n): Promise<ArtifactTheme | undefined> {\n const themeFile = files.find((file) => file.path === ARTIFACT_THEME_FILE)\n if (!themeFile) return undefined\n const parsed = parseArtifactTheme(\n await readArtifactText(blobStorage, themeFile, ARTIFACT_LIMITS.maxThemeBytes)\n )\n if (\"error\" in parsed) throw invalidArtifact(parsed.error)\n return parsed.theme\n}\n\nfunction checkTitle(value: string): string {\n const title = typeof value === \"string\" ? value.trim() : \"\"\n if (title.length === 0 || /[\\u0000-\\u001f\\u007f]/.test(title)) {\n throw invalidArtifact(\"An artifact needs a title of plain text.\")\n }\n if (title.length > ARTIFACT_LIMITS.maxTitleLength) {\n throw invalidArtifact(`A title may be at most ${ARTIFACT_LIMITS.maxTitleLength} characters.`)\n }\n return title\n}\n\nasync function publishVersion(\n context: PublishArtifactContext,\n artifactId: string,\n prepared: PreparedArtifactVersion\n): Promise<PublishedArtifactVersion> {\n try {\n return await context.storage.publish({\n projectId: context.projectId,\n artifactId,\n kind: prepared.kind,\n version: withBoardRenderKeys(prepared.version, artifactId),\n ...(prepared.baseRevision === undefined ? {} : { baseRevision: prepared.baseRevision }),\n ...(prepared.turnRunId === undefined ? {} : { turnRunId: prepared.turnRunId }),\n ...(prepared.document ? { document: prepared.document } : {}),\n })\n } catch (error) {\n throw artifactRequestError(error)\n }\n}\n\n/**\n * A storage refusal as the caller is told it: a missing artifact or restore point, a kind it does\n * not have, or a revision it moved past. Anything else is thrown as it is.\n */\nexport function artifactRequestError(error: unknown): unknown {\n if (!(error instanceof ArtifactStorageError)) return error\n\n switch (error.code) {\n case \"artifact_not_found\":\n case \"artifact_kind_mismatch\":\n case \"restore_point_not_found\":\n return new ArtifactRequestError(error.code, error.message)\n case \"artifact_moved\":\n return new ArtifactRequestError(\"artifact_moved\", error.message, error.latest)\n default:\n return error\n }\n}\n\nfunction notFound(artifactId: string): ArtifactRequestError {\n return new ArtifactRequestError(\n \"artifact_not_found\",\n `[Sixb] Artifact '${artifactId}' was not found.`\n )\n}\n\nasync function createArtifact(\n context: PublishArtifactContext,\n prepared: PreparedArtifactVersion\n): Promise<PublishedArtifactVersion> {\n for (let attempt = 1; ; attempt += 1) {\n const id = createArtifactId()\n try {\n return await context.storage.create({\n projectId: context.projectId,\n id,\n kind: prepared.kind,\n owner: prepared.owner,\n version: withBoardRenderKeys(prepared.version, id),\n ...(prepared.turnRunId === undefined ? {} : { turnRunId: prepared.turnRunId }),\n ...(prepared.document ? { document: prepared.document } : {}),\n })\n } catch (error) {\n const collided = error instanceof ArtifactStorageError && error.code === \"artifact_exists\"\n if (!collided || attempt === CREATE_ATTEMPTS) throw error\n }\n }\n}\n",
25
+ "import { createAgentThreadAccessRule } from \"../agents/thread-access\"\nimport { type Principal, SYSTEM_PRINCIPAL } from \"../auth\"\nimport { isRuntimeAllowed } from \"../authorization\"\nimport type { BlobStorage } from \"../blob-storage/types\"\nimport { resolveRuntimeAuthorizationForProject } from \"../execution/authorization\"\nimport { type AuthorizedObjectReader, objectReadersIn } from \"../execution/authorized-object-reader\"\nimport type { SharedAccessDelegationRef } from \"../execution/types\"\nimport type { ObjectQuery } from \"../objects/query/ir\"\nimport type { PropertyToken } from \"../ontology/tokens\"\nimport type { SixbRuntimeContext } from \"../runtime/types\"\nimport { ArtifactStorageError } from \"../storage/artifacts/errors\"\nimport type {\n ArtifactCommentAuthor,\n ArtifactFile,\n ArtifactGuest,\n ArtifactRecord,\n ArtifactRestorePointRecord,\n ArtifactStorage,\n ArtifactVersionRecord,\n ListArtifactsResult,\n ListArtifactVersionsResult,\n PublishedArtifactVersion,\n} from \"../storage/artifacts/types\"\nimport type { Storage } from \"../storage/types\"\nimport {\n type ArtifactAccess,\n type ArtifactAccessRule,\n assertUpdatable,\n createArtifactAccessRule,\n type HolderAccess,\n} from \"./access\"\nimport { type ArtifactCommentsRuntime, createArtifactCommentsRuntime } from \"./comments\"\nimport { ArtifactRequestError } from \"./errors\"\nimport { announceArtifactUpdates } from \"./events\"\nimport { type ArtifactHolding, readableHoldings } from \"./holders\"\nimport type { ArtifactKind } from \"./kinds\"\nimport { ARTIFACT_HOLDERS_LIMIT, ARTIFACT_LIMITS, ARTIFACT_STATE_LIMITS } from \"./limits\"\nimport { firstArtifactDocument, keepsDocument } from \"./live/state\"\nimport { invalidArtifact, readArtifactText } from \"./publish/files\"\nimport { type ArtifactWrite, withDocumentHolding, withMergedWrite } from \"./publish/merge\"\nimport {\n type BoardPreviewRequester,\n boardsReadLiveData,\n requestBoardPreviews,\n} from \"./publish/previews\"\nimport {\n artifactRequestError,\n artifactVersionWarnings,\n type PreparedArtifactVersion,\n type PublishedArtifact,\n prepareArtifactVersion,\n publishArtifact,\n storeArtifactVersion,\n} from \"./publish/publish\"\nimport { type ArtifactQueryChecker, createArtifactQueryChecker } from \"./publish/queries\"\nimport {\n ARTIFACT_QUERY_KINDS,\n type ArtifactQueryResult,\n artifactQueryPath,\n isArtifactQueryName,\n parseArtifactQuery,\n} from \"./queries\"\nimport { runArtifactQuery } from \"./run-query\"\n\n/** A version's content: what its kind renders from, and what it is called. */\nexport interface ArtifactContentInput {\n readonly kind: ArtifactKind\n readonly title: string\n /** Files stored with `sixb.blobs.put()` or `POST /api/files`, at their paths in the artifact. */\n readonly files: readonly ArtifactFile[]\n /**\n * Queries the version holds, by name, each stored as `queries/<name>.json` beside `files` and\n * checked as those files are. Each reader runs them with their own rights.\n */\n readonly queries?: Readonly<Record<string, ArtifactQueryInput>>\n}\n\n/**\n * A query a version holds, from the query builders: `sixb.objects(Invoice).where(...)` for rows,\n * or such a query with the properties to facet its rows by. Any builder fits: its `ir` is what\n * the version keeps.\n */\nexport type ArtifactQueryInput =\n | { readonly ir: ObjectQuery }\n | {\n readonly query: { readonly ir: ObjectQuery }\n readonly facets: readonly { readonly property: PropertyToken; readonly limit: number }[]\n }\n\nexport interface UpdateArtifactRuntimeInput extends ArtifactContentInput {\n /**\n * The revision this content was made from, such as the one a person edited. When the artifact\n * changed since, the update fails with `artifact_moved`, naming its revision and who wrote it;\n * a canvas instead takes what changed from that revision's files into what it holds now.\n */\n readonly baseRevision?: number\n /**\n * The files of `baseRevision`, which a canvas's merge starts from. Without them, it looks for\n * them among the artifact's versions and restore points, and refuses with `artifact_moved` when\n * none holds them.\n */\n readonly baseFiles?: readonly ArtifactFile[]\n /**\n * The title of `baseRevision`. A canvas merged past it keeps a title someone gave it since,\n * unless this write changes the title itself.\n */\n readonly baseTitle?: string\n}\n\n/**\n * A live room's write-back, for this repo's server: the canvas's Yjs document as its editors hold\n * it, merged into the stored one. The version holds what the merged document holds.\n */\nexport interface LiveArtifactWrite {\n readonly title: string\n /** The title the room last read: a title given since stays. */\n readonly baseTitle: string\n /** The revision the room last took in. */\n readonly baseRevision: number\n /**\n * The document's files as the room stored them: what the merged version holds alike keeps\n * these references.\n */\n readonly files: readonly ArtifactFile[]\n /** The document, encoded with `Y.encodeStateAsUpdate`. */\n readonly update: Uint8Array\n}\n\n/** A change made from what the caller saw: past `baseRevision`, it fails with `artifact_moved`. */\nexport interface ArtifactRevisionInput {\n readonly baseRevision?: number\n}\n\nexport interface ListArtifactsRuntimeInput {\n /**\n * Only the artifacts a conversation shares: every one of them, whoever owns it, for whoever reads\n * the conversation; otherwise the caller's own among them.\n */\n readonly threadId?: string\n /** Only artifacts of this kind. */\n readonly kind?: ArtifactKind\n readonly limit?: number\n readonly offset?: number\n}\n\n/**\n * The artifacts the caller reaches: its own, those shared in a conversation it reads, and those\n * held by an object it reads, as {@link ArtifactAccess} says. System code reaches every artifact in\n * the project, and an access token no conversation's.\n */\nexport interface ArtifactsRuntime extends ArtifactCommentsRuntime {\n /** Creates an artifact owned by the caller, with its first version. */\n create(input: ArtifactContentInput): Promise<PublishedArtifact>\n /**\n * Writes the latest version, authored by the caller: its open version's content is replaced, or\n * the next version opens when it is frozen. The artifact keeps its owner, and the kind must be\n * its. Throws `not_shared` or `read_only` when the caller may not update it.\n */\n update(artifactId: string, input: UpdateArtifactRuntimeInput): Promise<PublishedArtifact>\n /**\n * Creates a version: the open latest version is frozen, so it never changes again and the next\n * write opens the next one. A latest version already frozen is returned as it is. Who may\n * update may freeze; throws as `update` does.\n */\n freeze(artifactId: string, input?: ArtifactRevisionInput): Promise<PublishedArtifactVersion>\n /**\n * What the artifact's latest version held before each Agent turn's first write to it, and\n * before each restore, newest first; `null` when the caller cannot read the artifact.\n */\n listRestorePoints(artifactId: string): Promise<ArtifactRestorePointRecord[] | null>\n /** `null` when the caller cannot read the artifact, or it keeps no such restore point. */\n getRestorePoint(artifactId: string, revision: number): Promise<ArtifactRestorePointRecord | null>\n /**\n * Puts a restore point's content back in the latest version, authored by the caller, as\n * `update` writes it. What it replaces becomes a restore point, so the restore can be undone.\n * Throws as `update` does, and `restore_point_not_found`.\n */\n restore(\n artifactId: string,\n revision: number,\n input?: ArtifactRevisionInput\n ): Promise<PublishedArtifactVersion>\n /** What the caller may do with the artifact; `null` when there is no such artifact. */\n access(artifactId: string): Promise<ArtifactAccess | null>\n /** `null` when the caller cannot read it. */\n get(artifactId: string): Promise<ArtifactRecord | null>\n /**\n * The caller's own artifacts, or a conversation's, most recently updated first. One the caller\n * reaches only through an object is opened from that object: see `holders`.\n */\n list(input?: ListArtifactsRuntimeInput): Promise<ListArtifactsResult>\n /**\n * The objects that hold the artifact in a property, among those the caller reads with that\n * property: the first {@link ARTIFACT_HOLDERS_LIMIT}, in a stable order. `null` when the caller\n * cannot read the artifact.\n */\n holders(artifactId: string): Promise<ArtifactHolders | null>\n getVersion(artifactId: string, version: number | \"latest\"): Promise<ArtifactVersionRecord | null>\n /**\n * Runs the version's query `queries/<name>.json` as the caller, with their rights: a type they\n * cannot view refuses it, and a marked property they are not cleared for is left out of each\n * row. Whoever reads the artifact runs its queries, an observer too. `null` when the caller\n * cannot read the artifact or it has no such version. Throws `query_not_found`, and\n * `query_invalid` for a query the ontology no longer admits.\n */\n query(\n artifactId: string,\n name: string,\n options?: { readonly version?: number | \"latest\" }\n ): Promise<ArtifactQueryResult | null>\n /** Newest first; `null` when the caller cannot read the artifact. */\n listVersions(\n artifactId: string,\n input?: { readonly limit?: number; readonly offset?: number }\n ): Promise<ListArtifactVersionsResult | null>\n /**\n * Deletes the artifact with every version, from every conversation that shares it; only its\n * owner can. `false` when the caller does not own it.\n */\n delete(artifactId: string): Promise<boolean>\n /**\n * What the artifact keeps for the caller as its reader, as a page keeps it with `sixb.state`:\n * JSON values by key, across its versions. Each reader who may update the artifact keeps their\n * own. Each call throws `artifact_not_found`, `not_shared`, or `read_only` for an observer.\n */\n state(artifactId: string): ArtifactStateRuntime\n}\n\n/** One reader's values, kept by one artifact. */\nexport interface ArtifactStateRuntime {\n /** The value under the key, or undefined when there is none. */\n get(key: string): Promise<unknown>\n /**\n * Keeps a JSON value under the key, replacing one there. Throws `invalid_state` for a key or a\n * value that is not one, and `state_full` past `ARTIFACT_STATE_LIMITS`. Returns what it kept.\n */\n set(key: string, value: unknown): Promise<ArtifactStateValue>\n /** `false` when there was no value under the key. */\n delete(key: string): Promise<boolean>\n /** Every value, by key in order. */\n entries(): Promise<ArtifactStateValue[]>\n /** Deletes every value, and returns how many. */\n clear(): Promise<number>\n}\n\n/** The objects that hold an artifact, as the caller reads them. */\nexport interface ArtifactHolders {\n readonly holders: readonly ArtifactHolderObject[]\n /** More objects the caller reads hold it. */\n readonly hasMore: boolean\n}\n\n/** An object property that holds the artifact. */\nexport interface ArtifactHolderObject {\n readonly objectTypeId: string\n readonly primaryId: string\n readonly propertyId: string\n /** The object's value of its type's `search.title`, when it has one the caller reads. */\n readonly title?: string\n}\n\nexport interface ArtifactStateValue {\n readonly key: string\n readonly value: unknown\n readonly updatedAt: Date\n}\n\n/** Where an access rule reads: the project's storage, or a transaction's to decide inside it. */\nexport type ArtifactAccessStorage = Pick<Storage, \"artifacts\" | \"agents\" | \"objects\">\n\n/**\n * What each runtime's caller publishes by, for this repo's packages: an Agent turn publishes with\n * the access rule and the query checker of whoever asked for it.\n */\nconst publishers = new WeakMap<\n object,\n {\n readonly rule: () => ArtifactAccessRule\n readonly transactionRules: () => Promise<TransactionAccessRules>\n readonly checkQuery: ArtifactQueryChecker\n readonly requestPreviews: BoardPreviewRequester\n readonly writeLive: (artifactId: string, write: LiveArtifactWrite) => Promise<PublishedArtifact>\n }\n>()\n\nfunction publisherOf(artifacts: Partial<ArtifactsRuntime>) {\n const publisher = publishers.get(artifacts)\n if (!publisher) throw new Error(\"[Sixb] These artifacts are not a Sixb runtime's.\")\n return publisher\n}\n\n/** The access rule of the caller `artifacts` acts for. Each call returns a rule of its own. */\nexport function artifactAccessRule(artifacts: Partial<ArtifactsRuntime>): ArtifactAccessRule {\n return publisherOf(artifacts).rule()\n}\n\n/** {@link transactionArtifactAccessRules} for the caller `artifacts` acts for. */\nexport function artifactTransactionRules(\n artifacts: Partial<ArtifactsRuntime>\n): Promise<TransactionAccessRules> {\n return publisherOf(artifacts).transactionRules()\n}\n\n/** What checks a version's queries as the caller `artifacts` acts for. */\nexport function artifactQueryChecker(artifacts: Partial<ArtifactsRuntime>): ArtifactQueryChecker {\n return publisherOf(artifacts).checkQuery\n}\n\n/**\n * What asks for the pictures a stored version's boards miss, in the project `artifacts` belongs\n * to: nothing in a project without sandboxes, where nothing renders them.\n */\nexport function artifactPreviewRequester(\n artifacts: Partial<ArtifactsRuntime>\n): BoardPreviewRequester {\n return publisherOf(artifacts).requestPreviews\n}\n\n/**\n * Writes a live room's document back into the canvas, as the caller `artifacts` acts for: the\n * write `update` makes, checked, authored and announced as it is, from the document instead of\n * from files.\n */\nexport function writeLiveArtifact(\n artifacts: Partial<ArtifactsRuntime>,\n artifactId: string,\n write: LiveArtifactWrite\n): Promise<PublishedArtifact> {\n return publisherOf(artifacts).writeLive(artifactId, write)\n}\n\n/** The access rule for the runtime's caller, reading the project's storage. */\nexport function createRuntimeArtifactAccessRule(runtime: SixbRuntimeContext): ArtifactAccessRule {\n return accessRuleIn(runtime, runtime.storage, runtime.objectReader)\n}\n\n/** The runtime caller's access rule for a transaction's storage, deciding inside it. */\nexport type TransactionAccessRules = (tx: ArtifactAccessStorage) => ArtifactAccessRule\n\n/**\n * The access rule for the runtime's caller in a storage transaction: its threads, its holders and\n * its objects are the transaction's, so a participant removed or an object changed meanwhile is\n * seen. What the caller is cleared for is resolved now, before the transaction opens: resolving it\n * may read the project's storage, which a transaction's callback cannot.\n */\nexport async function transactionArtifactAccessRules(\n runtime: SixbRuntimeContext\n): Promise<TransactionAccessRules> {\n const readerIn = await objectReadersIn(runtime.objectReader)\n return (tx) => accessRuleIn(runtime, tx, readerIn(tx.objects))\n}\n\n/** The rule reading `storage`, with `reader` reading its objects as the caller. */\nfunction accessRuleIn(\n runtime: SixbRuntimeContext,\n storage: ArtifactAccessStorage,\n reader: AuthorizedObjectReader\n): ArtifactAccessRule {\n const artifacts = storage.artifacts\n if (!artifacts) {\n throw new ArtifactRequestError(\n \"storage_unavailable\",\n \"[Sixb] Artifacts need storage that supports them.\"\n )\n }\n\n const authority = resolveRuntimeAuthorizationForProject(runtime)\n const threads = createAgentThreadAccessRule(runtime, authority, storage.agents)\n\n return createArtifactAccessRule({\n storage: artifacts,\n projectId: runtime.projectId,\n // A shared link's session reaches artifacts as a guest; unresolved authority reaches none.\n caller:\n authority.type === \"unrestricted\"\n ? \"system\"\n : authority.type === \"principal\"\n ? authority.context.principal\n : authority.type === \"delegated\"\n ? \"guest\"\n : null,\n sharing: authority.type === \"principal\" && authority.ref.credential?.type === \"session\",\n conversation: async (threadId) => {\n if (await threads.read(threadId)) return \"update\"\n return isRuntimeAllowed(runtime, { kind: \"agentThreads.observe\" }) ? \"read\" : null\n },\n holders: async (artifact) => {\n let access: HolderAccess = null\n const holdings = readableHoldings({\n runtime,\n reader,\n objects: storage.objects,\n artifactId: artifact.id,\n })\n\n for await (const holding of holdings) {\n if (holding.access === \"update\") return \"update\"\n access = \"read\"\n }\n return access\n },\n })\n}\n\n/**\n * The artifacts among `artifactIds` that the runtime's caller may change, as its owner or with\n * `update`, as its access rule decides now. One that does not exist is not among them, and\n * without artifact storage none is.\n */\nexport async function updatableArtifactIds(\n runtime: SixbRuntimeContext,\n artifactIds: Iterable<string>\n): Promise<ReadonlySet<string>> {\n const ids = [...new Set(artifactIds)]\n const storage = runtime.storage.artifacts\n if (ids.length === 0 || !storage) return new Set()\n\n const rule = createRuntimeArtifactAccessRule(runtime)\n const updatable = await Promise.all(\n ids.map(async (id) => {\n const artifact = await storage.get({ projectId: runtime.projectId, id })\n if (!artifact) return []\n\n const access = await rule.accessTo(artifact)\n return access === \"owner\" || access === \"update\" ? [id] : []\n })\n )\n\n return new Set(updatable.flat())\n}\n\nexport function createArtifactsRuntime(\n runtime: SixbRuntimeContext,\n blobStorage: BlobStorage,\n options: {\n /** The project has sandboxes, where the agent worker renders the pictures of boards. */\n readonly rendersBoardPreviews?: boolean\n } = {}\n): ArtifactsRuntime {\n const authority = resolveRuntimeAuthorizationForProject(runtime)\n // A shared link's session writes nothing but comments, as a guest; unresolved authority, nothing.\n const caller: Principal | null =\n authority.type === \"principal\"\n ? authority.context.principal\n : authority.type === \"unrestricted\"\n ? SYSTEM_PRINCIPAL\n : null\n\n const requireStorage = (): ArtifactStorage => {\n const storage = runtime.storage.artifacts\n if (!storage) {\n throw new ArtifactRequestError(\n \"storage_unavailable\",\n \"[Sixb] Artifacts need storage that supports them.\"\n )\n }\n return storage\n }\n const requireCaller = (): Principal => {\n if (!caller) {\n throw new ArtifactRequestError(\n \"not_allowed\",\n authority.type === \"delegated\"\n ? \"[Sixb] A shared link's guest reads its artifacts and comments on them, nothing more.\"\n : \"[Sixb] This caller cannot publish artifacts.\"\n )\n }\n return caller\n }\n\n /** Who writes a comment: the caller, or a shared link's guest under the name they gave. */\n const commentAuthor = async (): Promise<ArtifactCommentAuthor> => {\n if (authority.type !== \"delegated\" || !authority.delegation) return requireCaller()\n return sharedLinkGuest(runtime, authority.delegation)\n }\n\n const rule = (): ArtifactAccessRule => createRuntimeArtifactAccessRule(runtime)\n const checkQuery = createArtifactQueryChecker(runtime)\n const requestPreviews: BoardPreviewRequester = async (version, requestOptions) => {\n const storage = runtime.storage.artifacts\n if (!options.rendersBoardPreviews || !storage) return\n\n // Its queries are answered as whoever published it, who is this runtime's caller.\n await requestBoardPreviews(\n {\n storage,\n queue: runtime.queues.agents,\n blobStorage,\n query: (name) => artifacts.query(version.artifactId, name, { version: version.version }),\n },\n version,\n requestOptions\n )\n }\n\n /** The artifact with what the caller may do with it; `null` when there is none. */\n const reach = async (\n artifactId: string\n ): Promise<{ readonly artifact: ArtifactRecord; readonly access: ArtifactAccess } | null> => {\n const artifact = await requireStorage().get({ projectId: runtime.projectId, id: artifactId })\n return artifact ? { artifact, access: await rule().accessTo(artifact) } : null\n }\n const getReadable = async (artifactId: string): Promise<ArtifactRecord | null> => {\n const reached = await reach(artifactId)\n return reached && reached.access !== \"none\" ? reached.artifact : null\n }\n\n /** The version with its artifact; `null` when the caller cannot read it or there is none. */\n const readVersion = async (artifactId: string, number: number | \"latest\") => {\n const artifact = await getReadable(artifactId)\n if (!artifact) return null\n\n const version = await requireStorage().getVersion({\n projectId: runtime.projectId,\n artifactId,\n version: number === \"latest\" ? artifact.latestVersion : number,\n })\n return version ? { artifact, version } : null\n }\n\n /** What an address in a version may name: one artifact the caller reads, by one rule. */\n const readableBy = (access: ArtifactAccessRule) => async (artifact: ArtifactRecord) =>\n (await access.accessTo(artifact)) !== \"none\"\n\n /** The artifact, refused unless the caller may update it. */\n const requireUpdatable = async (artifactId: string): Promise<ArtifactRecord> => {\n const reached = await reach(artifactId)\n if (!reached) throw notFound(artifactId)\n assertUpdatable(artifactId, reached.access)\n return reached.artifact\n }\n\n /**\n * Stores in one transaction, which checks again what the caller may do: a participant removed,\n * or an object that no longer holds the artifact, while the files were checked publishes nothing.\n */\n const store = async (prepared: PreparedArtifactVersion) => {\n const ruleIn = await transactionArtifactAccessRules(runtime)\n\n return runtime.storage.transaction(async (tx) => {\n const storage = tx.artifacts\n if (!storage) throw new Error(\"[Sixb] Storage transactions hold no artifacts.\")\n\n return storeArtifactVersion(\n { projectId: runtime.projectId, storage, blobStorage },\n prepared,\n (artifact) => ruleIn(tx).publishAccess(artifact)\n )\n })\n }\n\n /**\n * Changes an artifact the caller may update, in one transaction that decides it there, so a\n * participant removed, or an object changed, meanwhile changes nothing.\n */\n const change = async (\n artifactId: string,\n write: (storage: ArtifactStorage, author: Principal) => Promise<PublishedArtifactVersion>\n ) => {\n const author = requireCaller()\n requireStorage()\n const ruleIn = await transactionArtifactAccessRules(runtime)\n\n return runtime.storage.transaction(async (tx) => {\n const storage = tx.artifacts\n if (!storage) throw new Error(\"[Sixb] Storage transactions hold no artifacts.\")\n\n const artifact = await storage.get({ projectId: runtime.projectId, id: artifactId })\n if (!artifact) throw notFound(artifactId)\n assertUpdatable(artifactId, await ruleIn(tx).publishAccess(artifact))\n\n try {\n return await write(storage, author)\n } catch (error) {\n throw artifactRequestError(error)\n }\n })\n }\n\n /**\n * The version's files with its `queries` stored among them. Publishing then checks each one as\n * it checks a query file.\n */\n const contentFiles = async (input: ArtifactContentInput): Promise<readonly ArtifactFile[]> => {\n if (!input.queries) return input.files\n\n const files = [...input.files]\n for (const [name, query] of Object.entries(input.queries)) {\n const path = artifactQueryPath(name)\n if (input.files.some((file) => file.path === path)) {\n throw invalidArtifact(`'${path}' is both a file and a query; give it once.`)\n }\n\n const body = new TextEncoder().encode(JSON.stringify(queryFile(query)))\n const file = await blobStorage.put({\n body,\n expectedSizeBytes: body.byteLength,\n fileName: `${name}.json`,\n mediaType: \"application/json\",\n })\n files.push({ path, file })\n }\n return files\n }\n\n /**\n * Stores the latest version, authored by the caller, who may update the artifact. A canvas\n * written since the base is merged into, not refused: the merge is what is checked.\n */\n const write = async (\n input: ArtifactWrite & { readonly title: string }\n ): Promise<PublishedArtifact> => {\n const author = requireCaller()\n const context = { projectId: runtime.projectId, storage: requireStorage(), blobStorage }\n\n return withMergedWrite(context, input, async (merged) => {\n const prepared = await prepareArtifactVersion(context, {\n artifactId: input.artifactId,\n kind: input.kind,\n title: merged.title ?? input.title,\n files: merged.files,\n ...(merged.baseRevision === undefined ? {} : { baseRevision: merged.baseRevision }),\n ...(merged.document ? { document: merged.document } : {}),\n author,\n readable: readableBy(rule()),\n checkQuery,\n })\n const stored = await store(prepared)\n await announceArtifactUpdates(runtime.events, [stored.version])\n await requestPreviews(stored.version)\n\n return {\n ...stored,\n warnings: await artifactVersionWarnings(context, prepared, stored),\n ...(merged.merged ? { merged: true as const } : {}),\n }\n })\n }\n\n /** A live room's write-back: only a canvas keeps a document to merge it into. */\n const writeLive = async (\n artifactId: string,\n input: LiveArtifactWrite\n ): Promise<PublishedArtifact> => {\n const artifact = await requireUpdatable(artifactId)\n if (!keepsDocument(artifact.kind)) {\n throw invalidArtifact(\n `Artifact '${artifactId}' is a ${artifact.kind}, which is not edited live: publish its files.`\n )\n }\n\n return write({ artifactId, kind: artifact.kind, ...input })\n }\n\n const artifacts: ArtifactsRuntime = {\n ...createArtifactCommentsRuntime({\n projectId: runtime.projectId,\n storage: requireStorage,\n events: runtime.events,\n author: commentAuthor,\n manager: requireCaller,\n reach,\n }),\n\n async create(input) {\n const author = requireCaller()\n const files = await contentFiles(input)\n const document = await firstArtifactDocument(blobStorage, input.kind, files)\n\n const published = await publishArtifact(\n { projectId: runtime.projectId, storage: requireStorage(), blobStorage },\n {\n kind: input.kind,\n title: input.title,\n files,\n ...(document ? { document } : {}),\n author,\n readable: readableBy(rule()),\n checkQuery,\n },\n (artifact) => rule().publishAccess(artifact)\n )\n await requestPreviews(published.version)\n\n return published\n },\n\n async update(artifactId, input) {\n await requireUpdatable(artifactId)\n\n return write({\n artifactId,\n kind: input.kind,\n files: await contentFiles(input),\n ...(input.baseRevision === undefined ? {} : { baseRevision: input.baseRevision }),\n ...(input.baseFiles === undefined ? {} : { baseFiles: input.baseFiles }),\n title: input.title,\n ...(input.baseTitle === undefined ? {} : { baseTitle: input.baseTitle }),\n })\n },\n\n async freeze(artifactId, input = {}) {\n const frozenAt = new Date()\n const frozen = await change(artifactId, (storage, author) =>\n storage.freeze({\n projectId: runtime.projectId,\n artifactId,\n ...(input.baseRevision === undefined ? {} : { baseRevision: input.baseRevision }),\n frozenAt,\n frozenBy: author,\n })\n )\n\n // A version frozen before changed nothing to announce.\n if (frozen.version.frozenAt?.getTime() === frozenAt.getTime()) {\n await announceArtifactUpdates(runtime.events, [frozen.version])\n }\n return frozen\n },\n\n async listRestorePoints(artifactId) {\n if (!(await getReadable(artifactId))) return null\n return requireStorage().listRestorePoints({ projectId: runtime.projectId, id: artifactId })\n },\n\n async getRestorePoint(artifactId, revision) {\n if (!(await getReadable(artifactId))) return null\n return requireStorage().getRestorePoint({\n projectId: runtime.projectId,\n artifactId,\n revision,\n })\n },\n\n async restore(artifactId, revision, input = {}) {\n // A canvas's document takes the restored content as a change, so editors keep theirs.\n const context = { projectId: runtime.projectId, storage: requireStorage(), blobStorage }\n const point = await context.storage.getRestorePoint({\n projectId: runtime.projectId,\n artifactId,\n revision,\n })\n const restored = await withDocumentHolding(\n context,\n artifactId,\n point?.files ?? null,\n input.baseRevision,\n (held) =>\n change(artifactId, (storage, author) =>\n storage.restoreTo({\n projectId: runtime.projectId,\n artifactId,\n revision,\n ...held,\n author,\n restoredAt: new Date(),\n })\n )\n )\n await announceArtifactUpdates(runtime.events, [restored.version])\n\n // Pictures of live boards show their author's data: a restore by someone else leaves the\n // ones it misses to the boards that read none.\n await requestPreviews(\n restored.version,\n boardsReadLiveData(restored.version) ? { withoutAnswers: true } : {}\n )\n return restored\n },\n\n async access(artifactId) {\n return (await reach(artifactId))?.access ?? null\n },\n\n get: getReadable,\n\n async list(input = {}) {\n if (!caller) return { artifacts: [], hasMore: false, total: 0 }\n\n // Whoever reads a conversation reads every artifact it shares; anyone else, their own in it.\n const everyShared =\n input.threadId !== undefined && (await rule().conversation(input.threadId)) !== null\n const ownerFilter = authority.type === \"principal\" && !everyShared ? caller : null\n\n return requireStorage().list({\n projectId: runtime.projectId,\n ...(ownerFilter ? { owner: ownerFilter } : {}),\n ...(input.threadId === undefined ? {} : { threadId: input.threadId }),\n ...(input.kind === undefined ? {} : { kind: input.kind }),\n ...(input.limit === undefined ? {} : { limit: input.limit }),\n ...(input.offset === undefined ? {} : { offset: input.offset }),\n })\n },\n\n async holders(artifactId) {\n if (!(await getReadable(artifactId))) return null\n\n const holders: ArtifactHolderObject[] = []\n const holdings = readableHoldings({\n runtime,\n reader: runtime.objectReader,\n objects: runtime.storage.objects,\n artifactId,\n })\n\n // One past the page says whether there are more.\n for await (const holding of holdings) {\n if (holders.length === ARTIFACT_HOLDERS_LIMIT) return { holders, hasMore: true }\n holders.push(holderObject(runtime, holding))\n }\n return { holders, hasMore: false }\n },\n\n async getVersion(artifactId, version) {\n return (await readVersion(artifactId, version))?.version ?? null\n },\n\n async query(artifactId, name, options = {}) {\n const read = await readVersion(artifactId, options.version ?? \"latest\")\n if (!read) return null\n\n // A file artifact is delivered as it is: its one file is never run.\n const { artifact, version } = read\n const file =\n ARTIFACT_QUERY_KINDS.includes(artifact.kind) && isArtifactQueryName(name)\n ? version.files.find((candidate) => candidate.path === artifactQueryPath(name))\n : undefined\n if (!file) {\n throw new ArtifactRequestError(\n \"query_not_found\",\n `[Sixb] Version ${version.version} of artifact '${artifactId}' has no query '${name}'.`\n )\n }\n\n const text = await readArtifactText(blobStorage, file, ARTIFACT_LIMITS.maxQueryBytes)\n const parsed = parseArtifactQuery(file.path, text)\n if (\"error\" in parsed) {\n throw new ArtifactRequestError(\"query_invalid\", `[Sixb] ${parsed.error}`)\n }\n\n return runArtifactQuery(runtime, name, parsed.query)\n },\n\n async listVersions(artifactId, input = {}) {\n if (!(await getReadable(artifactId))) return null\n return requireStorage().listVersions({ projectId: runtime.projectId, artifactId, ...input })\n },\n\n async delete(artifactId) {\n if ((await reach(artifactId))?.access !== \"owner\") return false\n return requireStorage().delete({ projectId: runtime.projectId, id: artifactId })\n },\n\n state(artifactId) {\n // The reader is the caller; an observer reads the page but keeps nothing in it.\n const scope = async () => {\n const principal = requireCaller()\n await requireUpdatable(artifactId)\n return { projectId: runtime.projectId, artifactId, principal }\n }\n return {\n async get(key) {\n const entry = await requireStorage().getState({ ...(await scope()), key: stateKey(key) })\n return entry ? JSON.parse(entry.value) : undefined\n },\n async set(key, value) {\n const at = { ...(await scope()), key: stateKey(key) }\n const text = stateValue(value)\n const updatedAt = new Date()\n try {\n await requireStorage().setState({ ...at, value: text, updatedAt })\n } catch (error) {\n if (error instanceof ArtifactStorageError && error.code === \"artifact_state_full\") {\n throw new ArtifactRequestError(\"state_full\", error.message)\n }\n throw error\n }\n // As read back: what JSON keeps of it.\n return { key: at.key, value: JSON.parse(text), updatedAt }\n },\n async delete(key) {\n return requireStorage().deleteState({ ...(await scope()), key: stateKey(key) })\n },\n async entries() {\n const entries = await requireStorage().listState(await scope())\n return entries.map((entry) => ({\n key: entry.key,\n value: JSON.parse(entry.value),\n updatedAt: entry.updatedAt,\n }))\n },\n async clear() {\n return requireStorage().clearState(await scope())\n },\n }\n },\n }\n\n publishers.set(artifacts, {\n rule,\n transactionRules: () => transactionArtifactAccessRules(runtime),\n checkQuery,\n requestPreviews,\n writeLive,\n })\n return artifacts\n}\n\n/**\n * A key a page names a value by: a short line of text. Not `.` or `..`, which a page could never\n * reach: the API takes the key in its path, where those name another route.\n */\nfunction stateKey(key: string): string {\n if (\n typeof key !== \"string\" ||\n key.length === 0 ||\n key.length > ARTIFACT_STATE_LIMITS.maxKeyLength ||\n /\\p{Cc}/u.test(key) ||\n key === \".\" ||\n key === \"..\"\n ) {\n throw new ArtifactRequestError(\n \"invalid_state\",\n `[Sixb] A key is 1 to ${ARTIFACT_STATE_LIMITS.maxKeyLength} characters on one line, such as \"filters\".`\n )\n }\n return key\n}\n\n/** A value as JSON text, refused when JSON has no way to write it. */\nfunction stateValue(value: unknown): string {\n let text: string | undefined\n try {\n text = JSON.stringify(value)\n } catch {\n text = undefined\n }\n if (text === undefined) {\n throw new ArtifactRequestError(\n \"invalid_state\",\n \"[Sixb] A page keeps JSON values: text, numbers, true and false, null, lists, and objects of them.\"\n )\n }\n return text\n}\n\n/** What a query file holds for a query from the builders: its IR, with any facets by id. */\nfunction queryFile(query: ArtifactQueryInput): unknown {\n if (\"ir\" in query) return query.ir\n\n return {\n query: query.query.ir,\n facets: query.facets.map((facet) => ({ propertyId: facet.property.id, limit: facet.limit })),\n }\n}\n\n/** A holding as `holders` returns it: where it is, with the object's title when it has one. */\nfunction holderObject(runtime: SixbRuntimeContext, holding: ArtifactHolding): ArtifactHolderObject {\n const { objectTypeId, primaryId, propertyId, object } = holding\n const titleId = runtime.ontology.getObjectTypeById(objectTypeId)?.search?.title\n const value = titleId === undefined ? undefined : object.properties[titleId]\n const title = typeof value === \"string\" || typeof value === \"number\" ? String(value).trim() : \"\"\n\n return { objectTypeId, primaryId, propertyId, ...(title ? { title } : {}) }\n}\n\n/**\n * The guest a shared link's session comments as: the name its visitor gave, kept by the session.\n * Refused with `name_required` until they give one.\n */\nasync function sharedLinkGuest(\n runtime: SixbRuntimeContext,\n delegation: SharedAccessDelegationRef\n): Promise<ArtifactGuest> {\n const session = await runtime.storage.shareSessions?.getById({\n projectId: runtime.projectId,\n id: delegation.sessionId,\n })\n\n const name = session?.grantId === delegation.grantId ? session.guestName : undefined\n if (!name) {\n throw new ArtifactRequestError(\n \"name_required\",\n \"[Sixb] A shared link's guest gives their name before they comment.\"\n )\n }\n\n return { type: \"guest\", id: delegation.sessionId, name }\n}\n\nfunction notFound(artifactId: string): ArtifactRequestError {\n return new ArtifactRequestError(\n \"artifact_not_found\",\n `[Sixb] Artifact '${artifactId}' was not found.`\n )\n}\n"
26
+ ],
27
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDO,SAAS,2BAA2B,CACzC,SACA,WAEA,QACuB;AAAA,EACvB,MAAM,SAAS,UAAU,SAAS,cAAc,UAAU,QAAQ,YAAY;AAAA,EAC9E,MAAM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