@sixb/core 0.2.7 → 0.2.8
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 +52 -49
- package/dist/actions/index.js.map +1 -1
- package/dist/actions/request.d.ts.map +1 -1
- package/dist/actions/run/context.d.ts.map +1 -1
- package/dist/actions/run/execute.d.ts +3 -0
- package/dist/actions/run/execute.d.ts.map +1 -1
- package/dist/actions/run/executor.d.ts +3 -0
- package/dist/actions/run/executor.d.ts.map +1 -1
- package/dist/actions/run/normalize.d.ts.map +1 -1
- package/dist/actions/run/types.d.ts +6 -0
- package/dist/actions/run/types.d.ts.map +1 -1
- package/dist/actions/types/context.d.ts +7 -0
- package/dist/actions/types/context.d.ts.map +1 -1
- package/dist/agents/context/entries.d.ts +17 -0
- package/dist/agents/context/entries.d.ts.map +1 -1
- package/dist/agents/context/index.js +3 -2
- package/dist/agents/context/index.js.map +1 -1
- package/dist/agents/context-model.d.ts.map +1 -1
- package/dist/agents/context-resolution.d.ts.map +1 -1
- package/dist/agents/execution.d.ts +7 -0
- package/dist/agents/execution.d.ts.map +1 -1
- package/dist/agents/index.js +57 -54
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/model-call-retry.d.ts +28 -0
- package/dist/agents/model-call-retry.d.ts.map +1 -0
- package/dist/agents/model-loop.d.ts +4 -2
- package/dist/agents/model-loop.d.ts.map +1 -1
- package/dist/agents/run-artifacts.d.ts +2 -0
- package/dist/agents/run-artifacts.d.ts.map +1 -1
- package/dist/agents/run-plan.d.ts +1 -1
- package/dist/agents/run-plan.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-wire.d.ts +6 -0
- package/dist/agents/run-session-wire.d.ts.map +1 -1
- package/dist/agents/thread-access.d.ts +13 -0
- package/dist/agents/thread-access.d.ts.map +1 -1
- package/dist/agents/tool-files.d.ts.map +1 -1
- package/dist/artifacts/caller.d.ts +10 -0
- package/dist/artifacts/caller.d.ts.map +1 -0
- package/dist/artifacts/comment-place.d.ts +26 -0
- package/dist/artifacts/comment-place.d.ts.map +1 -0
- package/dist/artifacts/comment-text.d.ts +12 -4
- package/dist/artifacts/comment-text.d.ts.map +1 -1
- package/dist/artifacts/comments.d.ts +8 -2
- package/dist/artifacts/comments.d.ts.map +1 -1
- package/dist/artifacts/errors.d.ts +1 -1
- package/dist/artifacts/errors.d.ts.map +1 -1
- package/dist/artifacts/execution.d.ts +73 -5
- package/dist/artifacts/execution.d.ts.map +1 -1
- package/dist/artifacts/frames/assets.d.ts +27 -7
- package/dist/artifacts/frames/assets.d.ts.map +1 -1
- package/dist/artifacts/frames/entries.d.ts +5 -4
- package/dist/artifacts/frames/entries.d.ts.map +1 -1
- package/dist/artifacts/frames/hyperframes.d.ts +12 -0
- package/dist/artifacts/frames/hyperframes.d.ts.map +1 -0
- package/dist/artifacts/frames/index.d.ts +3 -1
- package/dist/artifacts/frames/index.d.ts.map +1 -1
- package/dist/artifacts/frames/index.js +20 -6
- package/dist/artifacts/frames/index.js.map +3 -3
- package/dist/artifacts/frames/kit.d.ts.map +1 -1
- package/dist/artifacts/frames/protocol.d.ts +33 -0
- package/dist/artifacts/frames/protocol.d.ts.map +1 -1
- package/dist/artifacts/frames/video-runtime.d.ts +21 -0
- package/dist/artifacts/frames/video-runtime.d.ts.map +1 -0
- package/dist/artifacts/html.d.ts +23 -0
- package/dist/artifacts/html.d.ts.map +1 -1
- package/dist/artifacts/index.d.ts +5 -3
- package/dist/artifacts/index.d.ts.map +1 -1
- package/dist/artifacts/index.js +71 -10
- package/dist/artifacts/index.js.map +4 -4
- package/dist/artifacts/kinds.d.ts +1 -1
- package/dist/artifacts/kinds.d.ts.map +1 -1
- package/dist/artifacts/limits.d.ts +37 -0
- package/dist/artifacts/limits.d.ts.map +1 -1
- package/dist/artifacts/live/document.d.ts.map +1 -1
- package/dist/artifacts/live/index.d.ts +6 -2
- package/dist/artifacts/live/index.d.ts.map +1 -1
- package/dist/artifacts/live/index.js +3432 -13
- package/dist/artifacts/live/index.js.map +6 -3
- package/dist/artifacts/live/presence.d.ts +7 -5
- package/dist/artifacts/live/presence.d.ts.map +1 -1
- package/dist/artifacts/live/protocol.d.ts +4 -2
- package/dist/artifacts/live/protocol.d.ts.map +1 -1
- package/dist/artifacts/live/server.d.ts +1 -1
- package/dist/artifacts/live/server.d.ts.map +1 -1
- package/dist/artifacts/live/server.js +36 -31
- package/dist/artifacts/live/server.js.map +1 -1
- package/dist/artifacts/live/state.d.ts +2 -2
- package/dist/artifacts/media/media.d.ts +96 -0
- package/dist/artifacts/media/media.d.ts.map +1 -0
- package/dist/artifacts/media/transcriber.d.ts +29 -0
- package/dist/artifacts/media/transcriber.d.ts.map +1 -0
- package/dist/artifacts/outline.d.ts +26 -1
- package/dist/artifacts/outline.d.ts.map +1 -1
- package/dist/artifacts/publish/files.d.ts +5 -2
- package/dist/artifacts/publish/files.d.ts.map +1 -1
- package/dist/artifacts/publish/index.d.ts +11 -2
- package/dist/artifacts/publish/index.d.ts.map +1 -1
- package/dist/artifacts/publish/index.js +110 -33
- package/dist/artifacts/publish/index.js.map +1 -1
- package/dist/artifacts/publish/pdf.d.ts.map +1 -1
- package/dist/artifacts/publish/previews.d.ts +7 -2
- package/dist/artifacts/publish/previews.d.ts.map +1 -1
- package/dist/artifacts/publish/publish.d.ts.map +1 -1
- package/dist/artifacts/publish/validate/html.d.ts +5 -4
- package/dist/artifacts/publish/validate/html.d.ts.map +1 -1
- package/dist/artifacts/publish/validate/video.d.ts +36 -0
- package/dist/artifacts/publish/validate/video.d.ts.map +1 -0
- package/dist/artifacts/publish/video.d.ts +79 -0
- package/dist/artifacts/publish/video.d.ts.map +1 -0
- package/dist/artifacts/resolve.d.ts +9 -0
- package/dist/artifacts/resolve.d.ts.map +1 -1
- package/dist/artifacts/video/composition.d.ts +183 -0
- package/dist/artifacts/video/composition.d.ts.map +1 -0
- package/dist/artifacts/video/edit.d.ts +298 -0
- package/dist/artifacts/video/edit.d.ts.map +1 -0
- package/dist/artifacts/video/export.d.ts +142 -0
- package/dist/artifacts/video/export.d.ts.map +1 -0
- package/dist/artifacts/video/looks.d.ts +133 -0
- package/dist/artifacts/video/looks.d.ts.map +1 -0
- package/dist/artifacts/video/project.d.ts +74 -0
- package/dist/artifacts/video/project.d.ts.map +1 -0
- package/dist/artifacts/video/stills.d.ts +65 -0
- package/dist/artifacts/video/stills.d.ts.map +1 -0
- package/dist/artifacts/video/timeline.d.ts +153 -0
- package/dist/artifacts/video/timeline.d.ts.map +1 -0
- package/dist/auth/index.js +9 -8
- package/dist/auth/index.js.map +1 -1
- package/dist/authorization/index.js +5 -4
- package/dist/authorization/index.js.map +1 -1
- package/dist/blob-storage/browser.d.ts +1 -1
- package/dist/blob-storage/browser.d.ts.map +1 -1
- package/dist/blob-storage/browser.js +8 -4
- package/dist/blob-storage/browser.js.map +1 -1
- package/dist/blob-storage/constants.d.ts +8 -3
- package/dist/blob-storage/constants.d.ts.map +1 -1
- package/dist/blob-storage/download-urls.d.ts +2 -2
- package/dist/blob-storage/download-urls.d.ts.map +1 -1
- package/dist/blob-storage/index.d.ts +1 -1
- package/dist/blob-storage/index.d.ts.map +1 -1
- package/dist/blob-storage/index.js +9 -5
- package/dist/blob-storage/index.js.map +1 -1
- package/dist/blob-storage/internal.d.ts +2 -2
- package/dist/blob-storage/internal.d.ts.map +1 -1
- package/dist/blob-storage/internal.js +10 -4
- package/dist/blob-storage/internal.js.map +1 -1
- package/dist/blob-storage/media-type.d.ts +12 -3
- package/dist/blob-storage/media-type.d.ts.map +1 -1
- package/dist/bootstrap/index.js +61 -58
- package/dist/bootstrap/index.js.map +2 -2
- package/dist/{chunk-az95tsh3.js → chunk-0fjryajn.js} +3 -2
- package/dist/chunk-0fjryajn.js.map +11 -0
- package/dist/{chunk-9tpmfh3n.js → chunk-0mk8qqp9.js} +3 -3
- package/dist/{chunk-9tpmfh3n.js.map → chunk-0mk8qqp9.js.map} +3 -3
- package/dist/{chunk-88xeh6zx.js → chunk-1g4me5f2.js} +182 -7
- package/dist/{chunk-88xeh6zx.js.map → chunk-1g4me5f2.js.map} +3 -3
- package/dist/{chunk-7mhbs9yy.js → chunk-1z8ccj53.js} +1 -1
- package/dist/{chunk-wkv3h3q7.js → chunk-2138b0ng.js} +115 -8
- package/dist/chunk-2138b0ng.js.map +12 -0
- package/dist/chunk-23eaayw4.js +3757 -0
- package/dist/chunk-23eaayw4.js.map +22 -0
- package/dist/{chunk-m1cwncee.js → chunk-2mxq1yd9.js} +45 -40
- package/dist/{chunk-m1cwncee.js.map → chunk-2mxq1yd9.js.map} +3 -3
- package/dist/{chunk-dmnd9ea6.js → chunk-30a0ftnm.js} +2 -2
- package/dist/chunk-389ybvw9.js.map +2 -2
- package/dist/{chunk-qbd282aa.js → chunk-39q9ybav.js} +2 -2
- package/dist/{chunk-06kpaqg4.js → chunk-3d9w8t4n.js} +110 -22
- package/dist/{chunk-06kpaqg4.js.map → chunk-3d9w8t4n.js.map} +5 -5
- package/dist/chunk-3dvcdn9w.js +8 -0
- package/dist/chunk-3dvcdn9w.js.map +10 -0
- package/dist/{chunk-fdk0ks9p.js → chunk-3x902cja.js} +3 -3
- package/dist/{chunk-c4nrycdy.js → chunk-4q4a5a96.js} +1 -1
- package/dist/{chunk-9cyq87qa.js → chunk-4tdm3fsj.js} +95 -32
- package/dist/{chunk-9cyq87qa.js.map → chunk-4tdm3fsj.js.map} +9 -9
- package/dist/{chunk-cpy282b8.js → chunk-4w8qzy9w.js} +6 -6
- package/dist/{chunk-c29729me.js → chunk-4z9xtxke.js} +8 -7
- package/dist/chunk-4z9xtxke.js.map +12 -0
- package/dist/chunk-5278qwax.js +270 -0
- package/dist/chunk-5278qwax.js.map +11 -0
- package/dist/{chunk-k1g14kk3.js → chunk-6a4hp405.js} +4 -5
- package/dist/{chunk-k1g14kk3.js.map → chunk-6a4hp405.js.map} +3 -3
- package/dist/{chunk-xavet0qs.js → chunk-6whr25gw.js} +2 -2
- package/dist/{chunk-mbwsgjn7.js → chunk-7zygtcqq.js} +14 -2
- package/dist/chunk-7zygtcqq.js.map +11 -0
- package/dist/chunk-88s9z5pf.js +3 -0
- package/dist/{chunk-de5sfbc3.js.map → chunk-88s9z5pf.js.map} +1 -1
- package/dist/{chunk-ygvay56w.js → chunk-896te58g.js} +2 -2
- package/dist/{chunk-pfdq1ga6.js → chunk-8eqqqc1h.js} +3 -3
- package/dist/{chunk-yyj009tv.js → chunk-8tefbhdx.js} +14 -14
- package/dist/{chunk-yyj009tv.js.map → chunk-8tefbhdx.js.map} +1 -1
- package/dist/{chunk-jka26v8c.js → chunk-8x1bsp68.js} +1 -1
- package/dist/{chunk-wzcjhv54.js → chunk-93e4w7te.js} +113 -1
- package/dist/chunk-93e4w7te.js.map +11 -0
- package/dist/{chunk-phs5fbff.js → chunk-990a5bkc.js} +424 -76
- package/dist/chunk-990a5bkc.js.map +21 -0
- package/dist/{chunk-6md802cc.js → chunk-9az7kjv4.js} +6 -6
- package/dist/{chunk-95ps0k5q.js → chunk-9e5t53z0.js} +1 -1
- package/dist/{chunk-js9e6487.js → chunk-9p7kyeqz.js} +4 -4
- package/dist/chunk-a68zz4r0.js +537 -0
- package/dist/chunk-a68zz4r0.js.map +11 -0
- package/dist/{chunk-d7vyc7k6.js → chunk-a700gjc8.js} +10 -2
- package/dist/chunk-a700gjc8.js.map +10 -0
- package/dist/{chunk-gfdh9kqa.js → chunk-a9qzjaz2.js} +2 -5
- package/dist/chunk-a9qzjaz2.js.map +10 -0
- package/dist/{chunk-8qmp9fpa.js → chunk-as94vcty.js} +619 -482
- package/dist/{chunk-8qmp9fpa.js.map → chunk-as94vcty.js.map} +19 -19
- package/dist/{chunk-brybqw5k.js → chunk-bkxm2dzx.js} +1 -1
- package/dist/{chunk-ppxf7gw2.js → chunk-d7t9jnym.js} +3 -3
- package/dist/{chunk-tapdssb5.js → chunk-e3b1r4d2.js} +8 -7
- package/dist/{chunk-tapdssb5.js.map → chunk-e3b1r4d2.js.map} +4 -4
- package/dist/{chunk-cg7cygfj.js → chunk-fdmvaz7x.js} +1 -1
- package/dist/{chunk-191jz8a6.js → chunk-ff0qdk7z.js} +1 -1
- package/dist/{chunk-9vsc919v.js → chunk-fgxvrxx4.js} +22 -2
- package/dist/chunk-fgxvrxx4.js.map +10 -0
- package/dist/{chunk-wx7smkn2.js → chunk-fq8drkp0.js} +1 -1
- package/dist/{chunk-60662fyv.js → chunk-fqms1a8c.js} +132 -4
- package/dist/{chunk-60662fyv.js.map → chunk-fqms1a8c.js.map} +8 -6
- package/dist/{chunk-v8a1qjzp.js → chunk-hpswfrjj.js} +1 -1
- package/dist/{chunk-qttqe1ah.js → chunk-jbg905hn.js} +80 -13
- package/dist/chunk-jbg905hn.js.map +25 -0
- package/dist/{chunk-bz5bnjjt.js → chunk-jjte0h4p.js} +1 -1
- package/dist/{chunk-hvq8xs66.js → chunk-jwjwvzj1.js} +797 -51
- package/dist/chunk-jwjwvzj1.js.map +38 -0
- package/dist/{chunk-k29rdc3h.js → chunk-k3vd2vyz.js} +6 -2
- package/dist/chunk-k3vd2vyz.js.map +10 -0
- package/dist/chunk-kcqpk9w1.js.map +2 -2
- package/dist/chunk-mvz89age.js.map +2 -2
- package/dist/{chunk-xrmbhap8.js → chunk-mwg0nwkb.js} +1 -1
- package/dist/{chunk-a3faa34j.js → chunk-nfjt8k8j.js} +1 -1
- package/dist/{chunk-394zjzjs.js → chunk-nhgqz3g3.js} +3 -3
- package/dist/{chunk-bqr703h4.js → chunk-p0c5kkhn.js} +23 -6
- package/dist/{chunk-bqr703h4.js.map → chunk-p0c5kkhn.js.map} +3 -3
- package/dist/{chunk-92wrka15.js → chunk-q150fnj9.js} +1 -1
- package/dist/{chunk-w3t94hm6.js → chunk-qk3zq25v.js} +1 -1
- package/dist/chunk-rtkqczbr.js.map +2 -2
- package/dist/{chunk-3qtk0070.js → chunk-ssqbrts1.js} +86 -9
- package/dist/chunk-ssqbrts1.js.map +14 -0
- package/dist/{chunk-5qqmndhm.js → chunk-szzhrn3e.js} +1 -1
- package/dist/{chunk-n1hbwc6y.js → chunk-t6pfch4e.js} +1 -1
- package/dist/{chunk-xtztwpkh.js → chunk-v6h4tc2v.js} +86 -5
- package/dist/chunk-v6h4tc2v.js.map +12 -0
- package/dist/{chunk-brhp9d97.js → chunk-vmqjndb3.js} +2 -2
- package/dist/chunk-vtjzwymr.js.map +2 -2
- package/dist/{chunk-fycac8e9.js → chunk-wpba6hhd.js} +10 -10
- package/dist/{chunk-fycac8e9.js.map → chunk-wpba6hhd.js.map} +1 -1
- package/dist/{chunk-t58sktr5.js → chunk-wrb1x1ss.js} +2 -2
- package/dist/{chunk-5sswe5ej.js → chunk-wsv23wvr.js} +2 -2
- package/dist/{chunk-04r2fdsd.js → chunk-x0hqc54n.js} +4 -4
- package/dist/{chunk-sgx82nnt.js → chunk-xg31er4p.js} +43 -4
- package/dist/chunk-xg31er4p.js.map +10 -0
- package/dist/{chunk-3neam1y5.js → chunk-y3qb965a.js} +2 -2
- package/dist/{chunk-5pz3htbe.js → chunk-y57eawng.js} +3 -3
- package/dist/{chunk-8ncg20rd.js → chunk-yah25st6.js} +5 -5
- package/dist/chunk-yah25st6.js.map +10 -0
- package/dist/{chunk-mrs7jy17.js → chunk-ywvxcmqj.js} +106 -13
- package/dist/{chunk-mrs7jy17.js.map → chunk-ywvxcmqj.js.map} +8 -7
- package/dist/{chunk-44hrfmbk.js → chunk-zmq9xc9s.js} +70 -31
- package/dist/{chunk-44hrfmbk.js.map → chunk-zmq9xc9s.js.map} +4 -3
- package/dist/datasets/write.js +8 -7
- package/dist/datasets/write.js.map +1 -1
- package/dist/errors/catalog.d.ts.map +1 -1
- package/dist/execution/agent.js +52 -49
- package/dist/execution/agent.js.map +1 -1
- package/dist/execution/kernel-operation.d.ts +1 -0
- package/dist/execution/kernel-operation.d.ts.map +1 -1
- package/dist/execution/primitive.js +52 -49
- package/dist/execution/primitive.js.map +1 -1
- package/dist/execution/request.js +53 -50
- package/dist/execution/request.js.map +2 -2
- package/dist/execution/types.d.ts +5 -0
- package/dist/execution/types.d.ts.map +1 -1
- package/dist/http/api-routes.d.ts.map +1 -1
- package/dist/http/index.js +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +69 -65
- package/dist/index.js.map +1 -1
- package/dist/lake-storage/index.js +9 -8
- package/dist/lake-storage/index.js.map +1 -1
- package/dist/maintenance/index.js +9 -8
- package/dist/maintenance/index.js.map +2 -2
- package/dist/materializer/index.js +26 -24
- package/dist/materializer/index.js.map +1 -1
- package/dist/models/audio/runtime.d.ts +3 -1
- package/dist/models/audio/runtime.d.ts.map +1 -1
- package/dist/models/audio/speech.d.ts +2 -2
- package/dist/models/audio/speech.d.ts.map +1 -1
- package/dist/models/audio/types.d.ts +23 -3
- package/dist/models/audio/types.d.ts.map +1 -1
- package/dist/models/calls.d.ts +7 -0
- package/dist/models/calls.d.ts.map +1 -1
- package/dist/models/catalog.d.ts +5 -0
- package/dist/models/catalog.d.ts.map +1 -1
- package/dist/models/definitions.d.ts +3 -2
- package/dist/models/definitions.d.ts.map +1 -1
- package/dist/models/errors.d.ts +5 -3
- package/dist/models/errors.d.ts.map +1 -1
- package/dist/models/events.d.ts +2 -0
- package/dist/models/events.d.ts.map +1 -1
- package/dist/models/execution/index.d.ts +1 -0
- package/dist/models/execution/index.d.ts.map +1 -1
- package/dist/models/execution/index.js +33 -28
- package/dist/models/execution/index.js.map +1 -1
- package/dist/models/execution/model-call-limits.d.ts.map +1 -1
- package/dist/models/execution/model-call-recorder.d.ts +8 -0
- package/dist/models/execution/model-call-recorder.d.ts.map +1 -1
- package/dist/models/execution/session.d.ts +12 -0
- package/dist/models/execution/session.d.ts.map +1 -1
- package/dist/models/execution/usage.d.ts.map +1 -1
- package/dist/models/execution.d.ts +1 -1
- package/dist/models/execution.d.ts.map +1 -1
- package/dist/models/generation-types.d.ts +2 -0
- package/dist/models/generation-types.d.ts.map +1 -1
- package/dist/models/index.d.ts +4 -2
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +2 -2
- package/dist/models/input-file.d.ts.map +1 -1
- package/dist/models/pricing.d.ts +2 -1
- package/dist/models/pricing.d.ts.map +1 -1
- package/dist/models/rate-card.d.ts +6 -0
- package/dist/models/rate-card.d.ts.map +1 -1
- package/dist/models/tools.d.ts +5 -0
- package/dist/models/tools.d.ts.map +1 -1
- package/dist/models/video/catalog.d.ts +13 -0
- package/dist/models/video/catalog.d.ts.map +1 -0
- package/dist/models/video/check.d.ts +76 -0
- package/dist/models/video/check.d.ts.map +1 -0
- package/dist/models/video/runtime.d.ts +21 -0
- package/dist/models/video/runtime.d.ts.map +1 -0
- package/dist/models/video/types.d.ts +188 -0
- package/dist/models/video/types.d.ts.map +1 -0
- package/dist/objects/execution.d.ts.map +1 -1
- package/dist/objects/index.js +52 -49
- package/dist/objects/index.js.map +1 -1
- package/dist/objects/query/index.js +25 -23
- package/dist/objects/query/index.js.map +1 -1
- package/dist/objects/sdk/object-set.d.ts.map +1 -1
- package/dist/ontology/index.js +4 -4
- package/dist/ontology/internal.js +4 -4
- package/dist/pipelines/index.js +28 -26
- package/dist/pipelines/index.js.map +1 -1
- package/dist/projections/internal.js +26 -24
- package/dist/projections/internal.js.map +1 -1
- package/dist/queues/index.d.ts +1 -1
- package/dist/queues/index.d.ts.map +1 -1
- package/dist/queues/types.d.ts +103 -6
- package/dist/queues/types.d.ts.map +1 -1
- package/dist/runtime/host.d.ts.map +1 -1
- package/dist/runtime/internal.d.ts +3 -1
- package/dist/runtime/internal.d.ts.map +1 -1
- package/dist/runtime/internal.js +49 -43
- package/dist/runtime/internal.js.map +2 -2
- package/dist/runtime/sixb.d.ts.map +1 -1
- package/dist/sandboxes/index.js +6 -6
- package/dist/security/public.d.ts +6 -4
- package/dist/security/public.d.ts.map +1 -1
- package/dist/security/public.js +5 -3
- package/dist/security/public.js.map +1 -1
- package/dist/shares/internal.js +25 -23
- package/dist/shares/internal.js.map +2 -2
- package/dist/storage/agents/in-memory.d.ts +2 -1
- package/dist/storage/agents/in-memory.d.ts.map +1 -1
- package/dist/storage/agents/index.d.ts +1 -1
- package/dist/storage/agents/index.d.ts.map +1 -1
- package/dist/storage/agents/provider.js +4 -4
- package/dist/storage/agents/types.d.ts +13 -0
- package/dist/storage/agents/types.d.ts.map +1 -1
- package/dist/storage/ai-cost/analytics.d.ts +1 -0
- package/dist/storage/ai-cost/analytics.d.ts.map +1 -1
- package/dist/storage/ai-cost/groups.d.ts +2 -0
- package/dist/storage/ai-cost/groups.d.ts.map +1 -1
- package/dist/storage/ai-cost/provider.js +5 -5
- package/dist/storage/ai-cost/types.d.ts +2 -1
- package/dist/storage/ai-cost/types.d.ts.map +1 -1
- package/dist/storage/ai-cost/validation.d.ts.map +1 -1
- package/dist/storage/ai-limits/enforcement.js +3 -3
- package/dist/storage/ai-limits/provider.js +2 -2
- package/dist/storage/ai-usage/in-memory.d.ts +8 -1
- package/dist/storage/ai-usage/in-memory.d.ts.map +1 -1
- package/dist/storage/ai-usage/index.d.ts +2 -2
- package/dist/storage/ai-usage/index.d.ts.map +1 -1
- package/dist/storage/ai-usage/record.d.ts +11 -1
- package/dist/storage/ai-usage/record.d.ts.map +1 -1
- package/dist/storage/ai-usage/types.d.ts +80 -1
- package/dist/storage/ai-usage/types.d.ts.map +1 -1
- package/dist/storage/ai-usage/usage.d.ts +1 -1
- package/dist/storage/ai-usage/usage.d.ts.map +1 -1
- package/dist/storage/artifacts/in-memory.d.ts +25 -2
- 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 +12 -1
- package/dist/storage/artifacts/record.d.ts.map +1 -1
- package/dist/storage/artifacts/types.d.ts +198 -6
- package/dist/storage/artifacts/types.d.ts.map +1 -1
- package/dist/storage/executions/provider.js +3 -2
- package/dist/storage/executions/provider.js.map +1 -1
- package/dist/storage/file-upload-sessions/provider.js +10 -9
- package/dist/storage/file-upload-sessions/provider.js.map +1 -1
- package/dist/storage/in-memory/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +4 -4
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +24 -22
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/internal.d.ts +2 -2
- package/dist/storage/internal.d.ts.map +1 -1
- package/dist/storage/internal.js +34 -14
- package/dist/storage/internal.js.map +2 -2
- package/dist/storage/workflow-runs/provider.js +10 -9
- package/dist/storage/workflow-runs/provider.js.map +1 -1
- package/dist/syncs/index.js +29 -27
- package/dist/syncs/index.js.map +1 -1
- package/dist/testing/agent-storage-contract.d.ts.map +1 -1
- package/dist/testing/ai-cost-storage-contract.d.ts.map +1 -1
- package/dist/testing/ai-usage-storage-contract.d.ts.map +1 -1
- package/dist/testing/artifact-storage-contract.d.ts +3 -0
- package/dist/testing/artifact-storage-contract.d.ts.map +1 -1
- package/dist/testing/execution-storage-contract.d.ts.map +1 -1
- package/dist/testing/index.js +619 -72
- package/dist/testing/index.js.map +9 -9
- package/dist/testing/lake-storage-contract.d.ts.map +1 -1
- package/dist/testing/queues-contract.d.ts.map +1 -1
- package/dist/webhooks/internal.js +26 -24
- package/dist/webhooks/internal.js.map +2 -2
- package/dist/workers/index.js +5 -5
- package/dist/workers/index.js.map +1 -1
- package/dist/workflows/index.js +58 -55
- package/dist/workflows/index.js.map +1 -1
- package/package.json +3 -1
- package/src/actions/request.ts +2 -0
- package/src/actions/run/context.ts +1 -0
- package/src/actions/run/execute.ts +5 -1
- package/src/actions/run/executor.ts +4 -0
- package/src/actions/run/normalize.ts +4 -0
- package/src/actions/run/types.ts +6 -0
- package/src/actions/types/context.ts +7 -0
- package/src/agents/README.md +3 -1
- package/src/agents/context/entries.ts +63 -9
- package/src/agents/context-model.ts +9 -0
- package/src/agents/context-resolution.ts +7 -0
- package/src/agents/execution.ts +39 -0
- package/src/agents/model-call-retry.ts +69 -0
- package/src/agents/model-loop.ts +86 -12
- package/src/agents/run-artifacts.ts +10 -5
- package/src/agents/run-plan.ts +2 -1
- package/src/agents/run-session-http.ts +1 -0
- package/src/agents/run-session-serve.ts +23 -2
- package/src/agents/run-session-wire.ts +45 -0
- package/src/agents/thread-access.ts +34 -1
- package/src/agents/tool-files.ts +23 -7
- package/src/artifacts/caller.ts +42 -0
- package/src/artifacts/comment-place.ts +51 -0
- package/src/artifacts/comment-text.ts +50 -7
- package/src/artifacts/comments.ts +132 -34
- package/src/artifacts/errors.ts +1 -0
- package/src/artifacts/execution.ts +249 -5
- package/src/artifacts/frames/assets.ts +93 -15
- package/src/artifacts/frames/entries.ts +7 -4
- package/src/artifacts/frames/generated/hyperframes-notices.txt +290 -0
- package/src/artifacts/frames/generated/hyperframes.txt +1145 -0
- package/src/artifacts/frames/generated.d.ts +5 -0
- package/src/artifacts/frames/hyperframes.ts +14 -0
- package/src/artifacts/frames/index.ts +5 -0
- package/src/artifacts/frames/kit.ts +7 -3
- package/src/artifacts/frames/protocol.ts +56 -0
- package/src/artifacts/frames/video-runtime.ts +165 -0
- package/src/artifacts/html.ts +13 -0
- package/src/artifacts/index.ts +7 -0
- package/src/artifacts/kinds.ts +9 -1
- package/src/artifacts/limits.ts +43 -0
- package/src/artifacts/live/document.ts +27 -3
- package/src/artifacts/live/index.ts +58 -2
- package/src/artifacts/live/presence.ts +17 -5
- package/src/artifacts/live/protocol.ts +4 -2
- package/src/artifacts/live/server.ts +1 -1
- package/src/artifacts/live/state.ts +3 -3
- package/src/artifacts/media/README.md +75 -0
- package/src/artifacts/media/media.ts +316 -0
- package/src/artifacts/media/transcriber.ts +84 -0
- package/src/artifacts/outline.ts +28 -0
- package/src/artifacts/publish/files.ts +19 -6
- package/src/artifacts/publish/index.ts +49 -2
- package/src/artifacts/publish/pdf.ts +3 -1
- package/src/artifacts/publish/previews.ts +22 -8
- package/src/artifacts/publish/publish.ts +4 -1
- package/src/artifacts/publish/validate/html.ts +23 -18
- package/src/artifacts/publish/validate/video.ts +309 -0
- package/src/artifacts/publish/video.ts +235 -0
- package/src/artifacts/resolve.ts +45 -0
- package/src/artifacts/video/README.md +402 -0
- package/src/artifacts/video/composition.ts +898 -0
- package/src/artifacts/video/edit.ts +3967 -0
- package/src/artifacts/video/export.ts +352 -0
- package/src/artifacts/video/looks.ts +694 -0
- package/src/artifacts/video/project.ts +198 -0
- package/src/artifacts/video/stills.ts +168 -0
- package/src/artifacts/video/timeline.ts +658 -0
- package/src/blob-storage/browser.ts +1 -1
- package/src/blob-storage/constants.ts +9 -3
- package/src/blob-storage/download-urls.ts +5 -3
- package/src/blob-storage/index.ts +1 -0
- package/src/blob-storage/internal.ts +13 -2
- package/src/blob-storage/media-type.ts +149 -8
- package/src/errors/catalog.ts +2 -1
- package/src/execution/authorization.ts +2 -2
- package/src/execution/kernel-operation.ts +14 -0
- package/src/execution/types.ts +2 -0
- package/src/http/api-routes.ts +117 -0
- package/src/index.ts +18 -1
- package/src/lake-storage/definition-updates.ts +3 -9
- package/src/models/audio/runtime.ts +48 -3
- package/src/models/audio/speech.ts +2 -2
- package/src/models/audio/types.ts +24 -3
- package/src/models/calls.ts +35 -18
- package/src/models/catalog.ts +9 -2
- package/src/models/definitions.ts +4 -2
- package/src/models/errors.ts +5 -3
- package/src/models/events.ts +2 -0
- package/src/models/execution/README.md +68 -2
- package/src/models/execution/index.ts +1 -0
- package/src/models/execution/model-call-limits.ts +11 -5
- package/src/models/execution/model-call-recorder.ts +14 -0
- package/src/models/execution/session.ts +52 -23
- package/src/models/execution/usage.ts +1 -0
- package/src/models/execution.ts +13 -2
- package/src/models/generation-types.ts +2 -0
- package/src/models/index.ts +20 -1
- package/src/models/input-file.ts +7 -2
- package/src/models/pricing.ts +19 -1
- package/src/models/rate-card.ts +15 -3
- package/src/models/tools.ts +5 -0
- package/src/models/video/catalog.ts +101 -0
- package/src/models/video/check.ts +441 -0
- package/src/models/video/runtime.ts +550 -0
- package/src/models/video/types.ts +194 -0
- package/src/objects/execution.ts +2 -0
- package/src/objects/sdk/object-set.ts +2 -0
- package/src/queues/index.ts +5 -0
- package/src/queues/types.ts +126 -5
- package/src/runtime/host.ts +3 -0
- package/src/runtime/internal.ts +3 -1
- package/src/runtime/sixb.ts +12 -4
- package/src/sandboxes/README.md +3 -2
- package/src/security/public.ts +6 -4
- package/src/storage/agents/in-memory.ts +39 -0
- package/src/storage/agents/index.ts +1 -0
- package/src/storage/agents/types.ts +14 -0
- package/src/storage/ai-cost/analytics.ts +2 -0
- package/src/storage/ai-cost/codec.ts +1 -0
- package/src/storage/ai-cost/groups.ts +7 -0
- package/src/storage/ai-cost/types.ts +2 -0
- package/src/storage/ai-cost/validation.ts +2 -0
- package/src/storage/ai-usage/in-memory.ts +93 -0
- package/src/storage/ai-usage/index.ts +10 -0
- package/src/storage/ai-usage/record.ts +106 -0
- package/src/storage/ai-usage/types.ts +102 -1
- package/src/storage/ai-usage/usage.ts +2 -0
- package/src/storage/artifacts/in-memory.ts +108 -11
- package/src/storage/artifacts/index.ts +14 -0
- package/src/storage/artifacts/record.ts +203 -1
- package/src/storage/artifacts/types.ts +199 -6
- package/src/storage/executions/validation.ts +2 -2
- package/src/storage/in-memory/index.ts +1 -1
- package/src/storage/index.ts +22 -1
- package/src/storage/internal.ts +9 -0
- package/src/testing/agent-storage-contract.ts +108 -0
- package/src/testing/ai-cost-storage-contract.ts +1 -0
- package/src/testing/ai-usage-storage-contract.ts +145 -1
- package/src/testing/artifact-storage-contract.ts +320 -0
- package/src/testing/execution-storage-contract.ts +10 -2
- package/src/testing/lake-storage-contract.ts +27 -0
- package/src/testing/queues-contract.ts +71 -0
- package/dist/chunk-3723kgba.js +0 -29
- package/dist/chunk-3723kgba.js.map +0 -10
- package/dist/chunk-3qtk0070.js.map +0 -14
- package/dist/chunk-8ncg20rd.js.map +0 -10
- package/dist/chunk-9vsc919v.js.map +0 -10
- package/dist/chunk-az95tsh3.js.map +0 -11
- package/dist/chunk-c29729me.js.map +0 -12
- package/dist/chunk-d7vyc7k6.js.map +0 -10
- package/dist/chunk-de5sfbc3.js +0 -3
- package/dist/chunk-gfdh9kqa.js.map +0 -11
- package/dist/chunk-hvq8xs66.js.map +0 -34
- package/dist/chunk-k29rdc3h.js.map +0 -10
- package/dist/chunk-mbwsgjn7.js.map +0 -11
- package/dist/chunk-phs5fbff.js.map +0 -19
- package/dist/chunk-qttqe1ah.js.map +0 -24
- package/dist/chunk-sgx82nnt.js.map +0 -10
- package/dist/chunk-vs2s3p8n.js +0 -2274
- package/dist/chunk-vs2s3p8n.js.map +0 -20
- package/dist/chunk-wkv3h3q7.js.map +0 -12
- package/dist/chunk-wzcjhv54.js.map +0 -11
- package/dist/chunk-xtztwpkh.js.map +0 -12
- /package/dist/{chunk-7mhbs9yy.js.map → chunk-1z8ccj53.js.map} +0 -0
- /package/dist/{chunk-dmnd9ea6.js.map → chunk-30a0ftnm.js.map} +0 -0
- /package/dist/{chunk-qbd282aa.js.map → chunk-39q9ybav.js.map} +0 -0
- /package/dist/{chunk-fdk0ks9p.js.map → chunk-3x902cja.js.map} +0 -0
- /package/dist/{chunk-c4nrycdy.js.map → chunk-4q4a5a96.js.map} +0 -0
- /package/dist/{chunk-cpy282b8.js.map → chunk-4w8qzy9w.js.map} +0 -0
- /package/dist/{chunk-xavet0qs.js.map → chunk-6whr25gw.js.map} +0 -0
- /package/dist/{chunk-ygvay56w.js.map → chunk-896te58g.js.map} +0 -0
- /package/dist/{chunk-pfdq1ga6.js.map → chunk-8eqqqc1h.js.map} +0 -0
- /package/dist/{chunk-jka26v8c.js.map → chunk-8x1bsp68.js.map} +0 -0
- /package/dist/{chunk-6md802cc.js.map → chunk-9az7kjv4.js.map} +0 -0
- /package/dist/{chunk-95ps0k5q.js.map → chunk-9e5t53z0.js.map} +0 -0
- /package/dist/{chunk-js9e6487.js.map → chunk-9p7kyeqz.js.map} +0 -0
- /package/dist/{chunk-brybqw5k.js.map → chunk-bkxm2dzx.js.map} +0 -0
- /package/dist/{chunk-ppxf7gw2.js.map → chunk-d7t9jnym.js.map} +0 -0
- /package/dist/{chunk-cg7cygfj.js.map → chunk-fdmvaz7x.js.map} +0 -0
- /package/dist/{chunk-191jz8a6.js.map → chunk-ff0qdk7z.js.map} +0 -0
- /package/dist/{chunk-wx7smkn2.js.map → chunk-fq8drkp0.js.map} +0 -0
- /package/dist/{chunk-v8a1qjzp.js.map → chunk-hpswfrjj.js.map} +0 -0
- /package/dist/{chunk-bz5bnjjt.js.map → chunk-jjte0h4p.js.map} +0 -0
- /package/dist/{chunk-xrmbhap8.js.map → chunk-mwg0nwkb.js.map} +0 -0
- /package/dist/{chunk-a3faa34j.js.map → chunk-nfjt8k8j.js.map} +0 -0
- /package/dist/{chunk-394zjzjs.js.map → chunk-nhgqz3g3.js.map} +0 -0
- /package/dist/{chunk-92wrka15.js.map → chunk-q150fnj9.js.map} +0 -0
- /package/dist/{chunk-w3t94hm6.js.map → chunk-qk3zq25v.js.map} +0 -0
- /package/dist/{chunk-5qqmndhm.js.map → chunk-szzhrn3e.js.map} +0 -0
- /package/dist/{chunk-n1hbwc6y.js.map → chunk-t6pfch4e.js.map} +0 -0
- /package/dist/{chunk-brhp9d97.js.map → chunk-vmqjndb3.js.map} +0 -0
- /package/dist/{chunk-t58sktr5.js.map → chunk-wrb1x1ss.js.map} +0 -0
- /package/dist/{chunk-5sswe5ej.js.map → chunk-wsv23wvr.js.map} +0 -0
- /package/dist/{chunk-04r2fdsd.js.map → chunk-x0hqc54n.js.map} +0 -0
- /package/dist/{chunk-3neam1y5.js.map → chunk-y3qb965a.js.map} +0 -0
- /package/dist/{chunk-5pz3htbe.js.map → chunk-y57eawng.js.map} +0 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/agents/thread-access.ts", "../src/artifacts/access.ts", "../src/artifacts/events.ts", "../src/artifacts/comments.ts", "../src/artifacts/holders.ts", "../src/artifacts/live/state.ts", "../src/artifacts/live/files.ts", "../src/artifacts/publish/merge.ts", "../src/artifacts/publish/pdf.ts", "../src/artifacts/publish/previews.ts", "../src/artifacts/publish/query-answers.ts", "../src/artifacts/publish/validate/document-html.ts", "../src/artifacts/paper.ts", "../src/artifacts/publish/fields.ts", "../src/artifacts/run-query.ts", "../src/artifacts/publish/queries.ts", "../src/artifacts/publish/references.ts", "../src/artifacts/publish/validate/canvas.ts", "../src/artifacts/publish/validate/document.ts", "../src/artifacts/publish/validate/file.ts", "../src/artifacts/publish/validate/page.ts", "../src/artifacts/publish/validate/sheet.ts", "../src/artifacts/publish/validate/slides.ts", "../src/artifacts/publish/video.ts", "../src/artifacts/publish/validate/video.ts", "../src/artifacts/publish/publish.ts", "../src/artifacts/video/export.ts", "../src/artifacts/video/stills.ts", "../src/artifacts/execution.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { type Principal, principalsEqual, SYSTEM_PRINCIPAL, type UserPrincipal } from \"../auth\"\nimport { isRuntimeAllowed } from \"../authorization\"\nimport type { resolveRuntimeAuthorizationForProject } from \"../execution/authorization\"\nimport type { AuthorizablePrincipal } from \"../execution/types\"\nimport type { SixbRuntimeContext } from \"../runtime/types\"\nimport type {\n AgentRunFailureCode,\n AgentRunFinishReason,\n AgentRunRecord,\n AgentRunStatus,\n AgentStorage,\n AgentThreadRecord,\n} from \"../storage/agents\"\nimport { AgentRequestError } from \"./errors\"\n\n/** How the caller takes part in a conversation: its owner, or a user its owner added. */\nexport type AgentThreadAccess = \"owner\" | \"participant\"\n\n/** A user the thread's owner added, who reads the conversation and talks in it. */\nexport interface AgentThreadParticipant {\n readonly principal: UserPrincipal\n readonly addedAt: Date\n readonly addedBy: Principal\n}\n\n/**\n * How far the caller's reading of a thread has reached, and what arrived past it. Reading on one\n * device clears it on every other.\n */\nexport interface AgentThreadReadView {\n readonly threadId: string\n /** The seq of the last message their reading reached; 0 when it reached none. */\n readonly throughSeq: number\n /** The seq of the thread's newest message, 0 when it has none. */\n readonly headSeq: number\n /**\n * Messages past `throughSeq` that someone else wrote: the Agent's answers and other people's\n * messages. Their own messages are not new to them, nor is a message that only reports how\n * approved calls ended.\n */\n readonly unread: number\n /** When they last marked the thread read, even where their place did not move. */\n readonly readAt?: Date\n}\n\n/** The thread's newest run, enough for a client to offer Continue or Retry without reading it. */\nexport interface AgentThreadLastRunView {\n readonly id: string\n readonly status: AgentRunStatus\n readonly finishReason?: AgentRunFinishReason\n /** Why it failed, when it did. */\n readonly errorCode?: AgentRunFailureCode\n readonly completedAt?: Date\n /**\n * Who asked for it, when it ended short (failed, timed out or interrupted): only they can run it\n * again, as it runs with their rights.\n */\n readonly requestedBy?: AuthorizablePrincipal\n}\n\n/** A run that stopped before its answer: it failed, timed out, or its worker went away. */\nexport function agentRunEndedShort(run: Pick<AgentRunRecord, \"status\" | \"finishReason\">): boolean {\n if (run.status === \"failed\") return true\n return run.finishReason === \"timeout\" || run.finishReason === \"interrupted\"\n}\n\n/**\n * A thread as the runtime returns it: the stored record with the users taking part in it, the\n * caller's place in it, and its newest run. `read` is absent for an observer, and for system code,\n * which is nobody's reading.\n */\nexport interface AgentThreadView extends AgentThreadRecord {\n readonly participants: readonly AgentThreadParticipant[]\n readonly read?: AgentThreadReadView\n readonly lastRun?: AgentThreadLastRunView\n}\n\n/** A thread the caller can read, and how it takes part in it. */\nexport interface ReadableAgentThread {\n readonly thread: AgentThreadView\n readonly access: AgentThreadAccess\n}\n\ntype RuntimeAuthority = ReturnType<typeof resolveRuntimeAuthorizationForProject>\n\n/**\n * The one rule for who reads a conversation through `sixb.agent`.\n *\n * The caller needs `can.run(agent)`, then must own the thread or take part in it. Code without a\n * caller (authorization disabled, or system code) reads every thread as its owner. A shared link,\n * a delegated execution or a denied caller reads none. An observer reads every thread through\n * `sixb.agent.observed` instead, without ever being its owner or a participant.\n *\n * A sub-agent's thread is read exactly when its conversation is, with the caller's access there:\n * whoever stops reading the conversation stops reading its children with it.\n */\nexport interface AgentThreadAccessRule {\n /** Who acts: the signed-in principal, or the system principal for code without a caller. */\n readonly caller: Principal\n /** The thread and how the caller takes part in it; `null` when it cannot read it. */\n read(threadId: string): Promise<ReadableAgentThread | null>\n /**\n * The conversations among these threads the caller reads, each once, as `read` answers each but\n * read together, in a few queries however many there are. A sub-agent's thread is left out.\n */\n readConversations(threadIds: readonly string[]): Promise<readonly ReadableAgentThread[]>\n /**\n * Whose conversations the caller reads, for a list to ask its storage for those alone: a\n * principal's, as owner or participant; `\"every\"` for code without a caller; `\"none\"` when it\n * reads none.\n */\n scope(): { readonly reader: Principal } | \"every\" | \"none\"\n}\n\nexport function createAgentThreadAccessRule(\n runtime: SixbRuntimeContext,\n authority: RuntimeAuthority,\n /** Where threads are read, the project's storage when omitted: a transaction's decides in it. */\n agents?: AgentStorage\n): AgentThreadAccessRule {\n const caller = authority.type === \"principal\" ? authority.context.principal : SYSTEM_PRINCIPAL\n const blocked = authority.type === \"denied\" || authority.type === \"delegated\"\n\n const accessIn = (thread: AgentThreadView): AgentThreadAccess | null => {\n if (blocked || !isRuntimeAllowed(runtime, { kind: \"agent.run\" })) return null\n if (authority.type !== \"principal\") return \"owner\"\n if (principalsEqual(caller, thread.ownerPrincipal)) return \"owner\"\n\n return thread.participants.some((participant) => principalsEqual(participant.principal, caller))\n ? \"participant\"\n : null\n }\n\n const read = async (threadId: string): Promise<ReadableAgentThread | null> => {\n if (blocked) return null\n\n const storage = agents ?? runtime.storage.agents\n const getById = (id: string) => storage?.threads.getById({ projectId: runtime.projectId, id })\n const stored = await getById(threadId)\n if (!stored) return null\n\n // One level only: a child's parent is always a conversation, as storage admits no other.\n const conversation = stored.parent ? await getById(stored.parent.threadId) : stored\n if (conversation?.kind !== \"conversation\") return null\n\n const [thread, readThrough = thread] = await agentThreadViews(\n runtime,\n conversation === stored ? [stored] : [stored, conversation],\n storage\n )\n const access = readThrough ? accessIn(readThrough) : null\n return thread && access ? { thread, access } : null\n }\n\n const readConversations = async (\n threadIds: readonly string[]\n ): Promise<readonly ReadableAgentThread[]> => {\n if (blocked || threadIds.length === 0) return []\n\n const storage = agents ?? runtime.storage.agents\n const stored =\n (await storage?.threads.getByIds({ projectId: runtime.projectId, ids: threadIds })) ?? []\n const conversations = stored.filter((thread) => thread.kind === \"conversation\")\n\n const views = await agentThreadViews(runtime, conversations, storage)\n return views.flatMap((thread) => {\n const access = accessIn(thread)\n return access ? [{ thread, access }] : []\n })\n }\n\n const scope = (): ReturnType<AgentThreadAccessRule[\"scope\"]> => {\n if (blocked || !isRuntimeAllowed(runtime, { kind: \"agent.run\" })) return \"none\"\n return authority.type === \"principal\" ? { reader: caller } : \"every\"\n }\n\n return { caller, read, readConversations, scope }\n}\n\n/** Refuse what only a conversation takes: a message, a fork, a participant, a mode, a sandbox. */\nexport function assertConversationThread(thread: Pick<AgentThreadRecord, \"id\" | \"kind\">): void {\n if (thread.kind === \"conversation\") return\n throw new AgentRequestError(\n \"thread_not_conversation\",\n `[Sixb] Agent thread '${thread.id}' is a sub-agent's: it is read through its conversation and takes no change of its own.`\n )\n}\n\n/**\n * The conversation a thread belongs to: the thread itself, or a sub-agent's parent. What a child\n * publishes, and the thread its sandbox names, are its conversation's.\n */\nexport function conversationThreadId(thread: Pick<AgentThreadRecord, \"id\" | \"parent\">): string {\n return thread.parent?.threadId ?? thread.id\n}\n\n/** Stored threads as the runtime returns them, with their participants and no execution tokens. */\nexport async function agentThreadViews(\n runtime: SixbRuntimeContext,\n threads: readonly AgentThreadRecord[],\n agents: AgentStorage | undefined = runtime.storage.agents\n): Promise<readonly AgentThreadView[]> {\n const participants =\n threads.length === 0\n ? []\n : ((await agents?.threads.listParticipants({\n projectId: runtime.projectId,\n threadIds: threads.map((thread) => thread.id),\n })) ?? [])\n\n return threads.map((thread) => ({\n ...publicThread(thread),\n participants: participants\n .filter((participant) => participant.threadId === thread.id)\n .map(({ principal, addedAt, addedBy }) => ({ principal, addedAt, addedBy })),\n }))\n}\n\n/** Execution ownership tokens never leave the storage/worker boundary. */\nfunction publicThread(thread: AgentThreadRecord): AgentThreadRecord {\n if (!thread.sandboxState) return thread\n\n const { name, status, initialized } = thread.sandboxState\n return { ...thread, sandboxState: { name, status, initialized } }\n}\n",
|
|
6
|
+
"import { type Principal, principalsEqual } from \"../auth\"\nimport type { ArtifactRecord, ArtifactStorage } from \"../storage/artifacts/types\"\nimport { ArtifactRequestError } from \"./errors\"\n\n/**\n * What the caller may do with an artifact.\n *\n * - `owner`: everything, deleting it included.\n * - `update`: read every version and publish the next one, as the owner, a participant of a\n * conversation that shares it, or someone who edits an object that holds it.\n * - `read`: read every version, as someone who observes a conversation that shares it, or reads\n * an object that holds it.\n * - `none`: nothing; the artifact exists but is not shared with the caller.\n */\nexport type ArtifactAccess = \"owner\" | \"update\" | \"read\" | \"none\"\n\n/** How the caller reads a conversation: talking in it, only observing it, or not at all. */\nexport type ConversationAccess = \"update\" | \"read\" | null\n\n/**\n * How the caller reaches an artifact through the objects that hold it: editing one, only reading\n * one, or through none.\n */\nexport type HolderAccess = \"update\" | \"read\" | null\n\n/**\n * The one rule for who reaches an artifact.\n *\n * Its owner reaches it, and code without a caller reaches every artifact. Anyone else reaches an\n * artifact through what shares it, and gets the most any of them gives:\n *\n * - a conversation they read, which shares the artifact the Agent published a version in, or a\n * fork of it copied: whoever owns or takes part in it may update the artifact, and an observer\n * only reads it. Only a signed-in session reaches what conversations share.\n * - an object that holds it in a property: whoever reads the object and that property reads the\n * artifact, and may update it when they may also edit the object's type. Every credential\n * reaches what objects hold, an access token included.\n *\n * A shared link's visitor, a guest, reaches only what the objects their link shares hold, and only\n * reads it: their link shows objects, it never lets them change one. The artifact is shared whole,\n * at every version, whatever published each one. A caller that reaches no artifact gets `none`.\n *\n * A rule reads how the caller reaches each conversation and each artifact's holders once, so it\n * lives for one operation.\n */\nexport interface ArtifactAccessRule {\n accessTo(artifact: ArtifactRecord): Promise<ArtifactAccess>\n /**\n * What the caller may do when publishing the artifact's next version from a conversation, or\n * outside any without `threadId`. A version published in a conversation shares the artifact\n * there: that is how sharing starts. Its owner, and whoever may update it through an object,\n * publish from any conversation. Anyone else publishes from a conversation only when it already\n * shares the artifact, with the access they have there, so a version never shares someone else's\n * artifact in another conversation.\n */\n publishAccess(artifact: ArtifactRecord, threadId?: string): Promise<ArtifactAccess>\n /** How the caller reads the artifacts a conversation shares. */\n conversation(threadId: string): Promise<ConversationAccess>\n}\n\nexport function createArtifactAccessRule(input: {\n readonly storage: ArtifactStorage\n readonly projectId: string\n /**\n * `system` for code without a caller, `guest` for a shared link's visitor, `null` for a caller\n * that reaches no artifact.\n */\n readonly caller: Principal | \"system\" | \"guest\" | null\n /** `false` unless the caller signed in with a session: anything else reaches no conversation. */\n readonly sharing: boolean\n /** How the caller reads a conversation, by the thread-access rule. */\n readonly conversation: (threadId: string) => Promise<ConversationAccess>\n /** How the caller reaches the artifact through the objects that hold it. */\n readonly holders: (artifact: ArtifactRecord) => Promise<HolderAccess>\n}): ArtifactAccessRule {\n const { caller } = input\n const conversations = new Map<string, Promise<ConversationAccess>>()\n const holders = new Map<string, Promise<HolderAccess>>()\n\n const conversation = (threadId: string): Promise<ConversationAccess> => {\n if (caller === null || caller === \"guest\" || !input.sharing) return Promise.resolve(null)\n\n let reads = conversations.get(threadId)\n if (!reads) {\n reads = input.conversation(threadId)\n conversations.set(threadId, reads)\n }\n return reads\n }\n\n const throughObjects = (artifact: ArtifactRecord): Promise<HolderAccess> => {\n let reaches = holders.get(artifact.id)\n if (!reaches) {\n // A guest only reads, whatever their objects' type would let a member do.\n reaches = input\n .holders(artifact)\n .then((access) => (caller === \"guest\" && access !== null ? \"read\" : access))\n holders.set(artifact.id, reaches)\n }\n return reaches\n }\n\n /** `owner` or `none` when the answer needs no other source; `undefined` when it does. */\n const ownAccess = (artifact: ArtifactRecord): ArtifactAccess | undefined => {\n if (caller === null) return \"none\"\n if (caller === \"guest\") return undefined\n if (caller === \"system\" || principalsEqual(caller, artifact.owner)) return \"owner\"\n return undefined\n }\n\n const threadIdsOf = async (artifact: ArtifactRecord): Promise<readonly string[]> =>\n input.sharing\n ? input.storage.listThreadIds({ projectId: input.projectId, id: artifact.id })\n : []\n\n const accessTo = async (artifact: ArtifactRecord): Promise<ArtifactAccess> => {\n const own = ownAccess(artifact)\n if (own) return own\n\n let access: ArtifactAccess = \"none\"\n for (const threadId of await threadIdsOf(artifact)) {\n const reads = await conversation(threadId)\n if (reads === \"update\") return \"update\"\n if (reads === \"read\") access = \"read\"\n }\n\n // Objects come last: each holder is an object read again as the caller, which costs more\n // than a conversation's participants.\n return (await throughObjects(artifact)) ?? access\n }\n\n const publishAccess = async (\n artifact: ArtifactRecord,\n threadId?: string\n ): Promise<ArtifactAccess> => {\n if (threadId === undefined) return accessTo(artifact)\n\n const own = ownAccess(artifact)\n if (own) return own\n\n const shared = (await threadIdsOf(artifact)).includes(threadId)\n const here = shared ? await conversation(threadId) : null\n if (here === \"update\") return \"update\"\n\n // Whoever may update it through an object writes it from any conversation, as its owner does.\n if ((await throughObjects(artifact)) === \"update\") return \"update\"\n return here ?? \"none\"\n }\n\n return { accessTo, publishAccess, conversation }\n}\n\n/** Refuses an artifact the caller may not update: `not_shared`, or `read_only` for a reader. */\nexport function assertUpdatable(artifactId: string, access: ArtifactAccess): void {\n if (access === \"none\") {\n throw new ArtifactRequestError(\n \"not_shared\",\n `[Sixb] Artifact '${artifactId}' is not shared with you.`\n )\n }\n\n if (access === \"read\") {\n throw new ArtifactRequestError(\n \"read_only\",\n `[Sixb] You only read artifact '${artifactId}': you cannot change it or keep page data in it.`\n )\n }\n}\n",
|
|
7
|
+
"import type { DomainEventLog } from \"../events/service\"\nimport type { ArtifactCommentRecord, ArtifactVersionRecord } from \"../storage/artifacts/types\"\n\n/**\n * Tells whoever reads each artifact that its latest version changed, as `artifact.updated`. The\n * writes are stored by now, so `emit` never fails them: an event lost on the way only leaves a\n * viewer showing what it read until it reads again.\n */\nexport async function announceArtifactUpdates(\n events: Pick<DomainEventLog, \"emit\">,\n latest: readonly ArtifactVersionRecord[]\n): Promise<void> {\n if (latest.length === 0) return\n\n await events.emit(\n {\n events: latest.map((version) => ({\n type: \"artifact.updated\" as const,\n payload: {\n artifactId: version.artifactId,\n version: version.version,\n revision: version.revision,\n frozen: version.frozenAt !== undefined,\n },\n // A revision changes once: announcing it again is the same event.\n idempotencyKey: `artifact.updated:${version.artifactId}:${version.revision}`,\n })),\n },\n { source: \"Sixb\" }\n )\n}\n\n/**\n * Tells whoever reads the comment's thread that it changed, as `artifact.commented`: the\n * artifact's members, and the guests of `shareGrantId`, the link a guest's thread came through.\n * The change is stored by now, so `emit` never fails it.\n */\nexport async function announceArtifactComment(\n events: Pick<DomainEventLog, \"emit\">,\n comment: Pick<ArtifactCommentRecord, \"artifactId\" | \"id\" | \"parentId\">,\n shareGrantId: string | undefined,\n action: \"created\" | \"resolved\" | \"reopened\" | \"deleted\"\n): Promise<void> {\n await events.emit(\n {\n events: [\n {\n type: \"artifact.commented\" as const,\n payload: {\n artifactId: comment.artifactId,\n commentId: comment.id,\n ...(comment.parentId === undefined ? {} : { parentId: comment.parentId }),\n ...(shareGrantId === undefined ? {} : { shareGrantId }),\n action,\n },\n },\n ],\n },\n { source: \"Sixb\" }\n )\n}\n",
|
|
8
|
+
"import type { Principal } from \"../auth\"\nimport { principalsEqual } from \"../auth\"\nimport type { DomainEventLog } from \"../events/service\"\nimport { ArtifactStorageError } from \"../storage/artifacts/errors\"\nimport type {\n ArtifactCommentAnchor,\n ArtifactCommentAuthor,\n ArtifactCommentRecord,\n ArtifactOrigin,\n ArtifactRecord,\n ArtifactStorage,\n} from \"../storage/artifacts/types\"\nimport type { ArtifactAccess } from \"./access\"\nimport { videoSceneAt } from \"./comment-place\"\nimport { ArtifactRequestError } from \"./errors\"\nimport { announceArtifactComment } from \"./events\"\nimport { createArtifactCommentId } from \"./ids\"\nimport { ARTIFACT_COMMENT_LIMITS } from \"./limits\"\nimport type { ArtifactOutline } from \"./outline\"\n\n// Comments on an artifact: whoever reads it reads and adds them, a shared link's guest included;\n// their author, or whoever may change the artifact, resolves or deletes them, and only the latter a\n// guest's. Each change is announced to its readers.\n//\n// A thread is the team's unless a guest started it. A guest reads only the threads started by a\n// guest of the same link, themselves or whoever else opened it, with every reply, a member's\n// included: the team's threads are missing to them, as if there were none.\n\n/** A comment to add, or a reply. */\nexport interface ArtifactCommentInput {\n /** Plain text. */\n readonly body: string\n /**\n * What it is about: a canvas's board by its item id, an element of the board by the address\n * `boardElements` gives it, with its first words as `label`; a video's instant in its latest\n * version, `at`, and the scene playing then, or a scene; or, without, the artifact. At the\n * revision its author saw, the artifact's by default. A reply is about what it replies to.\n */\n readonly anchor?: ArtifactCommentPlaceInput\n /** The comment this one replies to. */\n readonly parentId?: string\n /** The Agent's run that writes it for the caller, and that run's conversation. */\n readonly origin?: ArtifactOrigin\n}\n\n/**\n * Where a new comment is, as its author names it: a video's instant from its start, which the\n * comment keeps as an offset into the scene playing it.\n */\nexport type ArtifactCommentPlaceInput = Partial<Omit<ArtifactCommentAnchor, \"offset\">>\n\n/** The comment methods of the artifacts runtime. */\nexport interface ArtifactCommentsRuntime {\n /**\n * Every comment and reply the caller reads, oldest first: a shared link's guest, only its link's\n * threads. `null` when the caller cannot read the artifact.\n */\n listComments(artifactId: string): Promise<ArtifactCommentRecord[] | null>\n /**\n * Adds a comment, or a reply, authored by the caller, who must read the artifact. A shared link's\n * guest writes it under the name they gave, and is refused with `name_required` until they give\n * one. Throws `invalid_comment` for words or an anchor that will not do, `comment_not_found` for\n * a reply to no comment the caller reads, and `comments_full`.\n */\n addComment(artifactId: string, input: ArtifactCommentInput): Promise<ArtifactCommentRecord>\n /**\n * Marks a comment resolved, or opens it again. Its author or whoever may change the artifact\n * may: anyone else, and every guest, is refused with `not_allowed`, or `comment_not_found` for a\n * guest's comment they do not read.\n */\n resolveComment(\n artifactId: string,\n commentId: string,\n resolved?: boolean\n ): Promise<ArtifactCommentRecord>\n /** Deletes a comment and its replies, as `resolveComment` allows. */\n deleteComment(artifactId: string, commentId: string): Promise<void>\n}\n\n/** An element's address, as `boardElements` writes it, and the longest one a comment keeps. */\nconst ELEMENT_ADDRESS = /^body(>[a-z][a-z0-9-]*:\\d+)*$/\nconst MAX_ELEMENT_ADDRESS_LENGTH = 1024\n\nexport function createArtifactCommentsRuntime(input: {\n readonly projectId: string\n readonly storage: () => ArtifactStorage\n readonly events: Pick<DomainEventLog, \"emit\">\n /** Who writes a comment the caller adds. */\n readonly author: () => Promise<ArtifactCommentAuthor>\n /** Who resolves or deletes one; throws `not_allowed` for a caller who never may. */\n readonly manager: () => Principal\n /**\n * For a shared link's guest, the link they came through, by its grant: they read only the\n * threads its guests started. Without it, a member reads every thread.\n */\n readonly guest?: { readonly grantId?: string }\n readonly reach: (\n artifactId: string\n ) => Promise<{ readonly artifact: ArtifactRecord; readonly access: ArtifactAccess } | null>\n}): ArtifactCommentsRuntime {\n const { projectId, events, guest } = input\n\n /** The thread a comment is in: the comment itself, or the one it replies to. */\n const threadOf = (comment: ArtifactCommentRecord) =>\n comment.parentId === undefined\n ? Promise.resolve(comment)\n : input\n .storage()\n .getComment({ projectId, artifactId: comment.artifactId, id: comment.parentId })\n\n /** Whether the caller reads this thread: a member every one, a guest only its link's. */\n const reads = (thread: ArtifactCommentRecord | null): thread is ArtifactCommentRecord =>\n thread !== null &&\n (!guest || (guest.grantId !== undefined && threadLink(thread) === guest.grantId))\n\n /** The artifact the caller reads; refused with why otherwise. */\n const readable = async (artifactId: string) => {\n const reached = await input.reach(artifactId)\n if (!reached) throw notFound(artifactId)\n if (reached.access === \"none\") {\n throw new ArtifactRequestError(\n \"not_shared\",\n `[Sixb] Artifact '${artifactId}' is not shared with you.`\n )\n }\n return reached\n }\n\n /**\n * A comment the caller may resolve or delete, with its thread: theirs, or one on an artifact they\n * may change. One in a thread they do not read is missing.\n */\n const managed = async (artifactId: string, commentId: string) => {\n const { access } = await readable(artifactId)\n const comment = await input.storage().getComment({ projectId, artifactId, id: commentId })\n const thread = comment ? await threadOf(comment) : null\n if (!comment || !reads(thread)) throw commentNotFound(artifactId, commentId)\n const manager = input.manager()\n\n // A guest's comment is managed by those who may change the artifact, never by a guest.\n const changes = access === \"owner\" || access === \"update\"\n const authored = comment.author.type !== \"guest\" && principalsEqual(comment.author, manager)\n if (!changes && !authored) {\n throw new ArtifactRequestError(\n \"not_allowed\",\n \"[Sixb] Only a comment's author, or whoever may change the artifact, resolves or deletes it.\"\n )\n }\n return { comment, thread }\n }\n\n return {\n async listComments(artifactId) {\n const reached = await input.reach(artifactId)\n if (!reached || reached.access === \"none\") return null\n\n const comments = await input.storage().listComments({ projectId, id: artifactId })\n if (!guest) return comments\n\n const threads = new Set(\n comments\n .filter((comment) => comment.parentId === undefined && reads(comment))\n .map((comment) => comment.id)\n )\n return comments.filter((comment) => threads.has(comment.parentId ?? comment.id))\n },\n\n async addComment(artifactId, comment) {\n const { artifact } = await readable(artifactId)\n const author = await input.author()\n const storage = input.storage()\n\n const body = comment.body.trim()\n if (body.length === 0 || body.length > ARTIFACT_COMMENT_LIMITS.maxBodyLength) {\n throw invalid(\n `A comment holds 1 to ${ARTIFACT_COMMENT_LIMITS.maxBodyLength} characters of text.`\n )\n }\n\n // A reply is about what it replies to, in a thread the caller reads.\n let anchor: ArtifactCommentAnchor\n let parent: ArtifactCommentRecord | null = null\n if (comment.parentId !== undefined) {\n parent = await storage.getComment({ projectId, artifactId, id: comment.parentId })\n if (!reads(parent)) throw commentNotFound(artifactId, comment.parentId)\n anchor = parent.anchor\n } else {\n anchor = await checkAnchor(storage, artifact, comment.anchor ?? {})\n }\n\n try {\n const created = await storage.createComment({\n projectId,\n artifactId,\n id: createArtifactCommentId(),\n ...(comment.parentId === undefined ? {} : { parentId: comment.parentId }),\n anchor,\n body,\n author,\n ...(comment.origin ? { origin: comment.origin } : {}),\n createdAt: new Date(),\n })\n await announceArtifactComment(events, created, threadLink(parent ?? created), \"created\")\n return created\n } catch (error) {\n throw commentRequestError(error)\n }\n },\n\n async resolveComment(artifactId, commentId, resolved = true) {\n const { thread } = await managed(artifactId, commentId)\n const changed = await input.storage().resolveComment({\n projectId,\n artifactId,\n id: commentId,\n resolved: resolved ? { at: new Date(), by: input.manager() } : null,\n })\n if (!changed) throw commentNotFound(artifactId, commentId)\n\n await announceArtifactComment(\n events,\n changed,\n threadLink(thread),\n resolved ? \"resolved\" : \"reopened\"\n )\n return changed\n },\n\n async deleteComment(artifactId, commentId) {\n const { comment, thread } = await managed(artifactId, commentId)\n const deleted = await input.storage().deleteComment({ projectId, artifactId, id: commentId })\n if (!deleted) throw commentNotFound(artifactId, commentId)\n\n await announceArtifactComment(events, comment, threadLink(thread), \"deleted\")\n },\n }\n}\n\n/**\n * The shared link whose guests read a thread, by its grant: the one its first comment's guest came\n * through. None for a thread a member started, which is the team's.\n */\nfunction threadLink(thread: Pick<ArtifactCommentRecord, \"author\">): string | undefined {\n return thread.author.type === \"guest\" ? thread.author.grantId : undefined\n}\n\n/**\n * The anchor as it is kept: a place its artifact's latest version has, as its kind places a\n * comment, its label cut to length, and a revision the artifact has had.\n */\nasync function checkAnchor(\n storage: ArtifactStorage,\n artifact: ArtifactRecord,\n anchor: ArtifactCommentPlaceInput\n): Promise<ArtifactCommentAnchor> {\n const revision = anchor.revision ?? artifact.revision\n if (!Number.isSafeInteger(revision) || revision < 1 || revision > artifact.revision) {\n throw invalid(`A comment is about a revision of the artifact, 1 to ${artifact.revision}.`)\n }\n\n // A video's scene is named by its own label, which still names it once a version drops it.\n const { label: named, ...place } = await checkPlace(storage, artifact, anchor)\n const label = (named ?? anchor.label)\n ?.replace(/\\s+/g, \" \")\n .trim()\n .slice(0, ARTIFACT_COMMENT_LIMITS.maxLabelLength)\n return { ...place, ...(label ? { label } : {}), revision }\n}\n\ntype CommentPlace = Omit<ArtifactCommentAnchor, \"revision\">\n\n/**\n * Where on the artifact a comment is, as its kind places one: on a canvas, a board, an element of\n * it, and a point on it; on a video, an instant, its scene, and a point on the frame. A comment on\n * any other kind is about the whole artifact.\n */\nasync function checkPlace(\n storage: ArtifactStorage,\n artifact: ArtifactRecord,\n anchor: ArtifactCommentPlaceInput\n): Promise<CommentPlace> {\n const { board, element, at, scene, point } = anchor\n const placed = [board, element, at, scene, point].some((value) => value !== undefined)\n if (!placed) return {}\n\n if (\n point !== undefined &&\n ![point.x, point.y].every((value) => Number.isFinite(value) && value >= 0 && value <= 1)\n ) {\n throw invalid(\"A comment's point is on what it is about: x and y from 0 to 1.\")\n }\n\n const latest = async () =>\n (\n await storage.getVersion({\n projectId: artifact.projectId,\n artifactId: artifact.id,\n version: artifact.latestVersion,\n })\n )?.outline\n\n switch (artifact.kind) {\n case \"canvas\":\n return checkBoardPlace(anchor, latest)\n case \"video\":\n return checkScenePlace(anchor, latest)\n default:\n throw invalid(\n `A comment on a ${artifact.kind} is about the whole artifact: it names no board, scene, or instant.`\n )\n }\n}\n\n/** A board the canvas's latest version shows, an element's address under it, and a point on it. */\nasync function checkBoardPlace(\n anchor: ArtifactCommentPlaceInput,\n latest: () => Promise<ArtifactOutline | undefined>\n): Promise<CommentPlace> {\n const { board, element, point } = anchor\n if (anchor.at !== undefined || anchor.scene !== undefined) {\n throw invalid(\"A comment on a canvas is about a board, not an instant or a scene.\")\n }\n\n if (element !== undefined && board === undefined) {\n throw invalid(\"A comment on an element names the board it is on.\")\n }\n if (\n element !== undefined &&\n (element.length > MAX_ELEMENT_ADDRESS_LENGTH || !ELEMENT_ADDRESS.test(element))\n ) {\n throw invalid(`'${element}' is no element's address, as a board's elements have.`)\n }\n if (point !== undefined && board === undefined) {\n throw invalid(\"A comment's point is on the board it names.\")\n }\n\n if (board !== undefined) {\n const outline = await latest()\n const shows =\n outline?.kind === \"canvas\" &&\n outline.items.some((item) => item.type === \"board\" && item.id === board)\n if (!shows) throw invalid(`The artifact shows no board '${board}'.`)\n }\n\n return {\n ...(board === undefined ? {} : { board }),\n ...(element === undefined ? {} : { element }),\n ...(point === undefined ? {} : { point: { x: point.x, y: point.y } }),\n }\n}\n\n/**\n * An instant within the video's latest version, a scene it has, and a point on the frame at that\n * instant: the frame changes as it plays, so a point needs its instant. An instant is kept as how\n * far into the scene playing it, the one named or else the one on screen then, so that it follows\n * the scene in later versions; one that plays no scene keeps its instant from the video's start.\n */\nasync function checkScenePlace(\n anchor: ArtifactCommentPlaceInput,\n latest: () => Promise<ArtifactOutline | undefined>\n): Promise<CommentPlace> {\n const { at, scene, point } = anchor\n if (anchor.board !== undefined || anchor.element !== undefined) {\n throw invalid(\"A comment on a video is about an instant or a scene, not a board.\")\n }\n if (point !== undefined && at === undefined) {\n throw invalid(\"A comment's point is on the frame at its instant: give it `at` too.\")\n }\n\n const outline = await latest()\n if (outline?.kind !== \"video\") throw invalid(\"The artifact has no video to comment on.\")\n\n if (at !== undefined && !(Number.isSafeInteger(at) && at >= 0 && at <= outline.durationMs)) {\n throw invalid(\n `A comment's instant is in the video: \\`at\\` is 0 to ${outline.durationMs} milliseconds.`\n )\n }\n const named = scene === undefined ? undefined : outline.scenes.find((each) => each.id === scene)\n if (scene !== undefined && !named) throw invalid(`The video has no scene '${scene}'.`)\n if (named && at !== undefined && (at < named.startMs || at > named.startMs + named.durationMs)) {\n throw invalid(\n `Scene '${named.id}' plays from ${named.startMs} to ${named.startMs + named.durationMs} milliseconds: a comment's \\`at\\` is in the scene it names, or names none.`\n )\n }\n\n const playing = named ?? (at === undefined ? undefined : videoSceneAt(outline, at))\n const instant = at === undefined ? {} : playing ? { offset: at - playing.startMs } : { at }\n return {\n ...(playing ? { scene: playing.id } : {}),\n ...(playing?.label === undefined ? {} : { label: playing.label }),\n ...instant,\n ...(point === undefined ? {} : { point: { x: point.x, y: point.y } }),\n }\n}\n\nfunction commentRequestError(error: unknown): unknown {\n if (!(error instanceof ArtifactStorageError)) return error\n switch (error.code) {\n case \"artifact_not_found\":\n return new ArtifactRequestError(\"artifact_not_found\", error.message)\n case \"comment_not_found\":\n return new ArtifactRequestError(\"comment_not_found\", error.message)\n case \"artifact_comments_full\":\n return new ArtifactRequestError(\"comments_full\", error.message)\n default:\n return error\n }\n}\n\nfunction invalid(message: string): ArtifactRequestError {\n return new ArtifactRequestError(\"invalid_comment\", `[Sixb] ${message}`)\n}\n\nfunction notFound(artifactId: string): ArtifactRequestError {\n return new ArtifactRequestError(\n \"artifact_not_found\",\n `[Sixb] Artifact '${artifactId}' was not found.`\n )\n}\n\nfunction commentNotFound(artifactId: string, commentId: string): ArtifactRequestError {\n return new ArtifactRequestError(\n \"comment_not_found\",\n `[Sixb] Artifact '${artifactId}' has no comment '${commentId}'.`\n )\n}\n",
|
|
9
|
+
"/**\n * The objects that hold an artifact, as one caller reads them.\n *\n * The holder index (`ObjectStorage.listArtifactHolders`) is unscoped, and nothing rewrites it when\n * the ontology changes, so a row is never trusted as it is: each holder is read again through the\n * caller's object reader, as a file an object holds is opened. The object must be one they read,\n * the property one they are cleared for, and its value must still hold the artifact. Whoever may\n * also edit the object's type may update the artifact.\n */\nimport { isRuntimeAllowed } from \"../authorization\"\nimport { AuthorizationError } from \"../authorization/errors\"\nimport type { AuthorizedObjectReader } from \"../execution/authorized-object-reader\"\nimport { collectArtifactRefIds } from \"../ontology/artifact-ref\"\nimport type { SixbRuntimeContext } from \"../runtime/types\"\nimport type { ObjectRow, ObjectStorage } from \"../storage\"\nimport { objectBatchKey } from \"../storage/objects/keys\"\nimport type { ArtifactHolder } from \"../storage/ontology\"\n\n/** One object property that holds the artifact, as the caller reads it. */\nexport interface ArtifactHolding extends ArtifactHolder {\n /** `update` when the caller may edit the object's type, `read` otherwise. */\n readonly access: \"update\" | \"read\"\n /** The object, as the caller reads it. */\n readonly object: ObjectRow\n}\n\n/** How many index rows each read takes: an artifact is rarely held by more objects than this. */\nconst HOLDER_PAGE = 100\n\n/**\n * The holdings of the artifact that the caller reads, in the index's order. Each page of holders\n * is read with one object read per type; stop iterating to stop reading.\n */\nexport async function* readableHoldings(input: {\n readonly runtime: SixbRuntimeContext\n /** The caller's reader, reading from the same storage as `objects`. */\n readonly reader: AuthorizedObjectReader\n readonly objects: Pick<ObjectStorage, \"listArtifactHolders\">\n readonly artifactId: string\n}): AsyncGenerator<ArtifactHolding> {\n const { runtime, reader, artifactId } = input\n let after: ArtifactHolder | undefined\n\n do {\n const page = await input.objects.listArtifactHolders({\n projectId: runtime.projectId,\n artifactId,\n ...(after ? { after } : {}),\n limit: HOLDER_PAGE,\n })\n\n const objects = await readHolders(reader, page.holders)\n for (const holder of page.holders) {\n const object = objects.get(objectBatchKey(holder.objectTypeId, holder.primaryId))\n if (!object || !holdsArtifact(runtime, object, holder.propertyId, artifactId)) continue\n\n const edits = isRuntimeAllowed(runtime, {\n kind: \"object.edit\",\n objectTypeId: holder.objectTypeId,\n })\n yield { ...holder, access: edits ? \"update\" : \"read\", object }\n }\n\n after = page.next\n } while (after)\n}\n\n/**\n * The holders' objects the caller reads, keyed by `objectBatchKey`. A type they cannot view reads\n * nothing, and an object their view condition hides is absent.\n */\nasync function readHolders(\n reader: AuthorizedObjectReader,\n holders: readonly ArtifactHolder[]\n): Promise<ReadonlyMap<string, ObjectRow>> {\n // An object that holds the artifact under several properties is read once.\n const byType = new Map<string, Set<string>>()\n for (const { objectTypeId, primaryId } of holders) {\n const primaryIds = byType.get(objectTypeId) ?? new Set()\n byType.set(objectTypeId, primaryIds.add(primaryId))\n }\n\n const read = new Map<string, ObjectRow>()\n for (const [objectTypeId, primaryIds] of byType) {\n try {\n const rows = await reader.getByPrimaryIdBatch({\n items: [...primaryIds].map((primaryId) => ({ objectTypeId, primaryId })),\n })\n for (const [key, row] of rows) read.set(key, row)\n } catch (error) {\n if (!(error instanceof AuthorizationError)) throw error\n }\n }\n\n return read\n}\n\n/**\n * Whether the property, as the caller reads it, still holds the artifact. One the caller is not\n * cleared for comes back without its value, and one the type no longer declares holds nothing.\n */\nfunction holdsArtifact(\n runtime: SixbRuntimeContext,\n object: ObjectRow,\n propertyId: string,\n artifactId: string\n): boolean {\n const property = runtime.ontology\n .getObjectTypeById(object.objectTypeId)\n ?.properties.find((candidate) => candidate.id === propertyId)\n if (!property) return false\n\n const held = collectArtifactRefIds(\n property.schema,\n object.properties[propertyId],\n runtime.ontology.getValueTypesById(),\n new Set()\n )\n return held.has(artifactId)\n}\n",
|
|
10
|
+
"import * as Y from \"yjs\"\nimport type { BlobStorage, FileRef } from \"../../blob-storage/types\"\nimport type { ArtifactDocument, ArtifactFile, ArtifactRecord } from \"../../storage/artifacts/types\"\nimport type { ArtifactKind } from \"../kinds\"\nimport { createArtifactDocument, documentFiles, holdPage, mergeIntoDocument } from \"./document\"\nimport { readLiveFiles } from \"./files\"\n\n// An artifact's document as storage keeps it: its whole Yjs state in one blob, replaced by every\n// write. Everyone who loads it, a server holding it live or a write merging into it, continues\n// the same history, so their changes merge as Yjs merges concurrent edits.\n\n/**\n * Whether an artifact is edited live, and so keeps its content as a document: a canvas, a\n * document, Markdown or designed, which people edit in place, and a video, cut on its timeline.\n */\nexport function keepsDocument(kind: ArtifactKind): boolean {\n return kind === \"canvas\" || kind === \"document\" || kind === \"video\"\n}\n\n/**\n * The artifact's document, holding `files`, its latest version's.\n *\n * - The one storage keeps, when it holds the artifact's revision.\n * - One storage left behind, written without a document since: that one, then the change from what\n * it holds to `files`.\n * - None yet: one built from `files`.\n *\n * The last two are made under a client id named by what they start from and the files, so that\n * whoever makes one, wherever, makes the same history; the next write stores it. The document's\n * own changes are made under a fresh id.\n */\nexport async function loadArtifactDocument(\n blobStorage: Pick<BlobStorage, \"open\">,\n artifact: Pick<ArtifactRecord, \"id\" | \"kind\" | \"revision\" | \"document\">,\n files: readonly ArtifactFile[]\n): Promise<Y.Doc> {\n const doc = new Y.Doc()\n const stored = artifact.document\n const clientID = madeClientId(artifact.id, stored, files)\n if (stored?.revision === artifact.revision) {\n Y.applyUpdate(doc, await readDocumentState(blobStorage, stored.file))\n holdPage(doc, clientID)\n return doc\n }\n\n const live = await readLiveFiles(blobStorage, files)\n let made: Y.Doc\n if (stored) {\n made = new Y.Doc()\n made.clientID = clientID\n Y.applyUpdate(made, await readDocumentState(blobStorage, stored.file))\n mergeIntoDocument(made, documentFiles(made), live)\n } else {\n made = createArtifactDocument(artifact.kind, live, { clientID })\n }\n\n Y.applyUpdate(doc, Y.encodeStateAsUpdate(made))\n made.destroy()\n holdPage(doc, clientID)\n return doc\n}\n\n/** The encoded state storage keeps of an artifact's document. */\nexport async function readDocumentState(\n blobStorage: Pick<BlobStorage, \"open\">,\n document: FileRef\n): Promise<Uint8Array> {\n return new Uint8Array(await new Response(await blobStorage.open(document.blobId)).arrayBuffer())\n}\n\n/** Stores a document's whole state, for the write that holds its content. */\nexport async function storeArtifactDocument(\n blobStorage: Pick<BlobStorage, \"put\">,\n doc: Y.Doc\n): Promise<FileRef> {\n const body = Y.encodeStateAsUpdate(doc)\n return blobStorage.put({\n body,\n expectedSizeBytes: body.byteLength,\n fileName: \"document.yjs\",\n mediaType: \"application/octet-stream\",\n })\n}\n\n/** The document of a new artifact's first version, for a kind that keeps one. */\nexport async function firstArtifactDocument(\n blobStorage: Pick<BlobStorage, \"open\" | \"put\">,\n kind: ArtifactKind,\n files: readonly ArtifactFile[]\n): Promise<FileRef | undefined> {\n if (!keepsDocument(kind)) return undefined\n const doc = createArtifactDocument(kind, await readLiveFiles(blobStorage, files))\n try {\n return await storeArtifactDocument(blobStorage, doc)\n } finally {\n doc.destroy()\n }\n}\n\n/**\n * A Yjs client id named by what a document is made from: FNV-1a over the artifact, the document\n * left behind, if any, and each file's path and digest.\n */\nfunction madeClientId(\n artifactId: string,\n stored: ArtifactDocument | undefined,\n files: readonly ArtifactFile[]\n): number {\n const named = [...files]\n .map(({ path, file }) => `${path}\\u0000${file.digest}`)\n .sort()\n .join(\"\\u0001\")\n const from = stored ? `${stored.file.digest}@${stored.revision}` : \"\"\n let hash = 0x811c9dc5\n for (const char of `${artifactId}\\u0002${from}\\u0002${named}`) {\n hash ^= char.codePointAt(0) ?? 0\n hash = Math.imul(hash, 0x01000193) >>> 0\n }\n return hash\n}\n",
|
|
11
|
+
"import { createHash } from \"node:crypto\"\nimport { posix } from \"node:path\"\nimport { inferFileMediaType } from \"../../blob-storage/media-type\"\nimport type { BlobStorage } from \"../../blob-storage/types\"\nimport type { ArtifactFile } from \"../../storage/artifacts/types\"\nimport { ARTIFACT_LIMITS } from \"../limits\"\nimport { isLiveTextPath, type LiveFile, type LiveFiles } from \"./document\"\n\n// A version's files as the live layer reads them, and back. Reading takes each text file's words\n// from blob storage; storing puts back only the texts that changed, so a write keeps the\n// references of every file it did not touch.\n\nconst strictUtf8 = new TextDecoder(\"utf-8\", { fatal: true })\n\n/**\n * A version's files as text where their path says they are and their bytes are UTF-8 text no\n * larger than a file may be; any other is held as its reference.\n */\nexport async function readLiveFiles(\n blobStorage: Pick<BlobStorage, \"open\">,\n files: readonly ArtifactFile[]\n): Promise<Map<string, LiveFile>> {\n const read = await Promise.all(\n files.map(async ({ path, file }): Promise<[string, LiveFile]> => {\n if (!isLiveTextPath(path) || file.sizeBytes > ARTIFACT_LIMITS.maxFileBytes) {\n return [path, { file }]\n }\n\n const bytes = new Uint8Array(\n await new Response(await blobStorage.open(file.blobId)).arrayBuffer()\n )\n try {\n return [path, { text: strictUtf8.decode(bytes) }]\n } catch {\n return [path, { file }]\n }\n })\n )\n return new Map(read.sort(([left], [right]) => (left < right ? -1 : 1)))\n}\n\n/**\n * Files to publish from what the live layer holds: a text that `known` already holds at its path\n * keeps its reference, and any other is stored, with the media type its path had.\n */\nexport async function storeLiveFiles(\n blobStorage: Pick<BlobStorage, \"put\">,\n files: LiveFiles,\n known: readonly ArtifactFile[]\n): Promise<ArtifactFile[]> {\n const byPath = new Map(known.map((entry) => [entry.path, entry.file]))\n\n return Promise.all(\n [...files].map(async ([path, file]): Promise<ArtifactFile> => {\n if (\"file\" in file) return { path, file: { ...file.file } }\n\n const body = new TextEncoder().encode(file.text)\n const digest = `sha256:${createHash(\"sha256\").update(body).digest(\"hex\")}`\n const before = byPath.get(path)\n if (before?.digest === digest) return { path, file: { ...before } }\n\n const fileName = posix.basename(path)\n const stored = await blobStorage.put({\n body,\n expectedSizeBytes: body.byteLength,\n fileName,\n mediaType: before?.mediaType ?? inferFileMediaType(fileName, body),\n })\n return { path, file: stored }\n })\n )\n}\n\n/** Whether two sets of files are the same files, path by path and byte for byte. */\nexport function sameArtifactFiles(\n left: readonly ArtifactFile[],\n right: readonly ArtifactFile[]\n): boolean {\n if (left.length !== right.length) return false\n const digests = new Map(left.map((entry) => [entry.path, entry.file.digest]))\n return right.every((entry) => digests.get(entry.path) === entry.file.digest)\n}\n",
|
|
12
|
+
"import * as Y from \"yjs\"\nimport type { BlobStorage, FileRef } from \"../../blob-storage/types\"\nimport { ArtifactStorageError } from \"../../storage/artifacts/errors\"\nimport { turnUndoable } from \"../../storage/artifacts/record\"\nimport type { ArtifactFile, ArtifactStorage } from \"../../storage/artifacts/types\"\nimport { ArtifactRequestError } from \"../errors\"\nimport type { ArtifactKind } from \"../kinds\"\nimport { documentFiles, type LiveFiles, mergeIntoDocument } from \"../live/document\"\nimport { readLiveFiles, sameArtifactFiles, storeLiveFiles } from \"../live/files\"\nimport { keepsDocument, loadArtifactDocument, storeArtifactDocument } from \"../live/state\"\n\n// A canvas, or a designed document, is edited by many at once, and keeps its content as a Yjs\n// document (see ../live/state.ts). Every write to one is made into that document: a live editor's\n// as the Yjs update it holds, any other as the changes from the files it was made from to its own.\n// A write made from an earlier revision is so merged, not refused, and whatever was written\n// meanwhile stays. Anything else keeps the conflict check.\n\n/** How many times a merged write starts over when another lands between its merge and its store. */\nconst MERGE_ATTEMPTS = 3\n\n/** A write to an artifact, made from the files of `baseRevision`. */\nexport interface ArtifactWrite {\n readonly artifactId: string\n readonly kind: ArtifactKind\n readonly files: readonly ArtifactFile[]\n readonly baseRevision?: number\n /** The files of `baseRevision`, when the writer holds them; otherwise looked up. */\n readonly baseFiles?: readonly ArtifactFile[]\n /** The title it writes, and the one of `baseRevision`: a title given since stays unless it changes it. */\n readonly title?: string\n readonly baseTitle?: string\n /**\n * The artifact's document as a live editor holds it, encoded as a Yjs update: merged into the\n * stored one, whose files the write then holds.\n */\n readonly update?: Uint8Array\n}\n\n/** A write as it is stored: merged when the artifact moved past its base. */\nexport interface MergedArtifactWrite {\n readonly files: readonly ArtifactFile[]\n readonly baseRevision?: number\n /** It was merged with what others wrote since its base. */\n readonly merged: boolean\n /** The document that holds the write's content, for a kind that keeps one. */\n readonly document?: FileRef\n /** The title to keep instead of the write's: one given since its base, which it did not change. */\n readonly title?: string\n}\n\n/**\n * The write to store. One to an artifact that keeps a document is made into that document, which\n * is stored with it, and is based on the latest revision; one that moved past its base is merged\n * into what the latest version holds now. A write whose base files are not known is left as it is,\n * for the conflict check to refuse.\n */\nexport async function mergeArtifactWrite(\n context: {\n readonly projectId: string\n readonly storage: ArtifactStorage\n readonly blobStorage: Pick<BlobStorage, \"open\" | \"put\">\n },\n write: ArtifactWrite\n): Promise<MergedArtifactWrite> {\n const unmerged = {\n files: write.files,\n ...(write.baseRevision === undefined ? {} : { baseRevision: write.baseRevision }),\n merged: false,\n }\n if (!keepsDocument(write.kind)) return unmerged\n\n const { projectId, storage, blobStorage } = context\n const artifact = await storage.get({ projectId, id: write.artifactId })\n const latest =\n artifact &&\n (await storage.getVersion({\n projectId,\n artifactId: artifact.id,\n version: artifact.latestVersion,\n }))\n if (!artifact || !latest || artifact.kind !== write.kind) return unmerged\n\n const moved = write.baseRevision !== undefined && write.baseRevision !== artifact.revision\n const doc = await loadArtifactDocument(blobStorage, artifact, latest.files)\n try {\n let merged = moved\n if (write.update) {\n Y.applyUpdate(doc, write.update)\n } else {\n // The changes from the files it was made from. Those the writer names are its base, even\n // at the latest revision: an Agent's copy may hold less than the version it was installed\n // at, which merged others' words in, and a diff from the version would take them out.\n const files = moved\n ? (write.baseFiles ??\n (await filesAtRevision(storage, projectId, artifact.id, write.baseRevision ?? 0)))\n : write.baseFiles\n if (moved && !files) return unmerged\n\n // Made from what the latest version holds, as after a freeze: nothing to merge with.\n let base: LiveFiles = documentFiles(doc)\n merged = files !== undefined && files !== null && !sameArtifactFiles(files, latest.files)\n if (merged && files) base = await readLiveFiles(blobStorage, files)\n mergeIntoDocument(doc, base, await readLiveFiles(blobStorage, write.files))\n }\n\n // Merged, the write holds what the document holds; otherwise it is stored as it was made.\n // What the write and the latest version both hold keeps its reference, the write's first.\n const files =\n merged || write.update\n ? await storeLiveFiles(blobStorage, documentFiles(doc), [...latest.files, ...write.files])\n : write.files\n const renamed =\n moved &&\n write.baseTitle !== undefined &&\n write.title === write.baseTitle &&\n artifact.title !== write.title\n return {\n files,\n baseRevision: artifact.revision,\n merged,\n document: await storeArtifactDocument(blobStorage, doc),\n ...(renamed ? { title: artifact.title } : {}),\n }\n } finally {\n doc.destroy()\n }\n}\n\n/**\n * Runs a write, merged as {@link mergeArtifactWrite} merges it, and starts over when another write\n * lands between the merge and the store: `store` then fails with `artifact_moved`, which a merged\n * kind never shows its writer.\n */\nexport async function withMergedWrite<T>(\n context: MergeContext,\n write: ArtifactWrite,\n store: (merged: MergedArtifactWrite) => Promise<T>\n): Promise<T> {\n for (let attempt = 1; ; attempt += 1) {\n const merged = await mergeArtifactWrite(context, write)\n try {\n return await store(merged)\n } catch (error) {\n if (!isMoved(error) || !keepsDocument(write.kind) || attempt === MERGE_ATTEMPTS) {\n throw error\n }\n }\n }\n}\n\ntype MergeContext = Parameters<typeof mergeArtifactWrite>[0]\n\n/**\n * The artifact's document once it holds `files` again, as a restore or an undo puts them back:\n * the change to them, made into its stored document, and the revision that is based on. Null for\n * a kind that keeps no document, or without the artifact.\n */\nexport async function documentHolding(\n context: MergeContext,\n artifactId: string,\n files: readonly ArtifactFile[]\n): Promise<{ readonly document: FileRef; readonly baseRevision: number } | null> {\n const { projectId, storage, blobStorage } = context\n const artifact = await storage.get({ projectId, id: artifactId })\n if (!artifact || !keepsDocument(artifact.kind)) return null\n const latest = await storage.getVersion({\n projectId,\n artifactId,\n version: artifact.latestVersion,\n })\n if (!latest) return null\n\n const doc = await loadArtifactDocument(blobStorage, artifact, latest.files)\n try {\n mergeIntoDocument(doc, documentFiles(doc), await readLiveFiles(blobStorage, files))\n return {\n document: await storeArtifactDocument(blobStorage, doc),\n baseRevision: artifact.revision,\n }\n } finally {\n doc.destroy()\n }\n}\n\n/**\n * Runs a write that puts `files` back, with the document that holds them, based on the revision\n * it was made at; it starts over when another write lands first. A caller's own `baseRevision`\n * is kept, and the write then refused past it, as it would be without a document.\n */\nexport async function withDocumentHolding<T>(\n context: MergeContext,\n artifactId: string,\n files: readonly ArtifactFile[] | null,\n baseRevision: number | undefined,\n store: (held: { readonly document?: FileRef; readonly baseRevision?: number }) => Promise<T>\n): Promise<T> {\n for (let attempt = 1; ; attempt += 1) {\n const held = files ? await documentHolding(context, artifactId, files) : null\n const base = baseRevision ?? held?.baseRevision\n const fits = held && (baseRevision === undefined || baseRevision === held.baseRevision)\n try {\n return await store({\n ...(fits ? { document: held.document } : {}),\n ...(base === undefined ? {} : { baseRevision: base }),\n })\n } catch (error) {\n if (!isMoved(error) || baseRevision !== undefined || !held || attempt === MERGE_ATTEMPTS) {\n throw error\n }\n }\n }\n}\n\n/**\n * The documents of the artifacts a retry of a turn puts back, by id: each one the undo will put\n * back, as the turn's restore point holds it. Made before the undo, at the revision it requires,\n * so the undo can store them: one written meanwhile is not undone, and its document goes unused.\n * The later turns undone with it count as it does, as `laterTurnRunIds` says.\n */\nexport async function undoneTurnDocuments(\n context: MergeContext,\n turnRunId: string,\n laterTurnRunIds: readonly string[] = []\n): Promise<Record<string, FileRef>> {\n const { projectId, storage } = context\n const documents: Record<string, FileRef> = {}\n\n const laterWrites = new Map<string, number>()\n for (const later of laterTurnRunIds) {\n for (const write of await storage.listTurnWrites({ projectId, turnRunId: later })) {\n laterWrites.set(write.artifactId, (laterWrites.get(write.artifactId) ?? 0) + write.writes)\n }\n }\n\n for (const own of await storage.listTurnWrites({ projectId, turnRunId })) {\n if (own.created) continue\n const write = { ...own, writes: own.writes + (laterWrites.get(own.artifactId) ?? 0) }\n\n const artifact = await storage.get({ projectId, id: write.artifactId })\n if (!artifact || !keepsDocument(artifact.kind)) continue\n\n // Undone by the rule the undo applies, at the revision it will find.\n const points = await storage.listRestorePoints({ projectId, id: artifact.id })\n const point = points.find((each) => each.turnRunId === turnRunId)\n const target =\n point &&\n (await storage.getVersion({ projectId, artifactId: artifact.id, version: point.version }))\n const undoable = turnUndoable({\n write,\n revision: artifact.revision,\n ...(point ? { point } : {}),\n ...(target ? { target: { frozen: target.frozenAt !== undefined } } : {}),\n })\n if (!point || !undoable || !keepsDocument(artifact.kind)) continue\n\n const held = await documentHolding(context, artifact.id, point.files)\n if (held?.baseRevision === artifact.revision) documents[artifact.id] = held.document\n }\n return documents\n}\n\nfunction isMoved(error: unknown): boolean {\n return (\n (error instanceof ArtifactRequestError || error instanceof ArtifactStorageError) &&\n error.code === \"artifact_moved\"\n )\n}\n\n/**\n * The files the artifact held at a revision, when something still holds them: its latest version,\n * one of its versions, or a restore point. Null for a revision since replaced.\n */\nasync function filesAtRevision(\n storage: ArtifactStorage,\n projectId: string,\n artifactId: string,\n revision: number\n): Promise<readonly ArtifactFile[] | null> {\n const point = await storage.getRestorePoint({ projectId, artifactId, revision })\n if (point) return point.files\n\n const { versions } = await storage.listVersions({ projectId, artifactId, limit: 50 })\n return versions.find((version) => version.revision === revision)?.files ?? null\n}\n",
|
|
13
|
+
"import { createHash } from \"node:crypto\"\nimport type { FileRef } from \"../../blob-storage/types\"\nimport type { Queue, RenderQueueJob } from \"../../queues\"\nimport type { ArtifactStorage, ArtifactVersionRecord } from \"../../storage/artifacts/types\"\nimport { frameKitDigest } from \"./previews\"\nimport { DOCUMENT_HTML_ENTRY } from \"./validate/document-html\"\n\n// A designed document prints to PDF in Chromium, as its stylesheets' @page rule lays it out. The\n// PDF is derived data, kept apart from the version by what it prints, its render key, so a version\n// restored or frozen as it was keeps its PDF. It is printed when someone asks for it, by the render\n// worker in a blank sandbox of the project.\n\nexport { DOCUMENT_PDF_JOB } from \"../pdf-job\"\n\n/** The largest PDF the worker reads back from its sandbox: past it, the document has none. */\nexport const MAX_DOCUMENT_PDF_BYTES = 64 * 1024 * 1024\n\nconst RENDER_KEY_FORMAT = \"sixb-document-pdf/1\"\n\n/**\n * What a designed document's PDF is of, as a SHA-256: every file of its version, the frame's kit\n * and runtime it prints with, and its artifact, whose other artifacts' pictures it may show. Null\n * for a version that is not a designed document. `document` is the `document.html` it prints\n * instead of its own, with the values its fields read written in.\n */\nexport function documentPdfKey(\n version: Pick<ArtifactVersionRecord, \"artifactId\" | \"files\" | \"outline\">,\n document?: { readonly digest: string }\n): string | null {\n if (version.outline.kind !== \"document\" || version.outline.format !== \"html\") return null\n\n const files = version.files\n .map(\n (entry) =>\n [\n entry.path,\n document && entry.path === DOCUMENT_HTML_ENTRY ? document.digest : entry.file.digest,\n ] as const\n )\n .sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0))\n return createHash(\"sha256\")\n .update(\n JSON.stringify([RENDER_KEY_FORMAT, frameKitDigest(\"document\"), version.artifactId, files])\n )\n .digest(\"hex\")\n}\n\n/**\n * Asks the render worker to print a designed document's version to PDF, with `document` for its\n * `document.html` when given. Asking again while it is asked for asks nothing more; `retry`\n * forgets why it could not be printed before, and asks again.\n */\nexport async function requestDocumentPdf(\n context: {\n readonly storage: Pick<ArtifactStorage, \"clearPdfFailure\">\n readonly queue: Pick<Queue<RenderQueueJob>, \"enqueue\">\n },\n version: ArtifactVersionRecord,\n options: { readonly document?: FileRef; readonly retry?: boolean } = {}\n): Promise<void> {\n const renderKey = documentPdfKey(version, options.document)\n if (!renderKey) return\n\n if (options.retry) {\n await context.storage.clearPdfFailure({ projectId: version.projectId, renderKey })\n }\n await context.queue.enqueue({\n projectId: version.projectId,\n jobs: [\n {\n // One job per PDF: a job still kept answers asking again, unless it is a retry.\n id: `art_pdf_${renderKey}`,\n ...(options.retry ? { replace: true } : {}),\n type: \"artifact.pdf.requested\",\n payload: {\n artifactId: version.artifactId,\n version: version.version,\n renderKey,\n ...(options.document ? { document: options.document } : {}),\n },\n },\n ],\n })\n}\n",
|
|
14
|
+
"import { createHash } from \"node:crypto\"\nimport type { Principal } from \"../../auth\"\nimport type { BlobStorage, FileRef } from \"../../blob-storage/types\"\nimport { isValidFileRef } from \"../../blob-storage/validation\"\nimport type { Queue, RenderQueueJob } from \"../../queues\"\nimport type {\n ArtifactBoardPreviewRecord,\n ArtifactBoardPreviewSize,\n ArtifactFile,\n ArtifactStorage,\n ArtifactVersionRecord,\n} from \"../../storage/artifacts/types\"\nimport { CANVAS_FILE } from \"../canvas\"\nimport { BOARD_PREVIEW_JOB, BOARD_PREVIEW_WAIT_MS } from \"../canvas-display\"\nimport { FRAME_ASSETS } from \"../frames/assets\"\nimport type { FrameLayout } from \"../frames/entries\"\nimport { FRAME_DEFAULT_THEMES } from \"../frames/kit\"\nimport type { ArtifactOutline, CanvasOutline, CanvasOutlineItem } from \"../outline\"\nimport { type ArtifactQueryResult, artifactQueryName } from \"../queries\"\nimport type { ArtifactThemeMode } from \"../theme\"\nimport { answerArtifactQueries } from \"./query-answers\"\n\n// A canvas's boards are pages, and a hundred pages cannot all run at once: the app shows each as\n// a picture until it is read. The picture is derived data, kept apart from the version by what it\n// shows, its render key, so a version that keeps a board as it was keeps its picture.\n//\n// The render worker renders what a version's boards miss, in a blank sandbox, however the version\n// was published. A board runs with the data its version's publisher could see: never more.\n\n/** A board's picture in one mode and size, as its renderer hands it over. */\nexport interface BoardPreviewInput {\n /** The board's id in the version. */\n readonly board: string\n readonly theme: ArtifactThemeMode\n readonly size: ArtifactBoardPreviewSize\n /** A PNG at full size, a WebP when small. */\n readonly file: FileRef\n}\n\n/** What each size of picture is stored as. */\nexport const BOARD_PREVIEW_MEDIA_TYPES: Readonly<Record<ArtifactBoardPreviewSize, string>> = {\n full: \"image/png\",\n small: \"image/webp\",\n}\n\nconst SIZES: readonly ArtifactBoardPreviewSize[] = [\"full\", \"small\"]\n\n/** A board of a version whose picture is missing, in either size, in some of its modes. */\nexport interface MissingBoardPreview {\n readonly board: CanvasOutlineBoard\n readonly renderKey: string\n readonly themes: readonly ArtifactThemeMode[]\n}\n\n/** Whether a board's picture can be shown, will be, or will not come. */\nexport type BoardPreviewStatus = \"ready\" | \"pending\" | \"none\"\n\nexport type CanvasOutlineBoard = Extract<CanvasOutlineItem, { readonly type: \"board\" }>\n\n/** Asks for what is missing of a stored version's pictures; see {@link requestBoardPreviews}. */\nexport type BoardPreviewRequester = (\n version: ArtifactVersionRecord,\n options?: BoardPreviewRequestOptions\n) => Promise<void>\n\nexport interface BoardPreviewRequestOptions {\n /**\n * Leaves the version's queries unanswered: the worker then pictures only the boards that read\n * none, and a board that reads one keeps its outline.\n */\n readonly withoutAnswers?: boolean\n}\n\n/**\n * The largest picture of a board kept. Most boards' full pictures are far smaller, but a busy\n * board as wide as 8000 pixels can pass it: that picture is not kept, and the board shows its\n * outline in that size.\n */\nexport const MAX_BOARD_PREVIEW_BYTES = 8 * 1024 * 1024\n\nconst RENDER_KEY_FORMAT = \"sixb-board-preview/1\"\n\n/**\n * What a board's picture is of, as a SHA-256: its HTML and size, every file it could load (each\n * of the version's but `canvas.json` and the other boards' HTML), the frame's kit, runtime and\n * themes it runs in, and its artifact. `theme.json` is one of the files, so the modes and tokens it\n * sets are in the key too.\n *\n * Naming the artifact keeps each artifact's pictures its own: whoever may hand over a picture for\n * one may already change its boards, but not another's. Who saves the version does not count: a\n * person moving a note, or an Agent turn someone else asked for, keeps the pictures of the boards\n * it left as they were.\n *\n * When the version holds queries the picture shows its author's data: the key names the author\n * too, so a version saved by someone else renders their data, not the previous author's.\n */\nexport function boardRenderKey(input: {\n readonly board: Pick<CanvasOutlineBoard, \"file\" | \"w\" | \"h\">\n readonly files: readonly ArtifactFile[]\n /** Every board's HTML file in the version: the others are not this board's to load. */\n readonly boardFiles: ReadonlySet<string>\n readonly author: Principal\n readonly artifactId: string\n}): string {\n const { board, files, boardFiles, author, artifactId } = input\n\n const loaded = files\n .filter(\n (entry) =>\n entry.path !== CANVAS_FILE && (entry.path === board.file || !boardFiles.has(entry.path))\n )\n .map((entry) => [entry.path, entry.file.digest] as const)\n .sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0))\n\n const reader = boardsReadLiveData({ files }) ? [author.type, author.id] : null\n\n return createHash(\"sha256\")\n .update(\n JSON.stringify([\n RENDER_KEY_FORMAT,\n frameKitDigest(\"page\"),\n board.file,\n board.w,\n board.h,\n artifactId,\n reader,\n loaded,\n ])\n )\n .digest(\"hex\")\n}\n\n/** A canvas's outline with the modes its boards are pictured in. */\nexport function canvasPreviewOutline(\n outline: CanvasOutline,\n themes: readonly ArtifactThemeMode[]\n): CanvasOutline {\n return { ...outline, themes: [...themes] }\n}\n\n/**\n * A version with each of its canvas's boards named by its render key, for the artifact it is\n * stored in. Any other kind stays as it is.\n */\nexport function withBoardRenderKeys<\n TVersion extends Pick<ArtifactVersionRecord, \"outline\" | \"files\" | \"author\">,\n>(version: TVersion, artifactId: string): TVersion {\n const { outline } = version\n if (outline.kind !== \"canvas\") return version\n\n const boardFiles = new Set(\n outline.items.flatMap((item) => (item.type === \"board\" ? [item.file] : []))\n )\n return {\n ...version,\n outline: {\n ...outline,\n items: outline.items.map((item) =>\n item.type === \"board\"\n ? {\n ...item,\n renderKey: boardRenderKey({\n board: item,\n files: version.files,\n boardFiles,\n author: version.author,\n artifactId,\n }),\n }\n : item\n ),\n },\n }\n}\n\n/**\n * What a copy of an artifact, such as a forked conversation's, does with its canvases' pictures.\n * Each board is named anew for the copy. A board kept from a static version keeps the source's\n * pictures under its new name: it is the same page. A board that shows its author's data gets\n * none, and runs live for the copy's readers.\n */\nexport function boardPreviewsOfCopy(copyId: string): {\n /** The outline each copied version takes; see `CopyArtifactInput.outlineOf`. */\n readonly outlineOf: (version: ArtifactVersionRecord) => ArtifactOutline | undefined\n /** Keeps the static boards' pictures under their new names, once the copy is stored. */\n readonly carry: (\n storage: Pick<ArtifactStorage, \"listBoardPreviews\" | \"putBoardPreviews\">,\n projectId: string\n ) => Promise<void>\n} {\n const renamed = new Map<string, string>()\n\n const outlineOf = (version: ArtifactVersionRecord): ArtifactOutline | undefined => {\n if (version.outline.kind !== \"canvas\") return undefined\n\n const copied = withBoardRenderKeys(version, copyId)\n if (boardsReadLiveData(version)) return copied.outline\n\n const source = new Map(previewedBoards(version).boards.map((each) => [each.id, each.renderKey]))\n for (const board of previewedBoards(copied).boards) {\n const from = source.get(board.id)\n if (from) renamed.set(from, board.renderKey)\n }\n\n return copied.outline\n }\n\n const carry = async (\n storage: Pick<ArtifactStorage, \"listBoardPreviews\" | \"putBoardPreviews\">,\n projectId: string\n ) => {\n if (renamed.size === 0) return\n\n const pictures = await storage.listBoardPreviews({ projectId, renderKeys: [...renamed.keys()] })\n const previews = pictures.flatMap((picture) => {\n const renderKey = renamed.get(picture.renderKey)\n return renderKey ? [{ ...picture, renderKey }] : []\n })\n\n if (previews.length > 0) await storage.putBoardPreviews({ projectId, previews })\n }\n\n return { outlineOf, carry }\n}\n\n/** The boards of a version with a render key, and the modes each has a picture in. */\nfunction previewedBoards(version: ArtifactVersionRecord): {\n readonly boards: readonly (CanvasOutlineBoard & { readonly renderKey: string })[]\n readonly themes: readonly ArtifactThemeMode[]\n} {\n const { outline } = version\n if (outline.kind !== \"canvas\" || !outline.themes) return { boards: [], themes: [] }\n\n return {\n boards: outline.items.flatMap((item) =>\n item.type === \"board\" && item.renderKey ? [{ ...item, renderKey: item.renderKey }] : []\n ),\n themes: outline.themes,\n }\n}\n\n/** Whether a version holds queries: its boards then show its author's data. */\nexport function boardsReadLiveData(version: Pick<ArtifactVersionRecord, \"files\">): boolean {\n return version.files.some((file) => artifactQueryName(file.path) !== undefined)\n}\n\n/** The pictures a version's boards have, by board id: each in its modes and sizes. */\nexport async function boardPreviews(\n storage: Pick<ArtifactStorage, \"listBoardPreviews\">,\n version: ArtifactVersionRecord\n): Promise<ReadonlyMap<string, readonly ArtifactBoardPreviewRecord[]>> {\n const { boards } = previewedBoards(version)\n if (boards.length === 0) return new Map()\n\n const stored = await storage.listBoardPreviews({\n projectId: version.projectId,\n renderKeys: [...new Set(boards.map((board) => board.renderKey))],\n })\n\n return new Map(\n boards.map((board) => [\n board.id,\n stored.filter((preview) => preview.renderKey === board.renderKey),\n ])\n )\n}\n\n/** A board's picture in one mode and size, among its pictures. */\nexport function boardPreview(\n pictures: readonly ArtifactBoardPreviewRecord[] | undefined,\n theme: ArtifactThemeMode,\n size: ArtifactBoardPreviewSize\n): ArtifactBoardPreviewRecord | undefined {\n return pictures?.find((picture) => picture.theme === theme && picture.size === size)\n}\n\n/** Whether a board has its pictures in a mode: both sizes, which its renderer takes together. */\nfunction pictured(\n pictures: readonly ArtifactBoardPreviewRecord[] | undefined,\n theme: ArtifactThemeMode\n): boolean {\n return SIZES.every((size) => boardPreview(pictures, theme, size))\n}\n\n/** The boards of a version still without a picture in one of its modes, in the canvas's order. */\nexport async function missingBoardPreviews(\n storage: Pick<ArtifactStorage, \"listBoardPreviews\">,\n version: ArtifactVersionRecord\n): Promise<readonly MissingBoardPreview[]> {\n const { boards, themes } = previewedBoards(version)\n const stored = await boardPreviews(storage, version)\n\n return boards.flatMap((board) => {\n const missing = themes.filter((theme) => !pictured(stored.get(board.id), theme))\n return missing.length === 0 ? [] : [{ board, renderKey: board.renderKey, themes: missing }]\n })\n}\n\n/**\n * Each board's picture as a reader asks for it: `ready` in every mode, `pending` while one may\n * still come, `none` when nothing will render it: a project without sandboxes, a version from\n * before pictures, or one written longer ago than the wait.\n */\nexport async function boardPreviewStatuses(\n storage: Pick<ArtifactStorage, \"listBoardPreviews\">,\n version: ArtifactVersionRecord,\n input: { readonly renders: boolean; readonly now: Date }\n): Promise<ReadonlyMap<string, BoardPreviewStatus>> {\n const { boards, themes } = previewedBoards(version)\n const stored = await boardPreviews(storage, version)\n const waiting =\n input.renders && input.now.getTime() - version.updatedAt.getTime() < BOARD_PREVIEW_WAIT_MS\n\n return new Map(\n boards.map((board) => {\n const ready = themes.every((theme) => pictured(stored.get(board.id), theme))\n return [board.id, ready ? \"ready\" : waiting ? \"pending\" : \"none\"] as const\n })\n )\n}\n\n/** A picture that was not kept, and why, in words for whoever handed it over. */\nexport interface RefusedBoardPreview {\n readonly board: string\n readonly theme: ArtifactThemeMode\n readonly size: ArtifactBoardPreviewSize\n readonly reason: string\n}\n\n/**\n * Keeps pictures of a stored version's boards, each under its board's render key, as the render\n * worker stored them. Each picture stands alone: one for a board or a mode the version has no\n * picture for, in another format than its size's, or past the size limit, is left out and\n * returned, and the others are kept.\n */\nexport async function storeBoardPreviews(\n storage: Pick<ArtifactStorage, \"putBoardPreviews\">,\n version: ArtifactVersionRecord,\n previews: readonly BoardPreviewInput[]\n): Promise<readonly RefusedBoardPreview[]> {\n if (previews.length === 0) return []\n\n const { boards, themes } = previewedBoards(version)\n const keys = new Map(boards.map((board) => [board.id, board.renderKey]))\n const createdAt = new Date()\n\n const checked = previews.map(\n (\n preview\n ):\n | { readonly record: Omit<ArtifactBoardPreviewRecord, \"projectId\"> }\n | { readonly refused: RefusedBoardPreview } => {\n const { board, theme, size, file } = preview\n const refuse = (reason: string) => ({ refused: { board, theme, size, reason } })\n\n const renderKey = keys.get(board)\n if (!renderKey || !themes.includes(theme)) {\n return refuse(`the version has no board '${board}' to picture in ${theme} mode`)\n }\n\n const mediaType = SIZES.includes(size) ? BOARD_PREVIEW_MEDIA_TYPES[size] : undefined\n if (!mediaType || !isValidFileRef(file) || file.mediaType !== mediaType) {\n return refuse(`a ${size} picture must be ${mediaType ?? \"full or small\"}`)\n }\n if (file.sizeBytes > MAX_BOARD_PREVIEW_BYTES) {\n return refuse(`it is ${file.sizeBytes} bytes, past the ${MAX_BOARD_PREVIEW_BYTES} kept`)\n }\n\n return { record: { renderKey, theme, size, file: { ...file }, createdAt } }\n }\n )\n\n const records = checked.flatMap((each) => (\"record\" in each ? [each.record] : []))\n if (records.length > 0) {\n await storage.putBoardPreviews({ projectId: version.projectId, previews: records })\n }\n\n return checked.flatMap((each) => (\"refused\" in each ? [each.refused] : []))\n}\n\n/**\n * One job per artifact. Each write that asks replaces the job still waiting, so a canvas edited\n * live, written back every few seconds, waits for one job, which renders its latest revision once\n * it rests, never each state it went through.\n */\nexport function boardPreviewsJobId(artifactId: string): string {\n return `art_previews_${artifactId}`\n}\n\n/**\n * Asks the render worker to render what a stored version's boards still miss, once the canvas\n * rests, `BOARD_PREVIEW_JOB.settleMs` from now, in the artifact's one job: it takes the place of\n * any asked for an earlier revision. Nothing is asked when nothing is missing.\n *\n * Boards that read queries show their author's data, so the version's queries are answered now,\n * by `query`, as whoever just published it, and the job carries the answers: kept as a blob only\n * the job names. A query that fails is answered as its rejection. Only the write that asks last\n * has its answers rendered: those of a job it replaced are never read.\n *\n * The version exists by now and its pictures are derived from it, so a request that fails is\n * reported, not thrown: the publish succeeded, and the viewer shows the boards' outlines instead.\n */\nexport async function requestBoardPreviews(\n input: {\n readonly storage: Pick<ArtifactStorage, \"listBoardPreviews\">\n readonly queue: Pick<Queue<RenderQueueJob>, \"enqueue\">\n readonly blobStorage: Pick<BlobStorage, \"put\">\n /** Runs one of the version's queries as its publisher. */\n readonly query: (name: string) => Promise<ArtifactQueryResult | null>\n },\n version: ArtifactVersionRecord,\n options: BoardPreviewRequestOptions = {}\n): Promise<void> {\n if (version.outline.kind !== \"canvas\") return\n\n try {\n if ((await missingBoardPreviews(input.storage, version)).length === 0) return\n\n const queries =\n boardsReadLiveData(version) && !options.withoutAnswers\n ? await storeQueryAnswers(input, version)\n : undefined\n\n await input.queue.enqueue({\n projectId: version.projectId,\n jobs: [\n {\n id: boardPreviewsJobId(version.artifactId),\n replace: true,\n type: \"artifact.previews.requested\",\n payload: {\n artifactId: version.artifactId,\n version: version.version,\n updatedAt: version.updatedAt.toISOString(),\n ...(queries ? { queries } : {}),\n },\n availableAt: new Date(Date.now() + BOARD_PREVIEW_JOB.settleMs).toISOString(),\n },\n ],\n })\n } catch (error) {\n console.error(\n `[Sixb] Could not ask for the previews of version ${version.version} of '${version.artifactId}'; its boards show their outlines.`,\n error\n )\n }\n}\n\n/** The version's query answers, as its publisher reads them, as a JSON blob. */\nasync function storeQueryAnswers(\n input: {\n readonly blobStorage: Pick<BlobStorage, \"put\">\n readonly query: (name: string) => Promise<ArtifactQueryResult | null>\n },\n version: ArtifactVersionRecord\n): Promise<FileRef> {\n const answers = await answerArtifactQueries(version, input.query)\n const body = new TextEncoder().encode(JSON.stringify(answers))\n\n return input.blobStorage.put({\n body,\n expectedSizeBytes: body.byteLength,\n fileName: `${version.artifactId}-r${version.revision}-queries.json`,\n mediaType: \"application/json\",\n })\n}\n\nconst kitDigests = new Map<FrameLayout, string>()\n\n/**\n * What a frame of `layout` runs with besides its own files: a new kit renders it anew. The files\n * every layout shares, and those of its own layout alone: a video's runtimes are in a video's keys,\n * and in no deck's, page's or document's.\n */\nexport function frameKitDigest(layout: FrameLayout): string {\n let digest = kitDigests.get(layout)\n if (digest === undefined) {\n const assets = Object.fromEntries(\n Object.entries(FRAME_ASSETS).filter(\n ([, asset]) => asset.layout === undefined || asset.layout === layout\n )\n )\n digest = createHash(\"sha256\")\n .update(JSON.stringify([assets, FRAME_DEFAULT_THEMES]))\n .digest(\"hex\")\n kitDigests.set(layout, digest)\n }\n return digest\n}\n",
|
|
15
|
+
"import { AuthorizationError } from \"../../authorization/errors\"\nimport { ObjectQueryExecutionError } from \"../../objects/query/errors\"\nimport type { ArtifactVersionRecord } from \"../../storage/artifacts/types\"\nimport { ArtifactRequestError } from \"../errors\"\nimport {\n type ArtifactQueryResult,\n artifactQueryName,\n DOCUMENT_HOLDER_QUERY,\n isArtifactQueryName,\n} from \"../queries\"\nimport { serializeArtifactQueryResult } from \"../serialize-query\"\n\n// A page opened outside the app, by the Agent's layout check or to picture a canvas's boards, reads\n// its queries from answers read beforehand: each as the query route serves it to whoever read it,\n// or why it failed for them, which the page's `sixb.query` rejects with.\n\n/** What `sixb.query(name)` reads in a page opened outside the app. */\nexport type ArtifactQueryAnswer = { readonly result: unknown } | { readonly error: string }\n\n/** A version's query answers by name. */\nexport type ArtifactQueryAnswers = Readonly<Record<string, ArtifactQueryAnswer>>\n\n/**\n * One query's answer, as `read` reads it: its result serialized as the route serves it, or a\n * refusal in the words the API gives a reader. Any other failure stays internal.\n */\nexport async function answerArtifactQuery(\n read: () => Promise<ArtifactQueryResult | null>\n): Promise<ArtifactQueryAnswer> {\n try {\n const result = await read()\n if (!result) return { error: UNREADABLE }\n\n return { result: serializeArtifactQueryResult(result) }\n } catch (error) {\n if (\n error instanceof ArtifactRequestError ||\n error instanceof AuthorizationError ||\n error instanceof ObjectQueryExecutionError\n ) {\n return { error: /[.!?]$/.test(error.message) ? error.message : `${error.message}.` }\n }\n\n console.warn(\"[Sixb] A query of an artifact version did not run:\", error)\n return { error: UNREADABLE }\n }\n}\n\n/**\n * Every query a version holds, each answered by `read`: as whoever it reads as. A designed\n * document's holder, which its fields read, is answered too.\n */\nexport async function answerArtifactQueries(\n version: Pick<ArtifactVersionRecord, \"files\" | \"outline\">,\n read: (name: string) => Promise<ArtifactQueryResult | null>\n): Promise<ArtifactQueryAnswers> {\n const names = version.files.flatMap((file) => {\n const name = artifactQueryName(file.path)\n return name === undefined ? [] : [name]\n })\n if (version.outline.kind === \"document\" && version.outline.holder) {\n names.push(DOCUMENT_HOLDER_QUERY)\n }\n\n const answers = await Promise.all(\n names.map(async (name) => [name, await answerArtifactQuery(() => read(name))] as const)\n )\n return Object.fromEntries(answers)\n}\n\n/** Answers kept as JSON, or `null` when the text holds none. */\nexport function parseArtifactQueryAnswers(text: string): ArtifactQueryAnswers | null {\n let value: unknown\n try {\n value = JSON.parse(text)\n } catch {\n return null\n }\n if (!isObject(value)) return null\n\n const answers: Record<string, ArtifactQueryAnswer> = {}\n for (const [name, answer] of Object.entries(value)) {\n if (!isArtifactQueryName(name) || !isObject(answer)) return null\n\n if (\"result\" in answer) answers[name] = { result: answer.result }\n else if (typeof answer.error === \"string\") answers[name] = { error: answer.error }\n else return null\n }\n return answers\n}\n\nconst UNREADABLE = \"[Sixb] The query could not be read.\"\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n}\n",
|
|
16
|
+
"import { posix } from \"node:path\"\nimport type { ArtifactFile } from \"../../../storage/artifacts/types\"\nimport { isArtifactAddress } from \"../../address\"\nimport { documentMarks } from \"../../document-fill\"\nimport { FRAME_CDN_ALLOWLIST } from \"../../frames/assets\"\nimport type { DocumentMark } from \"../../frames/document-data\"\nimport { decodeHtmlEntities } from \"../../html\"\nimport { ARTIFACT_LIMITS } from \"../../limits\"\nimport { createHeadingSlugger, type DocumentHeading, type DocumentOutline } from \"../../outline\"\nimport { readDocumentPaper } from \"../../paper\"\nimport { type ArtifactBlobStorage, invalidArtifact, readArtifactText } from \"../files\"\nimport type { FoundReference } from \"../references\"\nimport { readHtmlReferences, refuseFrameAssetPaths } from \"./html\"\n\n/** The file a designed document renders from, beside its stylesheets, fonts, and images. */\nexport const DOCUMENT_HTML_ENTRY = \"document.html\"\n\n/**\n * What a designed document may not hold: it is read, laid out and printed, never run. A frame\n * would refuse most of them anyway; refusing them here says so to whoever publishes.\n */\nconst REFUSED_ELEMENTS = [\n \"script\",\n \"iframe\",\n \"frame\",\n \"frameset\",\n \"object\",\n \"embed\",\n \"applet\",\n \"form\",\n \"base\",\n \"portal\",\n \"meta[http-equiv]\",\n]\n\n/** Elements whose text is not markup, which may show no live data. */\nconst RAW_TEXT_ELEMENTS = [\"style\", \"title\", \"textarea\", \"xmp\", \"noembed\", \"noframes\", \"noscript\"]\n\n/** Attributes that hold an address, which may not run script. */\nconst ADDRESS_ATTRIBUTES = [\"href\", \"src\", \"xlink:href\", \"poster\", \"action\", \"formaction\"]\n\n/**\n * Reads a designed document: `document.html` and the stylesheets, fonts, and images beside it. It\n * may hold any markup that lays out text, tables, figures, and pictures, styled by any CSS, but\n * nothing that runs: no scripts, no handlers, no frames or forms. Its images are files in the\n * version or another artifact's, and its stylesheets are files in the version or on a CDN the\n * frame loads from. Its headings become the outline, as a Markdown document's do, and the\n * `@page` rule of its stylesheets becomes its paper. `<meta name=\"sixb:object-type\">` names the\n * type of the object it shows live data of, and its fields and repeated elements are returned for\n * publishing to check against what that object and its queries hold.\n */\nexport async function validateHtmlDocument(\n blobStorage: ArtifactBlobStorage,\n files: readonly ArtifactFile[]\n): Promise<{\n readonly entry: string\n readonly outline: DocumentOutline\n readonly references: readonly FoundReference[]\n readonly marks: readonly DocumentMark[]\n}> {\n const entry = files.find((file) => file.path === DOCUMENT_HTML_ENTRY)\n if (!entry) throw invalidArtifact(`A designed document needs '${DOCUMENT_HTML_ENTRY}'.`)\n refuseFrameAssetPaths(files, \"the document\")\n const html = await readArtifactText(blobStorage, entry, ARTIFACT_LIMITS.maxDocumentBytes)\n const paths = new Set(files.map((file) => file.path))\n\n let refused: string | undefined\n const refuse = (message: string) => {\n refused ??= message\n }\n\n const headings: { depth: number; text: string }[] = []\n const slug = createHeadingSlugger()\n const slugs: string[] = []\n let heading: { depth: number; text: string } | null = null\n // The document's styles in the order it applies them: a stylesheet file by its path, or the\n // text of a `<style>` element.\n const styles: ({ readonly path: string } | { readonly css: string })[] = []\n let style: { css: string } | null = null\n let objectTypeId: string | undefined\n\n const rewriter = new HTMLRewriter()\n .on(REFUSED_ELEMENTS.join(\", \"), {\n element(element) {\n refuse(\n `${DOCUMENT_HTML_ENTRY} holds <${element.tagName}>. A designed document is laid out and printed, never run: it may not hold scripts, frames, forms, or <base>.`\n )\n },\n })\n .on(\"*\", {\n element(element) {\n for (const [name, value] of element.attributes) {\n const attribute = name.toLowerCase()\n if (attribute.startsWith(\"on\")) {\n refuse(\n `${DOCUMENT_HTML_ENTRY} gives <${element.tagName}> the handler '${name}'. A designed document runs no script.`\n )\n } else if (\n ADDRESS_ATTRIBUTES.includes(attribute) &&\n /^\\s*javascript:/i.test(decodeHtmlEntities(value).replace(/[\\s\\u0000-\\u001f]/g, \"\"))\n ) {\n refuse(\n `${DOCUMENT_HTML_ENTRY} links <${element.tagName}> to a javascript: address. A designed document runs no script.`\n )\n }\n }\n },\n })\n // Their text is never markup: a value written into one could end it and start a script.\n .on(\n RAW_TEXT_ELEMENTS.map((tag) => `${tag}[data-sixb-field], ${tag}[data-sixb-each]`).join(\", \"),\n {\n element(element) {\n refuse(\n `${DOCUMENT_HTML_ENTRY} shows live data in <${element.tagName}>, whose text is not markup. Put the field in an element that shows text, such as <span>.`\n )\n },\n }\n )\n .on(\"h1, h2, h3, h4, h5, h6\", {\n element(element) {\n const current = { depth: Number(element.tagName.slice(1)), text: \"\" }\n heading = current\n headings.push(current)\n element.onEndTag(() => {\n slugs.push(slug(plainText(current.text)))\n heading = null\n })\n },\n text(chunk) {\n if (heading) heading.text += chunk.text\n },\n })\n .on(\"img[src]\", {\n element(element) {\n const source = decodeHtmlEntities(element.getAttribute(\"src\") ?? \"\").trim()\n // Another artifact's file is the references' to check.\n if (isArtifactAddress(source)) return\n const problem = localFileProblem(source, paths)\n if (problem) {\n refuse(\n `${DOCUMENT_HTML_ENTRY} shows the image '${source}', ${problem}. Images are files in the artifact, by their relative path, or another artifact's address, such as artifact:art_k3m9q2x7tp/logo.png.`\n )\n }\n },\n })\n .on(\"link[href]\", {\n element(element) {\n const rel = (element.getAttribute(\"rel\") ?? \"\").toLowerCase().split(/\\s+/)\n if (!rel.includes(\"stylesheet\")) return\n const href = decodeHtmlEntities(element.getAttribute(\"href\") ?? \"\").trim()\n if (FRAME_CDN_ALLOWLIST.some((origin) => href.startsWith(`${origin}/`))) return\n const problem = localFileProblem(href, paths)\n if (problem) {\n refuse(\n `${DOCUMENT_HTML_ENTRY} loads the stylesheet '${href}', ${problem}. A stylesheet is a file in the artifact, by its relative path, or on ${FRAME_CDN_ALLOWLIST.join(\", \")}.`\n )\n return\n }\n styles.push({ path: posix.normalize(safeDecodeUri(href.split(/[?#]/)[0] ?? \"\")) })\n },\n })\n .on('meta[name=\"sixb:object-type\"]', {\n element(element) {\n const content = decodeHtmlEntities(element.getAttribute(\"content\") ?? \"\").trim()\n if (content) objectTypeId ??= content\n },\n })\n .on(\"style\", {\n element(element) {\n const current = { css: \"\" }\n style = current\n styles.push(current)\n element.onEndTag(() => {\n style = null\n })\n },\n text(chunk) {\n if (style) style.css += chunk.text\n },\n })\n const { references, refusal } = readHtmlReferences(\n rewriter,\n () => slugs.at(-1) ?? \"\",\n DOCUMENT_HTML_ENTRY\n )\n rewriter.transform(html)\n\n const problem = refused ?? refusal()\n if (problem) throw invalidArtifact(problem)\n\n const stylesheets: string[] = []\n for (const each of styles) {\n if (\"css\" in each) {\n stylesheets.push(each.css)\n continue\n }\n const file = files.find((candidate) => candidate.path === each.path)\n if (file) {\n stylesheets.push(await readArtifactText(blobStorage, file, ARTIFACT_LIMITS.maxDocumentBytes))\n }\n }\n const paper = readDocumentPaper(stylesheets)\n\n const outlined = headings.map(\n ({ depth, text }, index): DocumentHeading => ({\n depth,\n text: plainText(text),\n slug: slugs[index] ?? \"\",\n })\n )\n return {\n entry: DOCUMENT_HTML_ENTRY,\n outline: {\n kind: \"document\",\n format: \"html\",\n headings: outlined,\n ...(paper ? { paper } : {}),\n ...(objectTypeId ? { holder: { objectTypeId, links: [] } } : {}),\n },\n references,\n marks: documentMarks(html),\n }\n}\n\nfunction plainText(text: string): string {\n return decodeHtmlEntities(text).replace(/\\s+/g, \" \").trim()\n}\n\n/** Why `source` is not one of the version's files, or null when it is one. */\nfunction localFileProblem(source: string, paths: ReadonlySet<string>): string | null {\n if (source === \"\" || source.startsWith(\"//\") || /^[a-z][a-z\\d+.-]*:/i.test(source)) {\n return \"which is not a file in the artifact\"\n }\n const path = posix.normalize(safeDecodeUri(source.split(/[?#]/)[0] ?? \"\"))\n return paths.has(path) ? null : \"which is not one of the artifact's files\"\n}\n\nfunction safeDecodeUri(value: string): string {\n try {\n return decodeURI(value)\n } catch {\n return value\n }\n}\n",
|
|
17
|
+
"/**\n * The sheet a designed document prints on, as its stylesheets' `@page` rule sets it, in CSS pixels\n * (96 to the inch): the page's size, and its margins. The app lays the document's pages out on it,\n * and the PDF prints on it.\n */\nexport interface DocumentPaper {\n readonly width: number\n readonly height: number\n readonly margin: {\n readonly top: number\n readonly right: number\n readonly bottom: number\n readonly left: number\n }\n}\n\nconst PX_PER_UNIT: Readonly<Record<string, number>> = {\n px: 1,\n in: 96,\n cm: 96 / 2.54,\n mm: 96 / 25.4,\n q: 96 / 101.6,\n pt: 96 / 72,\n pc: 16,\n}\n\n/** The named sizes CSS gives `size`, portrait, in millimetres or inches as their standard is. */\nconst PAGE_SIZES: Readonly<Record<string, readonly [string, string]>> = {\n a5: [\"148mm\", \"210mm\"],\n a4: [\"210mm\", \"297mm\"],\n a3: [\"297mm\", \"420mm\"],\n b5: [\"176mm\", \"250mm\"],\n b4: [\"250mm\", \"353mm\"],\n \"jis-b5\": [\"182mm\", \"257mm\"],\n \"jis-b4\": [\"257mm\", \"364mm\"],\n letter: [\"8.5in\", \"11in\"],\n legal: [\"8.5in\", \"14in\"],\n ledger: [\"11in\", \"17in\"],\n}\n\n/**\n * The paper the stylesheets ask for, read in the order the document applies them: the `size` and\n * margins of every unnamed, unqualified `@page` rule, a later one over an earlier one. Null when\n * none sets a size, or sets one Sixb can't measure (`auto`, or a length in `em`).\n */\nexport function readDocumentPaper(stylesheets: readonly string[]): DocumentPaper | null {\n let size: readonly [number, number] | null = null\n const margin: [number, number, number, number] = [0, 0, 0, 0]\n for (const css of stylesheets) {\n for (const declarations of pageRules(css)) {\n for (const [property, value] of declarations) {\n if (property === \"size\") {\n size = readSize(value) ?? size\n } else if (property === \"margin\") {\n const sides = readLengths(value)\n if (sides && sides.length <= 4) {\n const [top, right = top, bottom = top, left = right] = sides\n margin.splice(0, 4, top, right, bottom, left)\n }\n } else {\n const side = [\"margin-top\", \"margin-right\", \"margin-bottom\", \"margin-left\"].indexOf(\n property\n )\n const length = side === -1 ? null : readLength(value)\n if (length !== null) margin[side] = length\n }\n }\n }\n }\n if (!size) return null\n\n const round = (value: number) => Math.round(value * 100) / 100\n return {\n width: round(size[0]),\n height: round(size[1]),\n margin: {\n top: round(margin[0]),\n right: round(margin[1]),\n bottom: round(margin[2]),\n left: round(margin[3]),\n },\n }\n}\n\n/**\n * The declarations of each `@page { … }` rule in the CSS, in order, as `[property, value]` pairs.\n * A named page (`@page cover`) or one for some pages only (`@page :first`) is left out: it applies\n * to pages the document picks, not the sheet the document prints on. Margin boxes nested in a rule\n * (`@top-center { … }`) are skipped.\n */\nfunction pageRules(css: string): (readonly [string, string])[][] {\n const text = css.replace(/\\/\\*[\\s\\S]*?\\*\\//g, \"\")\n const rules: (readonly [string, string])[][] = []\n const opening = /@page\\b([^{;]*)\\{/gi\n for (let match = opening.exec(text); match; match = opening.exec(text)) {\n const body = blockAt(text, opening.lastIndex)\n opening.lastIndex += body.length\n if (match[1]?.trim()) continue\n\n // Only what sits at the rule's own level: nested blocks are margin boxes.\n let flat = \"\"\n let depth = 0\n for (const char of body) {\n if (char === \"{\") depth += 1\n else if (char === \"}\") depth -= 1\n else if (depth === 0) flat += char\n }\n rules.push(\n flat.split(\";\").flatMap((declaration) => {\n const colon = declaration.indexOf(\":\")\n if (colon === -1) return []\n const property = declaration.slice(0, colon).trim().toLowerCase()\n const value = declaration\n .slice(colon + 1)\n .replace(/!important\\s*$/i, \"\")\n .trim()\n .toLowerCase()\n return property && value ? [[property, value] as const] : []\n })\n )\n }\n return rules\n}\n\n/** The text of the block that opened just before `start`, up to its closing brace. */\nfunction blockAt(text: string, start: number): string {\n let depth = 1\n for (let index = start; index < text.length; index++) {\n if (text[index] === \"{\") depth += 1\n else if (text[index] === \"}\") depth -= 1\n if (depth === 0) return text.slice(start, index)\n }\n return text.slice(start)\n}\n\nfunction readSize(value: string): readonly [number, number] | null {\n const words = value.split(/\\s+/)\n const orientation = words.find((word) => word === \"portrait\" || word === \"landscape\")\n const rest = words.filter((word) => word !== orientation)\n let size: readonly [number, number] | null = null\n if (rest.length === 1 && rest[0] && PAGE_SIZES[rest[0]]) {\n const [width, height] = PAGE_SIZES[rest[0]] as readonly [string, string]\n size = [readLength(width) as number, readLength(height) as number]\n } else if (rest.length === 0 && orientation) {\n size = [readLength(\"8.5in\") as number, readLength(\"11in\") as number]\n } else {\n const lengths = readLengths(rest.join(\" \"))\n if (lengths?.length === 1 && lengths[0]) size = [lengths[0], lengths[0]]\n else if (lengths?.length === 2 && lengths[0] && lengths[1]) size = [lengths[0], lengths[1]]\n }\n if (!size || size[0] <= 0 || size[1] <= 0) return null\n\n const [short, long] = size[0] <= size[1] ? size : [size[1], size[0]]\n if (orientation === \"landscape\") return [long, short]\n if (orientation === \"portrait\") return [short, long]\n return size\n}\n\nfunction readLengths(value: string): number[] | null {\n const lengths = value.split(/\\s+/).map(readLength)\n return lengths.length > 0 && lengths.every((length) => length !== null)\n ? (lengths as number[])\n : null\n}\n\nfunction readLength(value: string): number | null {\n if (value === \"0\") return 0\n const match = /^(-?\\d*\\.?\\d+)([a-z]+)$/.exec(value)\n const perUnit = match?.[2] ? PX_PER_UNIT[match[2]] : undefined\n if (!match || perUnit === undefined) return null\n const length = Number(match[1]) * perUnit\n return Number.isFinite(length) && length >= 0 ? length : null\n}\n",
|
|
18
|
+
"import { type DocumentMark, type DocumentPath, documentData } from \"../frames/document-data\"\nimport type { DocumentHolder } from \"../outline\"\nimport type { ArtifactQueryProperty, CheckedArtifactQuery } from \"../queries\"\nimport type { ArtifactWarning } from \"../warnings\"\nimport { invalidArtifact } from \"./files\"\nimport type { ArtifactQueryChecker } from \"./queries\"\n\ntype Properties = Readonly<Record<string, ArtifactQueryProperty>>\n\n/**\n * What a path reads from: the holder, a query's rows, an item of what a holder's property or link\n * holds, which only the holder's type tells apart, or what is not checked.\n */\ntype Base =\n | { readonly kind: \"holder\" }\n | { readonly kind: \"rows\"; readonly query: CheckedArtifactQuery }\n | { readonly kind: \"item\"; readonly key: string }\n | { readonly kind: \"unknown\" }\n\n/**\n * Checks a designed document's fields and repeated elements against what they read, as its author\n * reads it: the object that holds it, of the type it names, and its queries. A path that reads\n * nothing they hold is a `field_unknown` warning, never a refusal, so a document that names a\n * property its author cannot see still publishes. One that reads a list item, or a value deeper\n * than a property, is not checked past it.\n *\n * Returns the holder, with the links its fields read through, which reading the holder expands.\n * A holder its author cannot read refuses the version, as a query they could not run does.\n */\nexport async function checkDocumentFields(input: {\n readonly marks: readonly DocumentMark[]\n readonly holder?: string\n readonly queries: ReadonlyMap<string, CheckedArtifactQuery>\n readonly checker?: ArtifactQueryChecker\n}): Promise<{ readonly holder?: DocumentHolder; readonly warnings: readonly ArtifactWarning[] }> {\n const data = documentData()\n const warnings: ArtifactWarning[] = []\n const unknown = (mark: DocumentMark, why: string) =>\n warnings.push({\n code: \"field_unknown\",\n message: `data-sixb-${mark.kind}=\"${mark.path}\" ${why}. It keeps the text written in it.`,\n })\n\n /** What a path reads from, given the repeated elements it is in. */\n const baseOf = (path: DocumentPath, within: readonly string[]): Base => {\n if (path.query !== undefined) {\n const query = input.queries.get(path.query)\n return query ? { kind: \"rows\", query } : { kind: \"unknown\" }\n }\n const each = within.at(-1)\n if (each === undefined) return { kind: \"holder\" }\n const parsed = data.parse(each)\n if (!parsed) return { kind: \"unknown\" }\n if (parsed.query !== undefined && parsed.steps.length === 0) return baseOf(parsed, [])\n const [step, ...rest] = parsed.steps\n const repeatsHolder = baseOf(parsed, within.slice(0, -1)).kind === \"holder\"\n return step && rest.length === 0 && step.id === undefined && repeatsHolder\n ? { kind: \"item\", key: step.key }\n : { kind: \"unknown\" }\n }\n\n const reads = input.marks.flatMap((mark) => {\n const path = data.parse(mark.path)\n if (!path) {\n unknown(mark, \"is not a path: name properties with dots, and a list's item by its id in [ ]\")\n return []\n }\n return [{ mark, path, base: baseOf(path, mark.within) }]\n })\n\n // A holder's properties, and those of the objects each link its fields name reaches.\n let holder: DocumentHolder | undefined\n let holderProperties: Properties = {}\n const linkProperties = new Map<string, Properties>()\n const readsHolder = reads.some((read) => read.base.kind === \"holder\")\n if (readsHolder && !input.holder) {\n warnings.push({\n code: \"field_unknown\",\n message:\n 'The document\\'s fields read the object that holds it, but it names no type of object: add <meta name=\"sixb:object-type\" content=\"...\"> to its <head>. They keep the text written in them.',\n })\n }\n if (input.holder) {\n if (!input.checker) {\n throw invalidArtifact(\n \"The document shows live data of the object that holds it, and this publish has no way to check that its author reads it.\"\n )\n }\n const objectTypeId = input.holder\n const start = { kind: \"start\", objectTypeId } as const\n try {\n holderProperties = (await input.checker({ kind: \"objects\", query: start })).schema.properties\n } catch (error) {\n throw invalidArtifact(\n `The document names the object type '${objectTypeId}' in <meta name=\"sixb:object-type\">, which you cannot read: ${error instanceof Error ? error.message.replace(/^\\[Sixb\\]\\s*/, \"\") : String(error)}`\n )\n }\n\n // A first step that is no property may be a link: its objects are read with the holder.\n const candidates = new Set<string>()\n for (const { base, path } of reads) {\n const first = path.steps[0]?.key\n if (base.kind === \"holder\" && first && !Object.hasOwn(holderProperties, first)) {\n candidates.add(first)\n }\n }\n for (const linkId of candidates) {\n try {\n const checked = await input.checker({\n kind: \"objects\",\n query: { kind: \"expand\", input: start, expansions: [{ linkId, direction: \"outgoing\" }] },\n })\n linkProperties.set(linkId, checked.schema.links[linkId]?.properties ?? {})\n } catch {\n // Neither a property nor a link: its fields are warned about below.\n }\n }\n holder = { objectTypeId, links: [...linkProperties.keys()] }\n }\n\n for (const { mark, path, base } of reads) {\n const [first, second] = path.steps\n switch (base.kind) {\n case \"unknown\":\n if (path.query !== undefined)\n unknown(mark, `names no query: add queries/${path.query}.json`)\n break\n case \"rows\": {\n const facets = base.query.kind === \"facets\"\n if (path.query !== undefined) {\n if (mark.kind === \"field\" && first?.key === \"total\" && path.steps.length === 1) break\n if (first?.key === \"facets\" && path.steps.length === 2 && facets) break\n if (mark.kind === \"each\" && path.steps.length === 0 && !facets) break\n unknown(\n mark,\n facets\n ? `reads facets: repeat over query:${path.query}.facets.<property>, or show query:${path.query}.total`\n : `reads rows: repeat over query:${path.query}, or show query:${path.query}.total`\n )\n break\n }\n if (!first) break\n const links = base.query.schema.links\n if (Object.hasOwn(base.query.schema.properties, first.key)) break\n if (Object.hasOwn(links, first.key)) {\n if (second && !Object.hasOwn(links[first.key]?.properties ?? {}, second.key)) {\n unknown(mark, `reads '${second.key}', which what '${first.key}' reaches does not hold`)\n }\n break\n }\n unknown(mark, `reads '${first.key}', which the rows of its query do not hold`)\n break\n }\n case \"item\": {\n // An item of a property's list is not checked; one the holder lacks is warned about once.\n const reached = linkProperties.get(base.key)\n if (reached && first && !Object.hasOwn(reached, first.key)) {\n unknown(mark, `reads '${first.key}', which what '${base.key}' reaches does not hold`)\n }\n break\n }\n case \"holder\": {\n if (!input.holder || !first) break\n if (Object.hasOwn(holderProperties, first.key)) break\n const reached = linkProperties.get(first.key)\n if (!reached) {\n unknown(mark, `reads '${first.key}', which a ${input.holder} does not hold`)\n } else if (second && !Object.hasOwn(reached, second.key)) {\n unknown(mark, `reads '${second.key}', which what '${first.key}' reaches does not hold`)\n }\n break\n }\n }\n }\n\n return { ...(holder ? { holder } : {}), warnings }\n}\n",
|
|
19
|
+
"import { getAuthorizedOntologyView, getQueryDiscovery } from \"../execution/authorized-object-reader\"\nimport type { AuthorizedOntologyView } from \"../objects/authorized-ontology-view\"\nimport { ObjectQueryPlanningError, ObjectQueryValidationError } from \"../objects/query/errors\"\nimport type { ObjectExpansion } from \"../objects/query/ir\"\nimport { type ValidatedObjectQuery, validateObjectQuery } from \"../objects/query/validate\"\nimport type { Schema, ValueType } from \"../ontology/types\"\nimport type { SixbRuntimeContext } from \"../runtime/types\"\nimport type { ObjectRow } from \"../storage/objects/types\"\nimport { ArtifactRequestError } from \"./errors\"\nimport { ARTIFACT_LIMITS } from \"./limits\"\nimport type {\n ArtifactQuery,\n ArtifactQueryProperty,\n ArtifactQueryResult,\n ArtifactQuerySchema,\n ArtifactQueryShape,\n} from \"./queries\"\n\n/** Rows read per call to the reader, so a large result never comes back in one response. */\nconst PAGE_SIZE = 1_000\n\n/**\n * Runs one of a version's queries as the runtime's caller, through their object reader: what they\n * cannot view refuses the query, and what they are not cleared for is left out of each row.\n *\n * The query was valid when it was published, but the ontology may have changed since: a query\n * that no longer validates, or no longer plans, is `query_invalid`. Rows are read a page at a\n * time, up to `ARTIFACT_LIMITS.maxQueryRows`, within any `limit` the query declares.\n */\nexport async function runArtifactQuery(\n runtime: Pick<SixbRuntimeContext, \"ontology\" | \"objectReader\">,\n name: string,\n query: ArtifactQuery\n): Promise<ArtifactQueryResult> {\n try {\n const shape = describeArtifactQuery(runtime, query)\n\n if (query.kind === \"facets\") {\n const { total, facets } = await runtime.objectReader.facet({\n query: query.query,\n facets: query.facets,\n })\n return { kind: \"facets\", total, facets, ...shape }\n }\n\n return { kind: \"objects\", ...(await readRows(runtime, query.query)), ...shape }\n } catch (error) {\n throw queryInvalid(name, error)\n }\n}\n\n/**\n * What a query returns and reads, and what its rows hold as the runtime's caller may view them. It\n * throws what validating the query throws.\n */\nexport function describeArtifactQuery(\n runtime: Pick<SixbRuntimeContext, \"ontology\" | \"objectReader\">,\n query: ArtifactQuery\n): ArtifactQueryShape {\n const validated = validateObjectQuery(query.query, {\n ontology: runtime.ontology,\n discovery: getQueryDiscovery(runtime.objectReader),\n })\n\n return {\n resultObjectTypeIds: [...validated.result.objectTypeIds],\n readObjectTypeIds: [...validated.touchedObjectTypeIds],\n schema: artifactQuerySchema(getAuthorizedOntologyView(runtime.objectReader), validated),\n }\n}\n\n/**\n * The properties of the types a validated query returns, and of those each link it expands on its\n * rows reaches, read from `view`: a reader is never told of a property their view leaves out. A\n * type the view leaves out adds none. Only the outermost expansions are read, where normalization\n * puts every expansion of the rows; one nested in another is not.\n */\nexport function artifactQuerySchema(\n view: AuthorizedOntologyView,\n validated: ValidatedObjectQuery\n): ArtifactQuerySchema {\n const valueTypes = view.getValueTypesById()\n const results = validated.result.objectTypeIds\n const root = validated.query\n\n const links: Record<string, { properties: Record<string, ArtifactQueryProperty> }> = {}\n for (const expansion of root.kind === \"expand\" ? root.expansions : []) {\n links[expansion.linkId] = {\n properties: propertiesOf(view, expansionTargets(view, results, expansion), valueTypes),\n }\n }\n\n return { properties: propertiesOf(view, results, valueTypes), links }\n}\n\nfunction propertiesOf(\n view: AuthorizedOntologyView,\n objectTypeIds: readonly string[],\n valueTypes: ReadonlyMap<string, ValueType>\n): Record<string, ArtifactQueryProperty> {\n const properties: Record<string, ArtifactQueryProperty> = {}\n\n for (const objectTypeId of objectTypeIds) {\n for (const property of view.getObjectTypeById(objectTypeId)?.properties ?? []) {\n properties[property.id] ??= queryProperty(property.schema, valueTypes)\n }\n }\n\n return properties\n}\n\n/** What an expansion reaches from the rows, as the validator resolves it, within the view. */\nfunction expansionTargets(\n view: AuthorizedOntologyView,\n results: readonly string[],\n expansion: ObjectExpansion\n): string[] {\n const targets = new Set<string>()\n\n if (expansion.direction === \"outgoing\") {\n for (const objectTypeId of results) {\n const link = view\n .getObjectTypeById(objectTypeId)\n ?.links.find((candidate) => candidate.id === expansion.linkId)\n if (!link || link.targetObjectTypeId === \"*\") continue\n\n for (const target of [link.targetObjectTypeId].flat()) targets.add(target)\n }\n return [...targets]\n }\n\n const sources =\n expansion.sourceObjectTypeId === undefined\n ? view.listObjectTypes()\n : [view.getObjectTypeById(expansion.sourceObjectTypeId)].filter((type) => type !== null)\n\n for (const source of sources) {\n const link = source.links.find((candidate) => candidate.id === expansion.linkId)\n if (!link) continue\n\n const reaches =\n link.targetObjectTypeId === \"*\" ||\n results.some((result) => view.isValidLinkTarget(link.targetObjectTypeId, result))\n if (reaches) targets.add(source.id)\n }\n return [...targets]\n}\n\n/** A property's schema as a value of a row holds it: a value type's resolved to its own. */\nfunction queryProperty(\n schema: Schema,\n valueTypes: ReadonlyMap<string, ValueType>,\n depth = 0\n): ArtifactQueryProperty {\n if (typeof schema === \"string\") return { type: schema }\n\n switch (schema.type) {\n case \"valueTypeRef\": {\n const named = valueTypes.get(schema.valueTypeId)?.schema ?? schema._resolved\n // A value type naming itself, through others or not, holds what nothing else says.\n return named && depth < 8 ? queryProperty(named, valueTypes, depth + 1) : { type: \"object\" }\n }\n case \"enum\":\n return { type: \"enum\", valueType: schema.valueType }\n default:\n return { type: schema.type }\n }\n}\n\nasync function readRows(\n runtime: Pick<SixbRuntimeContext, \"objectReader\">,\n query: ArtifactQuery[\"query\"]\n): Promise<{ objects: ObjectRow[]; total: number; truncated: boolean }> {\n const objects: ObjectRow[] = []\n let total = 0\n let pageToken: string | undefined\n\n for (;;) {\n // The last page asks only for what fits under the cap, and says whether more remain.\n const pageSize = Math.min(PAGE_SIZE, ARTIFACT_LIMITS.maxQueryRows - objects.length)\n const first = pageToken === undefined\n\n const page = await runtime.objectReader.executeQuery({\n query: { kind: \"page\", input: query, pageSize, ...(pageToken ? { pageToken } : {}) },\n ...(first ? { includeTotal: true } : {}),\n })\n\n if (first) total = page.total ?? page.objects.length\n objects.push(...page.objects)\n\n if (!page.hasMore || page.nextPageToken === undefined) {\n return { objects, total, truncated: false }\n }\n if (objects.length >= ARTIFACT_LIMITS.maxQueryRows) {\n return { objects, total, truncated: true }\n }\n\n pageToken = page.nextPageToken\n }\n}\n\n/** A query the ontology no longer admits, in the words validation gives; anything else as is. */\nfunction queryInvalid(name: string, error: unknown): unknown {\n if (!(error instanceof ObjectQueryValidationError || error instanceof ObjectQueryPlanningError)) {\n return error\n }\n\n const issues = error.issues.map((issue) => `${issue.path}: ${issue.message}`).join(\"; \")\n const problem =\n error instanceof ObjectQueryValidationError\n ? \"no longer matches the ontology\"\n : \"can no longer run\"\n\n return new ArtifactRequestError(\"query_invalid\", `[Sixb] Query '${name}' ${problem}: ${issues}`)\n}\n",
|
|
20
|
+
"import { isRuntimeAllowed } from \"../../authorization\"\nimport { AuthorizationError } from \"../../authorization/errors\"\nimport { readerClearance } from \"../../execution/authorized-object-reader\"\nimport type { PropertyClearance } from \"../../objects/property-clearance\"\nimport {\n ObjectQueryExecutionError,\n ObjectQueryPlanningError,\n ObjectQueryValidationError,\n} from \"../../objects/query/errors\"\nimport type { ObjectExpansion, ObjectQuery } from \"../../objects/query/ir\"\nimport { normalizeObjectQuery } from \"../../objects/query/normalize\"\nimport {\n type ObjectQuerySemanticAdmission,\n validateObjectQueryWithAdmission,\n} from \"../../objects/query/validate\"\nimport type { OntologyRegistry } from \"../../ontology\"\nimport type { SixbRuntimeContext } from \"../../runtime/types\"\nimport type { ArtifactFile } from \"../../storage/artifacts/types\"\nimport type { ArtifactKind } from \"../kinds\"\nimport { ARTIFACT_LIMITS } from \"../limits\"\nimport {\n ARTIFACT_QUERIES_DIRECTORY,\n ARTIFACT_QUERY_KINDS,\n type ArtifactQuery,\n artifactQueryName,\n type CheckedArtifactQuery,\n DOCUMENT_HOLDER_QUERY,\n parseArtifactQuery,\n} from \"../queries\"\nimport { describeArtifactQuery } from \"../run-query\"\nimport { type ArtifactBlobStorage, invalidArtifact, readArtifactText } from \"./files\"\nimport { DOCUMENT_HTML_ENTRY } from \"./validate/document-html\"\n\n/**\n * Admits a query as the version's author: it throws what running it as them would throw, and\n * refuses one that would return what they cannot read; it returns what the query returns and what\n * its rows hold as they see them. A version is refused when its author could not run one of its\n * queries, so a query never reads what whoever wrote it cannot. Each reader still runs it with\n * their own rights.\n */\nexport type ArtifactQueryChecker = (query: ArtifactQuery) => Promise<CheckedArtifactQuery>\n\n/**\n * The checker for the runtime's caller. Running the query once, as cheaply as its kind allows,\n * is the check: validation against the ontology, `can.view` on every type it reads, clearance for\n * every marked property it filters, sorts or facets on, and the caller's share scope all apply\n * there, as they do when it is read.\n *\n * What the rows carry is checked after: a read leaves out a marked property its reader is not\n * cleared for, and the member profiles of a reader who may not view them, so running the query\n * admits one that returns them. A reader's rows reach the page's code, which its author wrote, so\n * the query may return only what the author can read. Facets return counts, never a property.\n */\nexport function createArtifactQueryChecker(\n runtime: Pick<\n SixbRuntimeContext,\n \"objectReader\" | \"ontology\" | \"projectId\" | \"runtimeAuthorization\" | \"authorization\"\n >\n): ArtifactQueryChecker {\n return async (query) => {\n const shape = describeArtifactQuery(runtime, query)\n\n if (query.kind === \"facets\") {\n await runtime.objectReader.facet({ query: query.query, facets: query.facets })\n return { kind: query.kind, ...shape }\n }\n\n await runtime.objectReader.exists({ query: query.query })\n\n const clearance = await readerClearance(runtime.objectReader)\n if (clearance) assertReturnsReadable(query.query, runtime.ontology, clearance)\n\n // The reader attaches profiles only for an authority that may view the directory.\n if (!isRuntimeAllowed(runtime, { kind: \"users.view\" })) assertExpandsNoUsers(query.query)\n\n return { kind: query.kind, ...shape }\n }\n}\n\n/** A query that would return what its author cannot read, at `at` in the query. */\nclass UnreadableReturnError extends AuthorizationError {\n constructor(\n grantKey: string,\n readonly at: string,\n message: string\n ) {\n super(grantKey, message)\n }\n}\n\n/**\n * Refuses a query whose rows would carry a property its author cannot read: one of the result's,\n * those the outermost `project` lists or every one without it, or one of an object an `expand`\n * attaches, which no projection narrows.\n *\n * A `project` counts only under nothing but expansions, sorts and limits. Under a filter, a\n * traversal or a set operand it may not shape the rows, so the query then returns every property.\n */\nfunction assertReturnsReadable(\n query: ObjectQuery,\n ontology: OntologyRegistry,\n clearance: PropertyClearance\n): void {\n const { normalized, resultObjectTypeIds, expansions } = returnedShape(query, ontology)\n const project = outermostProject(normalized)\n\n for (const objectTypeId of resultObjectTypeIds) {\n const propertyIds = project?.properties ?? propertiesOf(ontology, objectTypeId)\n const unreadable = firstUnreadable(clearance, objectTypeId, propertyIds)\n if (!unreadable) continue\n\n const returns = `returns '${unreadable.propertyId}' on '${objectTypeId}', which you are not cleared to read`\n throw project\n ? new UnreadableReturnError(\n `clearance:marking:${unreadable.marking}`,\n `${project.at}.properties[${unreadable.index}]`,\n `[Sixb] ${returns}: list only the properties you can read.`\n )\n : new UnreadableReturnError(\n `clearance:marking:${unreadable.marking}`,\n \"$\",\n `[Sixb] ${returns}: add a \"project\" node that lists only the properties you can read.`\n )\n }\n\n for (const expansion of expansions) {\n for (const objectTypeId of expansion.objectTypeIds) {\n const unreadable = firstUnreadable(\n clearance,\n objectTypeId,\n propertiesOf(ontology, objectTypeId)\n )\n if (!unreadable) continue\n\n throw new UnreadableReturnError(\n `clearance:marking:${unreadable.marking}`,\n expansion.at,\n `[Sixb] expands '${expansion.linkId}' to '${objectTypeId}', whose '${unreadable.propertyId}' you are not cleared to read: an expansion returns every property, so leave it out, or read '${objectTypeId}' in a query of its own with a \"project\" node.`\n )\n }\n }\n}\n\n/**\n * Refuses a query that expands member profiles, for an author who may not view them. Only the\n * outermost expand names them, at its rows or under its expansions, once normalized.\n */\nfunction assertExpandsNoUsers(query: ObjectQuery): void {\n const normalized = normalizeObjectQuery(query)\n if (normalized.kind !== \"expand\") return\n\n const expanded = firstUserExpansion(normalized.users, normalized.expansions, \"$\")\n if (!expanded) return\n\n throw new UnreadableReturnError(\n \"view:users\",\n expanded.at,\n `[Sixb] returns the member profiles '${expanded.propertyId}' refers to, which you are not allowed to view: leave '${expanded.propertyId}' out of \"users\".`\n )\n}\n\nfunction firstUserExpansion(\n users: readonly string[] | undefined,\n expansions: readonly ObjectExpansion[],\n at: string\n): { readonly propertyId: string; readonly at: string } | undefined {\n const [propertyId] = users ?? []\n if (propertyId !== undefined) return { propertyId, at: `${at}.users[0]` }\n\n for (const [index, expansion] of expansions.entries()) {\n const path = at === \"$\" ? `$.expansions[${index}]` : `${at}.expand[${index}]`\n const found = firstUserExpansion(expansion.users, expansion.expand ?? [], path)\n if (found) return found\n }\n\n return undefined\n}\n\nfunction propertiesOf(ontology: OntologyRegistry, objectTypeId: string): readonly string[] {\n return ontology.resolveObjectType(objectTypeId).properties.map((property) => property.id)\n}\n\nfunction firstUnreadable(\n clearance: PropertyClearance,\n objectTypeId: string,\n propertyIds: readonly string[]\n): { readonly propertyId: string; readonly index: number; readonly marking: string } | undefined {\n for (const [index, propertyId] of propertyIds.entries()) {\n const marking = clearance.missingMarking(objectTypeId, propertyId)\n if (marking !== undefined) return { propertyId, index, marking }\n }\n\n return undefined\n}\n\n/**\n * The query as it runs, the object types it returns, and those each expansion attaches, at any\n * depth. Validation resolves an expansion's targets, so a recording admission reads them there:\n * a set operand's expansions are among them too.\n */\nfunction returnedShape(query: ObjectQuery, ontology: OntologyRegistry) {\n const expansions: { readonly at: string; readonly linkId: string; objectTypeIds: string[] }[] = []\n\n const state = Object.freeze({})\n const recorder: ObjectQuerySemanticAdmission = {\n empty: () => state,\n source: () => ({ state }),\n property: () => undefined,\n edge: (input) => {\n if (input.use === \"expand\") {\n expansions.push({\n at: input.path,\n linkId: input.linkId,\n objectTypeIds: [...input.result.objectTypeIds],\n })\n }\n return { state }\n },\n set: () => state,\n }\n\n const validated = validateObjectQueryWithAdmission(query, { ontology }, recorder)\n return {\n normalized: validated.query,\n resultObjectTypeIds: validated.result.objectTypeIds,\n expansions,\n }\n}\n\n/** The `project` that shapes the rows, through the nodes that keep them as they are. */\nfunction outermostProject(\n query: ObjectQuery,\n at = \"$\"\n): { readonly properties: readonly string[]; readonly at: string } | undefined {\n switch (query.kind) {\n case \"project\":\n return query.properties ? { properties: query.properties, at } : undefined\n case \"expand\":\n case \"limit\":\n case \"sort\":\n return outermostProject(query.input, `${at}.input`)\n default:\n return undefined\n }\n}\n\n/**\n * Checks the `queries/` files of a version: their names and number, their shape, then each one as\n * its author through `checker`, and returns what each check learned by query name, for the kind's\n * own check. Fails closed: a version that holds a query is refused without one. A file artifact is\n * delivered as it is, so its one file is never read as a query.\n *\n * A designed document's query may start from the object that holds it, `holder`, an object of\n * the type it names: it is checked from every object of that type its author reads.\n */\nexport async function checkArtifactQueries(\n blobStorage: ArtifactBlobStorage,\n kind: ArtifactKind,\n files: readonly ArtifactFile[],\n checker: ArtifactQueryChecker | undefined,\n options: { readonly holder?: string } = {}\n): Promise<ReadonlyMap<string, CheckedArtifactQuery>> {\n const checked = new Map<string, CheckedArtifactQuery>()\n if (kind === \"file\") return checked\n\n const queries = files.filter((file) => file.path.startsWith(ARTIFACT_QUERIES_DIRECTORY))\n const [first] = queries\n if (!first) return checked\n\n const markdown = kind === \"document\" && !files.some((file) => file.path === DOCUMENT_HTML_ENTRY)\n if (!ARTIFACT_QUERY_KINDS.includes(kind) || markdown) {\n throw invalidArtifact(\n `'${first.path}': a ${markdown ? \"Markdown document\" : kind} runs no query. A Markdown document shows a live sheet instead; a designed one, document.html, runs queries.`\n )\n }\n\n if (queries.length > ARTIFACT_LIMITS.maxQueries) {\n throw invalidArtifact(\n `A version holds at most ${ARTIFACT_LIMITS.maxQueries} queries; this one has ${queries.length}.`\n )\n }\n\n if (!checker) {\n throw invalidArtifact(\n `'${first.path}' is a query, and this publish has no way to check it as its author.`\n )\n }\n\n // One at a time, so the same version is always refused for the same query.\n for (const file of queries) {\n const name = artifactQueryName(file.path)\n if (!name) {\n throw invalidArtifact(\n `'${file.path}' is not a query: name it queries/<name>.json, with lowercase letters, digits and hyphens, at most 64 characters.`\n )\n }\n if (kind === \"document\" && name === DOCUMENT_HOLDER_QUERY) {\n throw invalidArtifact(\n `'${file.path}': \"${DOCUMENT_HOLDER_QUERY}\" is what a document's fields read of the object that holds it. Name the query otherwise.`\n )\n }\n\n const text = await readArtifactText(blobStorage, file, ARTIFACT_LIMITS.maxQueryBytes)\n const parsed = parseArtifactQuery(\n file.path,\n text,\n options.holder ? { holder: { kind: \"start\", objectTypeId: options.holder } } : {}\n )\n if (\"error\" in parsed) throw invalidArtifact(parsed.error)\n\n try {\n checked.set(name, await checker(parsed.query))\n } catch (error) {\n throw refusal(file.path, parsed, error)\n }\n }\n\n return checked\n}\n\n/**\n * Why the author cannot run the query, naming the file and, for a problem in the query, where it\n * is in the file. A query's own paths start at the query, which a request holds under `query`;\n * a facet's paths are the file's already.\n */\nfunction refusal(\n path: string,\n parsed: { readonly query: ArtifactQuery; readonly at: \"$\" | \"$.query\" },\n error: unknown\n): unknown {\n const inFile = (issuePath: string) =>\n parsed.query.kind === \"facets\" && issuePath.startsWith(\"$.facets\")\n ? issuePath\n : `${parsed.at}${issuePath.slice(1)}`\n\n if (error instanceof UnreadableReturnError) {\n return invalidArtifact(\n `${path}: ${inFile(error.at)}: ${error.message.replace(/^\\[Sixb\\]\\s*/, \"\")}`\n )\n }\n\n if (error instanceof ObjectQueryValidationError || error instanceof ObjectQueryPlanningError) {\n const issues = error.issues.map((issue) => `${inFile(issue.path)}: ${issue.message}`)\n return invalidArtifact(`${path}: ${issues.join(\"; \")}`)\n }\n\n if (error instanceof AuthorizationError || error instanceof ObjectQueryExecutionError) {\n return invalidArtifact(`${path}: ${error.message.replace(/^\\[Sixb\\]\\s*/, \"\")}`)\n }\n\n return error\n}\n",
|
|
21
|
+
"import { type Principal, principalsEqual } from \"../../auth\"\nimport type {\n ArtifactRecord,\n ArtifactStorage,\n ArtifactVersionRecord,\n} from \"../../storage/artifacts/types\"\nimport { parseArtifactAddress } from \"../address\"\nimport { ARTIFACT_LIMITS } from \"../limits\"\nimport type { ArtifactReference } from \"../references\"\nimport { resolveArtifactAddress } from \"../resolve\"\nimport type { ArtifactWarning } from \"../warnings\"\nimport { invalidArtifact } from \"./files\"\n\n/** An address a validator found in a version, before it is resolved. */\nexport type FoundReference = Omit<ArtifactReference, \"resolvedVersion\">\n\ninterface ReferenceContext {\n readonly projectId: string\n readonly storage: ArtifactStorage\n /** Whether an address may name this artifact: one whoever publishes can read. */\n readonly readable: (artifact: ArtifactRecord) => Promise<boolean>\n /** The artifact being published, which an address may not name. */\n readonly artifactId?: string\n}\n\n/**\n * Resolves every address a version uses against what its author can read, recording the version\n * each one resolved to. An address that resolves to nothing refuses the version, saying where it\n * is and what the target has instead, and so does one pinned to a version still open: a pin names\n * content that never changes.\n */\nexport async function resolveReferences(\n context: ReferenceContext,\n found: readonly FoundReference[]\n): Promise<ArtifactReference[]> {\n if (found.length > ARTIFACT_LIMITS.maxReferences) {\n throw invalidArtifact(\n `A version may refer to at most ${ARTIFACT_LIMITS.maxReferences} artifacts; this one has ${found.length} addresses.`\n )\n }\n const artifacts = new Map<string, Promise<ArtifactRecord | null>>()\n const versions = new Map<string, Promise<ArtifactVersionRecord | null>>()\n const resolved: ArtifactReference[] = []\n for (const reference of found) {\n const where = reference.at\n ? `In '${reference.at}', '${reference.address}'`\n : `'${reference.address}'`\n const address = parseArtifactAddress(reference.address)\n if (!address) {\n throw invalidArtifact(\n `${where} is not an artifact address: write artifact:<id>[@<version>][/<file>][#<part>], such as artifact:art_k3m9q2x7tp#chart=revenue.`\n )\n }\n if (address.artifactId === context.artifactId) {\n throw invalidArtifact(\n `${where} names the artifact being published. Link to one of its sections with #<slug> instead.`\n )\n }\n let artifact = artifacts.get(address.artifactId)\n if (!artifact) {\n artifact = context.storage\n .get({ projectId: context.projectId, id: address.artifactId })\n .then(async (record) => (record && (await context.readable(record)) ? record : null))\n artifacts.set(address.artifactId, artifact)\n }\n const record = await artifact\n if (!record) {\n throw invalidArtifact(`${where} names no artifact you can read.`)\n }\n const number = address.version ?? record.latestVersion\n const key = `${record.id}@${number}`\n let version = versions.get(key)\n if (!version) {\n version = context.storage.getVersion({\n projectId: context.projectId,\n artifactId: record.id,\n version: number,\n })\n versions.set(key, version)\n }\n const target = await version\n if (!target) throw invalidArtifact(`${where}: “${record.title}” has no version ${number}.`)\n if (address.version !== undefined && !target.frozenAt) {\n throw invalidArtifact(\n `${where} pins version ${number} of “${record.title}”, which is still open and changes with every write. Write artifact:${record.id} without @${number} to follow its latest version; a version can be pinned once someone creates it.`\n )\n }\n const result = resolveArtifactAddress(address, { kind: record.kind, ...target })\n if (\"problem\" in result) {\n throw invalidArtifact(`${where}: “${target.title}” ${result.problem}.`)\n }\n resolved.push({ ...reference, resolvedVersion: target.version })\n }\n return resolved\n}\n\n/**\n * The artifacts a write breaks: each one whose latest version follows this artifact's latest and\n * names something this version no longer has. Only artifacts the author can read are named,\n * and only those the version breaks are checked: most dependents cost no read.\n */\nexport async function brokenDependents(\n context: ReferenceContext,\n artifact: ArtifactRecord,\n version: ArtifactVersionRecord\n): Promise<ArtifactWarning[]> {\n const dependents = await context.storage.listReferencingVersions({\n projectId: context.projectId,\n artifactId: artifact.id,\n })\n const warnings: ArtifactWarning[] = []\n for (const dependent of dependents) {\n if (dependent.artifactId === artifact.id) continue\n\n const broken: ArtifactWarning[] = []\n for (const reference of dependent.references) {\n const address = parseArtifactAddress(reference.address)\n // A pinned address keeps showing the version it names.\n if (address?.artifactId !== artifact.id || address.version !== undefined) continue\n const result = resolveArtifactAddress(address, { kind: artifact.kind, ...version })\n if (!(\"problem\" in result)) continue\n broken.push({\n code: \"reference_broken\",\n message: `“${dependent.title}” (${dependent.artifactId}) ${reference.as === \"embed\" ? \"shows\" : \"links to\"} ${reference.address}, but version ${version.version} ${result.problem}. Update it with an address that resolves, or restore what it names.`,\n })\n }\n if (broken.length === 0) continue\n\n const owner = await context.storage.get({\n projectId: context.projectId,\n id: dependent.artifactId,\n })\n if (owner && (await context.readable(owner))) warnings.push(...broken)\n }\n return warnings\n}\n\n/** What its author reads when nothing else is said: their own artifacts, or all for system code. */\nexport function ownArtifacts(author: Principal): (artifact: ArtifactRecord) => Promise<boolean> {\n return async (artifact) => author.type === \"system\" || principalsEqual(author, artifact.owner)\n}\n",
|
|
22
|
+
"import { posix } from \"node:path\"\nimport type { ArtifactFile } from \"../../../storage/artifacts/types\"\nimport { CANVAS_FILE, type Canvas, parseCanvas } from \"../../canvas\"\nimport {\n type CanvasBox,\n type CanvasPoint,\n canvasArrowLine,\n canvasEndBox,\n canvasItemBox,\n} from \"../../canvas-display\"\nimport { ARTIFACT_LIMITS } from \"../../limits\"\nimport type { CanvasOutline, CanvasOutlineItem } from \"../../outline\"\nimport type { ArtifactWarning } from \"../../warnings\"\nimport { type ArtifactBlobStorage, invalidArtifact, readArtifactText } from \"../files\"\nimport type { FoundReference } from \"../references\"\nimport { readHtmlReferences, refuseFrameAssetPaths } from \"./html\"\n\n/**\n * Reads a canvas: `canvas.json`, then each board's HTML, which must be one of the version's files.\n * The addresses its embeds show and its boards use are returned to resolve, each at its item's id.\n * Boards that overlap, and notes or text drawn over a board, are warnings: the reader sees a page\n * covered.\n */\nexport async function validateCanvas(\n blobStorage: ArtifactBlobStorage,\n files: readonly ArtifactFile[]\n): Promise<{\n readonly entry: string\n readonly outline: CanvasOutline\n readonly references: readonly FoundReference[]\n readonly warnings: readonly ArtifactWarning[]\n}> {\n const byPath = new Map(files.map((file) => [file.path, file]))\n const canvasFile = byPath.get(CANVAS_FILE)\n if (!canvasFile) {\n throw invalidArtifact(\n `A canvas is '${CANVAS_FILE}', listing its items, with the HTML files its boards show beside it.`\n )\n }\n refuseFrameAssetPaths(files, \"the canvas\")\n const parsed = parseCanvas(\n await readArtifactText(blobStorage, canvasFile, ARTIFACT_LIMITS.maxCanvasBytes)\n )\n if (\"error\" in parsed) throw invalidArtifact(parsed.error)\n const { canvas } = parsed\n\n const references: FoundReference[] = []\n for (const item of canvas.items) {\n if (item.type === \"embed\") references.push({ address: item.src, as: \"embed\", at: item.id })\n if (item.type !== \"board\") continue\n const file = byPath.get(posix.normalize(item.file))\n if (!file) {\n throw invalidArtifact(\n `${CANVAS_FILE} board '${item.id}' shows '${item.file}', which is not one of the canvas's files.`\n )\n }\n const rewriter = new HTMLRewriter()\n const { references: found, refusal } = readHtmlReferences(rewriter, () => item.id, item.file)\n rewriter.transform(await readArtifactText(blobStorage, file, ARTIFACT_LIMITS.maxBoardBytes))\n const refused = refusal()\n if (refused) throw invalidArtifact(`Board '${item.id}': ${refused}`)\n references.push(...found)\n }\n\n return {\n entry: CANVAS_FILE,\n outline: {\n kind: \"canvas\",\n items: canvas.items.flatMap((item): CanvasOutlineItem[] => {\n const title = item.type === \"board\" || item.type === \"section\" ? item.title : undefined\n const named = { id: item.id, ...(title ? { title } : {}) }\n if (item.type === \"board\") {\n return [\n { ...named, type: \"board\", file: posix.normalize(item.file), w: item.w, h: item.h },\n ]\n }\n return item.type === \"section\" ? [{ ...named, type: \"section\" }] : []\n }),\n },\n references,\n warnings: [\n ...layoutWarnings(canvas),\n ...overprintWarnings(canvas),\n ...crossingArrowWarnings(canvas),\n ],\n }\n}\n\ninterface Box {\n readonly x: number\n readonly y: number\n readonly w: number\n readonly h: number\n}\n\nconst overlaps = (a: Box, b: Box) =>\n a.x < b.x + b.w && b.x < a.x + a.w && a.y < b.y + b.h && b.y < a.y + a.h\n\n/**\n * What covers a board on the canvas: another board over it, or a note or a text whose top left\n * corner lands on it. A note's height follows its text, so only its corner is sure; a section\n * holds boards on purpose.\n */\nfunction layoutWarnings(canvas: Canvas): ArtifactWarning[] {\n const boards = canvas.items.flatMap((item) => (item.type === \"board\" ? [item] : []))\n const warnings: ArtifactWarning[] = []\n boards.forEach((board, index) => {\n for (const other of boards.slice(index + 1)) {\n if (!overlaps(board, other)) continue\n warnings.push({\n code: \"canvas_overlap\",\n part: board.id,\n message: `Boards '${board.id}' and '${other.id}' overlap, so one covers the other's page: leave 80 pixels between boards in a row and 160 between rows.`,\n })\n }\n })\n for (const item of canvas.items) {\n if (item.type !== \"note\" && item.type !== \"text\") continue\n const corner = { x: item.x, y: item.y, w: 1, h: 1 }\n const board = boards.find((candidate) => overlaps(candidate, corner))\n if (!board) continue\n warnings.push({\n code: \"canvas_covers_board\",\n part: item.id,\n message: `${item.type === \"note\" ? \"Note\" : \"Text\"} '${item.id}' sits on board '${board.id}' and covers its page: put it beside the board, and an arrow to it when it is about the board.`,\n })\n }\n return warnings\n}\n\n/** The most pairs of words drawn over each other warned of one by one. */\nconst MAX_OVERPRINTS = 12\n\n/**\n * Texts and notes drawn over each other, as the app draws them: a title's box reckoned from its\n * words and size, lines and all, so a subtitle placed under where a large title ends is caught.\n */\nfunction overprintWarnings(canvas: Canvas): ArtifactWarning[] {\n const worded = canvas.items.flatMap((item) => {\n if (item.type !== \"text\" && item.type !== \"note\") return []\n const box = canvasItemBox(item)\n return box ? [{ item, box }] : []\n })\n\n const pairs = worded.flatMap((first, index) =>\n worded\n .slice(index + 1)\n .filter((second) => intersects(first.box, second.box))\n .map((second) => [first.item, second.item] as const)\n )\n\n const warnings: ArtifactWarning[] = pairs.slice(0, MAX_OVERPRINTS).map(([first, second]) => ({\n code: \"canvas_text_overlap\",\n part: first.id,\n message: `${first.type === \"note\" ? \"Note\" : \"Text\"} '${first.id}' and ${second.type} '${second.id}' are drawn over each other, so neither reads: move one clear of the other.`,\n }))\n const more = pairs.length - warnings.length\n if (more > 0) {\n warnings.push({\n code: \"canvas_text_overlap\",\n message: `${more} more pair${more === 1 ? \" is\" : \"s are\"} drawn over each other.`,\n })\n }\n return warnings\n}\n\n/** Whether two boxes share some area: touching edges do not. */\nfunction intersects(a: CanvasBox, b: CanvasBox): boolean {\n return a.x < b.x + b.width && b.x < a.x + a.width && a.y < b.y + b.height && b.y < a.y + a.height\n}\n\n/** The most arrows warned of one by one, and items named for one arrow. */\nconst MAX_CROSSING_ARROWS = 12\nconst MAX_CROSSED_ITEMS = 3\n\n/**\n * Arrows drawn across other items: the straight line the app draws, from the edge of one end's box\n * to the edge of the other's, through a board, a note, a shape, a text, or an embed. Sections hold\n * what their arrows join, so an arrow crosses them on purpose. A row that wraps to the next is the\n * usual cause: its last item's arrow runs back across the row to the next one's first.\n */\nfunction crossingArrowWarnings(canvas: Canvas): ArtifactWarning[] {\n const boxes = new Map(\n canvas.items.flatMap((item) => {\n const box = canvasItemBox(item)\n return box ? [[item.id, box] as const] : []\n })\n )\n const crossable = canvas.items.filter((item) => item.type !== \"arrow\" && item.type !== \"section\")\n\n const crossing = canvas.items.flatMap((arrow) => {\n if (arrow.type !== \"arrow\") return []\n const from = canvasEndBox(arrow.from, boxes)\n const to = canvasEndBox(arrow.to, boxes)\n if (!from || !to) return []\n\n const { start, end } = canvasArrowLine(from, to)\n const crossed = crossable.filter((item) => {\n const box = boxes.get(item.id)\n return item.id !== arrow.from && item.id !== arrow.to && box && crosses(start, end, box)\n })\n return crossed.length === 0 ? [] : [{ arrow, crossed }]\n })\n\n const warnings: ArtifactWarning[] = crossing\n .slice(0, MAX_CROSSING_ARROWS)\n .map(({ arrow, crossed }) => {\n const named = crossed.slice(0, MAX_CROSSED_ITEMS).map((item) => `${item.type} '${item.id}'`)\n const more = crossed.length - named.length\n return {\n code: \"canvas_arrow_crosses\",\n part: arrow.id,\n message: `Arrow '${arrow.id}' is drawn across ${named.join(\", \")}${more > 0 ? ` and ${more} more` : \"\"}: join neighbours in a row with arrows, and let a sequence that wraps to the next row read on without one.`,\n }\n })\n const more = crossing.length - warnings.length\n if (more > 0) {\n warnings.push({\n code: \"canvas_arrow_crosses\",\n message: `${more} more arrow${more === 1 ? \" is\" : \"s are\"} drawn across other items.`,\n })\n }\n return warnings\n}\n\n/** Whether the segment from `start` to `end` passes through the inside of a box. */\nfunction crosses(start: CanvasPoint, end: CanvasPoint, box: CanvasBox): boolean {\n // Liang-Barsky: clip the segment to the box, and see whether anything of it is left inside.\n const dx = end.x - start.x\n const dy = end.y - start.y\n let enter = 0\n let leave = 1\n const edges: readonly (readonly [number, number])[] = [\n [-dx, start.x - box.x],\n [dx, box.x + box.width - start.x],\n [-dy, start.y - box.y],\n [dy, box.y + box.height - start.y],\n ]\n for (const [direction, room] of edges) {\n if (direction === 0) {\n if (room <= 0) return false\n continue\n }\n const at = room / direction\n if (direction < 0) enter = Math.max(enter, at)\n else leave = Math.min(leave, at)\n if (enter >= leave) return false\n }\n return true\n}\n",
|
|
23
|
+
"import { posix } from \"node:path\"\nimport type { ArtifactFile } from \"../../../storage/artifacts/types\"\nimport { isArtifactAddress } from \"../../address\"\nimport type { DocumentMark } from \"../../frames/document-data\"\nimport { decodeHtmlEntities } from \"../../html\"\nimport { ARTIFACT_LIMITS } from \"../../limits\"\nimport { createHeadingSlugger, type DocumentHeading, type DocumentOutline } from \"../../outline\"\nimport { type ArtifactBlobStorage, invalidArtifact, readArtifactText } from \"../files\"\nimport type { FoundReference } from \"../references\"\nimport { DOCUMENT_HTML_ENTRY, validateHtmlDocument } from \"./document-html\"\n\n/** The file a document renders from. */\nexport const DOCUMENT_ENTRY = \"document.md\"\n\n/**\n * Reads a document, from its Markdown in `document.md` or, designed, from `document.html`: one or\n * the other, never both.\n */\nexport async function validateDocument(\n blobStorage: ArtifactBlobStorage,\n files: readonly ArtifactFile[]\n): Promise<{\n readonly entry: string\n readonly outline: DocumentOutline\n readonly references: readonly FoundReference[]\n /** A designed document's fields and repeated elements. */\n readonly marks?: readonly DocumentMark[]\n}> {\n const markdown = files.find((file) => file.path === DOCUMENT_ENTRY)\n const designed = files.some((file) => file.path === DOCUMENT_HTML_ENTRY)\n if (markdown && designed) {\n throw invalidArtifact(\n `A document renders from '${DOCUMENT_ENTRY}' or from '${DOCUMENT_HTML_ENTRY}', not both: keep one.`\n )\n }\n if (designed) return validateHtmlDocument(blobStorage, files)\n if (!markdown) {\n throw invalidArtifact(\n `A document needs its Markdown in '${DOCUMENT_ENTRY}', or its HTML in '${DOCUMENT_HTML_ENTRY}' when it has a design of its own.`\n )\n }\n return validateMarkdownDocument(blobStorage, markdown, files)\n}\n\n/**\n * Reads a document's Markdown: its headings become the outline, and every image must be a file in\n * the version or an `artifact:` address, so the document renders the same wherever it is opened.\n * The addresses it shows and links to are returned with the section each sits in, to resolve.\n */\nasync function validateMarkdownDocument(\n blobStorage: ArtifactBlobStorage,\n entry: ArtifactFile,\n files: readonly ArtifactFile[]\n): Promise<{\n readonly entry: string\n readonly outline: DocumentOutline\n readonly references: readonly FoundReference[]\n}> {\n const markdown = await readArtifactText(blobStorage, entry, ARTIFACT_LIMITS.maxDocumentBytes)\n\n // The same options the docs site renders with, so headings and images read the same way.\n const html = Bun.markdown.html(markdown, {\n tables: true,\n strikethrough: true,\n tasklists: true,\n autolinks: true,\n })\n const headings: { depth: number; text: string }[] = []\n const images: string[] = []\n // Each address with the index of the heading it follows, -1 before the first.\n const addresses: { address: string; as: \"embed\" | \"link\"; heading: number }[] = []\n let heading: { depth: number; text: string } | null = null\n new HTMLRewriter()\n .on(\"h1, h2, h3, h4, h5, h6\", {\n element(element) {\n heading = { depth: Number(element.tagName.slice(1)), text: \"\" }\n headings.push(heading)\n element.onEndTag(() => {\n heading = null\n })\n },\n text(chunk) {\n if (heading) heading.text += chunk.text\n },\n })\n .on(\"img\", {\n element(element) {\n const source = decodeHtmlEntities(element.getAttribute(\"src\") ?? \"\")\n if (isArtifactAddress(source)) {\n addresses.push({ address: source.trim(), as: \"embed\", heading: headings.length - 1 })\n } else {\n images.push(source)\n }\n },\n })\n .on(\"a\", {\n element(element) {\n const href = decodeHtmlEntities(element.getAttribute(\"href\") ?? \"\")\n if (isArtifactAddress(href)) {\n addresses.push({ address: href.trim(), as: \"link\", heading: headings.length - 1 })\n }\n },\n })\n .transform(html)\n\n const paths = new Set(files.map((file) => file.path))\n for (const source of images) checkImage(source, paths)\n\n const slug = createHeadingSlugger()\n const outlined = headings.map(({ depth, text }): DocumentHeading => {\n const plain = decodeHtmlEntities(text).replace(/\\s+/g, \" \").trim()\n return { depth, text: plain, slug: slug(plain) }\n })\n return {\n entry: DOCUMENT_ENTRY,\n outline: { kind: \"document\", headings: outlined },\n references: addresses.map(({ address, as, heading: index }) => ({\n address,\n as,\n at: outlined[index]?.slug ?? \"\",\n })),\n }\n}\n\nfunction checkImage(source: string, paths: ReadonlySet<string>): void {\n if (source === \"\" || source.startsWith(\"//\") || /^[a-z][a-z\\d+.-]*:/i.test(source)) {\n throw invalidArtifact(\n `${DOCUMENT_ENTRY} shows the image '${source}'. Images must be files in the artifact, by their relative path, or another artifact's address, such as artifact:art_k3m9q2x7tp#chart=revenue.`\n )\n }\n const path = posix.normalize(safeDecodeUri(source.split(/[?#]/)[0] ?? \"\"))\n if (!paths.has(path)) {\n throw invalidArtifact(\n `${DOCUMENT_ENTRY} shows the image '${source}', which is not one of the artifact's files.`\n )\n }\n}\n\nfunction safeDecodeUri(value: string): string {\n try {\n return decodeURI(value)\n } catch {\n return value\n }\n}\n",
|
|
24
|
+
"import { inferFileMediaType } from \"../../../blob-storage/media-type\"\nimport type { ArtifactFile } from \"../../../storage/artifacts/types\"\nimport type { FileOutline } from \"../../outline\"\nimport { invalidArtifact } from \"../files\"\n\n/** A file artifact is one file of any type, delivered as it is. */\nexport function validateFileArtifact(files: readonly ArtifactFile[]): {\n readonly entry: string\n readonly outline: FileOutline\n} {\n const [file] = files\n if (!file || files.length > 1) {\n throw invalidArtifact(`A file artifact holds exactly one file; this one has ${files.length}.`)\n }\n return {\n entry: file.path,\n outline: { kind: \"file\", mediaType: file.file.mediaType ?? inferFileMediaType(file.path) },\n }\n}\n",
|
|
25
|
+
"import type { ArtifactFile } from \"../../../storage/artifacts/types\"\nimport { decodeHtmlEntities } from \"../../html\"\nimport { ARTIFACT_LIMITS } from \"../../limits\"\nimport type { PageOutline } from \"../../outline\"\nimport { type ArtifactBlobStorage, invalidArtifact, readArtifactText } from \"../files\"\nimport type { FoundReference } from \"../references\"\nimport { HTML_ENTRY, readHtmlReferences, refuseFrameAssetPaths } from \"./html\"\n\n/**\n * Reads a page: `index.html` and the files it loads beside it, its scripts, styles, images, and\n * data. Its `<title>`, else its first `<h1>`, becomes its title in the outline. The `artifact:`\n * addresses it uses are returned to resolve, as a deck's are.\n */\nexport async function validatePage(\n blobStorage: ArtifactBlobStorage,\n files: readonly ArtifactFile[]\n): Promise<{\n readonly entry: string\n readonly outline: PageOutline\n readonly references: readonly FoundReference[]\n}> {\n const entry = files.find((file) => file.path === HTML_ENTRY)\n if (!entry) {\n throw invalidArtifact(\n `A page needs '${HTML_ENTRY}', the page itself; put its scripts, styles, and data beside it.`\n )\n }\n refuseFrameAssetPaths(files, \"the page\")\n const html = await readArtifactText(blobStorage, entry, ARTIFACT_LIMITS.maxPageBytes)\n\n let title = \"\"\n let heading = \"\"\n let readingHeading = false\n const rewriter = new HTMLRewriter()\n .on(\"title\", {\n text(chunk) {\n title += chunk.text\n },\n })\n .on(\"h1\", {\n element(element) {\n if (heading || readingHeading) return\n readingHeading = true\n element.onEndTag(() => {\n readingHeading = false\n heading ||= \" \"\n })\n },\n text(chunk) {\n if (readingHeading) heading += chunk.text\n },\n })\n const { references, refusal } = readHtmlReferences(rewriter, () => \"\")\n rewriter.transform(html)\n\n const refused = refusal()\n if (refused) throw invalidArtifact(refused)\n const plain = (text: string) => decodeHtmlEntities(text).replace(/\\s+/g, \" \").trim()\n const named = plain(title) || plain(heading)\n return {\n entry: HTML_ENTRY,\n outline: { kind: \"page\", ...(named ? { title: named.slice(0, 200) } : {}) },\n references,\n }\n}\n",
|
|
26
|
+
"import { posix } from \"node:path\"\nimport type { ArtifactFile } from \"../../../storage/artifacts/types\"\nimport { isArtifactAddress } from \"../../address\"\nimport { CsvParseError, type CsvTable, parseCsv } from \"../../csv\"\nimport { evaluateComputedColumns } from \"../../formula\"\nimport { ARTIFACT_LIMITS } from \"../../limits\"\nimport { liveSheetColumns } from \"../../live-sheet\"\nimport type { SheetOutline } from \"../../outline\"\nimport { artifactQueryPath, type CheckedArtifactQuery } from \"../../queries\"\nimport { sheetChartsProblem, sheetColumnsProblem, sheetFormulasProblem } from \"../../sheet-rules\"\nimport type { ArtifactWarning } from \"../../warnings\"\nimport {\n parseSheetDate,\n parseSheetNumber,\n parseWorkbook,\n type SheetColumnFormat,\n sheetFilePath,\n WORKBOOK_FILE,\n type Workbook,\n type WorkbookSheet,\n} from \"../../workbook\"\nimport { type ArtifactBlobStorage, invalidArtifact, readArtifactText } from \"../files\"\nimport type { FoundReference } from \"../references\"\n\n/**\n * Reads a sheet: `workbook.json`, then each sheet's CSV against it. Every cell of a typed column\n * must read as its type, every formula must compute its column, and every chart must name columns\n * its sheet has, so the grid formats and the charts draw the same wherever the sheet is opened.\n * Rows a formula computes to an error are warnings: the version publishes, and the grid shows them.\n *\n * A live sheet is checked against `queries`, what checking the version's queries as its author\n * learned: its query returns rows, and its columns show properties those rows hold, so its rules\n * hold as a CSV sheet's do. Its rows are each reader's, so no cell is checked.\n */\nexport async function validateSheet(\n blobStorage: ArtifactBlobStorage,\n files: readonly ArtifactFile[],\n queries: ReadonlyMap<string, CheckedArtifactQuery>\n): Promise<{\n readonly entry: string\n readonly outline: SheetOutline\n readonly references: readonly FoundReference[]\n readonly warnings: readonly ArtifactWarning[]\n}> {\n const byPath = new Map(files.map((file) => [file.path, file]))\n const workbookFile = byPath.get(WORKBOOK_FILE)\n if (!workbookFile) {\n throw invalidArtifact(\n `A sheet is a directory: '${WORKBOOK_FILE}' listing its sheets, and one CSV per sheet under sheets/. A single CSV publishes as a file.`\n )\n }\n const parsed = parseWorkbook(\n await readArtifactText(blobStorage, workbookFile, ARTIFACT_LIMITS.maxWorkbookBytes)\n )\n if (\"error\" in parsed) throw invalidArtifact(parsed.error)\n const { workbook } = parsed\n\n const declared = new Set(workbook.sheets.map((sheet) => sheetFilePath(sheet.name)))\n const stray = files.find((file) => file.path.startsWith(\"sheets/\") && !declared.has(file.path))\n if (stray) {\n throw invalidArtifact(\n `'${stray.path}' is not a sheet in ${WORKBOOK_FILE}: list it in \"sheets\", or move it out of sheets/.`\n )\n }\n\n const tables = new Map<string, CsvTable>()\n const references: FoundReference[] = []\n const warnings: ArtifactWarning[] = []\n const sheets: WorkbookSheet[] = []\n for (const sheet of workbook.sheets) {\n if (sheet.live) {\n const live = liveSheet(byPath, sheet, queries.get(sheet.live.query))\n sheets.push(live.sheet)\n tables.set(sheet.name, live.table)\n continue\n }\n\n const table = await readSheet(blobStorage, byPath, sheet, references)\n sheets.push(sheet)\n tables.set(sheet.name, table)\n warnings.push(...computeSheet(sheet, table))\n }\n\n // A live sheet's charts plot the columns it lays out, typed as its query's rows are.\n const laidOut: Workbook = { ...workbook, sheets }\n const charts = sheetChartsProblem(laidOut, tables)\n if (charts) throw invalidArtifact(charts)\n\n return {\n entry: WORKBOOK_FILE,\n outline: {\n kind: \"sheet\",\n sheets: workbook.sheets.map((sheet) => {\n const table = tables.get(sheet.name)\n return {\n name: sheet.name,\n rows: table?.rows.length ?? 0,\n columns: [...(table?.header ?? [])],\n ...(sheet.live ? { query: sheet.live.query } : {}),\n }\n }),\n charts: workbook.charts.map((chart) => chart.name),\n },\n references,\n warnings,\n }\n}\n\n/**\n * A live sheet laid out against its query as the author reads it, and its header as the table a\n * CSV would hold, with no rows: the rules a CSV sheet keeps are checked on it.\n */\nfunction liveSheet(\n byPath: ReadonlyMap<string, ArtifactFile>,\n sheet: WorkbookSheet,\n checked: CheckedArtifactQuery | undefined\n): { readonly sheet: WorkbookSheet; readonly table: CsvTable } {\n const query = sheet.live?.query\n const csv = sheetFilePath(sheet.name)\n if (byPath.has(csv)) {\n throw invalidArtifact(\n `Sheet '${sheet.name}' reads its rows from query '${query}', so it has no '${csv}': remove the CSV, or \"query\" to show it.`\n )\n }\n\n if (!checked || query === undefined) {\n throw invalidArtifact(\n `Sheet '${sheet.name}' reads query '${query}', which the version does not have: add '${artifactQueryPath(query ?? \"\")}'.`\n )\n }\n if (checked.kind === \"facets\") {\n throw invalidArtifact(\n `Sheet '${sheet.name}' reads query '${query}', which counts facets: a sheet shows rows. A page shows facets; give the sheet a query of rows.`\n )\n }\n\n const layout = liveSheetColumns(sheet, checked.schema)\n if (layout.problem) throw invalidArtifact(layout.problem)\n\n const table = { header: layout.columns.map((column) => column.name), rows: [] }\n const problem =\n sheetColumnsProblem(layout.sheet, table) ?? sheetFormulasProblem(layout.sheet, table)\n if (problem) throw invalidArtifact(problem)\n\n return { sheet: layout.sheet, table }\n}\n\nasync function readSheet(\n blobStorage: ArtifactBlobStorage,\n byPath: ReadonlyMap<string, ArtifactFile>,\n sheet: WorkbookSheet,\n references: FoundReference[]\n): Promise<CsvTable> {\n const path = sheetFilePath(sheet.name)\n const file = byPath.get(path)\n if (!file) throw invalidArtifact(`Sheet '${sheet.name}' needs its values in '${path}'.`)\n\n if (file.file.sizeBytes > ARTIFACT_LIMITS.maxSheetFileBytes) {\n throw invalidArtifact(\n `'${path}' is ${megabytes(file.file.sizeBytes)} MB; a sheet's values may be at most ${megabytes(ARTIFACT_LIMITS.maxSheetFileBytes)} MB, which is what the viewer reads. Split it into several sheets, or publish the CSV as a file.`\n )\n }\n let table: CsvTable\n try {\n table = parseCsv(await readArtifactText(blobStorage, file, ARTIFACT_LIMITS.maxSheetFileBytes))\n } catch (error) {\n if (error instanceof CsvParseError) throw invalidArtifact(`'${path}': ${error.message}`)\n throw error\n }\n\n const columns = sheetColumnsProblem(sheet, table)\n if (columns) throw invalidArtifact(columns)\n\n const { header } = table\n for (const [column, format] of Object.entries(sheet.columns)) {\n const index = header.indexOf(column)\n if (format.type === \"link\" || format.type === \"image\") {\n // A link or image may be another artifact's address, resolved with the rest.\n for (const [rowIndex, row] of table.rows.entries()) {\n const value = row[index]?.trim() ?? \"\"\n if (!isArtifactAddress(value)) continue\n references.push({\n address: value,\n as: format.type === \"image\" ? \"embed\" : \"link\",\n at: `${sheet.name}!${columnLetter(index)}${rowIndex + 2}`,\n })\n }\n }\n if (format.formula) {\n checkComputedValues(path, table, index, column)\n continue\n }\n checkColumn(path, table, index, column, format, byPath)\n }\n return table\n}\n\n/** A computed column's values come from its formula: the CSV leaves them empty. */\nfunction checkComputedValues(path: string, table: CsvTable, index: number, column: string): void {\n for (const [rowIndex, row] of table.rows.entries()) {\n const value = row[index] ?? \"\"\n if (value.trim()) {\n throw invalidArtifact(\n `'${path}' row ${rowIndex + 2}, column '${column}': ${JSON.stringify(value)} is in a computed column; leave its values empty, and its formula fills them.`\n )\n }\n }\n}\n\n/**\n * Checks each computed column's formula against the sheet's columns and computes them all, so a\n * formula that can't compute refuses the version and one that computes to an error in some rows\n * warns.\n */\nfunction computeSheet(sheet: WorkbookSheet, table: CsvTable): ArtifactWarning[] {\n const formulas = sheetFormulasProblem(sheet, table)\n if (formulas) throw invalidArtifact(formulas)\n\n const computed = evaluateComputedColumns(sheet, table)\n return [...computed.errors].map(([column, errors]) => ({\n code: \"sheet_formula_error\",\n part: sheet.name,\n message: `Sheet '${sheet.name}' column '${column}' computes to ${errors.code} in ${errors.count === 1 ? \"1 row\" : `${errors.count} rows`}, the first row ${errors.firstRow + 2}. IFERROR gives those rows a value.`,\n }))\n}\n\nfunction checkColumn(\n path: string,\n table: CsvTable,\n index: number,\n column: string,\n format: SheetColumnFormat,\n byPath: ReadonlyMap<string, ArtifactFile>\n): void {\n for (const [rowIndex, row] of table.rows.entries()) {\n const value = row[index] ?? \"\"\n if (!value.trim() || isArtifactAddress(value)) continue\n const problem = cellProblem(value, format, byPath)\n if (problem) {\n throw invalidArtifact(\n `'${path}' row ${rowIndex + 2}, column '${column}': ${JSON.stringify(value)} ${problem}`\n )\n }\n }\n}\n\nfunction cellProblem(\n value: string,\n format: SheetColumnFormat,\n byPath: ReadonlyMap<string, ArtifactFile>\n): string | undefined {\n switch (format.type) {\n case \"number\":\n case \"currency\":\n return parseSheetNumber(value) === undefined\n ? \"is not a number: write plain digits, such as 4120000 or -3.5, with no symbols or separators.\"\n : undefined\n case \"percent\":\n return parseSheetNumber(value) === undefined\n ? \"is not a number: write a percent as a fraction, such as 0.351 for 35.1%.\"\n : undefined\n case \"date\":\n return parseSheetDate(value) === undefined\n ? \"is not a date: write YYYY-MM-DD, or an ISO 8601 date and time.\"\n : undefined\n case \"link\":\n return /^https?:\\/\\/[^\\s]+$/i.test(value.trim())\n ? undefined\n : \"is not a link: write a full https:// address, or another artifact's address.\"\n case \"image\": {\n const imagePath = posix.normalize(value.trim())\n return byPath.has(imagePath)\n ? undefined\n : \"is not one of the artifact's files: add the image to the artifact and give its relative path, or give another artifact's address.\"\n }\n case \"boolean\":\n return /^(true|false)$/i.test(value.trim())\n ? undefined\n : \"is not true or false: write true or false, or leave the cell empty.\"\n case \"text\":\n case \"tag\":\n return undefined\n }\n}\n\n/** A column's letter as a spreadsheet shows it: A, Z, AA. */\nfunction columnLetter(index: number): string {\n let letters = \"\"\n for (let rest = index + 1; rest > 0; rest = Math.floor((rest - 1) / 26)) {\n letters = String.fromCharCode(65 + ((rest - 1) % 26)) + letters\n }\n return letters\n}\n\nfunction megabytes(bytes: number): string {\n return (bytes / (1024 * 1024)).toFixed(1).replace(/\\.0$/, \"\")\n}\n",
|
|
27
|
+
"import type { ArtifactFile } from \"../../../storage/artifacts/types\"\nimport { decodeHtmlEntities } from \"../../html\"\nimport { ARTIFACT_LIMITS } from \"../../limits\"\nimport type { SlidesOutline } from \"../../outline\"\nimport { type ArtifactBlobStorage, invalidArtifact, readArtifactText } from \"../files\"\nimport type { FoundReference } from \"../references\"\nimport { HTML_ENTRY, readHtmlReferences, refuseFrameAssetPaths } from \"./html\"\n\n/**\n * Reads a deck: `index.html` with one `<section class=\"slide\">` per 1280×720 slide, and the files\n * it loads beside it. Each slide's first heading becomes its title in the outline. The `artifact:`\n * addresses it uses are returned with the slide each is on, to resolve.\n */\nexport async function validateSlides(\n blobStorage: ArtifactBlobStorage,\n files: readonly ArtifactFile[]\n): Promise<{\n readonly entry: string\n readonly outline: SlidesOutline\n readonly references: readonly FoundReference[]\n}> {\n const entry = files.find((file) => file.path === HTML_ENTRY)\n if (!entry) {\n throw invalidArtifact(\n `A deck needs '${HTML_ENTRY}' with one <section class=\"slide\"> per slide.`\n )\n }\n refuseFrameAssetPaths(files, \"the deck\")\n const html = await readArtifactText(blobStorage, entry, ARTIFACT_LIMITS.maxDeckBytes)\n\n const slides: { title: string; heading: boolean }[] = []\n const at = () => String(Math.max(1, slides.length))\n // The heading being read, if it is the first of the current slide.\n let reading: { title: string; heading: boolean } | null = null\n const rewriter = new HTMLRewriter()\n .on(\"section\", {\n element(element) {\n const classes = (element.getAttribute(\"class\") ?? \"\").split(/\\s+/)\n if (classes.includes(\"slide\")) slides.push({ title: \"\", heading: false })\n },\n })\n .on(\"h1, h2, h3\", {\n element(element) {\n const slide = slides.at(-1)\n if (!slide || slide.heading) return\n slide.heading = true\n reading = slide\n element.onEndTag(() => {\n reading = null\n })\n },\n text(chunk) {\n if (reading) reading.title += chunk.text\n },\n })\n const { references, refusal } = readHtmlReferences(rewriter, at)\n rewriter.transform(html)\n\n const refused = refusal()\n if (refused) throw invalidArtifact(refused)\n if (slides.length === 0) {\n throw invalidArtifact(\n `${HTML_ENTRY} has no slides: put each slide in a <section class=\"slide\">.`\n )\n }\n if (slides.length > ARTIFACT_LIMITS.maxSlides) {\n throw invalidArtifact(\n `A deck holds at most ${ARTIFACT_LIMITS.maxSlides} slides; this one has ${slides.length}.`\n )\n }\n return {\n entry: HTML_ENTRY,\n outline: {\n kind: \"slides\",\n slides: slides.map(({ title }) => {\n const plain = decodeHtmlEntities(title).replace(/\\s+/g, \" \").trim()\n return plain ? { title: plain } : {}\n }),\n },\n references,\n }\n}\n",
|
|
28
|
+
"import { createHash } from \"node:crypto\"\nimport type { ArtifactFile } from \"../../storage/artifacts/types\"\nimport { isArtifactAddress } from \"../address\"\nimport {\n VIDEO_ENTRY,\n type VideoComposition,\n type VideoScene,\n type VideoSourceSpan,\n videoFilePath,\n videoPageMedia,\n} from \"../video/composition\"\nimport type { VideoMediaFile } from \"../video/export\"\nimport { scenesOnScreen, videoSegmentFrames } from \"../video/project\"\nimport { frameKitDigest } from \"./previews\"\n\n// A video renders scene by scene: each scene is a segment of the export, kept apart from the\n// version by what it shows, its render key, so a version that changes one scene renders that scene\n// again and reuses every other. See video/README.md.\n\nconst RENDER_KEY_FORMAT = \"sixb-video-scene/1\"\n\n/** What a scene's host writes of its times and its name, which its key holds as resolved. */\nconst HOST_TIMES = [\"data-start\", \"data-duration\", \"data-label\"]\n\n/** What stands where a scene's host was: a host moved past the root's own content still counts. */\nconst HOST_PLACE = \"<!-- scene -->\"\n\n/**\n * Where HyperFrames' CLI keeps a project's own state, its edit history among it. No frame loads\n * it, and a version that drops it, as the Agent's publishing always does, shows the same frames.\n */\nconst HYPERFRAMES_STATE = \".hyperframes/\"\n\n/**\n * Each scene's render key, by its id: a SHA-256 of what its frames are made of. That is\n *\n * - the frame's kit and runtime;\n * - `index.html` without its scene hosts, the root's own length, and the sounds it plays: the\n * frame's size, the root's styles, and what it shows itself;\n * - the scene's host, and those of the scenes on screen during its segment, from the frame it\n * starts on up to the one the next scene starts on, as one fades into it: each with what it\n * writes, its length, and its start from the scene's, in the order `index.html` lists them,\n * which stacks them. A scene that fades in after the segment shows none of its frames;\n * - its start in the video, only when the root plays or animates something of its own\n * (`rootTimeline`): only then does what the scene shows depend on when it plays. A scene's own\n * CSS animations and GSAP timeline run from its start, wherever it plays (measured: README);\n * - every other file of the version, with what it holds, but the other scenes' HTML, the videos\n * neither the root nor a scene on screen during the segment plays, every sound, and\n * HyperFrames' own state in `.hyperframes/`.\n *\n * A segment is pictures alone: the export mixes the whole video's sound once, apart, so a sound is\n * in no key, and a soundtrack changed or moved renders no scene again.\n *\n * So trimming a scene renders it again, and the scene it fades into, but not the others unless the\n * root has a timeline of its own. Images, stylesheets, fonts, scripts, and nested compositions are\n * in every key, whatever loads them; only a recording a scene loads by script alone is missed.\n *\n * `loads` holds what each scene plays, by its id: its file, what it nests, and what they play, as\n * their HTML writes it.\n *\n * The key names no artifact: two artifacts that hold the same scene, such as a copy, share its\n * segment. A segment is the scene's frames and nothing else, rendered by the worker from these\n * files alone, so it is the same picture whoever holds it. An `artifact:` address a scene plays\n * is in its HTML as written: the export adds what it resolves to, to its segment's own key.\n */\nexport function sceneRenderKeys(input: {\n /** `index.html`'s text, which the composition's spans point into. */\n readonly index: string\n readonly composition: VideoComposition\n readonly files: readonly ArtifactFile[]\n /** What the root plays itself. */\n readonly rootLoads: ReadonlySet<string>\n /** Whether the root plays or animates something of its own, its linked files read. */\n readonly rootTimeline: boolean\n readonly loads: ReadonlyMap<string, ReadonlySet<string>>\n}): ReadonlyMap<string, string> {\n const { index, composition, files, rootLoads, rootTimeline, loads } = input\n const { scenes } = composition\n\n // Its length and its poster's instant change no frame a scene renders, and a sound shows in\n // none: the root's `<audio>` elements are left out too. Each goes with the space before it, so a\n // root that writes one and a root that does not are the same text, and a soundtrack added,\n // moved, or trimmed with the video leaves it as it was.\n const { attributes } = composition.root\n const root = cut(index, [\n ...scenes.map((scene) => ({ ...scene.host.element, with: HOST_PLACE })),\n ...[\n ...([\"data-duration\", \"data-poster\"] as const).flatMap((name) => attributes[name] ?? []),\n ...composition.sounds,\n ].map((span) => ({ ...withSpaceBefore(index, span), with: \"\" })),\n ])\n\n const hostOf = (scene: VideoScene) => {\n const { element, attributes } = scene.host\n const times = HOST_TIMES.flatMap((name) => {\n const at = attributes[name]\n return at ? [{ start: at.start - element.start, end: at.end - element.start, with: \"\" }] : []\n })\n return cut(index.slice(element.start, element.end), times)\n }\n\n const segments = videoSegmentFrames(composition)\n return new Map(\n scenes.map((scene) => {\n const segment = segments.get(scene.id)\n const beside = (segment ? scenesOnScreen(composition, segment) : [scene]).sort(\n (a, b) => a.host.element.start - b.host.element.start\n )\n\n const loaded = videoSceneFiles({\n files,\n composition,\n rootLoads,\n loads,\n scenes: beside.map((each) => each.id),\n })\n .filter(({ path }) => path !== VIDEO_ENTRY)\n .map((entry) => [entry.path, entry.file.digest] as const)\n .sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0))\n\n const key = [\n RENDER_KEY_FORMAT,\n frameKitDigest(\"video\"),\n scene.id,\n sha256(root),\n beside.map((each) => [hostOf(each), each.startMs - scene.startMs, each.durationMs]),\n rootTimeline ? scene.startMs : null,\n loaded,\n ]\n return [scene.id, sha256(JSON.stringify(key))] as const\n })\n )\n}\n\n/**\n * The files the frames of `scenes`, shown together, are made of: `index.html`, what the root and\n * those scenes play, and every other file of the version but the other scenes' HTML, the videos\n * nothing among them plays, and HyperFrames' own state. A sound shows in no frame and is left out,\n * unless `sounds`: HyperFrames still loads every sound of what it renders.\n */\nexport function videoSceneFiles(input: {\n readonly files: readonly ArtifactFile[]\n readonly composition: Pick<VideoComposition, \"scenes\">\n readonly rootLoads: ReadonlySet<string>\n readonly loads: ReadonlyMap<string, ReadonlySet<string>>\n readonly scenes: readonly string[]\n readonly sounds?: boolean\n}): ArtifactFile[] {\n const { files, composition, rootLoads, loads } = input\n const sceneFiles = new Set(composition.scenes.map((scene) => scene.src))\n const own = new Set([...rootLoads, ...input.scenes.flatMap((id) => [...(loads.get(id) ?? [])])])\n\n return files.filter(({ path, file }) => {\n const type = file.mediaType ?? \"\"\n if (path === VIDEO_ENTRY) return true\n if (type.startsWith(\"audio/\") && !input.sounds) return false\n if (own.has(path)) return true\n if (path.startsWith(HYPERFRAMES_STATE)) return false\n return !sceneFiles.has(path) && !/^(video|audio)\\//.test(type)\n })\n}\n\n/** The span, with the spaces and line breaks right before it. */\nfunction withSpaceBefore(text: string, span: VideoSourceSpan): VideoSourceSpan {\n let start = span.start\n while (start > 0 && /\\s/.test(text[start - 1] ?? \"\")) start--\n return { start, end: span.end }\n}\n\n/**\n * What the whole video's sound is mixed from: its pages, each muted video's sources cut, and every\n * other file but the videos nothing heard plays. HyperFrames mixes no muted video, yet looks for\n * the file of every video it is left: the cut spares the sound footage it never hears. HyperFrames\n * refuses an unmuted video without sound, a scene's render too, so every unmuted one is fetched.\n *\n * `pages` holds each HTML file's text, by its path; the result, those it changed. Of what `media`\n * lends, an `artifact:` video is left out the same way.\n */\nexport function videoSoundProject(input: {\n readonly files: readonly ArtifactFile[]\n readonly pages: ReadonlyMap<string, string>\n readonly media: readonly VideoMediaFile[]\n}): {\n readonly files: ArtifactFile[]\n readonly pages: ReadonlyMap<string, string>\n readonly media: VideoMediaFile[]\n} {\n const paths = new Set(input.files.map((entry) => entry.path))\n const exists = (path: string) => paths.has(path)\n\n // What an element that may be heard plays: a path of the version, or an address.\n const heard = new Set<string>()\n const pages = new Map<string, string>()\n for (const [path, html] of input.pages) {\n const media = videoPageMedia(path, html)\n\n for (const { value, muted } of media) {\n if (muted) continue\n\n const written = value.trim()\n const played = isArtifactAddress(written) ? written : videoFilePath(path, written, exists)\n if (played) heard.add(played)\n }\n\n const cuts = media.filter((each) => each.muted).map((each) => ({ ...each.at, with: \"\" }))\n if (cuts.length > 0) pages.set(path, cut(html, cuts))\n }\n\n const isVideo = (file: { readonly mediaType?: string }) =>\n (file.mediaType ?? \"\").startsWith(\"video/\")\n\n return {\n files: input.files.filter(({ path, file }) => !isVideo(file) || heard.has(path)),\n pages,\n media: input.media.filter(({ address, file }) => !file || !isVideo(file) || heard.has(address)),\n }\n}\n\n/** The text with each span replaced by its `with`; the spans do not overlap. */\nfunction cut(\n text: string,\n spans: readonly (VideoSourceSpan & { readonly with: string })[]\n): string {\n let out = \"\"\n let kept = 0\n for (const span of [...spans].sort((a, b) => a.start - b.start)) {\n out += text.slice(kept, span.start) + span.with\n kept = span.end\n }\n return out + text.slice(kept)\n}\n\nfunction sha256(text: string): string {\n return createHash(\"sha256\").update(text).digest(\"hex\")\n}\n",
|
|
29
|
+
"import type { ArtifactFile } from \"../../../storage/artifacts/types\"\nimport { isArtifactAddress, parseArtifactAddress } from \"../../address\"\nimport type { FRAME_CDN_ALLOWLIST } from \"../../frames/assets\"\nimport { ARTIFACT_LIMITS } from \"../../limits\"\nimport type { VideoOutline } from \"../../outline\"\nimport {\n composeVideo,\n cssMoves,\n missingScene,\n parseVideoRoot,\n parseVideoScene,\n VIDEO_ENTRY,\n type VideoComposition,\n type VideoMediaReference,\n type VideoSceneFile,\n videoFilePath,\n} from \"../../video/composition\"\nimport { type ArtifactBlobStorage, invalidArtifact, readArtifactText } from \"../files\"\nimport type { FoundReference } from \"../references\"\nimport { sceneRenderKeys } from \"../video\"\nimport { refuseFrameAssetPaths } from \"./html\"\n\n/**\n * Reads a video: `index.html`, its root composition, then each scene's `<template>` file, and\n * resolves when each scene starts. Every file a composition plays must be one of the version's,\n * or a file of another artifact by its `artifact:` address, returned to resolve at the scene that\n * plays it. Each scene is named by its render key.\n */\nexport async function validateVideo(\n blobStorage: ArtifactBlobStorage,\n files: readonly ArtifactFile[]\n): Promise<{\n readonly entry: string\n readonly outline: VideoOutline\n readonly references: readonly FoundReference[]\n}> {\n const { outline, references } = await readVideoVersion(blobStorage, files)\n return { entry: VIDEO_ENTRY, outline, references }\n}\n\n/** A video's files, read as publishing reads them: what renders each of its scenes. */\nexport interface VideoVersionRead {\n readonly outline: VideoOutline\n readonly references: readonly FoundReference[]\n /** `index.html`'s text, which the composition's spans point into. */\n readonly index: string\n readonly composition: VideoComposition\n /** What the root plays itself. */\n readonly rootLoads: ReadonlySet<string>\n /** What each scene plays, by its id: its file, what it nests, and what they play. */\n readonly loads: ReadonlyMap<string, ReadonlySet<string>>\n /** Whether the root shows something that moves of its own, what it links read. */\n readonly rootTimeline: boolean\n}\n\n/**\n * Reads a video as {@link validateVideo} checks it, with what renders it: its composition and what\n * each scene plays. Throws `invalid_artifact` for a version publishing would refuse.\n */\nexport async function readVideoVersion(\n blobStorage: ArtifactBlobStorage,\n files: readonly ArtifactFile[]\n): Promise<VideoVersionRead> {\n const byPath = new Map(files.map((file) => [file.path, file]))\n const index = byPath.get(VIDEO_ENTRY)\n if (!index) {\n throw invalidArtifact(\n `A video needs '${VIDEO_ENTRY}', its root composition, with a <template> file for each scene and the media they play beside it.`\n )\n }\n refuseFrameAssetPaths(files, \"the video\")\n refuseTooManyRecordings(files)\n refuseLargePages(files)\n\n const read = (file: ArtifactFile) =>\n readArtifactText(blobStorage, file, ARTIFACT_LIMITS.maxSceneBytes)\n\n const indexText = await read(index)\n const root = parseVideoRoot(indexText)\n if (\"error\" in root) throw invalidArtifact(root.error)\n\n // One at a time, so the same version is always refused for the same scene.\n const scenes = new Map<string, VideoSceneFile>()\n for (const { id, src } of root.root.scenes) {\n const file = byPath.get(src)\n if (!file) throw invalidArtifact(missingScene(id, src))\n\n const scene = parseVideoScene(await read(file), src)\n if (\"error\" in scene) throw invalidArtifact(scene.error)\n scenes.set(src, scene.scene)\n }\n\n const composed = composeVideo(root.root, scenes)\n if (\"error\" in composed) throw invalidArtifact(composed.error)\n const { composition } = composed\n\n const references: FoundReference[] = []\n const exists = (path: string) => byPath.has(path)\n\n // A nested composition's file is read as a scene file is: a <template> holding one. Each is read\n // once, however many scenes nest it.\n const nestedFiles = new Map<string, VideoSceneFile>()\n const parsed = async (file: ArtifactFile): Promise<VideoSceneFile> => {\n const known = scenes.get(file.path) ?? nestedFiles.get(file.path)\n if (known) return known\n\n const scene = parseVideoScene(await read(file), file.path)\n if (\"error\" in scene) throw invalidArtifact(scene.error)\n nestedFiles.set(file.path, scene.scene)\n return scene.scene\n }\n\n // What each composition file loads: itself, what it plays, and what it nests, all the way down.\n // Each is walked once per scene, `loaded` being that scene's: a composition two scenes nest\n // plays its `artifact:` addresses at both.\n const load = async (\n path: string,\n file: VideoSceneFile,\n at: string,\n nesting: readonly string[],\n loaded: Map<string, ReadonlySet<string>>\n ): Promise<ReadonlySet<string>> => {\n const known = loaded.get(path)\n if (known) return known\n\n const paths = new Set([\n path,\n ...played({ file: path, at, media: file.media, exists, references }),\n ])\n for (const { element, value } of file.compositions) {\n const nested = videoFilePath(VIDEO_ENTRY, value, exists)\n const nestedEntry = nested === undefined ? undefined : byPath.get(nested)\n const tag = `<${element} data-composition-src=\"${value.trim()}\">`\n if (nested === undefined || !nestedEntry) {\n throw invalidArtifact(\n `${path}: ${tag} nests a composition that is not one of the video's files: name it by its path from the video's root, such as compositions/lower-third.html.`\n )\n }\n if (nested === path || nesting.includes(nested)) {\n throw invalidArtifact(\n `${path}: ${tag} nests '${nested}', which nests ${path} in turn: a composition never holds itself.`\n )\n }\n\n const nestedFile = await parsed(nestedEntry)\n for (const each of await load(nested, nestedFile, at, [...nesting, path], loaded)) {\n paths.add(each)\n }\n }\n\n loaded.set(path, paths)\n return paths\n }\n const rootLoads = played({\n file: VIDEO_ENTRY,\n at: \"\",\n media: composition.media,\n exists,\n references,\n })\n const loads = new Map<string, ReadonlySet<string>>()\n for (const scene of composition.scenes) {\n const file = scenes.get(scene.src)\n if (file) loads.set(scene.id, await load(scene.src, file, scene.id, [], new Map()))\n }\n\n const rootTimeline =\n composition.rootTimeline || (await linksMove(composition, byPath, read, exists))\n const keys = sceneRenderKeys({\n index: indexText,\n composition,\n files,\n rootLoads,\n rootTimeline,\n loads,\n })\n return {\n index: indexText,\n composition,\n rootLoads,\n loads,\n rootTimeline,\n outline: {\n kind: \"video\",\n width: composition.width,\n height: composition.height,\n fps: composition.fps,\n durationMs: composition.durationMs,\n ...(composition.posterMs === undefined ? {} : { posterMs: composition.posterMs }),\n scenes: composition.scenes.map((scene) => ({\n id: scene.id,\n ...(scene.label ? { label: scene.label } : {}),\n startMs: scene.startMs,\n durationMs: scene.durationMs,\n renderKey: keys.get(scene.id) ?? \"\",\n })),\n },\n references,\n }\n}\n\n/** The stylesheet hosts of `FRAME_CDN_ALLOWLIST` that serve fonts, whose CSS never moves. */\nconst FONT_HOSTS: readonly (typeof FRAME_CDN_ALLOWLIST)[number][] = [\n \"https://fonts.googleapis.com\",\n \"https://fonts.gstatic.com\",\n]\n\n/**\n * Whether what `index.html` links makes its root move as time passes: a stylesheet of the version\n * whose CSS animates, one from elsewhere than a font host, which cannot be read, or a script of the\n * version that registers a timeline. A library, a script that registers none, only loads. A file\n * too large to read counts.\n */\nasync function linksMove(\n composition: VideoComposition,\n byPath: ReadonlyMap<string, ArtifactFile>,\n read: (file: ArtifactFile) => Promise<string>,\n exists: (path: string) => boolean\n): Promise<boolean> {\n const fileOf = (value: string) => {\n const path = videoFilePath(VIDEO_ENTRY, value, exists)\n return path === undefined ? undefined : byPath.get(path)\n }\n const readable = (file: ArtifactFile) => file.file.sizeBytes <= ARTIFACT_LIMITS.maxSceneBytes\n\n for (const { value } of composition.links.stylesheets) {\n const file = fileOf(value)\n if (!file) {\n if (!FONT_HOSTS.some((origin) => value.trim().startsWith(`${origin}/`))) return true\n continue\n }\n if (!readable(file) || cssMoves(await read(file))) return true\n }\n\n for (const { value } of composition.links.scripts) {\n const file = fileOf(value)\n if (file && (!readable(file) || /__timelines/.test(await read(file)))) return true\n }\n return false\n}\n\n/**\n * The version's files a composition's HTML plays and shows. An `artifact:` address is found for\n * resolving, at the scene that plays it; `data:` and `blob:` URLs hold their own bytes. Anything\n * else must be one of the version's files: a frame plays nothing from elsewhere, and an export\n * renders from the version alone.\n */\nfunction played(input: {\n readonly file: string\n readonly at: string\n readonly media: readonly VideoMediaReference[]\n readonly exists: (path: string) => boolean\n readonly references: FoundReference[]\n}): ReadonlySet<string> {\n const { file, at, media, exists, references } = input\n const paths = new Set<string>()\n\n for (const { element, attribute, value } of media) {\n const written = value.trim()\n const tag = `<${element} ${attribute}=\"${written}\">`\n\n if (isArtifactAddress(written)) {\n if (!parseArtifactAddress(written)?.path) {\n throw invalidArtifact(\n `${file}: ${tag} names no file of that artifact: name one, such as artifact:art_k3m9q2x7tp/media/intro.mp4.`\n )\n }\n references.push({ address: written, as: \"embed\", at })\n continue\n }\n if (/^(data|blob):/i.test(written)) continue\n\n const path = videoFilePath(file, written, exists)\n if (path === undefined) {\n throw invalidArtifact(\n `${file}: ${tag} plays a file from outside the video, which neither the player nor an export can load: add it to the video, such as media/<name>, and name it by that path.`\n )\n }\n if (!exists(path)) {\n throw invalidArtifact(\n `${file}: ${tag} plays '${path}', which is not one of the video's files.`\n )\n }\n paths.add(path)\n }\n\n return paths\n}\n\n/** Every HTML file is read whole, the ones no scene names too: by the frame, and by an export. */\nfunction refuseLargePages(files: readonly ArtifactFile[]): void {\n const limit = ARTIFACT_LIMITS.maxSceneBytes\n const large = files.find(({ path, file }) => /\\.html?$/i.test(path) && file.sizeBytes > limit)\n if (large) {\n throw invalidArtifact(\n `'${large.path}' is ${large.file.sizeBytes} bytes: each of a video's HTML files holds at most ${limit}.`\n )\n }\n}\n\n/** Each recording a version holds is probed and proxied for the player: a video has a few dozen. */\nfunction refuseTooManyRecordings(files: readonly ArtifactFile[]): void {\n const recordings = files.filter(({ file }) => /^(video|audio)\\//.test(file.mediaType ?? \"\"))\n if (recordings.length > ARTIFACT_LIMITS.maxVideoMediaFiles) {\n throw invalidArtifact(\n `A video holds at most ${ARTIFACT_LIMITS.maxVideoMediaFiles} video and sound files; this one has ${recordings.length}. Leave out the ones it no longer plays.`\n )\n }\n}\n",
|
|
30
|
+
"import type { Principal } from \"../../auth\"\nimport type { FileRef } from \"../../blob-storage\"\nimport { ArtifactStorageError } from \"../../storage/artifacts/errors\"\nimport type {\n ArtifactFile,\n ArtifactOrigin,\n ArtifactRecord,\n ArtifactStorage,\n ArtifactVersionInput,\n ArtifactVersionRecord,\n PublishedArtifactVersion,\n} from \"../../storage/artifacts/types\"\nimport { type ArtifactAccess, assertUpdatable } from \"../access\"\nimport { ArtifactRequestError } from \"../errors\"\nimport { createArtifactId } from \"../ids\"\nimport type { ArtifactKind } from \"../kinds\"\nimport { ARTIFACT_LIMITS } from \"../limits\"\nimport type { ArtifactOutline } from \"../outline\"\nimport type { CheckedArtifactQuery } from \"../queries\"\nimport {\n ARTIFACT_THEME_FILE,\n type ArtifactTheme,\n artifactThemeModes,\n parseArtifactTheme,\n} from \"../theme\"\nimport type { ArtifactWarning } from \"../warnings\"\nimport { checkDocumentFields } from \"./fields\"\nimport {\n type ArtifactBlobStorage,\n checkArtifactFiles,\n invalidArtifact,\n readArtifactText,\n} from \"./files\"\nimport { canvasPreviewOutline, withBoardRenderKeys } from \"./previews\"\nimport { type ArtifactQueryChecker, checkArtifactQueries } from \"./queries\"\nimport {\n brokenDependents,\n type FoundReference,\n ownArtifacts,\n resolveReferences,\n} from \"./references\"\nimport { validateCanvas } from \"./validate/canvas\"\nimport { validateDocument } from \"./validate/document\"\nimport { validateFileArtifact } from \"./validate/file\"\nimport { validatePage } from \"./validate/page\"\nimport { validateSheet } from \"./validate/sheet\"\nimport { validateSlides } from \"./validate/slides\"\nimport { validateVideo } from \"./validate/video\"\n\nexport interface PublishArtifactContext {\n readonly projectId: string\n readonly storage: ArtifactStorage\n readonly blobStorage: ArtifactBlobStorage\n}\n\nexport interface PublishArtifactInput {\n /**\n * Writes this artifact's latest version: its open version, or the next one when it is frozen.\n * Without it, a new artifact is created.\n */\n readonly artifactId?: string\n readonly kind: ArtifactKind\n readonly title: string\n readonly files: readonly ArtifactFile[]\n /** Publishes the version, and owns the artifact when this creates it unless `owner` says. */\n readonly author: Principal\n /** Owns the artifact when this creates it: a conversation's owner, for an Agent turn in it. */\n readonly owner?: Principal\n /**\n * Whether an address in the version may name this artifact: one the author can read. Defaults to\n * the author's own artifacts.\n */\n readonly readable?: (artifact: ArtifactRecord) => Promise<boolean>\n /**\n * Checks each of the version's queries as the author, so none reads what they cannot. Without\n * it, a version that holds a query is refused.\n */\n readonly checkQuery?: ArtifactQueryChecker\n readonly origin?: ArtifactOrigin\n /** The revision this content was made from: publishing fails with `artifact_moved` past it. */\n readonly baseRevision?: number\n /**\n * The Agent turn that publishes: its first write to an artifact keeps a restore point, and a\n * retry of the turn undoes what it wrote.\n */\n readonly turnRunId?: string\n /** The content as the artifact's Yjs document, stored with it, for a kind edited live. */\n readonly document?: FileRef\n}\n\n/**\n * What the author may do with the artifact a version is published to, as the access rule's\n * `publishAccess` answers it from where the version is stored: a transaction's storage, for a\n * caller that stores in one. Storing refuses `none` with `not_shared` and `read` with `read_only`.\n */\nexport type PublishAccess = (artifact: ArtifactRecord) => Promise<ArtifactAccess>\n\nexport interface PublishedArtifact {\n readonly artifact: ArtifactRecord\n readonly version: ArtifactVersionRecord\n readonly warnings: readonly ArtifactWarning[]\n /** The write was merged with what others wrote since its base revision, as a canvas's is. */\n readonly merged?: true\n}\n\nconst CREATE_ATTEMPTS = 3\n\n/** A reader sees a board's picture until they open it, and the picture was taken as its author. */\nconst LIVE_BOARD_PREVIEWS: ArtifactWarning = {\n code: \"canvas_previews_show_author_data\",\n message:\n \"Its boards read live data, so each board's preview shows the data its author can see, to everyone who can open the canvas, until they open the board.\",\n}\n\n/** A version checked against its kind and with its addresses resolved, ready to store. */\nexport interface PreparedArtifactVersion {\n readonly artifactId?: string\n readonly baseRevision?: number\n readonly turnRunId?: string\n readonly document?: FileRef\n readonly kind: ArtifactKind\n /** Owns the artifact when this version creates it. */\n readonly owner: Principal\n readonly readable: (artifact: ArtifactRecord) => Promise<boolean>\n readonly version: ArtifactVersionInput\n /** What its kind's check found worth fixing in a version it accepts. */\n readonly warnings: readonly ArtifactWarning[]\n}\n\n/**\n * Validates a version against its kind and stores it. Who may publish is the caller's decision:\n * this checks only what the version holds.\n */\nexport async function publishArtifact(\n context: PublishArtifactContext,\n input: PublishArtifactInput,\n access: PublishAccess\n): Promise<PublishedArtifact> {\n const prepared = await prepareArtifactVersion(context, input)\n const stored = await storeArtifactVersion(context, prepared, access)\n return { ...stored, warnings: await artifactVersionWarnings(context, prepared, stored) }\n}\n\n/**\n * Everything publishing checks before it stores: the title, the files, the theme, every query, run\n * once as the author, the kind's own format, and every address, resolved against what the author\n * can read. It reads the files back and parses them, so a caller that stores inside a\n * transaction prepares outside it.\n */\nexport async function prepareArtifactVersion(\n context: PublishArtifactContext,\n input: PublishArtifactInput\n): Promise<PreparedArtifactVersion> {\n const title = checkTitle(input.title)\n await checkArtifactFiles(context.blobStorage, input.kind, input.files)\n const theme =\n input.kind === \"file\" ? undefined : await readTheme(context.blobStorage, input.files)\n\n // The queries first: a live sheet's columns are checked against what its query returns. A\n // document is read first instead: the type it names is where its queries may start, and its\n // fields are checked against what the queries return.\n const document =\n input.kind === \"document\" ? await validateDocument(context.blobStorage, input.files) : null\n const queries = await checkArtifactQueries(\n context.blobStorage,\n input.kind,\n input.files,\n input.checkQuery,\n document?.outline.holder ? { holder: document.outline.holder.objectTypeId } : {}\n )\n const fields = document?.marks\n ? await checkDocumentFields({\n marks: document.marks,\n ...(document.outline.holder ? { holder: document.outline.holder.objectTypeId } : {}),\n queries,\n ...(input.checkQuery ? { checker: input.checkQuery } : {}),\n })\n : null\n const validated = document\n ? {\n ...document,\n outline: {\n ...document.outline,\n ...(fields?.holder ? { holder: fields.holder } : {}),\n },\n warnings: fields?.warnings ?? [],\n }\n : await validateKind(context.blobStorage, input.kind, input.files, queries)\n\n const readable = input.readable ?? ownArtifacts(input.author)\n const references = await resolveReferences(\n referenceContext(context, { readable, artifactId: input.artifactId }),\n validated.references ?? []\n )\n\n return {\n ...(input.artifactId ? { artifactId: input.artifactId } : {}),\n ...(input.baseRevision === undefined ? {} : { baseRevision: input.baseRevision }),\n ...(input.turnRunId === undefined ? {} : { turnRunId: input.turnRunId }),\n ...(input.document ? { document: input.document } : {}),\n kind: input.kind,\n owner: input.owner ?? input.author,\n readable,\n warnings: [\n ...(validated.warnings ?? []),\n ...(input.kind === \"canvas\" && queries.size > 0 ? [LIVE_BOARD_PREVIEWS] : []),\n ],\n version: {\n title,\n entry: validated.entry,\n files: input.files.map(({ path, file }) => ({ path, file: { ...file } })),\n // A canvas's boards are shown as pictures until they are read, in the modes a reader sees;\n // each is named by what it shows once the version has its artifact.\n outline:\n validated.outline.kind === \"canvas\"\n ? canvasPreviewOutline(validated.outline, artifactThemeModes(theme))\n : validated.outline,\n references,\n author: input.author,\n ...(input.origin ? { origin: input.origin } : {}),\n updatedAt: new Date(),\n },\n }\n}\n\n/**\n * Stores a prepared version: as its artifact's latest version, or the first of a new artifact. A\n * write to an artifact is refused unless `access` says its author may update it: a caller that\n * stores inside a transaction answers it from there, so the check and the write see the same\n * artifact.\n */\nexport async function storeArtifactVersion(\n context: PublishArtifactContext,\n prepared: PreparedArtifactVersion,\n access: PublishAccess\n): Promise<PublishedArtifactVersion> {\n const { artifactId } = prepared\n if (!artifactId) return createArtifact(context, prepared)\n\n const artifact = await context.storage.get({ projectId: context.projectId, id: artifactId })\n if (!artifact) throw notFound(artifactId)\n assertUpdatable(artifactId, await access(artifact))\n\n return publishVersion(context, artifactId, prepared)\n}\n\n/**\n * What is worth fixing in a stored version: what its kind's check found, then what it breaks in\n * other artifacts that show it. A new artifact breaks nothing: no other artifact could name it\n * yet. The version is stored by now, so a failed check only loses those warnings.\n */\nexport async function artifactVersionWarnings(\n context: PublishArtifactContext,\n prepared: PreparedArtifactVersion,\n stored: PublishedArtifactVersion\n): Promise<readonly ArtifactWarning[]> {\n if (!prepared.artifactId) return prepared.warnings\n try {\n return [\n ...prepared.warnings,\n ...(await brokenDependents(\n referenceContext(context, prepared),\n stored.artifact,\n stored.version\n )),\n ]\n } catch (error) {\n console.warn(\n `[Sixb] Could not check which artifacts version ${stored.version.version} of '${stored.artifact.id}' breaks:`,\n error\n )\n return prepared.warnings\n }\n}\n\nfunction referenceContext(\n context: PublishArtifactContext,\n input: {\n readonly readable: (artifact: ArtifactRecord) => Promise<boolean>\n readonly artifactId?: string\n }\n) {\n return {\n projectId: context.projectId,\n storage: context.storage,\n readable: input.readable,\n ...(input.artifactId ? { artifactId: input.artifactId } : {}),\n }\n}\n\nasync function validateKind(\n blobStorage: ArtifactBlobStorage,\n kind: ArtifactKind,\n files: readonly ArtifactFile[],\n queries: ReadonlyMap<string, CheckedArtifactQuery>\n): Promise<{\n readonly entry: string\n readonly outline: ArtifactOutline\n readonly references?: readonly FoundReference[]\n readonly warnings?: readonly ArtifactWarning[]\n}> {\n switch (kind) {\n case \"document\":\n return validateDocument(blobStorage, files)\n case \"file\":\n return validateFileArtifact(files)\n case \"sheet\":\n return validateSheet(blobStorage, files, queries)\n case \"slides\":\n return validateSlides(blobStorage, files)\n case \"page\":\n return validatePage(blobStorage, files)\n case \"canvas\":\n return validateCanvas(blobStorage, files)\n case \"video\":\n return validateVideo(blobStorage, files)\n default:\n // A caller past the API's schema, such as a script on the SDK, can name any kind.\n throw invalidArtifact(`'${kind satisfies never}' is not a kind of artifact.`)\n }\n}\n\n/** The version's `theme.json`, refused when it is not one; none without the file. */\nasync function readTheme(\n blobStorage: ArtifactBlobStorage,\n files: readonly ArtifactFile[]\n): Promise<ArtifactTheme | undefined> {\n const themeFile = files.find((file) => file.path === ARTIFACT_THEME_FILE)\n if (!themeFile) return undefined\n const parsed = parseArtifactTheme(\n await readArtifactText(blobStorage, themeFile, ARTIFACT_LIMITS.maxThemeBytes)\n )\n if (\"error\" in parsed) throw invalidArtifact(parsed.error)\n return parsed.theme\n}\n\nfunction checkTitle(value: string): string {\n const title = typeof value === \"string\" ? value.trim() : \"\"\n if (title.length === 0 || /[\\u0000-\\u001f\\u007f]/.test(title)) {\n throw invalidArtifact(\"An artifact needs a title of plain text.\")\n }\n if (title.length > ARTIFACT_LIMITS.maxTitleLength) {\n throw invalidArtifact(`A title may be at most ${ARTIFACT_LIMITS.maxTitleLength} characters.`)\n }\n return title\n}\n\nasync function publishVersion(\n context: PublishArtifactContext,\n artifactId: string,\n prepared: PreparedArtifactVersion\n): Promise<PublishedArtifactVersion> {\n try {\n return await context.storage.publish({\n projectId: context.projectId,\n artifactId,\n kind: prepared.kind,\n version: withBoardRenderKeys(prepared.version, artifactId),\n ...(prepared.baseRevision === undefined ? {} : { baseRevision: prepared.baseRevision }),\n ...(prepared.turnRunId === undefined ? {} : { turnRunId: prepared.turnRunId }),\n ...(prepared.document ? { document: prepared.document } : {}),\n })\n } catch (error) {\n throw artifactRequestError(error)\n }\n}\n\n/**\n * A storage refusal as the caller is told it: a missing artifact or restore point, a kind it does\n * not have, or a revision it moved past. Anything else is thrown as it is.\n */\nexport function artifactRequestError(error: unknown): unknown {\n if (!(error instanceof ArtifactStorageError)) return error\n\n switch (error.code) {\n case \"artifact_not_found\":\n case \"artifact_kind_mismatch\":\n case \"restore_point_not_found\":\n return new ArtifactRequestError(error.code, error.message)\n case \"artifact_moved\":\n return new ArtifactRequestError(\"artifact_moved\", error.message, error.latest)\n default:\n return error\n }\n}\n\nfunction notFound(artifactId: string): ArtifactRequestError {\n return new ArtifactRequestError(\n \"artifact_not_found\",\n `[Sixb] Artifact '${artifactId}' was not found.`\n )\n}\n\nasync function createArtifact(\n context: PublishArtifactContext,\n prepared: PreparedArtifactVersion\n): Promise<PublishedArtifactVersion> {\n for (let attempt = 1; ; attempt += 1) {\n const id = createArtifactId()\n try {\n return await context.storage.create({\n projectId: context.projectId,\n id,\n kind: prepared.kind,\n owner: prepared.owner,\n version: withBoardRenderKeys(prepared.version, id),\n ...(prepared.turnRunId === undefined ? {} : { turnRunId: prepared.turnRunId }),\n ...(prepared.document ? { document: prepared.document } : {}),\n })\n } catch (error) {\n const collided = error instanceof ArtifactStorageError && error.code === \"artifact_exists\"\n if (!collided || attempt === CREATE_ATTEMPTS) throw error\n }\n }\n}\n",
|
|
31
|
+
"import { createHash } from \"node:crypto\"\nimport type { FileRef } from \"../../blob-storage/types\"\nimport type { Queue, RenderQueueJob } from \"../../queues\"\nimport type {\n ArtifactStorage,\n ArtifactVersionRecord,\n ArtifactVideoRenderLack,\n ArtifactVideoRenderRecord,\n} from \"../../storage/artifacts/types\"\nimport { parseArtifactAddress } from \"../address\"\nimport { HYPERFRAMES_VERSION } from \"../frames/hyperframes\"\nimport type { VideoOutline } from \"../outline\"\nimport { scenesOnScreen, videoFrameCount, videoSegmentFrames } from \"./project\"\n\n// A video version exports to one MP4 made of segments kept apart from it, each under a key that\n// hashes what it is made of: each scene's frames, from its start until the next scene starts,\n// rendered alone, and the whole video's sound, mixed once. A version that changes one scene\n// renders that scene's segment again and reuses every other, and the MP4 joins them without\n// encoding them again. See README.md beside this file.\n\n/**\n * What renders a video: the agent image's HyperFrames, the release the app plays. Every key names\n * it, so a sandbox that runs another refuses to render, rather than keep what it rendered under a\n * key it does not match.\n */\nexport const VIDEO_ENGINE = `hyperframes@${HYPERFRAMES_VERSION}`\n\n/**\n * How every segment is encoded, so segments join without being encoded again: H.264 at one\n * quality, a keyframe on its first frame and every two seconds after, captured by two browsers at\n * once, which keeps a segment rendered again the same. Changing them renders every segment anew.\n * CRF 20 makes a 1080×1920 video about 11 Mb/s, what social networks take in; CRF 18 made it 19,\n * twice the file for no difference a viewer sees (SSIM 0.986 against 0.989).\n */\nexport const VIDEO_SEGMENT_SETTINGS = { crf: 20, keyframeSeconds: 2, workers: 2 } as const\n\n/**\n * How the render worker assembles an export: each attempt within `timeoutMs`, which holds fetching\n * its segments, joining them, and keeping the MP4, up to `attempts`, `backoffMs` apart. While\n * segments render, it looks again every `recheckMs`, and gives up `waitMs` after it was asked.\n */\nexport const VIDEO_EXPORT_JOB = {\n timeoutMs: 20 * 60_000,\n attempts: 3,\n backoffMs: 15_000,\n recheckMs: 5_000,\n waitMs: 12 * 60 * 60_000,\n} as const\n\n/** How many times the render worker tries a segment, and how long it waits between. */\nexport const VIDEO_SEGMENT_JOB = { attempts: 2, backoffMs: 30_000 } as const\n\n/**\n * How long one segment may take. Rendering a heavy 1080p scene takes up to twelve times its length\n * in a small sandbox (2 vCPU): its frames get twenty seconds each second, in proportion to their\n * pixels, and five minutes to start. The sound is mixed in a few seconds of each minute.\n */\nexport function videoSegmentTimeoutMs(\n segment: VideoSegment,\n video: Pick<VideoOutline, \"fps\" | \"width\" | \"height\" | \"durationMs\">\n): number {\n if (segment.kind === \"sound\") return 5 * 60_000 + video.durationMs\n const seconds = (segment.endFrame - segment.startFrame) / video.fps\n const pixels = Math.max(1, (video.width * video.height) / (1920 * 1080))\n return 5 * 60_000 + Math.ceil(seconds * pixels * 20_000)\n}\n\n/** What an `artifact:` address a video plays resolved to, as whoever asked reads it: none when not. */\nexport interface VideoMediaFile {\n readonly address: string\n readonly file?: FileRef\n}\n\n/**\n * A segment of a video's export: the frames of a scene, from the frame it starts on up to the one\n * the next scene starts on, rendered alone and silent; or the whole video's sound.\n */\nexport type VideoSegment =\n | {\n readonly kind: \"scene\"\n readonly scene: string\n /** The scene's name, as the player shows it, which is in no key. */\n readonly label?: string\n readonly startFrame: number\n readonly endFrame: number\n }\n | { readonly kind: \"sound\" }\n\n/** What a video's export is made of: its segments, in the order they play, the sound last. */\nexport interface VideoExportPlan {\n readonly key: string\n /** How many frames the MP4 has. */\n readonly frames: number\n readonly segments: readonly (VideoSegment & { readonly key: string })[]\n}\n\n/** A video version, as an export reads it. */\nexport type VideoExportSource = Pick<ArtifactVersionRecord, \"files\" | \"references\"> & {\n readonly outline: VideoOutline\n readonly media: readonly VideoMediaFile[]\n}\n\nconst EXPORT_FORMAT = \"sixb-video-export/1\"\nconst SEGMENT_FORMAT = \"sixb-video-segment/1\"\nconst SOUND_FORMAT = \"sixb-video-sound/1\"\n\n/**\n * What a video's export is made of, from its outline alone, so whoever asks finds what is kept\n * without reading a file. The first segment starts at frame 0, each next one on the frame its\n * scene starts on; a scene that starts with another renders within the other's segment.\n *\n * A segment's key holds its scene's render key, where it starts and how many frames it has from\n * there, the engine and the settings, and what the `artifact:` addresses played by the root and\n * the scenes on screen during it resolve to. The sound's holds every file and what every address resolves to. The\n * export's holds its segments' keys.\n */\nexport function videoExportPlan(source: VideoExportSource): VideoExportPlan {\n const { outline } = source\n const { fps } = outline\n const frames = videoFrameCount(outline.durationMs, fps)\n\n const cuts = videoSegmentFrames(outline)\n const scenes = outline.scenes.flatMap((scene) => {\n // Scenes that start on one frame render in the segment of the first.\n const cut = cuts.get(scene.id)\n if (cut?.scene !== scene.id) return []\n const { startFrame, endFrame } = cut\n\n // The scene's render key holds the scenes on screen during its segment, and so does this.\n const beside = scenesOnScreen(outline, cut)\n const key = hash([\n SEGMENT_FORMAT,\n VIDEO_ENGINE,\n VIDEO_SEGMENT_SETTINGS,\n scene.renderKey,\n Math.round(((startFrame * 1000) / fps - scene.startMs) * 1000) / 1000,\n endFrame - startFrame,\n resolved(source, [\"\", ...beside.map((each) => each.id)]),\n ])\n const label = scene.label ? { label: scene.label } : {}\n return [{ kind: \"scene\" as const, scene: scene.id, ...label, startFrame, endFrame, key }]\n })\n\n const sound = {\n kind: \"sound\" as const,\n key: hash([\n SOUND_FORMAT,\n VIDEO_ENGINE,\n fps,\n frames,\n sorted(source.files.map((entry) => [entry.path, entry.file.digest] as const)),\n resolved(source),\n ]),\n }\n\n const segments = [...scenes, sound]\n return { key: hash([EXPORT_FORMAT, segments.map((each) => each.key)]), frames, segments }\n}\n\n/** Where the render worker assembles an export: one job per export, by its key. */\nexport function videoExportJobId(key: string): string {\n return `art_vexp_${key}`\n}\n\n/**\n * Where a retry asks anew for an export's segments: apart from the export's own job, which a\n * segment that finishes takes the place of with the payload it was asked with.\n */\nfunction videoExportRetryJobId(key: string): string {\n return `art_vexp_retry_${key}`\n}\n\n/** Where it renders a segment: one job per segment, by its key. */\nexport function videoSegmentJobId(key: string): string {\n return `art_vseg_${key}`\n}\n\n/** How far an export that is not kept yet has come. */\nexport interface VideoExportProgress {\n /** Its segments rendered, of all of them. */\n readonly ready: number\n readonly total: number\n /** Every segment is rendered, and the MP4 is being joined from them. */\n readonly assembling: boolean\n}\n\n/**\n * Where an export stands, from what is kept under its keys: the MP4, why it could not be made, or\n * how far it has come. A segment that failed fails the export: why is the segment's.\n */\nexport function videoExportStatus(\n plan: VideoExportPlan,\n kept: readonly ArtifactVideoRenderRecord[]\n):\n | { readonly status: \"ready\"; readonly file: FileRef }\n | {\n readonly status: \"failed\"\n readonly reason: string\n /** What the project lacks, when the video is not why. */\n readonly lacks?: ArtifactVideoRenderLack\n }\n | { readonly status: \"rendering\"; readonly progress: VideoExportProgress } {\n const byKey = new Map(kept.map((record) => [record.key, record]))\n\n const done = byKey.get(plan.key)\n if (done && \"failure\" in done) return failed(done)\n if (done) return { status: \"ready\", file: done.file }\n\n for (const segment of plan.segments) {\n const record = byKey.get(segment.key)\n if (record && \"failure\" in record) return failed(record)\n }\n return { status: \"rendering\", progress: videoExportProgress(plan, kept) }\n}\n\n/** Why a render kept failed, and what the project lacks when it says. */\nfunction failed(record: Extract<ArtifactVideoRenderRecord, { failure: string }>) {\n const lacks = record.lacks ? { lacks: record.lacks } : {}\n return { status: \"failed\" as const, reason: record.failure, ...lacks }\n}\n\n/** How many of an export's segments are rendered: those that failed are not. */\nexport function videoExportProgress(\n plan: VideoExportPlan,\n kept: readonly ArtifactVideoRenderRecord[]\n): VideoExportProgress {\n const rendered = new Set(kept.flatMap((record) => (\"failure\" in record ? [] : [record.key])))\n const ready = plan.segments.filter((segment) => rendered.has(segment.key)).length\n const total = plan.segments.length\n return { ready, total, assembling: ready === total }\n}\n\n/** Every key an export reads: its own, then its segments'. */\nexport function videoExportKeys(plan: VideoExportPlan): string[] {\n return [plan.key, ...plan.segments.map((segment) => segment.key)]\n}\n\n/**\n * Asks the render worker to assemble a video version's export, carrying what the version holds\n * now, and keeps that it was asked for, which reading it without asking then says. Asking again\n * while it is asked for asks nothing more; `retry` forgets why the export or its\n * segments could not be made, and asks again for each, in a job of its own: one in the export's\n * place could be taken by a segment that finishes meanwhile, which asks for nothing.\n */\nexport async function requestVideoExport(\n context: {\n readonly storage: Pick<ArtifactStorage, \"clearVideoRenderFailures\" | \"putVideoExportAsk\">\n readonly queue: Pick<Queue<RenderQueueJob>, \"enqueue\">\n },\n version: Pick<ArtifactVersionRecord, \"projectId\" | \"artifactId\" | \"version\">,\n source: VideoExportSource,\n options: { readonly plan: VideoExportPlan; readonly retry?: boolean }\n): Promise<void> {\n const { plan } = options\n if (options.retry) {\n await context.storage.clearVideoRenderFailures({\n projectId: version.projectId,\n keys: videoExportKeys(plan),\n })\n }\n\n await context.queue.enqueue({\n projectId: version.projectId,\n jobs: [\n {\n // One job per export: one asked for answers asking again. A retry, in its own, replaces\n // the retry before it.\n ...(options.retry\n ? { id: videoExportRetryJobId(plan.key), replace: true }\n : { id: videoExportJobId(plan.key) }),\n type: \"artifact.video.export.requested\",\n payload: {\n artifactId: version.artifactId,\n version: version.version,\n key: plan.key,\n outline: source.outline,\n files: source.files,\n references: source.references,\n media: source.media,\n askedAt: new Date().toISOString(),\n ...(options.retry ? { retry: true } : {}),\n },\n },\n ],\n })\n\n // Kept once its job is: an ask that never reached the queue leaves the export idle, to ask\n // again. One whose job is lost later is asked again by whoever watches it render.\n await context.storage.putVideoExportAsk({\n projectId: version.projectId,\n key: plan.key,\n askedAt: new Date(),\n })\n}\n\n/**\n * What each `artifact:` file a version plays resolves to, as `read` reads it: the version its\n * address pins, or the latest. One `read` cannot find, or that holds no such file, resolves to\n * none.\n */\nexport async function resolveVideoMedia(\n version: Pick<ArtifactVersionRecord, \"references\">,\n read: (\n artifactId: string,\n version: number | \"latest\"\n ) => Promise<Pick<ArtifactVersionRecord, \"files\"> | null>\n): Promise<VideoMediaFile[]> {\n const addresses = [\n ...new Set(\n version.references.filter((each) => each.as === \"embed\").map((each) => each.address)\n ),\n ]\n\n const media: VideoMediaFile[] = []\n for (const address of addresses) {\n const parsed = parseArtifactAddress(address)\n if (!parsed?.path) continue\n\n const target = await read(parsed.artifactId, parsed.version ?? \"latest\").catch(() => null)\n const file = target?.files.find((each) => each.path === parsed.path)?.file\n media.push(file ? { address, file } : { address })\n }\n return media\n}\n\n/**\n * The files of `source` the addresses played at `at` resolve to, `\"\"` naming the root, as\n * `[address, digest]` pairs; all of them without `at`.\n */\nfunction resolved(\n source: Pick<VideoExportSource, \"references\" | \"media\">,\n at?: readonly string[]\n): (readonly [string, string | null])[] {\n const played = new Set(\n source.references\n .filter((reference) => at === undefined || at.includes(reference.at))\n .map((reference) => reference.address)\n )\n return sorted(\n source.media\n .filter((each) => played.has(each.address))\n .map((each) => [each.address, each.file?.digest ?? null] as const)\n )\n}\n\nfunction sorted<T extends readonly [string, unknown]>(pairs: readonly T[]): T[] {\n return [...pairs].sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0))\n}\n\nfunction hash(value: unknown): string {\n return createHash(\"sha256\").update(JSON.stringify(value)).digest(\"hex\")\n}\n",
|
|
32
|
+
"import { createHash } from \"node:crypto\"\nimport type { Queue, RenderQueueJob } from \"../../queues\"\nimport type { ArtifactStorage, ArtifactVersionRecord } from \"../../storage/artifacts/types\"\nimport type { VideoOutline } from \"../outline\"\nimport { resolveVideoMedia, VIDEO_ENGINE } from \"./export\"\nimport { videoSegmentFrames, videoSegmentMiddleMs } from \"./project\"\n\n// Each scene of a video gets a still: a picture of the middle of its segment, which the player\n// shows for its chapter. It is kept under the scene's render key, so a version that keeps a scene\n// as it was keeps its still. The video's poster is the still at the instant its root's\n// `data-poster` names, or the first scene's: the instant the player opens on, `videoPosterMs`.\n// Like a canvas's previews, stills are asked for when a version is published, once the video\n// rests.\n\n/**\n * How the render worker snapshots a version's stills: each attempt within `timeoutMs`, up to\n * `attempts`, `backoffMs` apart, `settleMs` after the last write that asked.\n */\nexport const VIDEO_STILLS_JOB = {\n timeoutMs: 10 * 60_000,\n attempts: 3,\n backoffMs: 30_000,\n settleMs: 15_000,\n} as const\n\n/** A still's width at most, in pixels: a card's poster, sharp on a screen of twice its density. */\nexport const VIDEO_STILL_WIDTH = 1280\n\nconst STILL_FORMAT = \"sixb-video-still/1\"\nconst POSTER_FORMAT = \"sixb-video-poster/1\"\n\n/**\n * A picture of a video at one instant, kept under its key: the middle of a scene's segment, or the\n * instant its root's `data-poster` names. `scene` is the scene whose segment holds the instant,\n * which every scene on screen then overlaps, so the project that snapshots it keeps those.\n */\nexport interface VideoStill {\n readonly key: string\n readonly atMs: number\n readonly scene: string\n}\n\n/**\n * Each scene's still: the middle of its segment, what its chapter plays until the next scene\n * starts, kept under what the scene's segment shows and where in it the instant falls. What an\n * `artifact:` address it plays resolves to is not in its key: a still shows it as the version's\n * publisher read it, and a later change to that artifact keeps the still until the scene changes.\n */\nexport function videoSceneStills(outline: VideoOutline): VideoStill[] {\n const segments = videoSegmentFrames(outline)\n return outline.scenes.flatMap((scene) => {\n const segment = segments.get(scene.id)\n if (!segment) return []\n\n const atMs = videoSegmentMiddleMs(segment, outline.fps)\n const key = hash([STILL_FORMAT, VIDEO_ENGINE, scene.renderKey, atMs - scene.startMs])\n return [{ key, atMs, scene: scene.id }]\n })\n}\n\n/**\n * A video's stills: each scene's, then, when its root names one, its poster's instant, kept under\n * what the scene that holds that instant shows and where in it the instant falls.\n */\nexport function videoStills(outline: VideoOutline): VideoStill[] {\n const scenes = videoSceneStills(outline)\n const poster = posterStill(outline)\n return poster ? [...scenes, poster] : scenes\n}\n\n/**\n * The still a card shows, of the instant the player opens on, `videoPosterMs`: the one its root's\n * `data-poster` names, else the first scene's.\n */\nexport function videoPoster(outline: VideoOutline): VideoStill | undefined {\n const [first] = videoStills(outline)\n return posterStill(outline) ?? first\n}\n\nfunction posterStill(outline: VideoOutline): VideoStill | undefined {\n const { posterMs } = outline\n if (posterMs === undefined) return undefined\n\n // The last scene to start by then, or the first: the one whose segment holds the instant.\n const scene =\n [...outline.scenes].reverse().find((each) => each.startMs <= posterMs) ?? outline.scenes[0]\n if (!scene) return undefined\n return {\n key: hash([POSTER_FORMAT, VIDEO_ENGINE, scene.renderKey, posterMs - scene.startMs]),\n atMs: posterMs,\n scene: scene.id,\n }\n}\n\n/**\n * The stills of a video version not kept yet. One that could not be made is asked for again, once\n * the video is published again: a still is cheap, and a failure may have been the sandbox's.\n */\nexport async function missingVideoStills(\n storage: Pick<ArtifactStorage, \"listVideoRenders\">,\n version: Pick<ArtifactVersionRecord, \"projectId\" | \"outline\">\n): Promise<VideoStill[]> {\n if (version.outline.kind !== \"video\") return []\n\n const stills = videoStills(version.outline)\n const kept = await storage.listVideoRenders({\n projectId: version.projectId,\n keys: stills.map((still) => still.key),\n })\n const done = new Set(kept.flatMap((record) => (\"failure\" in record ? [] : [record.key])))\n return stills.filter((still) => !done.has(still.key))\n}\n\n/** One job per artifact, which each write that asks replaces. */\nexport function videoStillsJobId(artifactId: string): string {\n return `art_vstills_${artifactId}`\n}\n\n/**\n * Asks the render worker for the stills a stored video version misses, once the video rests,\n * `VIDEO_STILLS_JOB.settleMs` from now, in the artifact's one job: it takes the place of any asked\n * for an earlier write. The `artifact:` files it plays resolve as `read`, its publisher, reads\n * them. Nothing is asked when nothing is missing.\n *\n * The version exists by now and its stills are derived from it, so a request that fails is\n * reported, not thrown: the publish succeeded, and the player shows its scenes without pictures.\n */\nexport async function requestVideoStills(\n input: {\n readonly storage: Pick<ArtifactStorage, \"listVideoRenders\">\n readonly queue: Pick<Queue<RenderQueueJob>, \"enqueue\">\n readonly read: Parameters<typeof resolveVideoMedia>[1]\n },\n version: ArtifactVersionRecord\n): Promise<void> {\n if (version.outline.kind !== \"video\") return\n\n try {\n if ((await missingVideoStills(input.storage, version)).length === 0) return\n\n await input.queue.enqueue({\n projectId: version.projectId,\n jobs: [\n {\n id: videoStillsJobId(version.artifactId),\n replace: true,\n type: \"artifact.video.stills.requested\",\n payload: {\n artifactId: version.artifactId,\n version: version.version,\n updatedAt: version.updatedAt.toISOString(),\n media: await resolveVideoMedia(version, input.read),\n },\n availableAt: new Date(Date.now() + VIDEO_STILLS_JOB.settleMs).toISOString(),\n },\n ],\n })\n } catch (error) {\n console.error(\n `[Sixb] Could not ask for the stills of version ${version.version} of '${version.artifactId}'; its scenes show without pictures.`,\n error\n )\n }\n}\n\nfunction hash(value: unknown): string {\n return createHash(\"sha256\").update(JSON.stringify(value)).digest(\"hex\")\n}\n",
|
|
33
|
+
"import { createAgentThreadAccessRule } from \"../agents/thread-access\"\nimport { type Principal, SYSTEM_PRINCIPAL } from \"../auth\"\nimport { AuthorizationError, isRuntimeAllowed } from \"../authorization\"\nimport type { BlobStorage, FileRef } from \"../blob-storage/types\"\nimport { computeBlobDigest } from \"../blob-storage/utils\"\nimport { resolveRuntimeAuthorizationForProject } from \"../execution/authorization\"\nimport { type AuthorizedObjectReader, objectReadersIn } from \"../execution/authorized-object-reader\"\nimport type { SharedAccessDelegationRef } from \"../execution/types\"\nimport type { ObjectQuery } from \"../objects/query/ir\"\nimport type { PropertyToken } from \"../ontology/tokens\"\nimport type { SixbRuntimeContext } from \"../runtime/types\"\nimport { ArtifactStorageError } from \"../storage/artifacts/errors\"\nimport type {\n ArtifactCommentAuthor,\n ArtifactFile,\n ArtifactGuest,\n ArtifactMediaParts,\n ArtifactRecord,\n ArtifactRestorePointRecord,\n ArtifactStorage,\n ArtifactVersionRecord,\n ArtifactVideoRenderLack,\n ListArtifactsResult,\n ListArtifactVersionsResult,\n PublishedArtifactVersion,\n} from \"../storage/artifacts/types\"\nimport type { Storage } from \"../storage/types\"\nimport {\n type ArtifactAccess,\n type ArtifactAccessRule,\n assertUpdatable,\n createArtifactAccessRule,\n type HolderAccess,\n} from \"./access\"\nimport { parseArtifactAddress } from \"./address\"\nimport { type ArtifactCommentsRuntime, createArtifactCommentsRuntime } from \"./comments\"\nimport { documentMarks, fillDocumentHtml, frozenDocumentHtml } from \"./document-fill\"\nimport { ArtifactRequestError } from \"./errors\"\nimport { announceArtifactUpdates } from \"./events\"\nimport { type DocumentQueryResult, documentData } from \"./frames/document-data\"\nimport { type ArtifactHolding, readableHoldings } from \"./holders\"\nimport type { ArtifactKind } from \"./kinds\"\nimport { ARTIFACT_HOLDERS_LIMIT, ARTIFACT_LIMITS, ARTIFACT_STATE_LIMITS } from \"./limits\"\nimport { firstArtifactDocument, keepsDocument } from \"./live/state\"\nimport {\n isMediaFile,\n refreshArtifactMedia,\n requestArtifactMedia,\n retryArtifactMedia,\n unmadeMediaParts,\n} from \"./media/media\"\nimport type { DocumentHolder } from \"./outline\"\nimport { invalidArtifact, readArtifactText, titleFileName } from \"./publish/files\"\nimport { type ArtifactWrite, withDocumentHolding, withMergedWrite } from \"./publish/merge\"\nimport { documentPdfKey, requestDocumentPdf } from \"./publish/pdf\"\nimport {\n type BoardPreviewRequester,\n boardsReadLiveData,\n requestBoardPreviews,\n} from \"./publish/previews\"\nimport {\n artifactRequestError,\n artifactVersionWarnings,\n type PreparedArtifactVersion,\n type PublishedArtifact,\n prepareArtifactVersion,\n publishArtifact,\n storeArtifactVersion,\n} from \"./publish/publish\"\nimport { type ArtifactQueryChecker, createArtifactQueryChecker } from \"./publish/queries\"\nimport { DOCUMENT_HTML_ENTRY } from \"./publish/validate/document-html\"\nimport {\n ARTIFACT_QUERY_KINDS,\n type ArtifactQueryResult,\n artifactQueryPath,\n DOCUMENT_HOLDER_QUERY,\n isArtifactQueryName,\n parseArtifactQuery,\n} from \"./queries\"\nimport { runArtifactQuery } from \"./run-query\"\nimport {\n requestVideoExport,\n resolveVideoMedia,\n type VideoExportProgress,\n videoExportKeys,\n videoExportPlan,\n videoExportProgress,\n videoExportStatus,\n} from \"./video/export\"\nimport { requestVideoStills } from \"./video/stills\"\n\n/** A version's content: what its kind renders from, and what it is called. */\nexport interface ArtifactContentInput {\n readonly kind: ArtifactKind\n readonly title: string\n /** Files stored with `sixb.blobs.put()` or `POST /api/files`, at their paths in the artifact. */\n readonly files: readonly ArtifactFile[]\n /**\n * Queries the version holds, by name, each stored as `queries/<name>.json` beside `files` and\n * checked as those files are. Each reader runs them with their own rights.\n */\n readonly queries?: Readonly<Record<string, ArtifactQueryInput>>\n}\n\n/**\n * A query a version holds, from the query builders: `sixb.objects(Invoice).where(...)` for rows,\n * or such a query with the properties to facet its rows by. Any builder fits: its `ir` is what\n * the version keeps.\n */\nexport type ArtifactQueryInput =\n | { readonly ir: ObjectQuery }\n | {\n readonly query: { readonly ir: ObjectQuery }\n readonly facets: readonly { readonly property: PropertyToken; readonly limit: number }[]\n }\n\nexport interface UpdateArtifactRuntimeInput extends ArtifactContentInput {\n /**\n * The revision this content was made from, such as the one a person edited. When the artifact\n * changed since, the update fails with `artifact_moved`, naming its revision and who wrote it;\n * a canvas instead takes what changed from that revision's files into what it holds now.\n */\n readonly baseRevision?: number\n /**\n * The files of `baseRevision`, which a canvas's merge starts from. Without them, it looks for\n * them among the artifact's versions and restore points, and refuses with `artifact_moved` when\n * none holds them.\n */\n readonly baseFiles?: readonly ArtifactFile[]\n /**\n * The title of `baseRevision`. A write merged past it keeps a title someone gave it since,\n * unless this write changes the title itself.\n */\n readonly baseTitle?: string\n}\n\n/**\n * A live room's write-back, for this repo's server: the canvas's Yjs document as its editors hold\n * it, merged into the stored one. The version holds what the merged document holds.\n */\nexport interface LiveArtifactWrite {\n readonly title: string\n /** The title the room last read: a title given since stays. */\n readonly baseTitle: string\n /** The revision the room last took in. */\n readonly baseRevision: number\n /**\n * The document's files as the room stored them: what the merged version holds alike keeps\n * these references.\n */\n readonly files: readonly ArtifactFile[]\n /** The document, encoded with `Y.encodeStateAsUpdate`. */\n readonly update: Uint8Array\n}\n\n/** A change made from what the caller saw: past `baseRevision`, it fails with `artifact_moved`. */\nexport interface ArtifactRevisionInput {\n readonly baseRevision?: number\n}\n\nexport interface ListArtifactsRuntimeInput {\n /**\n * Only the artifacts a conversation shares: every one of them, whoever owns it, for whoever reads\n * the conversation; otherwise the caller's own among them.\n */\n readonly threadId?: string\n /** Only artifacts of this kind. */\n readonly kind?: ArtifactKind\n readonly limit?: number\n readonly offset?: number\n}\n\n/**\n * The artifacts the caller reaches: its own, those shared in a conversation it reads, and those\n * held by an object it reads, as {@link ArtifactAccess} says. System code reaches every artifact in\n * the project, and an access token no conversation's.\n */\nexport interface ArtifactsRuntime extends ArtifactCommentsRuntime {\n /** Creates an artifact owned by the caller, with its first version. */\n create(input: ArtifactContentInput): Promise<PublishedArtifact>\n /**\n * Writes the latest version, authored by the caller: its open version's content is replaced, or\n * the next version opens when it is frozen. The artifact keeps its owner, and the kind must be\n * its. Throws `not_shared` or `read_only` when the caller may not update it.\n */\n update(artifactId: string, input: UpdateArtifactRuntimeInput): Promise<PublishedArtifact>\n /**\n * Creates a version: the open latest version is frozen, so it never changes again and the next\n * write opens the next one. A latest version already frozen is returned as it is. Who may\n * update may freeze; throws as `update` does.\n */\n freeze(artifactId: string, input?: ArtifactRevisionInput): Promise<PublishedArtifactVersion>\n /**\n * What the artifact's latest version held before each Agent turn's first write to it, and\n * before each restore, newest first; `null` when the caller cannot read the artifact.\n */\n listRestorePoints(artifactId: string): Promise<ArtifactRestorePointRecord[] | null>\n /** `null` when the caller cannot read the artifact, or it keeps no such restore point. */\n getRestorePoint(artifactId: string, revision: number): Promise<ArtifactRestorePointRecord | null>\n /**\n * Puts a restore point's content back in the latest version, authored by the caller, as\n * `update` writes it. What it replaces becomes a restore point, so the restore can be undone.\n * Throws as `update` does, and `restore_point_not_found`.\n */\n restore(\n artifactId: string,\n revision: number,\n input?: ArtifactRevisionInput\n ): Promise<PublishedArtifactVersion>\n /** What the caller may do with the artifact; `null` when there is no such artifact. */\n access(artifactId: string): Promise<ArtifactAccess | null>\n /** `null` when the caller cannot read it. */\n get(artifactId: string): Promise<ArtifactRecord | null>\n /**\n * The caller's own artifacts, or a conversation's, most recently updated first. One the caller\n * reaches only through an object is opened from that object: see `holders`.\n */\n list(input?: ListArtifactsRuntimeInput): Promise<ListArtifactsResult>\n /**\n * The objects that hold the artifact in a property, among those the caller reads with that\n * property: the first {@link ARTIFACT_HOLDERS_LIMIT}, in a stable order. `null` when the caller\n * cannot read the artifact.\n */\n holders(artifactId: string): Promise<ArtifactHolders | null>\n getVersion(artifactId: string, version: number | \"latest\"): Promise<ArtifactVersionRecord | null>\n /**\n * A designed document's PDF, printed as its stylesheets' `@page` rule lays it out, with the\n * values its fields read as the caller reads them: `ready` with its file once printed, else\n * `printing`, having asked the render worker to print it, which takes a few seconds; `print:\n * false` reads it without asking. `failed` with why when it could not be printed; `retry` asks\n * again instead. A document that shows live data answers with a `key` naming the values it\n * prints: asked again with it, it reads what that first ask printed, whatever the values are by\n * then, and asks nothing more.\n * Whoever reads the artifact may ask. `null` when the caller cannot read the artifact or it has\n * no such version. Throws `invalid_artifact` for a version that is not a designed document, and\n * `pdf_unavailable` in a project without sandboxes, where nothing prints.\n */\n pdf(\n artifactId: string,\n options?: {\n readonly version?: number | \"latest\"\n readonly retry?: boolean\n readonly print?: boolean\n readonly key?: string\n }\n ): Promise<ArtifactPdf | null>\n /**\n * What Sixb derives of a video or a sound among a version's files, at `path`: what it holds, a\n * proxy that plays in its place, a poster, a filmstrip, its peaks, its cuts and its transcript,\n * each ready, pending, or why it will not come. They are derived once for every file that holds\n * the same bytes, in a sandbox of the project, when a version holding it is published; one\n * nothing was derived of yet is asked for now, unless `derive: false`. A part that `failed` says\n * why until asked with `retry`, which derives each failed part again. In a project without\n * sandboxes, each part is unavailable. Whoever reads the artifact may ask. `null` when the\n * caller cannot read the artifact or it has no such version. Throws `invalid_artifact` when the\n * version holds no video or sound at `path`.\n */\n media(\n artifactId: string,\n options: {\n readonly path: string\n readonly version?: number | \"latest\"\n readonly derive?: boolean\n readonly retry?: boolean\n }\n ): Promise<ArtifactMedia | null>\n /**\n * A video version's MP4: `ready` with its file once rendered, named after the version's title,\n * else `rendering` with how far it has come, having asked the render worker for it;\n * `render: false` reads it without asking, `idle` when no one asked for it yet. It renders scene by scene in sandboxes of the\n * project, about as long as the video itself for a light one, and keeps each scene's segment, so a version that changes one scene renders only\n * that scene again. Its `artifact:` files are those the caller reads. `failed` with why when it\n * could not be rendered; `retry` asks again instead. Whoever reads the artifact may ask. `null`\n * when the caller cannot read the artifact or it has no such version. Throws `invalid_artifact`\n * for a version that is not a video, and `video_unavailable` in a project without sandboxes.\n */\n video(\n artifactId: string,\n options?: {\n readonly version?: number | \"latest\"\n readonly retry?: boolean\n readonly render?: boolean\n }\n ): Promise<ArtifactVideoExport | null>\n /**\n * Runs the version's query `queries/<name>.json` as the caller, with their rights: a type they\n * cannot view refuses it, and a marked property they are not cleared for is left out of each\n * row. Whoever reads the artifact runs its queries, an observer too. `null` when the caller\n * cannot read the artifact or it has no such version. Throws `query_not_found`, and\n * `query_invalid` for a query the ontology no longer admits.\n */\n query(\n artifactId: string,\n name: string,\n options?: { readonly version?: number | \"latest\" }\n ): Promise<ArtifactQueryResult | null>\n /** Newest first; `null` when the caller cannot read the artifact. */\n listVersions(\n artifactId: string,\n input?: { readonly limit?: number; readonly offset?: number }\n ): Promise<ListArtifactVersionsResult | null>\n /**\n * Deletes the artifact with every version, from every conversation that shares it; only its\n * owner can. `false` when the caller does not own it.\n */\n delete(artifactId: string): Promise<boolean>\n /**\n * What the artifact keeps for the caller as its reader, as a page keeps it with `sixb.state`:\n * JSON values by key, across its versions. Each reader who may update the artifact keeps their\n * own. Each call throws `artifact_not_found`, `not_shared`, or `read_only` for an observer.\n */\n state(artifactId: string): ArtifactStateRuntime\n}\n\n/** One reader's values, kept by one artifact. */\nexport interface ArtifactStateRuntime {\n /** The value under the key, or undefined when there is none. */\n get(key: string): Promise<unknown>\n /**\n * Keeps a JSON value under the key, replacing one there. Throws `invalid_state` for a key or a\n * value that is not one, and `state_full` past `ARTIFACT_STATE_LIMITS`. Returns what it kept.\n */\n set(key: string, value: unknown): Promise<ArtifactStateValue>\n /** `false` when there was no value under the key. */\n delete(key: string): Promise<boolean>\n /** Every value, by key in order. */\n entries(): Promise<ArtifactStateValue[]>\n /** Deletes every value, and returns how many. */\n clear(): Promise<number>\n}\n\n/** A designed document's PDF: its file once printed, being printed, or why it could not be. */\nexport type ArtifactPdf = (\n | {\n readonly status: \"ready\"\n readonly file: FileRef\n /** How many pages it printed on. */\n readonly pages: number\n }\n | { readonly status: \"printing\" }\n | { readonly status: \"failed\"; readonly reason: string }\n) & {\n /** The values a document that shows live data prints, to ask for that PDF again with. */\n readonly key?: string\n}\n\n/** A video version's MP4: its file once rendered, how far it has come, or why it could not be. */\nexport type ArtifactVideoExport =\n | {\n readonly status: \"ready\"\n readonly file: FileRef\n readonly durationMs: number\n readonly sizeBytes: number\n }\n | {\n readonly status: \"rendering\"\n /** Its segments rendered, of all of them, then the MP4 being joined from them. */\n readonly progress: VideoExportProgress\n }\n /** Read with `render: false`, no one asked for it yet: asking renders it. */\n | { readonly status: \"idle\" }\n | {\n readonly status: \"failed\"\n /** Why, as a developer reads it: the scene, the sound, or what the project lacks. */\n readonly reason: string\n /**\n * What the project lacks to render it, when the video is not why: asking again with\n * `retry` renders it once the project has it, and fails the same until then.\n */\n readonly lacks?: ArtifactVideoRenderLack\n }\n\n/** What Sixb derives of a video or a sound of a version. */\nexport interface ArtifactMedia {\n readonly version: number\n readonly path: string\n /** The original, as the version holds it. */\n readonly file: FileRef\n readonly parts: ArtifactMediaParts\n}\n\n/** The objects that hold an artifact, as the caller reads them. */\nexport interface ArtifactHolders {\n readonly holders: readonly ArtifactHolderObject[]\n /** More objects the caller reads hold it. */\n readonly hasMore: boolean\n}\n\n/** An object property that holds the artifact. */\nexport interface ArtifactHolderObject {\n readonly objectTypeId: string\n readonly primaryId: string\n readonly propertyId: string\n /** The object's value of its type's `search.title`, when it has one the caller reads. */\n readonly title?: string\n}\n\nexport interface ArtifactStateValue {\n readonly key: string\n readonly value: unknown\n readonly updatedAt: Date\n}\n\n/** Where an access rule reads: the project's storage, or a transaction's to decide inside it. */\nexport type ArtifactAccessStorage = Pick<Storage, \"artifacts\" | \"agents\" | \"objects\">\n\n/**\n * What each runtime's caller publishes by, for this repo's packages: an Agent turn publishes with\n * the access rule and the query checker of whoever asked for it.\n */\nconst publishers = new WeakMap<\n object,\n {\n readonly rule: () => ArtifactAccessRule\n readonly transactionRules: () => Promise<TransactionAccessRules>\n readonly checkQuery: ArtifactQueryChecker\n readonly requestPreviews: BoardPreviewRequester\n readonly writeLive: (artifactId: string, write: LiveArtifactWrite) => Promise<PublishedArtifact>\n }\n>()\n\nfunction publisherOf(artifacts: Partial<ArtifactsRuntime>) {\n const publisher = publishers.get(artifacts)\n if (!publisher) throw new Error(\"[Sixb] These artifacts are not a Sixb runtime's.\")\n return publisher\n}\n\n/** The access rule of the caller `artifacts` acts for. Each call returns a rule of its own. */\nexport function artifactAccessRule(artifacts: Partial<ArtifactsRuntime>): ArtifactAccessRule {\n return publisherOf(artifacts).rule()\n}\n\n/** {@link transactionArtifactAccessRules} for the caller `artifacts` acts for. */\nexport function artifactTransactionRules(\n artifacts: Partial<ArtifactsRuntime>\n): Promise<TransactionAccessRules> {\n return publisherOf(artifacts).transactionRules()\n}\n\n/** What checks a version's queries as the caller `artifacts` acts for. */\nexport function artifactQueryChecker(artifacts: Partial<ArtifactsRuntime>): ArtifactQueryChecker {\n return publisherOf(artifacts).checkQuery\n}\n\n/**\n * What asks for the pictures a stored version's boards miss, and for what is derived of its media,\n * in the project `artifacts` belongs to: nothing in a project without sandboxes, where nothing\n * renders them.\n */\nexport function artifactPreviewRequester(\n artifacts: Partial<ArtifactsRuntime>\n): BoardPreviewRequester {\n return publisherOf(artifacts).requestPreviews\n}\n\n/**\n * Writes a live room's document back into the canvas, as the caller `artifacts` acts for: the\n * write `update` makes, checked, authored and announced as it is, from the document instead of\n * from files.\n */\nexport function writeLiveArtifact(\n artifacts: Partial<ArtifactsRuntime>,\n artifactId: string,\n write: LiveArtifactWrite\n): Promise<PublishedArtifact> {\n return publisherOf(artifacts).writeLive(artifactId, write)\n}\n\n/** The access rule for the runtime's caller, reading the project's storage. */\nexport function createRuntimeArtifactAccessRule(runtime: SixbRuntimeContext): ArtifactAccessRule {\n return accessRuleIn(runtime, runtime.storage, runtime.objectReader)\n}\n\n/** The runtime caller's access rule for a transaction's storage, deciding inside it. */\nexport type TransactionAccessRules = (tx: ArtifactAccessStorage) => ArtifactAccessRule\n\n/**\n * The access rule for the runtime's caller in a storage transaction: its threads, its holders and\n * its objects are the transaction's, so a participant removed or an object changed meanwhile is\n * seen. What the caller is cleared for is resolved now, before the transaction opens: resolving it\n * may read the project's storage, which a transaction's callback cannot.\n */\nexport async function transactionArtifactAccessRules(\n runtime: SixbRuntimeContext\n): Promise<TransactionAccessRules> {\n const readerIn = await objectReadersIn(runtime.objectReader)\n return (tx) => accessRuleIn(runtime, tx, readerIn(tx.objects))\n}\n\n/** The rule reading `storage`, with `reader` reading its objects as the caller. */\nfunction accessRuleIn(\n runtime: SixbRuntimeContext,\n storage: ArtifactAccessStorage,\n reader: AuthorizedObjectReader\n): ArtifactAccessRule {\n const artifacts = storage.artifacts\n if (!artifacts) {\n throw new ArtifactRequestError(\n \"storage_unavailable\",\n \"[Sixb] Artifacts need storage that supports them.\"\n )\n }\n\n const authority = resolveRuntimeAuthorizationForProject(runtime)\n const threads = createAgentThreadAccessRule(runtime, authority, storage.agents)\n\n return createArtifactAccessRule({\n storage: artifacts,\n projectId: runtime.projectId,\n // A shared link's session reaches artifacts as a guest; unresolved authority reaches none.\n caller:\n authority.type === \"unrestricted\"\n ? \"system\"\n : authority.type === \"principal\"\n ? authority.context.principal\n : authority.type === \"delegated\"\n ? \"guest\"\n : null,\n sharing: authority.type === \"principal\" && authority.ref.credential?.type === \"session\",\n conversation: async (threadId) => {\n if (await threads.read(threadId)) return \"update\"\n return isRuntimeAllowed(runtime, { kind: \"agentThreads.observe\" }) ? \"read\" : null\n },\n holders: async (artifact) => {\n let access: HolderAccess = null\n const holdings = readableHoldings({\n runtime,\n reader,\n objects: storage.objects,\n artifactId: artifact.id,\n })\n\n for await (const holding of holdings) {\n if (holding.access === \"update\") return \"update\"\n access = \"read\"\n }\n return access\n },\n })\n}\n\n/**\n * The artifacts among `artifactIds` that the runtime's caller may change, as its owner or with\n * `update`, as its access rule decides now. One that does not exist is not among them, and\n * without artifact storage none is.\n */\nexport async function updatableArtifactIds(\n runtime: SixbRuntimeContext,\n artifactIds: Iterable<string>\n): Promise<ReadonlySet<string>> {\n const ids = [...new Set(artifactIds)]\n const storage = runtime.storage.artifacts\n if (ids.length === 0 || !storage) return new Set()\n\n const rule = createRuntimeArtifactAccessRule(runtime)\n const updatable = await Promise.all(\n ids.map(async (id) => {\n const artifact = await storage.get({ projectId: runtime.projectId, id })\n if (!artifact) return []\n\n const access = await rule.accessTo(artifact)\n return access === \"owner\" || access === \"update\" ? [id] : []\n })\n )\n\n return new Set(updatable.flat())\n}\n\nexport function createArtifactsRuntime(\n runtime: SixbRuntimeContext,\n blobStorage: BlobStorage,\n options: {\n /**\n * The project has sandboxes, where the render worker pictures canvas boards, prints designed\n * documents to PDF, and derives what plays and shows in place of a video or a sound.\n */\n readonly rendersInSandboxes?: boolean\n /** The project has a transcription model, which transcribes what its media say. */\n readonly transcribesMedia?: boolean\n } = {}\n): ArtifactsRuntime {\n const authority = resolveRuntimeAuthorizationForProject(runtime)\n // A shared link's session writes nothing but comments, as a guest; unresolved authority, nothing.\n const caller: Principal | null =\n authority.type === \"principal\"\n ? authority.context.principal\n : authority.type === \"unrestricted\"\n ? SYSTEM_PRINCIPAL\n : null\n\n const requireStorage = (): ArtifactStorage => {\n const storage = runtime.storage.artifacts\n if (!storage) {\n throw new ArtifactRequestError(\n \"storage_unavailable\",\n \"[Sixb] Artifacts need storage that supports them.\"\n )\n }\n return storage\n }\n const requireCaller = (): Principal => {\n if (!caller) {\n throw new ArtifactRequestError(\n \"not_allowed\",\n authority.type === \"delegated\"\n ? \"[Sixb] A shared link's guest reads its artifacts and comments on them, nothing more.\"\n : \"[Sixb] This caller cannot publish artifacts.\"\n )\n }\n return caller\n }\n\n /** Who writes a comment: the caller, or a shared link's guest under the name they gave. */\n const commentAuthor = async (): Promise<ArtifactCommentAuthor> => {\n if (authority.type !== \"delegated\" || !authority.delegation) return requireCaller()\n return sharedLinkGuest(runtime, authority.delegation)\n }\n\n const rule = (): ArtifactAccessRule => createRuntimeArtifactAccessRule(runtime)\n const checkQuery = createArtifactQueryChecker(runtime)\n\n /** Runs one of a version's queries, or a designed document's holder, as the caller. */\n const runQuery = async (\n read: { readonly artifact: ArtifactRecord; readonly version: ArtifactVersionRecord },\n name: string\n ): Promise<ArtifactQueryResult> => {\n // A file artifact is delivered as it is: its one file is never run.\n const { artifact, version } = read\n const holder = version.outline.kind === \"document\" ? version.outline.holder : undefined\n\n // What a designed document's fields read of the object that holds it: that object, with\n // the objects each link they read through reaches.\n if (holder && name === DOCUMENT_HOLDER_QUERY) {\n const refs: ObjectQuery = { kind: \"refs\", refs: [await requireHolder(artifact.id, holder)] }\n const expansions = holder.links.map((linkId) => ({\n linkId,\n direction: \"outgoing\" as const,\n }))\n return runArtifactQuery(runtime, name, {\n kind: \"objects\",\n query: expansions.length > 0 ? { kind: \"expand\", input: refs, expansions } : refs,\n })\n }\n\n const file =\n ARTIFACT_QUERY_KINDS.includes(artifact.kind) && isArtifactQueryName(name)\n ? version.files.find((candidate) => candidate.path === artifactQueryPath(name))\n : undefined\n if (!file) {\n throw new ArtifactRequestError(\n \"query_not_found\",\n `[Sixb] Version ${version.version} of artifact '${artifact.id}' has no query '${name}'.`\n )\n }\n\n const text = await readArtifactText(blobStorage, file, ARTIFACT_LIMITS.maxQueryBytes)\n const parse = (start?: ObjectQuery) =>\n parseArtifactQuery(file.path, text, start ? { holder: start } : {})\n let parsed = parse(holder ? { kind: \"refs\", refs: [] } : undefined)\n // A query that starts from the holder is read again from the one the caller reads.\n if (holder && \"usesHolder\" in parsed && parsed.usesHolder) {\n parsed = parse({ kind: \"refs\", refs: [await requireHolder(artifact.id, holder)] })\n }\n if (\"error\" in parsed) {\n throw new ArtifactRequestError(\"query_invalid\", `[Sixb] ${parsed.error}`)\n }\n\n return runArtifactQuery(runtime, name, parsed.query)\n }\n\n /**\n * A designed document's markup with the values its fields read written in, as the caller reads\n * them, and no field left marked, or every one with `keep`; null when it shows no live data. What\n * the caller cannot read keeps its written text. A frozen version's are those written in when it\n * was frozen, which are not read again.\n */\n const writtenIn = async (\n read: {\n readonly artifact: ArtifactRecord\n readonly version: ArtifactVersionRecord\n },\n options: { readonly keep?: boolean } = {}\n ): Promise<string | null> => {\n const { version } = read\n const entry = version.files.find((file) => file.path === DOCUMENT_HTML_ENTRY)\n if (version.outline.kind !== \"document\" || !entry) return null\n\n const html = await readArtifactText(blobStorage, entry, ARTIFACT_LIMITS.maxDocumentBytes)\n const reads = documentData().reads(documentMarks(html))\n if (!reads.holder && reads.queries.length === 0) return null\n if (version.frozenAt) return frozenDocumentHtml(html)\n\n // What the caller may not read, or no one object holds, keeps its written text; anything\n // else that fails is thrown, never written in as text that stays.\n const answer = (name: string) =>\n runQuery(read, name).then(\n (result) => result as DocumentQueryResult,\n (error: unknown) => {\n if (error instanceof AuthorizationError || error instanceof ArtifactRequestError) {\n return undefined\n }\n throw error\n }\n )\n const [holder, ...results] = await Promise.all([\n reads.holder ? answer(DOCUMENT_HOLDER_QUERY) : undefined,\n ...reads.queries.map(answer),\n ])\n const queries: Record<string, DocumentQueryResult> = {}\n reads.queries.forEach((name, index) => {\n const result = results[index]\n if (result) queries[name] = result\n })\n const row = holder?.objects?.[0]\n return fillDocumentHtml(\n html,\n { ...(row ? { holder: row } : {}), queries },\n options.keep ? { keep: true } : { plain: true }\n )\n }\n\n /**\n * The one object of the type a designed document names that holds it, as the caller reads it.\n * Throws `holder_not_found` when none does, or several do: its fields keep their written text.\n */\n const requireHolder = async (\n artifactId: string,\n holder: DocumentHolder\n ): Promise<{ readonly objectTypeId: string; readonly primaryId: string }> => {\n const found = new Set<string>()\n const holdings = readableHoldings({\n runtime,\n reader: runtime.objectReader,\n objects: runtime.storage.objects,\n artifactId,\n })\n for await (const holding of holdings) {\n if (holding.objectTypeId === holder.objectTypeId) found.add(holding.primaryId)\n if (found.size > 1) break\n }\n const [primaryId] = found\n if (found.size !== 1 || primaryId === undefined) {\n throw new ArtifactRequestError(\n \"holder_not_found\",\n `[Sixb] No one ${holder.objectTypeId} you read holds artifact '${artifactId}', so its fields show what is written in them.`\n )\n }\n return { objectTypeId: holder.objectTypeId, primaryId }\n }\n const mediaContext = (storage: ArtifactStorage) => ({\n storage,\n queue: runtime.queues.renders,\n transcribes: options.transcribesMedia === true,\n })\n const requestPreviews: BoardPreviewRequester = async (version, requestOptions) => {\n const storage = runtime.storage.artifacts\n if (!options.rendersInSandboxes || !storage) return\n\n // Each video and sound of any kind, once for every file with its bytes, and each a video\n // plays from another artifact: its frame plays their proxies too.\n const borrowed = await borrowedRecordings(version)\n await requestArtifactMedia(mediaContext(storage), {\n ...version,\n files: [...version.files, ...borrowed],\n })\n\n // A video's scenes, each at its middle, with what it plays from other artifacts as whoever\n // published it reads them.\n await requestVideoStills(\n {\n storage,\n queue: runtime.queues.renders,\n read: (id, number) => artifacts.getVersion(id, number),\n },\n version\n )\n\n // Its queries are answered as whoever published it, who is this runtime's caller.\n await requestBoardPreviews(\n {\n storage,\n queue: runtime.queues.renders,\n blobStorage,\n query: (name) => artifacts.query(version.artifactId, name, { version: version.version }),\n },\n version,\n requestOptions\n )\n }\n\n /**\n * The videos and sounds a video plays from other artifacts, at the versions its addresses\n * resolved to when it was published, as the caller reads them. One that cannot be read now is\n * left out: it plays as it is.\n */\n const borrowedRecordings = async (version: ArtifactVersionRecord): Promise<ArtifactFile[]> => {\n if (version.outline.kind !== \"video\") return []\n\n const recordings: ArtifactFile[] = []\n try {\n for (const reference of version.references) {\n const address = parseArtifactAddress(reference.address)\n if (reference.as !== \"embed\" || !address?.path) continue\n\n const lender = await readVersion(address.artifactId, reference.resolvedVersion)\n const file = lender?.version.files.find((candidate) => candidate.path === address.path)\n if (file && isMediaFile(file)) recordings.push(file)\n }\n } catch (error) {\n console.error(\n `[Sixb] Could not read the recordings version ${version.version} of '${version.artifactId}' plays from other artifacts; they play as they are.`,\n error\n )\n }\n return recordings\n }\n\n /** The artifact with what the caller may do with it; `null` when there is none. */\n const reach = async (\n artifactId: string\n ): Promise<{ readonly artifact: ArtifactRecord; readonly access: ArtifactAccess } | null> => {\n const artifact = await requireStorage().get({ projectId: runtime.projectId, id: artifactId })\n return artifact ? { artifact, access: await rule().accessTo(artifact) } : null\n }\n const getReadable = async (artifactId: string): Promise<ArtifactRecord | null> => {\n const reached = await reach(artifactId)\n return reached && reached.access !== \"none\" ? reached.artifact : null\n }\n\n /** The version with its artifact; `null` when the caller cannot read it or there is none. */\n const readVersion = async (artifactId: string, number: number | \"latest\") => {\n const artifact = await getReadable(artifactId)\n if (!artifact) return null\n\n const version = await requireStorage().getVersion({\n projectId: runtime.projectId,\n artifactId,\n version: number === \"latest\" ? artifact.latestVersion : number,\n })\n return version ? { artifact, version } : null\n }\n\n /** What an address in a version may name: one artifact the caller reads, by one rule. */\n const readableBy = (access: ArtifactAccessRule) => async (artifact: ArtifactRecord) =>\n (await access.accessTo(artifact)) !== \"none\"\n\n /** The artifact, refused unless the caller may update it. */\n const requireUpdatable = async (artifactId: string): Promise<ArtifactRecord> => {\n const reached = await reach(artifactId)\n if (!reached) throw notFound(artifactId)\n assertUpdatable(artifactId, reached.access)\n return reached.artifact\n }\n\n /**\n * Stores in one transaction, which checks again what the caller may do: a participant removed,\n * or an object that no longer holds the artifact, while the files were checked publishes nothing.\n */\n const store = async (prepared: PreparedArtifactVersion) => {\n const ruleIn = await transactionArtifactAccessRules(runtime)\n\n return runtime.storage.transaction(async (tx) => {\n const storage = tx.artifacts\n if (!storage) throw new Error(\"[Sixb] Storage transactions hold no artifacts.\")\n\n return storeArtifactVersion(\n { projectId: runtime.projectId, storage, blobStorage },\n prepared,\n (artifact) => ruleIn(tx).publishAccess(artifact)\n )\n })\n }\n\n /**\n * Changes an artifact the caller may update, in one transaction that decides it there, so a\n * participant removed, or an object changed, meanwhile changes nothing.\n */\n const change = async (\n artifactId: string,\n write: (storage: ArtifactStorage, author: Principal) => Promise<PublishedArtifactVersion>\n ) => {\n const author = requireCaller()\n requireStorage()\n const ruleIn = await transactionArtifactAccessRules(runtime)\n\n return runtime.storage.transaction(async (tx) => {\n const storage = tx.artifacts\n if (!storage) throw new Error(\"[Sixb] Storage transactions hold no artifacts.\")\n\n const artifact = await storage.get({ projectId: runtime.projectId, id: artifactId })\n if (!artifact) throw notFound(artifactId)\n assertUpdatable(artifactId, await ruleIn(tx).publishAccess(artifact))\n\n try {\n return await write(storage, author)\n } catch (error) {\n throw artifactRequestError(error)\n }\n })\n }\n\n /**\n * The version's files with its `queries` stored among them. Publishing then checks each one as\n * it checks a query file.\n */\n const contentFiles = async (input: ArtifactContentInput): Promise<readonly ArtifactFile[]> => {\n if (!input.queries) return input.files\n\n const files = [...input.files]\n for (const [name, query] of Object.entries(input.queries)) {\n const path = artifactQueryPath(name)\n if (input.files.some((file) => file.path === path)) {\n throw invalidArtifact(`'${path}' is both a file and a query; give it once.`)\n }\n\n const body = new TextEncoder().encode(JSON.stringify(queryFile(query)))\n const file = await blobStorage.put({\n body,\n expectedSizeBytes: body.byteLength,\n fileName: `${name}.json`,\n mediaType: \"application/json\",\n })\n files.push({ path, file })\n }\n return files\n }\n\n /**\n * Stores the latest version, authored by the caller, who may update the artifact. One that\n * keeps a document, written since the base, is merged into, not refused: the merge is checked.\n */\n const write = async (\n input: ArtifactWrite & { readonly title: string }\n ): Promise<PublishedArtifact> => {\n const author = requireCaller()\n const context = { projectId: runtime.projectId, storage: requireStorage(), blobStorage }\n\n return withMergedWrite(context, input, async (merged) => {\n const prepared = await prepareArtifactVersion(context, {\n artifactId: input.artifactId,\n kind: input.kind,\n title: merged.title ?? input.title,\n files: merged.files,\n ...(merged.baseRevision === undefined ? {} : { baseRevision: merged.baseRevision }),\n ...(merged.document ? { document: merged.document } : {}),\n author,\n readable: readableBy(rule()),\n checkQuery,\n })\n const stored = await store(prepared)\n await announceArtifactUpdates(runtime.events, [stored.version])\n await requestPreviews(stored.version)\n\n return {\n ...stored,\n warnings: await artifactVersionWarnings(context, prepared, stored),\n ...(merged.merged ? { merged: true as const } : {}),\n }\n })\n }\n\n /** A live room's write-back: only a canvas or a document keeps one to merge it into. */\n const writeLive = async (\n artifactId: string,\n input: LiveArtifactWrite\n ): Promise<PublishedArtifact> => {\n const artifact = await requireUpdatable(artifactId)\n if (!keepsDocument(artifact.kind)) {\n throw invalidArtifact(\n `Artifact '${artifactId}' is a ${artifact.kind} that is not edited live: publish its files.`\n )\n }\n\n return write({ artifactId, kind: artifact.kind, ...input })\n }\n\n const artifacts: ArtifactsRuntime = {\n ...createArtifactCommentsRuntime({\n projectId: runtime.projectId,\n storage: requireStorage,\n events: runtime.events,\n author: commentAuthor,\n manager: requireCaller,\n reach,\n ...(authority.type === \"delegated\"\n ? { guest: { grantId: authority.delegation?.grantId } }\n : {}),\n }),\n\n async create(input) {\n const author = requireCaller()\n const files = await contentFiles(input)\n const document = await firstArtifactDocument(blobStorage, input.kind, files)\n\n const published = await publishArtifact(\n { projectId: runtime.projectId, storage: requireStorage(), blobStorage },\n {\n kind: input.kind,\n title: input.title,\n files,\n ...(document ? { document } : {}),\n author,\n readable: readableBy(rule()),\n checkQuery,\n },\n (artifact) => rule().publishAccess(artifact)\n )\n await requestPreviews(published.version)\n\n return published\n },\n\n async update(artifactId, input) {\n await requireUpdatable(artifactId)\n\n return write({\n artifactId,\n kind: input.kind,\n files: await contentFiles(input),\n ...(input.baseRevision === undefined ? {} : { baseRevision: input.baseRevision }),\n ...(input.baseFiles === undefined ? {} : { baseFiles: input.baseFiles }),\n title: input.title,\n ...(input.baseTitle === undefined ? {} : { baseTitle: input.baseTitle }),\n })\n },\n\n async freeze(artifactId, input = {}) {\n // A designed document's fields are written in first, as the person freezing reads them, and\n // stay marked: the version it closes shows those values, which are never read again, and\n // the next version, opened from it, reads them anew.\n let baseRevision = input.baseRevision\n const open = await readVersion(artifactId, \"latest\")\n const filled = open && !open.version.frozenAt ? await writtenIn(open, { keep: true }) : null\n if (open && filled !== null) {\n await requireUpdatable(artifactId)\n const document = await blobStorage.put({\n body: new TextEncoder().encode(filled),\n fileName: DOCUMENT_HTML_ENTRY,\n mediaType: \"text/html\",\n })\n const written = await write({\n artifactId,\n kind: \"document\",\n files: open.version.files.map((file) =>\n file.path === DOCUMENT_HTML_ENTRY ? { path: file.path, file: document } : file\n ),\n baseRevision: baseRevision ?? open.version.revision,\n title: open.version.title,\n })\n baseRevision = written.version.revision\n }\n\n const frozenAt = new Date()\n const frozen = await change(artifactId, (storage, author) =>\n storage.freeze({\n projectId: runtime.projectId,\n artifactId,\n ...(baseRevision === undefined ? {} : { baseRevision }),\n frozenAt,\n frozenBy: author,\n })\n )\n\n // A version frozen before changed nothing to announce.\n if (frozen.version.frozenAt?.getTime() === frozenAt.getTime()) {\n await announceArtifactUpdates(runtime.events, [frozen.version])\n }\n return frozen\n },\n\n async listRestorePoints(artifactId) {\n if (!(await getReadable(artifactId))) return null\n return requireStorage().listRestorePoints({ projectId: runtime.projectId, id: artifactId })\n },\n\n async getRestorePoint(artifactId, revision) {\n if (!(await getReadable(artifactId))) return null\n return requireStorage().getRestorePoint({\n projectId: runtime.projectId,\n artifactId,\n revision,\n })\n },\n\n async restore(artifactId, revision, input = {}) {\n // A live document takes the restored content as a change, so editors keep theirs.\n const context = { projectId: runtime.projectId, storage: requireStorage(), blobStorage }\n const point = await context.storage.getRestorePoint({\n projectId: runtime.projectId,\n artifactId,\n revision,\n })\n const restored = await withDocumentHolding(\n context,\n artifactId,\n point?.files ?? null,\n input.baseRevision,\n (held) =>\n change(artifactId, (storage, author) =>\n storage.restoreTo({\n projectId: runtime.projectId,\n artifactId,\n revision,\n ...held,\n author,\n restoredAt: new Date(),\n })\n )\n )\n await announceArtifactUpdates(runtime.events, [restored.version])\n\n // Pictures of live boards show their author's data: a restore by someone else leaves the\n // ones it misses to the boards that read none.\n await requestPreviews(\n restored.version,\n boardsReadLiveData(restored.version) ? { withoutAnswers: true } : {}\n )\n return restored\n },\n\n async access(artifactId) {\n return (await reach(artifactId))?.access ?? null\n },\n\n get: getReadable,\n\n async list(input = {}) {\n if (!caller) return { artifacts: [], hasMore: false, total: 0 }\n\n // Whoever reads a conversation reads every artifact it shares; anyone else, their own in it.\n const everyShared =\n input.threadId !== undefined && (await rule().conversation(input.threadId)) !== null\n const ownerFilter = authority.type === \"principal\" && !everyShared ? caller : null\n\n return requireStorage().list({\n projectId: runtime.projectId,\n ...(ownerFilter ? { owner: ownerFilter } : {}),\n ...(input.threadId === undefined ? {} : { threadId: input.threadId }),\n ...(input.kind === undefined ? {} : { kind: input.kind }),\n ...(input.limit === undefined ? {} : { limit: input.limit }),\n ...(input.offset === undefined ? {} : { offset: input.offset }),\n })\n },\n\n async holders(artifactId) {\n if (!(await getReadable(artifactId))) return null\n\n const holders: ArtifactHolderObject[] = []\n const holdings = readableHoldings({\n runtime,\n reader: runtime.objectReader,\n objects: runtime.storage.objects,\n artifactId,\n })\n\n // One past the page says whether there are more.\n for await (const holding of holdings) {\n if (holders.length === ARTIFACT_HOLDERS_LIMIT) return { holders, hasMore: true }\n holders.push(holderObject(runtime, holding))\n }\n return { holders, hasMore: false }\n },\n\n async getVersion(artifactId, version) {\n return (await readVersion(artifactId, version))?.version ?? null\n },\n\n async pdf(artifactId, pdfOptions = {}) {\n const read = await readVersion(artifactId, pdfOptions.version ?? \"latest\")\n if (!read) return null\n\n const { version } = read\n if (!documentPdfKey(version)) {\n throw invalidArtifact(\n `Version ${version.version} of '${artifactId}' is not a designed document, which alone prints to PDF.`\n )\n }\n // A document that shows live data prints the values the caller reads, written in, and its\n // key names them; a frozen one prints those written in when it was frozen. Asked with its\n // key, it is the PDF of those values, and they are not read again.\n const { key } = pdfOptions\n const filled = key !== undefined ? null : await writtenIn(read)\n const printed = filled === null ? null : new TextEncoder().encode(filled)\n const digest = key ?? (printed ? computeBlobDigest(printed) : undefined)\n const keyed = digest ? { key: digest } : {}\n const renderKey = documentPdfKey(version, digest ? { digest } : undefined) as string\n const storage = requireStorage()\n const kept = await storage.getPdf({ projectId: runtime.projectId, renderKey })\n if (kept && !(\"failure\" in kept)) {\n return { status: \"ready\", file: kept.file, pages: kept.pages, ...keyed }\n }\n if (kept && (!pdfOptions.retry || key !== undefined)) {\n return { status: \"failed\", reason: kept.failure, ...keyed }\n }\n // The ask that gave the key asked for it to be printed.\n if (pdfOptions.print === false || key !== undefined) return { status: \"printing\", ...keyed }\n if (!options.rendersInSandboxes) {\n throw new ArtifactRequestError(\n \"pdf_unavailable\",\n \"[Sixb] A document prints to PDF in a sandbox, and this project has no sandbox provider.\"\n )\n }\n\n const document = printed\n ? await blobStorage.put({\n body: printed,\n fileName: DOCUMENT_HTML_ENTRY,\n mediaType: \"text/html\",\n })\n : undefined\n await requestDocumentPdf({ storage, queue: runtime.queues.renders }, version, {\n ...(document ? { document } : {}),\n retry: pdfOptions.retry === true,\n })\n return { status: \"printing\", ...keyed }\n },\n\n async media(artifactId, mediaOptions) {\n const read = await readVersion(artifactId, mediaOptions.version ?? \"latest\")\n if (!read) return null\n\n const { version } = read\n const file = version.files.find((candidate) => candidate.path === mediaOptions.path)\n if (!file || !isMediaFile(file)) {\n throw invalidArtifact(\n `Version ${version.version} of '${artifactId}' holds no video or sound at '${mediaOptions.path}'.`\n )\n }\n\n const storage = requireStorage()\n const media = { version: version.version, path: file.path, file: file.file }\n const [kept] = await storage.listMedia({\n projectId: runtime.projectId,\n digests: [file.file.digest],\n })\n if (!options.rendersInSandboxes) {\n const reason = \"This project has no sandboxes to derive it in.\"\n const lacking = { status: \"unavailable\", reason, lacks: \"sandboxes\" } as const\n return { ...media, parts: kept?.parts ?? unmadeMediaParts(() => lacking) }\n }\n\n const context = mediaContext(storage)\n if (kept && mediaOptions.retry) {\n return { ...media, parts: await retryArtifactMedia(context, kept, file.file) }\n }\n if (kept && mediaOptions.derive === false) return { ...media, parts: kept.parts }\n if (kept) return { ...media, parts: await refreshArtifactMedia(context, kept, file.file) }\n\n // Published before media were derived, or asked for when its job could not be: ask now.\n if (mediaOptions.derive !== false) await requestArtifactMedia(context, version)\n return { ...media, parts: unmadeMediaParts(() => ({ status: \"pending\" })) }\n },\n\n async video(artifactId, videoOptions = {}) {\n const read = await readVersion(artifactId, videoOptions.version ?? \"latest\")\n if (!read) return null\n\n const { version } = read\n const { outline } = version\n if (outline.kind !== \"video\") {\n throw invalidArtifact(\n `Version ${version.version} of '${artifactId}' is not a video, which alone renders to MP4.`\n )\n }\n\n // What it plays from other artifacts, as the caller reads them, is in its keys.\n const media = await resolveVideoMedia(version, (id, number) =>\n artifacts.getVersion(id, number)\n )\n const source = { outline, files: version.files, references: version.references, media }\n const plan = videoExportPlan(source)\n const storage = requireStorage()\n const kept = await storage.listVideoRenders({\n projectId: runtime.projectId,\n keys: videoExportKeys(plan),\n })\n const status = videoExportStatus(plan, kept)\n // How far it has come, what failed asked for again.\n const progress = () => videoExportProgress(plan, kept)\n if (status.status === \"ready\") {\n // Kept for every version made the same, it downloads named after this one's title.\n const fileName = `${titleFileName(version.title, \"Video\")}.mp4`\n return {\n status: \"ready\",\n file: { ...status.file, fileName },\n durationMs: outline.durationMs,\n sizeBytes: status.file.sizeBytes,\n }\n }\n if (status.status === \"failed\" && !videoOptions.retry) return status\n if (videoOptions.render === false) {\n // What its segments' keys hold may have been rendered for another video made in part the\n // same: only an ask says it renders.\n const asked = await storage.getVideoExportAsk({\n projectId: runtime.projectId,\n key: plan.key,\n })\n return asked ? { status: \"rendering\", progress: progress() } : { status: \"idle\" }\n }\n if (!options.rendersInSandboxes) {\n throw new ArtifactRequestError(\n \"video_unavailable\",\n \"[Sixb] A video renders to MP4 in sandboxes, and this project has no sandbox provider.\"\n )\n }\n\n const retry = status.status === \"failed\"\n await requestVideoExport({ storage, queue: runtime.queues.renders }, version, source, {\n plan,\n retry,\n })\n return { status: \"rendering\", progress: progress() }\n },\n\n async query(artifactId, name, options = {}) {\n const read = await readVersion(artifactId, options.version ?? \"latest\")\n if (!read) return null\n\n return runQuery(read, name)\n },\n\n async listVersions(artifactId, input = {}) {\n if (!(await getReadable(artifactId))) return null\n return requireStorage().listVersions({ projectId: runtime.projectId, artifactId, ...input })\n },\n\n async delete(artifactId) {\n if ((await reach(artifactId))?.access !== \"owner\") return false\n return requireStorage().delete({ projectId: runtime.projectId, id: artifactId })\n },\n\n state(artifactId) {\n // The reader is the caller; an observer reads the page but keeps nothing in it.\n const scope = async () => {\n const principal = requireCaller()\n await requireUpdatable(artifactId)\n return { projectId: runtime.projectId, artifactId, principal }\n }\n return {\n async get(key) {\n const entry = await requireStorage().getState({ ...(await scope()), key: stateKey(key) })\n return entry ? JSON.parse(entry.value) : undefined\n },\n async set(key, value) {\n const at = { ...(await scope()), key: stateKey(key) }\n const text = stateValue(value)\n const updatedAt = new Date()\n try {\n await requireStorage().setState({ ...at, value: text, updatedAt })\n } catch (error) {\n if (error instanceof ArtifactStorageError && error.code === \"artifact_state_full\") {\n throw new ArtifactRequestError(\"state_full\", error.message)\n }\n throw error\n }\n // As read back: what JSON keeps of it.\n return { key: at.key, value: JSON.parse(text), updatedAt }\n },\n async delete(key) {\n return requireStorage().deleteState({ ...(await scope()), key: stateKey(key) })\n },\n async entries() {\n const entries = await requireStorage().listState(await scope())\n return entries.map((entry) => ({\n key: entry.key,\n value: JSON.parse(entry.value),\n updatedAt: entry.updatedAt,\n }))\n },\n async clear() {\n return requireStorage().clearState(await scope())\n },\n }\n },\n }\n\n publishers.set(artifacts, {\n rule,\n transactionRules: () => transactionArtifactAccessRules(runtime),\n checkQuery,\n requestPreviews,\n writeLive,\n })\n return artifacts\n}\n\n/**\n * A key a page names a value by: a short line of text. Not `.` or `..`, which a page could never\n * reach: the API takes the key in its path, where those name another route.\n */\nfunction stateKey(key: string): string {\n if (\n typeof key !== \"string\" ||\n key.length === 0 ||\n key.length > ARTIFACT_STATE_LIMITS.maxKeyLength ||\n /\\p{Cc}/u.test(key) ||\n key === \".\" ||\n key === \"..\"\n ) {\n throw new ArtifactRequestError(\n \"invalid_state\",\n `[Sixb] A key is 1 to ${ARTIFACT_STATE_LIMITS.maxKeyLength} characters on one line, such as \"filters\".`\n )\n }\n return key\n}\n\n/** A value as JSON text, refused when JSON has no way to write it. */\nfunction stateValue(value: unknown): string {\n let text: string | undefined\n try {\n text = JSON.stringify(value)\n } catch {\n text = undefined\n }\n if (text === undefined) {\n throw new ArtifactRequestError(\n \"invalid_state\",\n \"[Sixb] A page keeps JSON values: text, numbers, true and false, null, lists, and objects of them.\"\n )\n }\n return text\n}\n\n/** What a query file holds for a query from the builders: its IR, with any facets by id. */\nfunction queryFile(query: ArtifactQueryInput): unknown {\n if (\"ir\" in query) return query.ir\n\n return {\n query: query.query.ir,\n facets: query.facets.map((facet) => ({ propertyId: facet.property.id, limit: facet.limit })),\n }\n}\n\n/** A holding as `holders` returns it: where it is, with the object's title when it has one. */\nfunction holderObject(runtime: SixbRuntimeContext, holding: ArtifactHolding): ArtifactHolderObject {\n const { objectTypeId, primaryId, propertyId, object } = holding\n const titleId = runtime.ontology.getObjectTypeById(objectTypeId)?.search?.title\n const value = titleId === undefined ? undefined : object.properties[titleId]\n const title = typeof value === \"string\" || typeof value === \"number\" ? String(value).trim() : \"\"\n\n return { objectTypeId, primaryId, propertyId, ...(title ? { title } : {}) }\n}\n\n/**\n * The guest a shared link's session comments as: the name its visitor gave, kept by the session.\n * Refused with `name_required` until they give one.\n */\nasync function sharedLinkGuest(\n runtime: SixbRuntimeContext,\n delegation: SharedAccessDelegationRef\n): Promise<ArtifactGuest> {\n const session = await runtime.storage.shareSessions?.getById({\n projectId: runtime.projectId,\n id: delegation.sessionId,\n })\n\n const name = session?.grantId === delegation.grantId ? session.guestName : undefined\n if (!name) {\n throw new ArtifactRequestError(\n \"name_required\",\n \"[Sixb] A shared link's guest gives their name before they comment.\"\n )\n }\n\n return { type: \"guest\", id: delegation.sessionId, name, grantId: delegation.grantId }\n}\n\nfunction notFound(artifactId: string): ArtifactRequestError {\n return new ArtifactRequestError(\n \"artifact_not_found\",\n `[Sixb] Artifact '${artifactId}' was not found.`\n )\n}\n"
|
|
34
|
+
],
|
|
35
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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