@sixb/core 0.1.15 → 0.1.17
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 +25 -25
- package/dist/actions/types/context.d.ts +2 -2
- package/dist/actions/types/context.d.ts.map +1 -1
- package/dist/actions/worker.js +1 -1
- package/dist/agents/index.js +41 -40
- package/dist/agents/index.js.map +1 -1
- package/dist/auth/index.js +5 -5
- package/dist/authorization/index.js +2 -2
- package/dist/blob-storage/download-urls.d.ts +41 -0
- package/dist/blob-storage/download-urls.d.ts.map +1 -0
- package/dist/blob-storage/execution.d.ts +9 -1
- package/dist/blob-storage/execution.d.ts.map +1 -1
- package/dist/blob-storage/index.js +5 -3
- package/dist/blob-storage/index.js.map +1 -1
- package/dist/blob-storage/internal.d.ts +2 -0
- package/dist/blob-storage/internal.d.ts.map +1 -0
- package/dist/blob-storage/internal.js +11 -0
- package/dist/blob-storage/internal.js.map +9 -0
- package/dist/bootstrap/index.js +45 -44
- package/dist/bootstrap/index.js.map +1 -1
- package/dist/{chunk-wem5vqjw.js → chunk-10styjgk.js} +18 -13
- package/dist/{chunk-wem5vqjw.js.map → chunk-10styjgk.js.map} +3 -3
- package/dist/{chunk-hgqpcmyr.js → chunk-1hqwggsn.js} +47 -19
- package/dist/chunk-1hqwggsn.js.map +12 -0
- package/dist/{chunk-q3grgzp1.js → chunk-23xs4qp9.js} +2 -2
- package/dist/{chunk-vef6qa14.js → chunk-2am3db31.js} +2 -2
- package/dist/{chunk-fj1dvp37.js → chunk-2vhg6ysa.js} +1 -1
- package/dist/{chunk-p0nbkys4.js → chunk-33saed7g.js} +1 -1
- package/dist/{chunk-mdnw7nj8.js → chunk-3rrezgyc.js} +33 -8
- package/dist/chunk-3rrezgyc.js.map +15 -0
- package/dist/{chunk-jgwb25gc.js → chunk-4as3wt1c.js} +13 -5
- package/dist/chunk-4as3wt1c.js.map +12 -0
- package/dist/chunk-4ra628t7.js +88 -0
- package/dist/chunk-4ra628t7.js.map +10 -0
- package/dist/{chunk-mmac1mp6.js → chunk-52c5zb0z.js} +2 -2
- package/dist/{chunk-8fjmqjyx.js → chunk-5be2ath4.js} +1 -1
- package/dist/{chunk-2fv8sajb.js → chunk-5thzcb8g.js} +2 -2
- package/dist/{chunk-fjw417jf.js → chunk-5yd8cchh.js} +1143 -784
- package/dist/chunk-5yd8cchh.js.map +66 -0
- package/dist/{chunk-2tz5vnvz.js → chunk-6wbm6ymz.js} +235 -41
- package/dist/{chunk-2tz5vnvz.js.map → chunk-6wbm6ymz.js.map} +8 -6
- package/dist/{chunk-py2dw8cw.js → chunk-7ecp4v7a.js} +26 -19
- package/dist/chunk-7ecp4v7a.js.map +17 -0
- package/dist/{chunk-f85hpqnm.js → chunk-99nd4rc1.js} +3 -3
- package/dist/{chunk-f85hpqnm.js.map → chunk-99nd4rc1.js.map} +3 -3
- package/dist/{chunk-1jvq82rp.js → chunk-9g6jz9kk.js} +5 -5
- package/dist/{chunk-39tqv9hz.js → chunk-9se093qz.js} +5 -6
- package/dist/{chunk-39tqv9hz.js.map → chunk-9se093qz.js.map} +3 -4
- package/dist/{chunk-8w27xf9e.js → chunk-a7er86jd.js} +1 -1
- package/dist/{chunk-zdkcdshk.js → chunk-aq39q04r.js} +41 -3
- package/dist/{chunk-zdkcdshk.js.map → chunk-aq39q04r.js.map} +4 -3
- package/dist/chunk-b9affek3.js +261 -0
- package/dist/chunk-b9affek3.js.map +12 -0
- package/dist/{chunk-bxx3ms5t.js → chunk-c2rga5cx.js} +2 -2
- package/dist/{chunk-dsfw1bdr.js → chunk-cnb5kv05.js} +2 -2
- package/dist/chunk-d62kjtbg.js.map +2 -2
- package/dist/{chunk-dqkd3kdj.js → chunk-dam456ve.js} +234 -35
- package/dist/{chunk-dqkd3kdj.js.map → chunk-dam456ve.js.map} +7 -5
- package/dist/{chunk-n5t4mq6z.js → chunk-e67ynxcr.js} +3 -3
- package/dist/{chunk-xnx96gfy.js → chunk-ere85b8y.js} +17 -8
- package/dist/chunk-ere85b8y.js.map +15 -0
- package/dist/{chunk-k4kkp58d.js → chunk-ewqa58h9.js} +12 -2
- package/dist/chunk-ewqa58h9.js.map +11 -0
- package/dist/{chunk-6q7c68yx.js → chunk-f1xh7a32.js} +3 -3
- package/dist/{chunk-z708gemf.js → chunk-fggq3d9k.js} +450 -799
- package/dist/chunk-fggq3d9k.js.map +49 -0
- package/dist/{chunk-7jc21943.js → chunk-gf7yht60.js} +4 -4
- package/dist/chunk-h8teetr0.js +9 -0
- package/dist/chunk-h8teetr0.js.map +10 -0
- package/dist/chunk-hn2r7z41.js.map +1 -1
- package/dist/{chunk-ffwvdgk1.js → chunk-jjrn5v0p.js} +1 -1
- package/dist/{chunk-r5sc1d2b.js → chunk-jnfxmr3f.js} +1 -1
- package/dist/{chunk-y0zmae99.js → chunk-k4g51s47.js} +3 -3
- package/dist/{chunk-a0073121.js → chunk-kpx7jrmn.js} +3 -1
- package/dist/chunk-kpx7jrmn.js.map +12 -0
- package/dist/{chunk-p1683c0v.js → chunk-kyjcwqz6.js} +5 -2
- package/dist/{chunk-p1683c0v.js.map → chunk-kyjcwqz6.js.map} +3 -3
- package/dist/{chunk-3c90jvfj.js → chunk-pja9jfz6.js} +742 -583
- package/dist/chunk-pja9jfz6.js.map +19 -0
- package/dist/chunk-pqajwytd.js.map +1 -1
- package/dist/{chunk-mr60an99.js → chunk-qczk96d9.js} +22 -2
- package/dist/{chunk-mr60an99.js.map → chunk-qczk96d9.js.map} +3 -3
- package/dist/{chunk-s3csryxe.js → chunk-rj69qcrd.js} +8 -2
- package/dist/chunk-rj69qcrd.js.map +11 -0
- package/dist/{chunk-d8yes9yx.js → chunk-rpxz486p.js} +32 -5
- package/dist/{chunk-d8yes9yx.js.map → chunk-rpxz486p.js.map} +4 -4
- package/dist/{chunk-drz59ve0.js → chunk-rx7h5fdx.js} +1 -1
- package/dist/{chunk-ky7zpbtt.js → chunk-s7ftxrdr.js} +106 -8
- package/dist/chunk-s7ftxrdr.js.map +22 -0
- package/dist/{chunk-yfppyaty.js → chunk-sk0hcjsz.js} +1 -1
- package/dist/{chunk-qne45xqq.js → chunk-svabwqdq.js} +2 -2
- package/dist/{chunk-xr7y35yj.js → chunk-t9shqx3w.js} +2 -2
- package/dist/{chunk-4jph1t3v.js → chunk-tjjgy3z4.js} +27 -24
- package/dist/{chunk-4jph1t3v.js.map → chunk-tjjgy3z4.js.map} +4 -4
- package/dist/{chunk-ex8s8wsk.js → chunk-vp3z1ckh.js} +42 -10
- package/dist/{chunk-ex8s8wsk.js.map → chunk-vp3z1ckh.js.map} +7 -6
- package/dist/{chunk-adbve9zt.js → chunk-vre348sb.js} +2 -2
- package/dist/{chunk-a4g5yjm0.js → chunk-w9yycd3t.js} +1 -1
- package/dist/{chunk-g4rbm4a6.js → chunk-wt4szfec.js} +379 -331
- package/dist/chunk-wt4szfec.js.map +14 -0
- package/dist/{chunk-wd34wnsy.js → chunk-xcy5ddha.js} +6 -6
- package/dist/{chunk-3nx8vj5a.js → chunk-xyvy73tj.js} +5 -3
- package/dist/chunk-xyvy73tj.js.map +12 -0
- package/dist/datasets/write.js +1 -1
- package/dist/execution/agent.js +38 -37
- package/dist/execution/agent.js.map +1 -1
- package/dist/execution/authorized-object-reader.d.ts +3 -1
- package/dist/execution/authorized-object-reader.d.ts.map +1 -1
- package/dist/execution/primitive.js +36 -35
- package/dist/execution/primitive.js.map +2 -2
- package/dist/execution/request.js +37 -36
- package/dist/execution/request.js.map +2 -2
- package/dist/index.d.ts +8 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +62 -59
- package/dist/index.js.map +1 -1
- package/dist/lake-storage/in-memory.d.ts +5 -1
- package/dist/lake-storage/in-memory.d.ts.map +1 -1
- package/dist/lake-storage/index.d.ts +1 -1
- package/dist/lake-storage/index.d.ts.map +1 -1
- package/dist/lake-storage/index.js +2 -2
- package/dist/lake-storage/types.d.ts +26 -0
- package/dist/lake-storage/types.d.ts.map +1 -1
- package/dist/maintenance/ontology-maintenance.d.ts +5 -1
- package/dist/maintenance/ontology-maintenance.d.ts.map +1 -1
- package/dist/maintenance/types.d.ts +1 -4
- package/dist/maintenance/types.d.ts.map +1 -1
- package/dist/materialization/event-envelopes.d.ts +20 -0
- package/dist/materialization/event-envelopes.d.ts.map +1 -0
- package/dist/materialization/events.d.ts +29 -3
- package/dist/materialization/events.d.ts.map +1 -1
- package/dist/materialization/index.d.ts +4 -1
- package/dist/materialization/index.d.ts.map +1 -1
- package/dist/materialization/index.js +9 -3
- package/dist/materialization/index.js.map +1 -1
- package/dist/materializer/edits/plan.d.ts +2 -10
- package/dist/materializer/edits/plan.d.ts.map +1 -1
- package/dist/materializer/effective/build-events.d.ts +5 -21
- package/dist/materializer/effective/build-events.d.ts.map +1 -1
- package/dist/materializer/effective/vector-indexing.d.ts +2 -3
- package/dist/materializer/effective/vector-indexing.d.ts.map +1 -1
- package/dist/materializer/effective/vectors.d.ts +2 -3
- package/dist/materializer/effective/vectors.d.ts.map +1 -1
- package/dist/materializer/execution/scope.d.ts +1 -11
- package/dist/materializer/execution/scope.d.ts.map +1 -1
- package/dist/materializer/execution/work-executor.d.ts +5 -7
- package/dist/materializer/execution/work-executor.d.ts.map +1 -1
- package/dist/materializer/execution/work-records.d.ts +1 -3
- package/dist/materializer/execution/work-records.d.ts.map +1 -1
- package/dist/materializer/index.js +31 -32
- package/dist/materializer/index.js.map +1 -1
- package/dist/materializer/projections/replace.d.ts.map +1 -1
- package/dist/materializer/projections/replacement-plan.d.ts +8 -11
- package/dist/materializer/projections/replacement-plan.d.ts.map +1 -1
- package/dist/materializer/shared/batching.d.ts +5 -0
- package/dist/materializer/shared/batching.d.ts.map +1 -1
- package/dist/materializer/telemetry/plan.d.ts +2 -8
- package/dist/materializer/telemetry/plan.d.ts.map +1 -1
- package/dist/models/audio/catalog.d.ts +20 -0
- package/dist/models/audio/catalog.d.ts.map +1 -0
- package/dist/models/audio/errors.d.ts +8 -0
- package/dist/models/audio/errors.d.ts.map +1 -0
- package/dist/models/audio/file.d.ts +9 -0
- package/dist/models/audio/file.d.ts.map +1 -0
- package/dist/models/audio/runtime.d.ts +8 -0
- package/dist/models/audio/runtime.d.ts.map +1 -0
- package/dist/models/audio/types.d.ts +60 -0
- package/dist/models/audio/types.d.ts.map +1 -0
- package/dist/models/catalog.d.ts +23 -1
- package/dist/models/catalog.d.ts.map +1 -1
- package/dist/models/definitions.d.ts +1 -1
- package/dist/models/definitions.d.ts.map +1 -1
- package/dist/models/embedding-model.d.ts +4 -0
- package/dist/models/embedding-model.d.ts.map +1 -1
- package/dist/models/events.d.ts +3 -0
- package/dist/models/events.d.ts.map +1 -1
- package/dist/models/execution/index.js +22 -22
- package/dist/models/execution/model-call-admission.d.ts +6 -1
- package/dist/models/execution/model-call-admission.d.ts.map +1 -1
- package/dist/models/execution/model-call-limits.d.ts.map +1 -1
- package/dist/models/execution/model-call-recorder.d.ts.map +1 -1
- package/dist/models/execution/reranking.d.ts +4 -0
- package/dist/models/execution/reranking.d.ts.map +1 -0
- package/dist/models/execution/usage.d.ts.map +1 -1
- package/dist/models/execution.d.ts +2 -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 +7 -1
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +7 -3
- package/dist/models/index.js.map +1 -1
- package/dist/models/pricing.d.ts +2 -2
- package/dist/models/pricing.d.ts.map +1 -1
- package/dist/models/reranking-model.d.ts +49 -0
- package/dist/models/reranking-model.d.ts.map +1 -0
- package/dist/objects/index.js +25 -25
- package/dist/objects/query/executor.d.ts +2 -1
- package/dist/objects/query/executor.d.ts.map +1 -1
- package/dist/objects/query/index.d.ts +1 -1
- package/dist/objects/query/index.d.ts.map +1 -1
- package/dist/objects/query/index.js +24 -24
- package/dist/objects/query/index.js.map +1 -1
- package/dist/objects/query/ir.d.ts +8 -1
- package/dist/objects/query/ir.d.ts.map +1 -1
- package/dist/objects/query/normalize.d.ts.map +1 -1
- package/dist/objects/query/planner.d.ts +1 -1
- package/dist/objects/query/planner.d.ts.map +1 -1
- package/dist/objects/query/primary-id.d.ts +7 -0
- package/dist/objects/query/primary-id.d.ts.map +1 -0
- package/dist/objects/query/reranking-executor.d.ts +13 -0
- package/dist/objects/query/reranking-executor.d.ts.map +1 -0
- package/dist/objects/query/reranking-limits.d.ts +3 -0
- package/dist/objects/query/reranking-limits.d.ts.map +1 -0
- package/dist/objects/query/reranking-query.d.ts +4 -0
- package/dist/objects/query/reranking-query.d.ts.map +1 -0
- package/dist/objects/query/validate.d.ts.map +1 -1
- package/dist/objects/sdk/query-builder.d.ts +8 -0
- package/dist/objects/sdk/query-builder.d.ts.map +1 -1
- package/dist/objects/sdk/query-executor.d.ts +2 -2
- package/dist/objects/sdk/query-executor.d.ts.map +1 -1
- package/dist/objects/sdk/runtime-query-executor.d.ts.map +1 -1
- package/dist/objects/vectors/indexing-dispatch.d.ts +21 -0
- package/dist/objects/vectors/indexing-dispatch.d.ts.map +1 -0
- package/dist/objects/vectors/indexing-generate.d.ts.map +1 -1
- package/dist/objects/vectors/profile.d.ts.map +1 -1
- package/dist/objects/vectors/query.d.ts +1 -1
- package/dist/objects/vectors/query.d.ts.map +1 -1
- package/dist/objects/vectors/resolve-query.d.ts.map +1 -1
- package/dist/objects/vectors/types.d.ts +1 -1
- package/dist/objects/vectors/types.d.ts.map +1 -1
- package/dist/ontology/builders.d.ts +13 -4
- package/dist/ontology/builders.d.ts.map +1 -1
- package/dist/ontology/index.d.ts +1 -1
- package/dist/ontology/index.d.ts.map +1 -1
- package/dist/ontology/index.js +3 -3
- package/dist/ontology/internal.js +2 -2
- package/dist/ontology/query-capabilities.d.ts +1 -0
- package/dist/ontology/query-capabilities.d.ts.map +1 -1
- package/dist/ontology/types.d.ts +20 -0
- package/dist/ontology/types.d.ts.map +1 -1
- package/dist/ontology/validation/query.d.ts.map +1 -1
- package/dist/ontology/vector-profiles.d.ts.map +1 -1
- package/dist/pipelines/index.js +23 -23
- package/dist/projections/internal.js +22 -22
- package/dist/query.d.ts +4 -2
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +2 -2
- package/dist/queues/in-memory.d.ts +3 -0
- package/dist/queues/in-memory.d.ts.map +1 -1
- package/dist/queues/index.js +1 -1
- package/dist/queues/types.d.ts +4 -0
- package/dist/queues/types.d.ts.map +1 -1
- package/dist/runtime/host.d.ts +1 -0
- package/dist/runtime/host.d.ts.map +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/internal.d.ts +1 -0
- package/dist/runtime/internal.d.ts.map +1 -1
- package/dist/runtime/internal.js +28 -26
- package/dist/runtime/internal.js.map +1 -1
- package/dist/runtime/public-origin.d.ts +10 -0
- package/dist/runtime/public-origin.d.ts.map +1 -0
- package/dist/runtime/sixb.d.ts +1 -0
- package/dist/runtime/sixb.d.ts.map +1 -1
- package/dist/runtime/types.d.ts +12 -2
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/sandboxes/index.js +5 -5
- package/dist/shares/internal.js +19 -19
- package/dist/storage/agents/provider.js +2 -2
- 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/provider.js +3 -3
- package/dist/storage/ai-cost/types.d.ts +1 -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 +2 -2
- package/dist/storage/ai-limits/in-memory.d.ts.map +1 -1
- package/dist/storage/ai-limits/provider.d.ts +7 -2
- package/dist/storage/ai-limits/provider.d.ts.map +1 -1
- package/dist/storage/ai-limits/provider.js +4 -2
- package/dist/storage/ai-limits/provider.js.map +1 -1
- package/dist/storage/ai-limits/types.d.ts +3 -0
- package/dist/storage/ai-limits/types.d.ts.map +1 -1
- package/dist/storage/ai-usage/record.d.ts.map +1 -1
- package/dist/storage/ai-usage/types.d.ts +8 -4
- package/dist/storage/ai-usage/types.d.ts.map +1 -1
- package/dist/storage/ai-usage/usage.d.ts.map +1 -1
- package/dist/storage/file-download-grants/in-memory.d.ts +11 -0
- package/dist/storage/file-download-grants/in-memory.d.ts.map +1 -0
- package/dist/storage/file-download-grants/index.d.ts +3 -0
- package/dist/storage/file-download-grants/index.d.ts.map +1 -0
- package/dist/storage/file-download-grants/record.d.ts +11 -0
- package/dist/storage/file-download-grants/record.d.ts.map +1 -0
- package/dist/storage/file-download-grants/types.d.ts +44 -0
- package/dist/storage/file-download-grants/types.d.ts.map +1 -0
- package/dist/storage/file-upload-sessions/provider.js +6 -6
- package/dist/storage/in-memory/index.d.ts +4 -0
- package/dist/storage/in-memory/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +5 -3
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +30 -30
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/internal.d.ts +1 -0
- package/dist/storage/internal.d.ts.map +1 -1
- package/dist/storage/internal.js +8 -4
- package/dist/storage/internal.js.map +1 -1
- package/dist/storage/migrations/index.d.ts +1 -1
- package/dist/storage/migrations/index.d.ts.map +1 -1
- package/dist/storage/migrations/migrate-storage.d.ts +3 -3
- package/dist/storage/migrations/migrate-storage.d.ts.map +1 -1
- package/dist/storage/migrations/types.d.ts +7 -0
- package/dist/storage/migrations/types.d.ts.map +1 -1
- package/dist/storage/objects/in-memory/query.d.ts.map +1 -1
- package/dist/storage/objects/in-memory/selected-reader.d.ts.map +1 -1
- package/dist/storage/objects/in-memory/storage.d.ts.map +1 -1
- package/dist/storage/objects/query-preparation.d.ts +39 -0
- package/dist/storage/objects/query-preparation.d.ts.map +1 -0
- package/dist/storage/objects/types.d.ts +2 -0
- package/dist/storage/objects/types.d.ts.map +1 -1
- package/dist/storage/ontology/commits.d.ts +1 -6
- package/dist/storage/ontology/commits.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/index.d.ts +4 -2
- package/dist/storage/ontology/in-memory/index.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/materializations-state.d.ts +0 -2
- package/dist/storage/ontology/in-memory/materializations-state.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/materializations-work.d.ts +1 -3
- package/dist/storage/ontology/in-memory/materializations-work.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/materializations.d.ts +23 -57
- package/dist/storage/ontology/in-memory/materializations.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/outbox.d.ts +3 -2
- package/dist/storage/ontology/in-memory/outbox.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/replacement-plans.d.ts +104 -0
- package/dist/storage/ontology/in-memory/replacement-plans.d.ts.map +1 -0
- package/dist/storage/ontology/in-memory/shared-state.d.ts +17 -2
- package/dist/storage/ontology/in-memory/shared-state.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/source-roots.d.ts +3 -1
- package/dist/storage/ontology/in-memory/source-roots.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/sources.d.ts +1 -2
- package/dist/storage/ontology/in-memory/sources.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/state-reader.d.ts +25 -0
- package/dist/storage/ontology/in-memory/state-reader.d.ts.map +1 -0
- package/dist/storage/ontology/index.d.ts +6 -3
- package/dist/storage/ontology/index.d.ts.map +1 -1
- package/dist/storage/ontology/materializations.d.ts +40 -59
- package/dist/storage/ontology/materializations.d.ts.map +1 -1
- package/dist/storage/ontology/outbox.d.ts +4 -6
- package/dist/storage/ontology/outbox.d.ts.map +1 -1
- package/dist/storage/ontology/provider-work.d.ts +114 -3
- package/dist/storage/ontology/provider-work.d.ts.map +1 -1
- package/dist/storage/ontology/provider.d.ts +14 -39
- package/dist/storage/ontology/provider.d.ts.map +1 -1
- package/dist/storage/ontology/provider.js +26 -12
- package/dist/storage/ontology/provider.js.map +1 -1
- package/dist/storage/ontology/replacement-plans.d.ts +103 -0
- package/dist/storage/ontology/replacement-plans.d.ts.map +1 -0
- package/dist/storage/ontology/sources.d.ts +0 -8
- package/dist/storage/ontology/sources.d.ts.map +1 -1
- package/dist/storage/operation-scope.d.ts.map +1 -1
- package/dist/storage/operation-scope.js +1 -1
- package/dist/storage/projection-runs/in-memory.d.ts.map +1 -1
- package/dist/storage/projection-runs/types.d.ts +2 -0
- package/dist/storage/projection-runs/types.d.ts.map +1 -1
- package/dist/storage/types.d.ts +2 -0
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/storage/workflow-runs/provider.js +6 -6
- package/dist/syncs/index.js +24 -24
- package/dist/testing/ai-cost-storage-contract.d.ts.map +1 -1
- package/dist/testing/ai-limit-storage-contract.d.ts.map +1 -1
- package/dist/testing/ai-usage-storage-contract.d.ts.map +1 -1
- package/dist/testing/file-download-grant-storage-contract.d.ts +9 -0
- package/dist/testing/file-download-grant-storage-contract.d.ts.map +1 -0
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +2548 -1489
- package/dist/testing/index.js.map +14 -13
- package/dist/testing/lake-storage-contract.d.ts.map +1 -1
- package/dist/testing/materializer-storage-contract.d.ts +14 -0
- package/dist/testing/materializer-storage-contract.d.ts.map +1 -1
- package/dist/testing/object-read-scope-contract.d.ts.map +1 -1
- package/dist/testing/ontology-contract-fixture.d.ts +5 -1
- package/dist/testing/ontology-contract-fixture.d.ts.map +1 -1
- package/dist/testing/ontology-storage-contract.d.ts.map +1 -1
- package/dist/testing/projection-run-storage-contract.d.ts.map +1 -1
- package/dist/testing/queues-contract.d.ts.map +1 -1
- package/dist/webhooks/internal.js +20 -20
- package/dist/workers/index.js +15 -17
- package/dist/workers/index.js.map +3 -3
- package/dist/workers/queue-worker.d.ts +3 -2
- package/dist/workers/queue-worker.d.ts.map +1 -1
- package/dist/workflows/index.js +42 -41
- package/dist/workflows/index.js.map +1 -1
- package/package.json +7 -1
- package/src/actions/types/context.ts +5 -2
- package/src/blob-storage/download-urls.ts +138 -0
- package/src/blob-storage/execution.ts +32 -1
- package/src/blob-storage/internal.ts +1 -0
- package/src/execution/authorized-object-reader.ts +8 -1
- package/src/index.ts +25 -0
- package/src/lake-storage/in-memory.ts +38 -9
- package/src/lake-storage/index.ts +2 -0
- package/src/lake-storage/types.ts +30 -0
- package/src/maintenance/ontology-maintenance.ts +50 -23
- package/src/maintenance/types.ts +1 -4
- package/src/materialization/event-envelopes.ts +168 -0
- package/src/materialization/events.ts +40 -4
- package/src/materialization/index.ts +9 -1
- package/src/materializer/README.md +55 -10
- package/src/materializer/edits/commit.ts +3 -19
- package/src/materializer/edits/plan.ts +20 -71
- package/src/materializer/effective/build-events.ts +42 -136
- package/src/materializer/effective/vector-indexing.ts +2 -3
- package/src/materializer/effective/vectors.ts +2 -3
- package/src/materializer/execution/scope.ts +1 -38
- package/src/materializer/execution/work-executor.ts +21 -115
- package/src/materializer/execution/work-records.ts +0 -15
- package/src/materializer/projections/replace.ts +106 -63
- package/src/materializer/projections/replacement-plan.ts +73 -218
- package/src/materializer/shared/batching.ts +7 -0
- package/src/materializer/telemetry/append.ts +2 -14
- package/src/materializer/telemetry/plan.ts +6 -43
- package/src/models/audio/catalog.ts +90 -0
- package/src/models/audio/errors.ts +19 -0
- package/src/models/audio/file.ts +78 -0
- package/src/models/audio/runtime.ts +182 -0
- package/src/models/audio/types.ts +69 -0
- package/src/models/catalog.ts +52 -5
- package/src/models/definitions.ts +8 -1
- package/src/models/embedding-model.ts +12 -0
- package/src/models/events.ts +3 -0
- package/src/models/execution/README.md +20 -1
- package/src/models/execution/embedding.ts +5 -1
- package/src/models/execution/model-call-admission.ts +6 -1
- package/src/models/execution/model-call-limits.ts +21 -11
- package/src/models/execution/model-call-recorder.ts +1 -0
- package/src/models/execution/model-call-recovery.ts +1 -0
- package/src/models/execution/reranking.ts +137 -0
- package/src/models/execution/usage.ts +1 -0
- package/src/models/execution.ts +5 -1
- package/src/models/generation-types.ts +2 -0
- package/src/models/index.ts +32 -0
- package/src/models/pricing.ts +2 -1
- package/src/models/reranking-model.ts +114 -0
- package/src/objects/query/executor.ts +42 -2
- package/src/objects/query/explain.ts +8 -0
- package/src/objects/query/index.ts +1 -0
- package/src/objects/query/ir.ts +10 -0
- package/src/objects/query/normalize.ts +2 -0
- package/src/objects/query/planner.ts +12 -1
- package/src/objects/query/primary-id.ts +56 -0
- package/src/objects/query/reranking-executor.ts +91 -0
- package/src/objects/query/reranking-limits.ts +3 -0
- package/src/objects/query/reranking-query.ts +8 -0
- package/src/objects/query/validate.ts +33 -10
- package/src/objects/sdk/query-builder.ts +15 -2
- package/src/objects/sdk/query-executor.ts +2 -2
- package/src/objects/sdk/runtime-query-executor.ts +7 -4
- package/src/objects/vectors/README.md +14 -2
- package/src/objects/vectors/handle.ts +1 -1
- package/src/objects/vectors/indexing-dispatch.ts +83 -0
- package/src/objects/vectors/indexing-generate.ts +5 -1
- package/src/objects/vectors/profile.ts +2 -0
- package/src/objects/vectors/query.ts +21 -4
- package/src/objects/vectors/resolve-query.ts +9 -5
- package/src/objects/vectors/types.ts +3 -1
- package/src/ontology/builders.ts +22 -7
- package/src/ontology/index.ts +2 -0
- package/src/ontology/query-capabilities.ts +1 -1
- package/src/ontology/types.ts +21 -0
- package/src/ontology/validation/query.ts +57 -0
- package/src/ontology/vector-profiles.ts +1 -0
- package/src/query.ts +4 -0
- package/src/queues/in-memory.ts +54 -19
- package/src/queues/types.ts +4 -0
- package/src/runtime/host.ts +28 -1
- package/src/runtime/index.ts +1 -0
- package/src/runtime/internal.ts +1 -0
- package/src/runtime/public-origin.ts +33 -0
- package/src/runtime/sixb.ts +13 -2
- package/src/runtime/types.ts +12 -2
- package/src/storage/ai-cost/analytics.ts +2 -0
- package/src/storage/ai-cost/codec.ts +2 -1
- package/src/storage/ai-cost/types.ts +1 -0
- package/src/storage/ai-cost/validation.ts +21 -8
- package/src/storage/ai-limits/in-memory.ts +10 -2
- package/src/storage/ai-limits/provider.ts +29 -2
- package/src/storage/ai-limits/types.ts +3 -0
- package/src/storage/ai-usage/record.ts +9 -0
- package/src/storage/ai-usage/types.ts +8 -4
- package/src/storage/ai-usage/usage.ts +2 -0
- package/src/storage/file-download-grants/in-memory.ts +73 -0
- package/src/storage/file-download-grants/index.ts +8 -0
- package/src/storage/file-download-grants/record.ts +47 -0
- package/src/storage/file-download-grants/types.ts +48 -0
- package/src/storage/in-memory/index.ts +13 -2
- package/src/storage/index.ts +31 -13
- package/src/storage/internal.ts +1 -0
- package/src/storage/migrations/index.ts +1 -0
- package/src/storage/migrations/migrate-storage.ts +36 -12
- package/src/storage/migrations/types.ts +8 -0
- package/src/storage/objects/in-memory/query.ts +2 -0
- package/src/storage/objects/in-memory/selected-reader.ts +1 -0
- package/src/storage/objects/in-memory/storage.ts +1 -0
- package/src/storage/objects/query-preparation.ts +77 -0
- package/src/storage/objects/types.ts +2 -0
- package/src/storage/ontology/commits.ts +1 -6
- package/src/storage/ontology/in-memory/index.ts +28 -9
- package/src/storage/ontology/in-memory/materializations-finalization.ts +35 -68
- package/src/storage/ontology/in-memory/materializations-state.ts +0 -22
- package/src/storage/ontology/in-memory/materializations-work.ts +0 -45
- package/src/storage/ontology/in-memory/materializations.ts +172 -653
- package/src/storage/ontology/in-memory/outbox.ts +37 -29
- package/src/storage/ontology/in-memory/replacement-plans.ts +697 -0
- package/src/storage/ontology/in-memory/shared-state.ts +24 -2
- package/src/storage/ontology/in-memory/source-roots.ts +7 -2
- package/src/storage/ontology/in-memory/sources.ts +7 -33
- package/src/storage/ontology/in-memory/state-reader.ts +245 -0
- package/src/storage/ontology/index.ts +19 -13
- package/src/storage/ontology/materializations.ts +45 -74
- package/src/storage/ontology/outbox.ts +4 -7
- package/src/storage/ontology/provider-header-validation.ts +0 -57
- package/src/storage/ontology/provider-work.ts +381 -90
- package/src/storage/ontology/provider.ts +74 -171
- package/src/storage/ontology/replacement-plans.ts +117 -0
- package/src/storage/ontology/sources.ts +0 -12
- package/src/storage/operation-scope.ts +33 -1
- package/src/storage/projection-runs/in-memory.ts +7 -1
- package/src/storage/projection-runs/types.ts +2 -0
- package/src/storage/types.ts +2 -0
- package/src/testing/ai-cost-storage-contract.ts +1 -0
- package/src/testing/ai-limit-storage-contract.ts +62 -0
- package/src/testing/ai-usage-storage-contract.ts +31 -0
- package/src/testing/file-download-grant-storage-contract.ts +139 -0
- package/src/testing/index.ts +4 -0
- package/src/testing/lake-storage-contract.ts +87 -1
- package/src/testing/materializer-storage-contract.ts +1008 -1
- package/src/testing/object-read-scope-contract.ts +1 -0
- package/src/testing/ontology-contract-fixture.ts +11 -87
- package/src/testing/ontology-storage-contract.ts +70 -39
- package/src/testing/projection-run-storage-contract.ts +14 -0
- package/src/testing/queues-contract.ts +59 -0
- package/src/workers/queue-worker.ts +19 -16
- package/dist/chunk-3c90jvfj.js.map +0 -15
- package/dist/chunk-3nx8vj5a.js.map +0 -12
- package/dist/chunk-7ytf06d3.js +0 -113
- package/dist/chunk-7ytf06d3.js.map +0 -10
- package/dist/chunk-a0073121.js.map +0 -12
- package/dist/chunk-fjw417jf.js.map +0 -62
- package/dist/chunk-g4rbm4a6.js.map +0 -15
- package/dist/chunk-hgqpcmyr.js.map +0 -12
- package/dist/chunk-jgwb25gc.js.map +0 -12
- package/dist/chunk-k4kkp58d.js.map +0 -11
- package/dist/chunk-ky7zpbtt.js.map +0 -19
- package/dist/chunk-mdnw7nj8.js.map +0 -15
- package/dist/chunk-py2dw8cw.js.map +0 -17
- package/dist/chunk-s3csryxe.js.map +0 -11
- package/dist/chunk-xnx96gfy.js.map +0 -15
- package/dist/chunk-z708gemf.js.map +0 -50
- package/dist/materializer/execution/plan-stream.d.ts +0 -8
- package/dist/materializer/execution/plan-stream.d.ts.map +0 -1
- package/src/materializer/execution/plan-stream.ts +0 -121
- /package/dist/{chunk-q3grgzp1.js.map → chunk-23xs4qp9.js.map} +0 -0
- /package/dist/{chunk-vef6qa14.js.map → chunk-2am3db31.js.map} +0 -0
- /package/dist/{chunk-fj1dvp37.js.map → chunk-2vhg6ysa.js.map} +0 -0
- /package/dist/{chunk-p0nbkys4.js.map → chunk-33saed7g.js.map} +0 -0
- /package/dist/{chunk-mmac1mp6.js.map → chunk-52c5zb0z.js.map} +0 -0
- /package/dist/{chunk-8fjmqjyx.js.map → chunk-5be2ath4.js.map} +0 -0
- /package/dist/{chunk-2fv8sajb.js.map → chunk-5thzcb8g.js.map} +0 -0
- /package/dist/{chunk-1jvq82rp.js.map → chunk-9g6jz9kk.js.map} +0 -0
- /package/dist/{chunk-8w27xf9e.js.map → chunk-a7er86jd.js.map} +0 -0
- /package/dist/{chunk-bxx3ms5t.js.map → chunk-c2rga5cx.js.map} +0 -0
- /package/dist/{chunk-dsfw1bdr.js.map → chunk-cnb5kv05.js.map} +0 -0
- /package/dist/{chunk-n5t4mq6z.js.map → chunk-e67ynxcr.js.map} +0 -0
- /package/dist/{chunk-6q7c68yx.js.map → chunk-f1xh7a32.js.map} +0 -0
- /package/dist/{chunk-7jc21943.js.map → chunk-gf7yht60.js.map} +0 -0
- /package/dist/{chunk-ffwvdgk1.js.map → chunk-jjrn5v0p.js.map} +0 -0
- /package/dist/{chunk-r5sc1d2b.js.map → chunk-jnfxmr3f.js.map} +0 -0
- /package/dist/{chunk-y0zmae99.js.map → chunk-k4g51s47.js.map} +0 -0
- /package/dist/{chunk-drz59ve0.js.map → chunk-rx7h5fdx.js.map} +0 -0
- /package/dist/{chunk-yfppyaty.js.map → chunk-sk0hcjsz.js.map} +0 -0
- /package/dist/{chunk-qne45xqq.js.map → chunk-svabwqdq.js.map} +0 -0
- /package/dist/{chunk-xr7y35yj.js.map → chunk-t9shqx3w.js.map} +0 -0
- /package/dist/{chunk-adbve9zt.js.map → chunk-vre348sb.js.map} +0 -0
- /package/dist/{chunk-a4g5yjm0.js.map → chunk-w9yycd3t.js.map} +0 -0
- /package/dist/{chunk-wd34wnsy.js.map → chunk-xcy5ddha.js.map} +0 -0
|
@@ -4,25 +4,26 @@ import {
|
|
|
4
4
|
isSixbError2
|
|
5
5
|
} from "./chunk-6fsr7y93.js";
|
|
6
6
|
import {
|
|
7
|
-
AiLimitStorageError2
|
|
8
|
-
|
|
7
|
+
AiLimitStorageError2,
|
|
8
|
+
aiLimitMeterApplies2
|
|
9
|
+
} from "./chunk-4as3wt1c.js";
|
|
9
10
|
import {
|
|
10
11
|
aiLimitSubjectsFromAttribution2,
|
|
11
12
|
applicableAiLimitPolicies2,
|
|
12
13
|
aiUsageLimitExceededError2,
|
|
13
14
|
aiUsageLimitUnavailableError2
|
|
14
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-2vhg6ysa.js";
|
|
15
16
|
import {
|
|
16
17
|
AiUsageStorageError2,
|
|
17
18
|
normalizeAiModelCallCostRecord2,
|
|
18
19
|
aiModelCallCostMatchesUsage2
|
|
19
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-ere85b8y.js";
|
|
20
21
|
import {
|
|
21
22
|
AiCostStorageError2
|
|
22
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-5yd8cchh.js";
|
|
23
24
|
import {
|
|
24
25
|
normalizeAiModelCallRecord2
|
|
25
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-rj69qcrd.js";
|
|
26
27
|
import {
|
|
27
28
|
assertJsonObject2
|
|
28
29
|
} from "./chunk-wy0qdqfm.js";
|
|
@@ -37,7 +38,7 @@ function createAiModelCallLimitController2(input) {
|
|
|
37
38
|
const policies = await input.storage.aiLimits.listPolicies({
|
|
38
39
|
projectId: input.projectId
|
|
39
40
|
});
|
|
40
|
-
applicable = applicableAiLimitPolicies2(policies, subjects);
|
|
41
|
+
applicable = applicableAiLimitPolicies2(policies, subjects).filter((policy) => aiLimitMeterApplies2(policy.limit.meter, admission.modelKind));
|
|
41
42
|
} catch (error) {
|
|
42
43
|
throw limitStorageUnavailable(error);
|
|
43
44
|
}
|
|
@@ -52,7 +53,8 @@ function createAiModelCallLimitController2(input) {
|
|
|
52
53
|
result = await input.storage.aiLimits.reserveModelCall({
|
|
53
54
|
...reservationIdentity(admission),
|
|
54
55
|
subjects,
|
|
55
|
-
estimates
|
|
56
|
+
estimates,
|
|
57
|
+
...admission.modelKind === undefined ? {} : { modelKind: admission.modelKind }
|
|
56
58
|
});
|
|
57
59
|
} catch (error) {
|
|
58
60
|
throw limitStorageUnavailable(error);
|
|
@@ -80,20 +82,22 @@ function createAiModelCallLimitController2(input) {
|
|
|
80
82
|
};
|
|
81
83
|
}
|
|
82
84
|
function reservationEstimates(input, needsCost) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
+
const estimates = [];
|
|
86
|
+
if (input.inputTokens.status === "estimated" && input.estimatedTotalTokens !== undefined) {
|
|
87
|
+
estimates.push({ meter: "tokens.total", amount: input.estimatedTotalTokens });
|
|
85
88
|
}
|
|
86
|
-
const estimates = [
|
|
87
|
-
{ meter: "tokens.total", amount: input.estimatedTotalTokens }
|
|
88
|
-
];
|
|
89
89
|
if (needsCost) {
|
|
90
90
|
try {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
91
|
+
let money = input.reservationCost;
|
|
92
|
+
if (money == null && input.inputTokens.status === "estimated") {
|
|
93
|
+
money = input.costEstimator?.estimateReservation?.({
|
|
94
|
+
inputTokens: input.inputTokens.tokens,
|
|
95
|
+
outputTokens: input.outputTokenAllowance
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
if (money) {
|
|
96
99
|
estimates.push({ meter: "cost.catalogEstimated", amount: money });
|
|
100
|
+
}
|
|
97
101
|
} catch {
|
|
98
102
|
return estimates;
|
|
99
103
|
}
|
|
@@ -263,6 +267,7 @@ function requireAccountingCapabilities(storage) {
|
|
|
263
267
|
// src/models/execution/usage.ts
|
|
264
268
|
function aiModelCallUsageFromModel(usage) {
|
|
265
269
|
return {
|
|
270
|
+
...usage.audioDurationMs === undefined ? {} : { audioDurationMs: usage.audioDurationMs },
|
|
266
271
|
...usage.inputTokens === undefined ? {} : { inputTokens: usage.inputTokens },
|
|
267
272
|
...usage.outputTokens === undefined ? {} : { outputTokens: usage.outputTokens },
|
|
268
273
|
...usage.uncachedInputTokens === undefined ? {} : { uncachedInputTokens: usage.uncachedInputTokens },
|
|
@@ -305,6 +310,7 @@ function toQueuePayload(record) {
|
|
|
305
310
|
providerId: record.providerId,
|
|
306
311
|
...record.providerIds === undefined ? {} : { providerIds: structuredClone(record.providerIds) },
|
|
307
312
|
requestedModelId: record.requestedModelId,
|
|
313
|
+
...record.modelKind === undefined ? {} : { modelKind: record.modelKind },
|
|
308
314
|
...record.requestedReasoning === undefined ? {} : { requestedReasoning: structuredClone(record.requestedReasoning) },
|
|
309
315
|
...record.responseModelId === undefined ? {} : { responseModelId: record.responseModelId },
|
|
310
316
|
responseId: record.responseId,
|
|
@@ -501,6 +507,7 @@ class AiModelCallRecorder2 {
|
|
|
501
507
|
providerId: event.providerId,
|
|
502
508
|
...event.providerIds === undefined ? {} : { providerIds: event.providerIds },
|
|
503
509
|
requestedModelId: event.modelId,
|
|
510
|
+
...event.modelKind === undefined ? {} : { modelKind: event.modelKind },
|
|
504
511
|
...event.requestedReasoning === undefined ? {} : { requestedReasoning: event.requestedReasoning },
|
|
505
512
|
...event.responseModelId === undefined ? {} : { responseModelId: event.responseModelId },
|
|
506
513
|
responseId: event.responseId,
|
|
@@ -585,4 +592,4 @@ async function enqueueAiModelCallRecovery2(queue, input) {
|
|
|
585
592
|
|
|
586
593
|
export { AI_MODEL_CALL_OUTPUT_TOKEN_ALLOWANCE, aiModelCallOutputTokenAllowance, requireAccountingCapabilities, createAiModelCallLimitController2, ModelUsageRecordingError2, recordRecoveredAiModelCall2, isPermanentAiUsageRecoveryError2, AiModelCallRecorder2, enqueueAiModelCallRecovery2 };
|
|
587
594
|
|
|
588
|
-
//# debugId=
|
|
595
|
+
//# debugId=723C9B221336858664756E2164756E21
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/models/execution/model-call-limits.ts", "../src/models/execution/errors.ts", "../src/models/execution/model-call-accounting.ts", "../src/models/execution/usage.ts", "../src/models/execution/model-call-recovery.ts", "../src/models/execution/model-call-recorder.ts", "../src/models/execution/model-call-admission.ts", "../src/models/execution/recovery-queue.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { isSixbError } from \"../../errors/internal\"\nimport type { AuthorizablePrincipal } from \"../../execution\"\nimport type {\n AiLimitPolicy,\n AiLimitQuantity,\n AiModelCallReservationIdentity,\n ReserveAiModelCallResult,\n} from \"../../storage\"\nimport {\n aiLimitSubjectsFromAttribution,\n aiUsageLimitExceededError,\n aiUsageLimitUnavailableError,\n applicableAiLimitPolicies,\n} from \"../../storage/ai-limits/enforcement\"\nimport { aiLimitMeterApplies } from \"../../storage/ai-limits/provider\"\nimport type {\n AiModelCallAdmissionDecision,\n AiModelCallAdmissionInput,\n BeforeAiModelCall,\n MarkAiModelCallUnknown,\n} from \"./model-call-admission\"\nimport type { ModelCallAccountingStorage } from \"./types\"\n\nexport interface AiModelCallLimitController {\n readonly beforeModelCall: BeforeAiModelCall\n readonly markModelCallUnknown: MarkAiModelCallUnknown\n}\n\n/** Build the reservation lifecycle for model calls from any execution. */\nexport function createAiModelCallLimitController(input: {\n readonly storage: Pick<ModelCallAccountingStorage, \"aiLimits\">\n readonly projectId: string\n readonly requestedBy?: AuthorizablePrincipal\n readonly requesterGroupIds: readonly string[]\n}): AiModelCallLimitController {\n const subjects = aiLimitSubjectsFromAttribution(input.requestedBy, input.requesterGroupIds)\n\n return {\n beforeModelCall: async (admission) => {\n let applicable: readonly AiLimitPolicy[]\n try {\n const policies = await input.storage.aiLimits.listPolicies({\n projectId: input.projectId,\n })\n applicable = applicableAiLimitPolicies(policies, subjects).filter((policy) =>\n aiLimitMeterApplies(policy.limit.meter, admission.modelKind)\n )\n } catch (error) {\n throw limitStorageUnavailable(error)\n }\n // This read is the fast no-policy path. A concurrently created policy linearizes after it;\n // every later call will see it, while existing policies always continue to atomic reserve.\n if (applicable.length === 0) return { reservation: \"none\" }\n\n const estimates = reservationEstimates(\n admission,\n applicable.some((policy) => policy.limit.meter === \"cost.catalogEstimated\")\n )\n if (estimates.length === 0) {\n throw aiUsageLimitUnavailableError([\"missingEstimate\"])\n }\n\n let result: ReserveAiModelCallResult\n try {\n result = await input.storage.aiLimits.reserveModelCall({\n ...reservationIdentity(admission),\n subjects,\n estimates,\n ...(admission.modelKind === undefined ? {} : { modelKind: admission.modelKind }),\n })\n } catch (error) {\n throw limitStorageUnavailable(error)\n }\n switch (result.status) {\n case \"reserved\":\n return { reservation: \"active\" } satisfies AiModelCallAdmissionDecision\n case \"notRequired\":\n return { reservation: \"none\" } satisfies AiModelCallAdmissionDecision\n case \"denied\":\n throw aiUsageLimitExceededError(result.resetAt)\n case \"unavailable\":\n throw aiUsageLimitUnavailableError(result.reasons)\n case \"terminal\":\n throw aiUsageLimitUnavailableError([\"terminalReservationReplay\"])\n }\n },\n markModelCallUnknown: async (identity) => {\n try {\n await input.storage.aiLimits.markReservationUnknown(identity)\n } catch (error) {\n throw limitStorageUnavailable(error)\n }\n },\n }\n}\n\nfunction reservationEstimates(\n input: AiModelCallAdmissionInput,\n needsCost: boolean\n): readonly AiLimitQuantity[] {\n const estimates: AiLimitQuantity[] = []\n if (input.inputTokens.status === \"estimated\" && input.estimatedTotalTokens !== undefined) {\n estimates.push({ meter: \"tokens.total\", amount: input.estimatedTotalTokens })\n }\n\n if (needsCost) {\n try {\n let money = input.reservationCost\n if (money == null && input.inputTokens.status === \"estimated\") {\n money = input.costEstimator?.estimateReservation?.({\n inputTokens: input.inputTokens.tokens,\n outputTokens: input.outputTokenAllowance,\n })\n }\n\n if (money) {\n estimates.push({ meter: \"cost.catalogEstimated\", amount: money })\n }\n } catch {\n // An unavailable price must not prevent a token-only policy from being evaluated.\n return estimates\n }\n }\n\n return estimates\n}\n\nfunction reservationIdentity(input: AiModelCallAdmissionInput): AiModelCallReservationIdentity {\n return {\n projectId: input.projectId,\n executionId: input.executionId,\n attempt: input.attempt,\n callId: input.callId,\n }\n}\n\nfunction limitStorageUnavailable(error: unknown): unknown {\n if (\n isSixbError(error) &&\n (error.code === \"ai.usage_limit_exceeded\" || error.code === \"ai.usage_limit_unavailable\")\n ) {\n return error\n }\n return aiUsageLimitUnavailableError([\"limitStorageUnavailable\"])\n}\n",
|
|
6
|
+
"/** A provider call was not recorded synchronously, so its execution must stop. */\nexport class ModelUsageRecordingError extends Error {\n readonly name = \"ModelUsageRecordingError\"\n\n constructor(\n readonly executionId: string,\n readonly callId: string,\n readonly recoveryScheduled: boolean,\n options?: ErrorOptions\n ) {\n super(\n recoveryScheduled\n ? `[SixbModels] AI usage for call '${callId}' in execution '${executionId}' was deferred to durable recovery.`\n : `[SixbModels] Could not preserve AI usage for call '${callId}' in execution '${executionId}'.`,\n options\n )\n }\n}\n",
|
|
7
|
+
"import { createHash } from \"node:crypto\"\nimport { assertJsonObject } from \"../../json\"\nimport type {\n AiBillableMeter,\n AiCostStorage,\n AiLimitStorage,\n AiModelCallCostRecord,\n AiModelCallUsageRecord,\n AiPricingContext,\n AiUsageStorage,\n RecordAiModelCallResult,\n Storage,\n} from \"../../storage\"\nimport {\n aiModelCallCostMatchesUsage,\n normalizeAiModelCallCostRecord,\n} from \"../../storage/ai-cost/provider\"\nimport { normalizeAiModelCallRecord } from \"../../storage/ai-usage/record\"\nimport type { ModelCostEstimate } from \"../pricing\"\nimport type { ModelCallAccountingStorage, RecoverAiModelCallInput } from \"./types\"\n\ninterface RecordAiModelCallAccountingInput extends RecoverAiModelCallInput {\n readonly storage: Pick<ModelCallAccountingStorage, \"transaction\">\n}\n\ninterface AiAccountingCapabilities {\n readonly aiUsage: AiUsageStorage\n readonly aiCosts: AiCostStorage\n readonly aiLimits: AiLimitStorage\n}\n\n/** Atomically append one provider call's usage and the valuation captured by the model runtime. */\nexport async function recordAiModelCallAccounting(\n input: RecordAiModelCallAccountingInput\n): Promise<RecordAiModelCallResult> {\n return input.storage.transaction(async (tx) => {\n const { aiUsage, aiCosts, aiLimits } = requireAccountingCapabilities(tx)\n const usage = await aiUsage.recordModelCall(input.usage)\n // Usage deduplicates provider lifecycle replays by execution/call identity. Always attach the\n // valuation to the canonical row it returns, not the fresh candidate ID from a replay.\n const canonical = normalizeModelCallAccounting({\n ...input,\n usage: usage.record,\n ratedAt: usage.record.recordedAt,\n })\n const record = modelCostRecord(canonical, usage.record.id)\n const estimate =\n canonical.cost.status !== \"reported\" || canonical.estimate === undefined\n ? undefined\n : modelCostRecord({ ...canonical, cost: canonical.estimate }, usage.record.id)\n await aiCosts.recordModelCallCost({\n ...record,\n ...(estimate === undefined\n ? {}\n : {\n estimate:\n estimate.status === \"rated\"\n ? { status: \"rated\", money: estimate.money, components: estimate.components }\n : {\n status: \"unpriceable\",\n reason: estimate.reason,\n ...(estimate.missingMeters === undefined\n ? {}\n : { missingMeters: estimate.missingMeters }),\n },\n }),\n })\n if (usage.created) {\n await aiLimits.recordModelCallActuals({\n projectId: usage.record.projectId,\n usageRecordId: usage.record.id,\n recordedAt: input.ratedAt,\n })\n }\n if (input.reconcileLimitReservation) {\n await aiLimits.reconcileModelCall({\n projectId: usage.record.projectId,\n executionId: usage.record.executionId,\n attempt: usage.record.attempt,\n callId: usage.record.callId,\n usageRecordId: usage.record.id,\n reconciledAt: input.ratedAt,\n })\n }\n return usage\n })\n}\n\n/** Sanitize optional enrichment before either persistence or a JSON-safe recovery handoff. */\nexport function normalizeModelCallAccounting(\n input: RecoverAiModelCallInput\n): RecoverAiModelCallInput {\n const usage = normalizeAiModelCallRecord(input.usage)\n return {\n ...input,\n cost:\n input.cost.status === \"reported\" ? input.cost : validatedEstimate(input.cost, input, usage),\n ...(input.estimate === undefined\n ? {}\n : { estimate: validatedEstimate(input.estimate, input, usage) }),\n }\n}\n\nfunction validatedEstimate(\n cost: ModelCostEstimate,\n input: RecoverAiModelCallInput,\n usage: AiModelCallUsageRecord\n): ModelCostEstimate {\n try {\n assertJsonObject(cost, \"model cost estimate\")\n const record = normalizeAiModelCallCostRecord(modelCostRecord({ ...input, cost }, usage.id))\n if (!aiModelCallCostMatchesUsage(record, usage)) {\n throw new TypeError(\"Estimate quantities do not match recorded usage.\")\n }\n return structuredClone(cost)\n } catch {\n console.warn(\n \"[SixbModels] Invalid model cost estimate; preserving call usage and provider cost.\"\n )\n return { status: \"unpriceable\", reason: \"inconsistent-usage\" }\n }\n}\n\nfunction modelCostRecord(\n input: RecoverAiModelCallInput,\n usageRecordId: string\n): AiModelCallCostRecord {\n const billingIdentity = {\n providerId: input.usage.providerId,\n modelId: input.usage.requestedModelId,\n }\n const pricingContext: AiPricingContext = {\n ...(input.route?.providerId === undefined ? {} : { routedProviderId: input.route.providerId }),\n ...(input.route?.modelId === undefined ? {} : { routedModelId: input.route.modelId }),\n }\n if (input.cost.status === \"reported\" || input.cost.status === \"rated\") {\n return {\n projectId: input.usage.projectId,\n usageRecordId,\n status: \"rated\",\n billingIdentity,\n pricingContext,\n priceSource: costPriceSource(input.usage, input.cost),\n money: input.cost.money,\n components: input.cost.status === \"rated\" ? input.cost.components : [],\n ratedAt: new Date(input.ratedAt),\n }\n }\n\n const reason =\n input.cost.reason === \"missing-rate-card\"\n ? \"missingRateCard\"\n : input.cost.reason === \"missing-usage\"\n ? \"missingUsageMeter\"\n : \"invalidUsageForFormula\"\n const missingMeters =\n reason === \"missingUsageMeter\" ? normalizeMissingMeters(input.cost.missingMeters) : undefined\n return {\n projectId: input.usage.projectId,\n usageRecordId,\n status: \"unpriceable\",\n billingIdentity,\n pricingContext,\n reason,\n ...(missingMeters === undefined ? {} : { missingMeters }),\n ratedAt: new Date(input.ratedAt),\n }\n}\n\nfunction costPriceSource(\n usage: RecoverAiModelCallInput[\"usage\"],\n cost: Extract<RecoverAiModelCallInput[\"cost\"], { status: \"reported\" | \"rated\" }>\n) {\n if (cost.status === \"reported\") {\n return {\n sourceId: \"provider-reported\",\n sourceEntryId: `${usage.providerId}/${usage.responseId}`,\n sourceVersion: \"response-v1\",\n observedAt: new Date(usage.occurredAt),\n }\n }\n const rates = cost.components.map(({ meter, rateAmountNanosPerMillion }) => ({\n meter,\n rateAmountNanosPerMillion,\n }))\n const version = createHash(\"sha256\").update(JSON.stringify(rates)).digest(\"hex\")\n return {\n sourceId: \"model-rate-card\",\n sourceEntryId: `${usage.providerId}/${usage.requestedModelId}`,\n sourceVersion: `sha256:${version}`,\n observedAt: new Date(usage.occurredAt),\n }\n}\n\nfunction normalizeMissingMeters(\n meters: Extract<RecoverAiModelCallInput[\"cost\"], { status: \"unpriceable\" }>[\"missingMeters\"]\n): readonly AiBillableMeter[] {\n const fallback: readonly AiBillableMeter[] = [\"tokens.input.total\", \"tokens.output.total\"]\n return [...new Set<AiBillableMeter>(meters ?? fallback)]\n}\n\nexport function requireAccountingCapabilities(\n storage: Pick<Storage, \"aiUsage\" | \"aiCosts\" | \"aiLimits\">\n): AiAccountingCapabilities {\n if (!storage.aiUsage || !storage.aiCosts || !storage.aiLimits) {\n throw new Error(\n \"[SixbModels] AI model-call accounting requires storage.aiUsage, storage.aiCosts, and storage.aiLimits.\"\n )\n }\n return { aiUsage: storage.aiUsage, aiCosts: storage.aiCosts, aiLimits: storage.aiLimits }\n}\n",
|
|
8
|
+
"import type { AiModelCallUsageInput } from \"../../storage\"\nimport type { ModelUsage } from \"../events\"\n\n/** Map one provider-neutral model call into Sixb's durable accounting vocabulary. */\nexport function aiModelCallUsageFromModel(usage: ModelUsage): AiModelCallUsageInput {\n return {\n ...(usage.audioDurationMs === undefined ? {} : { audioDurationMs: usage.audioDurationMs }),\n ...(usage.inputTokens === undefined ? {} : { inputTokens: usage.inputTokens }),\n ...(usage.outputTokens === undefined ? {} : { outputTokens: usage.outputTokens }),\n ...(usage.uncachedInputTokens === undefined\n ? {}\n : { uncachedInputTokens: usage.uncachedInputTokens }),\n ...(usage.cacheReadInputTokens === undefined\n ? {}\n : { cacheReadInputTokens: usage.cacheReadInputTokens }),\n ...(usage.cacheWriteInputTokens === undefined\n ? {}\n : { cacheWriteInputTokens: usage.cacheWriteInputTokens }),\n ...(usage.textOutputTokens === undefined ? {} : { textOutputTokens: usage.textOutputTokens }),\n ...(usage.reasoningOutputTokens === undefined\n ? {}\n : { reasoningOutputTokens: usage.reasoningOutputTokens }),\n }\n}\n",
|
|
9
|
+
"import type { RecordAiModelCallInput, RecordAiModelCallResult } from \"../../storage\"\nimport { AiCostStorageError, AiLimitStorageError, AiUsageStorageError } from \"../../storage\"\nimport { normalizeAiModelCallRecord } from \"../../storage/ai-usage/record\"\nimport { recordAiModelCallAccounting } from \"./model-call-accounting\"\nimport type {\n AiModelCallAccountingPayload,\n AiModelCallRecordPayload,\n AiModelCallRecoveryRecord,\n ModelCallAccountingStorage,\n RecoverAiModelCallInput,\n} from \"./types\"\nimport { aiModelCallUsageFromModel } from \"./usage\"\n\nclass InvalidAiUsageRecoveryJobError extends Error {\n readonly name = \"InvalidAiUsageRecoveryJobError\"\n\n constructor(message: string, options?: ErrorOptions) {\n super(`[SixbModels] ${message}`, options)\n }\n}\n\n/** Encode one failed accounting transaction for a durable, JSON-safe handoff. */\nexport function modelCallRecoveryPayload(input: RecoverAiModelCallInput): {\n readonly record: AiModelCallRecordPayload\n readonly accounting: AiModelCallAccountingPayload\n} {\n normalizeAiModelCallRecord(input.usage)\n return {\n record: toQueuePayload(input.usage),\n accounting: toAccountingPayload(input),\n }\n}\n\n/** Replay one durable handoff through the idempotent atomic accounting boundary. */\nexport async function recordRecoveredAiModelCall(\n storage: Pick<ModelCallAccountingStorage, \"transaction\">,\n job: AiModelCallRecoveryRecord\n): Promise<RecordAiModelCallResult> {\n const usage = fromQueuePayload(job)\n const accounting = accountingFromQueuePayload(job)\n return recordAiModelCallAccounting({ storage, usage, ...accounting })\n}\n\n/** Validation and referential-integrity failures cannot become valid through queue redelivery. */\nexport function isPermanentAiUsageRecoveryError(error: unknown): boolean {\n return (\n error instanceof InvalidAiUsageRecoveryJobError ||\n error instanceof TypeError ||\n (error instanceof AiUsageStorageError &&\n (error.code === \"duplicate_id\" || error.code === \"missing_execution\")) ||\n (error instanceof AiCostStorageError &&\n (error.code === \"missing_usage\" || error.code === \"cost_mismatch\")) ||\n (error instanceof AiLimitStorageError &&\n (error.code === \"missing_execution\" ||\n error.code === \"missing_reservation\" ||\n error.code === \"missing_usage_record\" ||\n error.code === \"usage_mismatch\" ||\n error.code === \"reservation_conflict\" ||\n error.code === \"reconciliation_conflict\" ||\n error.code === \"invalid_reservation_state\"))\n )\n}\n\nfunction toQueuePayload(record: RecordAiModelCallInput): AiModelCallRecordPayload {\n return {\n id: record.id,\n executionId: record.executionId,\n attempt: record.attempt,\n callId: record.callId,\n requesterGroupIds: [...record.requesterGroupIds],\n providerId: record.providerId,\n ...(record.providerIds === undefined\n ? {}\n : { providerIds: structuredClone(record.providerIds) }),\n requestedModelId: record.requestedModelId,\n ...(record.modelKind === undefined ? {} : { modelKind: record.modelKind }),\n ...(record.requestedReasoning === undefined\n ? {}\n : { requestedReasoning: structuredClone(record.requestedReasoning) }),\n ...(record.responseModelId === undefined ? {} : { responseModelId: record.responseModelId }),\n responseId: record.responseId,\n usage: aiModelCallUsageFromModel(record.usage),\n ...(record.rawUsage === undefined ? {} : { rawUsage: structuredClone(record.rawUsage) }),\n occurredAt: record.occurredAt.toISOString(),\n }\n}\n\nfunction toAccountingPayload(input: RecoverAiModelCallInput): AiModelCallAccountingPayload {\n return {\n cost: structuredClone(input.cost),\n ...(input.estimate === undefined ? {} : { estimate: structuredClone(input.estimate) }),\n ...(input.route === undefined ? {} : { route: structuredClone(input.route) }),\n ratedAt: input.ratedAt.toISOString(),\n ...(input.reconcileLimitReservation ? { reconcileLimitReservation: true } : {}),\n }\n}\n\nfunction fromQueuePayload(job: AiModelCallRecoveryRecord): RecordAiModelCallInput {\n const occurredAt = parseDate(job.payload.record.occurredAt, job.id, \"occurredAt\")\n return { ...job.payload.record, projectId: job.projectId, occurredAt }\n}\n\nfunction accountingFromQueuePayload(\n job: AiModelCallRecoveryRecord\n): Omit<RecoverAiModelCallInput, \"usage\"> {\n const accounting = job.payload.accounting\n return {\n cost: structuredClone(accounting.cost),\n ...(accounting.estimate === undefined\n ? {}\n : { estimate: structuredClone(accounting.estimate) }),\n ...(accounting.route === undefined ? {} : { route: structuredClone(accounting.route) }),\n ratedAt: parseDate(accounting.ratedAt, job.id, \"ratedAt\"),\n reconcileLimitReservation: accounting.reconcileLimitReservation === true,\n }\n}\n\nfunction parseDate(value: string, jobId: string, field: string): Date {\n const date = new Date(value)\n if (!Number.isFinite(date.getTime())) {\n throw new InvalidAiUsageRecoveryJobError(\n `AI usage recovery job '${jobId}' has an invalid ${field} timestamp.`\n )\n }\n return date\n}\n",
|
|
10
|
+
"import { randomUUID } from \"node:crypto\"\nimport type { ReadonlyJsonObject, RecordAiModelCallInput } from \"../../storage\"\nimport type { ModelCallEndEvent, ModelUsage } from \"../events\"\nimport type { LanguageModel } from \"../language-model\"\nimport { ModelUsageRecordingError } from \"./errors\"\nimport {\n normalizeModelCallAccounting,\n recordAiModelCallAccounting,\n requireAccountingCapabilities,\n} from \"./model-call-accounting\"\nimport {\n type AiModelCallAdmissionInput,\n aiModelCallOutputTokenAllowance,\n estimateAiModelCallInputTokens,\n estimatedAiModelCallTotalTokens,\n} from \"./model-call-admission\"\nimport type { AiModelCallLimitController } from \"./model-call-limits\"\nimport { isPermanentAiUsageRecoveryError } from \"./model-call-recovery\"\nimport type {\n ModelCallAccountingStorage,\n RecoverAiModelCall,\n RecoverAiModelCallInput,\n} from \"./types\"\nimport { aiModelCallUsageFromModel } from \"./usage\"\n\nconst STORAGE_RETRY_DELAYS_MS = [50, 200, 600] as const\n\nexport interface AiModelCallRecorderInput {\n readonly storage: ModelCallAccountingStorage\n readonly projectId: string\n readonly executionId: string\n readonly attempt: number\n readonly requesterGroupIds: readonly string[]\n readonly limits: AiModelCallLimitController\n readonly recoverAiModelCall: RecoverAiModelCall\n}\n\ninterface AiModelCallRecorderInternals {\n readonly generateId?: () => string\n readonly now?: () => Date\n readonly retryDelaysMs?: readonly number[]\n readonly sleep?: (ms: number) => Promise<void>\n readonly recordAccounting?: (input: RecoverAiModelCallInput) => Promise<void>\n}\n\n/** Persist every completed provider call before another billable loop step can start. */\nexport class AiModelCallRecorder {\n private readonly generateId: () => string\n private readonly now: () => Date\n private readonly retryDelaysMs: readonly number[]\n private readonly sleep: (ms: number) => Promise<void>\n private readonly recordAccounting: (input: RecoverAiModelCallInput) => Promise<void>\n private readonly reservations = new Set<string>()\n private admissionError: unknown\n private recordingError: ModelUsageRecordingError | undefined\n\n constructor(\n private readonly input: AiModelCallRecorderInput,\n internals: AiModelCallRecorderInternals = {}\n ) {\n requireAccountingCapabilities(input.storage)\n this.generateId = internals.generateId ?? (() => `ai_usage_${randomUUID()}`)\n this.now = internals.now ?? (() => new Date())\n this.retryDelaysMs = internals.retryDelaysMs ?? STORAGE_RETRY_DELAYS_MS\n this.sleep = internals.sleep ?? sleep\n this.recordAccounting =\n internals.recordAccounting ??\n (async (recovery) => {\n await recordAiModelCallAccounting({ storage: this.input.storage, ...recovery })\n })\n }\n\n /** Wrap the resolved model so all calls in an execution share admission. */\n wrapModel(model: LanguageModel): LanguageModel {\n return {\n providerId: model.providerId,\n modelId: model.modelId,\n definition: model.definition,\n costEstimator: model.costEstimator,\n ...(model.validateResponseFormat === undefined\n ? {}\n : { validateResponseFormat: model.validateResponseFormat.bind(model) }),\n stream: async (request) => {\n this.assertHealthy()\n const inputTokens = estimateAiModelCallInputTokens({\n prompt: request.messages,\n tools: request.tools,\n responseFormat: request.responseFormat,\n })\n const outputTokenAllowance = aiModelCallOutputTokenAllowance(request.maxOutputTokens)\n await this.admitCall({\n callId: request.callId,\n providerId: model.providerId,\n modelId: model.modelId,\n costEstimator: model.costEstimator,\n inputTokens,\n outputTokenAllowance,\n estimatedTotalTokens: estimatedAiModelCallTotalTokens(inputTokens, outputTokenAllowance),\n })\n try {\n return await model.stream(request)\n } catch (error) {\n await this.markCallUnknown(request.callId)\n throw error\n }\n },\n }\n }\n\n /** Admit one provider attempt, independently of its language or embedding protocol. */\n async admitCall(\n call: Omit<\n AiModelCallAdmissionInput,\n \"projectId\" | \"executionId\" | \"attempt\" | \"requesterGroupIds\"\n >\n ): Promise<void> {\n this.assertHealthy()\n try {\n const decision = await this.input.limits.beforeModelCall({\n ...call,\n projectId: this.input.projectId,\n executionId: this.input.executionId,\n attempt: this.input.attempt,\n requesterGroupIds: this.input.requesterGroupIds,\n })\n if (decision.reservation === \"active\") this.reservations.add(call.callId)\n } catch (error) {\n // Execution boundaries must retain the original coded admission failure.\n this.admissionError = error\n throw error\n }\n }\n\n /** Keep an unresolved reservation when an attempted call's billable outcome is unknown. */\n private async markCallUnknown(callId: string): Promise<void> {\n if (!this.reservations.has(callId)) return\n await this.input.limits.markModelCallUnknown({\n projectId: this.input.projectId,\n executionId: this.input.executionId,\n attempt: this.input.attempt,\n callId,\n })\n }\n\n readonly onModelCallEnd = async (event: ModelCallEndEvent): Promise<void> => {\n // Calls already in flight still need their own accounting after another call fails.\n // Only admission is gated by the execution's sticky failure.\n try {\n const occurredAt = this.now()\n const record: RecordAiModelCallInput = {\n id: this.generateId(),\n projectId: this.input.projectId,\n executionId: this.input.executionId,\n attempt: this.input.attempt,\n callId: event.callId,\n requesterGroupIds: this.input.requesterGroupIds,\n providerId: event.providerId,\n ...(event.providerIds === undefined ? {} : { providerIds: event.providerIds }),\n requestedModelId: event.modelId,\n ...(event.modelKind === undefined ? {} : { modelKind: event.modelKind }),\n ...(event.requestedReasoning === undefined\n ? {}\n : { requestedReasoning: event.requestedReasoning }),\n ...(event.responseModelId === undefined ? {} : { responseModelId: event.responseModelId }),\n responseId: event.responseId,\n usage: aiModelCallUsageFromModel(event.usage),\n ...(event.usage.raw === undefined ? {} : { rawUsage: rawUsage(event.usage) }),\n occurredAt,\n }\n const recoveryInput = normalizeModelCallAccounting({\n usage: record,\n cost: event.cost,\n ...(event.estimate === undefined ? {} : { estimate: event.estimate }),\n ...(event.route === undefined ? {} : { route: event.route }),\n ratedAt: new Date(occurredAt),\n ...(this.reservations.has(event.callId) ? { reconcileLimitReservation: true } : {}),\n })\n\n try {\n await retryOperation(\n () => this.recordAccounting(recoveryInput),\n this.retryDelaysMs,\n this.sleep,\n (error) => !isPermanentAiUsageRecoveryError(error)\n )\n } catch (storageError) {\n if (isPermanentAiUsageRecoveryError(storageError)) throw storageError\n\n try {\n await retryOperation(\n () => this.input.recoverAiModelCall(recoveryInput),\n this.retryDelaysMs,\n this.sleep,\n (error) => !isPermanentAiUsageRecoveryError(error)\n )\n } catch (recoveryError) {\n throw new AggregateError(\n [storageError, recoveryError],\n \"Direct AI accounting and durable recovery both failed.\"\n )\n }\n throw new ModelUsageRecordingError(this.input.executionId, event.callId, true, {\n cause: storageError,\n })\n }\n } catch (error) {\n const recordingError =\n error instanceof ModelUsageRecordingError\n ? error\n : new ModelUsageRecordingError(this.input.executionId, event.callId, false, {\n cause: error,\n })\n this.recordingError ??= recordingError\n throw recordingError\n }\n }\n\n assertHealthy(): void {\n if (this.admissionError !== undefined) throw this.admissionError\n if (this.recordingError) throw this.recordingError\n }\n}\n\nfunction rawUsage(usage: ModelUsage): ReadonlyJsonObject {\n return structuredClone(usage.raw ?? {})\n}\n\nasync function retryOperation<TResult>(\n operation: () => Promise<TResult>,\n retryDelaysMs: readonly number[],\n wait: (ms: number) => Promise<void>,\n shouldRetry: (error: unknown) => boolean\n): Promise<TResult> {\n for (let attempt = 0; ; attempt += 1) {\n try {\n return await operation()\n } catch (error) {\n if (!shouldRetry(error)) throw error\n const delay = retryDelaysMs[attempt]\n if (delay === undefined) throw error\n await wait(delay)\n }\n }\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms))\n}\n",
|
|
11
|
+
"import type { AiModelCallReservationIdentity } from \"../../storage\"\nimport type { ModelKind } from \"../definitions\"\nimport type { ModelCostEstimator, ModelMoney } from \"../pricing\"\n\n/** Default output ceiling when a call and its resolved model supply no limit. */\nexport const AI_MODEL_CALL_OUTPUT_TOKEN_ALLOWANCE = 4_096\n\nexport type AiModelCallInputTokenEstimate =\n | {\n readonly status: \"estimated\"\n readonly tokens: number\n readonly method: \"utf8BytesDividedByFour\"\n }\n | {\n readonly status: \"unavailable\"\n readonly reason: \"nonTextInput\" | \"unserializableInput\"\n }\n\n/** Provider-neutral snapshot passed to aggregate-budget admission before a provider request. */\nexport interface AiModelCallAdmissionInput {\n readonly projectId: string\n readonly executionId: string\n readonly attempt: number\n readonly requesterGroupIds: readonly string[]\n readonly callId: string\n readonly providerId: string\n readonly modelId: string\n /** Selects the applicable limit meters; transcription and reranking skip token limits. */\n readonly modelKind?: ModelKind\n readonly costEstimator?: ModelCostEstimator\n /** A non-token estimate, computed by the resolved binding before inference. */\n readonly reservationCost?: ModelMoney\n readonly inputTokens: AiModelCallInputTokenEstimate\n readonly outputTokenAllowance: number\n readonly estimatedTotalTokens?: number\n}\n\nexport interface AiModelCallAdmissionDecision {\n /** Active means accounting must reconcile the reservation for this provider attempt. */\n readonly reservation: \"active\" | \"none\"\n}\n\nexport type BeforeAiModelCall = (\n input: AiModelCallAdmissionInput\n) => AiModelCallAdmissionDecision | Promise<AiModelCallAdmissionDecision>\n\nexport type MarkAiModelCallUnknown = (input: AiModelCallReservationIdentity) => void | Promise<void>\n\n/**\n * Estimate the exact, prepared provider request without requiring a provider-specific tokenizer.\n *\n * The heuristic is intentionally explicit so reservations are reproducible. Non-text inputs are\n * reported as unavailable; an enforced token or cost policy can then fail closed instead of\n * pretending that an image, file, or provider-defined payload has no token cost.\n */\nexport function estimateAiModelCallInputTokens(input: {\n readonly prompt: unknown\n readonly tools: unknown\n readonly responseFormat: unknown\n}): AiModelCallInputTokenEstimate {\n if (containsNonTextInput(input.prompt)) {\n return { status: \"unavailable\", reason: \"nonTextInput\" }\n }\n\n let serialized: string | undefined\n try {\n serialized = JSON.stringify(input)\n } catch {\n return { status: \"unavailable\", reason: \"unserializableInput\" }\n }\n if (serialized === undefined) {\n return { status: \"unavailable\", reason: \"unserializableInput\" }\n }\n\n const bytes = new TextEncoder().encode(serialized).byteLength\n return {\n status: \"estimated\",\n tokens: Math.ceil(bytes / 4),\n method: \"utf8BytesDividedByFour\",\n }\n}\n\nexport function aiModelCallOutputTokenAllowance(maxOutputTokens: number | undefined): number {\n if (maxOutputTokens === undefined) return AI_MODEL_CALL_OUTPUT_TOKEN_ALLOWANCE\n if (!Number.isSafeInteger(maxOutputTokens) || maxOutputTokens <= 0) {\n throw new TypeError(\n \"[SixbModels] AI model-call maxOutputTokens must be a positive safe integer.\"\n )\n }\n return maxOutputTokens\n}\n\nexport function estimatedAiModelCallTotalTokens(\n inputTokens: AiModelCallInputTokenEstimate,\n outputTokenAllowance: number\n): number | undefined {\n if (inputTokens.status !== \"estimated\") return undefined\n const total = inputTokens.tokens + outputTokenAllowance\n if (!Number.isSafeInteger(total)) {\n throw new TypeError(\"[SixbModels] AI model-call token estimate exceeds the safe range.\")\n }\n return total\n}\n\nfunction containsNonTextInput(value: unknown, seen = new WeakSet<object>()): boolean {\n if (value === null || typeof value !== \"object\") return false\n if (\n value instanceof URL ||\n value instanceof ArrayBuffer ||\n ArrayBuffer.isView(value) ||\n (typeof Blob !== \"undefined\" && value instanceof Blob)\n ) {\n return true\n }\n if (seen.has(value)) return false\n seen.add(value)\n\n if (!Array.isArray(value)) {\n const type = Reflect.get(value, \"type\")\n if (\n type === \"image\" ||\n type === \"file\" ||\n type === \"reasoning-file\" ||\n type === \"custom\" ||\n type === \"provider-state\"\n ) {\n return true\n }\n }\n\n return Object.values(value).some((entry) => containsNonTextInput(entry, seen))\n}\n",
|
|
12
|
+
"import { createSixbError } from \"../../errors/internal\"\nimport type { AgentQueueJob, Queue } from \"../../queues\"\nimport { modelCallRecoveryPayload } from \"./model-call-recovery\"\nimport type { RecoverAiModelCallInput } from \"./types\"\n\n/** Stable queue identity: a lost enqueue response can safely retry the same accounting handoff. */\nfunction agentAiUsageRecoveryJobId(recordId: string): string {\n return `agt_usage_job_${recordId}`\n}\n\n/** Transport adapter for the agent worker's existing durable recovery lane. */\nexport async function enqueueAiModelCallRecovery(\n queue: Pick<Queue<AgentQueueJob>, \"enqueue\">,\n input: RecoverAiModelCallInput\n): Promise<void> {\n const payload = modelCallRecoveryPayload(input)\n const record = input.usage\n const jobId = agentAiUsageRecoveryJobId(record.id)\n const [job] = await queue.enqueue({\n projectId: record.projectId,\n jobs: [{ id: jobId, type: \"agent.ai-usage.record.requested\", payload }],\n })\n\n if (job?.id !== jobId || job.type !== \"agent.ai-usage.record.requested\") {\n throw createSixbError(\n \"internal.unexpected\",\n `[SixbModels] Agent queue did not confirm AI usage recovery job '${jobId}'.`,\n { details: { jobId } }\n )\n }\n}\n"
|
|
13
|
+
],
|
|
14
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BO,SAAS,iCAAgC,CAAC,OAKlB;AAAA,EAC7B,MAAM,WAAW,gCAA+B,MAAM,aAAa,MAAM,iBAAiB;AAAA,EAE1F,OAAO;AAAA,IACL,iBAAiB,OAAO,cAAc;AAAA,MACpC,IAAI;AAAA,MACJ,IAAI;AAAA,QACF,MAAM,WAAW,MAAM,MAAM,QAAQ,SAAS,aAAa;AAAA,UACzD,WAAW,MAAM;AAAA,QACnB,CAAC;AAAA,QACD,aAAa,2BAA0B,UAAU,QAAQ,EAAE,OAAO,CAAC,WACjE,qBAAoB,OAAO,MAAM,OAAO,UAAU,SAAS,CAC7D;AAAA,QACA,OAAO,OAAO;AAAA,QACd,MAAM,wBAAwB,KAAK;AAAA;AAAA,MAIrC,IAAI,WAAW,WAAW;AAAA,QAAG,OAAO,EAAE,aAAa,OAAO;AAAA,MAE1D,MAAM,YAAY,qBAChB,WACA,WAAW,KAAK,CAAC,WAAW,OAAO,MAAM,UAAU,uBAAuB,CAC5E;AAAA,MACA,IAAI,UAAU,WAAW,GAAG;AAAA,QAC1B,MAAM,8BAA6B,CAAC,iBAAiB,CAAC;AAAA,MACxD;AAAA,MAEA,IAA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AA0B,CAC9C,OACA,OACe;AAAA,EACf,MAAM,UAAU,yBAAyB,KAAK;AAAA,EAC9C,MAAM,SAAS,MAAM;AAAA,EACrB,MAAM,QAAQ,0BAA0B,OAAO,EAAE;AAAA,EACjD,OAAO,OAAO,MAAM,MAAM,QAAQ;AAAA,IAChC,WAAW,OAAO;AAAA,IAClB,MAAM,CAAC,EAAE,IAAI,OAAO,MAAM,mCAAmC,QAAQ,CAAC;AAAA,EACxE,CAAC;AAAA,EAED,IAAI,KAAK,OAAO,SAAS,IAAI,SAAS,mCAAmC;AAAA,IACvE,MAAM,iBACJ,uBACA,mEAAmE,WACnE,EAAE,SAAS,EAAE,MAAM,EAAE,CACvB;AAAA,EACF;AAAA;",
|
|
15
|
+
"debugId": "723C9B221336858664756E2164756E21",
|
|
16
|
+
"names": []
|
|
17
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
normalizeAiPricingContext2,
|
|
4
4
|
normalizeAiCostEstimate
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-ere85b8y.js";
|
|
6
6
|
// src/storage/ai-cost/codec.ts
|
|
7
7
|
function aiModelCallCostDetails2(record) {
|
|
8
8
|
return {
|
|
@@ -79,7 +79,7 @@ function metersFromUnknown(value) {
|
|
|
79
79
|
return value.map(billableMeter);
|
|
80
80
|
}
|
|
81
81
|
function billableMeter(value) {
|
|
82
|
-
if (value !== "tokens.input.total" && value !== "tokens.input.uncached" && value !== "tokens.input.cacheRead" && value !== "tokens.input.cacheWrite" && value !== "tokens.input.cacheWrite5m" && value !== "tokens.input.cacheWrite1h" && value !== "tokens.output.total" && value !== "tokens.output.text" && value !== "tokens.output.reasoning") {
|
|
82
|
+
if (value !== "tokens.input.total" && value !== "tokens.input.uncached" && value !== "tokens.input.cacheRead" && value !== "tokens.input.cacheWrite" && value !== "tokens.input.cacheWrite5m" && value !== "tokens.input.cacheWrite1h" && value !== "tokens.output.total" && value !== "tokens.output.text" && value !== "tokens.output.reasoning" && value !== "audio.input.milliseconds") {
|
|
83
83
|
throw invalidDetails();
|
|
84
84
|
}
|
|
85
85
|
return value;
|
|
@@ -121,4 +121,4 @@ function invalidDetails() {
|
|
|
121
121
|
}
|
|
122
122
|
export { aiModelCallCostDetails2, parseAiModelCallCostDetails2 };
|
|
123
123
|
|
|
124
|
-
//# debugId=
|
|
124
|
+
//# debugId=E206E702DC38494B64756E2164756E21
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/storage/ai-cost/codec.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import type {\n AiBillableMeter,\n AiCostEstimate,\n AiModelCallCostRecord,\n AiPriceSource,\n AiPricingContext,\n} from \"./types\"\nimport { normalizeAiCostEstimate, normalizeAiPricingContext } from \"./validation\"\n\nexport interface AiModelCallCostDetails {\n readonly estimate?: AiCostEstimate\n readonly pricingContext: AiPricingContext\n readonly priceSource?: Omit<AiPriceSource, \"observedAt\"> & {\n readonly observedAt: string\n }\n readonly components?: Extract<AiModelCallCostRecord, { status: \"rated\" }>[\"components\"]\n readonly missingMeters?: readonly AiBillableMeter[]\n}\n\nexport function aiModelCallCostDetails(record: AiModelCallCostRecord): AiModelCallCostDetails {\n return {\n ...(record.estimate === undefined ? {} : { estimate: record.estimate }),\n pricingContext: record.pricingContext,\n ...(record.priceSource === undefined\n ? {}\n : {\n priceSource: {\n ...record.priceSource,\n observedAt: record.priceSource.observedAt.toISOString(),\n },\n }),\n ...(record.status === \"rated\" ? { components: record.components } : {}),\n ...(record.status === \"unpriceable\" && record.missingMeters\n ? { missingMeters: record.missingMeters }\n : {}),\n }\n}\n\nexport function parseAiModelCallCostDetails(value: unknown): AiModelCallCostDetails {\n const parsed: unknown = typeof value === \"string\" ? JSON.parse(value) : value\n if (!isRecord(parsed)) throw invalidDetails()\n const priceSource = parsed.priceSource\n if (priceSource !== undefined && !isRecord(priceSource)) throw invalidDetails()\n const components = parsed.components\n const missingMeters = parsed.missingMeters\n return {\n ...(parsed.estimate === undefined\n ? {}\n : { estimate: normalizeAiCostEstimate(parsed.estimate) }),\n pricingContext: pricingContextFromUnknown(parsed.pricingContext),\n ...(priceSource === undefined\n ? {}\n : {\n priceSource: {\n sourceId: requiredString(priceSource.sourceId),\n sourceEntryId: requiredString(priceSource.sourceEntryId),\n sourceVersion: requiredString(priceSource.sourceVersion),\n ...optionalStringProperty(priceSource, \"sourceUrl\"),\n observedAt: requiredString(priceSource.observedAt),\n },\n }),\n ...(components === undefined ? {} : { components: costComponentsFromUnknown(components) }),\n ...(missingMeters === undefined ? {} : { missingMeters: metersFromUnknown(missingMeters) }),\n }\n}\n\nfunction pricingContextFromUnknown(value: unknown): AiPricingContext {\n if (!isRecord(value)) throw invalidDetails()\n return normalizeAiPricingContext({\n ...optionalStringProperty(value, \"serviceTier\"),\n ...optionalBooleanProperty(value, \"batch\"),\n ...optionalStringProperty(value, \"region\"),\n ...optionalStringProperty(value, \"inferenceGeo\"),\n ...optionalStringProperty(value, \"routedProviderId\"),\n ...optionalStringProperty(value, \"routedModelId\"),\n ...optionalStringProperty(value, \"deploymentId\"),\n ...optionalStringProperty(value, \"inferenceProfileId\"),\n ...optionalNumberProperty(value, \"cacheWriteTtlSeconds\"),\n ...optionalStringProperty(value, \"mode\"),\n })\n}\n\nfunction costComponentsFromUnknown(\n value: unknown\n): Extract<AiModelCallCostRecord, { status: \"rated\" }>[\"components\"] {\n if (!Array.isArray(value)) throw invalidDetails()\n return value.map((component) => {\n if (!isRecord(component)) throw invalidDetails()\n return {\n meter: billableMeter(component.meter),\n quantity: requiredString(component.quantity),\n rateAmountNanosPerMillion: requiredString(component.rateAmountNanosPerMillion),\n chargeAmountNanos: requiredString(component.chargeAmountNanos),\n }\n })\n}\n\nfunction metersFromUnknown(value: unknown): readonly AiBillableMeter[] {\n if (!Array.isArray(value)) throw invalidDetails()\n return value.map(billableMeter)\n}\n\nfunction billableMeter(value: unknown): AiBillableMeter {\n if (\n value !== \"tokens.input.total\" &&\n value !== \"tokens.input.uncached\" &&\n value !== \"tokens.input.cacheRead\" &&\n value !== \"tokens.input.cacheWrite\" &&\n value !== \"tokens.input.cacheWrite5m\" &&\n value !== \"tokens.input.cacheWrite1h\" &&\n value !== \"tokens.output.total\" &&\n value !== \"tokens.output.text\" &&\n value !== \"tokens.output.reasoning\"\n ) {\n throw invalidDetails()\n }\n return value\n}\n\nfunction optionalStringProperty(\n value: Record<string, unknown>,\n name: string\n): Record<string, string> {\n const property = value[name]\n if (property === undefined) return {}\n if (typeof property !== \"string\") throw invalidDetails()\n return { [name]: property }\n}\n\nfunction optionalBooleanProperty(\n value: Record<string, unknown>,\n name: string\n): Record<string, boolean> {\n const property = value[name]\n if (property === undefined) return {}\n if (typeof property !== \"boolean\") throw invalidDetails()\n return { [name]: property }\n}\n\nfunction optionalNumberProperty(\n value: Record<string, unknown>,\n name: string\n): Record<string, number> {\n const property = value[name]\n if (property === undefined) return {}\n if (typeof property !== \"number\") throw invalidDetails()\n return { [name]: property }\n}\n\nfunction requiredString(value: unknown): string {\n if (typeof value !== \"string\") throw invalidDetails()\n return value\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n}\n\nfunction invalidDetails(): Error {\n return new Error(\"[Sixb] AI valuation details are invalid.\")\n}\n"
|
|
5
|
+
"import type {\n AiBillableMeter,\n AiCostEstimate,\n AiModelCallCostRecord,\n AiPriceSource,\n AiPricingContext,\n} from \"./types\"\nimport { normalizeAiCostEstimate, normalizeAiPricingContext } from \"./validation\"\n\nexport interface AiModelCallCostDetails {\n readonly estimate?: AiCostEstimate\n readonly pricingContext: AiPricingContext\n readonly priceSource?: Omit<AiPriceSource, \"observedAt\"> & {\n readonly observedAt: string\n }\n readonly components?: Extract<AiModelCallCostRecord, { status: \"rated\" }>[\"components\"]\n readonly missingMeters?: readonly AiBillableMeter[]\n}\n\nexport function aiModelCallCostDetails(record: AiModelCallCostRecord): AiModelCallCostDetails {\n return {\n ...(record.estimate === undefined ? {} : { estimate: record.estimate }),\n pricingContext: record.pricingContext,\n ...(record.priceSource === undefined\n ? {}\n : {\n priceSource: {\n ...record.priceSource,\n observedAt: record.priceSource.observedAt.toISOString(),\n },\n }),\n ...(record.status === \"rated\" ? { components: record.components } : {}),\n ...(record.status === \"unpriceable\" && record.missingMeters\n ? { missingMeters: record.missingMeters }\n : {}),\n }\n}\n\nexport function parseAiModelCallCostDetails(value: unknown): AiModelCallCostDetails {\n const parsed: unknown = typeof value === \"string\" ? JSON.parse(value) : value\n if (!isRecord(parsed)) throw invalidDetails()\n const priceSource = parsed.priceSource\n if (priceSource !== undefined && !isRecord(priceSource)) throw invalidDetails()\n const components = parsed.components\n const missingMeters = parsed.missingMeters\n return {\n ...(parsed.estimate === undefined\n ? {}\n : { estimate: normalizeAiCostEstimate(parsed.estimate) }),\n pricingContext: pricingContextFromUnknown(parsed.pricingContext),\n ...(priceSource === undefined\n ? {}\n : {\n priceSource: {\n sourceId: requiredString(priceSource.sourceId),\n sourceEntryId: requiredString(priceSource.sourceEntryId),\n sourceVersion: requiredString(priceSource.sourceVersion),\n ...optionalStringProperty(priceSource, \"sourceUrl\"),\n observedAt: requiredString(priceSource.observedAt),\n },\n }),\n ...(components === undefined ? {} : { components: costComponentsFromUnknown(components) }),\n ...(missingMeters === undefined ? {} : { missingMeters: metersFromUnknown(missingMeters) }),\n }\n}\n\nfunction pricingContextFromUnknown(value: unknown): AiPricingContext {\n if (!isRecord(value)) throw invalidDetails()\n return normalizeAiPricingContext({\n ...optionalStringProperty(value, \"serviceTier\"),\n ...optionalBooleanProperty(value, \"batch\"),\n ...optionalStringProperty(value, \"region\"),\n ...optionalStringProperty(value, \"inferenceGeo\"),\n ...optionalStringProperty(value, \"routedProviderId\"),\n ...optionalStringProperty(value, \"routedModelId\"),\n ...optionalStringProperty(value, \"deploymentId\"),\n ...optionalStringProperty(value, \"inferenceProfileId\"),\n ...optionalNumberProperty(value, \"cacheWriteTtlSeconds\"),\n ...optionalStringProperty(value, \"mode\"),\n })\n}\n\nfunction costComponentsFromUnknown(\n value: unknown\n): Extract<AiModelCallCostRecord, { status: \"rated\" }>[\"components\"] {\n if (!Array.isArray(value)) throw invalidDetails()\n return value.map((component) => {\n if (!isRecord(component)) throw invalidDetails()\n return {\n meter: billableMeter(component.meter),\n quantity: requiredString(component.quantity),\n rateAmountNanosPerMillion: requiredString(component.rateAmountNanosPerMillion),\n chargeAmountNanos: requiredString(component.chargeAmountNanos),\n }\n })\n}\n\nfunction metersFromUnknown(value: unknown): readonly AiBillableMeter[] {\n if (!Array.isArray(value)) throw invalidDetails()\n return value.map(billableMeter)\n}\n\nfunction billableMeter(value: unknown): AiBillableMeter {\n if (\n value !== \"tokens.input.total\" &&\n value !== \"tokens.input.uncached\" &&\n value !== \"tokens.input.cacheRead\" &&\n value !== \"tokens.input.cacheWrite\" &&\n value !== \"tokens.input.cacheWrite5m\" &&\n value !== \"tokens.input.cacheWrite1h\" &&\n value !== \"tokens.output.total\" &&\n value !== \"tokens.output.text\" &&\n value !== \"tokens.output.reasoning\" &&\n value !== \"audio.input.milliseconds\"\n ) {\n throw invalidDetails()\n }\n return value\n}\n\nfunction optionalStringProperty(\n value: Record<string, unknown>,\n name: string\n): Record<string, string> {\n const property = value[name]\n if (property === undefined) return {}\n if (typeof property !== \"string\") throw invalidDetails()\n return { [name]: property }\n}\n\nfunction optionalBooleanProperty(\n value: Record<string, unknown>,\n name: string\n): Record<string, boolean> {\n const property = value[name]\n if (property === undefined) return {}\n if (typeof property !== \"boolean\") throw invalidDetails()\n return { [name]: property }\n}\n\nfunction optionalNumberProperty(\n value: Record<string, unknown>,\n name: string\n): Record<string, number> {\n const property = value[name]\n if (property === undefined) return {}\n if (typeof property !== \"number\") throw invalidDetails()\n return { [name]: property }\n}\n\nfunction requiredString(value: unknown): string {\n if (typeof value !== \"string\") throw invalidDetails()\n return value\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n}\n\nfunction invalidDetails(): Error {\n return new Error(\"[Sixb] AI valuation details are invalid.\")\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";;;;;;AAmBO,SAAS,uBAAsB,CAAC,QAAuD;AAAA,EAC5F,OAAO;AAAA,OACD,OAAO,aAAa,YAAY,CAAC,IAAI,EAAE,UAAU,OAAO,SAAS;AAAA,IACrE,gBAAgB,OAAO;AAAA,OACnB,OAAO,gBAAgB,YACvB,CAAC,IACD;AAAA,MACE,aAAa;AAAA,WACR,OAAO;AAAA,QACV,YAAY,OAAO,YAAY,WAAW,YAAY;AAAA,MACxD;AAAA,IACF;AAAA,OACA,OAAO,WAAW,UAAU,EAAE,YAAY,OAAO,WAAW,IAAI,CAAC;AAAA,OACjE,OAAO,WAAW,iBAAiB,OAAO,gBAC1C,EAAE,eAAe,OAAO,cAAc,IACtC,CAAC;AAAA,EACP;AAAA;AAGK,SAAS,4BAA2B,CAAC,OAAwC;AAAA,EAClF,MAAM,SAAkB,OAAO,UAAU,WAAW,KAAK,MAAM,KAAK,IAAI;AAAA,EACxE,IAAI,CAAC,SAAS,MAAM;AAAA,IAAG,MAAM,eAAe;AAAA,EAC5C,MAAM,cAAc,OAAO;AAAA,EAC3B,IAAI,gBAAgB,aAAa,CAAC,SAAS,WAAW;AAAA,IAAG,MAAM,eAAe;AAAA,EAC9E,MAAM,aAAa,OAAO;AAAA,EAC1B,MAAM,gBAAgB,OAAO;AAAA,EAC7B,OAAO;AAAA,OACD,OAAO,aAAa,YACpB,CAAC,IACD,EAAE,UAAU,wBAAwB,OAAO,QAAQ,EAAE;AAAA,IACzD,gBAAgB,0BAA0B,OAAO,cAAc;AAAA,OAC3D,gBAAgB,YAChB,CAAC,IACD;AAAA,MACE,aAAa;AAAA,QACX,UAAU,eAAe,YAAY,QAAQ;AAAA,QAC7C,eAAe,eAAe,YAAY,aAAa;AAAA,QACvD,eAAe,eAAe,YAAY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,CAAC,MAAM,QAAQ,KAAK;AAAA;AAG5E,SAAS,cAAc,GAAU;AAAA,EAC/B,OAAO,IAAI,MAAM,0CAA0C;AAAA;",
|
|
8
|
+
"debugId": "E206E702DC38494B64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
assertPropertyTokenBelongsToObjectType2,
|
|
4
4
|
assertTelemetryProperty2
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-rpxz486p.js";
|
|
6
6
|
import {
|
|
7
7
|
lowerEditBatch2
|
|
8
8
|
} from "./chunk-wr8qp979.js";
|
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
objectRefKey2,
|
|
11
11
|
linkRefKey2,
|
|
12
12
|
linkScopeKey
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-b9affek3.js";
|
|
14
14
|
import {
|
|
15
15
|
createLinkScopeFingerprint2
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-fggq3d9k.js";
|
|
17
17
|
import {
|
|
18
18
|
ActionValidationError2
|
|
19
19
|
} from "./chunk-6fsr7y93.js";
|
|
@@ -24,10 +24,10 @@ import {
|
|
|
24
24
|
effectsWithoutEditsMessage,
|
|
25
25
|
assertNonEmpty2,
|
|
26
26
|
isObjectActionDefinition2
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-svabwqdq.js";
|
|
28
28
|
import {
|
|
29
29
|
decorateObjectQueryExecutor
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-ewqa58h9.js";
|
|
31
31
|
import {
|
|
32
32
|
RuntimeError2
|
|
33
33
|
} from "./chunk-m4ehq95f.js";
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
import {
|
|
3
|
+
BlobStorageError2
|
|
4
|
+
} from "./chunk-h8teetr0.js";
|
|
2
5
|
import {
|
|
3
6
|
blobIdFromDigest2
|
|
4
7
|
} from "./chunk-h3v76ams.js";
|
|
5
|
-
// src/blob-storage/errors.ts
|
|
6
|
-
class BlobStorageError2 extends Error {
|
|
7
|
-
name = "BlobStorageError";
|
|
8
|
-
}
|
|
9
8
|
// src/blob-storage/utils.ts
|
|
10
9
|
import { createHash } from "crypto";
|
|
11
10
|
function streamBlobBody2(input) {
|
|
@@ -141,6 +140,6 @@ class InMemoryBlobStorage2 {
|
|
|
141
140
|
return stored;
|
|
142
141
|
}
|
|
143
142
|
}
|
|
144
|
-
export {
|
|
143
|
+
export { streamBlobBody2, readBlobBody2, assertExpectedBlobSize2, assertValidExpectedBlobSize2, computeBlobDigest2, createFileRef2, InMemoryBlobStorage2 };
|
|
145
144
|
|
|
146
|
-
//# debugId=
|
|
145
|
+
//# debugId=952B02F894863A4864756E2164756E21
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/blob-storage/
|
|
3
|
+
"sources": ["../src/blob-storage/utils.ts", "../src/blob-storage/in-memory.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * Error for blob storage invariants and provider-level failures.\n */\nexport class BlobStorageError extends Error {\n readonly name = \"BlobStorageError\"\n}\n",
|
|
6
5
|
"import { createHash } from \"node:crypto\"\nimport { BlobStorageError } from \"./errors\"\nimport type { BlobBody, BlobDigest, BlobInfo, FileRef, PutBlobInput } from \"./types\"\n\n/** Normalize every supported blob body to the streaming representation used by providers. */\nexport function streamBlobBody(input: BlobBody): ReadableStream<Uint8Array> {\n if (input instanceof ReadableStream) {\n return input\n }\n\n if (input instanceof Blob) {\n return input.stream()\n }\n\n if (input instanceof ArrayBuffer) {\n return new Blob([input.slice(0)]).stream()\n }\n\n const bytes = new Uint8Array(new ArrayBuffer(input.byteLength))\n bytes.set(input)\n return new Blob([bytes]).stream()\n}\n\nexport async function readBlobBody(\n input: PutBlobInput[\"body\"],\n signal?: AbortSignal\n): Promise<Uint8Array> {\n // In-memory providers intentionally materialize bodies; durable providers should stream instead.\n signal?.throwIfAborted()\n\n if (input instanceof Uint8Array) {\n return new Uint8Array(input)\n }\n\n if (input instanceof ArrayBuffer) {\n return new Uint8Array(input.slice(0))\n }\n\n if (input instanceof Blob) {\n const bytes = new Uint8Array(await input.arrayBuffer())\n signal?.throwIfAborted()\n return bytes\n }\n\n const reader = input.getReader()\n const chunks: Uint8Array[] = []\n let totalBytes = 0\n const cancelOnAbort = () => {\n void reader.cancel(signal?.reason)\n }\n signal?.addEventListener(\"abort\", cancelOnAbort, { once: true })\n\n try {\n while (true) {\n const { done, value } = await reader.read()\n signal?.throwIfAborted()\n if (done) {\n break\n }\n\n const chunk = new Uint8Array(value)\n chunks.push(chunk)\n totalBytes += chunk.byteLength\n }\n } finally {\n signal?.removeEventListener(\"abort\", cancelOnAbort)\n reader.releaseLock()\n }\n\n const bytes = new Uint8Array(totalBytes)\n let offset = 0\n for (const chunk of chunks) {\n bytes.set(chunk, offset)\n offset += chunk.byteLength\n }\n\n return bytes\n}\n\nexport function assertExpectedBlobSize(\n expectedSizeBytes: number | undefined,\n actualSizeBytes: number,\n provider = \"BlobStorage\"\n): void {\n assertValidExpectedBlobSize(expectedSizeBytes, provider)\n if (expectedSizeBytes === undefined) {\n return\n }\n\n if (actualSizeBytes !== expectedSizeBytes) {\n throw new BlobStorageError(\n `[${provider}] Blob size mismatch: expected ${expectedSizeBytes} bytes, received ${actualSizeBytes}.`\n )\n }\n}\n\nexport function assertValidExpectedBlobSize(\n expectedSizeBytes: number | undefined,\n provider = \"BlobStorage\"\n): void {\n if (expectedSizeBytes === undefined) {\n return\n }\n\n if (!Number.isSafeInteger(expectedSizeBytes) || expectedSizeBytes < 0) {\n throw new BlobStorageError(\n `[${provider}] expectedSizeBytes must be a non-negative safe integer.`\n )\n }\n}\n\nexport function computeBlobDigest(bytes: Uint8Array): BlobDigest {\n const hash = createHash(\"sha256\").update(bytes).digest(\"hex\")\n return `sha256:${hash}`\n}\n\nexport function createFileRef(input: PutBlobInput, info: BlobInfo): FileRef {\n return {\n blobId: info.blobId,\n digest: info.digest,\n sizeBytes: info.sizeBytes,\n ...(input.fileName !== undefined ? { fileName: input.fileName } : {}),\n ...(input.mediaType !== undefined ? { mediaType: input.mediaType } : {}),\n ...(input.logicalPath !== undefined ? { logicalPath: input.logicalPath } : {}),\n }\n}\n",
|
|
7
6
|
"import { blobIdFromDigest } from \"./derive\"\nimport { BlobStorageError } from \"./errors\"\nimport type {\n BlobByteRange,\n BlobInfo,\n BlobStorage,\n FileRef,\n PutBlobInput,\n RangeReadableBlobStorage,\n} from \"./types\"\nimport {\n assertExpectedBlobSize,\n assertValidExpectedBlobSize,\n computeBlobDigest,\n createFileRef,\n readBlobBody,\n} from \"./utils\"\n\ntype StoredBlob = {\n readonly bytes: Uint8Array\n readonly info: BlobInfo\n}\n\nexport class InMemoryBlobStorage implements BlobStorage, RangeReadableBlobStorage {\n private readonly blobsById = new Map<string, StoredBlob>()\n\n async put(input: PutBlobInput): Promise<FileRef> {\n assertValidExpectedBlobSize(input.expectedSizeBytes)\n const bytes = await readBlobBody(input.body, input.signal)\n assertExpectedBlobSize(input.expectedSizeBytes, bytes.byteLength, \"BlobStorage\")\n const digest = computeBlobDigest(bytes)\n const blobId = blobIdFromDigest(digest)\n\n let stored = this.blobsById.get(blobId)\n if (!stored) {\n stored = {\n bytes,\n info: {\n blobId,\n digest,\n sizeBytes: bytes.byteLength,\n },\n }\n this.blobsById.set(blobId, stored)\n }\n\n return createFileRef(input, stored.info)\n }\n\n async open(blobId: string): Promise<ReadableStream<Uint8Array>> {\n const stored = this.requireStoredBlob(blobId)\n return new Blob([new Uint8Array(stored.bytes)]).stream()\n }\n\n async openRange(blobId: string, range: BlobByteRange): Promise<ReadableStream<Uint8Array>> {\n const stored = this.requireStoredBlob(blobId)\n const bytes = stored.bytes.slice(range.start, range.endInclusive + 1)\n return new Blob([bytes]).stream()\n }\n\n async stat(blobId: string): Promise<BlobInfo | null> {\n const stored = this.blobsById.get(blobId)\n return stored ? { ...stored.info } : null\n }\n\n private requireStoredBlob(blobId: string): StoredBlob {\n const stored = this.blobsById.get(blobId)\n if (!stored) {\n throw new BlobStorageError(`[BlobStorage] Unknown blob '${blobId}'`)\n }\n\n return stored\n }\n}\n"
|
|
8
7
|
],
|
|
9
|
-
"mappings": "
|
|
10
|
-
"debugId": "
|
|
8
|
+
"mappings": ";;;;;;;;AAAA;AAKO,SAAS,eAAc,CAAC,OAA6C;AAAA,EAC1E,IAAI,iBAAiB,gBAAgB;AAAA,IACnC,OAAO;AAAA,EACT;AAAA,EAEA,IAAI,iBAAiB,MAAM;AAAA,IACzB,OAAO,MAAM,OAAO;AAAA,EACtB;AAAA,EAEA,IAAI,iBAAiB,aAAa;AAAA,IAChC,OAAO,IAAI,KAAK,CAAC,MAAM,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO;AAAA,EAC3C;AAAA,EAEA,MAAM,QAAQ,IAAI,WAAW,IAAI,YAAY,MAAM,UAAU,CAAC;AAAA,EAC9D,MAAM,IAAI,KAAK;AAAA,EACf,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE,OAAO;AAAA;AAGlC,eAAsB,aAAY,CAChC,OACA,QACqB;AAAA,EAErB,QAAQ,eAAe;AAAA,EAEvB,IAAI,iBAAiB,YAAY;AAAA,IAC/B,OAAO,IAAI,WAAW,KAAK;AAAA,EAC7B;AAAA,EAEA,IAAI,iBAAiB,aAAa;AAAA,IAChC,OAAO,IAAI,WAAW,MAAM,MAAM,CAAC,CAAC;AAAA,EACtC;AAAA,EAEA,IAAI,iBAAiB,MAAM;AAAA,IACzB,MAAM,QAAQ,IAAI,WAAW,MAAM,MAAM,YAAY,CAAC;AAAA,IACtD,QAAQ,eAAe;AAAA,IACvB,OAAO;AAAA,EACT;AAAA,EAEA,MAAM,SAAS,MAAM,UAAU;AAAA,EAC/B,MAAM,SAAuB,CAAC;AAAA,EAC9B,IAAI,aAAa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A2D;AAAA,IACzF,MAAM,SAAS,KAAK,kBAAkB,MAAM;AAAA,IAC5C,MAAM,QAAQ,OAAO,MAAM,MAAM,MAAM,OAAO,MAAM,eAAe,CAAC;AAAA,IACpE,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE,OAAO;AAAA;AAAA,OAG5B,KAAI,CAAC,QAA0C;AAAA,IACnD,MAAM,SAAS,KAAK,UAAU,IAAI,MAAM;AAAA,IACxC,OAAO,SAAS,KAAK,OAAO,KAAK,IAAI;AAAA;AAAA,EAG/B,iBAAiB,CAAC,QAA4B;AAAA,IACpD,MAAM,SAAS,KAAK,UAAU,IAAI,MAAM;AAAA,IACxC,IAAI,CAAC,QAAQ;AAAA,MACX,MAAM,IAAI,kBAAiB,+BAA+B,SAAS;AAAA,IACrE;AAAA,IAEA,OAAO;AAAA;AAEX;",
|
|
9
|
+
"debugId": "952B02F894863A4864756E2164756E21",
|
|
11
10
|
"names": []
|
|
12
11
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
createObjectOperationScope2
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-qczk96d9.js";
|
|
5
|
+
import {
|
|
6
|
+
isFileRef2
|
|
7
|
+
} from "./chunk-h3v76ams.js";
|
|
5
8
|
import {
|
|
6
9
|
stableJsonStringify2
|
|
7
10
|
} from "./chunk-wy0qdqfm.js";
|
|
@@ -71,6 +74,41 @@ function isStorageSerializationFailure2(error) {
|
|
|
71
74
|
return error instanceof StorageTransactionError2 && error.code === "serialization_failure";
|
|
72
75
|
}
|
|
73
76
|
|
|
77
|
+
// src/storage/file-download-grants/record.ts
|
|
78
|
+
function parseFileDownloadGrantRow2(row) {
|
|
79
|
+
const id = text(row.id, "id", String(row.id));
|
|
80
|
+
const file = typeof row.file === "string" ? JSON.parse(row.file) : row.file;
|
|
81
|
+
if (!isFileRef2(file))
|
|
82
|
+
throw corrupt(id, "file is not a file reference");
|
|
83
|
+
return {
|
|
84
|
+
id,
|
|
85
|
+
projectId: text(row.projectId, "projectId", id),
|
|
86
|
+
tokenHash: text(row.tokenHash, "tokenHash", id),
|
|
87
|
+
file,
|
|
88
|
+
executionId: text(row.executionId, "executionId", id),
|
|
89
|
+
createdAt: date(row.createdAt, "createdAt", id),
|
|
90
|
+
expiresAt: date(row.expiresAt, "expiresAt", id),
|
|
91
|
+
...row.revokedAt == null ? {} : { revokedAt: date(row.revokedAt, "revokedAt", id) }
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function cloneFileDownloadGrantRecord(record) {
|
|
95
|
+
return structuredClone(record);
|
|
96
|
+
}
|
|
97
|
+
function text(value, column, id) {
|
|
98
|
+
if (typeof value !== "string" || value.length === 0)
|
|
99
|
+
throw corrupt(id, `${column} is not text`);
|
|
100
|
+
return value;
|
|
101
|
+
}
|
|
102
|
+
function date(value, column, id) {
|
|
103
|
+
const parsed = value instanceof Date || typeof value === "string" ? new Date(value) : null;
|
|
104
|
+
if (!parsed || !Number.isFinite(parsed.getTime()))
|
|
105
|
+
throw corrupt(id, `${column} is not a date`);
|
|
106
|
+
return parsed;
|
|
107
|
+
}
|
|
108
|
+
function corrupt(id, reason) {
|
|
109
|
+
return new Error(`[Sixb] Stored file download grant '${id}' is invalid: ${reason}.`);
|
|
110
|
+
}
|
|
111
|
+
|
|
74
112
|
// src/storage/pipeline-runs/idempotency.ts
|
|
75
113
|
function canRequeuePipelineRunAfterEnqueueFailure2(existing, input) {
|
|
76
114
|
return existing.status === "failed" && existing.error?.code === "queue.enqueue_failed" && existing.error.retryable && existing.executionId === input.executionId && existing.pipelineId === input.pipelineId;
|
|
@@ -127,6 +165,6 @@ function throwNestedStorageTransaction2() {
|
|
|
127
165
|
});
|
|
128
166
|
}
|
|
129
167
|
|
|
130
|
-
export { actionSubjectsEqual2, actionRunParamsEqual2, actionRunPhaseRecordsEqual2, finishActionRunPhase2, canRequeueActionRunAfterEnqueueFailure2, isTerminalActionRun2, ObjectNotFoundError2, ObjectStorageError2, StorageTransactionError2, isStorageSerializationFailure2, canRequeuePipelineRunAfterEnqueueFailure2, canRequeueSyncRunAfterEnqueueFailure2, createTransactionStorageProxy2, assertTransactionActive2, throwNestedStorageTransaction2 };
|
|
168
|
+
export { actionSubjectsEqual2, actionRunParamsEqual2, actionRunPhaseRecordsEqual2, finishActionRunPhase2, canRequeueActionRunAfterEnqueueFailure2, isTerminalActionRun2, ObjectNotFoundError2, ObjectStorageError2, StorageTransactionError2, isStorageSerializationFailure2, parseFileDownloadGrantRow2, cloneFileDownloadGrantRecord, canRequeuePipelineRunAfterEnqueueFailure2, canRequeueSyncRunAfterEnqueueFailure2, createTransactionStorageProxy2, assertTransactionActive2, throwNestedStorageTransaction2 };
|
|
131
169
|
|
|
132
|
-
//# debugId=
|
|
170
|
+
//# debugId=5CC5641C67CFE27364756E2164756E21
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/storage/action-runs/idempotency.ts", "../src/storage/errors.ts", "../src/storage/pipeline-runs/idempotency.ts", "../src/storage/sync-runs/idempotency.ts", "../src/storage/transaction.ts"],
|
|
3
|
+
"sources": ["../src/storage/action-runs/idempotency.ts", "../src/storage/errors.ts", "../src/storage/file-download-grants/record.ts", "../src/storage/pipeline-runs/idempotency.ts", "../src/storage/sync-runs/idempotency.ts", "../src/storage/transaction.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import type { ActionSubject } from \"../../actions\"\nimport { stableJsonStringify } from \"../../json\"\nimport type {\n ActionRunEffectsRecord,\n ActionRunPhase,\n ActionRunRecord,\n ActionRunWritebackRecord,\n FinishActionRunInput,\n QueueActionRunInput,\n} from \"./types\"\n\nexport function actionSubjectsEqual(left: ActionSubject, right: ActionSubject): boolean {\n if (left.kind !== right.kind) return false\n if (left.kind === \"none\") return true\n if (right.kind === \"none\") return false\n return left.objectTypeId === right.objectTypeId && left.primaryId === right.primaryId\n}\n\nexport function actionRunParamsEqual(left: unknown, right: unknown): boolean {\n return stableJsonStringify(left) === stableJsonStringify(right)\n}\n\nexport type ActionRunPhaseRecord = ActionRunWritebackRecord | ActionRunEffectsRecord\n\nexport function actionRunPhaseRecordsEqual(\n left: ActionRunPhaseRecord,\n right: ActionRunPhaseRecord\n): boolean {\n return actionRunParamsEqual(stripPhaseRecordCompletedAt(left), stripPhaseRecordCompletedAt(right))\n}\n\nexport function finishActionRunPhase(\n input: FinishActionRunInput,\n current: ActionRunPhase | null | undefined\n): ActionRunPhase {\n if (input.status === \"succeeded\") {\n return input.phase ?? current ?? \"validation\"\n }\n\n return input.error.details.phase\n}\n\nexport function canRequeueActionRunAfterEnqueueFailure(\n existing: ActionRunRecord,\n input: QueueActionRunInput\n): boolean {\n return (\n existing.status === \"failed\" &&\n existing.phase === \"enqueue\" &&\n existing.executionId === input.executionId &&\n existing.error?.retryable === true &&\n existing.actionId === input.actionId &&\n existing.idempotencyKey === input.idempotencyKey &&\n actionSubjectsEqual(existing.subject, input.subject) &&\n actionRunParamsEqual(existing.params, input.params)\n )\n}\n\nexport function isTerminalActionRun(record: Pick<ActionRunRecord, \"status\">): boolean {\n return (\n record.status === \"succeeded\" || record.status === \"failed\" || record.status === \"cancelled\"\n )\n}\n\nfunction stripPhaseRecordCompletedAt(\n record: ActionRunPhaseRecord\n): Omit<ActionRunPhaseRecord, \"completedAt\"> {\n const { completedAt: _completedAt, ...stableRecord } = record\n return stableRecord\n}\n",
|
|
6
6
|
"/**\n * Thrown when a storage lookup by primary ID finds no matching object.\n * Carries structured context so callers can discriminate without string parsing.\n */\nexport class ObjectNotFoundError extends Error {\n readonly name = \"ObjectNotFoundError\"\n\n constructor(\n readonly objectTypeId: string,\n readonly primaryId: string,\n readonly context: string\n ) {\n super(`[Sixb] ${context}: ${objectTypeId}:${primaryId}`)\n }\n}\n\nexport class ObjectStorageError extends Error {\n readonly name = \"ObjectStorageError\"\n}\n\nexport type StorageTransactionErrorCode =\n | \"nested_transaction\"\n | \"serialization_failure\"\n | \"transaction_inactive\"\n\nexport interface StorageTransactionErrorOptions {\n readonly cause?: unknown\n readonly code?: StorageTransactionErrorCode\n}\n\nexport class StorageTransactionError extends Error {\n readonly name = \"StorageTransactionError\"\n readonly code?: StorageTransactionErrorCode\n override readonly cause?: unknown\n\n constructor(message: string, options: StorageTransactionErrorOptions = {}) {\n super(message)\n this.code = options.code\n this.cause = options.cause\n }\n}\n\nexport function isStorageSerializationFailure(error: unknown): boolean {\n return error instanceof StorageTransactionError && error.code === \"serialization_failure\"\n}\n",
|
|
7
|
+
"import { isFileRef } from \"../../blob-storage\"\nimport type { FileDownloadGrantRecord } from \"./types\"\n\n/**\n * Rebuilds a grant from a provider row with camelCase keys. `file` may arrive parsed (jsonb) or\n * as text (SQLite), and timestamps as `Date` or ISO text. Fails closed on corruption: a grant that\n * cannot be read must not serve a file.\n */\nexport function parseFileDownloadGrantRow(row: {\n readonly [column: string]: unknown\n}): FileDownloadGrantRecord {\n const id = text(row.id, \"id\", String(row.id))\n const file = typeof row.file === \"string\" ? JSON.parse(row.file) : row.file\n if (!isFileRef(file)) throw corrupt(id, \"file is not a file reference\")\n\n return {\n id,\n projectId: text(row.projectId, \"projectId\", id),\n tokenHash: text(row.tokenHash, \"tokenHash\", id),\n file,\n executionId: text(row.executionId, \"executionId\", id),\n createdAt: date(row.createdAt, \"createdAt\", id),\n expiresAt: date(row.expiresAt, \"expiresAt\", id),\n ...(row.revokedAt == null ? {} : { revokedAt: date(row.revokedAt, \"revokedAt\", id) }),\n }\n}\n\nexport function cloneFileDownloadGrantRecord(\n record: FileDownloadGrantRecord\n): FileDownloadGrantRecord {\n return structuredClone(record)\n}\n\nfunction text(value: unknown, column: string, id: string): string {\n if (typeof value !== \"string\" || value.length === 0) throw corrupt(id, `${column} is not text`)\n return value\n}\n\nfunction date(value: unknown, column: string, id: string): Date {\n const parsed = value instanceof Date || typeof value === \"string\" ? new Date(value) : null\n if (!parsed || !Number.isFinite(parsed.getTime())) throw corrupt(id, `${column} is not a date`)\n return parsed\n}\n\nfunction corrupt(id: string, reason: string): Error {\n return new Error(`[Sixb] Stored file download grant '${id}' is invalid: ${reason}.`)\n}\n",
|
|
7
8
|
"import type { PipelineRunRecord, QueuePipelineRunInput } from \"./types\"\n\nexport function canRequeuePipelineRunAfterEnqueueFailure(\n existing: PipelineRunRecord,\n input: QueuePipelineRunInput\n): boolean {\n return (\n existing.status === \"failed\" &&\n existing.error?.code === \"queue.enqueue_failed\" &&\n existing.error.retryable &&\n existing.executionId === input.executionId &&\n existing.pipelineId === input.pipelineId\n )\n}\n",
|
|
8
9
|
"import type { QueueSyncRunInput, SyncRunRecord } from \"./types\"\n\nexport function canRequeueSyncRunAfterEnqueueFailure(\n existing: SyncRunRecord,\n input: QueueSyncRunInput\n): boolean {\n return (\n existing.status === \"failed\" &&\n existing.error?.code === \"queue.enqueue_failed\" &&\n existing.error.retryable &&\n existing.executionId === input.executionId &&\n existing.syncId === input.syncId &&\n existing.datasetId === input.datasetId &&\n existing.mode === input.mode &&\n existing.expectedLatestVersionId === input.expectedLatestVersionId &&\n existing.commitMessage === input.commitMessage\n )\n}\n",
|
|
9
10
|
"import { StorageTransactionError } from \"./errors\"\nimport { createObjectOperationScope } from \"./operation-scope\"\nimport type { Storage } from \"./types\"\n\ntype ObjectLike = Record<PropertyKey, unknown>\n\nexport function createTransactionStorageProxy<T extends Storage>(\n target: T,\n isActive: () => boolean\n): T {\n const proxies = new WeakMap<object, object>()\n const objectStorage = createObjectOperationScope(target.objects, {\n assertAvailable: () => assertTransactionActive(isActive),\n run: async <TResult>(operation: () => Promise<TResult> | TResult): Promise<TResult> => {\n assertTransactionActive(isActive)\n return operation()\n },\n })\n\n const wrap = <TValue extends object>(value: TValue): TValue => {\n const existing = proxies.get(value)\n if (existing) return existing as TValue\n\n const proxy = new Proxy(value as ObjectLike, {\n // The guard runs on property access and on call. Its purpose is to fail fast when a\n // transaction handle (`tx`) leaks past the transaction's lifetime — using it afterward is a\n // bug, not a recoverable state. Overhead is bounded: only the storage namespaces reachable\n // from `tx` are wrapped (a handful), not the row/link data graph, and never per-record.\n get(current, property, receiver) {\n assertTransactionActive(isActive)\n const result =\n current === target && property === \"objects\"\n ? objectStorage\n : Reflect.get(current, property, receiver)\n if (typeof result === \"function\") {\n return (...args: unknown[]) => {\n assertTransactionActive(isActive)\n return result.apply(current, args)\n }\n }\n if (result && typeof result === \"object\") {\n return wrap(result)\n }\n return result\n },\n })\n\n proxies.set(value, proxy)\n return proxy as TValue\n }\n\n return wrap(target)\n}\n\nexport function assertTransactionActive(isActive: () => boolean): void {\n if (!isActive()) {\n throw new StorageTransactionError(\n \"[Sixb] Transaction storage cannot be used after transaction completion.\",\n { code: \"transaction_inactive\" }\n )\n }\n}\n\nexport function throwNestedStorageTransaction(): never {\n throw new StorageTransactionError(\"[Sixb] Nested storage transactions are not supported yet.\", {\n code: \"nested_transaction\",\n })\n}\n"
|
|
10
11
|
],
|
|
11
|
-
"mappings": "
|
|
12
|
-
"debugId": "
|
|
12
|
+
"mappings": ";;;;;;;;;;;;AAWO,SAAS,oBAAmB,CAAC,MAAqB,OAA+B;AAAA,EACtF,IAAI,KAAK,SAAS,MAAM;AAAA,IAAM,OAAO;AAAA,EACrC,IAAI,KAAK,SAAS;AAAA,IAAQ,OAAO;AAAA,EACjC,IAAI,MAAM,SAAS;AAAA,IAAQ,OAAO;AAAA,EAClC,OAAO,KAAK,iBAAiB,MAAM,gBAAgB,KAAK,cAAc,MAAM;AAAA;AAGvE,SAAS,qBAAoB,CAAC,MAAe,OAAyB;AAAA,EAC3E,OAAO,qBAAoB,IAAI,MAAM,qBAAoB,KAAK;AAAA;AAKzD,SAAS,2BAA0B,CACxC,MACA,OACS;AAAA,EACT,OAAO,sBAAqB,4BAA4B,IAAI,GAAG,4BAA4B,KAAK,CAAC;AAAA;AAG5F,SAAS,qBAAoB,CAClC,OACA,SACgB;AAAA,EAChB,IAAI,MAAM,WAAW,aAAa;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