@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,759 @@
1
+ import { type DefaultTreeAdapterTypes, parse } from "parse5"
2
+ import type * as Y from "yjs"
3
+ import { mergeText } from "./diff"
4
+
5
+ // A canvas's board as an editor changes it in place: the static elements of its HTML, each at an
6
+ // address that names where it is in the source, and edits to them as changes to the source's
7
+ // text, applied to the board's `Y.Text` in the live document. What a script builds is in no
8
+ // source, so it has no address and cannot be edited. Browser-safe.
9
+
10
+ type Node = DefaultTreeAdapterTypes.Node
11
+ type Element = DefaultTreeAdapterTypes.Element
12
+ type TextNode = DefaultTreeAdapterTypes.TextNode
13
+
14
+ /**
15
+ * What an editor can do with an element:
16
+ *
17
+ * - `text`: type into it. Its words, with the inline tags among them, are one block of text.
18
+ * - `image`: replace an `<img>`'s picture or its description.
19
+ * - `whole`: something drawn whole, such as an `<svg>` or an embed; only its style changes.
20
+ * - `box`: anything else, holding other elements; only its style changes.
21
+ *
22
+ * Every kind takes the style properties in {@link BOARD_STYLE_PROPERTIES}.
23
+ */
24
+ export type BoardElementKind = "text" | "image" | "whole" | "box"
25
+
26
+ /** A static element of a board's source. */
27
+ export interface BoardElement {
28
+ /**
29
+ * Where it is in the source: each step its tag and its index among its siblings of that tag,
30
+ * from the body down, as `body>main:0>h1:0`. The same source gives the same addresses.
31
+ */
32
+ readonly address: string
33
+ readonly tag: string
34
+ readonly kind: BoardElementKind
35
+ /** Where it is in the source, from its start tag to its end tag included. */
36
+ readonly start: number
37
+ readonly end: number
38
+ /** Its first words, or an image's description: what names it once it is gone. */
39
+ readonly label: string
40
+ }
41
+
42
+ /** A change to a board's source: `remove` characters at `index`, then `insert` there. */
43
+ export interface BoardChange {
44
+ readonly index: number
45
+ readonly remove: number
46
+ readonly insert: string
47
+ }
48
+
49
+ /** The changes an edit makes, in order through the source, none overlapping. */
50
+ export type BoardEdit = readonly BoardChange[]
51
+
52
+ /** The style properties an editor may set on an element. */
53
+ export const BOARD_STYLE_PROPERTIES = [
54
+ "color",
55
+ "background",
56
+ "background-color",
57
+ "font-size",
58
+ "font-weight",
59
+ "text-align",
60
+ "padding",
61
+ "gap",
62
+ "border-radius",
63
+ ] as const
64
+
65
+ export type BoardStyleProperty = (typeof BOARD_STYLE_PROPERTIES)[number]
66
+
67
+ /** The attributes the frame sets on each addressed element of a board served for editing. */
68
+ export const BOARD_ADDRESS_ATTRIBUTE = "data-sixb-at"
69
+ export const BOARD_KIND_ATTRIBUTE = "data-sixb-edit"
70
+ /** A text element's words as the source has them, hashed: one a script rewrote is not editable. */
71
+ export const BOARD_TEXT_ATTRIBUTE = "data-sixb-text"
72
+
73
+ /** The longest label an element gets. */
74
+ const MAX_LABEL_LENGTH = 80
75
+ /** The longest value a style property takes. */
76
+ const MAX_STYLE_VALUE_LENGTH = 100
77
+
78
+ /** Elements that hold no part of what a board shows, or that scripts fill: never addressed. */
79
+ const UNADDRESSED = new Set([
80
+ "script",
81
+ "style",
82
+ "template",
83
+ "noscript",
84
+ "link",
85
+ "meta",
86
+ "base",
87
+ "title",
88
+ ])
89
+ /** Elements drawn whole: their insides are not addressed. */
90
+ const WHOLE = new Set([
91
+ "svg",
92
+ "math",
93
+ "canvas",
94
+ "video",
95
+ "audio",
96
+ "iframe",
97
+ "object",
98
+ "embed",
99
+ "picture",
100
+ "select",
101
+ "textarea",
102
+ "input",
103
+ "sixb-embed",
104
+ ])
105
+ /** Tags that format words inside a block of text. */
106
+ const INLINE = new Set([
107
+ "a",
108
+ "abbr",
109
+ "b",
110
+ "bdi",
111
+ "bdo",
112
+ "br",
113
+ "cite",
114
+ "code",
115
+ "data",
116
+ "dfn",
117
+ "em",
118
+ "i",
119
+ "kbd",
120
+ "mark",
121
+ "q",
122
+ "s",
123
+ "samp",
124
+ "small",
125
+ "span",
126
+ "strong",
127
+ "sub",
128
+ "sup",
129
+ "time",
130
+ "u",
131
+ "var",
132
+ "wbr",
133
+ ])
134
+ /** Blocks meant for words: typed into even while empty, where an empty `<div>` may be a script's. */
135
+ const TEXT_BLOCKS = new Set([
136
+ "p",
137
+ "h1",
138
+ "h2",
139
+ "h3",
140
+ "h4",
141
+ "h5",
142
+ "h6",
143
+ "li",
144
+ "td",
145
+ "th",
146
+ "dt",
147
+ "dd",
148
+ "figcaption",
149
+ "blockquote",
150
+ "label",
151
+ "caption",
152
+ "button",
153
+ "legend",
154
+ "summary",
155
+ ])
156
+
157
+ interface Located {
158
+ readonly element: BoardElement
159
+ readonly node: Element
160
+ }
161
+
162
+ /** Every static element of a board's source, in source order. */
163
+ export function boardElements(source: string): BoardElement[] {
164
+ return located(source).map(({ element }) => element)
165
+ }
166
+
167
+ /** The element at an address in a board's source; null when the source has none there. */
168
+ export function boardElement(source: string, address: string): BoardElement | null {
169
+ return located(source).find(({ element }) => element.address === address)?.element ?? null
170
+ }
171
+
172
+ /**
173
+ * The source with each static element marked with its address, its kind, and a text element's
174
+ * words hashed, as the frame serves a board for editing. Nothing else in it changes.
175
+ */
176
+ export function annotateBoard(source: string): string {
177
+ const changes: BoardChange[] = []
178
+ for (const { element, node } of located(source)) {
179
+ const index = startTagClose(source, node)
180
+ if (index === null) continue
181
+
182
+ const attributes = [
183
+ `${BOARD_ADDRESS_ATTRIBUTE}="${escapeAttribute(element.address)}"`,
184
+ `${BOARD_KIND_ATTRIBUTE}="${element.kind}"`,
185
+ ...(element.kind === "text"
186
+ ? [`${BOARD_TEXT_ATTRIBUTE}="${boardTextHash(textOf(node))}"`]
187
+ : []),
188
+ ]
189
+ changes.push({ index, remove: 0, insert: ` ${attributes.join(" ")}` })
190
+ }
191
+ return applyBoardEdit(source, changes)
192
+ }
193
+
194
+ /**
195
+ * Sets a text element's words. Only what changed is replaced, inside the text it falls in, so
196
+ * the inline tags around the rest stay: typing in a bold word keeps it bold.
197
+ */
198
+ export function setBoardText(source: string, address: string, text: string): BoardEdit {
199
+ const { node } = elementAt(source, address, ["text"])
200
+ const nodes = textNodes(node)
201
+ const before = nodes.map((each) => each.value).join("")
202
+ if (before === text) return []
203
+
204
+ // The span that changed, between what both start and end with.
205
+ let prefix = 0
206
+ const most = Math.min(before.length, text.length)
207
+ while (prefix < most && before[prefix] === text[prefix]) prefix += 1
208
+ let suffix = 0
209
+ while (
210
+ suffix < most - prefix &&
211
+ before[before.length - 1 - suffix] === text[text.length - 1 - suffix]
212
+ ) {
213
+ suffix += 1
214
+ }
215
+ const from = prefix
216
+ const to = before.length - suffix
217
+ const insert = escapeText(text.slice(prefix, text.length - suffix))
218
+
219
+ // An element with no words yet takes them right after its start tag.
220
+ if (nodes.length === 0) {
221
+ const index = startTagEnd(node)
222
+ return index === null ? [] : [{ index, remove: 0, insert }]
223
+ }
224
+
225
+ // The words go into the text where the change starts, after what it follows: typed at the end
226
+ // of a bold word, they are bold too.
227
+ const ends: number[] = []
228
+ let total = 0
229
+ for (const each of nodes) {
230
+ total += each.value.length
231
+ ends.push(total)
232
+ }
233
+ const into = Math.max(
234
+ 0,
235
+ ends.findIndex((end) => from <= end)
236
+ )
237
+
238
+ const changes: BoardChange[] = []
239
+ for (const [position, each] of nodes.entries()) {
240
+ const end = ends[position] as number
241
+ const start = end - each.value.length
242
+ const removeFrom = Math.max(from, start)
243
+ const removeTo = Math.min(to, end)
244
+ const removes = removeFrom < removeTo
245
+ const takes = position === into
246
+ if (!takes && !removes) continue
247
+
248
+ const raw = rawOffsets(source, each)
249
+ if (raw) {
250
+ const index = raw[(takes ? from : removeFrom) - start] as number
251
+ const until = removes ? (raw[removeTo - start] as number) : index
252
+ changes.push({ index, remove: until - index, insert: takes ? insert : "" })
253
+ continue
254
+ }
255
+
256
+ // Text whose source does not map character by character onto its words, as an entity this
257
+ // does not know: written again whole, with the change.
258
+ const value =
259
+ each.value.slice(0, (takes ? from : removeFrom) - start) +
260
+ (takes ? text.slice(prefix, text.length - suffix) : "") +
261
+ each.value.slice(removes ? removeTo - start : (takes ? from : removeFrom) - start)
262
+ changes.push({ index: each.start, remove: each.end - each.start, insert: escapeText(value) })
263
+ }
264
+ return changes.filter((change) => change.remove > 0 || change.insert.length > 0)
265
+ }
266
+
267
+ /**
268
+ * Sets a text element's words from what someone typed into it, starting from `base`, its words as
269
+ * they saw them: what others changed in it since is kept, merged as the live document merges
270
+ * concurrent edits. Throws when the address names no text any more: the board changed, and the
271
+ * editor reloads it.
272
+ */
273
+ export function mergeBoardText(
274
+ source: string,
275
+ address: string,
276
+ base: string,
277
+ typed: string
278
+ ): BoardEdit {
279
+ const { node } = elementAt(source, address, ["text"])
280
+ const live = textOf(node)
281
+ return setBoardText(source, address, live === base ? typed : mergeText(base, typed, live))
282
+ }
283
+
284
+ /** Replaces an image's picture, its description, or both. */
285
+ export function setBoardImage(
286
+ source: string,
287
+ address: string,
288
+ image: { readonly src?: string; readonly alt?: string }
289
+ ): BoardEdit {
290
+ const { node } = elementAt(source, address, ["image"])
291
+ if (image.src !== undefined) checkImageSource(image.src)
292
+
293
+ const changes: BoardChange[] = []
294
+ for (const name of ["src", "alt"] as const) {
295
+ const value = image[name]
296
+ if (value !== undefined) changes.push(attributeChange(source, node, name, value))
297
+ }
298
+ return changes.sort((left, right) => left.index - right.index)
299
+ }
300
+
301
+ /**
302
+ * Sets style properties in an element's inline style, or removes those set to `null`. The rest of
303
+ * its style stays as it is.
304
+ */
305
+ export function setBoardStyle(
306
+ source: string,
307
+ address: string,
308
+ properties: Readonly<Partial<Record<BoardStyleProperty, string | null>>>
309
+ ): BoardEdit {
310
+ const { node } = elementAt(source, address, ["text", "image", "whole", "box"])
311
+
312
+ const declarations = parseStyle(
313
+ node.attrs.find((attribute) => attribute.name === "style")?.value ?? ""
314
+ )
315
+ for (const [name, value] of Object.entries(properties)) {
316
+ if (!(BOARD_STYLE_PROPERTIES as readonly string[]).includes(name)) {
317
+ throw new Error(
318
+ `[Sixb] '${name}' is not a style a board's element takes in place: ${BOARD_STYLE_PROPERTIES.join(", ")}.`
319
+ )
320
+ }
321
+ const index = declarations.findIndex(([property]) => property === name)
322
+ if (value === null || value === undefined) {
323
+ if (index >= 0) declarations.splice(index, 1)
324
+ continue
325
+ }
326
+ const checked = checkStyleValue(name, value)
327
+ if (index >= 0) declarations[index] = [name, checked]
328
+ else declarations.push([name, checked])
329
+ }
330
+
331
+ const style = declarations.map(([property, value]) => `${property}: ${value}`).join("; ")
332
+ if (style === "" && !node.attrs.some((attribute) => attribute.name === "style")) return []
333
+ return [attributeChange(source, node, "style", style)]
334
+ }
335
+
336
+ /** A board's source once an edit is made to it. */
337
+ export function applyBoardEdit(source: string, edit: BoardEdit): string {
338
+ let result = ""
339
+ let at = 0
340
+ for (const change of edit) {
341
+ result += source.slice(at, change.index) + change.insert
342
+ at = change.index + change.remove
343
+ }
344
+ return result + source.slice(at)
345
+ }
346
+
347
+ /**
348
+ * Makes an edit to a board's text in the live document, in one transaction under `origin`. It
349
+ * must be made from what the text holds now.
350
+ */
351
+ export function applyBoardEditToText(text: Y.Text, edit: BoardEdit, origin?: unknown): void {
352
+ if (edit.length === 0) return
353
+ const apply = () => {
354
+ // From the end, so each change's index still names where it was made.
355
+ for (const change of [...edit].reverse()) {
356
+ if (change.remove > 0) text.delete(change.index, change.remove)
357
+ if (change.insert.length > 0) text.insert(change.index, change.insert)
358
+ }
359
+ }
360
+ const doc = text.doc
361
+ if (doc) doc.transact(apply, origin)
362
+ else apply()
363
+ }
364
+
365
+ /** What a frame showing a board for editing changes in place, for one element. */
366
+ export interface BoardFramePatch {
367
+ readonly address: string
368
+ /** Every attribute it holds now, the frame's own included. */
369
+ readonly attributes?: Readonly<Record<string, string>>
370
+ /** What it holds now, for an element that holds no addressed element. */
371
+ readonly html?: string
372
+ }
373
+
374
+ /**
375
+ * What a frame showing `before` for editing changes so it shows `after`, element by element; null
376
+ * when the elements themselves changed, added, removed or moved, and the frame loads `after`
377
+ * instead.
378
+ */
379
+ export function boardFramePatches(before: string, after: string): BoardFramePatch[] | null {
380
+ if (before === after) return []
381
+ const beforeSource = annotateBoard(before)
382
+ const afterSource = annotateBoard(after)
383
+ const old = located(beforeSource)
384
+ const next = located(afterSource)
385
+ const same =
386
+ old.length === next.length &&
387
+ old.every(
388
+ ({ element }, index) =>
389
+ element.address === next[index]?.element.address &&
390
+ element.kind === next[index]?.element.kind
391
+ )
392
+ if (!same) return null
393
+
394
+ const patches: BoardFramePatch[] = []
395
+ for (const [index, { element, node }] of next.entries()) {
396
+ const previous = (old[index] as Located).node
397
+ const attributes = attributesOf(node)
398
+ const changed = JSON.stringify(attributesOf(previous)) !== JSON.stringify(attributes)
399
+
400
+ // What holds no addressed element is written whole. A box's own words, between its
401
+ // children, are not: the frame loads the board again when they change.
402
+ let html: string | undefined
403
+ if (element.kind === "box") {
404
+ if (ownContent(beforeSource, previous) !== ownContent(afterSource, node)) return null
405
+ } else {
406
+ const inner = innerOf(afterSource, node)
407
+ if (inner !== null && innerOf(beforeSource, previous) !== inner) html = inner
408
+ }
409
+
410
+ if (changed || html !== undefined) {
411
+ patches.push({
412
+ address: element.address,
413
+ ...(changed ? { attributes } : {}),
414
+ ...(html === undefined ? {} : { html }),
415
+ })
416
+ }
417
+ }
418
+ return patches
419
+ }
420
+
421
+ /**
422
+ * The hash of a text element's words that marks it in a board served for editing: FNV-1a over
423
+ * its UTF-16 code units, in hex. The frame's runtime hashes what the element holds the same way.
424
+ */
425
+ export function boardTextHash(text: string): string {
426
+ let hash = 0x811c9dc5
427
+ for (let index = 0; index < text.length; index += 1) {
428
+ hash ^= text.charCodeAt(index)
429
+ hash = Math.imul(hash, 0x01000193) >>> 0
430
+ }
431
+ return hash.toString(16)
432
+ }
433
+
434
+ /** The address an image's picture is given from a board: its file's path, from the board's folder. */
435
+ export function boardFilePath(board: string, file: string): string {
436
+ const from = board.split("/").slice(0, -1)
437
+ const to = file.split("/")
438
+ let common = 0
439
+ while (common < from.length && common < to.length - 1 && from[common] === to[common]) common += 1
440
+ const path = [...from.slice(common).map(() => ".."), ...to.slice(common)].join("/")
441
+ return path.split("/").map(encodeURIComponent).join("/")
442
+ }
443
+
444
+ // ── The source as a tree ────────────────────────────────────────────────
445
+
446
+ function located(source: string): Located[] {
447
+ const document = parse(source, { sourceCodeLocationInfo: true })
448
+ const html = document.childNodes.find(isElement)
449
+ const body = html?.childNodes.find(
450
+ (child): child is Element => isElement(child) && child.tagName === "body"
451
+ )
452
+ if (!body) return []
453
+
454
+ const found: Located[] = []
455
+ const visit = (node: Element, address: string) => {
456
+ if (node.sourceCodeLocation?.startTag) {
457
+ const kind = kindOf(node)
458
+ found.push({
459
+ node,
460
+ element: {
461
+ address,
462
+ tag: node.tagName,
463
+ kind,
464
+ start: node.sourceCodeLocation.startOffset,
465
+ end: node.sourceCodeLocation.endOffset,
466
+ label: labelOf(node, kind),
467
+ },
468
+ })
469
+ if (kind !== "box") return
470
+ }
471
+
472
+ const seen = new Map<string, number>()
473
+ for (const child of node.childNodes) {
474
+ if (!isElement(child) || UNADDRESSED.has(child.tagName)) continue
475
+ const index = seen.get(child.tagName) ?? 0
476
+ seen.set(child.tagName, index + 1)
477
+ visit(child, `${address}>${child.tagName}:${index}`)
478
+ }
479
+ }
480
+ visit(body, "body")
481
+ return found
482
+ }
483
+
484
+ function kindOf(node: Element): BoardElementKind {
485
+ if (node.tagName === "img") return "image"
486
+ if (WHOLE.has(node.tagName) || node.namespaceURI !== "http://www.w3.org/1999/xhtml") {
487
+ return "whole"
488
+ }
489
+ if (!holdsOnlyWords(node)) return "box"
490
+ return textOf(node).trim() !== "" || TEXT_BLOCKS.has(node.tagName) || INLINE.has(node.tagName)
491
+ ? "text"
492
+ : "box"
493
+ }
494
+
495
+ /** Whether an element holds only words and the inline tags that format them. */
496
+ function holdsOnlyWords(node: Element): boolean {
497
+ return node.childNodes.every((child) => {
498
+ if (isText(child)) return true
499
+ if (!isElement(child)) return child.nodeName === "#comment"
500
+ return INLINE.has(child.tagName) && holdsOnlyWords(child)
501
+ })
502
+ }
503
+
504
+ function labelOf(node: Element, kind: BoardElementKind): string {
505
+ const words =
506
+ kind === "image"
507
+ ? (node.attrs.find((attribute) => attribute.name === "alt")?.value ?? "")
508
+ : kind === "text"
509
+ ? spokenWords(node)
510
+ : textNodes(node)
511
+ .map((each) => each.value)
512
+ .join(" ")
513
+ const label = words.replace(/\s+/g, " ").trim()
514
+ return label.length > MAX_LABEL_LENGTH ? `${label.slice(0, MAX_LABEL_LENGTH - 1)}…` : label
515
+ }
516
+
517
+ /** A text's words as they read: a line break between two words parts them. */
518
+ function spokenWords(node: Element): string {
519
+ let words = ""
520
+ const visit = (each: Node) => {
521
+ if (isText(each)) {
522
+ words += each.value
523
+ } else if (isElement(each)) {
524
+ if (each.tagName === "br") words += " "
525
+ else if (!UNADDRESSED.has(each.tagName)) for (const child of each.childNodes) visit(child)
526
+ }
527
+ }
528
+ for (const child of node.childNodes) visit(child)
529
+ return words
530
+ }
531
+
532
+ function textOf(node: Element): string {
533
+ return textNodes(node)
534
+ .map((each) => each.value)
535
+ .join("")
536
+ }
537
+
538
+ interface SourceText {
539
+ readonly value: string
540
+ readonly start: number
541
+ readonly end: number
542
+ }
543
+
544
+ /** The texts inside an element, in order, where the source has them. */
545
+ function textNodes(node: Element): SourceText[] {
546
+ const texts: SourceText[] = []
547
+ const visit = (each: Node) => {
548
+ if (isText(each)) {
549
+ const location = each.sourceCodeLocation
550
+ if (location)
551
+ texts.push({ value: each.value, start: location.startOffset, end: location.endOffset })
552
+ return
553
+ }
554
+ if (isElement(each) && !UNADDRESSED.has(each.tagName)) {
555
+ for (const child of each.childNodes) visit(child)
556
+ }
557
+ }
558
+ for (const child of node.childNodes) visit(child)
559
+ return texts
560
+ }
561
+
562
+ /**
563
+ * Where in the source each character of a text starts, and one past its end: null when the
564
+ * source's characters do not map one by one onto the text's, as an entity the decoding here does
565
+ * not know would.
566
+ */
567
+ function rawOffsets(source: string, text: SourceText): number[] | null {
568
+ const raw = source.slice(text.start, text.end)
569
+ const offsets: number[] = []
570
+ let decoded = ""
571
+ let at = 0
572
+ while (at < raw.length) {
573
+ const entity = raw[at] === "&" ? /^&(#x[\da-f]+|#\d+|[a-z]+);/i.exec(raw.slice(at)) : null
574
+ // The parser reads a line break as one `\n`, whether it was written `\r\n` or `\r`.
575
+ const crlf = raw[at] === "\r" && raw[at + 1] === "\n"
576
+ const value = entity ? decodeEntity(entity[1] as string) : raw[at] === "\r" ? "\n" : raw[at]
577
+ const length = entity ? entity[0].length : crlf ? 2 : 1
578
+ if (value === null || value === undefined) return null
579
+
580
+ for (let unit = 0; unit < value.length; unit += 1) offsets.push(text.start + at)
581
+ decoded += value
582
+ at += length
583
+ }
584
+ offsets.push(text.end)
585
+ return decoded === text.value ? offsets : null
586
+ }
587
+
588
+ const NAMED_ENTITIES: Readonly<Record<string, string>> = {
589
+ amp: "&",
590
+ lt: "<",
591
+ gt: ">",
592
+ quot: '"',
593
+ apos: "'",
594
+ nbsp: "\u00a0",
595
+ }
596
+
597
+ function decodeEntity(entity: string): string | null {
598
+ if (entity[0] !== "#") return NAMED_ENTITIES[entity.toLowerCase()] ?? null
599
+ const codePoint =
600
+ entity[1]?.toLowerCase() === "x"
601
+ ? Number.parseInt(entity.slice(2), 16)
602
+ : Number(entity.slice(1))
603
+ // A single character only: one that takes two code units would split between them.
604
+ return Number.isInteger(codePoint) && codePoint > 0 && codePoint < 0x10000
605
+ ? String.fromCharCode(codePoint)
606
+ : null
607
+ }
608
+
609
+ /** Just past an element's start tag. */
610
+ function startTagEnd(node: Element): number | null {
611
+ return node.sourceCodeLocation?.startTag?.endOffset ?? null
612
+ }
613
+
614
+ /** Where an attribute goes in an element's start tag: before its `>`, or its `/>`. */
615
+ function startTagClose(source: string, node: Element): number | null {
616
+ const end = startTagEnd(node)
617
+ if (end === null) return null
618
+
619
+ // A `/` before the `>` closes the tag unless it ends an unquoted value, as `src=/a/b/` does.
620
+ const attributes = Object.values(node.sourceCodeLocation?.attrs ?? {})
621
+ const lastValueEnd = Math.max(0, ...attributes.map((location) => location.endOffset))
622
+ let at = end - 1
623
+ if (source[at - 1] === "/" && lastValueEnd < at) at -= 1
624
+ while (at > lastValueEnd && /\s/.test(source[at - 1] ?? "")) at -= 1
625
+ return at
626
+ }
627
+
628
+ function attributeChange(source: string, node: Element, name: string, value: string): BoardChange {
629
+ const written = `${name}="${escapeAttribute(value)}"`
630
+ const location = node.sourceCodeLocation?.attrs?.[name]
631
+ if (location) {
632
+ return {
633
+ index: location.startOffset,
634
+ remove: location.endOffset - location.startOffset,
635
+ insert: written,
636
+ }
637
+ }
638
+ const index = startTagClose(source, node)
639
+ if (index === null) throw new Error("[Sixb] This element has no start tag in the board's source.")
640
+ return { index, remove: 0, insert: ` ${written}` }
641
+ }
642
+
643
+ function attributesOf(node: Element): Record<string, string> {
644
+ return Object.fromEntries(node.attrs.map((attribute) => [attribute.name, attribute.value]))
645
+ }
646
+
647
+ /** What an element holds in the source, between its tags; null for one with no end tag. */
648
+ function innerOf(source: string, node: Element): string | null {
649
+ const location = node.sourceCodeLocation
650
+ const start = location?.startTag?.endOffset
651
+ const end = location?.endTag?.startOffset
652
+ if (start === undefined) return null
653
+ return source.slice(start, end ?? location?.endOffset ?? start)
654
+ }
655
+
656
+ /** What a box holds in the source besides its addressed children. */
657
+ function ownContent(source: string, node: Element): string | null {
658
+ const inner = innerOf(source, node)
659
+ const start = node.sourceCodeLocation?.startTag?.endOffset
660
+ if (inner === null || start === undefined) return inner
661
+
662
+ let own = ""
663
+ let at = start
664
+ for (const child of node.childNodes) {
665
+ if (!isElement(child) || UNADDRESSED.has(child.tagName) || !child.sourceCodeLocation) continue
666
+ own += source.slice(at, child.sourceCodeLocation.startOffset)
667
+ at = child.sourceCodeLocation.endOffset
668
+ }
669
+ return own + source.slice(at, start + inner.length)
670
+ }
671
+
672
+ function elementAt(source: string, address: string, kinds: readonly BoardElementKind[]): Located {
673
+ const found = located(source).find(({ element }) => element.address === address)
674
+ if (!found) {
675
+ throw new Error(
676
+ `[Sixb] The board holds no element at '${address}': it changed, or a script builds it.`
677
+ )
678
+ }
679
+ if (!kinds.includes(found.element.kind)) {
680
+ throw new Error(
681
+ `[Sixb] The element at '${address}' is ${articled(found.element.kind)}: it takes no such edit.`
682
+ )
683
+ }
684
+ return found
685
+ }
686
+
687
+ function articled(kind: BoardElementKind): string {
688
+ return { text: "text", image: "an image", whole: "drawn whole", box: "a box of elements" }[kind]
689
+ }
690
+
691
+ /** Declarations of an inline style, in order. */
692
+ function parseStyle(style: string): [string, string][] {
693
+ const declarations: [string, string][] = []
694
+ let depth = 0
695
+ let quote: string | null = null
696
+ let current = ""
697
+ const flush = () => {
698
+ const colon = current.indexOf(":")
699
+ if (colon > 0) {
700
+ const property = current.slice(0, colon).trim().toLowerCase()
701
+ const value = current.slice(colon + 1).trim()
702
+ if (property && value) declarations.push([property, value])
703
+ }
704
+ current = ""
705
+ }
706
+ for (const char of style) {
707
+ if (quote) {
708
+ if (char === quote) quote = null
709
+ } else if (char === '"' || char === "'") quote = char
710
+ else if (char === "(") depth += 1
711
+ else if (char === ")") depth = Math.max(0, depth - 1)
712
+ else if (char === ";" && depth === 0) {
713
+ flush()
714
+ continue
715
+ }
716
+ current += char
717
+ }
718
+ flush()
719
+ return declarations
720
+ }
721
+
722
+ function checkStyleValue(property: string, value: string): string {
723
+ const trimmed = value.trim()
724
+ if (
725
+ trimmed === "" ||
726
+ trimmed.length > MAX_STYLE_VALUE_LENGTH ||
727
+ /[;{}<>"'\\]|\/\*|url\s*\(|expression\s*\(|@/i.test(trimmed)
728
+ ) {
729
+ throw new Error(`[Sixb] '${value}' is not a value '${property}' takes in place.`)
730
+ }
731
+ return trimmed
732
+ }
733
+
734
+ function checkImageSource(src: string): void {
735
+ const trimmed = src.trim()
736
+ if (
737
+ trimmed === "" ||
738
+ trimmed.length > 2048 ||
739
+ /^(javascript|vbscript|data:text)/i.test(trimmed.replace(/[\s\u0000-\u001f]/g, ""))
740
+ ) {
741
+ throw new Error(`[Sixb] '${src}' is not a picture a board's image shows.`)
742
+ }
743
+ }
744
+
745
+ function escapeText(text: string): string {
746
+ return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;")
747
+ }
748
+
749
+ function escapeAttribute(value: string): string {
750
+ return value.replace(/&/g, "&amp;").replace(/"/g, "&quot;")
751
+ }
752
+
753
+ function isElement(node: Node): node is Element {
754
+ return "tagName" in node
755
+ }
756
+
757
+ function isText(node: Node): node is TextNode {
758
+ return node.nodeName === "#text"
759
+ }