@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.
- package/dist/actions/index.js +56 -50
- package/dist/actions/index.js.map +1 -1
- package/dist/actions/request.d.ts.map +1 -1
- package/dist/actions/run/executor.d.ts +0 -2
- package/dist/actions/run/executor.d.ts.map +1 -1
- package/dist/actions/types/context.d.ts +5 -1
- package/dist/actions/types/context.d.ts.map +1 -1
- package/dist/agents/cancel.d.ts +1 -1
- package/dist/agents/cancel.d.ts.map +1 -1
- package/dist/agents/child-question.d.ts +35 -2
- package/dist/agents/child-question.d.ts.map +1 -1
- package/dist/agents/execution.d.ts +3 -2
- package/dist/agents/execution.d.ts.map +1 -1
- package/dist/agents/fork.d.ts.map +1 -1
- package/dist/agents/ids.d.ts +2 -0
- package/dist/agents/ids.d.ts.map +1 -1
- package/dist/agents/index.d.ts +4 -4
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +91 -76
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/model-loop.d.ts.map +1 -1
- package/dist/agents/request.d.ts +7 -1
- package/dist/agents/request.d.ts.map +1 -1
- package/dist/agents/run-artifacts.d.ts +73 -10
- package/dist/agents/run-artifacts.d.ts.map +1 -1
- package/dist/agents/run-session-children.d.ts +9 -0
- package/dist/agents/run-session-children.d.ts.map +1 -1
- package/dist/agents/run-session-http.d.ts.map +1 -1
- package/dist/agents/run-session-serve.d.ts.map +1 -1
- package/dist/agents/run-session.d.ts +3 -0
- package/dist/agents/run-session.d.ts.map +1 -1
- package/dist/agents/streams/index.js +2 -2
- package/dist/agents/streams/internal.js +2 -2
- package/dist/agents/streams/protocol.d.ts.map +1 -1
- package/dist/agents/tool-files.d.ts +1 -1
- package/dist/agents/tool-files.d.ts.map +1 -1
- package/dist/agents/tool-input-coercion.d.ts +20 -0
- package/dist/agents/tool-input-coercion.d.ts.map +1 -0
- package/dist/agents/validation.d.ts +1 -1
- package/dist/agents/validation.d.ts.map +1 -1
- package/dist/artifacts/access.d.ts +37 -17
- package/dist/artifacts/access.d.ts.map +1 -1
- package/dist/artifacts/canvas-display.d.ts +65 -0
- package/dist/artifacts/canvas-display.d.ts.map +1 -0
- package/dist/artifacts/canvas.d.ts +6 -1
- package/dist/artifacts/canvas.d.ts.map +1 -1
- package/dist/artifacts/comment-text.d.ts +19 -0
- package/dist/artifacts/comment-text.d.ts.map +1 -0
- package/dist/artifacts/comments.d.ts +52 -0
- package/dist/artifacts/comments.d.ts.map +1 -0
- package/dist/artifacts/errors.d.ts +3 -3
- package/dist/artifacts/errors.d.ts.map +1 -1
- package/dist/artifacts/events.d.ts +14 -0
- package/dist/artifacts/events.d.ts.map +1 -0
- package/dist/artifacts/execution.d.ts +129 -22
- package/dist/artifacts/execution.d.ts.map +1 -1
- package/dist/artifacts/frames/assets.d.ts +12 -1
- package/dist/artifacts/frames/assets.d.ts.map +1 -1
- package/dist/artifacts/frames/grants.d.ts +8 -5
- package/dist/artifacts/frames/grants.d.ts.map +1 -1
- package/dist/artifacts/frames/index.d.ts +1 -1
- package/dist/artifacts/frames/index.d.ts.map +1 -1
- package/dist/artifacts/frames/index.js +32 -964
- package/dist/artifacts/frames/index.js.map +4 -8
- package/dist/artifacts/frames/kit.d.ts.map +1 -1
- package/dist/artifacts/frames/protocol.d.ts +129 -0
- package/dist/artifacts/frames/protocol.d.ts.map +1 -1
- package/dist/artifacts/frames/runtime.d.ts +24 -7
- package/dist/artifacts/frames/runtime.d.ts.map +1 -1
- package/dist/artifacts/holders.d.ts +23 -0
- package/dist/artifacts/holders.d.ts.map +1 -0
- package/dist/artifacts/ids.d.ts +2 -0
- package/dist/artifacts/ids.d.ts.map +1 -1
- package/dist/artifacts/index.d.ts +6 -4
- package/dist/artifacts/index.d.ts.map +1 -1
- package/dist/artifacts/index.js +134 -13
- package/dist/artifacts/index.js.map +5 -4
- package/dist/artifacts/limits.d.ts +24 -3
- package/dist/artifacts/limits.d.ts.map +1 -1
- package/dist/artifacts/live/board.d.ts +103 -0
- package/dist/artifacts/live/board.d.ts.map +1 -0
- package/dist/artifacts/live/diff.d.ts +43 -0
- package/dist/artifacts/live/diff.d.ts.map +1 -0
- package/dist/artifacts/live/document.d.ts +55 -0
- package/dist/artifacts/live/document.d.ts.map +1 -0
- package/dist/artifacts/live/files.d.ts +16 -0
- package/dist/artifacts/live/files.d.ts.map +1 -0
- package/dist/artifacts/live/index.d.ts +9 -0
- package/dist/artifacts/live/index.d.ts.map +1 -0
- package/dist/artifacts/live/index.js +593 -0
- package/dist/artifacts/live/index.js.map +10 -0
- package/dist/artifacts/live/presence.d.ts +55 -0
- package/dist/artifacts/live/presence.d.ts.map +1 -0
- package/dist/artifacts/live/protocol.d.ts +109 -0
- package/dist/artifacts/live/protocol.d.ts.map +1 -0
- package/dist/artifacts/live/protocol.js +21 -0
- package/dist/artifacts/live/protocol.js.map +9 -0
- package/dist/artifacts/live/server.d.ts +10 -0
- package/dist/artifacts/live/server.d.ts.map +1 -0
- package/dist/artifacts/live/server.js +86 -0
- package/dist/artifacts/live/server.js.map +9 -0
- package/dist/artifacts/live/state.d.ts +26 -0
- package/dist/artifacts/live/state.d.ts.map +1 -0
- package/dist/artifacts/outline.d.ts +11 -0
- package/dist/artifacts/outline.d.ts.map +1 -1
- package/dist/artifacts/publish/index.d.ts +8 -1
- package/dist/artifacts/publish/index.d.ts.map +1 -1
- package/dist/artifacts/publish/index.js +62 -34
- package/dist/artifacts/publish/index.js.map +1 -1
- package/dist/artifacts/publish/merge.d.ts +75 -0
- package/dist/artifacts/publish/merge.d.ts.map +1 -0
- package/dist/artifacts/publish/previews.d.ts +153 -0
- package/dist/artifacts/publish/previews.d.ts.map +1 -0
- package/dist/artifacts/publish/publish.d.ts +29 -8
- package/dist/artifacts/publish/publish.d.ts.map +1 -1
- package/dist/artifacts/publish/query-answers.d.ts +20 -0
- package/dist/artifacts/publish/query-answers.d.ts.map +1 -0
- package/dist/artifacts/publish/references.d.ts +4 -3
- package/dist/artifacts/publish/references.d.ts.map +1 -1
- package/dist/artifacts/publish/validate/canvas.d.ts.map +1 -1
- package/dist/artifacts/theme.d.ts +5 -1
- package/dist/artifacts/theme.d.ts.map +1 -1
- package/dist/auth/directory.d.ts +33 -0
- package/dist/auth/directory.d.ts.map +1 -0
- package/dist/auth/index.js +13 -12
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/member-events.d.ts +5 -1
- package/dist/auth/member-events.d.ts.map +1 -1
- package/dist/auth/runtime.d.ts +22 -1
- package/dist/auth/runtime.d.ts.map +1 -1
- package/dist/auth/strategy.d.ts +2 -2
- package/dist/auth/strategy.d.ts.map +1 -1
- package/dist/auth/types.d.ts +42 -1
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/authorization/decision.d.ts +6 -5
- package/dist/authorization/decision.d.ts.map +1 -1
- package/dist/authorization/event-visibility.d.ts.map +1 -1
- package/dist/authorization/index.js +7 -6
- package/dist/authorization/index.js.map +1 -1
- package/dist/blob-storage/index.js +4 -4
- package/dist/blob-storage/index.js.map +1 -1
- package/dist/bootstrap/index.js +63 -57
- package/dist/bootstrap/index.js.map +2 -2
- package/dist/broker/in-memory.d.ts.map +1 -1
- package/dist/broker/index.js +1 -1
- package/dist/broker/types.d.ts +4 -0
- package/dist/broker/types.d.ts.map +1 -1
- package/dist/{chunk-s7j8ewqv.js → chunk-0k3r5kb3.js} +257 -43
- package/dist/{chunk-s7j8ewqv.js.map → chunk-0k3r5kb3.js.map} +14 -13
- package/dist/{chunk-e5wf5vz0.js → chunk-0kgrghqx.js} +13 -1
- package/dist/chunk-0kgrghqx.js.map +10 -0
- package/dist/{chunk-80gym75n.js → chunk-186k5yz3.js} +1 -1
- package/dist/chunk-191jz8a6.js +61 -0
- package/dist/chunk-191jz8a6.js.map +10 -0
- package/dist/{chunk-mmagke4x.js → chunk-22d3qg4x.js} +2 -2
- package/dist/{chunk-mmagke4x.js.map → chunk-22d3qg4x.js.map} +3 -3
- package/dist/{chunk-ga63a3dz.js → chunk-2bn6813a.js} +3 -3
- package/dist/chunk-2c4j899j.js.map +2 -2
- package/dist/{chunk-e6xgz4h4.js → chunk-3014rfjz.js} +197 -18
- package/dist/chunk-3014rfjz.js.map +21 -0
- package/dist/{chunk-ytzcxtpt.js → chunk-3ba89vm7.js} +1 -1
- package/dist/chunk-3hzhcfsv.js +139 -0
- package/dist/chunk-3hzhcfsv.js.map +10 -0
- package/dist/chunk-3sgvd10b.js +69 -0
- package/dist/chunk-3sgvd10b.js.map +10 -0
- package/dist/chunk-3z1vxzcm.js +234 -0
- package/dist/chunk-3z1vxzcm.js.map +12 -0
- package/dist/{chunk-djs3hw9p.js → chunk-3zagkr6w.js} +73 -6
- package/dist/chunk-3zagkr6w.js.map +21 -0
- package/dist/{chunk-wkq3kvzd.js → chunk-48c1z8nj.js} +6 -6
- package/dist/chunk-48c1z8nj.js.map +10 -0
- package/dist/{chunk-d04g36fw.js → chunk-5qqmndhm.js} +1 -1
- package/dist/{chunk-scyq22td.js → chunk-5rqqp8cr.js} +19 -4
- package/dist/chunk-5rqqp8cr.js.map +12 -0
- package/dist/chunk-6ef4esq4.js +225 -0
- package/dist/chunk-6ef4esq4.js.map +11 -0
- package/dist/{chunk-jspskey0.js → chunk-7j4yydm2.js} +67 -45
- package/dist/chunk-7j4yydm2.js.map +11 -0
- package/dist/chunk-7kpqntgw.js +70 -0
- package/dist/chunk-7kpqntgw.js.map +10 -0
- package/dist/{chunk-5wtnmpze.js → chunk-7qe46788.js} +1 -1
- package/dist/{chunk-31kcqmhf.js → chunk-855w9nvw.js} +1 -1
- package/dist/{chunk-e7v3trpz.js → chunk-8a8k38tz.js} +4 -3
- package/dist/chunk-8a8k38tz.js.map +10 -0
- package/dist/chunk-8bns0y68.js +1322 -0
- package/dist/chunk-8bns0y68.js.map +25 -0
- package/dist/{chunk-jftd33rc.js → chunk-8t2ynwg0.js} +105 -9
- package/dist/chunk-8t2ynwg0.js.map +11 -0
- package/dist/{chunk-9whfmsfk.js → chunk-8tqnsx3q.js} +1 -1
- package/dist/{chunk-s3we74h8.js → chunk-9nsjjd44.js} +38 -5
- package/dist/chunk-9nsjjd44.js.map +12 -0
- package/dist/{chunk-hz5d43gn.js → chunk-9vsc919v.js} +14 -6
- package/dist/chunk-9vsc919v.js.map +10 -0
- package/dist/{chunk-waqk73p1.js → chunk-a6fjkcne.js} +185 -341
- package/dist/{chunk-waqk73p1.js.map → chunk-a6fjkcne.js.map} +6 -7
- package/dist/chunk-az95tsh3.js.map +2 -2
- package/dist/{chunk-s038wa5v.js → chunk-b9qfh2ya.js} +1 -1
- package/dist/{chunk-5taem5aw.js → chunk-bc3y6gff.js} +13 -4
- package/dist/chunk-bc3y6gff.js.map +10 -0
- package/dist/chunk-bz5bnjjt.js +358 -0
- package/dist/chunk-bz5bnjjt.js.map +12 -0
- package/dist/{chunk-w976a4me.js → chunk-czct88ht.js} +28 -4
- package/dist/chunk-czct88ht.js.map +10 -0
- package/dist/{chunk-5kyvrtjh.js → chunk-d9xbwh3h.js} +131 -32
- package/dist/chunk-d9xbwh3h.js.map +13 -0
- package/dist/{chunk-kfee1h52.js → chunk-dfveegqq.js} +28 -8
- package/dist/chunk-dfveegqq.js.map +13 -0
- package/dist/{chunk-2g0r46hy.js → chunk-dhkc9b23.js} +15 -2
- package/dist/chunk-dhkc9b23.js.map +12 -0
- package/dist/chunk-dmnd9ea6.js +106 -0
- package/dist/chunk-dmnd9ea6.js.map +10 -0
- package/dist/{chunk-nz7815t3.js → chunk-e0hnbb1m.js} +27 -2
- package/dist/chunk-e0hnbb1m.js.map +14 -0
- package/dist/chunk-e91fmg6t.js +288 -0
- package/dist/chunk-e91fmg6t.js.map +11 -0
- package/dist/{chunk-3sqqhpr7.js → chunk-evj5jxz3.js} +134 -19
- package/dist/{chunk-3sqqhpr7.js.map → chunk-evj5jxz3.js.map} +11 -10
- package/dist/{chunk-w122ymx4.js → chunk-f6ahf5gf.js} +15 -4
- package/dist/{chunk-w122ymx4.js.map → chunk-f6ahf5gf.js.map} +3 -3
- package/dist/{chunk-jjmggm9a.js → chunk-fe6r7yhg.js} +1 -1
- package/dist/{chunk-165c9wm6.js → chunk-g2ph4873.js} +1 -1
- package/dist/{chunk-dsv783c3.js → chunk-gxwy4c3s.js} +203 -57
- package/dist/chunk-gxwy4c3s.js.map +47 -0
- package/dist/chunk-hgj98cbb.js +22 -0
- package/dist/chunk-hgj98cbb.js.map +10 -0
- package/dist/chunk-hn2r7z41.js.map +3 -3
- package/dist/chunk-hvbvq7p4.js +1553 -0
- package/dist/chunk-hvbvq7p4.js.map +18 -0
- package/dist/chunk-j0wgh8gv.js +250 -0
- package/dist/chunk-j0wgh8gv.js.map +10 -0
- package/dist/{chunk-z8fx5cgb.js → chunk-j2zm215x.js} +37 -3
- package/dist/chunk-j2zm215x.js.map +12 -0
- package/dist/{chunk-j1ny5fwh.js → chunk-k1g14kk3.js} +11 -83
- package/dist/{chunk-j1ny5fwh.js.map → chunk-k1g14kk3.js.map} +4 -5
- package/dist/chunk-kr6dx38r.js +25 -0
- package/dist/chunk-kr6dx38r.js.map +10 -0
- package/dist/chunk-m2jerfef.js +474 -0
- package/dist/chunk-m2jerfef.js.map +11 -0
- package/dist/{chunk-m2vh8gh0.js → chunk-msyevpp3.js} +62 -15
- package/dist/{chunk-m2vh8gh0.js.map → chunk-msyevpp3.js.map} +5 -5
- package/dist/{chunk-escedwyt.js → chunk-mvz89age.js} +6 -1
- package/dist/{chunk-escedwyt.js.map → chunk-mvz89age.js.map} +3 -3
- package/dist/chunk-mwcqz3e3.js +30 -0
- package/dist/chunk-mwcqz3e3.js.map +10 -0
- package/dist/chunk-n2ay51px.js +21 -0
- package/dist/chunk-n2ay51px.js.map +10 -0
- package/dist/chunk-n4zzaf6q.js.map +1 -1
- package/dist/{chunk-gkv8r794.js → chunk-n68vz95m.js} +5 -5
- package/dist/{chunk-gkv8r794.js.map → chunk-n68vz95m.js.map} +3 -3
- package/dist/{chunk-0j3crh1w.js → chunk-p351afzm.js} +14 -14
- package/dist/{chunk-0j3crh1w.js.map → chunk-p351afzm.js.map} +4 -4
- package/dist/{chunk-c7cfe31p.js → chunk-p8pgnq8d.js} +16 -16
- package/dist/{chunk-c7cfe31p.js.map → chunk-p8pgnq8d.js.map} +1 -1
- package/dist/chunk-pk539cwv.js +370 -0
- package/dist/chunk-pk539cwv.js.map +11 -0
- package/dist/{chunk-jbw70d6t.js → chunk-ppxf7gw2.js} +52 -10
- package/dist/chunk-ppxf7gw2.js.map +11 -0
- package/dist/{chunk-9x8dybsb.js → chunk-pvpq483h.js} +10 -2
- package/dist/chunk-pvpq483h.js.map +10 -0
- package/dist/{chunk-4zm1k3xj.js → chunk-r2psmn42.js} +1 -1
- package/dist/{chunk-a7aa0nzj.js → chunk-r9rtavg9.js} +14 -14
- package/dist/{chunk-a7aa0nzj.js.map → chunk-r9rtavg9.js.map} +1 -1
- package/dist/{chunk-w1btn96n.js → chunk-rsrc7vtw.js} +523 -254
- package/dist/chunk-rsrc7vtw.js.map +49 -0
- package/dist/{chunk-2ajw5rz0.js → chunk-rsxb14an.js} +3 -3
- package/dist/{chunk-kkjfve0t.js → chunk-rt9deb92.js} +4 -3
- package/dist/{chunk-kkjfve0t.js.map → chunk-rt9deb92.js.map} +3 -3
- package/dist/{chunk-r1cxq7vv.js → chunk-rtdrm592.js} +2 -2
- package/dist/{chunk-a5v4gjdx.js → chunk-rtm1jq00.js} +460 -227
- package/dist/{chunk-a5v4gjdx.js.map → chunk-rtm1jq00.js.map} +25 -22
- package/dist/{chunk-4bm0caep.js → chunk-smnt672s.js} +1 -1
- package/dist/{chunk-21q0j5f2.js → chunk-stmxh0hv.js} +2 -2
- package/dist/{chunk-nh26e7c5.js → chunk-sysnvjce.js} +5 -5
- package/dist/{chunk-nh26e7c5.js.map → chunk-sysnvjce.js.map} +3 -3
- package/dist/{chunk-7z5rkf0m.js → chunk-t0s7b3d1.js} +4 -3
- package/dist/{chunk-7z5rkf0m.js.map → chunk-t0s7b3d1.js.map} +3 -3
- package/dist/{chunk-57g0215c.js → chunk-t24yktqr.js} +296 -7
- package/dist/{chunk-57g0215c.js.map → chunk-t24yktqr.js.map} +6 -3
- package/dist/{chunk-mbc5hvnj.js → chunk-td26wjr5.js} +18 -7
- package/dist/{chunk-mbc5hvnj.js.map → chunk-td26wjr5.js.map} +3 -3
- package/dist/{chunk-ff5xkv0p.js → chunk-tfzvjdms.js} +1 -1
- package/dist/{chunk-f1h34y3r.js → chunk-vepea5c3.js} +6 -6
- package/dist/{chunk-f1h34y3r.js.map → chunk-vepea5c3.js.map} +1 -1
- package/dist/chunk-vtjzwymr.js +37 -0
- package/dist/chunk-vtjzwymr.js.map +10 -0
- package/dist/{chunk-twfreyxr.js → chunk-vzkxqf8h.js} +23 -13
- package/dist/{chunk-twfreyxr.js.map → chunk-vzkxqf8h.js.map} +6 -6
- package/dist/{chunk-eqgr6nsa.js → chunk-w1wq7gfr.js} +983 -185
- package/dist/chunk-w1wq7gfr.js.map +75 -0
- package/dist/{chunk-6b61s40c.js → chunk-w3t94hm6.js} +1 -1
- package/dist/{chunk-fwsvshr5.js → chunk-wa05txmk.js} +20 -7
- package/dist/{chunk-fwsvshr5.js.map → chunk-wa05txmk.js.map} +3 -3
- package/dist/chunk-whbwf3np.js +12 -0
- package/dist/chunk-whbwf3np.js.map +10 -0
- package/dist/{chunk-t5608tkq.js → chunk-yv8hv4wq.js} +3 -1
- package/dist/{chunk-t5608tkq.js.map → chunk-yv8hv4wq.js.map} +3 -3
- package/dist/{chunk-j8thxj7w.js → chunk-yy914zfr.js} +1218 -101
- package/dist/chunk-yy914zfr.js.map +30 -0
- package/dist/connectors/builders.d.ts +2 -2
- package/dist/connectors/builders.d.ts.map +1 -1
- package/dist/connectors/connections/access.d.ts +11 -0
- package/dist/connectors/connections/access.d.ts.map +1 -0
- package/dist/connectors/connections/contracts.d.ts +6 -1
- package/dist/connectors/connections/contracts.d.ts.map +1 -1
- package/dist/connectors/connections/internal.js +1 -1
- package/dist/connectors/connections/runs.d.ts +6 -0
- package/dist/connectors/connections/runs.d.ts.map +1 -1
- package/dist/connectors/connections/service.d.ts +25 -0
- package/dist/connectors/connections/service.d.ts.map +1 -1
- package/dist/connectors/connections/views.d.ts +1 -1
- package/dist/connectors/connections/views.d.ts.map +1 -1
- package/dist/connectors/execution.d.ts.map +1 -1
- package/dist/connectors/index.d.ts +1 -1
- package/dist/connectors/index.d.ts.map +1 -1
- package/dist/connectors/service.d.ts +3 -0
- package/dist/connectors/service.d.ts.map +1 -1
- package/dist/connectors/types.d.ts +21 -2
- package/dist/connectors/types.d.ts.map +1 -1
- package/dist/datasets/execution.d.ts +12 -6
- package/dist/datasets/execution.d.ts.map +1 -1
- package/dist/datasets/ingest-flush-batch.d.ts +59 -0
- package/dist/datasets/ingest-flush-batch.d.ts.map +1 -0
- package/dist/datasets/ingest-flush-job.d.ts +33 -0
- package/dist/datasets/ingest-flush-job.d.ts.map +1 -0
- package/dist/datasets/ingest-flush.d.ts +66 -0
- package/dist/datasets/ingest-flush.d.ts.map +1 -0
- package/dist/datasets/produced-version.d.ts +21 -0
- package/dist/datasets/produced-version.d.ts.map +1 -0
- package/dist/datasets/write.d.ts +22 -1
- package/dist/datasets/write.d.ts.map +1 -1
- package/dist/datasets/write.js +8 -4
- package/dist/datasets/write.js.map +1 -1
- package/dist/deploy/internal.js +5 -4
- package/dist/deploy/internal.js.map +4 -4
- package/dist/deploy/types.d.ts +2 -3
- package/dist/deploy/types.d.ts.map +1 -1
- package/dist/error-reporting/capability.d.ts +8 -2
- package/dist/error-reporting/capability.d.ts.map +1 -1
- package/dist/error-reporting/internal.d.ts +1 -1
- package/dist/error-reporting/internal.d.ts.map +1 -1
- package/dist/error-reporting/internal.js +17 -5
- package/dist/error-reporting/internal.js.map +1 -1
- package/dist/error-reporting/reporter.d.ts.map +1 -1
- package/dist/error-reporting/reports.d.ts +55 -0
- package/dist/error-reporting/reports.d.ts.map +1 -1
- package/dist/error-reporting/types.d.ts +82 -1
- package/dist/error-reporting/types.d.ts.map +1 -1
- package/dist/errors/catalog.d.ts +5 -0
- package/dist/errors/catalog.d.ts.map +1 -1
- package/dist/errors/internal.js +1 -1
- package/dist/events/definitions.d.ts +4 -0
- package/dist/events/definitions.d.ts.map +1 -1
- package/dist/events/execution.d.ts +1 -0
- package/dist/events/execution.d.ts.map +1 -1
- package/dist/events/index.d.ts +1 -1
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +5 -5
- package/dist/events/scope.d.ts.map +1 -1
- package/dist/events/scope.js +1 -1
- package/dist/events/selectors/index.js +2 -2
- package/dist/events/types/artifacts.d.ts +38 -0
- package/dist/events/types/artifacts.d.ts.map +1 -0
- package/dist/events/types/index.d.ts +3 -1
- package/dist/events/types/index.d.ts.map +1 -1
- package/dist/events/types/users.d.ts +5 -2
- package/dist/events/types/users.d.ts.map +1 -1
- package/dist/execution/agent.js +58 -52
- package/dist/execution/agent.js.map +1 -1
- package/dist/execution/authorized-object-reader.d.ts +10 -0
- package/dist/execution/authorized-object-reader.d.ts.map +1 -1
- package/dist/execution/object-reader-clearance.d.ts +6 -0
- package/dist/execution/object-reader-clearance.d.ts.map +1 -1
- package/dist/execution/object-reader-security.d.ts +9 -2
- package/dist/execution/object-reader-security.d.ts.map +1 -1
- package/dist/execution/primitive.js +56 -50
- package/dist/execution/primitive.js.map +1 -1
- package/dist/execution/request.js +50 -44
- package/dist/execution/request.js.map +2 -2
- package/dist/http/api-routes.d.ts +1 -1
- package/dist/http/api-routes.d.ts.map +1 -1
- package/dist/http/index.js +1 -1
- package/dist/index.d.ts +10 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +96 -88
- package/dist/index.js.map +1 -1
- package/dist/lake-storage/errors.d.ts +15 -0
- package/dist/lake-storage/errors.d.ts.map +1 -1
- package/dist/lake-storage/index.d.ts +3 -2
- package/dist/lake-storage/index.d.ts.map +1 -1
- package/dist/lake-storage/index.js +16 -10
- package/dist/lake-storage/index.js.map +1 -1
- package/dist/lake-storage/maintenance.d.ts +88 -0
- package/dist/lake-storage/maintenance.d.ts.map +1 -0
- package/dist/lake-storage/merge.d.ts +3 -1
- package/dist/lake-storage/merge.d.ts.map +1 -1
- package/dist/lake-storage/source-ordering.d.ts +23 -0
- package/dist/lake-storage/source-ordering.d.ts.map +1 -1
- package/dist/lake-storage/types.d.ts +10 -0
- package/dist/lake-storage/types.d.ts.map +1 -1
- package/dist/maintenance/heartbeat.d.ts +5 -0
- package/dist/maintenance/heartbeat.d.ts.map +1 -0
- package/dist/maintenance/index.d.ts +4 -2
- package/dist/maintenance/index.d.ts.map +1 -1
- package/dist/maintenance/index.js +515 -0
- package/dist/maintenance/index.js.map +16 -0
- package/dist/maintenance/lake-retention-status.d.ts +36 -0
- package/dist/maintenance/lake-retention-status.d.ts.map +1 -0
- package/dist/maintenance/lake-retention.d.ts +84 -0
- package/dist/maintenance/lake-retention.d.ts.map +1 -0
- package/dist/maintenance/loop.d.ts +95 -0
- package/dist/maintenance/loop.d.ts.map +1 -0
- package/dist/maintenance/ontology-maintenance.d.ts +17 -16
- package/dist/maintenance/ontology-maintenance.d.ts.map +1 -1
- package/dist/maintenance/passes/cron-pass.d.ts +21 -0
- package/dist/maintenance/passes/cron-pass.d.ts.map +1 -0
- package/dist/maintenance/passes/directory-pass.d.ts +12 -0
- package/dist/maintenance/passes/directory-pass.d.ts.map +1 -0
- package/dist/maintenance/passes/ingest-pass.d.ts +26 -0
- package/dist/maintenance/passes/ingest-pass.d.ts.map +1 -0
- package/dist/maintenance/passes/lake-change-feed.d.ts +38 -0
- package/dist/maintenance/passes/lake-change-feed.d.ts.map +1 -0
- package/dist/maintenance/passes/lake-retention-pass.d.ts +20 -0
- package/dist/maintenance/passes/lake-retention-pass.d.ts.map +1 -0
- package/dist/maintenance/passes/ontology-pass.d.ts +8 -0
- package/dist/maintenance/passes/ontology-pass.d.ts.map +1 -0
- package/dist/maintenance/passes/projections-pass.d.ts +26 -0
- package/dist/maintenance/passes/projections-pass.d.ts.map +1 -0
- package/dist/maintenance/passes/recovery-pass.d.ts +6 -0
- package/dist/maintenance/passes/recovery-pass.d.ts.map +1 -0
- package/dist/maintenance/passes/recovery-passes.d.ts +24 -0
- package/dist/maintenance/passes/recovery-passes.d.ts.map +1 -0
- package/dist/maintenance/passes/runs-pass.d.ts +6 -0
- package/dist/maintenance/passes/runs-pass.d.ts.map +1 -0
- package/dist/maintenance/passes/triggers-pass.d.ts +41 -0
- package/dist/maintenance/passes/triggers-pass.d.ts.map +1 -0
- package/dist/maintenance/status.d.ts +19 -0
- package/dist/maintenance/status.d.ts.map +1 -0
- package/dist/maintenance/types.d.ts +25 -24
- package/dist/maintenance/types.d.ts.map +1 -1
- package/dist/materialization/model.d.ts +11 -2
- package/dist/materialization/model.d.ts.map +1 -1
- package/dist/materializer/edits/artifact-refs.d.ts +33 -0
- package/dist/materializer/edits/artifact-refs.d.ts.map +1 -0
- package/dist/materializer/edits/commit.d.ts.map +1 -1
- package/dist/materializer/edits/operations.d.ts +7 -1
- package/dist/materializer/edits/operations.d.ts.map +1 -1
- package/dist/materializer/edits/plan.d.ts.map +1 -1
- package/dist/materializer/execution/work-records.d.ts +6 -0
- package/dist/materializer/execution/work-records.d.ts.map +1 -1
- package/dist/materializer/index.js +31 -28
- package/dist/materializer/index.js.map +1 -1
- package/dist/materializer/projections/replacement-plan.d.ts.map +1 -1
- package/dist/materializer/shared/normalize.d.ts.map +1 -1
- package/dist/materializer/telemetry/plan.d.ts.map +1 -1
- package/dist/models/execution/index.js +30 -27
- package/dist/models/execution/index.js.map +1 -1
- package/dist/models/language-model.d.ts +6 -0
- package/dist/models/language-model.d.ts.map +1 -1
- package/dist/models/tools.d.ts +2 -0
- package/dist/models/tools.d.ts.map +1 -1
- package/dist/objects/artifact-refs.d.ts +5 -0
- package/dist/objects/artifact-refs.d.ts.map +1 -0
- package/dist/objects/index.js +59 -54
- package/dist/objects/index.js.map +1 -1
- package/dist/objects/materializer-adapter.d.ts +4 -3
- package/dist/objects/materializer-adapter.d.ts.map +1 -1
- package/dist/objects/object/upsert-batch.d.ts.map +1 -1
- package/dist/objects/object/upsert.d.ts.map +1 -1
- package/dist/objects/query/index.js +29 -26
- package/dist/objects/query/index.js.map +1 -1
- package/dist/objects/query/ir.d.ts +3 -1
- package/dist/objects/query/ir.d.ts.map +1 -1
- package/dist/objects/query/scalar-values.d.ts.map +1 -1
- package/dist/objects/runtime-batch.d.ts +2 -0
- package/dist/objects/runtime-batch.d.ts.map +1 -1
- package/dist/ontology/artifact-ref.d.ts +36 -0
- package/dist/ontology/artifact-ref.d.ts.map +1 -0
- package/dist/ontology/docs-markdown.d.ts.map +1 -1
- package/dist/ontology/index.d.ts +3 -1
- package/dist/ontology/index.d.ts.map +1 -1
- package/dist/ontology/index.js +8 -5
- package/dist/ontology/index.js.map +1 -1
- package/dist/ontology/inference/index.d.ts +2 -0
- package/dist/ontology/inference/index.d.ts.map +1 -1
- package/dist/ontology/internal.js +7 -6
- package/dist/ontology/internal.js.map +1 -1
- package/dist/ontology/json-schema.d.ts.map +1 -1
- package/dist/ontology/primitives.d.ts.map +1 -1
- package/dist/ontology/reference-values.d.ts +10 -0
- package/dist/ontology/reference-values.d.ts.map +1 -0
- package/dist/ontology/refs.d.ts +6 -1
- package/dist/ontology/refs.d.ts.map +1 -1
- package/dist/ontology/registry.d.ts +9 -1
- package/dist/ontology/registry.d.ts.map +1 -1
- package/dist/ontology/types.d.ts +2 -1
- package/dist/ontology/types.d.ts.map +1 -1
- package/dist/ontology/user-ref.d.ts +16 -0
- package/dist/ontology/user-ref.d.ts.map +1 -1
- package/dist/ontology/validation/normalize.d.ts.map +1 -1
- package/dist/ontology/validation/properties.d.ts.map +1 -1
- package/dist/ontology/validation/schema.d.ts.map +1 -1
- package/dist/pending-tasks.d.ts +17 -0
- package/dist/pending-tasks.d.ts.map +1 -0
- package/dist/pipelines/index.js +37 -34
- package/dist/pipelines/index.js.map +1 -1
- package/dist/pipelines/run-dispatch.d.ts +6 -0
- package/dist/pipelines/run-dispatch.d.ts.map +1 -1
- package/dist/predicates/types.d.ts +4 -0
- package/dist/predicates/types.d.ts.map +1 -1
- package/dist/projections/builders.d.ts +13 -11
- package/dist/projections/builders.d.ts.map +1 -1
- package/dist/projections/internal.js +30 -27
- package/dist/projections/internal.js.map +1 -1
- package/dist/projections/types.d.ts +1 -1
- package/dist/projections/types.d.ts.map +1 -1
- package/dist/projections/validation.d.ts +2 -2
- package/dist/projections/validation.d.ts.map +1 -1
- package/dist/queues/in-memory.d.ts +6 -1
- package/dist/queues/in-memory.d.ts.map +1 -1
- package/dist/queues/index.d.ts +1 -1
- package/dist/queues/index.d.ts.map +1 -1
- package/dist/queues/index.js +1 -1
- package/dist/queues/types.d.ts +55 -2
- package/dist/queues/types.d.ts.map +1 -1
- package/dist/runtime/create.d.ts +3 -0
- package/dist/runtime/create.d.ts.map +1 -1
- package/dist/runtime/host.d.ts +22 -5
- package/dist/runtime/host.d.ts.map +1 -1
- package/dist/runtime/index.d.ts +0 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/internal.d.ts +6 -0
- package/dist/runtime/internal.d.ts.map +1 -1
- package/dist/runtime/internal.js +52 -31
- package/dist/runtime/internal.js.map +1 -1
- package/dist/runtime/sixb.d.ts +6 -1
- package/dist/runtime/sixb.d.ts.map +1 -1
- package/dist/sandboxes/index.js +8 -7
- package/dist/sandboxes/index.js.map +1 -1
- package/dist/scheduler/index.d.ts +0 -2
- package/dist/scheduler/index.d.ts.map +1 -1
- package/dist/scheduler/index.js +3 -6
- package/dist/scheduler/index.js.map +1 -1
- package/dist/schedules/index.js +9 -11
- package/dist/schedules/index.js.map +1 -1
- package/dist/security/internal.js +1 -1
- package/dist/shared/backoff.d.ts +12 -0
- package/dist/shared/backoff.d.ts.map +1 -0
- package/dist/shared/duration.d.ts +3 -0
- package/dist/shared/duration.d.ts.map +1 -0
- package/dist/shared/params/artifact-refs.d.ts +19 -0
- package/dist/shared/params/artifact-refs.d.ts.map +1 -0
- package/dist/shares/guest-name.d.ts +8 -0
- package/dist/shares/guest-name.d.ts.map +1 -0
- package/dist/shares/internal.d.ts +1 -0
- package/dist/shares/internal.d.ts.map +1 -1
- package/dist/shares/internal.js +69 -28
- package/dist/shares/internal.js.map +3 -3
- package/dist/shares/session-protocol.d.ts +13 -0
- package/dist/shares/session-protocol.d.ts.map +1 -1
- package/dist/storage/action-runs/failure.js +2 -2
- package/dist/storage/agents/provider.js +1 -1
- package/dist/storage/agents/types.d.ts +1 -1
- package/dist/storage/agents/types.d.ts.map +1 -1
- package/dist/storage/ai-limits/enforcement.js +2 -2
- package/dist/storage/artifacts/errors.d.ts +9 -4
- package/dist/storage/artifacts/errors.d.ts.map +1 -1
- package/dist/storage/artifacts/in-memory.d.ts +27 -4
- package/dist/storage/artifacts/in-memory.d.ts.map +1 -1
- package/dist/storage/artifacts/index.d.ts +1 -1
- package/dist/storage/artifacts/index.d.ts.map +1 -1
- package/dist/storage/artifacts/record.d.ts +39 -2
- package/dist/storage/artifacts/record.d.ts.map +1 -1
- package/dist/storage/artifacts/types.d.ts +328 -39
- package/dist/storage/artifacts/types.d.ts.map +1 -1
- package/dist/storage/auth/in-memory/auth-storage.d.ts +2 -1
- package/dist/storage/auth/in-memory/auth-storage.d.ts.map +1 -1
- package/dist/storage/auth/in-memory/identities.d.ts +4 -0
- package/dist/storage/auth/in-memory/identities.d.ts.map +1 -1
- package/dist/storage/auth/in-memory/shared.d.ts +3 -1
- package/dist/storage/auth/in-memory/shared.d.ts.map +1 -1
- package/dist/storage/auth/in-memory/users.d.ts.map +1 -1
- package/dist/storage/auth/index.d.ts +1 -1
- package/dist/storage/auth/index.d.ts.map +1 -1
- package/dist/storage/auth/types.d.ts +39 -0
- package/dist/storage/auth/types.d.ts.map +1 -1
- package/dist/storage/connector-connections/in-memory.d.ts +1 -1
- package/dist/storage/connector-connections/in-memory.d.ts.map +1 -1
- package/dist/storage/connector-connections/index.d.ts +1 -1
- package/dist/storage/connector-connections/index.d.ts.map +1 -1
- package/dist/storage/connector-connections/provider/runs.d.ts.map +1 -1
- package/dist/storage/connector-connections/provider/shared.d.ts +12 -2
- package/dist/storage/connector-connections/provider/shared.d.ts.map +1 -1
- package/dist/storage/connector-connections/provider.d.ts +1 -0
- package/dist/storage/connector-connections/provider.d.ts.map +1 -1
- package/dist/storage/connector-connections/provider.js +21 -5
- package/dist/storage/connector-connections/provider.js.map +5 -5
- package/dist/storage/connector-connections/types.d.ts +1 -1
- package/dist/storage/connector-connections/types.d.ts.map +1 -1
- package/dist/storage/dataset-ingest/codec.d.ts +6 -0
- package/dist/storage/dataset-ingest/codec.d.ts.map +1 -0
- package/dist/storage/dataset-ingest/in-memory.d.ts +28 -0
- package/dist/storage/dataset-ingest/in-memory.d.ts.map +1 -0
- package/dist/storage/dataset-ingest/index.d.ts +4 -0
- package/dist/storage/dataset-ingest/index.d.ts.map +1 -0
- package/dist/storage/dataset-ingest/provider.d.ts +157 -0
- package/dist/storage/dataset-ingest/provider.d.ts.map +1 -0
- package/dist/storage/dataset-ingest/provider.js +17 -0
- package/dist/storage/dataset-ingest/provider.js.map +9 -0
- package/dist/storage/dataset-ingest/types.d.ts +188 -0
- package/dist/storage/dataset-ingest/types.d.ts.map +1 -0
- package/dist/storage/file-upload-sessions/provider.js +12 -11
- package/dist/storage/file-upload-sessions/provider.js.map +1 -1
- package/dist/storage/in-memory/index.d.ts +12 -0
- package/dist/storage/in-memory/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +18 -11
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +56 -46
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/internal.d.ts +4 -1
- package/dist/storage/internal.d.ts.map +1 -1
- package/dist/storage/internal.js +81 -5
- package/dist/storage/internal.js.map +4 -3
- package/dist/storage/lake-retention-runs/in-memory.d.ts +11 -0
- package/dist/storage/lake-retention-runs/in-memory.d.ts.map +1 -0
- package/dist/storage/lake-retention-runs/index.d.ts +3 -0
- package/dist/storage/lake-retention-runs/index.d.ts.map +1 -0
- package/dist/storage/lake-retention-runs/types.d.ts +21 -0
- package/dist/storage/lake-retention-runs/types.d.ts.map +1 -0
- package/dist/storage/maintenance-heartbeats/in-memory.d.ts +11 -0
- package/dist/storage/maintenance-heartbeats/in-memory.d.ts.map +1 -0
- package/dist/storage/maintenance-heartbeats/index.d.ts +3 -0
- package/dist/storage/maintenance-heartbeats/index.d.ts.map +1 -0
- package/dist/storage/maintenance-heartbeats/record.d.ts +11 -0
- package/dist/storage/maintenance-heartbeats/record.d.ts.map +1 -0
- package/dist/storage/maintenance-heartbeats/types.d.ts +30 -0
- package/dist/storage/maintenance-heartbeats/types.d.ts.map +1 -0
- package/dist/storage/objects/in-memory/query.d.ts.map +1 -1
- package/dist/storage/objects/in-memory/storage.d.ts +15 -1
- package/dist/storage/objects/in-memory/storage.d.ts.map +1 -1
- package/dist/storage/objects/read-scope.d.ts.map +1 -1
- package/dist/storage/objects/types.d.ts +18 -1
- package/dist/storage/objects/types.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/materializations.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/replacement-plans.d.ts.map +1 -1
- package/dist/storage/ontology/index.d.ts +1 -1
- package/dist/storage/ontology/index.d.ts.map +1 -1
- package/dist/storage/ontology/materializations.d.ts +20 -0
- package/dist/storage/ontology/materializations.d.ts.map +1 -1
- package/dist/storage/ontology/provider-work.d.ts +7 -1
- package/dist/storage/ontology/provider-work.d.ts.map +1 -1
- package/dist/storage/ontology/provider.js +1 -1
- package/dist/storage/pipeline-runs/in-memory.d.ts +8 -2
- package/dist/storage/pipeline-runs/in-memory.d.ts.map +1 -1
- package/dist/storage/pipeline-runs/index.d.ts +1 -1
- package/dist/storage/pipeline-runs/index.d.ts.map +1 -1
- package/dist/storage/pipeline-runs/provider.js +1 -1
- package/dist/storage/pipeline-runs/transitions.d.ts +2 -2
- package/dist/storage/pipeline-runs/transitions.d.ts.map +1 -1
- package/dist/storage/pipeline-runs/types.d.ts +26 -6
- package/dist/storage/pipeline-runs/types.d.ts.map +1 -1
- package/dist/storage/projection-runs/errors.d.ts +6 -0
- package/dist/storage/projection-runs/errors.d.ts.map +1 -1
- package/dist/storage/projection-runs/in-memory.d.ts +5 -1
- package/dist/storage/projection-runs/in-memory.d.ts.map +1 -1
- package/dist/storage/projection-runs/index.d.ts +2 -2
- package/dist/storage/projection-runs/index.d.ts.map +1 -1
- package/dist/storage/projection-runs/lifecycle.d.ts +1 -0
- package/dist/storage/projection-runs/lifecycle.d.ts.map +1 -1
- package/dist/storage/projection-runs/provider.js +2 -2
- package/dist/storage/projection-runs/types.d.ts +16 -0
- package/dist/storage/projection-runs/types.d.ts.map +1 -1
- package/dist/storage/run-claim.d.ts +132 -0
- package/dist/storage/run-claim.d.ts.map +1 -0
- package/dist/storage/share-grants/provider.js +3 -3
- package/dist/storage/share-sessions/in-memory.d.ts +2 -1
- package/dist/storage/share-sessions/in-memory.d.ts.map +1 -1
- package/dist/storage/share-sessions/index.d.ts +1 -1
- package/dist/storage/share-sessions/index.d.ts.map +1 -1
- package/dist/storage/share-sessions/provider.d.ts +1 -1
- package/dist/storage/share-sessions/provider.d.ts.map +1 -1
- package/dist/storage/share-sessions/provider.js +4 -2
- package/dist/storage/share-sessions/provider.js.map +1 -1
- package/dist/storage/share-sessions/record.d.ts +2 -1
- package/dist/storage/share-sessions/record.d.ts.map +1 -1
- package/dist/storage/share-sessions/types.d.ts +17 -1
- package/dist/storage/share-sessions/types.d.ts.map +1 -1
- package/dist/storage/sync-runs/in-memory.d.ts +10 -2
- package/dist/storage/sync-runs/in-memory.d.ts.map +1 -1
- package/dist/storage/sync-runs/index.d.ts +1 -1
- package/dist/storage/sync-runs/index.d.ts.map +1 -1
- package/dist/storage/sync-runs/transitions.d.ts +2 -2
- package/dist/storage/sync-runs/transitions.d.ts.map +1 -1
- package/dist/storage/sync-runs/types.d.ts +29 -3
- package/dist/storage/sync-runs/types.d.ts.map +1 -1
- package/dist/storage/types.d.ts +12 -6
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/storage/webhook-runs/in-memory.d.ts +2 -1
- package/dist/storage/webhook-runs/in-memory.d.ts.map +1 -1
- package/dist/storage/webhook-runs/index.d.ts +2 -2
- package/dist/storage/webhook-runs/index.d.ts.map +1 -1
- package/dist/storage/webhook-runs/types.d.ts +33 -2
- package/dist/storage/webhook-runs/types.d.ts.map +1 -1
- package/dist/storage/workflow-runs/in-memory.d.ts +6 -3
- package/dist/storage/workflow-runs/in-memory.d.ts.map +1 -1
- package/dist/storage/workflow-runs/index.d.ts +1 -1
- package/dist/storage/workflow-runs/index.d.ts.map +1 -1
- package/dist/storage/workflow-runs/provider.js +12 -11
- package/dist/storage/workflow-runs/provider.js.map +1 -1
- package/dist/storage/workflow-runs/types.d.ts +11 -28
- package/dist/storage/workflow-runs/types.d.ts.map +1 -1
- package/dist/syncs/index.js +38 -35
- package/dist/syncs/index.js.map +1 -1
- package/dist/syncs/run-dispatch.d.ts +2 -0
- package/dist/syncs/run-dispatch.d.ts.map +1 -1
- package/dist/testing/ai-model-call-groups-contract.d.ts.map +1 -1
- package/dist/testing/artifact-holders-contract.d.ts +15 -0
- package/dist/testing/artifact-holders-contract.d.ts.map +1 -0
- package/dist/testing/artifact-storage-contract.d.ts.map +1 -1
- package/dist/testing/auth-storage-contract.d.ts.map +1 -1
- package/dist/testing/broker-contract.d.ts.map +1 -1
- package/dist/testing/connector-connection-storage-contract.d.ts +1 -1
- package/dist/testing/connector-connection-storage-contract.d.ts.map +1 -1
- package/dist/testing/dataset-ingest-storage-contract.d.ts +11 -0
- package/dist/testing/dataset-ingest-storage-contract.d.ts.map +1 -0
- package/dist/testing/dataset-sequence-contract.d.ts +1 -1
- package/dist/testing/dataset-sequence-contract.d.ts.map +1 -1
- package/dist/testing/execution.d.ts.map +1 -1
- package/dist/testing/index.d.ts +8 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +6245 -3192
- package/dist/testing/index.js.map +28 -19
- package/dist/testing/lake-retention-run-storage-contract.d.ts +9 -0
- package/dist/testing/lake-retention-run-storage-contract.d.ts.map +1 -0
- package/dist/testing/maintenance-heartbeat-storage-contract.d.ts +9 -0
- package/dist/testing/maintenance-heartbeat-storage-contract.d.ts.map +1 -0
- package/dist/testing/object-query-contract.d.ts.map +1 -1
- package/dist/testing/pipeline-execution.d.ts.map +1 -1
- package/dist/testing/pipeline-run-read-contract.d.ts +13 -0
- package/dist/testing/pipeline-run-read-contract.d.ts.map +1 -0
- package/dist/testing/projection-run-storage-contract.d.ts.map +1 -1
- package/dist/testing/queues-contract.d.ts.map +1 -1
- package/dist/testing/run-claim-storage-contract.d.ts +12 -0
- package/dist/testing/run-claim-storage-contract.d.ts.map +1 -0
- package/dist/testing/run-claim.d.ts +30 -0
- package/dist/testing/run-claim.d.ts.map +1 -0
- package/dist/testing/run-recovery-contract.d.ts +49 -0
- package/dist/testing/run-recovery-contract.d.ts.map +1 -0
- package/dist/testing/share-session-storage-contract.d.ts.map +1 -1
- package/dist/testing/stored-artifacts.d.ts +10 -0
- package/dist/testing/stored-artifacts.d.ts.map +1 -0
- package/dist/testing/sync-execution.d.ts.map +1 -1
- package/dist/testing/webhook-execution.d.ts +1 -1
- package/dist/testing/webhook-execution.d.ts.map +1 -1
- package/dist/testing/webhook-run-storage-contract.d.ts.map +1 -1
- package/dist/users/execution.d.ts +18 -1
- package/dist/users/execution.d.ts.map +1 -1
- package/dist/users/index.d.ts +1 -1
- package/dist/users/index.d.ts.map +1 -1
- package/dist/webhooks/delivery-lease.d.ts +13 -0
- package/dist/webhooks/delivery-lease.d.ts.map +1 -0
- package/dist/webhooks/internal.d.ts +2 -0
- package/dist/webhooks/internal.d.ts.map +1 -1
- package/dist/webhooks/internal.js +68 -36
- package/dist/webhooks/internal.js.map +5 -4
- package/dist/webhooks/run-admission.d.ts.map +1 -1
- package/dist/workers/index.d.ts +5 -1
- package/dist/workers/index.d.ts.map +1 -1
- package/dist/workers/index.js +193 -58
- package/dist/workers/index.js.map +8 -7
- package/dist/workers/job-ids.d.ts +17 -0
- package/dist/workers/job-ids.d.ts.map +1 -0
- package/dist/workers/lost-projection-runs.d.ts +26 -0
- package/dist/workers/lost-projection-runs.d.ts.map +1 -0
- package/dist/workers/lost-runs.d.ts +51 -0
- package/dist/workers/lost-runs.d.ts.map +1 -0
- package/dist/workers/queue-delivery.d.ts.map +1 -1
- package/dist/workers/queue-worker.d.ts +1 -2
- package/dist/workers/queue-worker.d.ts.map +1 -1
- package/dist/workers/queued-run-dispatch.d.ts +90 -0
- package/dist/workers/queued-run-dispatch.d.ts.map +1 -0
- package/dist/workers/run-lease.d.ts +25 -0
- package/dist/workers/run-lease.d.ts.map +1 -0
- package/dist/workers/run-worker.d.ts +95 -0
- package/dist/workers/run-worker.d.ts.map +1 -0
- package/dist/workflows/index.js +64 -58
- package/dist/workflows/index.js.map +1 -1
- package/dist/workflows/request.d.ts.map +1 -1
- package/dist/workflows/run-dispatch.d.ts +6 -1
- package/dist/workflows/run-dispatch.d.ts.map +1 -1
- package/package.json +41 -3
- package/src/actions/request.ts +24 -7
- package/src/actions/run/executor.ts +9 -42
- package/src/actions/types/context.ts +8 -3
- package/src/agents/approval-outcome.ts +2 -2
- package/src/agents/cancel.ts +2 -2
- package/src/agents/child-question.ts +76 -8
- package/src/agents/execution.ts +11 -3
- package/src/agents/fork.ts +12 -4
- package/src/agents/ids.ts +4 -1
- package/src/agents/index.ts +16 -3
- package/src/agents/model-loop.ts +3 -1
- package/src/agents/request.ts +42 -31
- package/src/agents/run-artifacts.ts +290 -46
- package/src/agents/run-session-children.ts +33 -0
- package/src/agents/run-session-http.ts +5 -0
- package/src/agents/run-session-serve.ts +11 -0
- package/src/agents/run-session.ts +8 -1
- package/src/agents/streams/protocol.ts +5 -10
- package/src/agents/tool-files.ts +1 -1
- package/src/agents/tool-input-coercion.ts +140 -0
- package/src/agents/validation.ts +12 -1
- package/src/artifacts/access.ts +71 -28
- package/src/artifacts/canvas-display.ts +160 -0
- package/src/artifacts/canvas.ts +26 -1
- package/src/artifacts/comment-text.ts +32 -0
- package/src/artifacts/comments.ts +275 -0
- package/src/artifacts/errors.ts +6 -1
- package/src/artifacts/events.ts +58 -0
- package/src/artifacts/execution.ts +496 -53
- package/src/artifacts/frames/assets.ts +20 -1
- package/src/artifacts/frames/grants.ts +31 -10
- package/src/artifacts/frames/index.ts +2 -0
- package/src/artifacts/frames/kit.ts +8 -5
- package/src/artifacts/frames/protocol.ts +231 -0
- package/src/artifacts/frames/runtime.ts +600 -29
- package/src/artifacts/holders.ts +120 -0
- package/src/artifacts/ids.ts +8 -0
- package/src/artifacts/index.ts +31 -2
- package/src/artifacts/limits.ts +28 -4
- package/src/artifacts/live/board.ts +759 -0
- package/src/artifacts/live/diff.ts +297 -0
- package/src/artifacts/live/document.ts +354 -0
- package/src/artifacts/live/files.ts +82 -0
- package/src/artifacts/live/index.ts +50 -0
- package/src/artifacts/live/presence.ts +144 -0
- package/src/artifacts/live/protocol.ts +134 -0
- package/src/artifacts/live/server.ts +16 -0
- package/src/artifacts/live/state.ts +115 -0
- package/src/artifacts/outline.ts +12 -0
- package/src/artifacts/publish/index.ts +26 -1
- package/src/artifacts/publish/merge.ts +271 -0
- package/src/artifacts/publish/previews.ts +485 -0
- package/src/artifacts/publish/publish.ts +92 -39
- package/src/artifacts/publish/query-answers.ts +85 -0
- package/src/artifacts/publish/references.ts +10 -4
- package/src/artifacts/publish/validate/canvas.ts +133 -1
- package/src/artifacts/theme.ts +9 -1
- package/src/auth/directory.ts +166 -0
- package/src/auth/member-events.ts +10 -3
- package/src/auth/runtime.ts +108 -8
- package/src/auth/strategy.ts +3 -1
- package/src/auth/types.ts +44 -0
- package/src/authorization/decision.ts +6 -5
- package/src/authorization/event-visibility.ts +4 -0
- package/src/broker/in-memory.ts +33 -6
- package/src/broker/types.ts +4 -0
- package/src/connectors/builders.ts +34 -2
- package/src/connectors/connections/access.ts +83 -0
- package/src/connectors/connections/contracts.ts +6 -1
- package/src/connectors/connections/execution.ts +2 -2
- package/src/connectors/connections/runs.ts +51 -2
- package/src/connectors/connections/service.ts +208 -41
- package/src/connectors/connections/views.ts +11 -4
- package/src/connectors/execution.ts +27 -3
- package/src/connectors/index.ts +2 -0
- package/src/connectors/service.ts +12 -0
- package/src/connectors/types.ts +37 -2
- package/src/datasets/execution.ts +74 -37
- package/src/datasets/ingest-flush-batch.ts +289 -0
- package/src/datasets/ingest-flush-job.ts +112 -0
- package/src/datasets/ingest-flush.ts +377 -0
- package/src/datasets/produced-version.ts +55 -0
- package/src/datasets/write.ts +65 -11
- package/src/deploy/services.ts +1 -1
- package/src/deploy/types.ts +2 -3
- package/src/deploy/validation.ts +1 -0
- package/src/error-reporting/capability.ts +66 -0
- package/src/error-reporting/internal.ts +12 -0
- package/src/error-reporting/reporter.ts +11 -35
- package/src/error-reporting/reports.ts +167 -0
- package/src/error-reporting/types.ts +99 -0
- package/src/errors/catalog.ts +6 -0
- package/src/events/definitions.ts +14 -0
- package/src/events/execution.ts +77 -28
- package/src/events/index.ts +3 -0
- package/src/events/scope.ts +2 -0
- package/src/events/types/artifacts.ts +40 -0
- package/src/events/types/index.ts +3 -0
- package/src/events/types/users.ts +5 -2
- package/src/execution/authorized-object-reader.ts +34 -0
- package/src/execution/object-reader-clearance.ts +31 -0
- package/src/execution/object-reader-security.ts +33 -13
- package/src/http/api-routes.ts +106 -5
- package/src/index.ts +22 -4
- package/src/lake-storage/errors.ts +21 -0
- package/src/lake-storage/index.ts +9 -1
- package/src/lake-storage/maintenance.ts +93 -0
- package/src/lake-storage/merge.ts +3 -1
- package/src/lake-storage/source-ordering.ts +28 -2
- package/src/lake-storage/types.ts +14 -0
- package/src/maintenance/heartbeat.ts +14 -0
- package/src/maintenance/index.ts +5 -3
- package/src/maintenance/lake-retention-status.ts +81 -0
- package/src/maintenance/lake-retention.ts +347 -0
- package/src/maintenance/loop.ts +365 -0
- package/src/maintenance/ontology-maintenance.ts +76 -229
- package/src/maintenance/passes/cron-pass.ts +217 -0
- package/src/maintenance/passes/directory-pass.ts +22 -0
- package/src/maintenance/passes/ingest-pass.ts +94 -0
- package/src/maintenance/passes/lake-change-feed.ts +112 -0
- package/src/maintenance/passes/lake-retention-pass.ts +71 -0
- package/src/maintenance/passes/ontology-pass.ts +19 -0
- package/src/maintenance/passes/projections-pass.ts +238 -0
- package/src/maintenance/passes/recovery-pass.ts +17 -0
- package/src/maintenance/passes/recovery-passes.ts +39 -0
- package/src/maintenance/passes/runs-pass.ts +12 -0
- package/src/maintenance/passes/triggers-pass.ts +332 -0
- package/src/maintenance/status.ts +75 -0
- package/src/maintenance/types.ts +27 -25
- package/src/materialization/model.ts +33 -21
- package/src/materializer/README.md +13 -2
- package/src/materializer/edits/artifact-refs.ts +140 -0
- package/src/materializer/edits/commit.ts +20 -7
- package/src/materializer/edits/operations.ts +23 -7
- package/src/materializer/edits/plan.ts +2 -0
- package/src/materializer/execution/work-records.ts +61 -0
- package/src/materializer/projections/replacement-plan.ts +2 -0
- package/src/materializer/shared/normalize.ts +14 -0
- package/src/materializer/telemetry/plan.ts +2 -0
- package/src/models/language-model.ts +6 -0
- package/src/models/tools.ts +2 -0
- package/src/objects/artifact-refs.ts +34 -0
- package/src/objects/materializer-adapter.ts +8 -3
- package/src/objects/object/upsert-batch.ts +7 -0
- package/src/objects/object/upsert.ts +11 -2
- package/src/objects/query/ir.ts +2 -0
- package/src/objects/query/scalar-values.ts +5 -3
- package/src/objects/runtime-batch.ts +8 -1
- package/src/objects/vectors/README.md +4 -4
- package/src/ontology/artifact-ref.ts +83 -0
- package/src/ontology/docs-markdown.ts +17 -0
- package/src/ontology/index.ts +3 -1
- package/src/ontology/inference/index.ts +2 -0
- package/src/ontology/json-schema.ts +13 -0
- package/src/ontology/primitives.ts +14 -0
- package/src/ontology/reference-values.ts +62 -0
- package/src/ontology/refs.ts +7 -1
- package/src/ontology/registry.ts +26 -1
- package/src/ontology/types.ts +2 -0
- package/src/ontology/user-ref.ts +35 -45
- package/src/ontology/validation/normalize.ts +13 -0
- package/src/ontology/validation/properties.ts +9 -0
- package/src/ontology/validation/schema.ts +12 -0
- package/src/pending-tasks.ts +51 -0
- package/src/pipelines/run-dispatch.ts +120 -238
- package/src/predicates/types.ts +2 -1
- package/src/projections/builders.ts +28 -13
- package/src/projections/run-dispatch.ts +1 -1
- package/src/projections/types.ts +1 -1
- package/src/projections/validation.ts +22 -8
- package/src/queues/in-memory.ts +50 -3
- package/src/queues/index.ts +4 -0
- package/src/queues/types.ts +68 -1
- package/src/runtime/create.ts +4 -0
- package/src/runtime/host.ts +118 -13
- package/src/runtime/index.ts +0 -1
- package/src/runtime/internal.ts +13 -0
- package/src/runtime/ontology-mutations.ts +1 -1
- package/src/runtime/sixb.ts +14 -5
- package/src/scheduler/index.ts +0 -2
- package/src/shared/backoff.ts +34 -0
- package/src/shared/duration.ts +15 -0
- package/src/shared/params/artifact-refs.ts +42 -0
- package/src/shares/compiler.ts +1 -1
- package/src/shares/guest-name.ts +20 -0
- package/src/shares/internal.ts +1 -0
- package/src/shares/session-protocol.ts +63 -0
- package/src/storage/agents/types.ts +1 -1
- package/src/storage/artifacts/errors.ts +10 -2
- package/src/storage/artifacts/in-memory.ts +579 -96
- package/src/storage/artifacts/index.ts +22 -1
- package/src/storage/artifacts/record.ts +255 -11
- package/src/storage/artifacts/types.ts +343 -40
- package/src/storage/auth/in-memory/auth-storage.ts +42 -5
- package/src/storage/auth/in-memory/identities.ts +16 -0
- package/src/storage/auth/in-memory/shared.ts +15 -0
- package/src/storage/auth/in-memory/users.ts +17 -16
- package/src/storage/auth/index.ts +3 -0
- package/src/storage/auth/types.ts +38 -0
- package/src/storage/connector-connections/in-memory.ts +4 -1
- package/src/storage/connector-connections/index.ts +1 -0
- package/src/storage/connector-connections/provider/runs.ts +3 -0
- package/src/storage/connector-connections/provider/shared.ts +30 -0
- package/src/storage/connector-connections/provider.ts +4 -0
- package/src/storage/connector-connections/types.ts +1 -0
- package/src/storage/dataset-ingest/codec.ts +90 -0
- package/src/storage/dataset-ingest/in-memory.ts +277 -0
- package/src/storage/dataset-ingest/index.ts +16 -0
- package/src/storage/dataset-ingest/provider.ts +592 -0
- package/src/storage/dataset-ingest/types.ts +191 -0
- package/src/storage/in-memory/index.ts +33 -0
- package/src/storage/index.ts +65 -5
- package/src/storage/internal.ts +20 -0
- package/src/storage/lake-retention-runs/in-memory.ts +22 -0
- package/src/storage/lake-retention-runs/index.ts +2 -0
- package/src/storage/lake-retention-runs/types.ts +19 -0
- package/src/storage/maintenance-heartbeats/in-memory.ts +24 -0
- package/src/storage/maintenance-heartbeats/index.ts +7 -0
- package/src/storage/maintenance-heartbeats/record.ts +50 -0
- package/src/storage/maintenance-heartbeats/types.ts +30 -0
- package/src/storage/objects/in-memory/query.ts +1 -0
- package/src/storage/objects/in-memory/storage.ts +81 -0
- package/src/storage/objects/read-scope.ts +1 -0
- package/src/storage/objects/types.ts +16 -1
- package/src/storage/ontology/in-memory/materializations.ts +8 -0
- package/src/storage/ontology/in-memory/replacement-plans.ts +4 -1
- package/src/storage/ontology/index.ts +2 -0
- package/src/storage/ontology/materializations.ts +18 -0
- package/src/storage/ontology/provider-work.ts +39 -0
- package/src/storage/pipeline-runs/in-memory.ts +97 -24
- package/src/storage/pipeline-runs/index.ts +0 -1
- package/src/storage/pipeline-runs/provider.ts +1 -1
- package/src/storage/pipeline-runs/transitions.ts +7 -4
- package/src/storage/pipeline-runs/types.ts +33 -7
- package/src/storage/projection-runs/errors.ts +10 -0
- package/src/storage/projection-runs/in-memory.ts +56 -1
- package/src/storage/projection-runs/index.ts +2 -1
- package/src/storage/projection-runs/lifecycle.ts +9 -1
- package/src/storage/projection-runs/types.ts +20 -1
- package/src/storage/run-claim.ts +224 -0
- package/src/storage/share-sessions/in-memory.ts +21 -0
- package/src/storage/share-sessions/index.ts +1 -0
- package/src/storage/share-sessions/provider.ts +1 -0
- package/src/storage/share-sessions/record.ts +28 -0
- package/src/storage/share-sessions/types.ts +19 -1
- package/src/storage/sync-runs/in-memory.ts +109 -29
- package/src/storage/sync-runs/index.ts +1 -1
- package/src/storage/sync-runs/transitions.ts +7 -4
- package/src/storage/sync-runs/types.ts +36 -3
- package/src/storage/types.ts +15 -5
- package/src/storage/webhook-runs/in-memory.ts +26 -2
- package/src/storage/webhook-runs/index.ts +3 -1
- package/src/storage/webhook-runs/types.ts +44 -3
- package/src/storage/workflow-runs/in-memory.ts +50 -36
- package/src/storage/workflow-runs/index.ts +0 -2
- package/src/storage/workflow-runs/types.ts +18 -30
- package/src/syncs/run-dispatch.ts +118 -239
- package/src/testing/ai-model-call-groups-contract.ts +2 -1
- package/src/testing/artifact-holders-contract.ts +392 -0
- package/src/testing/artifact-storage-contract.ts +1205 -151
- package/src/testing/auth-storage-contract.ts +228 -1
- package/src/testing/broker-contract.ts +56 -0
- package/src/testing/connector-connection-storage-contract.ts +94 -5
- package/src/testing/dataset-ingest-storage-contract.ts +480 -0
- package/src/testing/dataset-sequence-contract.ts +97 -12
- package/src/testing/execution.ts +23 -0
- package/src/testing/index.ts +31 -0
- package/src/testing/lake-retention-run-storage-contract.ts +75 -0
- package/src/testing/maintenance-heartbeat-storage-contract.ts +99 -0
- package/src/testing/object-query-contract.ts +93 -0
- package/src/testing/pipeline-execution.ts +3 -1
- package/src/testing/pipeline-run-read-contract.ts +123 -0
- package/src/testing/projection-run-storage-contract.ts +113 -0
- package/src/testing/queues-contract.ts +112 -0
- package/src/testing/run-claim-storage-contract.ts +736 -0
- package/src/testing/run-claim.ts +69 -0
- package/src/testing/run-recovery-contract.ts +176 -0
- package/src/testing/share-session-storage-contract.ts +43 -0
- package/src/testing/stored-artifacts.ts +43 -0
- package/src/testing/sync-execution.ts +3 -1
- package/src/testing/webhook-execution.ts +7 -2
- package/src/testing/webhook-run-storage-contract.ts +102 -5
- package/src/users/execution.ts +50 -2
- package/src/users/index.ts +1 -0
- package/src/webhooks/delivery-lease.ts +40 -0
- package/src/webhooks/internal.ts +2 -0
- package/src/webhooks/run-admission.ts +22 -9
- package/src/workers/README.md +169 -0
- package/src/workers/index.ts +9 -1
- package/src/workers/job-ids.ts +31 -0
- package/src/workers/lost-projection-runs.ts +114 -0
- package/src/workers/lost-runs.ts +397 -0
- package/src/workers/queue-delivery.ts +2 -14
- package/src/workers/queue-worker.ts +9 -17
- package/src/workers/queued-run-dispatch.ts +308 -0
- package/src/workers/run-lease.ts +46 -0
- package/src/workers/run-worker.ts +312 -0
- package/src/workers/worker.ts +4 -17
- package/src/workflows/request.ts +2 -0
- package/src/workflows/run-dispatch.ts +22 -4
- package/src/workflows/snapshot.ts +1 -0
- package/dist/chunk-2g0r46hy.js.map +0 -12
- package/dist/chunk-3fqxbn31.js +0 -107
- package/dist/chunk-3fqxbn31.js.map +0 -11
- package/dist/chunk-4s753g3k.js +0 -314
- package/dist/chunk-4s753g3k.js.map +0 -12
- package/dist/chunk-5kyvrtjh.js.map +0 -12
- package/dist/chunk-5taem5aw.js.map +0 -10
- package/dist/chunk-65abf64x.js +0 -13
- package/dist/chunk-65abf64x.js.map +0 -10
- package/dist/chunk-9x8dybsb.js.map +0 -10
- package/dist/chunk-az47zep4.js +0 -41
- package/dist/chunk-az47zep4.js.map +0 -10
- package/dist/chunk-c706qvyc.js +0 -299
- package/dist/chunk-c706qvyc.js.map +0 -11
- package/dist/chunk-djs3hw9p.js.map +0 -20
- package/dist/chunk-dsv783c3.js.map +0 -47
- package/dist/chunk-e5wf5vz0.js.map +0 -10
- package/dist/chunk-e6xgz4h4.js.map +0 -21
- package/dist/chunk-e7v3trpz.js.map +0 -10
- package/dist/chunk-eqgr6nsa.js.map +0 -72
- package/dist/chunk-fb3feg1e.js +0 -298
- package/dist/chunk-fb3feg1e.js.map +0 -12
- package/dist/chunk-hz5d43gn.js.map +0 -10
- package/dist/chunk-j8thxj7w.js.map +0 -22
- package/dist/chunk-jbw70d6t.js.map +0 -10
- package/dist/chunk-jftd33rc.js.map +0 -11
- package/dist/chunk-jspskey0.js.map +0 -10
- package/dist/chunk-kfee1h52.js.map +0 -13
- package/dist/chunk-kwfhd1g0.js +0 -144
- package/dist/chunk-kwfhd1g0.js.map +0 -13
- package/dist/chunk-nz7815t3.js.map +0 -14
- package/dist/chunk-s3we74h8.js.map +0 -12
- package/dist/chunk-scyq22td.js.map +0 -12
- package/dist/chunk-w1btn96n.js.map +0 -44
- package/dist/chunk-w976a4me.js.map +0 -10
- package/dist/chunk-wkq3kvzd.js.map +0 -10
- package/dist/chunk-wrjx1fqz.js +0 -587
- package/dist/chunk-wrjx1fqz.js.map +0 -18
- package/dist/chunk-yw9pyg66.js +0 -143
- package/dist/chunk-yw9pyg66.js.map +0 -11
- package/dist/chunk-z8fx5cgb.js.map +0 -11
- package/dist/scheduler/runtime.d.ts +0 -40
- package/dist/scheduler/runtime.d.ts.map +0 -1
- package/dist/workers/unstarted-run.d.ts +0 -10
- package/dist/workers/unstarted-run.d.ts.map +0 -1
- package/src/scheduler/runtime.ts +0 -214
- package/src/workers/unstarted-run.ts +0 -18
- /package/dist/{chunk-80gym75n.js.map → chunk-186k5yz3.js.map} +0 -0
- /package/dist/{chunk-ga63a3dz.js.map → chunk-2bn6813a.js.map} +0 -0
- /package/dist/{chunk-ytzcxtpt.js.map → chunk-3ba89vm7.js.map} +0 -0
- /package/dist/{chunk-d04g36fw.js.map → chunk-5qqmndhm.js.map} +0 -0
- /package/dist/{chunk-5wtnmpze.js.map → chunk-7qe46788.js.map} +0 -0
- /package/dist/{chunk-31kcqmhf.js.map → chunk-855w9nvw.js.map} +0 -0
- /package/dist/{chunk-9whfmsfk.js.map → chunk-8tqnsx3q.js.map} +0 -0
- /package/dist/{chunk-s038wa5v.js.map → chunk-b9qfh2ya.js.map} +0 -0
- /package/dist/{chunk-jjmggm9a.js.map → chunk-fe6r7yhg.js.map} +0 -0
- /package/dist/{chunk-165c9wm6.js.map → chunk-g2ph4873.js.map} +0 -0
- /package/dist/{chunk-4zm1k3xj.js.map → chunk-r2psmn42.js.map} +0 -0
- /package/dist/{chunk-2ajw5rz0.js.map → chunk-rsxb14an.js.map} +0 -0
- /package/dist/{chunk-r1cxq7vv.js.map → chunk-rtdrm592.js.map} +0 -0
- /package/dist/{chunk-4bm0caep.js.map → chunk-smnt672s.js.map} +0 -0
- /package/dist/{chunk-21q0j5f2.js.map → chunk-stmxh0hv.js.map} +0 -0
- /package/dist/{chunk-ff5xkv0p.js.map → chunk-tfzvjdms.js.map} +0 -0
- /package/dist/{chunk-6b61s40c.js.map → chunk-w3t94hm6.js.map} +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/storage/action-runs/idempotency.ts", "../src/storage/action-runs/record.ts", "../src/storage/errors.ts", "../src/storage/activity/policy.ts", "../src/storage/artifacts/errors.ts", "../src/storage/artifacts/record.ts", "../src/storage/file-download-grants/record.ts", "../src/storage/pipeline-runs/idempotency.ts", "../src/storage/pipeline-runs/transitions.ts", "../src/storage/sync-runs/idempotency.ts", "../src/storage/sync-runs/transitions.ts", "../src/storage/transaction.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import type { ActionSubject } from \"../../actions\"\nimport { stableJsonStringify } from \"../../json\"\nimport type { ActionRunEffectsRecord, ActionRunRecord, ActionRunWritebackRecord } from \"./types\"\n\nexport function actionSubjectsEqual(left: ActionSubject, right: ActionSubject): boolean {\n if (left.kind !== right.kind) return false\n if (left.kind === \"none\") return true\n if (right.kind === \"none\") return false\n return left.objectTypeId === right.objectTypeId && left.primaryId === right.primaryId\n}\n\nexport function actionRunParamsEqual(left: unknown, right: unknown): boolean {\n return stableJsonStringify(left) === stableJsonStringify(right)\n}\n\n/** Whether two runs carry the same request: the same Action, subject, and params. */\nexport function actionRunRequestsEqual(\n left: Pick<ActionRunRecord, \"actionId\" | \"subject\" | \"params\">,\n right: Pick<ActionRunRecord, \"actionId\" | \"subject\" | \"params\">\n): boolean {\n return (\n left.actionId === right.actionId &&\n actionSubjectsEqual(left.subject, right.subject) &&\n actionRunParamsEqual(left.params, right.params)\n )\n}\n\nexport type ActionRunPhaseRecord = ActionRunWritebackRecord | ActionRunEffectsRecord\n\nexport function actionRunPhaseRecordsEqual(\n left: ActionRunPhaseRecord,\n right: ActionRunPhaseRecord\n): boolean {\n return actionRunParamsEqual(stripPhaseRecordCompletedAt(left), stripPhaseRecordCompletedAt(right))\n}\n\nfunction stripPhaseRecordCompletedAt(\n record: ActionRunPhaseRecord\n): Omit<ActionRunPhaseRecord, \"completedAt\"> {\n const { completedAt: _completedAt, ...stableRecord } = record\n return stableRecord\n}\n",
|
|
6
|
+
"import { assertJsonValue, cloneJsonValue } from \"../../json\"\nimport { ActionRunError } from \"./errors\"\nimport { parseActionRunFailure } from \"./failure\"\nimport { actionRunPhaseRecordsEqual } from \"./idempotency\"\nimport type {\n ActionRunEffectsRecord,\n ActionRunRecord,\n ActionRunWritebackRecord,\n RecordActionEffectsInput,\n RecordActionRunInput,\n} from \"./types\"\nimport { ACTION_RUN_PHASES } from \"./types\"\n\n/**\n * Validate a terminal run record before a provider inserts it, and detach it from the caller.\n *\n * Every provider records through this, so a stored run always reads back as the record that was\n * written: a failed run carries the failure of the phase it ended in, and a succeeded one none. A\n * run is recorded before its effects run, so no record starts in the `effects` phase.\n */\nexport function normalizeRecordActionRunInput(input: RecordActionRunInput): RecordActionRunInput {\n const label = `[Sixb] Action run '${input.id}'`\n for (const field of [\"id\", \"projectId\", \"executionId\", \"actionId\", \"idempotencyKey\"] as const) {\n if (typeof input[field] !== \"string\" || input[field].trim().length === 0) {\n throw new ActionRunError(`${label} must have a nonblank ${field}.`)\n }\n }\n const status: string = input.status\n if (status !== \"succeeded\" && status !== \"failed\") {\n throw new ActionRunError(`${label} has unknown status '${status}'.`)\n }\n if (!(ACTION_RUN_PHASES as readonly string[]).includes(input.phase)) {\n throw new ActionRunError(`${label} has unknown phase '${input.phase}'.`)\n }\n if (input.phase === \"effects\") {\n throw new ActionRunError(`${label} is recorded before its effects run.`)\n }\n const startedAt = requireDate(input.startedAt, `${label} startedAt`)\n const finishedAt = requireDate(input.finishedAt, `${label} finishedAt`)\n if (finishedAt < startedAt) {\n throw new ActionRunError(`${label} cannot finish before it started.`)\n }\n assertJsonValue(input.params, `${label} params`)\n\n const fields = {\n id: input.id,\n projectId: input.projectId,\n executionId: input.executionId,\n actionId: input.actionId,\n subject: structuredClone(input.subject),\n phase: input.phase,\n startedAt,\n finishedAt,\n params: structuredClone(input.params),\n idempotencyKey: input.idempotencyKey,\n ...(input.writeback === undefined\n ? {}\n : { writeback: normalizeWriteback(input.writeback, label) }),\n }\n\n if (input.status === \"succeeded\") {\n if (input.error !== undefined) {\n throw new ActionRunError(`${label} succeeded, so it cannot record a failure.`)\n }\n return { ...fields, status: \"succeeded\" }\n }\n const error = parseActionRunFailure(input.error, input.phase)\n if (error.details.runId !== input.id || error.details.actionId !== input.actionId) {\n throw new ActionRunError(`${label} records the failure of another run.`)\n }\n return { ...fields, status: \"failed\", error }\n}\n\n/**\n * Resolve what recording effects does to the stored run: write `effects`, or nothing (`null`) when\n * an equal outcome is already recorded.\n *\n * Effects run only after a succeeded run committed its edits, and their outcome is recorded once.\n */\nexport function resolveActionRunEffects(\n existing: ActionRunRecord | null,\n input: RecordActionEffectsInput\n): { readonly run: ActionRunRecord; readonly effects: ActionRunEffectsRecord | null } {\n const label = `[Sixb] Action run '${input.id}'`\n if (!existing) {\n throw new ActionRunError(`${label} not found for project '${input.projectId}'.`)\n }\n const completedAt = requireDate(input.completedAt ?? new Date(), `${label} effects`)\n const effects: ActionRunEffectsRecord =\n input.status === \"succeeded\"\n ? { status: \"succeeded\", completedAt }\n : { status: \"failed\", completedAt, error: parseActionRunFailure(input.error, \"effects\") }\n\n if (existing.effects) {\n if (actionRunPhaseRecordsEqual(existing.effects, effects))\n return { run: existing, effects: null }\n throw new ActionRunError(`${label} already has a different effects record.`)\n }\n if (existing.status !== \"succeeded\" || existing.phase !== \"commit\") {\n throw new ActionRunError(\n `${label} cannot record effects: it ended '${existing.status}' in phase '${existing.phase}'.`\n )\n }\n return { run: existing, effects }\n}\n\nfunction normalizeWriteback(\n writeback: ActionRunWritebackRecord,\n label: string\n): ActionRunWritebackRecord {\n const completedAt = requireDate(writeback.completedAt, `${label} writeback`)\n if (writeback.status === \"succeeded\") {\n assertJsonValue(writeback.result, `${label} writeback result`)\n return { status: \"succeeded\", completedAt, result: cloneJsonValue(writeback.result) }\n }\n return {\n status: \"failed\",\n completedAt,\n error: parseActionRunFailure(writeback.error, \"writeback\"),\n }\n}\n\n/** A detached copy of `value`, which must be a valid date. */\nfunction requireDate(value: Date, label: string): Date {\n const date = value instanceof Date ? new Date(value) : new Date(Number.NaN)\n if (!Number.isFinite(date.getTime())) {\n throw new ActionRunError(`${label} must be a valid date.`)\n }\n return date\n}\n",
|
|
7
|
+
"/**\n * Thrown when a storage lookup by primary ID finds no matching object.\n * Carries structured context so callers can discriminate without string parsing.\n */\nexport class ObjectNotFoundError extends Error {\n readonly name = \"ObjectNotFoundError\"\n\n constructor(\n readonly objectTypeId: string,\n readonly primaryId: string,\n readonly context: string\n ) {\n super(`[Sixb] ${context}: ${objectTypeId}:${primaryId}`)\n }\n}\n\nexport class ObjectStorageError extends Error {\n readonly name = \"ObjectStorageError\"\n}\n\nexport type StorageTransactionErrorCode =\n | \"nested_transaction\"\n | \"serialization_failure\"\n | \"transaction_inactive\"\n\nexport interface StorageTransactionErrorOptions {\n readonly cause?: unknown\n readonly code?: StorageTransactionErrorCode\n}\n\nexport class StorageTransactionError extends Error {\n readonly name = \"StorageTransactionError\"\n readonly code?: StorageTransactionErrorCode\n override readonly cause?: unknown\n\n constructor(message: string, options: StorageTransactionErrorOptions = {}) {\n super(message)\n this.code = options.code\n this.cause = options.cause\n }\n}\n\nexport function isStorageSerializationFailure(error: unknown): boolean {\n return error instanceof StorageTransactionError && error.code === \"serialization_failure\"\n}\n",
|
|
8
|
+
"/**\n * The activity rules every provider shares: validation, retries, quota, visit assignment and\n * sequence. Providers own atomicity and their queries; see `src/activity/README.md`.\n */\nimport type {\n ActivityActor,\n ActivityAttribution,\n ActivityDay,\n ActivityEventInput,\n ActivityInteraction,\n ActivityPageView,\n AppendActivityInput,\n} from \"./types\"\n\n// The HTTP schemas share these, so the API and the providers refuse the same inputs.\nexport const ACTIVITY_BATCH_LIMIT = 20\nexport const ACTIVITY_EVENT_ID_PATTERN = /^[a-zA-Z0-9_-]{1,80}$/\nexport const ACTIVITY_VISIT_ID_PATTERN = /^[a-zA-Z0-9_-]{1,128}$/\nexport const ACTIVITY_HOSTNAME_PATTERN =\n /^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\\.)*[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/\n/** A UTM label: any text without control characters. */\nexport const ACTIVITY_LABEL_PATTERN = /^[^\\x00-\\x1f\\x7f]*$/\nexport const ACTIVITY_LABEL_MAX_LENGTH = 100\nexport const ACTIVITY_REFERRER_MAX_LENGTH = 253\nexport const ACTIVITY_ROUTE_MAX_LENGTH = 512\nexport const ACTIVITY_ID_MAX_LENGTH = 256\n/**\n * An interaction name: lowercase dotted segments, each starting with a letter and at most 40\n * characters, such as `invoices.row.open`, without a run of four digits. A segment that starts\n * with a digit, or holds a long number, is usually a value, which names never carry. No pattern\n * catches every value: names are meant to be constants.\n */\nexport const ACTIVITY_INTERACTION_NAME_PATTERN =\n /^(?!.*\\d{4})[a-z][a-z0-9_-]{0,39}(?:\\.[a-z][a-z0-9_-]{0,39})*$/\nexport const ACTIVITY_INTERACTION_NAME_MAX_LENGTH = 100\nexport const ACTIVITY_MAX_PERIOD_MS = 31 * 24 * 60 * 60_000\nexport const ACTIVITY_MAX_PAGE_SIZE = 100\n\nexport const ACTIVITY_SOURCE_LIMIT_PER_MINUTE = 120\nexport const ACTIVITY_MIN_IDLE_TIMEOUT_MS = 60_000\n/** A visit ends at its next event once this old, so a period query bounds `started_at`. */\nexport const ACTIVITY_MAX_VISIT_MS = 24 * 60 * 60_000\n\nconst QUOTA_WINDOW_MS = 60_000\nconst DAY_MS = 86_400_000\nconst ATTRIBUTION_KEYS = [\"source\", \"medium\", \"campaign\", \"referrer\"] as const\n\n/** What a provider keeps per session between batches, read and written under its lock. */\nexport interface ActivitySourceState {\n readonly visitId: string\n /** When the current visit started; `null` once that visit was deleted. Epoch milliseconds. */\n readonly visitStartedAt: number | null\n /** Epoch milliseconds. Never moves backwards. */\n readonly lastSeenAt: number\n /** Sequence of the visit's last stored event, page view or interaction. */\n readonly sequence: number\n readonly windowStart: number\n readonly windowCount: number\n}\n\n/** A page view or an interaction already stored for the session, compared with a retry of it. */\nexport interface StoredActivityEvent {\n readonly id: string\n readonly route: string\n /** Set for an interaction only. */\n readonly name?: string\n readonly attribution?: ActivityAttribution\n}\n\n/** A page view to insert. Its own attribution is kept only to recognize a retry. */\nexport interface PlannedActivityPageView extends ActivityPageView {\n readonly attribution?: ActivityAttribution\n}\n\nexport type ActivityAppendPlan =\n | { readonly status: \"duplicate\" }\n | { readonly status: \"throttled\" }\n | {\n readonly status: \"append\"\n /** Set when the batch starts a visit, with the arrival that visit keeps. */\n readonly newVisit: { readonly attribution: ActivityAttribution | null } | null\n readonly pageViews: readonly PlannedActivityPageView[]\n readonly interactions: readonly ActivityInteraction[]\n /** Events counted against the quota: page views, activity and interactions alike. */\n readonly accepted: number\n readonly state: ActivitySourceState\n }\n\nexport function validateActivityEvents(events: readonly ActivityEventInput[]): void {\n if (!Array.isArray(events) || events.length === 0 || events.length > ACTIVITY_BATCH_LIMIT) {\n throw new Error(`[Sixb] Activity batches must contain 1 to ${ACTIVITY_BATCH_LIMIT} events.`)\n }\n\n const ids = new Set<string>()\n for (const event of events) {\n if (\n !event ||\n typeof event.id !== \"string\" ||\n !ACTIVITY_EVENT_ID_PATTERN.test(event.id) ||\n ids.has(event.id)\n ) {\n throw new Error(\"[Sixb] Activity event ids must be unique, nonempty identifiers.\")\n }\n ids.add(event.id)\n\n if (\n event.type !== \"page.view\" &&\n event.type !== \"visit.activity\" &&\n event.type !== \"ui.interaction\"\n ) {\n throw new Error(\"[Sixb] Unknown activity event type.\")\n }\n\n if (!isActivityRoutePattern(event.route)) {\n throw new Error(\n \"[Sixb] Activity routes must be normalized file-router patterns without URL parameters.\"\n )\n }\n\n if (event.type !== \"ui.interaction\") {\n serializeActivityAttribution(event.attribution)\n continue\n }\n\n if (!isActivityInteractionName(event.name)) {\n throw new Error(\n `[Sixb] Activity interaction names are lowercase dotted identifiers such as \"invoices.export\": each segment starts with a letter, holds at most 40 characters and no run of four digits, and the name at most ${ACTIVITY_INTERACTION_NAME_MAX_LENGTH}.`\n )\n }\n\n // An interaction is its name, route and time: the arrival travels with page views.\n if (Reflect.get(event, \"attribution\") !== undefined) {\n throw new Error(\"[Sixb] Activity interactions carry no attribution.\")\n }\n }\n}\n\nexport function validateActivityAppend(input: AppendActivityInput): void {\n validateActivityEvents(input.events)\n\n if (input.actor.type !== \"user\" && input.actor.type !== \"share\") {\n throw new Error(\"[Sixb] Invalid activity actor.\")\n }\n\n const actorId = input.actor.type === \"user\" ? input.actor.userId : input.actor.grantId\n for (const value of [input.projectId, input.sessionId, input.newVisitId, actorId]) {\n if (typeof value !== \"string\" || !value.trim() || value.length > ACTIVITY_ID_MAX_LENGTH) {\n throw new Error(\"[Sixb] Invalid activity identity.\")\n }\n }\n\n if (\n !Number.isFinite(input.now.getTime()) ||\n !Number.isSafeInteger(input.idleTimeoutMs) ||\n input.idleTimeoutMs < ACTIVITY_MIN_IDLE_TIMEOUT_MS\n ) {\n throw new Error(\"[Sixb] Invalid activity clock or inactivity window.\")\n }\n}\n\n/**\n * Plans one batch for one session. `current` is the session's state, absent before its first\n * batch; `stored` holds its page views and interactions whose ids appear in the batch.\n */\nexport function planActivityAppend(\n input: AppendActivityInput,\n current: ActivitySourceState | undefined,\n stored: readonly StoredActivityEvent[]\n): ActivityAppendPlan {\n const fresh = input.events.filter((event) => !isRetry(event, stored))\n if (fresh.length === 0) {\n return { status: \"duplicate\" }\n }\n\n // A server clock stepping back must not reorder a visit.\n const now = Math.max(input.now.getTime(), current?.lastSeenAt ?? 0)\n\n const windowOpen = current !== undefined && now - current.windowStart < QUOTA_WINDOW_MS\n const windowStart = windowOpen ? current.windowStart : now\n const windowCount = windowOpen ? current.windowCount : 0\n if (windowCount + fresh.length > ACTIVITY_SOURCE_LIMIT_PER_MINUTE) {\n return { status: \"throttled\" }\n }\n\n const continued = continuesVisit(current, now, input.idleTimeoutMs) ? current : undefined\n const visitId = continued?.visitId ?? input.newVisitId\n const previousSequence = continued?.sequence ?? 0\n\n // Page views and interactions share the visit's sequence, in the order the batch sent them.\n const pageViews: PlannedActivityPageView[] = []\n const interactions: ActivityInteraction[] = []\n let sequence = previousSequence\n\n fresh.forEach((event, index) => {\n const receivedAt = new Date(now)\n const opensVisit = !continued && index === 0\n\n if (event.type === \"ui.interaction\") {\n // Like activity, an interaction that opens a visit starts it on its page. The page view's\n // id is derived outside the event-id alphabet, so no browser event can claim it.\n if (opensVisit) {\n sequence += 1\n pageViews.push({\n id: `${event.id}.page`,\n visitId,\n sequence,\n route: event.route,\n receivedAt,\n attribution: {},\n })\n }\n\n sequence += 1\n interactions.push({\n id: event.id,\n visitId,\n sequence,\n name: event.name,\n route: event.route,\n receivedAt,\n })\n return\n }\n\n // A visit opened by activity, someone back on a page after inactivity, starts on that page.\n if (event.type === \"page.view\" || opensVisit) {\n sequence += 1\n pageViews.push({\n id: event.id,\n visitId,\n sequence,\n route: event.route,\n receivedAt,\n ...(event.attribution === undefined\n ? {}\n : { attribution: structuredClone(event.attribution) }),\n })\n }\n })\n\n // An interaction carries no arrival: the visit it opens reads as direct.\n const first = fresh[0]\n const arrival = first?.type === \"ui.interaction\" ? {} : first?.attribution\n\n return {\n status: \"append\",\n newVisit: continued ? null : { attribution: cloneAttribution(arrival) },\n pageViews,\n interactions,\n accepted: fresh.length,\n state: {\n visitId,\n visitStartedAt: continued ? continued.visitStartedAt : now,\n lastSeenAt: now,\n sequence,\n windowStart,\n windowCount: windowCount + fresh.length,\n },\n }\n}\n\n/**\n * A visit continues while it is active and younger than a day. One whose row was deleted cannot:\n * the next event starts another.\n */\nfunction continuesVisit(\n current: ActivitySourceState | undefined,\n now: number,\n idleTimeoutMs: number\n): current is ActivitySourceState {\n return (\n current !== undefined &&\n current.visitStartedAt !== null &&\n now - current.lastSeenAt < idleTimeoutMs &&\n now - current.visitStartedAt < ACTIVITY_MAX_VISIT_MS\n )\n}\n\n/**\n * An event whose id is already stored is a retry, and must say the same thing. Stored rows are\n * page views, the activity that opened a visit, and interactions; either of the first two types\n * can retry a page view. Other activity is not stored, and is never recognized as a retry.\n */\nfunction isRetry(event: ActivityEventInput, stored: readonly StoredActivityEvent[]): boolean {\n const previous = stored.find((candidate) => candidate.id === event.id)\n if (!previous) {\n return false\n }\n\n const same =\n event.type === \"ui.interaction\"\n ? event.name === previous.name && event.route === previous.route\n : previous.name === undefined &&\n event.route === previous.route &&\n serializeActivityAttribution(event.attribution) ===\n serializeActivityAttribution(previous.attribution)\n\n if (!same) {\n throw new Error(\"[Sixb] Activity event id was reused with different content.\")\n }\n\n return true\n}\n\n/**\n * Each UTC day of `[from, to)` that a visit overlaps, with its page views. A visit across midnight\n * counts on both days.\n */\nexport function activityCalendarDays(\n period: { readonly from: Date; readonly to: Date },\n visits: readonly { readonly startedAt: Date; readonly lastSeenAt: Date }[],\n pageViewsByDay: ReadonlyMap<string, number>\n): ActivityDay[] {\n const visitsByDay = new Map<string, number>()\n const from = period.from.getTime()\n const last = period.to.getTime() - 1\n\n for (const visit of visits) {\n const firstDay = Math.floor(Math.max(visit.startedAt.getTime(), from) / DAY_MS)\n const lastDay = Math.floor(Math.min(visit.lastSeenAt.getTime(), last) / DAY_MS)\n\n for (let day = firstDay; day <= lastDay; day++) {\n const key = activityDay(day * DAY_MS)\n visitsByDay.set(key, (visitsByDay.get(key) ?? 0) + 1)\n }\n }\n\n const days = new Set([...visitsByDay.keys(), ...pageViewsByDay.keys()])\n return [...days].sort().map((day) => ({\n day,\n visits: visitsByDay.get(day) ?? 0,\n pageViews: pageViewsByDay.get(day) ?? 0,\n }))\n}\n\n/** The UTC calendar day of an instant, as `YYYY-MM-DD`. */\nexport function activityDay(at: Date | number): string {\n return new Date(at).toISOString().slice(0, 10)\n}\n\nexport function activityActor(\n type: string,\n userId: string | null,\n grantId: string | null\n): ActivityActor {\n if (type === \"user\" && userId) {\n return { type, userId }\n }\n if (type === \"share\" && grantId) {\n return { type, grantId }\n }\n throw new Error(\"[Sixb] Stored activity actor is invalid.\")\n}\n\n/** Canonical JSON, so a retry matches whatever order its keys come in. `undefined` stays null. */\nexport function serializeActivityAttribution(value: unknown): string | null {\n if (value === undefined) {\n return null\n }\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n throw new Error(\"[Sixb] Invalid activity attribution.\")\n }\n if (Object.keys(value).some((key) => !ATTRIBUTION_KEYS.some((field) => field === key))) {\n throw new Error(\"[Sixb] Unknown activity attribution field.\")\n }\n\n const result: Record<string, string> = {}\n for (const key of ATTRIBUTION_KEYS) {\n const text: unknown = Reflect.get(value, key)\n if (text === undefined) {\n continue\n }\n\n const maxLength = key === \"referrer\" ? ACTIVITY_REFERRER_MAX_LENGTH : ACTIVITY_LABEL_MAX_LENGTH\n if (!isAttributionLabel(text, maxLength)) {\n throw new Error(\"[Sixb] Activity attribution requires bounded, nonempty labels.\")\n }\n if (key === \"referrer\" && !ACTIVITY_HOSTNAME_PATTERN.test(text)) {\n throw new Error(\"[Sixb] Activity referrer must be a hostname, not a URL.\")\n }\n\n result[key] = text\n }\n\n return JSON.stringify(result)\n}\n\nexport function parseActivityAttribution(value: string | null): ActivityAttribution | null {\n if (value === null) {\n return null\n }\n\n const data: unknown = JSON.parse(value)\n serializeActivityAttribution(data)\n // The check above limits every key and value to the attribution contract.\n return data as ActivityAttribution\n}\n\nfunction cloneAttribution(value: ActivityAttribution | undefined): ActivityAttribution | null {\n return value === undefined ? null : structuredClone(value)\n}\n\nfunction isAttributionLabel(value: unknown, maxLength: number): value is string {\n return (\n typeof value === \"string\" &&\n value.length > 0 &&\n value.length <= maxLength &&\n value === value.trim() &&\n ACTIVITY_LABEL_PATTERN.test(value)\n )\n}\n\nfunction isActivityInteractionName(value: unknown): value is string {\n return (\n typeof value === \"string\" &&\n value.length <= ACTIVITY_INTERACTION_NAME_MAX_LENGTH &&\n ACTIVITY_INTERACTION_NAME_PATTERN.test(value)\n )\n}\n\n/** A file-router pattern: rooted, normalized, without a query, fragment or escape. */\nexport function isActivityRoutePattern(value: unknown): value is string {\n return (\n typeof value === \"string\" &&\n value.length <= ACTIVITY_ROUTE_MAX_LENGTH &&\n value.startsWith(\"/\") &&\n !value.includes(\"//\") &&\n !/[?#%\\s\\x00-\\x1f]/.test(value)\n )\n}\n",
|
|
9
|
+
"import type { Principal } from \"../../auth\"\n\nexport type ArtifactStorageErrorCode =\n | \"artifact_exists\"\n | \"artifact_not_found\"\n | \"artifact_kind_mismatch\"\n | \"artifact_moved\"\n | \"artifact_state_full\"\n | \"artifact_comments_full\"\n | \"comment_not_found\"\n | \"restore_point_not_found\"\n\n/**\n * Where an artifact had moved on to when a write found it moved: its latest version, its\n * revision, who last wrote that version's content, and, once it was created, who created it.\n */\nexport interface ArtifactLatestVersion {\n readonly version: number\n readonly revision: number\n readonly author: Principal\n readonly frozenBy?: Principal\n}\n\n/** Error for artifact-storage invariants. Callers branch on `code` rather than message text. */\nexport class ArtifactStorageError extends Error {\n readonly name = \"ArtifactStorageError\"\n\n constructor(\n readonly code: ArtifactStorageErrorCode,\n message: string,\n /** With `artifact_moved`: where the artifact is, which the write was not based on. */\n readonly latest?: ArtifactLatestVersion\n ) {\n super(message)\n }\n}\n",
|
|
10
|
+
"import { isArtifactKind } from \"../../artifacts/kinds\"\nimport { ARTIFACT_COMMENT_LIMITS, ARTIFACT_STATE_LIMITS } from \"../../artifacts/limits\"\nimport type { ArtifactOutline } from \"../../artifacts/outline\"\nimport type { ArtifactReference } from \"../../artifacts/references\"\nimport { type Principal, principalsEqual } from \"../../auth\"\nimport { isFileRef } from \"../../blob-storage\"\nimport { type ArtifactLatestVersion, ArtifactStorageError } from \"./errors\"\nimport type {\n ArtifactBoardPreviewRecord,\n ArtifactCommentAuthor,\n ArtifactCommentRecord,\n ArtifactDocument,\n ArtifactFile,\n ArtifactFrameGrantRecord,\n ArtifactFrameTarget,\n ArtifactKind,\n ArtifactRecord,\n ArtifactRestorePointRecord,\n ArtifactStateEntry,\n ArtifactTurnWriteRecord,\n ArtifactVersionRecord,\n} from \"./types\"\n\n// Rows arrive from providers with camelCase keys. JSON columns may arrive parsed (jsonb) or as text\n// (SQLite), and timestamps as `Date` or ISO text. A row that does not read back as a valid record\n// fails closed rather than rendering something the store never held.\n\ntype Row = { readonly [column: string]: unknown }\n\nexport function parseArtifactRow(row: Row): ArtifactRecord {\n const id = text(row.id, \"id\", \"artifact\")\n const where = `artifact '${id}'`\n const kind = row.kind\n if (!isArtifactKind(kind)) throw corrupt(where, \"kind is not an artifact kind\")\n return {\n projectId: text(row.projectId, \"projectId\", where),\n id,\n kind,\n title: text(row.title, \"title\", where),\n owner: principal(row.ownerPrincipalType, row.ownerPrincipalId, \"owner\", where),\n latestVersion: positiveInteger(row.latestVersion, \"latestVersion\", where),\n revision: positiveInteger(row.revision, \"revision\", where),\n createdAt: date(row.createdAt, \"createdAt\", where),\n updatedAt: date(row.updatedAt, \"updatedAt\", where),\n ...document(row.document, row.documentRevision, where),\n }\n}\n\n/** The artifact's Yjs document, when it keeps one, and the revision it holds. */\nfunction document(\n value: unknown,\n revision: unknown,\n where: string\n): { readonly document?: ArtifactDocument } {\n if ((value == null) !== (revision == null)) {\n throw corrupt(where, \"document and documentRevision are not both set\")\n }\n if (value == null) return {}\n const file = json(value, \"document\", where)\n if (!isFileRef(file)) throw corrupt(where, \"document is not a file reference\")\n return { document: { file, revision: positiveInteger(revision, \"documentRevision\", where) } }\n}\n\nexport function parseArtifactVersionRow(row: Row): ArtifactVersionRecord {\n const artifactId = text(row.artifactId, \"artifactId\", \"artifact version\")\n const version = positiveInteger(row.version, \"version\", `artifact '${artifactId}'`)\n const where = `artifact '${artifactId}' version ${version}`\n return {\n projectId: text(row.projectId, \"projectId\", where),\n artifactId,\n version,\n revision: positiveInteger(row.revision, \"revision\", where),\n ...content(row, where),\n createdAt: date(row.createdAt, \"createdAt\", where),\n updatedAt: date(row.updatedAt, \"updatedAt\", where),\n ...frozen(row, where),\n }\n}\n\n/** When, and by whom, a version was created: both or neither. */\nfunction frozen(row: Row, where: string) {\n if ((row.frozenAt == null) !== (row.frozenByPrincipalType == null)) {\n throw corrupt(where, \"a frozen version names who froze it, and an open one does not\")\n }\n if (row.frozenAt == null) return {}\n\n return {\n frozenAt: date(row.frozenAt, \"frozenAt\", where),\n frozenBy: principal(row.frozenByPrincipalType, row.frozenByPrincipalId, \"frozenBy\", where),\n }\n}\n\nexport function parseArtifactRestorePointRow(row: Row): ArtifactRestorePointRecord {\n const artifactId = text(row.artifactId, \"artifactId\", \"artifact restore point\")\n const revision = positiveInteger(row.revision, \"revision\", `artifact '${artifactId}'`)\n const where = `restore point of artifact '${artifactId}' at revision ${revision}`\n const reason = row.reason\n if (reason !== \"turn\" && reason !== \"restore\")\n throw corrupt(where, \"reason is not turn or restore\")\n if ((reason === \"turn\") !== (row.turnRunId != null)) {\n throw corrupt(where, \"a turn's restore point names its run, and only it does\")\n }\n return {\n projectId: text(row.projectId, \"projectId\", where),\n artifactId,\n revision,\n version: positiveInteger(row.version, \"version\", where),\n frozen: flag(row.frozen, \"frozen\", where),\n ...content(row, where),\n updatedAt: date(row.updatedAt, \"updatedAt\", where),\n reason,\n ...(reason === \"turn\" ? { turnRunId: text(row.turnRunId, \"turnRunId\", where) } : {}),\n createdAt: date(row.createdAt, \"createdAt\", where),\n }\n}\n\nexport function parseArtifactTurnWriteRow(row: Row): ArtifactTurnWriteRecord {\n const artifactId = text(row.artifactId, \"artifactId\", \"artifact turn write\")\n const where = `turn write to artifact '${artifactId}'`\n return {\n artifactId,\n created: flag(row.created, \"created\", where),\n revision: positiveInteger(row.revision, \"revision\", where),\n writes: positiveInteger(row.writes, \"writes\", where),\n }\n}\n\n/**\n * Whether a retry may undo a turn's writes to an artifact: nobody else changed it since the turn\n * began. Every change moves an artifact's revision by exactly one, so the turn's writes alone took\n * it from its restore point's revision, or from nothing when the turn created it, to `revision`;\n * a write, a version created, or a restore by anyone else between two of them leaves it further.\n * And the version the restore point held open must still be open: undoing never rewrites or\n * reopens a version someone created.\n */\nexport function turnUndoable(input: {\n readonly write: Pick<ArtifactTurnWriteRecord, \"created\" | \"writes\">\n /** The artifact's revision now. */\n readonly revision: number\n /** The turn's restore point; none for an artifact the turn created. */\n readonly point?: Pick<ArtifactRestorePointRecord, \"revision\" | \"frozen\">\n /** The version the restore point was taken of, as it is now; none when it is gone. */\n readonly target?: { readonly frozen: boolean }\n}): boolean {\n const { write, revision, point, target } = input\n if (write.created) return revision === write.writes\n\n if (!point || !target) return false\n if (target.frozen && !point.frozen) return false\n\n return revision - point.revision === write.writes\n}\n\n/**\n * Whether someone other than a retried turn and its requester commented on an artifact the turn\n * created. Their words would go with it, so a retry keeps it, as it keeps one someone else wrote:\n * a comment never moves the revision, which is all `turnUndoable` reads.\n */\nexport function othersCommented(\n comments: readonly Pick<ArtifactCommentRecord, \"author\" | \"origin\">[],\n turn: { readonly turnRunId: string; readonly requester?: Principal }\n): boolean {\n return comments.some(({ author, origin }) => {\n if (origin?.runId === turn.turnRunId) return false\n return !turn.requester || author.type === \"guest\" || !principalsEqual(author, turn.requester)\n })\n}\n\n/** What a version or a restore point holds, and who last wrote it from where. */\nfunction content(row: Row, where: string) {\n const originThreadId = row.originThreadId\n const originRunId = row.originRunId\n if ((originThreadId == null) !== (originRunId == null)) {\n throw corrupt(where, \"origin needs both a thread and a run\")\n }\n return {\n title: text(row.title, \"title\", where),\n entry: text(row.entry, \"entry\", where),\n files: files(json(row.files, \"files\", where), where),\n outline: outline(json(row.outline, \"outline\", where), where),\n references: references(json(row.refs, \"refs\", where), where),\n author: principal(row.authorPrincipalType, row.authorPrincipalId, \"author\", where),\n ...(originThreadId == null\n ? {}\n : {\n origin: {\n threadId: text(originThreadId, \"originThreadId\", where),\n runId: text(originRunId, \"originRunId\", where),\n },\n }),\n }\n}\n\n/** Targets are checked one by one: they decide what a frame may show from other artifacts. */\nexport function parseArtifactFrameGrantRow(row: Row): ArtifactFrameGrantRecord {\n const artifactId = text(row.artifactId, \"artifactId\", \"artifact frame grant\")\n const where = `frame grant for artifact '${artifactId}'`\n return {\n projectId: text(row.projectId, \"projectId\", where),\n tokenHash: text(row.tokenHash, \"tokenHash\", where),\n artifactId,\n version: positiveInteger(row.version, \"version\", where),\n filesDigest: text(row.filesDigest, \"filesDigest\", where),\n targets: frameTargets(json(row.targets, \"targets\", where), where),\n createdAt: date(row.createdAt, \"createdAt\", where),\n expiresAt: date(row.expiresAt, \"expiresAt\", where),\n }\n}\n\nexport function parseArtifactBoardPreviewRow(row: Row): ArtifactBoardPreviewRecord {\n const renderKey = text(row.renderKey, \"renderKey\", \"board preview\")\n const where = `board preview '${renderKey}'`\n const theme = row.theme\n if (theme !== \"light\" && theme !== \"dark\") throw corrupt(where, \"theme is not light or dark\")\n const size = row.size\n if (size !== \"full\" && size !== \"small\") throw corrupt(where, \"size is not full or small\")\n const file = json(row.file, \"file\", where)\n if (!isFileRef(file)) throw corrupt(where, \"file is not a file reference\")\n return {\n projectId: text(row.projectId, \"projectId\", where),\n renderKey,\n theme,\n size,\n file,\n createdAt: date(row.createdAt, \"createdAt\", where),\n }\n}\n\nexport function parseArtifactStateRow(row: Row): ArtifactStateEntry {\n const key = text(row.key, \"key\", \"artifact state\")\n const where = `artifact state '${key}'`\n const sizeBytes = Number(row.sizeBytes)\n if (!Number.isSafeInteger(sizeBytes) || sizeBytes < 0) {\n throw corrupt(where, \"sizeBytes is not a byte count\")\n }\n return {\n key,\n value: text(row.value, \"value\", where),\n sizeBytes,\n updatedAt: date(row.updatedAt, \"updatedAt\", where),\n }\n}\n\n/** A value's UTF-8 bytes, which a reader's state limits count. */\nexport function artifactStateBytes(value: string): number {\n return new TextEncoder().encode(value).byteLength\n}\n\n/**\n * Throws `artifact_state_full` when a value would take a reader past `ARTIFACT_STATE_LIMITS`.\n * `others` is what the reader keeps under every other key, so replacing a value counts once.\n */\nexport function checkArtifactStateWrite(input: {\n readonly key: string\n readonly valueBytes: number\n readonly others: { readonly keys: number; readonly bytes: number }\n}): void {\n const limits = ARTIFACT_STATE_LIMITS\n if (input.valueBytes > limits.maxValueBytes) {\n throw artifactStorageErrors.stateFull(\n `[Sixb] '${input.key}' is ${kilobytes(input.valueBytes)}; a page keeps at most ${kilobytes(limits.maxValueBytes)} under one key.`\n )\n }\n if (input.others.keys + 1 > limits.maxKeys) {\n throw artifactStorageErrors.stateFull(\n `[Sixb] A page keeps at most ${limits.maxKeys} keys for each reader: delete one before keeping '${input.key}'.`\n )\n }\n if (input.others.bytes + input.valueBytes > limits.maxBytes) {\n throw artifactStorageErrors.stateFull(\n `[Sixb] A page keeps at most ${kilobytes(limits.maxBytes)} for each reader; '${input.key}' would take it to ${kilobytes(input.others.bytes + input.valueBytes)}.`\n )\n }\n}\n\nfunction kilobytes(bytes: number): string {\n return `${Math.ceil(bytes / 1024).toLocaleString(\"en-US\")} KB`\n}\n\n/** The errors every provider raises, with one wording. */\nexport const artifactStorageErrors = {\n exists: (id: string) =>\n new ArtifactStorageError(\"artifact_exists\", `[Sixb] Artifact '${id}' already exists.`),\n notFound: (id: string) =>\n new ArtifactStorageError(\"artifact_not_found\", `[Sixb] Artifact '${id}' was not found.`),\n kindMismatch: (id: string, kind: ArtifactKind, requested: ArtifactKind) =>\n new ArtifactStorageError(\n \"artifact_kind_mismatch\",\n `[Sixb] Artifact '${id}' is a ${kind}; it cannot take a ${requested} version.`\n ),\n moved: (id: string, baseRevision: number, latest: ArtifactLatestVersion) =>\n new ArtifactStorageError(\n \"artifact_moved\",\n `[Sixb] Artifact '${id}' changed since revision ${baseRevision}, which this was based on: it is at revision ${latest.revision}, version ${latest.version}${latest.frozenBy ? `, which ${latest.frozenBy.type} '${latest.frozenBy.id}' created` : \"\"}.`,\n latest\n ),\n restorePointNotFound: (id: string, revision: number) =>\n new ArtifactStorageError(\n \"restore_point_not_found\",\n `[Sixb] Artifact '${id}' keeps no restore point of revision ${revision}.`\n ),\n stateFull: (message: string) => new ArtifactStorageError(\"artifact_state_full\", message),\n commentNotFound: (artifactId: string, id: string) =>\n new ArtifactStorageError(\n \"comment_not_found\",\n `[Sixb] Artifact '${artifactId}' has no comment '${id}' to reply to.`\n ),\n commentsFull: (artifactId: string) =>\n new ArtifactStorageError(\n \"artifact_comments_full\",\n `[Sixb] Artifact '${artifactId}' holds ${ARTIFACT_COMMENT_LIMITS.maxComments} comments, as many as it may: delete some first.`\n ),\n guestCommentsFull: (artifactId: string) =>\n new ArtifactStorageError(\n \"artifact_comments_full\",\n `[Sixb] Guests have left ${ARTIFACT_COMMENT_LIMITS.maxGuestComments} comments on artifact '${artifactId}', as many as they may: a member can delete some.`\n ),\n}\n\nexport function parseArtifactCommentRow(row: Row): ArtifactCommentRecord {\n const id = text(row.id, \"id\", \"artifact comment\")\n const where = `artifact comment '${id}'`\n if ((row.resolvedAt == null) !== (row.resolvedByPrincipalType == null)) {\n throw corrupt(where, \"resolvedAt and resolvedBy are not both set\")\n }\n const anchor = json(row.anchor, \"anchor\", where)\n if (!isObject(anchor) || !Number.isSafeInteger(anchor.revision) || Number(anchor.revision) < 1) {\n throw corrupt(where, \"anchor names no revision\")\n }\n for (const key of [\"board\", \"element\", \"label\"] as const) {\n if (anchor[key] !== undefined && typeof anchor[key] !== \"string\") {\n throw corrupt(where, `anchor's ${key} is not text`)\n }\n }\n const { point } = anchor\n if (\n point !== undefined &&\n (!isObject(point) || !Number.isFinite(point.x) || !Number.isFinite(point.y))\n ) {\n throw corrupt(where, \"anchor's point is not two numbers\")\n }\n return {\n projectId: text(row.projectId, \"projectId\", where),\n artifactId: text(row.artifactId, \"artifactId\", where),\n id,\n ...(row.parentId == null ? {} : { parentId: text(row.parentId, \"parentId\", where) }),\n anchor: {\n ...(typeof anchor.board === \"string\" ? { board: anchor.board } : {}),\n ...(typeof anchor.element === \"string\" ? { element: anchor.element } : {}),\n ...(typeof anchor.label === \"string\" ? { label: anchor.label } : {}),\n ...(isObject(point) ? { point: { x: Number(point.x), y: Number(point.y) } } : {}),\n revision: Number(anchor.revision),\n },\n body: text(row.body, \"body\", where),\n ...(row.originThreadId == null || row.originRunId == null\n ? {}\n : {\n origin: {\n threadId: text(row.originThreadId, \"originThreadId\", where),\n runId: text(row.originRunId, \"originRunId\", where),\n },\n }),\n author: commentAuthor(row, where),\n createdAt: date(row.createdAt, \"createdAt\", where),\n ...(row.resolvedAt == null\n ? {}\n : {\n resolvedAt: date(row.resolvedAt, \"resolvedAt\", where),\n resolvedBy: principal(\n row.resolvedByPrincipalType,\n row.resolvedByPrincipalId,\n \"resolvedBy\",\n where\n ),\n }),\n }\n}\n\nfunction files(value: unknown, where: string): ArtifactFile[] {\n if (!Array.isArray(value)) throw corrupt(where, \"files is not a list\")\n return value.map((entry) => {\n if (!isObject(entry) || typeof entry.path !== \"string\" || !isFileRef(entry.file)) {\n throw corrupt(where, \"a file entry is not a path and a file reference\")\n }\n return { path: entry.path, file: entry.file }\n })\n}\n\nfunction outline(value: unknown, where: string): ArtifactOutline {\n if (!isObject(value) || !isArtifactKind(value.kind)) {\n throw corrupt(where, \"outline does not name an artifact kind\")\n }\n return value as unknown as ArtifactOutline\n}\n\nfunction references(value: unknown, where: string): ArtifactReference[] {\n if (!Array.isArray(value)) throw corrupt(where, \"references is not a list\")\n return value.map((entry) => {\n if (\n !isObject(entry) ||\n typeof entry.address !== \"string\" ||\n (entry.as !== \"embed\" && entry.as !== \"link\") ||\n typeof entry.at !== \"string\" ||\n !Number.isSafeInteger(entry.resolvedVersion) ||\n (entry.resolvedVersion as number) < 1\n ) {\n throw corrupt(where, \"a reference is not an address, a verb, a place, and a version\")\n }\n return {\n address: entry.address,\n as: entry.as,\n at: entry.at,\n resolvedVersion: entry.resolvedVersion as number,\n }\n })\n}\n\nfunction frameTargets(value: unknown, where: string): ArtifactFrameTarget[] {\n if (!Array.isArray(value)) throw corrupt(where, \"targets is not a list\")\n return value.map((entry) => {\n if (\n !isObject(entry) ||\n typeof entry.address !== \"string\" ||\n typeof entry.artifactId !== \"string\" ||\n !(\n entry.version === \"latest\" ||\n (Number.isSafeInteger(entry.version) && (entry.version as number) >= 1)\n )\n ) {\n throw corrupt(where, \"a target is not an address, an artifact, and a version\")\n }\n return {\n address: entry.address,\n artifactId: entry.artifactId,\n version: entry.version as number | \"latest\",\n }\n })\n}\n\nconst PRINCIPAL_TYPES: ReadonlySet<string> = new Set([\"user\", \"serviceAccount\", \"system\"])\n\nfunction principal(type: unknown, id: unknown, column: string, where: string): Principal {\n if (typeof type !== \"string\" || !PRINCIPAL_TYPES.has(type)) {\n throw corrupt(where, `${column} is not a principal`)\n }\n return { type: type as Principal[\"type\"], id: text(id, column, where) }\n}\n\n/** A comment's author: a principal, or a guest with the name they gave and nothing else. */\nfunction commentAuthor(row: Row, where: string): ArtifactCommentAuthor {\n if (row.authorPrincipalType !== \"guest\") {\n if (row.authorName != null) throw corrupt(where, \"a principal's comment keeps a guest's name\")\n return principal(row.authorPrincipalType, row.authorPrincipalId, \"author\", where)\n }\n\n return {\n type: \"guest\",\n id: text(row.authorPrincipalId, \"author\", where),\n name: text(row.authorName, \"authorName\", where),\n }\n}\n\n/** A boolean, as Postgres returns it or as SQLite keeps it: 0 or 1. */\nfunction flag(value: unknown, column: string, where: string): boolean {\n if (typeof value === \"boolean\") return value\n if (value === 0 || value === 1) return value === 1\n throw corrupt(where, `${column} is not true or false`)\n}\n\nfunction json(value: unknown, column: string, where: string): unknown {\n if (typeof value !== \"string\") return value\n try {\n return JSON.parse(value)\n } catch {\n throw corrupt(where, `${column} is not JSON`)\n }\n}\n\nfunction text(value: unknown, column: string, where: string): string {\n if (typeof value !== \"string\" || value.length === 0) throw corrupt(where, `${column} is not text`)\n return value\n}\n\nfunction positiveInteger(value: unknown, column: string, where: string): number {\n const number = typeof value === \"bigint\" ? Number(value) : value\n if (typeof number !== \"number\" || !Number.isSafeInteger(number) || number < 1) {\n throw corrupt(where, `${column} is not a positive integer`)\n }\n return number\n}\n\nfunction date(value: unknown, column: string, where: string): Date {\n const parsed = value instanceof Date || typeof value === \"string\" ? new Date(value) : null\n if (!parsed || !Number.isFinite(parsed.getTime())) throw corrupt(where, `${column} is not a date`)\n return parsed\n}\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n}\n\nfunction corrupt(where: string, reason: string): Error {\n return new Error(`[Sixb] Stored ${where} is invalid: ${reason}.`)\n}\n",
|
|
11
|
+
"import { isFileRef } from \"../../blob-storage\"\nimport type { FileDownloadGrantRecord } from \"./types\"\n\n/**\n * Rebuilds a grant from a provider row with camelCase keys. `file` may arrive parsed (jsonb) or\n * as text (SQLite), and timestamps as `Date` or ISO text. Fails closed on corruption: a grant that\n * cannot be read must not serve a file.\n */\nexport function parseFileDownloadGrantRow(row: {\n readonly [column: string]: unknown\n}): FileDownloadGrantRecord {\n const id = text(row.id, \"id\", String(row.id))\n const file = typeof row.file === \"string\" ? JSON.parse(row.file) : row.file\n if (!isFileRef(file)) throw corrupt(id, \"file is not a file reference\")\n\n return {\n id,\n projectId: text(row.projectId, \"projectId\", id),\n tokenHash: text(row.tokenHash, \"tokenHash\", id),\n file,\n executionId: text(row.executionId, \"executionId\", id),\n createdAt: date(row.createdAt, \"createdAt\", id),\n expiresAt: date(row.expiresAt, \"expiresAt\", id),\n ...(row.revokedAt == null ? {} : { revokedAt: date(row.revokedAt, \"revokedAt\", id) }),\n }\n}\n\nexport function cloneFileDownloadGrantRecord(\n record: FileDownloadGrantRecord\n): FileDownloadGrantRecord {\n return structuredClone(record)\n}\n\nfunction text(value: unknown, column: string, id: string): string {\n if (typeof value !== \"string\" || value.length === 0) throw corrupt(id, `${column} is not text`)\n return value\n}\n\nfunction date(value: unknown, column: string, id: string): Date {\n const parsed = value instanceof Date || typeof value === \"string\" ? new Date(value) : null\n if (!parsed || !Number.isFinite(parsed.getTime())) throw corrupt(id, `${column} is not a date`)\n return parsed\n}\n\nfunction corrupt(id: string, reason: string): Error {\n return new Error(`[Sixb] Stored file download grant '${id}' is invalid: ${reason}.`)\n}\n",
|
|
12
|
+
"import type { PipelineRunRecord, QueuePipelineRunInput } from \"./types\"\n\nexport function canRequeuePipelineRunAfterEnqueueFailure(\n existing: PipelineRunRecord,\n input: QueuePipelineRunInput\n): boolean {\n return (\n existing.status === \"failed\" &&\n existing.error?.code === \"queue.enqueue_failed\" &&\n existing.error.retryable &&\n existing.executionId === input.executionId &&\n existing.pipelineId === input.pipelineId\n )\n}\n",
|
|
13
|
+
"import type { FinishPipelineRunInput, PipelineRunStatus } from \"./types\"\n\n/**\n * A run succeeds from `running`. One that never started can fail, its job not published\n * (`queue.enqueue_failed`) or ended before starting it, or end `cancelled`, lost for too long.\n */\nexport function canFinishPipelineRun(\n status: PipelineRunStatus,\n input: FinishPipelineRunInput\n): boolean {\n if (input.status === \"succeeded\") return status === \"running\"\n if (input.status === \"failed\" && input.error.code === \"queue.enqueue_failed\") {\n return status === \"queued\"\n }\n\n return status === \"queued\" || status === \"running\"\n}\n",
|
|
14
|
+
"import type { QueueSyncRunInput, SyncRunRecord } from \"./types\"\n\nexport function canRequeueSyncRunAfterEnqueueFailure(\n existing: SyncRunRecord,\n input: QueueSyncRunInput\n): boolean {\n return (\n existing.status === \"failed\" &&\n existing.error?.code === \"queue.enqueue_failed\" &&\n existing.error.retryable &&\n existing.executionId === input.executionId &&\n existing.syncId === input.syncId &&\n existing.datasetId === input.datasetId &&\n existing.mode === input.mode &&\n existing.expectedLatestVersionId === input.expectedLatestVersionId &&\n existing.commitMessage === input.commitMessage\n )\n}\n",
|
|
15
|
+
"import type { FinishSyncRunInput, SyncRunStatus } from \"./types\"\n\n/**\n * A run succeeds from `running`. One that never started can fail, its job not published\n * (`queue.enqueue_failed`) or ended before starting it, or end `cancelled`, lost for too long.\n */\nexport function canFinishSyncRun(status: SyncRunStatus, input: FinishSyncRunInput): boolean {\n if (input.status === \"succeeded\") return status === \"running\"\n if (input.status === \"failed\" && input.error.code === \"queue.enqueue_failed\") {\n return status === \"queued\"\n }\n\n return status === \"queued\" || status === \"running\"\n}\n",
|
|
16
|
+
"import { StorageTransactionError } from \"./errors\"\nimport { createObjectOperationScope } from \"./operation-scope\"\nimport type { Storage } from \"./types\"\n\ntype ObjectLike = Record<PropertyKey, unknown>\n\nexport function createTransactionStorageProxy<T extends Storage>(\n target: T,\n isActive: () => boolean\n): T {\n const proxies = new WeakMap<object, object>()\n const objectStorage = createObjectOperationScope(target.objects, {\n assertAvailable: () => assertTransactionActive(isActive),\n run: async <TResult>(operation: () => Promise<TResult> | TResult): Promise<TResult> => {\n assertTransactionActive(isActive)\n return operation()\n },\n })\n\n const wrap = <TValue extends object>(value: TValue): TValue => {\n const existing = proxies.get(value)\n if (existing) return existing as TValue\n\n const proxy = new Proxy(value as ObjectLike, {\n // The guard runs on property access and on call. Its purpose is to fail fast when a\n // transaction handle (`tx`) leaks past the transaction's lifetime — using it afterward is a\n // bug, not a recoverable state. Overhead is bounded: only the storage namespaces reachable\n // from `tx` are wrapped (a handful), not the row/link data graph, and never per-record.\n get(current, property, receiver) {\n assertTransactionActive(isActive)\n const result =\n current === target && property === \"objects\"\n ? objectStorage\n : Reflect.get(current, property, receiver)\n if (typeof result === \"function\") {\n return (...args: unknown[]) => {\n assertTransactionActive(isActive)\n return result.apply(current, args)\n }\n }\n if (result && typeof result === \"object\") {\n return wrap(result)\n }\n return result\n },\n })\n\n proxies.set(value, proxy)\n return proxy as TValue\n }\n\n return wrap(target)\n}\n\nexport function assertTransactionActive(isActive: () => boolean): void {\n if (!isActive()) {\n throw new StorageTransactionError(\n \"[Sixb] Transaction storage cannot be used after transaction completion.\",\n { code: \"transaction_inactive\" }\n )\n }\n}\n\nexport function throwNestedStorageTransaction(): never {\n throw new StorageTransactionError(\"[Sixb] Nested storage transactions are not supported yet.\", {\n code: \"nested_transaction\",\n })\n}\n"
|
|
17
|
+
],
|
|
18
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,SAAS,mBAAmB,CAAC,MAAqB,OAA+B;AAAA,EACtF,IAAI,KAAK,SAAS,MAAM;AAAA,IAAM,OAAO;AAAA,EACrC,IAAI,KAAK,SAAS;AAAA,IAAQ,OAAO;AAAA,EACjC,IAAI,MAAM,SAAS;AAAA,IAAQ,OAAO;AAAA,EAClC,OAAO,KAAK,iBAAiB,MAAM,gBAAgB,KAAK,cAAc,MAAM;AAAA;AAGvE,SAAS,oBAAoB,CAAC,MAAe,OAAyB;AAAA,EAC3E,OAAO,qBAAoB,IAAI,MAAM,qBAAoB,KAAK;AAAA;AAIzD,SAAS,sBAAsB,CACpC,MACA,OACS;AAAA,EACT,OACE,KAAK,aAAa,MAAM,YACxB,oBAAoB,KAAK,SAAS,MAAM,OAAO,KAC/C,qBAAqB,KAAK,QAAQ,MAAM,MAAM;AAAA;AAM3C,SAAS,0BAA0B,CACxC,MACA,OACS;AAAA,EACT,OAAO,qBAAqB,4BAA4B,IAAI,GAAG,4BAA4B,KAAK,CAAC;AAAA;AAGnG,SAAS,2BAA2B,CAClC,QAC2C;AAAA,EAC3C,QAAQ,aAAa,iBAAiB,iBAAiB;AAAA,EACvD,OAAO;AAAA;;;ACpBF,SAAS,8BAA6B,CAAC,OAAmD;AAAA,EAC/F,MAAM,QAAQ,sBAAsB,MAAM;AAAA,EAC1C,WAAW,SAAS,CAAC,MAAM,aAAa,eAAe,YAAY,gBAAgB,GAAY;AAAA,IAC7F,IAAI,OAAO,MAAM,WAAW,YAAY,MAAM,OAAO,KAAK,EAAE,WAAW,GAAG;AAAA,MACxE,MAAM,IAAI,gBAAe,GAAG,8BAA8B,QAAQ;AAAA,IACpE;AAAA,EACF;AAAA,EACA,MAAM,SAAiB,M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;AAAA,QAC7C,IAAI,OAAO,WAAW,YAAY;AAAA,UAChC,OAAO,IAAI,SAAoB;AAAA,YAC7B,yBAAwB,QAAQ;AAAA,YAChC,OAAO,OAAO,MAAM,SAAS,IAAI;AAAA;AAAA,QAErC;AAAA,QACA,IAAI,UAAU,OAAO,WAAW,UAAU;AAAA,UACxC,OAAO,KAAK,MAAM;AAAA,QACpB;AAAA,QACA,OAAO;AAAA;AAAA,IAEX,CAAC;AAAA,IAED,QAAQ,IAAI,OAAO,KAAK;AAAA,IACxB,OAAO;AAAA;AAAA,EAGT,OAAO,KAAK,MAAM;AAAA;AAGb,SAAS,wBAAuB,CAAC,UAA+B;AAAA,EACrE,IAAI,CAAC,SAAS,GAAG;AAAA,IACf,MAAM,IAAI,yBACR,2EACA,EAAE,MAAM,uBAAuB,CACjC;AAAA,EACF;AAAA;AAGK,SAAS,8BAA6B,GAAU;AAAA,EACrD,MAAM,IAAI,yBAAwB,6DAA6D;AAAA,IAC7F,MAAM;AAAA,EACR,CAAC;AAAA;",
|
|
19
|
+
"debugId": "E296A7D3BCBE681164756E2164756E21",
|
|
20
|
+
"names": []
|
|
21
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
createSixbError2
|
|
4
|
+
} from "./chunk-mvz89age.js";
|
|
5
|
+
import {
|
|
6
|
+
joinJobId
|
|
7
|
+
} from "./chunk-n2ay51px.js";
|
|
8
|
+
|
|
9
|
+
// src/workers/queued-run-dispatch.ts
|
|
10
|
+
import { randomUUID } from "crypto";
|
|
11
|
+
import { isDeepStrictEqual } from "util";
|
|
12
|
+
async function dispatchQueuedRun(input) {
|
|
13
|
+
const runId = createRunId(input);
|
|
14
|
+
let persisted = await persistRun(input, runId);
|
|
15
|
+
if (!persisted.publish && input.automatic && persisted.run.status === "queued") {
|
|
16
|
+
persisted = await reuseRun(input, persisted.run);
|
|
17
|
+
}
|
|
18
|
+
if (!persisted.publish)
|
|
19
|
+
return input.primitive.result(persisted.run);
|
|
20
|
+
return publishRun(input, persisted);
|
|
21
|
+
}
|
|
22
|
+
async function persistRun(input, runId) {
|
|
23
|
+
const { primitive } = input;
|
|
24
|
+
const store = primitive.store(input.storage);
|
|
25
|
+
const existing = await store.getById({ projectId: input.projectId, id: runId });
|
|
26
|
+
if (existing)
|
|
27
|
+
return reuseRun(input, existing);
|
|
28
|
+
const execution = await input.createExecution(`exec_${randomUUID()}`, runId);
|
|
29
|
+
const queuedAt = new Date;
|
|
30
|
+
try {
|
|
31
|
+
return await input.storage.transaction((tx) => persistRunInTransaction(input, tx, runId, execution, queuedAt), { isolation: "serializable" });
|
|
32
|
+
} catch (error) {
|
|
33
|
+
if (!(error instanceof primitive.RunError))
|
|
34
|
+
throw error;
|
|
35
|
+
const raced = await store.getById({ projectId: input.projectId, id: runId });
|
|
36
|
+
if (!raced)
|
|
37
|
+
throw error;
|
|
38
|
+
await assertReusable(input, raced, input.storage);
|
|
39
|
+
return { publish: false, run: raced };
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async function persistRunInTransaction(input, tx, runId, execution, queuedAt) {
|
|
43
|
+
const store = input.primitive.store(tx);
|
|
44
|
+
const raced = await store.getById({ projectId: input.projectId, id: runId });
|
|
45
|
+
if (raced) {
|
|
46
|
+
await assertReusable(input, raced, tx);
|
|
47
|
+
return { publish: false, run: raced };
|
|
48
|
+
}
|
|
49
|
+
if (input.joinQueuedRun) {
|
|
50
|
+
const waiting = await store.oldestQueued();
|
|
51
|
+
if (waiting && input.primitive.matches(waiting)) {
|
|
52
|
+
return {
|
|
53
|
+
publish: true,
|
|
54
|
+
run: waiting,
|
|
55
|
+
queuedAt: waiting.queuedAt,
|
|
56
|
+
created: false,
|
|
57
|
+
jobId: joinJobId(waiting.id)
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
await tx.executions.create(execution);
|
|
62
|
+
const run = await store.queue({ id: runId, executionId: execution.id, queuedAt });
|
|
63
|
+
return { publish: true, run, queuedAt, created: true };
|
|
64
|
+
}
|
|
65
|
+
async function reuseRun(input, existing) {
|
|
66
|
+
await assertReusable(input, existing, input.storage);
|
|
67
|
+
if (input.automatic && existing.status === "queued") {
|
|
68
|
+
await requireExecution(input, existing);
|
|
69
|
+
return { publish: true, run: existing, queuedAt: existing.queuedAt, created: false };
|
|
70
|
+
}
|
|
71
|
+
if (existing.status !== "failed" || existing.error?.code !== "queue.enqueue_failed" || !existing.error.retryable) {
|
|
72
|
+
return { publish: false, run: existing };
|
|
73
|
+
}
|
|
74
|
+
await requireExecution(input, existing);
|
|
75
|
+
const queuedAt = new Date;
|
|
76
|
+
const run = await input.primitive.store(input.storage).requeue(existing, queuedAt);
|
|
77
|
+
return { publish: true, run, queuedAt, created: false };
|
|
78
|
+
}
|
|
79
|
+
async function assertReusable(input, run, storage) {
|
|
80
|
+
if (!input.primitive.matches(run)) {
|
|
81
|
+
throw new input.primitive.RunError(`[Sixb] ${input.primitive.label} run '${run.id}' already exists with a different request payload.`);
|
|
82
|
+
}
|
|
83
|
+
await input.validateExistingRun?.(run, storage);
|
|
84
|
+
}
|
|
85
|
+
async function requireExecution(input, run) {
|
|
86
|
+
const execution = await input.storage.executions.getById({
|
|
87
|
+
projectId: input.projectId,
|
|
88
|
+
id: run.executionId
|
|
89
|
+
});
|
|
90
|
+
if (!execution) {
|
|
91
|
+
throw new input.primitive.RunError(`[Sixb] Execution '${run.executionId}' for ${input.primitive.label} run '${run.id}' was not found.`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
async function publishRun(input, persisted) {
|
|
95
|
+
const { primitive } = input;
|
|
96
|
+
const jobId = persisted.jobId ?? persisted.run.id;
|
|
97
|
+
try {
|
|
98
|
+
const job = await primitive.enqueue({
|
|
99
|
+
id: jobId,
|
|
100
|
+
runId: persisted.run.id,
|
|
101
|
+
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
102
|
+
});
|
|
103
|
+
if (!job || job.id !== jobId) {
|
|
104
|
+
throw new primitive.RunError(`[Sixb] Queue did not acknowledge ${primitive.label} run '${persisted.run.id}'.`);
|
|
105
|
+
}
|
|
106
|
+
return primitive.result(persisted.run, {
|
|
107
|
+
queuedAt: persisted.queuedAt,
|
|
108
|
+
jobId: job.id,
|
|
109
|
+
created: persisted.created
|
|
110
|
+
});
|
|
111
|
+
} catch (error) {
|
|
112
|
+
if (input.automatic)
|
|
113
|
+
throw error;
|
|
114
|
+
await primitive.failPublication(persisted.run, createSixbError2("queue.enqueue_failed", `[Sixb] Could not enqueue ${primitive.label} run '${persisted.run.id}'.`, {
|
|
115
|
+
cause: error,
|
|
116
|
+
details: {
|
|
117
|
+
...primitive.failureDetails(persisted.run),
|
|
118
|
+
runId: persisted.run.id,
|
|
119
|
+
phase: "enqueue"
|
|
120
|
+
}
|
|
121
|
+
}), error, new Date);
|
|
122
|
+
throw error;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function hasAutomaticRunProvenance(execution, input) {
|
|
126
|
+
return execution !== null && isDeepStrictEqual(execution.source, input.source) && execution.correlationId === input.correlationId && execution.requestedBy === undefined;
|
|
127
|
+
}
|
|
128
|
+
function createRunId(input) {
|
|
129
|
+
if (input.runId === undefined)
|
|
130
|
+
return `run_${randomUUID()}`;
|
|
131
|
+
if (!input.runId.trim()) {
|
|
132
|
+
throw new input.primitive.RequestError(`[Sixb] ${input.primitive.label} run id must not be empty`);
|
|
133
|
+
}
|
|
134
|
+
return input.runId;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export { dispatchQueuedRun, hasAutomaticRunProvenance };
|
|
138
|
+
|
|
139
|
+
//# debugId=6225D8ED2701523964756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/workers/queued-run-dispatch.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { randomUUID } from \"node:crypto\"\nimport { isDeepStrictEqual } from \"node:util\"\nimport { createSixbError, type SixbCodedError } from \"../errors/internal\"\nimport type { CreateExecutionInput, ExecutionRecord, Storage } from \"../storage\"\nimport { joinJobId } from \"./job-ids\"\n\n/** A durable run that waits for a worker: the part of a Sync or Pipeline run dispatch reads. */\nexport interface QueuedRun {\n readonly id: string\n readonly executionId: string\n readonly status: string\n readonly queuedAt: Date\n readonly error?: { readonly code: string; readonly retryable: boolean }\n}\n\nexport interface QueuedRunStore<TRun extends QueuedRun> {\n getById(params: { projectId: string; id: string }): Promise<TRun | null>\n /** The oldest run of this definition that has not started, whatever its request. */\n oldestQueued(): Promise<TRun | undefined>\n queue(run: {\n readonly id: string\n readonly executionId: string\n readonly queuedAt: Date\n }): Promise<TRun>\n /** Queue again a run whose job could not be published. */\n requeue(run: TRun, queuedAt: Date): Promise<TRun>\n}\n\nexport type RunDispatchProvenance =\n | { readonly type: \"schedule\" | \"event\"; readonly eventId: string }\n | { readonly type: \"datasetVersion\"; readonly datasetId: string; readonly versionId: string }\n\n/** What a primitive supplies to run dispatch: everything else about admission is shared. */\nexport interface QueuedRunPrimitive<TRun extends QueuedRun, TResult> {\n /** Capitalized, as error messages name it. */\n readonly label: string\n /** Details that identify the primitive in a failure, beside the run id. */\n failureDetails(run: TRun): Readonly<Record<string, string>>\n\n /** The primitive's runs, in this storage or in one transaction of it. */\n store(storage: Storage): QueuedRunStore<TRun>\n /** A run of this definition, with this same request, could serve as this one. */\n matches(run: TRun): boolean\n\n enqueue(job: {\n readonly id: string\n readonly runId: string\n readonly metadata?: Readonly<Record<string, string>>\n }): Promise<{ readonly id: string } | undefined>\n /** Record and report that the run's job could not be published. */\n failPublication(run: TRun, failure: SixbCodedError, cause: unknown, at: Date): Promise<void>\n\n result(run: TRun, publication?: RunPublication): TResult\n\n /** Says a run record cannot serve this request. */\n readonly RunError: new (\n message: string\n ) => Error\n /** Says the request itself is malformed. */\n readonly RequestError: new (\n message: string\n ) => Error\n}\n\nexport interface RunPublication {\n readonly queuedAt: Date\n readonly jobId: string\n readonly created: boolean\n}\n\nexport interface DispatchQueuedRunInput<TRun extends QueuedRun, TResult> {\n readonly primitive: QueuedRunPrimitive<TRun, TResult>\n readonly projectId: string\n readonly storage: Storage\n readonly runId?: string\n readonly metadata?: Readonly<Record<string, string>>\n readonly createExecution: (executionId: string, runId: string) => Promise<CreateExecutionInput>\n readonly validateExistingRun?: (run: TRun, storage: Storage) => Promise<void>\n /** Return a matching run that has not started yet instead of queueing another one. */\n readonly joinQueuedRun?: boolean\n /**\n * A trigger, not a caller. It republishes a queued run it finds, and leaves its publication\n * uncertain: its consumer retains the batch and retries, where a caller is told it failed.\n */\n readonly automatic?: boolean\n}\n\ntype PersistedRun<TRun extends QueuedRun> =\n | { readonly publish: false; readonly run: TRun }\n | {\n readonly publish: true\n readonly run: TRun\n readonly queuedAt: Date\n readonly created: boolean\n /** Defaults to the run id. A trigger that joins a run publishes its own job for it. */\n readonly jobId?: string\n }\n\n/** Persist an execution and a queued run before publishing the run's queue job. */\nexport async function dispatchQueuedRun<TRun extends QueuedRun, TResult>(\n input: DispatchQueuedRunInput<TRun, TResult>\n): Promise<TResult> {\n const runId = createRunId(input)\n\n let persisted = await persistRun(input, runId)\n if (!persisted.publish && input.automatic && persisted.run.status === \"queued\") {\n persisted = await reuseRun(input, persisted.run)\n }\n\n if (!persisted.publish) return input.primitive.result(persisted.run)\n return publishRun(input, persisted)\n}\n\nasync function persistRun<TRun extends QueuedRun, TResult>(\n input: DispatchQueuedRunInput<TRun, TResult>,\n runId: string\n): Promise<PersistedRun<TRun>> {\n const { primitive } = input\n\n const store = primitive.store(input.storage)\n\n const existing = await store.getById({ projectId: input.projectId, id: runId })\n if (existing) return reuseRun(input, existing)\n\n const execution = await input.createExecution(`exec_${randomUUID()}`, runId)\n const queuedAt = new Date()\n\n try {\n return await input.storage.transaction(\n (tx) => persistRunInTransaction(input, tx, runId, execution, queuedAt),\n { isolation: \"serializable\" }\n )\n } catch (error) {\n if (!(error instanceof primitive.RunError)) throw error\n\n const raced = await store.getById({ projectId: input.projectId, id: runId })\n if (!raced) throw error\n\n await assertReusable(input, raced, input.storage)\n return { publish: false, run: raced }\n }\n}\n\nasync function persistRunInTransaction<TRun extends QueuedRun, TResult>(\n input: DispatchQueuedRunInput<TRun, TResult>,\n tx: Storage,\n runId: string,\n execution: CreateExecutionInput,\n queuedAt: Date\n): Promise<PersistedRun<TRun>> {\n const store = input.primitive.store(tx)\n\n const raced = await store.getById({ projectId: input.projectId, id: runId })\n if (raced) {\n await assertReusable(input, raced, tx)\n return { publish: false, run: raced }\n }\n\n if (input.joinQueuedRun) {\n const waiting = await store.oldestQueued()\n if (waiting && input.primitive.matches(waiting)) {\n return {\n publish: true,\n run: waiting,\n queuedAt: waiting.queuedAt,\n created: false,\n // The run's own job may be gone, so a joining trigger brings one that can start the run.\n jobId: joinJobId(waiting.id),\n }\n }\n }\n\n await tx.executions.create(execution)\n const run = await store.queue({ id: runId, executionId: execution.id, queuedAt })\n return { publish: true, run, queuedAt, created: true }\n}\n\nasync function reuseRun<TRun extends QueuedRun, TResult>(\n input: DispatchQueuedRunInput<TRun, TResult>,\n existing: TRun\n): Promise<PersistedRun<TRun>> {\n await assertReusable(input, existing, input.storage)\n\n if (input.automatic && existing.status === \"queued\") {\n await requireExecution(input, existing)\n return { publish: true, run: existing, queuedAt: existing.queuedAt, created: false }\n }\n\n if (\n existing.status !== \"failed\" ||\n existing.error?.code !== \"queue.enqueue_failed\" ||\n !existing.error.retryable\n ) {\n return { publish: false, run: existing }\n }\n\n await requireExecution(input, existing)\n\n const queuedAt = new Date()\n const run = await input.primitive.store(input.storage).requeue(existing, queuedAt)\n return { publish: true, run, queuedAt, created: false }\n}\n\nasync function assertReusable<TRun extends QueuedRun, TResult>(\n input: DispatchQueuedRunInput<TRun, TResult>,\n run: TRun,\n storage: Storage\n): Promise<void> {\n if (!input.primitive.matches(run)) {\n throw new input.primitive.RunError(\n `[Sixb] ${input.primitive.label} run '${run.id}' already exists with a different request payload.`\n )\n }\n\n await input.validateExistingRun?.(run, storage)\n}\n\nasync function requireExecution<TRun extends QueuedRun, TResult>(\n input: DispatchQueuedRunInput<TRun, TResult>,\n run: TRun\n): Promise<void> {\n const execution = await input.storage.executions.getById({\n projectId: input.projectId,\n id: run.executionId,\n })\n if (!execution) {\n throw new input.primitive.RunError(\n `[Sixb] Execution '${run.executionId}' for ${input.primitive.label} run '${run.id}' was not found.`\n )\n }\n}\n\nasync function publishRun<TRun extends QueuedRun, TResult>(\n input: DispatchQueuedRunInput<TRun, TResult>,\n persisted: Extract<PersistedRun<TRun>, { readonly publish: true }>\n): Promise<TResult> {\n const { primitive } = input\n const jobId = persisted.jobId ?? persisted.run.id\n\n try {\n const job = await primitive.enqueue({\n id: jobId,\n runId: persisted.run.id,\n ...(input.metadata === undefined ? {} : { metadata: input.metadata }),\n })\n if (!job || job.id !== jobId) {\n throw new primitive.RunError(\n `[Sixb] Queue did not acknowledge ${primitive.label} run '${persisted.run.id}'.`\n )\n }\n\n return primitive.result(persisted.run, {\n queuedAt: persisted.queuedAt,\n jobId: job.id,\n created: persisted.created,\n })\n } catch (error) {\n // Automatic consumers retain the batch and retry. Keep uncertain delivery queued:\n // a lost reply does not prove that the queue rejected the job.\n if (input.automatic) throw error\n\n await primitive.failPublication(\n persisted.run,\n createSixbError(\n \"queue.enqueue_failed\",\n `[Sixb] Could not enqueue ${primitive.label} run '${persisted.run.id}'.`,\n {\n cause: error,\n details: {\n ...primitive.failureDetails(persisted.run),\n runId: persisted.run.id,\n phase: \"enqueue\",\n },\n }\n ),\n error,\n new Date()\n )\n throw error\n }\n}\n\n/** Whether an execution is the one this automatic trigger would have created for its run. */\nexport function hasAutomaticRunProvenance(\n execution: ExecutionRecord | null,\n input: { readonly source: RunDispatchProvenance; readonly correlationId: string }\n): boolean {\n return (\n execution !== null &&\n isDeepStrictEqual(execution.source, input.source) &&\n execution.correlationId === input.correlationId &&\n execution.requestedBy === undefined\n )\n}\n\nfunction createRunId<TRun extends QueuedRun, TResult>(\n input: DispatchQueuedRunInput<TRun, TResult>\n): string {\n if (input.runId === undefined) return `run_${randomUUID()}`\n\n if (!input.runId.trim()) {\n throw new input.primitive.RequestError(\n `[Sixb] ${input.primitive.label} run id must not be empty`\n )\n }\n\n return input.runId\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;;;;;;;;AAAA;AACA;AAkGO,eAAe,iBAAkD,CACtE,OACkB;AAAA,EAClB,MAAM,QAAQ,YAAY,KAAK;AAAA,EAE/B,IAAI,YAAY,MAAM,WAAW,OAAO,KAAK;AAAA,EAC7C,IAAI,CAAC,UAAU,WAAW,MAAM,aAAa,UAAU,IAAI,WAAW,UAAU;AAAA,IAC9E,YAAY,MAAM,SAAS,OAAO,UAAU,GAAG;AAAA,EACjD;AAAA,EAEA,IAAI,CAAC,UAAU;AAAA,IAAS,OAAO,MAAM,UAAU,OAAO,UAAU,GAAG;AAAA,EACnE,OAAO,WAAW,OAAO,SAAS;AAAA;AAGpC,eAAe,UAA2C,CACxD,OACA,OAC6B;AAAA,EAC7B,QAAQ,cAAc;AAAA,EAEtB,MAAM,QAAQ,UAAU,MAAM,MAAM,OAAO;AAAA,EAE3C,MAAM,WAAW,MAAM,MAAM,QAAQ,EAAE,WAAW,MAAM,WAAW,IAAI,MAAM,CAAC;AAAA,EAC9E,IAAI;AAAA,IAAU,OAAO,SAAS,OAAO,QAAQ;AAAA,EAE7C,MAAM,YAAY,MAAM,MAAM,gBAAgB,QAAQ,WAAW,KAAK,KAAK;AAAA,EAC3E,MAAM,WAAW,IAAI;AAAA,EAErB,IAAI;AAAA,IACF,OAAO,MAAM,MAAM,QAAQ,YACzB,CAAC,OAAO,wBAAwB,OAAO,IAAI,OAAO,WAAW,QAAQ,GACrE,EAAE,WAAW,eAAe,CAC9B;AAAA,IACA,OAAO,OAAO;AAAA,IACd,IAAI,EAAE,iBAAiB,UAAU;AAAA,MAAW,MAAM;AAAA,IAElD,MAAM,QAAQ,MAAM,MAAM,QAAQ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* 60000;
|
|
4
|
+
var STALE_RUN_AFTER_MS = 7 * 24 * 60 * 60000;
|
|
5
|
+
function runHeldUntil(run) {
|
|
6
|
+
if (run.execution)
|
|
7
|
+
return run.execution.queueLeaseExpiresAt;
|
|
8
|
+
return run.startedAt && new Date(run.startedAt.getTime() + ORPHANED_RUN_AFTER_MS2);
|
|
9
|
+
}
|
|
10
|
+
function isOrphanedRun(run, now) {
|
|
11
|
+
const heldUntil = runHeldUntil(run);
|
|
12
|
+
return run.status === "running" && run.execution === undefined && heldUntil !== undefined && heldUntil.getTime() <= now.getTime();
|
|
13
|
+
}
|
|
14
|
+
function planRunClaim2(run, input, sibling) {
|
|
15
|
+
const now = input.claimedAt ?? new Date;
|
|
16
|
+
if (run.status !== "queued" && run.status !== "running" || isOrphanedRun(run, now)) {
|
|
17
|
+
return { take: false, claim: { outcome: "settled", run } };
|
|
18
|
+
}
|
|
19
|
+
if (run.status === "queued" && sibling?.execution) {
|
|
20
|
+
return { take: false, claim: { outcome: "waiting", run, sibling } };
|
|
21
|
+
}
|
|
22
|
+
const heldUntil = runHeldUntil(run);
|
|
23
|
+
if (run.status === "running" && heldUntil && heldUntil.getTime() > now.getTime()) {
|
|
24
|
+
return { take: false, claim: { outcome: "held", run, ownedUntil: heldUntil } };
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
take: true,
|
|
28
|
+
outcome: run.status === "queued" ? "started" : "resumed",
|
|
29
|
+
startedAt: run.status === "queued" ? now : run.startedAt ?? now,
|
|
30
|
+
attempt: run.attempt + 1,
|
|
31
|
+
execution: input.execution
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function isStaleRun(run, now) {
|
|
35
|
+
return now.getTime() - lostSince(run) >= STALE_RUN_AFTER_MS;
|
|
36
|
+
}
|
|
37
|
+
function selectLostRuns(runs, input) {
|
|
38
|
+
return [...runs].filter((run) => run.projectId === input.projectId && isLostRun(run, input)).sort((left, right) => Number(right.status === "running") - Number(left.status === "running") || lostSince(left) - lostSince(right)).slice(0, input.limit);
|
|
39
|
+
}
|
|
40
|
+
function isLostRun(run, input) {
|
|
41
|
+
if (run.status === "queued") {
|
|
42
|
+
return run.queuedAt !== undefined && run.queuedAt.getTime() <= input.queuedBefore.getTime();
|
|
43
|
+
}
|
|
44
|
+
if (run.status !== "running")
|
|
45
|
+
return false;
|
|
46
|
+
if (run.execution)
|
|
47
|
+
return run.execution.queueLeaseExpiresAt.getTime() <= input.lapsedBy.getTime();
|
|
48
|
+
return run.startedAt !== undefined && run.startedAt.getTime() <= input.orphanedBefore.getTime();
|
|
49
|
+
}
|
|
50
|
+
function lostSince(run) {
|
|
51
|
+
return (run.execution?.queueLeaseExpiresAt ?? run.startedAt ?? run.queuedAt ?? 0).valueOf();
|
|
52
|
+
}
|
|
53
|
+
function laterLease2(current, next) {
|
|
54
|
+
return current && current.getTime() > next.getTime() ? current : next;
|
|
55
|
+
}
|
|
56
|
+
function holdsRun2(run, token, now = new Date) {
|
|
57
|
+
if (token !== undefined)
|
|
58
|
+
return run.execution?.token === token;
|
|
59
|
+
return !run.execution || run.execution.queueLeaseExpiresAt.getTime() <= now.getTime();
|
|
60
|
+
}
|
|
61
|
+
function mayFinishRun2(run, input) {
|
|
62
|
+
if (input.status === "cancelled" && input.executionToken === undefined)
|
|
63
|
+
return true;
|
|
64
|
+
return holdsRun2(run, input.executionToken);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export { ORPHANED_RUN_AFTER_MS2, isOrphanedRun, planRunClaim2, isStaleRun, selectLostRuns, laterLease2, holdsRun2, mayFinishRun2 };
|
|
68
|
+
|
|
69
|
+
//# debugId=405F6F0520960B4564756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/storage/run-claim.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Who holds a running run: the token that fences every write to it, and until when the queue lease\n * behind that token is known to last.\n */\nexport interface RunExecution {\n readonly token: string\n readonly queueLeaseExpiresAt: Date\n}\n\n/**\n * A run from before runs held a lease shows nothing that says whether a worker still has it. It is\n * left alone for this long, far past what a deploy takes to replace its workers, and then counts\n * as lost. A longer run on a worker of that older version would be lost with it.\n */\nexport const ORPHANED_RUN_AFTER_MS = 24 * 60 * 60_000\n\n/**\n * A run lost for this long is ended rather than brought back: whatever it was asked for is a week\n * old, and a lost job cannot be told from a stopped queue, so the bound sits past a long outage.\n */\nconst STALE_RUN_AFTER_MS = 7 * 24 * 60 * 60_000\n\nexport interface ClaimRunInput {\n readonly projectId: string\n readonly id: string\n /** The execution that takes the run, when the run can be taken. */\n readonly execution: RunExecution\n /** Defaults to now. */\n readonly claimedAt?: Date\n}\n\n/**\n * What a delivery found. `started` and `resumed` hand it the run. `held` means a live execution has\n * it until `ownedUntil`, so this delivery is a duplicate. `waiting` means the run has not started\n * and cannot until `sibling` ends. `settled` means nothing is left to do.\n */\nexport type RunClaim<TRun> =\n | { readonly outcome: \"started\" | \"resumed\"; readonly run: TRun }\n | { readonly outcome: \"held\"; readonly run: TRun; readonly ownedUntil: Date }\n | { readonly outcome: \"waiting\"; readonly run: TRun; readonly sibling: ClaimableRun }\n | { readonly outcome: \"settled\"; readonly run: TRun }\n\nexport interface ConfirmRunExecutionInput {\n readonly projectId: string\n readonly id: string\n readonly executionToken: string\n readonly queueLeaseExpiresAt: Date\n}\n\nexport interface ReleaseRunExecutionInput {\n readonly projectId: string\n readonly id: string\n readonly executionToken: string\n /**\n * False hands the run back as if this execution had not happened: a deploy stopping a worker\n * must not use up the attempts a run has against crashes and failures.\n */\n readonly spentAttempt: boolean\n /** Defaults to now. */\n readonly releasedAt?: Date\n}\n\n/**\n * What the recovery pass asks a store: the runs no delivery can be counted on to reach. Stores answer\n * from their status index, so a project with nothing lost reads no rows, however many runs it keeps.\n */\nexport interface ListLostRunsInput {\n readonly projectId: string\n /** Older than this, a queued run's job should have started it. */\n readonly queuedBefore: Date\n /** A running run whose lease ended by this has lost its execution. */\n readonly lapsedBy: Date\n /** A running run with no lease, started before this, belongs to an older version that is gone. */\n readonly orphanedBefore: Date\n readonly limit: number\n}\n\nexport interface ClaimableRun {\n readonly id: string\n readonly status: string\n readonly startedAt?: Date\n readonly attempt: number\n readonly execution?: RunExecution\n}\n\nexport type RunClaimPlan<TRun> =\n | {\n readonly take: true\n readonly outcome: \"started\" | \"resumed\"\n readonly startedAt: Date\n readonly attempt: number\n readonly execution: RunExecution\n }\n | { readonly take: false; readonly claim: RunClaim<TRun> }\n\n/** Until when an execution may be holding a running run. */\nfunction runHeldUntil(run: ClaimableRun): Date | undefined {\n if (run.execution) return run.execution.queueLeaseExpiresAt\n return run.startedAt && new Date(run.startedAt.getTime() + ORPHANED_RUN_AFTER_MS)\n}\n\n/**\n * Whether a running run has no execution, and has not for long enough to be lost. Every execution\n * leaves one on the run, and a hand-back only lets its lease lapse, so this is an older version's.\n */\nexport function isOrphanedRun(run: ClaimableRun, now: Date): boolean {\n const heldUntil = runHeldUntil(run)\n return (\n run.status === \"running\" &&\n run.execution === undefined &&\n heldUntil !== undefined &&\n heldUntil.getTime() <= now.getTime()\n )\n}\n\n/**\n * The one decision every delivery of a run makes, in the transaction that holds the run: `queued`\n * starts, `running` resumes under a new token once nothing holds it, and anything else is over. A\n * run keeps the time it first started across resumes. An orphaned run is not resumed: nothing says\n * what its old worker did, so only the recovery pass ends it.\n *\n * `sibling` is a run this one must not overlap. It waits for that run to end, and a trigger that\n * arrives meanwhile joins it, since it has not started.\n */\nexport function planRunClaim<TRun extends ClaimableRun>(\n run: TRun,\n input: Pick<ClaimRunInput, \"execution\" | \"claimedAt\">,\n sibling?: ClaimableRun\n): RunClaimPlan<TRun> {\n const now = input.claimedAt ?? new Date()\n\n if ((run.status !== \"queued\" && run.status !== \"running\") || isOrphanedRun(run, now)) {\n return { take: false, claim: { outcome: \"settled\", run } }\n }\n\n // A sibling with no execution was started by an older version, which never promised this rule.\n if (run.status === \"queued\" && sibling?.execution) {\n return { take: false, claim: { outcome: \"waiting\", run, sibling } }\n }\n\n const heldUntil = runHeldUntil(run)\n if (run.status === \"running\" && heldUntil && heldUntil.getTime() > now.getTime()) {\n return { take: false, claim: { outcome: \"held\", run, ownedUntil: heldUntil } }\n }\n\n return {\n take: true,\n outcome: run.status === \"queued\" ? \"started\" : \"resumed\",\n startedAt: run.status === \"queued\" ? now : (run.startedAt ?? now),\n attempt: run.attempt + 1,\n execution: input.execution,\n }\n}\n\ntype LostRunCandidate = ClaimableRun & {\n readonly projectId: string\n readonly queuedAt?: Date\n}\n\n/** Whether a lost run has been lost for so long that it should end, not go on. */\nexport function isStaleRun(run: Omit<LostRunCandidate, \"projectId\">, now: Date): boolean {\n return now.getTime() - lostSince(run) >= STALE_RUN_AFTER_MS\n}\n\n/**\n * `listLost`, over rows held in memory. Running runs come first, longest lost first: a queued run\n * may only be waiting for its sibling, and however many of those there are, they must not keep a\n * lost run from being looked at. Stores that query say the same in their own language.\n */\nexport function selectLostRuns<TRun extends LostRunCandidate>(\n runs: Iterable<TRun>,\n input: ListLostRunsInput\n): readonly TRun[] {\n return [...runs]\n .filter((run) => run.projectId === input.projectId && isLostRun(run, input))\n .sort(\n (left, right) =>\n Number(right.status === \"running\") - Number(left.status === \"running\") ||\n lostSince(left) - lostSince(right)\n )\n .slice(0, input.limit)\n}\n\nfunction isLostRun(run: LostRunCandidate, input: ListLostRunsInput): boolean {\n if (run.status === \"queued\") {\n return run.queuedAt !== undefined && run.queuedAt.getTime() <= input.queuedBefore.getTime()\n }\n if (run.status !== \"running\") return false\n\n if (run.execution) return run.execution.queueLeaseExpiresAt.getTime() <= input.lapsedBy.getTime()\n\n return run.startedAt !== undefined && run.startedAt.getTime() <= input.orphanedBefore.getTime()\n}\n\nfunction lostSince(run: Omit<LostRunCandidate, \"projectId\">): number {\n return (run.execution?.queueLeaseExpiresAt ?? run.startedAt ?? run.queuedAt ?? 0).valueOf()\n}\n\n/** A lease only moves forward: confirmations can race, and the latest one must win. */\nexport function laterLease(current: Date | undefined, next: Date): Date {\n return current && current.getTime() > next.getTime() ? current : next\n}\n\n/**\n * Only the execution that holds a run may write to it. A write with no token comes from outside any\n * execution, so it needs a run nothing holds. `now` is when the write happens.\n */\nexport function holdsRun(\n run: Pick<ClaimableRun, \"execution\">,\n token: string | undefined,\n now: Date = new Date()\n): boolean {\n if (token !== undefined) return run.execution?.token === token\n return !run.execution || run.execution.queueLeaseExpiresAt.getTime() <= now.getTime()\n}\n\n/** A cancel with no token comes from outside, and ends the run for whichever execution holds it. */\nexport function mayFinishRun(\n run: Pick<ClaimableRun, \"execution\">,\n input: { readonly status: string; readonly executionToken?: string }\n): boolean {\n if (input.status === \"cancelled\" && input.executionToken === undefined) return true\n return holdsRun(run, input.executionToken)\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;AAcO,IAAM,yBAAwB,KAAK,KAAK;AAM/C,IAAM,qBAAqB,IAAI,KAAK,KAAK;AA4EzC,SAAS,YAAY,CAAC,KAAqC;AAAA,EACzD,IAAI,IAAI;AAAA,IAAW,OAAO,IAAI,UAAU;AAAA,EACxC,OAAO,IAAI,aAAa,IAAI,KAAK,IAAI,UAAU,QAAQ,IAAI,sBAAqB;AAAA;AAO3E,SAAS,aAAa,CAAC,KAAmB,KAAoB;AAAA,EACnE,MAAM,YAAY,aAAa,GAAG;AAAA,EAClC,OACE,IAAI,WAAW,aACf,IAAI,cAAc,aAClB,cAAc,aACd,UAAU,QAAQ,KAAK,IAAI,QAAQ;AAAA;AAahC,SAAS,aAAuC,CACrD,KACA,OACA,SACoB;AAAA,EACpB,MAAM,MAAM,MAAM,aAAa,IAAI;AAAA,EAEnC,IAAK,IAAI,WAAW,YAAY,IAAI,WAAW,aAAc,cAAc,KAAK,GAAG,GAAG;AAAA,IACpF,OAAO,EAAE,MAAM,OAAO,OAAO,EAAE,SAAS,WAAW,IAAI,EAAE;AAAA,EAC3D;AAAA,EAGA,IAAI,IAAI,WAAW,YAAY,SAAS,WAAW;AAA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