@sixb/core 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/delegated-admission.d.ts +24 -0
- package/dist/actions/delegated-admission.d.ts.map +1 -0
- package/dist/actions/descriptor.d.ts +29 -0
- package/dist/actions/descriptor.d.ts.map +1 -0
- package/dist/actions/execution.d.ts +5 -5
- package/dist/actions/execution.d.ts.map +1 -1
- package/dist/actions/index.js +50 -40
- package/dist/actions/index.js.map +1 -1
- package/dist/actions/request.d.ts.map +1 -1
- package/dist/actions/run-authorization.d.ts +20 -0
- package/dist/actions/run-authorization.d.ts.map +1 -0
- package/dist/actions/run-dispatch.d.ts +3 -1
- package/dist/actions/run-dispatch.d.ts.map +1 -1
- package/dist/actions/worker.js +5 -5
- package/dist/actions/worker.js.map +1 -1
- package/dist/agents/adapters.d.ts +6 -166
- package/dist/agents/adapters.d.ts.map +1 -1
- package/dist/agents/authority.d.ts +22 -6
- package/dist/agents/authority.d.ts.map +1 -1
- package/dist/agents/builders.d.ts +3 -11
- package/dist/agents/builders.d.ts.map +1 -1
- package/dist/agents/context-resolution.d.ts.map +1 -1
- package/dist/agents/context.js +2 -2
- package/dist/agents/dispatch.d.ts +9 -1
- package/dist/agents/dispatch.d.ts.map +1 -1
- package/dist/agents/errors.d.ts +1 -10
- package/dist/agents/errors.d.ts.map +1 -1
- package/dist/agents/execution.d.ts +9 -10
- package/dist/agents/execution.d.ts.map +1 -1
- package/dist/agents/identity.d.ts +3 -0
- package/dist/agents/identity.d.ts.map +1 -0
- package/dist/agents/ids.d.ts +4 -0
- package/dist/agents/ids.d.ts.map +1 -1
- package/dist/agents/index.d.ts +15 -11
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +90 -78
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/message.d.ts +19 -13
- package/dist/agents/message.d.ts.map +1 -1
- package/dist/agents/model-loop.d.ts +58 -0
- package/dist/agents/model-loop.d.ts.map +1 -0
- package/dist/agents/reference.d.ts +4 -0
- package/dist/agents/reference.d.ts.map +1 -0
- package/dist/agents/request.d.ts +10 -8
- package/dist/agents/request.d.ts.map +1 -1
- package/dist/agents/retired-config.d.ts +4 -0
- package/dist/agents/retired-config.d.ts.map +1 -0
- package/dist/agents/streams.d.ts +13 -8
- package/dist/agents/streams.d.ts.map +1 -1
- package/dist/agents/streams.js +7 -5
- package/dist/agents/streams.js.map +1 -1
- package/dist/agents/tool-catalog.d.ts +9 -0
- package/dist/agents/tool-catalog.d.ts.map +1 -0
- package/dist/agents/tool-definition.d.ts +1 -1
- package/dist/agents/tool-definition.d.ts.map +1 -1
- package/dist/agents/types.d.ts +31 -68
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/agents/validation.d.ts +3 -13
- package/dist/agents/validation.d.ts.map +1 -1
- package/dist/ai-usage/execution.d.ts +53 -0
- package/dist/ai-usage/execution.d.ts.map +1 -0
- package/dist/ai-usage/index.d.ts +3 -0
- package/dist/ai-usage/index.d.ts.map +1 -0
- package/dist/auth/index.js +12 -9
- package/dist/auth/index.js.map +1 -1
- package/dist/authorization/decision.d.ts +14 -3
- package/dist/authorization/decision.d.ts.map +1 -1
- package/dist/authorization/grant-kinds.d.ts +25 -8
- package/dist/authorization/grant-kinds.d.ts.map +1 -1
- package/dist/authorization/index.d.ts +1 -1
- package/dist/authorization/index.d.ts.map +1 -1
- package/dist/authorization/index.js +12 -7
- package/dist/authorization/index.js.map +1 -1
- package/dist/authorization/resolve.d.ts +3 -3
- package/dist/authorization/resolve.d.ts.map +1 -1
- package/dist/authorization/types.d.ts +7 -5
- package/dist/authorization/types.d.ts.map +1 -1
- package/dist/blob-storage/browser.js +2 -2
- package/dist/blob-storage/index.js +3 -3
- package/dist/bootstrap/discovery.d.ts +6 -6
- package/dist/bootstrap/discovery.d.ts.map +1 -1
- package/dist/bootstrap/index.js +62 -51
- package/dist/bootstrap/index.js.map +1 -1
- package/dist/bootstrap/ontology-type-manifest.d.ts.map +1 -1
- package/dist/broker/index.js +2 -2
- package/dist/{chunk-zqysyfjt.js → chunk-08m3b6w8.js} +1 -1
- package/dist/chunk-19jp6g9d.js +131 -0
- package/dist/chunk-19jp6g9d.js.map +11 -0
- package/dist/{chunk-3j7573mj.js → chunk-2dw777qw.js} +50 -5
- package/dist/{chunk-3j7573mj.js.map → chunk-2dw777qw.js.map} +4 -3
- package/dist/{chunk-0172wgm9.js → chunk-2xns679x.js} +10 -2
- package/dist/{chunk-0172wgm9.js.map → chunk-2xns679x.js.map} +3 -3
- package/dist/chunk-359jm1jw.js +147 -0
- package/dist/chunk-359jm1jw.js.map +10 -0
- package/dist/{chunk-dy311asx.js → chunk-3xep5cjx.js} +58 -23
- package/dist/chunk-3xep5cjx.js.map +15 -0
- package/dist/{chunk-n4spznws.js → chunk-3z1qec12.js} +83 -12
- package/dist/chunk-3z1qec12.js.map +12 -0
- package/dist/{chunk-z3zp0bj1.js → chunk-407j3msh.js} +1 -1
- package/dist/{chunk-rhrbz7d4.js → chunk-4a849fr1.js} +1 -1
- package/dist/{chunk-cy0n5dms.js → chunk-4jjp5k14.js} +1 -1
- package/dist/chunk-4qfkag59.js +1568 -0
- package/dist/chunk-4qfkag59.js.map +20 -0
- package/dist/{chunk-1e8m6yn3.js → chunk-4sm0aznx.js} +685 -86
- package/dist/chunk-4sm0aznx.js.map +43 -0
- package/dist/chunk-4yqmp43v.js +159 -0
- package/dist/chunk-4yqmp43v.js.map +11 -0
- package/dist/{chunk-rdeagz6b.js → chunk-5e3pq99w.js} +3 -7
- package/dist/{chunk-rdeagz6b.js.map → chunk-5e3pq99w.js.map} +3 -3
- package/dist/{chunk-ezake7g1.js → chunk-5ntny1qx.js} +1 -1
- package/dist/{chunk-dm72y8wt.js → chunk-7y0f6rf1.js} +29 -16
- package/dist/chunk-7y0f6rf1.js.map +10 -0
- package/dist/{chunk-72q2y8hn.js → chunk-8tsf6dmc.js} +2 -2
- package/dist/{chunk-qewtks41.js → chunk-9nbmsvn5.js} +123 -20
- package/dist/chunk-9nbmsvn5.js.map +11 -0
- package/dist/{chunk-5sxb1168.js → chunk-aa2pen2v.js} +256 -82
- package/dist/chunk-aa2pen2v.js.map +34 -0
- package/dist/{chunk-819wnjz8.js → chunk-ajnan18g.js} +13 -10
- package/dist/chunk-ajnan18g.js.map +12 -0
- package/dist/chunk-c15dr03f.js +43 -0
- package/dist/chunk-c15dr03f.js.map +10 -0
- package/dist/{chunk-t0jjkep3.js → chunk-d8qkxt2v.js} +4 -2
- package/dist/chunk-d8qkxt2v.js.map +10 -0
- package/dist/{chunk-vybf6pkp.js → chunk-dbc80ad7.js} +1 -1
- package/dist/{chunk-nkbfrt0c.js → chunk-f26bck4t.js} +7 -7
- package/dist/{chunk-x2yw73hy.js → chunk-fvt9rjsa.js} +23 -7
- package/dist/chunk-fvt9rjsa.js.map +10 -0
- package/dist/{chunk-znagycq7.js → chunk-gbejpkex.js} +5 -5
- package/dist/{chunk-znagycq7.js.map → chunk-gbejpkex.js.map} +1 -1
- package/dist/{chunk-e42bc6m3.js → chunk-gzasd5b6.js} +5 -5
- package/dist/{chunk-e42bc6m3.js.map → chunk-gzasd5b6.js.map} +3 -3
- package/dist/{chunk-rnshztfq.js → chunk-h0k55pc7.js} +6 -6
- package/dist/{chunk-rnshztfq.js.map → chunk-h0k55pc7.js.map} +1 -1
- package/dist/chunk-h5vqbfmd.js +1537 -0
- package/dist/chunk-h5vqbfmd.js.map +19 -0
- package/dist/chunk-j1sbhm7p.js +45 -0
- package/dist/chunk-j1sbhm7p.js.map +10 -0
- package/dist/chunk-jecn6t54.js +307 -0
- package/dist/chunk-jecn6t54.js.map +12 -0
- package/dist/{chunk-dsrkgtnh.js → chunk-jq43kdvk.js} +1 -1
- package/dist/{chunk-wtmzkcht.js → chunk-k34z5rvh.js} +1 -1
- package/dist/{chunk-f6erf2vv.js → chunk-k522z7v6.js} +10 -5
- package/dist/chunk-k522z7v6.js.map +10 -0
- package/dist/{chunk-htq0qh7z.js → chunk-ka3a2ft3.js} +2 -2
- package/dist/{chunk-ckxfnx7f.js → chunk-mth82m8t.js} +129 -95
- package/dist/chunk-mth82m8t.js.map +14 -0
- package/dist/{chunk-5gynx4xn.js → chunk-mwsxn98e.js} +79 -77
- package/dist/{chunk-5gynx4xn.js.map → chunk-mwsxn98e.js.map} +8 -8
- package/dist/{chunk-f2rt4vkh.js → chunk-n2w475r0.js} +3 -3
- package/dist/chunk-n4khvw9n.js +111 -0
- package/dist/chunk-n4khvw9n.js.map +11 -0
- package/dist/{chunk-t8t39h7v.js → chunk-n6jxh8sw.js} +10 -2
- package/dist/chunk-n6jxh8sw.js.map +10 -0
- package/dist/chunk-nn0tekr1.js +284 -0
- package/dist/chunk-nn0tekr1.js.map +12 -0
- package/dist/chunk-nx7k8tpr.js +436 -0
- package/dist/chunk-nx7k8tpr.js.map +12 -0
- package/dist/{chunk-drjqm1aa.js → chunk-p03r0h5s.js} +310 -28
- package/dist/chunk-p03r0h5s.js.map +16 -0
- package/dist/{chunk-1g8negke.js → chunk-p1rzczbt.js} +93 -8
- package/dist/chunk-p1rzczbt.js.map +12 -0
- package/dist/{chunk-f83ka50g.js → chunk-p1x242ad.js} +652 -77
- package/dist/chunk-p1x242ad.js.map +25 -0
- package/dist/chunk-p2vqaxkc.js +528 -0
- package/dist/chunk-p2vqaxkc.js.map +15 -0
- package/dist/{chunk-a31h57d5.js → chunk-pc7ys28c.js} +70 -7
- package/dist/chunk-pc7ys28c.js.map +14 -0
- package/dist/{chunk-md8k0r54.js → chunk-q0k9nc5a.js} +281 -89
- package/dist/chunk-q0k9nc5a.js.map +14 -0
- package/dist/{chunk-bhxaq2nn.js → chunk-qw9gvjv5.js} +1 -1
- package/dist/chunk-r8jrnexe.js +403 -0
- package/dist/chunk-r8jrnexe.js.map +10 -0
- package/dist/{chunk-h9kxd41f.js → chunk-rafagrwr.js} +48 -7
- package/dist/chunk-rafagrwr.js.map +11 -0
- package/dist/{chunk-dysw7nsm.js → chunk-rv2hkwwa.js} +2 -2
- package/dist/{chunk-ghteq96b.js → chunk-s5y30bc9.js} +2 -2
- package/dist/{chunk-t624af60.js → chunk-sbzzr4kx.js} +1848 -757
- package/dist/chunk-sbzzr4kx.js.map +63 -0
- package/dist/{chunk-6gjqgd3d.js → chunk-tpnd31c1.js} +2 -1
- package/dist/chunk-tpnd31c1.js.map +11 -0
- package/dist/chunk-trxxmgnf.js +68 -0
- package/dist/chunk-trxxmgnf.js.map +11 -0
- package/dist/{chunk-0hc5j867.js → chunk-v1xppd0y.js} +17 -13
- package/dist/{chunk-0hc5j867.js.map → chunk-v1xppd0y.js.map} +2 -2
- package/dist/chunk-v4en4jc2.js +252 -0
- package/dist/chunk-v4en4jc2.js.map +10 -0
- package/dist/{chunk-xkthy56g.js → chunk-w1tvjszy.js} +1 -1
- package/dist/{chunk-8b55ygje.js → chunk-w3e09qqk.js} +1 -1
- package/dist/{chunk-8gv5z0zm.js → chunk-w9tg6yyb.js} +13 -8
- package/dist/{chunk-8gv5z0zm.js.map → chunk-w9tg6yyb.js.map} +3 -3
- package/dist/{chunk-62c7t4jc.js → chunk-wdage1eb.js} +1 -1
- package/dist/{chunk-tg5mee00.js → chunk-wtf06et8.js} +11 -7
- package/dist/{chunk-tg5mee00.js.map → chunk-wtf06et8.js.map} +3 -3
- package/dist/{chunk-nva1xkjz.js → chunk-xajtptbw.js} +1237 -1434
- package/dist/chunk-xajtptbw.js.map +40 -0
- package/dist/{chunk-xc7hq65b.js → chunk-yp8ee62z.js} +49 -2
- package/dist/chunk-yp8ee62z.js.map +11 -0
- package/dist/chunk-z4ccwbkz.js +139 -0
- package/dist/chunk-z4ccwbkz.js.map +10 -0
- package/dist/datasets/builders.d.ts +11 -2
- package/dist/datasets/builders.d.ts.map +1 -1
- package/dist/datasets/changes.d.ts +14 -4
- package/dist/datasets/changes.d.ts.map +1 -1
- package/dist/datasets/execution.d.ts +15 -1
- package/dist/datasets/execution.d.ts.map +1 -1
- package/dist/datasets/index.d.ts +1 -0
- package/dist/datasets/index.d.ts.map +1 -1
- package/dist/datasets/sequence.d.ts +7 -0
- package/dist/datasets/sequence.d.ts.map +1 -0
- package/dist/datasets/types.d.ts +1 -0
- package/dist/datasets/types.d.ts.map +1 -1
- package/dist/datasets/validation.d.ts.map +1 -1
- package/dist/datasets/write.d.ts +37 -0
- package/dist/datasets/write.d.ts.map +1 -0
- package/dist/datasets/write.js +17 -0
- package/dist/datasets/write.js.map +9 -0
- package/dist/error-reporting/internal.js +4 -4
- package/dist/error-reporting/types.d.ts +7 -2
- package/dist/error-reporting/types.d.ts.map +1 -1
- package/dist/errors/catalog.d.ts +8 -0
- package/dist/errors/catalog.d.ts.map +1 -1
- package/dist/errors/internal.js +2 -2
- package/dist/events/execution.d.ts.map +1 -1
- package/dist/events/index.js +4 -4
- package/dist/events/types/datasets.d.ts +2 -6
- package/dist/events/types/datasets.d.ts.map +1 -1
- package/dist/execution/agent.d.ts +18 -9
- package/dist/execution/agent.d.ts.map +1 -1
- package/dist/execution/agent.js +62 -46
- package/dist/execution/agent.js.map +1 -1
- package/dist/execution/authorization.d.ts +68 -20
- package/dist/execution/authorization.d.ts.map +1 -1
- package/dist/execution/authorized-object-reader.d.ts +69 -0
- package/dist/execution/authorized-object-reader.d.ts.map +1 -0
- package/dist/execution/durable.d.ts.map +1 -1
- package/dist/execution/index.d.ts +1 -1
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/primitive.js +55 -46
- package/dist/execution/primitive.js.map +2 -2
- package/dist/execution/request.d.ts +14 -1
- package/dist/execution/request.d.ts.map +1 -1
- package/dist/execution/request.js +92 -54
- package/dist/execution/request.js.map +3 -3
- package/dist/execution/scopes.d.ts +16 -0
- package/dist/execution/scopes.d.ts.map +1 -1
- package/dist/execution/types.d.ts +10 -1
- package/dist/execution/types.d.ts.map +1 -1
- package/dist/http/api-routes.d.ts +2 -0
- package/dist/http/api-routes.d.ts.map +1 -1
- package/dist/http/index.js +1 -1
- package/dist/index.d.ts +15 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +128 -109
- package/dist/index.js.map +1 -1
- package/dist/json.d.ts +2 -0
- package/dist/json.d.ts.map +1 -1
- package/dist/lake-storage/definition-updates.d.ts.map +1 -1
- package/dist/lake-storage/errors.d.ts +5 -1
- package/dist/lake-storage/errors.d.ts.map +1 -1
- package/dist/lake-storage/in-memory.d.ts +1 -0
- package/dist/lake-storage/in-memory.d.ts.map +1 -1
- package/dist/lake-storage/index.d.ts +6 -1
- package/dist/lake-storage/index.d.ts.map +1 -1
- package/dist/lake-storage/index.js +27 -10
- package/dist/lake-storage/index.js.map +1 -1
- package/dist/lake-storage/merge-validation.d.ts.map +1 -1
- package/dist/lake-storage/merge.d.ts +13 -2
- package/dist/lake-storage/merge.d.ts.map +1 -1
- package/dist/lake-storage/source-ordering.d.ts +19 -0
- package/dist/lake-storage/source-ordering.d.ts.map +1 -0
- package/dist/lake-storage/sql-transforms.d.ts +2 -1
- package/dist/lake-storage/sql-transforms.d.ts.map +1 -1
- package/dist/lake-storage/types.d.ts +10 -5
- package/dist/lake-storage/types.d.ts.map +1 -1
- package/dist/lake-storage/version-inputs.d.ts +4 -0
- package/dist/lake-storage/version-inputs.d.ts.map +1 -0
- package/dist/logging/index.js +3 -3
- package/dist/logging/types.js +2 -2
- package/dist/materialization/index.js +2 -2
- package/dist/materializer/index.js +38 -31
- package/dist/materializer/index.js.map +1 -1
- package/dist/models/catalog.d.ts +40 -0
- package/dist/models/catalog.d.ts.map +1 -0
- package/dist/models/definitions.d.ts +25 -0
- package/dist/models/definitions.d.ts.map +1 -0
- package/dist/models/errors.d.ts +52 -0
- package/dist/models/errors.d.ts.map +1 -0
- package/dist/models/events.d.ts +192 -0
- package/dist/models/events.d.ts.map +1 -0
- package/dist/models/index.d.ts +17 -39
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +50 -0
- package/dist/models/index.js.map +9 -0
- package/dist/models/language-model.d.ts +90 -0
- package/dist/models/language-model.d.ts.map +1 -0
- package/dist/models/messages.d.ts +74 -0
- package/dist/models/messages.d.ts.map +1 -0
- package/dist/models/pricing.d.ts +69 -0
- package/dist/models/pricing.d.ts.map +1 -0
- package/dist/models/rate-card.d.ts +24 -0
- package/dist/models/rate-card.d.ts.map +1 -0
- package/dist/models/tools.d.ts +24 -0
- package/dist/models/tools.d.ts.map +1 -0
- package/dist/objects/authorized-ontology-view.d.ts +25 -0
- package/dist/objects/authorized-ontology-view.d.ts.map +1 -0
- package/dist/objects/execution.d.ts +1 -1
- package/dist/objects/execution.d.ts.map +1 -1
- package/dist/objects/index.js +43 -36
- package/dist/objects/index.js.map +1 -1
- package/dist/objects/link/authorization.d.ts +2 -7
- package/dist/objects/link/authorization.d.ts.map +1 -1
- package/dist/objects/query/executor.d.ts +4 -2
- package/dist/objects/query/executor.d.ts.map +1 -1
- package/dist/objects/query/index.js +36 -29
- package/dist/objects/query/index.js.map +1 -1
- package/dist/objects/query/links.d.ts +22 -1
- package/dist/objects/query/links.d.ts.map +1 -1
- package/dist/objects/query/selected-read-admission.d.ts +27 -0
- package/dist/objects/query/selected-read-admission.d.ts.map +1 -0
- package/dist/objects/query/validate.d.ts +60 -2
- package/dist/objects/query/validate.d.ts.map +1 -1
- package/dist/objects/sdk/object-handle.d.ts.map +1 -1
- package/dist/objects/sdk/object-set.d.ts.map +1 -1
- package/dist/objects/sdk/runtime-query-executor.d.ts +2 -7
- package/dist/objects/sdk/runtime-query-executor.d.ts.map +1 -1
- package/dist/objects/sdk/telemetry-channel.d.ts.map +1 -1
- package/dist/objects/service/list-service.d.ts +2 -3
- package/dist/objects/service/list-service.d.ts.map +1 -1
- package/dist/objects/telemetry/history.d.ts +8 -6
- package/dist/objects/telemetry/history.d.ts.map +1 -1
- package/dist/objects/telemetry/index.d.ts +2 -2
- package/dist/objects/telemetry/index.d.ts.map +1 -1
- package/dist/objects/telemetry/workload.d.ts +11 -0
- package/dist/objects/telemetry/workload.d.ts.map +1 -0
- package/dist/ontology/index.d.ts +2 -1
- package/dist/ontology/index.d.ts.map +1 -1
- package/dist/ontology/index.js +15 -14
- package/dist/ontology/index.js.map +1 -1
- package/dist/ontology/inference/index.d.ts +2 -1
- package/dist/ontology/inference/index.d.ts.map +1 -1
- package/dist/ontology/internal.d.ts +0 -1
- package/dist/ontology/internal.d.ts.map +1 -1
- package/dist/ontology/internal.js +5 -10
- package/dist/ontology/internal.js.map +3 -3
- package/dist/ontology/json-schema.d.ts +10 -6
- package/dist/ontology/json-schema.d.ts.map +1 -1
- package/dist/ontology/link-path-selection.d.ts +35 -0
- package/dist/ontology/link-path-selection.d.ts.map +1 -0
- package/dist/ontology/refs.d.ts +2 -0
- package/dist/ontology/refs.d.ts.map +1 -1
- package/dist/ontology/tokens.d.ts +2 -1
- package/dist/ontology/tokens.d.ts.map +1 -1
- package/dist/pipelines/execution.d.ts.map +1 -1
- package/dist/pipelines/index.js +41 -36
- package/dist/pipelines/index.js.map +1 -1
- package/dist/pipelines/request.d.ts.map +1 -1
- package/dist/projections/execution.d.ts.map +1 -1
- package/dist/projections/internal.js +39 -32
- package/dist/projections/internal.js.map +1 -1
- package/dist/projections/run-dispatch.d.ts.map +1 -1
- package/dist/queues/in-memory.d.ts +3 -2
- package/dist/queues/in-memory.d.ts.map +1 -1
- package/dist/queues/index.d.ts +3 -1
- package/dist/queues/index.d.ts.map +1 -1
- package/dist/queues/index.js +1 -1
- package/dist/queues/types.d.ts +15 -3
- package/dist/queues/types.d.ts.map +1 -1
- package/dist/rules/execution.d.ts.map +1 -1
- package/dist/runtime/create.d.ts +7 -4
- package/dist/runtime/create.d.ts.map +1 -1
- package/dist/runtime/definitions.d.ts +4 -2
- package/dist/runtime/definitions.d.ts.map +1 -1
- package/dist/runtime/host.d.ts +5 -2
- package/dist/runtime/host.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/resolve-definitions.d.ts +4 -2
- package/dist/runtime/resolve-definitions.d.ts.map +1 -1
- package/dist/runtime/sixb.d.ts +8 -2
- package/dist/runtime/sixb.d.ts.map +1 -1
- package/dist/runtime/types.d.ts +3 -0
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/schedules/execution.d.ts +2 -1
- package/dist/schedules/execution.d.ts.map +1 -1
- package/dist/security/every.d.ts +4 -4
- package/dist/security/every.d.ts.map +1 -1
- package/dist/security/grants.d.ts +12 -6
- package/dist/security/grants.d.ts.map +1 -1
- package/dist/security/index.d.ts +1 -1
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/registry.d.ts +2 -1
- package/dist/security/registry.d.ts.map +1 -1
- package/dist/security/types.d.ts +19 -5
- package/dist/security/types.d.ts.map +1 -1
- package/dist/security/validation.d.ts +6 -2
- package/dist/security/validation.d.ts.map +1 -1
- package/dist/shares/access-plan.d.ts +22 -0
- package/dist/shares/access-plan.d.ts.map +1 -0
- package/dist/shares/builders.d.ts +14 -0
- package/dist/shares/builders.d.ts.map +1 -0
- package/dist/shares/compiler.d.ts +14 -0
- package/dist/shares/compiler.d.ts.map +1 -0
- package/dist/shares/errors.d.ts +4 -0
- package/dist/shares/errors.d.ts.map +1 -0
- package/dist/shares/execution.d.ts +57 -0
- package/dist/shares/execution.d.ts.map +1 -0
- package/dist/shares/index.d.ts +10 -0
- package/dist/shares/index.d.ts.map +1 -0
- package/dist/shares/internal.d.ts +3 -0
- package/dist/shares/internal.d.ts.map +1 -0
- package/dist/shares/internal.js +239 -0
- package/dist/shares/internal.js.map +10 -0
- package/dist/shares/intersection.d.ts +9 -0
- package/dist/shares/intersection.d.ts.map +1 -0
- package/dist/shares/session-protocol.d.ts +41 -0
- package/dist/shares/session-protocol.d.ts.map +1 -0
- package/dist/shares/types.d.ts +51 -0
- package/dist/shares/types.d.ts.map +1 -0
- package/dist/shares/validation.d.ts +11 -0
- package/dist/shares/validation.d.ts.map +1 -0
- package/dist/storage/action-runs/failure.js +3 -3
- package/dist/storage/action-runs/provider.js +2 -2
- package/dist/storage/agents/errors.d.ts +1 -1
- package/dist/storage/agents/errors.d.ts.map +1 -1
- package/dist/storage/agents/in-memory.d.ts +3 -2
- package/dist/storage/agents/in-memory.d.ts.map +1 -1
- package/dist/storage/agents/index.d.ts +1 -1
- package/dist/storage/agents/index.d.ts.map +1 -1
- package/dist/storage/agents/provider.d.ts +11 -4
- package/dist/storage/agents/provider.d.ts.map +1 -1
- package/dist/storage/agents/provider.js +18 -15
- package/dist/storage/agents/provider.js.map +1 -1
- package/dist/storage/agents/types.d.ts +65 -17
- package/dist/storage/agents/types.d.ts.map +1 -1
- package/dist/storage/ai-cost/analytics.d.ts +2 -1
- package/dist/storage/ai-cost/analytics.d.ts.map +1 -1
- package/dist/storage/ai-cost/codec.d.ts +3 -2
- package/dist/storage/ai-cost/codec.d.ts.map +1 -1
- package/dist/storage/ai-cost/groups.d.ts +51 -0
- package/dist/storage/ai-cost/groups.d.ts.map +1 -0
- package/dist/storage/ai-cost/in-memory.d.ts +11 -1
- package/dist/storage/ai-cost/in-memory.d.ts.map +1 -1
- package/dist/storage/ai-cost/index.d.ts +1 -1
- package/dist/storage/ai-cost/index.d.ts.map +1 -1
- package/dist/storage/ai-cost/provider.d.ts +2 -0
- package/dist/storage/ai-cost/provider.d.ts.map +1 -1
- package/dist/storage/ai-cost/provider.js +29 -13
- package/dist/storage/ai-cost/provider.js.map +3 -3
- package/dist/storage/ai-cost/types.d.ts +64 -15
- package/dist/storage/ai-cost/types.d.ts.map +1 -1
- package/dist/storage/ai-cost/validation.d.ts +2 -1
- package/dist/storage/ai-cost/validation.d.ts.map +1 -1
- package/dist/storage/ai-limits/enforcement.d.ts +14 -0
- package/dist/storage/ai-limits/enforcement.d.ts.map +1 -0
- package/dist/storage/ai-limits/enforcement.js +21 -0
- package/dist/storage/ai-limits/enforcement.js.map +9 -0
- package/dist/storage/ai-limits/errors.d.ts +8 -0
- package/dist/storage/ai-limits/errors.d.ts.map +1 -0
- package/dist/storage/ai-limits/in-memory.d.ts +78 -0
- package/dist/storage/ai-limits/in-memory.d.ts.map +1 -0
- package/dist/storage/ai-limits/index.d.ts +7 -0
- package/dist/storage/ai-limits/index.d.ts.map +1 -0
- package/dist/storage/ai-limits/period.d.ts +4 -0
- package/dist/storage/ai-limits/period.d.ts.map +1 -0
- package/dist/storage/ai-limits/provider.d.ts +85 -0
- package/dist/storage/ai-limits/provider.d.ts.map +1 -0
- package/dist/storage/ai-limits/provider.js +62 -0
- package/dist/storage/ai-limits/provider.js.map +9 -0
- package/dist/storage/ai-limits/types.d.ts +175 -0
- package/dist/storage/ai-limits/types.d.ts.map +1 -0
- package/dist/storage/ai-usage/in-memory.d.ts +4 -0
- package/dist/storage/ai-usage/in-memory.d.ts.map +1 -1
- package/dist/storage/ai-usage/record.d.ts.map +1 -1
- package/dist/storage/ai-usage/types.d.ts +6 -2
- package/dist/storage/ai-usage/types.d.ts.map +1 -1
- package/dist/storage/auth/errors.d.ts +1 -1
- package/dist/storage/auth/errors.d.ts.map +1 -1
- package/dist/storage/auth/in-memory/auth-storage.d.ts +4 -1
- package/dist/storage/auth/in-memory/auth-storage.d.ts.map +1 -1
- package/dist/storage/auth/in-memory/device-authorizations.d.ts +29 -0
- package/dist/storage/auth/in-memory/device-authorizations.d.ts.map +1 -0
- package/dist/storage/auth/in-memory/shared.d.ts +3 -1
- package/dist/storage/auth/in-memory/shared.d.ts.map +1 -1
- package/dist/storage/auth/index.d.ts +2 -1
- package/dist/storage/auth/index.d.ts.map +1 -1
- package/dist/storage/auth/types.d.ts +66 -0
- package/dist/storage/auth/types.d.ts.map +1 -1
- package/dist/storage/connector-connections/provider.js +2 -2
- package/dist/storage/executions/in-memory.d.ts +3 -0
- package/dist/storage/executions/in-memory.d.ts.map +1 -1
- package/dist/storage/executions/provider.d.ts +4 -1
- package/dist/storage/executions/provider.d.ts.map +1 -1
- package/dist/storage/executions/provider.js +23 -3
- package/dist/storage/executions/provider.js.map +3 -3
- package/dist/storage/executions/run-link.d.ts +14 -2
- package/dist/storage/executions/run-link.d.ts.map +1 -1
- package/dist/storage/executions/validation.d.ts +6 -0
- package/dist/storage/executions/validation.d.ts.map +1 -1
- package/dist/storage/in-memory/index.d.ts +12 -0
- package/dist/storage/in-memory/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +15 -6
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +78 -36
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/objects/execution-limits.d.ts +25 -0
- package/dist/storage/objects/execution-limits.d.ts.map +1 -0
- package/dist/storage/objects/guard.d.ts +16 -0
- package/dist/storage/objects/guard.d.ts.map +1 -0
- package/dist/storage/objects/in-memory/index.d.ts +3 -0
- package/dist/storage/objects/in-memory/index.d.ts.map +1 -0
- package/dist/storage/objects/in-memory/keys.d.ts +10 -0
- package/dist/storage/objects/in-memory/keys.d.ts.map +1 -0
- package/dist/storage/objects/in-memory/query.d.ts +31 -0
- package/dist/storage/objects/in-memory/query.d.ts.map +1 -0
- package/dist/storage/objects/in-memory/read-scope.d.ts +18 -0
- package/dist/storage/objects/in-memory/read-scope.d.ts.map +1 -0
- package/dist/storage/objects/in-memory/read-source.d.ts +10 -0
- package/dist/storage/objects/in-memory/read-source.d.ts.map +1 -0
- package/dist/storage/objects/in-memory/selected-reader.d.ts +9 -0
- package/dist/storage/objects/in-memory/selected-reader.d.ts.map +1 -0
- package/dist/storage/objects/{in-memory.d.ts → in-memory/storage.d.ts} +13 -10
- package/dist/storage/objects/in-memory/storage.d.ts.map +1 -0
- package/dist/storage/objects/index.d.ts +4 -1
- package/dist/storage/objects/index.d.ts.map +1 -1
- package/dist/storage/objects/keys.d.ts +1 -1
- package/dist/storage/objects/keys.d.ts.map +1 -1
- package/dist/storage/objects/read-scope.d.ts +25 -0
- package/dist/storage/objects/read-scope.d.ts.map +1 -0
- package/dist/storage/objects/types.d.ts +114 -22
- package/dist/storage/objects/types.d.ts.map +1 -1
- package/dist/storage/ontology/provider.js +3 -3
- package/dist/storage/operation-scope.d.ts +3 -0
- package/dist/storage/operation-scope.d.ts.map +1 -1
- package/dist/storage/operation-scope.js +4 -2
- package/dist/storage/operation-scope.js.map +1 -1
- package/dist/storage/pipeline-runs/provider.js +2 -2
- package/dist/storage/projection-runs/provider.js +4 -4
- package/dist/storage/share-grants/errors.d.ts +8 -0
- package/dist/storage/share-grants/errors.d.ts.map +1 -0
- package/dist/storage/share-grants/in-memory.d.ts +11 -0
- package/dist/storage/share-grants/in-memory.d.ts.map +1 -0
- package/dist/storage/share-grants/index.d.ts +5 -0
- package/dist/storage/share-grants/index.d.ts.map +1 -0
- package/dist/storage/share-grants/provider.d.ts +4 -0
- package/dist/storage/share-grants/provider.d.ts.map +1 -0
- package/dist/storage/share-grants/provider.js +24 -0
- package/dist/storage/share-grants/provider.js.map +9 -0
- package/dist/storage/share-grants/record.d.ts +11 -0
- package/dist/storage/share-grants/record.d.ts.map +1 -0
- package/dist/storage/share-grants/types.d.ts +97 -0
- package/dist/storage/share-grants/types.d.ts.map +1 -0
- package/dist/storage/share-sessions/errors.d.ts +8 -0
- package/dist/storage/share-sessions/errors.d.ts.map +1 -0
- package/dist/storage/share-sessions/in-memory.d.ts +14 -0
- package/dist/storage/share-sessions/in-memory.d.ts.map +1 -0
- package/dist/storage/share-sessions/index.d.ts +5 -0
- package/dist/storage/share-sessions/index.d.ts.map +1 -0
- package/dist/storage/share-sessions/provider.d.ts +3 -0
- package/dist/storage/share-sessions/provider.d.ts.map +1 -0
- package/dist/storage/share-sessions/provider.js +20 -0
- package/dist/storage/share-sessions/provider.js.map +9 -0
- package/dist/storage/share-sessions/record.d.ts +8 -0
- package/dist/storage/share-sessions/record.d.ts.map +1 -0
- package/dist/storage/share-sessions/types.d.ts +50 -0
- package/dist/storage/share-sessions/types.d.ts.map +1 -0
- package/dist/storage/sync-runs/provider.js +2 -2
- package/dist/storage/transaction.d.ts +2 -1
- package/dist/storage/transaction.d.ts.map +1 -1
- package/dist/storage/types.d.ts +13 -1
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/storage/webhook-runs/provider.js +2 -2
- package/dist/storage/workflow-runs/provider.d.ts +1 -1
- package/dist/storage/workflow-runs/provider.js +14 -12
- package/dist/storage/workflow-runs/provider.js.map +1 -1
- package/dist/storage/workflow-runs/types.d.ts +5 -4
- package/dist/storage/workflow-runs/types.d.ts.map +1 -1
- package/dist/syncs/execution.d.ts.map +1 -1
- package/dist/syncs/index.js +41 -36
- package/dist/syncs/index.js.map +1 -1
- package/dist/syncs/request.d.ts.map +1 -1
- package/dist/testing/agent-execution.d.ts +3 -1
- package/dist/testing/agent-execution.d.ts.map +1 -1
- package/dist/testing/agent-storage-contract.d.ts.map +1 -1
- package/dist/testing/ai-cost-storage-contract.d.ts.map +1 -1
- package/dist/testing/ai-limit-storage-contract.d.ts +18 -0
- package/dist/testing/ai-limit-storage-contract.d.ts.map +1 -0
- package/dist/testing/ai-model-call-groups-contract.d.ts +6 -0
- package/dist/testing/ai-model-call-groups-contract.d.ts.map +1 -0
- package/dist/testing/ai-usage-storage-contract.d.ts.map +1 -1
- package/dist/testing/auth-storage-contract.d.ts.map +1 -1
- package/dist/testing/dataset-sequence-contract.d.ts +4 -0
- package/dist/testing/dataset-sequence-contract.d.ts.map +1 -0
- package/dist/testing/effective-storage-contract.d.ts.map +1 -1
- package/dist/testing/execution-storage-contract.d.ts +4 -0
- package/dist/testing/execution-storage-contract.d.ts.map +1 -1
- package/dist/testing/index.d.ts +5 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +5392 -2070
- package/dist/testing/index.js.map +21 -15
- package/dist/testing/lake-merge-storage-contract.d.ts +1 -0
- package/dist/testing/lake-merge-storage-contract.d.ts.map +1 -1
- package/dist/testing/lake-storage-contract.d.ts.map +1 -1
- package/dist/testing/object-read-scope-contract.d.ts +22 -0
- package/dist/testing/object-read-scope-contract.d.ts.map +1 -0
- package/dist/testing/queues-contract.d.ts.map +1 -1
- package/dist/testing/share-grant-storage-contract.d.ts +10 -0
- package/dist/testing/share-grant-storage-contract.d.ts.map +1 -0
- package/dist/testing/share-session-storage-contract.d.ts +9 -0
- package/dist/testing/share-session-storage-contract.d.ts.map +1 -0
- package/dist/webhooks/internal.js +36 -29
- package/dist/webhooks/internal.js.map +2 -2
- package/dist/workers/index.js +2 -2
- package/dist/workflows/agent-step-identity.d.ts +3 -0
- package/dist/workflows/agent-step-identity.d.ts.map +1 -0
- package/dist/workflows/builders.d.ts +2 -3
- package/dist/workflows/builders.d.ts.map +1 -1
- package/dist/workflows/execution.d.ts +1 -1
- package/dist/workflows/execution.d.ts.map +1 -1
- package/dist/workflows/failure.d.ts +1 -1
- package/dist/workflows/failure.d.ts.map +1 -1
- package/dist/workflows/index.d.ts +3 -2
- package/dist/workflows/index.d.ts.map +1 -1
- package/dist/workflows/index.js +63 -48
- package/dist/workflows/index.js.map +1 -1
- package/dist/workflows/request.d.ts.map +1 -1
- package/dist/workflows/types.d.ts +26 -11
- package/dist/workflows/types.d.ts.map +1 -1
- package/dist/workflows/validation.d.ts +7 -1
- package/dist/workflows/validation.d.ts.map +1 -1
- package/package.json +43 -4
- package/src/actions/delegated-admission.ts +72 -0
- package/src/actions/descriptor.ts +58 -0
- package/src/actions/execution.ts +99 -24
- package/src/actions/request.ts +136 -19
- package/src/actions/run-authorization.ts +53 -0
- package/src/actions/run-dispatch.ts +8 -1
- package/src/agents/adapters.ts +60 -456
- package/src/agents/authority.ts +215 -34
- package/src/agents/builders.ts +3 -50
- package/src/agents/context-compaction.ts +4 -0
- package/src/agents/context-resolution.ts +1 -4
- package/src/agents/dispatch.ts +59 -2
- package/src/agents/errors.ts +4 -11
- package/src/agents/execution.ts +65 -56
- package/src/agents/identity.ts +4 -0
- package/src/agents/ids.ts +16 -1
- package/src/agents/index.ts +23 -30
- package/src/agents/message.ts +20 -12
- package/src/agents/model-loop.ts +1071 -0
- package/src/agents/reference.ts +7 -0
- package/src/agents/request.ts +157 -77
- package/src/agents/retired-config.ts +20 -0
- package/src/agents/streams.ts +45 -19
- package/src/agents/tool-catalog.ts +21 -0
- package/src/agents/tool-definition.ts +9 -5
- package/src/agents/types.ts +39 -81
- package/src/agents/validation.ts +11 -216
- package/src/ai-usage/execution.ts +189 -0
- package/src/ai-usage/index.ts +15 -0
- package/src/authorization/decision.ts +54 -22
- package/src/authorization/grant-kinds.ts +72 -15
- package/src/authorization/index.ts +2 -0
- package/src/authorization/resolve.ts +12 -5
- package/src/authorization/types.ts +7 -5
- package/src/bootstrap/discovery.ts +3 -3
- package/src/bootstrap/ontology-type-manifest.ts +12 -6
- package/src/datasets/builders.ts +23 -2
- package/src/datasets/changes.ts +16 -4
- package/src/datasets/execution.ts +76 -5
- package/src/datasets/index.ts +1 -0
- package/src/datasets/sequence.ts +77 -0
- package/src/datasets/types.ts +1 -0
- package/src/datasets/validation.ts +26 -0
- package/src/datasets/write.ts +240 -0
- package/src/error-reporting/types.ts +4 -2
- package/src/errors/catalog.ts +8 -0
- package/src/events/execution.ts +57 -7
- package/src/events/types/datasets.ts +2 -6
- package/src/execution/agent.ts +129 -25
- package/src/execution/authorization.ts +493 -83
- package/src/execution/authorized-object-reader.ts +695 -0
- package/src/execution/durable.ts +10 -2
- package/src/execution/index.ts +1 -0
- package/src/execution/request.ts +67 -14
- package/src/execution/scopes.ts +36 -6
- package/src/execution/types.ts +9 -1
- package/src/http/api-routes.ts +108 -0
- package/src/index.ts +72 -22
- package/src/json.ts +9 -0
- package/src/lake-storage/definition-updates.ts +9 -0
- package/src/lake-storage/errors.ts +6 -1
- package/src/lake-storage/in-memory.ts +53 -17
- package/src/lake-storage/index.ts +10 -1
- package/src/lake-storage/merge-validation.ts +12 -2
- package/src/lake-storage/merge.ts +40 -2
- package/src/lake-storage/source-ordering.ts +95 -0
- package/src/lake-storage/sql-transforms.ts +2 -1
- package/src/lake-storage/types.ts +10 -5
- package/src/lake-storage/version-inputs.ts +14 -0
- package/src/models/catalog.ts +137 -0
- package/src/models/definitions.ts +202 -0
- package/src/models/errors.ts +83 -0
- package/src/models/events.ts +198 -0
- package/src/models/index.ts +89 -71
- package/src/models/language-model.ts +143 -0
- package/src/models/messages.ts +78 -0
- package/src/models/pricing.ts +390 -0
- package/src/models/rate-card.ts +101 -0
- package/src/models/tools.ts +29 -0
- package/src/objects/authorized-ontology-view.ts +512 -0
- package/src/objects/execution.ts +98 -143
- package/src/objects/link/authorization.ts +3 -2
- package/src/objects/query/executor.ts +45 -34
- package/src/objects/query/links.ts +84 -25
- package/src/objects/query/selected-read-admission.ts +310 -0
- package/src/objects/query/validate.ts +353 -36
- package/src/objects/sdk/object-handle.ts +2 -8
- package/src/objects/sdk/object-set.ts +10 -11
- package/src/objects/sdk/runtime-query-executor.ts +8 -28
- package/src/objects/sdk/telemetry-channel.ts +11 -7
- package/src/objects/service/list-service.ts +15 -29
- package/src/objects/telemetry/history.ts +297 -17
- package/src/objects/telemetry/index.ts +2 -2
- package/src/objects/telemetry/workload.ts +79 -0
- package/src/ontology/index.ts +7 -1
- package/src/ontology/inference/index.ts +4 -1
- package/src/ontology/internal.ts +0 -1
- package/src/ontology/json-schema.ts +13 -12
- package/src/ontology/link-path-selection.ts +193 -0
- package/src/ontology/refs.ts +19 -0
- package/src/ontology/tokens.ts +15 -8
- package/src/pipelines/execution.ts +30 -7
- package/src/pipelines/request.ts +5 -0
- package/src/projections/execution.ts +72 -11
- package/src/projections/run-dispatch.ts +6 -12
- package/src/queues/in-memory.ts +5 -0
- package/src/queues/index.ts +11 -0
- package/src/queues/types.ts +20 -3
- package/src/rules/execution.ts +20 -8
- package/src/runtime/create.ts +11 -5
- package/src/runtime/definitions.ts +4 -2
- package/src/runtime/host.ts +28 -8
- package/src/runtime/internal.ts +1 -0
- package/src/runtime/resolve-definitions.ts +22 -36
- package/src/runtime/sixb.ts +29 -10
- package/src/runtime/types.ts +3 -0
- package/src/schedules/execution.ts +24 -2
- package/src/security/every.ts +4 -4
- package/src/security/grants.ts +100 -14
- package/src/security/index.ts +3 -0
- package/src/security/registry.ts +9 -5
- package/src/security/types.ts +23 -4
- package/src/security/validation.ts +33 -9
- package/src/shares/access-plan.ts +225 -0
- package/src/shares/builders.ts +381 -0
- package/src/shares/compiler.ts +359 -0
- package/src/shares/errors.ts +3 -0
- package/src/shares/execution.ts +394 -0
- package/src/shares/index.ts +28 -0
- package/src/shares/internal.ts +9 -0
- package/src/shares/intersection.ts +178 -0
- package/src/shares/session-protocol.ts +258 -0
- package/src/shares/types.ts +76 -0
- package/src/shares/validation.ts +40 -0
- package/src/storage/agents/errors.ts +1 -0
- package/src/storage/agents/in-memory.ts +121 -11
- package/src/storage/agents/index.ts +7 -0
- package/src/storage/agents/provider.ts +150 -6
- package/src/storage/agents/types.ts +73 -16
- package/src/storage/ai-cost/analytics.ts +63 -6
- package/src/storage/ai-cost/codec.ts +37 -12
- package/src/storage/ai-cost/groups.ts +248 -0
- package/src/storage/ai-cost/in-memory.ts +42 -0
- package/src/storage/ai-cost/index.ts +6 -0
- package/src/storage/ai-cost/provider.ts +7 -0
- package/src/storage/ai-cost/types.ts +76 -14
- package/src/storage/ai-cost/validation.ts +147 -17
- package/src/storage/ai-limits/enforcement.ts +68 -0
- package/src/storage/ai-limits/errors.ts +23 -0
- package/src/storage/ai-limits/in-memory.ts +671 -0
- package/src/storage/ai-limits/index.ts +31 -0
- package/src/storage/ai-limits/period.ts +11 -0
- package/src/storage/ai-limits/provider.ts +430 -0
- package/src/storage/ai-limits/types.ts +195 -0
- package/src/storage/ai-usage/in-memory.ts +13 -0
- package/src/storage/ai-usage/record.ts +17 -0
- package/src/storage/ai-usage/types.ts +6 -2
- package/src/storage/auth/errors.ts +6 -0
- package/src/storage/auth/in-memory/auth-storage.ts +69 -0
- package/src/storage/auth/in-memory/device-authorizations.ts +145 -0
- package/src/storage/auth/in-memory/shared.ts +7 -0
- package/src/storage/auth/index.ts +7 -0
- package/src/storage/auth/types.ts +73 -0
- package/src/storage/executions/in-memory.ts +9 -1
- package/src/storage/executions/provider.ts +30 -1
- package/src/storage/executions/run-link.ts +45 -6
- package/src/storage/executions/validation.ts +82 -7
- package/src/storage/in-memory/index.ts +69 -6
- package/src/storage/index.ts +102 -1
- package/src/storage/objects/execution-limits.ts +283 -0
- package/src/storage/objects/guard.ts +55 -0
- package/src/storage/objects/in-memory/index.ts +2 -0
- package/src/storage/objects/in-memory/keys.ts +46 -0
- package/src/storage/objects/in-memory/query.ts +754 -0
- package/src/storage/objects/in-memory/read-scope.ts +211 -0
- package/src/storage/objects/in-memory/read-source.ts +10 -0
- package/src/storage/objects/in-memory/selected-reader.ts +252 -0
- package/src/storage/objects/in-memory/storage.ts +589 -0
- package/src/storage/objects/index.ts +21 -0
- package/src/storage/objects/keys.ts +1 -1
- package/src/storage/objects/read-scope.ts +672 -0
- package/src/storage/objects/types.ts +123 -19
- package/src/storage/operation-scope.ts +16 -0
- package/src/storage/share-grants/errors.ts +14 -0
- package/src/storage/share-grants/in-memory.ts +107 -0
- package/src/storage/share-grants/index.ts +14 -0
- package/src/storage/share-grants/provider.ts +11 -0
- package/src/storage/share-grants/record.ts +347 -0
- package/src/storage/share-grants/types.ts +112 -0
- package/src/storage/share-sessions/errors.ts +14 -0
- package/src/storage/share-sessions/in-memory.ts +105 -0
- package/src/storage/share-sessions/index.ts +11 -0
- package/src/storage/share-sessions/provider.ts +9 -0
- package/src/storage/share-sessions/record.ts +176 -0
- package/src/storage/share-sessions/types.ts +57 -0
- package/src/storage/transaction.ts +14 -2
- package/src/storage/types.ts +64 -0
- package/src/storage/workflow-runs/in-memory.ts +3 -3
- package/src/storage/workflow-runs/provider.ts +2 -2
- package/src/storage/workflow-runs/types.ts +6 -3
- package/src/syncs/execution.ts +25 -5
- package/src/syncs/request.ts +5 -0
- package/src/testing/agent-execution.ts +40 -28
- package/src/testing/agent-storage-contract.ts +249 -28
- package/src/testing/ai-cost-storage-contract.ts +96 -8
- package/src/testing/ai-limit-storage-contract.ts +1134 -0
- package/src/testing/ai-model-call-groups-contract.ts +353 -0
- package/src/testing/ai-usage-storage-contract.ts +31 -0
- package/src/testing/auth-storage-contract.ts +85 -0
- package/src/testing/dataset-sequence-contract.ts +373 -0
- package/src/testing/effective-storage-contract.ts +34 -0
- package/src/testing/execution-storage-contract.ts +81 -2
- package/src/testing/index.ts +26 -0
- package/src/testing/lake-merge-storage-contract.ts +3 -0
- package/src/testing/lake-storage-contract.ts +58 -0
- package/src/testing/object-read-scope-contract.ts +939 -0
- package/src/testing/queues-contract.ts +36 -1
- package/src/testing/share-grant-storage-contract.ts +325 -0
- package/src/testing/share-session-storage-contract.ts +235 -0
- package/src/workflows/agent-step-identity.ts +4 -0
- package/src/workflows/builders.ts +95 -9
- package/src/workflows/execution.ts +55 -16
- package/src/workflows/failure.ts +2 -2
- package/src/workflows/index.ts +3 -0
- package/src/workflows/request.ts +5 -0
- package/src/workflows/types.ts +23 -11
- package/src/workflows/validation.ts +100 -7
- package/dist/chunk-1e8m6yn3.js.map +0 -37
- package/dist/chunk-1g8negke.js.map +0 -11
- package/dist/chunk-4gz41why.js +0 -72
- package/dist/chunk-4gz41why.js.map +0 -11
- package/dist/chunk-5sxb1168.js.map +0 -34
- package/dist/chunk-6gjqgd3d.js.map +0 -11
- package/dist/chunk-819wnjz8.js.map +0 -12
- package/dist/chunk-a31h57d5.js.map +0 -13
- package/dist/chunk-a44d5zgd.js +0 -556
- package/dist/chunk-a44d5zgd.js.map +0 -16
- package/dist/chunk-ckxfnx7f.js.map +0 -13
- package/dist/chunk-dm72y8wt.js.map +0 -10
- package/dist/chunk-drjqm1aa.js.map +0 -15
- package/dist/chunk-dy311asx.js.map +0 -14
- package/dist/chunk-f6erf2vv.js.map +0 -10
- package/dist/chunk-f83ka50g.js.map +0 -23
- package/dist/chunk-fe5ev6mr.js +0 -55
- package/dist/chunk-fe5ev6mr.js.map +0 -11
- package/dist/chunk-h9kxd41f.js.map +0 -11
- package/dist/chunk-hceck7dq.js +0 -137
- package/dist/chunk-hceck7dq.js.map +0 -10
- package/dist/chunk-md8k0r54.js.map +0 -14
- package/dist/chunk-n4spznws.js.map +0 -11
- package/dist/chunk-nva1xkjz.js.map +0 -46
- package/dist/chunk-qewtks41.js.map +0 -11
- package/dist/chunk-t0jjkep3.js.map +0 -10
- package/dist/chunk-t624af60.js.map +0 -56
- package/dist/chunk-t8t39h7v.js.map +0 -10
- package/dist/chunk-t9xghkva.js +0 -28
- package/dist/chunk-t9xghkva.js.map +0 -10
- package/dist/chunk-x2yw73hy.js.map +0 -10
- package/dist/chunk-xc7hq65b.js.map +0 -10
- package/dist/storage/objects/in-memory.d.ts.map +0 -1
- package/src/storage/objects/in-memory.ts +0 -1241
- /package/dist/{chunk-zqysyfjt.js.map → chunk-08m3b6w8.js.map} +0 -0
- /package/dist/{chunk-z3zp0bj1.js.map → chunk-407j3msh.js.map} +0 -0
- /package/dist/{chunk-rhrbz7d4.js.map → chunk-4a849fr1.js.map} +0 -0
- /package/dist/{chunk-cy0n5dms.js.map → chunk-4jjp5k14.js.map} +0 -0
- /package/dist/{chunk-ezake7g1.js.map → chunk-5ntny1qx.js.map} +0 -0
- /package/dist/{chunk-72q2y8hn.js.map → chunk-8tsf6dmc.js.map} +0 -0
- /package/dist/{chunk-vybf6pkp.js.map → chunk-dbc80ad7.js.map} +0 -0
- /package/dist/{chunk-nkbfrt0c.js.map → chunk-f26bck4t.js.map} +0 -0
- /package/dist/{chunk-dsrkgtnh.js.map → chunk-jq43kdvk.js.map} +0 -0
- /package/dist/{chunk-wtmzkcht.js.map → chunk-k34z5rvh.js.map} +0 -0
- /package/dist/{chunk-htq0qh7z.js.map → chunk-ka3a2ft3.js.map} +0 -0
- /package/dist/{chunk-f2rt4vkh.js.map → chunk-n2w475r0.js.map} +0 -0
- /package/dist/{chunk-bhxaq2nn.js.map → chunk-qw9gvjv5.js.map} +0 -0
- /package/dist/{chunk-dysw7nsm.js.map → chunk-rv2hkwwa.js.map} +0 -0
- /package/dist/{chunk-ghteq96b.js.map → chunk-s5y30bc9.js.map} +0 -0
- /package/dist/{chunk-xkthy56g.js.map → chunk-w1tvjszy.js.map} +0 -0
- /package/dist/{chunk-8b55ygje.js.map → chunk-w3e09qqk.js.map} +0 -0
- /package/dist/{chunk-62c7t4jc.js.map → chunk-wdage1eb.js.map} +0 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/objects/action/request.ts", "../src/objects/errors.ts", "../src/objects/materializer-adapter.ts", "../src/objects/link/authorization.ts", "../src/objects/link/remove.ts", "../src/objects/link/endpoints.ts", "../src/objects/link/upsert.ts", "../src/objects/runtime-batch.ts", "../src/objects/link/upsert-batch.ts", "../src/objects/object/delete.ts", "../src/objects/object/upsert.ts", "../src/objects/object/upsert-batch.ts", "../src/objects/telemetry/write-batch.ts", "../src/objects/telemetry/append-batch.ts", "../src/objects/telemetry/history.ts", "../src/objects/context/resolve.ts", "../src/objects/sdk/telemetry-channel.ts", "../src/objects/sdk/object-handle.ts", "../src/objects/sdk/runtime-query-executor.ts", "../src/objects/sdk/object-set.ts", "../src/objects/service/action-service.ts", "../src/objects/service/link-service.ts", "../src/objects/service/list-service.ts", "../src/objects/service/object-service.ts", "../src/objects/service/telemetry-service.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Compatibility leaf operation: request an action on an object.\n *\n * The canonical action request path lives in `actions/request.ts`; object-bound\n * helpers delegate here by supplying an object subject.\n */\nimport {\n type RequestActionAndWaitOptions,\n type RequestActionOptions,\n type RequestActionResult,\n requestAction as requestRuntimeAction,\n requestActionAndWait as requestRuntimeActionAndWait,\n} from \"../../actions/request\"\nimport type { ActionRunRecord } from \"../../storage\"\nimport type { ExecutionObjectContext } from \"../context\"\n\nexport type { RequestActionAndWaitOptions, RequestActionOptions }\n\nexport async function requestAction(\n ctx: ExecutionObjectContext,\n params: {\n primaryId: string\n actionId: string\n params?: Record<string, unknown>\n options?: RequestActionOptions\n }\n): Promise<RequestActionResult> {\n return requestRuntimeAction(ctx, ctx.execution, {\n actionId: params.actionId,\n subject: {\n kind: \"object\",\n objectTypeId: ctx.objectType.id,\n primaryId: params.primaryId,\n },\n params: params.params,\n runId: params.options?.runId,\n signal: params.options?.signal,\n })\n}\n\nexport async function requestActionAndWait(\n ctx: ExecutionObjectContext,\n params: {\n primaryId: string\n actionId: string\n params?: Record<string, unknown>\n options?: RequestActionAndWaitOptions\n }\n): Promise<ActionRunRecord> {\n return requestRuntimeActionAndWait(ctx, ctx.execution, {\n actionId: params.actionId,\n subject: {\n kind: \"object\",\n objectTypeId: ctx.objectType.id,\n primaryId: params.primaryId,\n },\n params: params.params,\n runId: params.options?.runId,\n timeoutMs: params.options?.timeoutMs,\n signal: params.options?.signal,\n onRequested: params.options?.onRequested,\n })\n}\n",
|
|
6
|
+
"/**\n * Error for runtime invariants and failures specific to the objects module\n * (e.g., unexpected event results after appending an object/link event).\n */\nexport class ObjectError extends Error {\n readonly name = \"ObjectError\"\n}\n",
|
|
7
|
+
"/**\n * Runtime translation onto the ontology Materializer.\n *\n * Every typed and dynamic object/link mutation lowers to canonical Materializer operations here and\n * every Materializer result is mapped back to the public runtime shapes. The adapter owns no\n * ontology semantics: authority classification, effective resolution, validation, and event\n * construction all happen inside the Materializer's single commit.\n */\n\nimport { randomUUID } from \"node:crypto\"\nimport type { JsonValue } from \"../json\"\nimport type {\n EditCommitResult,\n EffectiveObjectSnapshot,\n MaterializationItemError,\n OntologyEditOperation,\n OntologyLinkRef,\n OntologyObjectRef,\n OntologyOperationOutcome,\n} from \"../materialization/model\"\nimport { normalizeJsonProperties } from \"../materializer\"\nimport type { ObjectLink, ValueType } from \"../ontology\"\nimport { OntologyValidationError } from \"../ontology/errors\"\nimport type { ObjectTypeWithPropertyTokens } from \"../ontology/tokens\"\nimport {\n assertKnownProperties,\n assertLinkTargetType,\n normalizeLinkProperties,\n normalizeObjectProperties,\n validateLinkProperties,\n validateObjectProperties,\n} from \"../ontology/validation\"\nimport { getOntologyMutationRuntime } from \"../runtime/ontology-mutations\"\nimport type { SixbRuntimeContext } from \"../runtime/types\"\nimport type { ObjectRow } from \"../storage\"\nimport { ObjectError } from \"./errors\"\n\n/** The runtime pieces one commit needs. */\nexport type RuntimeMaterializerContext = Pick<SixbRuntimeContext, \"projectId\" | \"storage\">\n\n/** One caller-supplied batch item, lowered to the operations it contributes. */\nexport interface RuntimeBatchGroup {\n /** Position in the caller's input array; item errors are reported against it. */\n readonly index: number\n readonly operations: readonly OntologyEditOperation[]\n}\n\nexport interface RuntimeBatchCommit {\n readonly commit: EditCommitResult | null\n /** Outcomes per input position, in the order the item's operations were submitted. */\n readonly outcomes: ReadonlyMap<number, readonly OntologyOperationOutcome[]>\n}\n\n/**\n * Commits ordered operations as one atomic runtime commit.\n *\n * A fresh request id per call keeps each runtime mutation its own commit; the Materializer's\n * idempotency replay then only collapses a retry of the very same request.\n */\nexport async function commitRuntimeOperations(\n ctx: RuntimeMaterializerContext,\n operations: readonly OntologyEditOperation[]\n): Promise<EditCommitResult> {\n const mutations = getOntologyMutationRuntime(ctx)\n const commit = await mutations.commitEdits({\n mode: \"atomic\",\n source: { kind: \"runtime\", requestId: randomUUID() },\n operations,\n expectedObjects: [],\n expectedLinks: [],\n expectedLinkScopes: [],\n })\n return commit\n}\n\n/**\n * Commits grouped batch operations as one ordered continue-mode transaction.\n *\n * Successful items apply against one evolving authority state while semantic failures are recorded\n * per item. Provider, serialization, and CAS failures still roll the whole transaction back.\n *\n * An item that lowers to several operations is declared as one operation group so the Materializer\n * rolls the whole item back rather than committing the operations that ran before the failure.\n */\nexport async function commitRuntimeBatch(\n ctx: RuntimeMaterializerContext,\n groups: readonly RuntimeBatchGroup[]\n): Promise<RuntimeBatchCommit> {\n const operations = groups.flatMap((group) => group.operations)\n if (operations.length === 0) {\n return { commit: null, outcomes: new Map() }\n }\n\n const operationGroups = groups\n .filter((group) => group.operations.length > 1)\n .map((group) => group.operations.map((operation) => operation.id))\n\n const mutations = getOntologyMutationRuntime(ctx)\n const commit = await mutations.commitEdits({\n mode: \"continue\",\n source: { kind: \"runtime\", requestId: randomUUID() },\n operations,\n ...(operationGroups.length > 0 ? { operationGroups } : {}),\n })\n\n const byId = new Map(commit.outcomes.map((outcome) => [outcome.id, outcome]))\n const outcomes = new Map<number, readonly OntologyOperationOutcome[]>()\n for (const group of groups) {\n outcomes.set(\n group.index,\n group.operations.map((operation) => requireOutcome(byId, operation.id))\n )\n }\n return { commit, outcomes }\n}\n\n/**\n * Assigns the canonical operation id for one batch item.\n *\n * Ids derive from the caller's original ordinal so outcomes map back to input positions even when\n * earlier items failed local validation and never reached the Materializer.\n */\nexport function runtimeOperationId(index: number, subOrdinal = 0): string {\n return subOrdinal === 0 ? `op:${index}` : `op:${index}.${subOrdinal}`\n}\n\nexport interface NormalizedRuntimeObject {\n readonly primaryId: string\n /** Managed authority values; identity lives in the object ref, never in the properties. */\n readonly properties: Readonly<Record<string, JsonValue>>\n}\n\n/**\n * Validates and normalizes one runtime object input at the SDK/service boundary.\n *\n * Shape and value-type errors surface here so a batch can report them against the caller's original\n * position. Authority classification, required-property enforcement, and cardinality stay in the\n * Materializer, which validates the resolved effective object instead of the request.\n */\nexport function normalizeRuntimeObject(input: {\n readonly objectType: ObjectTypeWithPropertyTokens\n readonly primaryPropertyId: string\n readonly properties: Record<string, unknown>\n readonly valueTypesById: ReadonlyMap<string, ValueType>\n}): NormalizedRuntimeObject {\n const { objectType, primaryPropertyId, properties, valueTypesById } = input\n assertKnownProperties(objectType, properties)\n validateObjectProperties(objectType, properties, valueTypesById)\n\n const primaryValue = properties[primaryPropertyId]\n if (primaryValue === undefined || primaryValue === null) {\n throw new OntologyValidationError(\n `[Sixb] Missing primary property '${primaryPropertyId}' in upsert for '${objectType.id}'`\n )\n }\n\n const normalized = normalizeObjectProperties(\n objectType.properties,\n properties,\n valueTypesById,\n objectType.id\n )\n const { [primaryPropertyId]: _identity, ...managed } = normalized\n return {\n primaryId: String(primaryValue),\n properties: normalizeJsonProperties(managed, `${objectType.id} properties`),\n }\n}\n\n/**\n * Validates and normalizes one runtime link input.\n *\n * Managed link authority carries the complete property set, so required link properties must be\n * present in the request rather than inherited from the stored edge.\n */\nexport function normalizeRuntimeLink(input: {\n readonly objectType: ObjectTypeWithPropertyTokens\n readonly linkDefinition: ObjectLink\n readonly linkId: string\n readonly targetTypeId: string\n readonly properties?: Record<string, unknown>\n readonly valueTypesById: ReadonlyMap<string, ValueType>\n readonly isValidLinkTarget: (expected: string | string[], actual: string) => boolean\n}): Readonly<Record<string, JsonValue>> | undefined {\n const { objectType, linkDefinition, linkId, targetTypeId, properties, valueTypesById } = input\n assertLinkTargetType(objectType.id, linkId, linkDefinition, targetTypeId, input.isValidLinkTarget)\n validateLinkProperties(objectType, linkDefinition, properties, undefined, valueTypesById)\n const normalized = normalizeLinkProperties(objectType, linkDefinition, properties, valueTypesById)\n if (normalized === undefined) return undefined\n return normalizeJsonProperties(normalized, `${objectType.id}.${linkId} properties`)\n}\n\nexport function objectUpsertOperation(input: {\n readonly id: string\n readonly ref: OntologyObjectRef\n readonly properties: Readonly<Record<string, JsonValue>>\n}): OntologyEditOperation {\n return { id: input.id, kind: \"object.upsert\", ref: input.ref, properties: input.properties }\n}\n\nexport function objectDeleteOperation(input: {\n readonly id: string\n readonly ref: OntologyObjectRef\n}): OntologyEditOperation {\n return { id: input.id, kind: \"object.delete\", ref: input.ref }\n}\n\nexport function objectRestoreOperation(input: {\n readonly id: string\n readonly ref: OntologyObjectRef\n}): OntologyEditOperation {\n return { id: input.id, kind: \"object.restore\", ref: input.ref }\n}\n\nexport function linkUpsertOperation(input: {\n readonly id: string\n readonly ref: OntologyLinkRef\n readonly properties?: Readonly<Record<string, JsonValue>>\n}): OntologyEditOperation {\n return {\n id: input.id,\n kind: \"link.upsert\",\n ref: input.ref,\n ...(input.properties !== undefined ? { properties: input.properties } : {}),\n }\n}\n\nexport function linkDeleteOperation(input: {\n readonly id: string\n readonly ref: OntologyLinkRef\n}): OntologyEditOperation {\n return { id: input.id, kind: \"link.delete\", ref: input.ref }\n}\n\n/** Reads the outcomes one batch item produced; the commit returns one per submitted operation. */\nexport function requireItemOutcomes(\n commit: RuntimeBatchCommit,\n index: number\n): readonly OntologyOperationOutcome[] {\n const outcomes = commit.outcomes.get(index)\n if (!outcomes || outcomes.length === 0) {\n throw new ObjectError(`[Sixb] Materializer returned no outcome for batch item ${index}.`)\n }\n return outcomes\n}\n\n/** Reads the effective object an ok outcome produced; runtime object writes always resolve one. */\nexport function requireEffectiveObject(outcome: OntologyOperationOutcome): EffectiveObjectSnapshot {\n if (!outcome.ok || !outcome.object) {\n throw new ObjectError(`[Sixb] Materializer returned no effective object for '${outcome.id}'.`)\n }\n return outcome.object\n}\n\nexport function toObjectRow(projectId: string, snapshot: EffectiveObjectSnapshot): ObjectRow {\n return {\n projectId,\n objectTypeId: snapshot.ref.objectTypeId,\n primaryId: snapshot.ref.primaryId,\n properties: structuredClone(snapshot.properties) as Record<string, unknown>,\n createdAt: new Date(snapshot.createdAt),\n updatedAt: new Date(snapshot.updatedAt),\n version: snapshot.version,\n lastCommitId: snapshot.lastCommitId,\n }\n}\n\n/** Rehydrates a persisted item error into the public runtime error type. */\nexport function toItemError(error: MaterializationItemError): Error {\n switch (error.code) {\n case \"validation\":\n return new OntologyValidationError(error.message)\n }\n}\n\nfunction requireOutcome(\n outcomes: ReadonlyMap<string, OntologyOperationOutcome>,\n id: string\n): OntologyOperationOutcome {\n const outcome = outcomes.get(id)\n if (!outcome) {\n throw new ObjectError(`[Sixb] Materializer returned no outcome for '${id}'.`)\n }\n return outcome\n}\n",
|
|
8
|
+
"/**\n * The authorization rule for writing a link, in one place because all three link leaves need it.\n */\nimport { assertAuthorized, assertCanEdit } from \"../../authorization\"\nimport type { SixbRuntimeContext } from \"../../runtime/types\"\n\n/**\n * Assert a principal may create or remove a link.\n *\n * `edit` on the **source** type, `view` on the **target**: a link is declared on the source type\n * (`objectType.links`), and writing one changes the source's edges, not the target's properties.\n * Requiring `edit` on the target too would mean a clerk needs write access to every customer before\n * attaching an invoice to one.\n *\n * `view` on the target is still required, and for two reasons: it matches how links are *read* —\n * `canViewLink` already demands `view` on both endpoints — and without it the endpoint-existence\n * check that follows would answer whether a target the principal cannot see exists.\n *\n * Call this *before* any endpoint lookup, for that second reason.\n */\nexport function assertCanWriteLink(\n ctx: Pick<SixbRuntimeContext, \"projectId\" | \"runtimeAuthorization\" | \"authorization\">,\n endpoints: { readonly sourceTypeId: string; readonly targetTypeId: string }\n): void {\n assertCanEdit(ctx, endpoints.sourceTypeId)\n assertAuthorized(ctx, { kind: \"object.view\", objectTypeId: endpoints.targetTypeId })\n}\n",
|
|
9
|
+
"/**\n * Leaf operation: remove a single link through the ontology Materializer.\n */\nimport { assertLinkTargetType } from \"../../ontology/validation\"\nimport type { ResolvedLinkContext } from \"../context\"\nimport {\n commitRuntimeOperations,\n linkDeleteOperation,\n runtimeOperationId,\n} from \"../materializer-adapter\"\nimport { assertCanWriteLink } from \"./authorization\"\n\nexport async function removeLink(\n ctx: ResolvedLinkContext,\n params: {\n sourceId: string\n linkId: string\n targetTypeId: string\n targetId: string\n }\n): Promise<void> {\n const { objectType, linkDefinition, ontology } = ctx\n const { sourceId, linkId, targetTypeId, targetId } = params\n assertCanWriteLink(ctx, { sourceTypeId: objectType.id, targetTypeId })\n\n assertLinkTargetType(objectType.id, linkId, linkDefinition, targetTypeId, (expected, actual) =>\n ontology.isValidLinkTarget(expected, actual)\n )\n\n // A missing link is a no-op: the delete records managed authority only when an effective edge\n // exists, so the commit reports `unchanged` instead of failing.\n await commitRuntimeOperations(ctx, [\n linkDeleteOperation({\n id: runtimeOperationId(0),\n ref: {\n source: { objectTypeId: objectType.id, primaryId: sourceId },\n linkId,\n target: { objectTypeId: targetTypeId, primaryId: targetId },\n },\n }),\n ])\n}\n",
|
|
10
|
+
"/**\n * Shared endpoint existence reads for runtime link batches.\n *\n * The Materializer independently refuses a link whose endpoints are not effective. These reads exist\n * only so batch callers keep receiving the public {@link ObjectNotFoundError} for a missing endpoint\n * instead of a generic per-item validation error.\n */\n\nimport type { SixbRuntimeContext } from \"../../runtime/types\"\nimport { objectBatchKey } from \"../../storage\"\nimport { ObjectNotFoundError } from \"../../storage/errors\"\n\nexport interface LinkEndpointItem {\n readonly objectType: { readonly id: string }\n readonly sourceId: string\n readonly targetTypeId: string\n readonly targetId: string\n}\n\nexport type EndpointExistence = ReadonlySet<string>\n\nexport function collectEndpointLookups(\n items: readonly LinkEndpointItem[]\n): { objectTypeId: string; primaryId: string }[] {\n const lookups: { objectTypeId: string; primaryId: string }[] = []\n const seen = new Set<string>()\n\n for (const item of items) {\n for (const endpoint of [\n { objectTypeId: item.objectType.id, primaryId: item.sourceId },\n { objectTypeId: item.targetTypeId, primaryId: item.targetId },\n ]) {\n const key = endpointKey(endpoint.objectTypeId, endpoint.primaryId)\n if (seen.has(key)) continue\n seen.add(key)\n lookups.push(endpoint)\n }\n }\n\n return lookups\n}\n\nexport async function loadEndpointExistence(\n ctx: Pick<SixbRuntimeContext, \"projectId\" | \"storage\">,\n lookups: readonly { objectTypeId: string; primaryId: string }[]\n): Promise<EndpointExistence> {\n if (lookups.length === 0) return new Set()\n const rows = await ctx.storage.objects.getByPrimaryIdBatch({\n projectId: ctx.projectId,\n items: lookups,\n })\n return new Set(rows.keys())\n}\n\n/** Throws {@link ObjectNotFoundError} for the first endpoint the read did not find. */\nexport function requireEndpoints(item: LinkEndpointItem, existing: EndpointExistence): void {\n if (!existing.has(endpointKey(item.objectType.id, item.sourceId))) {\n throw new ObjectNotFoundError(item.objectType.id, item.sourceId, \"Source object not found\")\n }\n if (!existing.has(endpointKey(item.targetTypeId, item.targetId))) {\n throw new ObjectNotFoundError(item.targetTypeId, item.targetId, \"Target object not found\")\n }\n}\n\nfunction endpointKey(objectTypeId: string, primaryId: string): string {\n return objectBatchKey(objectTypeId, primaryId)\n}\n",
|
|
11
|
+
"/**\n * Leaf operation: upsert a single link through the ontology Materializer.\n */\nimport type { ResolvedLinkContext } from \"../context\"\nimport {\n commitRuntimeOperations,\n linkUpsertOperation,\n normalizeRuntimeLink,\n runtimeOperationId,\n} from \"../materializer-adapter\"\nimport { assertCanWriteLink } from \"./authorization\"\nimport { collectEndpointLookups, loadEndpointExistence, requireEndpoints } from \"./endpoints\"\n\nexport async function upsertLink(\n ctx: ResolvedLinkContext,\n params: {\n sourceId: string\n linkId: string\n targetTypeId: string\n targetId: string\n properties?: Record<string, unknown>\n }\n): Promise<void> {\n const { objectType, linkDefinition, ontology } = ctx\n const { sourceId, linkId, targetTypeId, targetId, properties } = params\n assertCanWriteLink(ctx, { sourceTypeId: objectType.id, targetTypeId })\n const endpoints = { objectType, sourceId, targetTypeId, targetId }\n\n // Endpoint reads keep the public `ObjectNotFoundError` contract; the Materializer independently\n // refuses a link whose endpoints are not effective when it commits. This runs before property\n // normalization so the same input reports the same error class here and through the batch APIs,\n // which check endpoints first inside `plan`.\n requireEndpoints(endpoints, await loadEndpointExistence(ctx, collectEndpointLookups([endpoints])))\n\n const normalizedProperties = normalizeRuntimeLink({\n objectType,\n linkDefinition,\n linkId,\n targetTypeId,\n properties,\n valueTypesById: ontology.getValueTypesById(),\n isValidLinkTarget: (expected, actual) => ontology.isValidLinkTarget(expected, actual),\n })\n\n await commitRuntimeOperations(ctx, [\n linkUpsertOperation({\n id: runtimeOperationId(0),\n ref: {\n source: { objectTypeId: objectType.id, primaryId: sourceId },\n linkId,\n target: { objectTypeId: targetTypeId, primaryId: targetId },\n },\n ...(normalizedProperties !== undefined ? { properties: normalizedProperties } : {}),\n }),\n ])\n}\n",
|
|
12
|
+
"/**\n * Per-item mechanics shared by every runtime batch.\n *\n * One place owns the rules the public batch APIs promise: a local failure stays at its own input\n * position, an identical repeat collapses onto the first item and shares its result, a conflicting\n * repeat is rejected, and each item's Materializer outcomes map back to the position they came from.\n */\n\nimport type { OntologyEditOperation, OntologyOperationOutcome } from \"../materialization/model\"\nimport { OntologyValidationError } from \"../ontology/errors\"\nimport type { BatchItemResult } from \"../runtime/types\"\nimport {\n commitRuntimeBatch,\n type RuntimeMaterializerContext,\n requireItemOutcomes,\n toItemError,\n} from \"./materializer-adapter\"\n\nexport interface RuntimeBatchItemPlan {\n /** Identity this item claims. A later item claiming it must be identical. */\n readonly key: string\n /** How that identity reads in an error message, e.g. `object 'room:r1'`. */\n readonly label: string\n /** Canonical content, so an identical repeat is recognized as one. */\n readonly fingerprint: string\n readonly operations: readonly OntologyEditOperation[]\n}\n\nexport interface RuntimeItemBatch<TItem, TValue> {\n readonly ctx: RuntimeMaterializerContext\n readonly items: readonly TItem[]\n /** Lowers one item, throwing to record a local failure at that item's position. */\n plan(item: TItem, index: number): RuntimeBatchItemPlan\n /** Maps the outcomes of a fully successful item to its public value. */\n value(outcomes: readonly OntologyOperationOutcome[]): TValue\n}\n\ninterface PlannedItem {\n readonly index: number\n readonly operations: readonly OntologyEditOperation[]\n}\n\ninterface ClaimedIdentity {\n readonly index: number\n readonly fingerprint: string\n}\n\nexport async function runRuntimeItemBatch<TItem, TValue>(\n batch: RuntimeItemBatch<TItem, TValue>\n): Promise<readonly BatchItemResult<TValue>[]> {\n const { items } = batch\n if (items.length === 0) return []\n\n const results: BatchItemResult<TValue>[] = new Array(items.length)\n const planned: PlannedItem[] = []\n const claims = new Map<string, ClaimedIdentity>()\n /** Positions that repeat an earlier identical item and share its result. */\n const aliases = new Map<number, number>()\n\n for (const [index, item] of items.entries()) {\n let plan: RuntimeBatchItemPlan\n try {\n plan = batch.plan(item, index)\n } catch (error) {\n results[index] = {\n ok: false,\n error: error instanceof Error ? error : new Error(String(error)),\n }\n continue\n }\n\n const claimed = claims.get(plan.key)\n if (claimed) {\n if (claimed.fingerprint !== plan.fingerprint) {\n results[index] = {\n ok: false,\n error: new OntologyValidationError(\n `[Sixb] Conflicting duplicate ${plan.label} at batch positions ${claimed.index} and ${index}`\n ),\n }\n continue\n }\n aliases.set(index, claimed.index)\n continue\n }\n\n claims.set(plan.key, { index, fingerprint: plan.fingerprint })\n planned.push({ index, operations: plan.operations })\n }\n\n const commit = await commitRuntimeBatch(batch.ctx, planned)\n\n for (const { index } of planned) {\n const outcomes = requireItemOutcomes(commit, index)\n const failed = outcomes.find((outcome) => !outcome.ok)\n results[index] =\n failed?.ok === false\n ? { ok: false, error: toItemError(failed.error) }\n : { ok: true, value: batch.value(outcomes) }\n }\n for (const [index, source] of aliases) {\n results[index] = results[source]\n }\n return results\n}\n",
|
|
13
|
+
"/**\n * Leaf operation: batch upsert links through the ontology Materializer.\n *\n * Takes SixbRuntimeContext (shared infra) + per-item pre-resolved data, because each item can target\n * a different objectType + linkDefinition. Everything valid is submitted as one ordered\n * continue-mode commit.\n */\n\nimport { stableJsonStringify } from \"../../json\"\nimport { linkRefKey } from \"../../materialization/refs\"\nimport type { BatchItemResult, SixbRuntimeContext } from \"../../runtime/types\"\nimport type { ResolvedLinkBatchItem } from \"../context\"\nimport {\n linkUpsertOperation,\n normalizeRuntimeLink,\n runtimeOperationId,\n} from \"../materializer-adapter\"\nimport { runRuntimeItemBatch } from \"../runtime-batch\"\nimport { assertCanWriteLink } from \"./authorization\"\nimport { collectEndpointLookups, loadEndpointExistence, requireEndpoints } from \"./endpoints\"\n\nexport async function upsertLinkBatch(\n ctx: SixbRuntimeContext,\n items: readonly ResolvedLinkBatchItem[]\n): Promise<readonly BatchItemResult<void>[]> {\n const { ontology } = ctx\n if (items.length === 0) return []\n\n // Every item, up front, and before the endpoint lookup below. Authorization is a precondition, not\n // a per-item validation: a refused item must not become one failed `BatchItemResult` while the\n // rest of the batch commits. Asserting inside `plan` would do exactly that, and would also let the\n // existence lookup answer for targets the principal cannot see.\n for (const item of items) {\n assertCanWriteLink(ctx, {\n sourceTypeId: item.objectType.id,\n targetTypeId: item.targetTypeId,\n })\n }\n\n const existing = await loadEndpointExistence(ctx, collectEndpointLookups(items))\n const valueTypesById = ontology.getValueTypesById()\n\n return runRuntimeItemBatch({\n ctx,\n items,\n plan(item, index) {\n requireEndpoints(item, existing)\n const properties = normalizeRuntimeLink({\n objectType: item.objectType,\n linkDefinition: item.linkDefinition,\n linkId: item.linkId,\n targetTypeId: item.targetTypeId,\n properties: item.properties,\n valueTypesById,\n isValidLinkTarget: (expected, actual) => ontology.isValidLinkTarget(expected, actual),\n })\n const ref = {\n source: { objectTypeId: item.objectType.id, primaryId: item.sourceId },\n linkId: item.linkId,\n target: { objectTypeId: item.targetTypeId, primaryId: item.targetId },\n }\n const edge = linkRefKey(ref)\n return {\n key: edge,\n // The key is a JSON array, which is unreadable in the error an operator sees on a failed\n // link projection. Name the edge the way the object path names an object.\n label: `link '${item.objectType.id}:${item.sourceId}.${item.linkId} -> ${item.targetTypeId}:${item.targetId}'`,\n fingerprint: stableJsonStringify(properties ?? null),\n operations: [\n linkUpsertOperation({\n id: runtimeOperationId(index),\n ref,\n ...(properties !== undefined ? { properties } : {}),\n }),\n ],\n }\n },\n value: () => undefined,\n })\n}\n",
|
|
14
|
+
"/**\n * Leaf operations: delete and restore a single object through the ontology Materializer.\n *\n * Both are thin wrappers over one materializer operation, exactly like `removeLink` — the cascade\n * over links and the effective-state bookkeeping happen inside the commit.\n */\nimport { assertCanEdit } from \"../../authorization\"\nimport type { ResolvedObjectContext } from \"../context\"\nimport {\n commitRuntimeOperations,\n objectDeleteOperation,\n objectRestoreOperation,\n runtimeOperationId,\n} from \"../materializer-adapter\"\n\n/**\n * Delete the object with this primary id.\n *\n * A missing object is a no-op: the delete records managed authority only where effective state\n * exists, so the commit reports `unchanged` rather than failing. An object a projection also writes\n * stays hidden even while the projection keeps asserting it — `restore()` is what reveals it again.\n */\nexport async function deleteObject(ctx: ResolvedObjectContext, primaryId: string): Promise<void> {\n assertCanEdit(ctx, ctx.objectType.id)\n await commitRuntimeOperations(ctx, [\n objectDeleteOperation({\n id: runtimeOperationId(0),\n ref: { objectTypeId: ctx.objectType.id, primaryId },\n }),\n ])\n}\n\n/**\n * Withdraw a previous delete.\n *\n * For an object written only from code this is a no-op — there is nothing left to reveal, so write it\n * again instead. For an object a projection also writes, it makes the projected state visible again.\n */\nexport async function restoreObject(ctx: ResolvedObjectContext, primaryId: string): Promise<void> {\n assertCanEdit(ctx, ctx.objectType.id)\n await commitRuntimeOperations(ctx, [\n objectRestoreOperation({\n id: runtimeOperationId(0),\n ref: { objectTypeId: ctx.objectType.id, primaryId },\n }),\n ])\n}\n",
|
|
15
|
+
"/**\n * Leaf operation: upsert a single object through the ontology Materializer.\n */\n\nimport { assertCanEdit } from \"../../authorization\"\nimport type { ObjectRow } from \"../../storage\"\nimport type { ResolvedObjectContext } from \"../context\"\nimport {\n commitRuntimeOperations,\n normalizeRuntimeObject,\n objectUpsertOperation,\n requireEffectiveObject,\n runtimeOperationId,\n toObjectRow,\n} from \"../materializer-adapter\"\n\nexport async function upsertObject(\n ctx: ResolvedObjectContext,\n properties: Record<string, unknown>\n): Promise<ObjectRow> {\n assertCanEdit(ctx, ctx.objectType.id)\n const { objectType, primaryPropertyId, ontology } = ctx\n\n const normalized = normalizeRuntimeObject({\n objectType,\n primaryPropertyId,\n properties,\n valueTypesById: ontology.getValueTypesById(),\n })\n const ref = { objectTypeId: objectType.id, primaryId: normalized.primaryId }\n\n // The Materializer classifies this as an independent create, a patch over source authority, or a\n // restore plus patch inside its own transaction.\n const commit = await commitRuntimeOperations(ctx, [\n objectUpsertOperation({ id: runtimeOperationId(0), ref, properties: normalized.properties }),\n ])\n return toObjectRow(ctx.projectId, requireEffectiveObject(commit.outcomes[0]))\n}\n",
|
|
16
|
+
"/**\n * Leaf operation: batch upsert objects of a single type through the ontology Materializer.\n *\n * Everything that survives local normalization is submitted as one ordered continue-mode commit, so\n * later items observe earlier ones and a provider failure rolls the whole batch back.\n */\nimport { assertCanEdit } from \"../../authorization\"\nimport { stableJsonStringify } from \"../../json\"\nimport type { BatchItemResult } from \"../../runtime/types\"\nimport type { ObjectRow } from \"../../storage\"\nimport type { ResolvedObjectContext } from \"../context\"\nimport {\n normalizeRuntimeObject,\n objectUpsertOperation,\n requireEffectiveObject,\n runtimeOperationId,\n toObjectRow,\n} from \"../materializer-adapter\"\nimport { runRuntimeItemBatch } from \"../runtime-batch\"\n\nexport async function upsertObjectBatch(\n ctx: ResolvedObjectContext,\n items: readonly { properties: Record<string, unknown> }[]\n): Promise<readonly BatchItemResult<ObjectRow>[]> {\n assertCanEdit(ctx, ctx.objectType.id)\n const { objectType, primaryPropertyId, ontology } = ctx\n const valueTypesById = ontology.getValueTypesById()\n\n return runRuntimeItemBatch({\n ctx,\n items,\n plan(item, index) {\n const normalized = normalizeRuntimeObject({\n objectType,\n primaryPropertyId,\n properties: item.properties,\n valueTypesById,\n })\n const ref = { objectTypeId: objectType.id, primaryId: normalized.primaryId }\n return {\n // One commit resolves one authority state per object, so two items for the same identity are\n // unambiguous only when they ask for the same thing.\n key: `${ref.objectTypeId}:${ref.primaryId}`,\n label: `object '${ref.objectTypeId}:${ref.primaryId}'`,\n fingerprint: stableJsonStringify(normalized.properties),\n operations: [\n objectUpsertOperation({\n id: runtimeOperationId(index),\n ref,\n properties: normalized.properties,\n }),\n ],\n }\n },\n value: ([outcome]) => toObjectRow(ctx.projectId, requireEffectiveObject(outcome)),\n })\n}\n",
|
|
17
|
+
"/**\n * Low-level write: append normalized telemetry points through the ontology Materializer.\n *\n * Shared by the batch operation and the per-property appenders in ObjectByIdHandle. The Materializer\n * persists immutable point history, derives latest telemetry state, and writes the commit's outbox\n * facts in one transaction, so this leaf never appends events or writes providers itself.\n */\nimport { randomUUID } from \"node:crypto\"\nimport type { AuthorizationContext } from \"../../authorization\"\nimport { assertCanAppendTelemetry } from \"../../authorization\"\nimport { MaterializationObjectNotFoundError } from \"../../materialization/errors\"\nimport type { TelemetryCommitResult, TelemetryPointWrite } from \"../../materialization/model\"\nimport { getOntologyMutationRuntime } from \"../../runtime/ontology-mutations\"\nimport { ObjectNotFoundError } from \"../../storage/errors\"\nimport type { RuntimeMaterializerContext } from \"../materializer-adapter\"\n\nexport type TelemetryWriteContext = RuntimeMaterializerContext & {\n readonly authorization?: AuthorizationContext\n}\n\nexport async function writeTelemetryBatch(\n ctx: TelemetryWriteContext,\n points: readonly TelemetryPointWrite[]\n): Promise<TelemetryCommitResult | null> {\n // Asserted from the points rather than a resolved context: this leaf is the low-level choke point\n // for both `appendTelemetryBatch` and the per-property `TelemetryChannel`, and only the points know\n // which object types the call actually touches.\n for (const objectTypeId of new Set(points.map((point) => point.series.object.objectTypeId))) {\n assertCanAppendTelemetry(ctx, objectTypeId)\n }\n if (points.length === 0) return null\n\n let commit: TelemetryCommitResult\n try {\n commit = await getOntologyMutationRuntime(ctx).appendTelemetry({\n source: { kind: \"runtime\", requestId: randomUUID() },\n points,\n })\n } catch (error) {\n if (error instanceof MaterializationObjectNotFoundError) {\n throw new ObjectNotFoundError(\n error.objectTypeId,\n error.primaryId,\n \"Object not found for telemetry append\"\n )\n }\n throw error\n }\n return commit\n}\n",
|
|
18
|
+
"/**\n * Leaf operation: batch telemetry append for multiple objects of a single type.\n */\nimport { assertCanAppendTelemetry } from \"../../authorization\"\nimport type { TelemetryPointWrite } from \"../../materialization/model\"\nimport { telemetryPointKey } from \"../../materialization/refs\"\nimport { OntologyValidationError } from \"../../ontology/errors\"\nimport { assertTelemetryProperty } from \"../../ontology/validation\"\nimport type { ResolvedObjectContext } from \"../context\"\nimport { writeTelemetryBatch } from \"./write-batch\"\n\n/**\n * Type guard for telemetry values that carry an explicit unit.\n *\n * Matches only the exact `{ value, unit }` wrapper (a string `unit` and no other\n * keys) so a legitimate JSON/object telemetry value is not silently\n * reinterpreted as value+unit. A fully explicit batch contract (passing units\n * out-of-band like the single-property appender) is tracked as a follow-up;\n * this narrows the heuristic without changing the public batch API.\n */\nfunction isUnitBearingValue(raw: unknown): raw is { value: unknown; unit: string } {\n if (raw === null || typeof raw !== \"object\") {\n return false\n }\n const record = raw as Record<string, unknown>\n return \"value\" in record && typeof record.unit === \"string\" && Object.keys(record).length === 2\n}\n\nexport async function appendTelemetryBatch(\n ctx: ResolvedObjectContext,\n items: readonly {\n id: string\n properties: Record<string, unknown | { value: unknown; unit: string }>\n at?: Date\n }[]\n): Promise<void> {\n // `writeTelemetryBatch` asserts again from the points it receives. Asserting here as well is not\n // redundant: it reports the type by name before any property is resolved, and it still refuses an\n // empty batch, which produces no points to assert over.\n assertCanAppendTelemetry(ctx, ctx.objectType.id)\n const { objectType } = ctx\n // Telemetry identity is `(series, at)`, so a repeated instant inside one call is an upsert: the\n // last value wins rather than failing the whole batch.\n const points = new Map<string, TelemetryPointWrite>()\n\n for (const item of items) {\n const at = (item.at ?? new Date()).toISOString()\n\n for (const [propertyId, rawValue] of Object.entries(item.properties)) {\n const propertyToken = objectType.p[propertyId]\n if (!propertyToken) {\n throw new OntologyValidationError(`Unknown property '${objectType.id}.${propertyId}'`)\n }\n\n assertTelemetryProperty(propertyToken.property)\n\n // Value and unit validation, plus schema normalization, happen inside the Materializer.\n const series = {\n object: { objectTypeId: objectType.id, primaryId: item.id },\n propertyId: propertyToken.id,\n }\n points.set(telemetryPointKey(series, at), {\n series,\n value: isUnitBearingValue(rawValue)\n ? (rawValue.value as TelemetryPointWrite[\"value\"])\n : (rawValue as TelemetryPointWrite[\"value\"]),\n ...(isUnitBearingValue(rawValue) ? { unit: rawValue.unit } : {}),\n at,\n })\n }\n }\n\n await writeTelemetryBatch(ctx, [...points.values()])\n}\n",
|
|
19
|
+
"import { createSixbError } from \"../../errors/internal\"\nimport type { AuthorizedObjectReader } from \"../../execution/authorized-object-reader\"\nimport type {\n TimeseriesHistoryBatchInput,\n TimeseriesHistoryBatchResult,\n TimeseriesHistorySeriesInput,\n TimeseriesPoint,\n TimeseriesStorage,\n} from \"../../storage\"\n\nexport interface TelemetryHistoryOptions {\n readonly storage: TimeseriesStorage\n readonly objectReader: AuthorizedObjectReader\n}\n\nexport type TelemetryHistoryBatchInput = Omit<TimeseriesHistoryBatchInput, \"projectId\">\n\ninterface SnapshotTelemetryHistoryRequest extends TelemetryHistoryBatchInput {\n readonly maxPointOccurrences?: number\n}\n\n/** Read only series selected for the exact object occurrence carried by the nominal reader. */\nexport async function getTelemetryHistoryBatch(\n input: TelemetryHistoryBatchInput,\n options: TelemetryHistoryOptions\n): Promise<readonly TimeseriesHistoryBatchResult[]> {\n // Capture both provider capabilities before reading caller-owned request fields.\n const objectReader = options.objectReader\n const storage = options.storage\n const projectId = objectReader.projectId\n const request = snapshotTelemetryHistoryInput(input, objectReader)\n\n const uniqueSeries = deduplicateSeries(request.series)\n const readableSeries = await selectReadableSeries(uniqueSeries, objectReader)\n const resultsBySeries = await readAndValidateHistory({\n storage,\n projectId,\n request,\n series: readableSeries,\n })\n\n // Objects and telemetry do not share a portable read snapshot. Recheck live selection after\n // all provider-owned values have been detached, before deciding which points to return.\n const releasableSeries =\n readableSeries.length === 0 ? [] : await selectReadableSeries(readableSeries, objectReader)\n const result = assembleHistoryResults({ request, resultsBySeries, releasableSeries })\n objectReader.assertVisibleOutputWithinLimit(result)\n return result\n}\n\n/** Read the latest point only while its exact object property remains selected. */\nexport async function getLatestTelemetryPoint(\n input: TimeseriesHistorySeriesInput,\n options: TelemetryHistoryOptions\n): Promise<TimeseriesPoint | null> {\n const objectReader = options.objectReader\n const storage = options.storage\n const projectId = objectReader.projectId\n const series = snapshotTelemetrySeries(input)\n const readable = await objectReader.canReadObjectProperty(objectPropertySelection(series))\n if (!readable) return visibleLatestResult(null, objectReader)\n\n const rawResult = await storage.getLatest({ projectId, ...series })\n const result = rawResult === null ? null : snapshotProviderPoint(rawResult)\n if (result) assertTimeseriesPointMatchesSeries(projectId, series, result)\n\n // See the batch release check above. Revocation during the timeseries read hides the result.\n const releaseReadable = await objectReader.canReadObjectProperty(objectPropertySelection(series))\n if (!releaseReadable) return visibleLatestResult(null, objectReader)\n\n return visibleLatestResult(result, objectReader)\n}\n\nfunction deduplicateSeries(\n series: readonly TimeseriesHistorySeriesInput[]\n): TimeseriesHistorySeriesInput[] {\n const uniqueSeries = new Map<string, TimeseriesHistorySeriesInput>()\n for (const item of series) {\n const key = seriesKey(item)\n if (!uniqueSeries.has(key)) uniqueSeries.set(key, item)\n }\n return [...uniqueSeries.values()]\n}\n\nasync function selectReadableSeries(\n series: readonly TimeseriesHistorySeriesInput[],\n objectReader: AuthorizedObjectReader\n): Promise<readonly TimeseriesHistorySeriesInput[]> {\n const readable = await objectReader.canReadObjectPropertiesBatch({\n items: series.map(objectPropertySelection),\n })\n return series.filter((_, index) => readable[index] === true)\n}\n\nasync function readAndValidateHistory(input: {\n readonly storage: TimeseriesStorage\n readonly projectId: string\n readonly request: SnapshotTelemetryHistoryRequest\n readonly series: readonly TimeseriesHistorySeriesInput[]\n}): Promise<ReadonlyMap<string, TimeseriesHistoryBatchResult>> {\n const { storage, projectId, request, series } = input\n\n // The provider receives its own detached request. It must never retain or mutate the canonical\n // series snapshot that admission and the final release check rely on.\n const providerRequest = structuredClone({\n projectId,\n series,\n ...(request.from === undefined ? {} : { from: request.from }),\n ...(request.to === undefined ? {} : { to: request.to }),\n ...(request.limitPerSeries === undefined ? {} : { limitPerSeries: request.limitPerSeries }),\n ...(request.order === undefined ? {} : { order: request.order }),\n })\n const stored = series.length === 0 ? [] : await storage.getHistoryBatch(providerRequest)\n\n // Fully detach and validate provider-owned data before the final live check. A provider result\n // may contain accessors or a custom iterator; none of that code may run after release admission.\n if (!Array.isArray(stored)) throw invalidTimeseriesProviderResult()\n const storedCount = stored.length\n if (!Number.isSafeInteger(storedCount) || storedCount > series.length) {\n throw invalidTimeseriesProviderResult()\n }\n const seriesKeys = new Set(series.map(seriesKey))\n const providerResultBySeries = new Map<string, TimeseriesHistoryBatchResult>()\n for (let index = 0; index < storedCount; index += 1) {\n const providerResult = snapshotProviderResult(stored[index]!, request.limitPerSeries)\n const key = seriesKey(providerResult)\n if (providerResultBySeries.has(key) || !seriesKeys.has(key)) {\n throw invalidTimeseriesProviderResult()\n }\n for (const point of providerResult.points) {\n assertTimeseriesPointMatchesSeries(projectId, providerResult, point)\n }\n providerResultBySeries.set(key, providerResult)\n }\n\n return providerResultBySeries\n}\n\n/** Restore request order and duplicates, with independent point copies for every occurrence. */\nfunction assembleHistoryResults(input: {\n readonly request: SnapshotTelemetryHistoryRequest\n readonly resultsBySeries: ReadonlyMap<string, TimeseriesHistoryBatchResult>\n readonly releasableSeries: readonly TimeseriesHistorySeriesInput[]\n}): readonly TimeseriesHistoryBatchResult[] {\n const { request, resultsBySeries, releasableSeries } = input\n const releasableSeriesKeys = new Set(releasableSeries.map(seriesKey))\n const releasedPoints = request.series.map((series) =>\n releasableSeriesKeys.has(seriesKey(series))\n ? (resultsBySeries.get(seriesKey(series))?.points ?? [])\n : []\n )\n const pointOccurrences = releasedPoints.reduce((total, points) => total + points.length, 0)\n if (request.maxPointOccurrences !== undefined && pointOccurrences > request.maxPointOccurrences) {\n throw invalidTimeseriesProviderResult()\n }\n return request.series.map((series, index) => ({\n ...series,\n points: releasedPoints[index]!.map((point) => structuredClone(point)),\n }))\n}\n\nfunction snapshotTelemetrySeries(\n series: TimeseriesHistorySeriesInput\n): TimeseriesHistorySeriesInput {\n if (typeof series !== \"object\" || series === null || Array.isArray(series)) {\n throw new Error(\"[Sixb] Telemetry history series must be an object.\")\n }\n const objectTypeId = telemetryIdentifier(series.objectTypeId, \"objectTypeId\")\n const objectId = telemetryIdentifier(series.objectId, \"objectId\")\n const propertyId = telemetryIdentifier(series.propertyId, \"propertyId\")\n return structuredClone({ objectTypeId, objectId, propertyId })\n}\n\nfunction assertTimeseriesPointMatchesSeries(\n projectId: string,\n series: TimeseriesHistorySeriesInput,\n point: TimeseriesPoint\n): void {\n if (\n typeof point !== \"object\" ||\n point === null ||\n point.projectId !== projectId ||\n point.objectTypeId !== series.objectTypeId ||\n point.objectId !== series.objectId ||\n point.propertyId !== series.propertyId\n ) {\n throw invalidTimeseriesProviderResult()\n }\n}\n\nfunction snapshotTelemetryHistoryInput(\n input: TelemetryHistoryBatchInput,\n objectReader: AuthorizedObjectReader\n): SnapshotTelemetryHistoryRequest {\n const authoredSeries = input.series\n const from = input.from\n const to = input.to\n const limitPerSeries = input.limitPerSeries\n const order = input.order\n if (!Array.isArray(authoredSeries)) {\n throw new Error(\"[Sixb] Telemetry history series must be an array.\")\n }\n if (order !== undefined && order !== \"asc\" && order !== \"desc\") {\n throw new Error(\"[Sixb] Telemetry history order must be 'asc' or 'desc'.\")\n }\n\n // Capture length once and walk by index so proxies cannot change the iteration shape halfway.\n const seriesCount = authoredSeries.length\n const admission = objectReader.admitTelemetryHistoryRead({\n seriesCount,\n ...(limitPerSeries === undefined ? {} : { limitPerSeries }),\n })\n const series: TimeseriesHistorySeriesInput[] = []\n for (let index = 0; index < seriesCount; index += 1) {\n series.push(snapshotTelemetrySeries(authoredSeries[index]!))\n }\n return structuredClone({\n series,\n ...(from === undefined ? {} : { from }),\n ...(to === undefined ? {} : { to }),\n ...(admission.limitPerSeries === undefined ? {} : { limitPerSeries: admission.limitPerSeries }),\n ...(order === undefined ? {} : { order }),\n ...(admission.maxPointOccurrences === undefined\n ? {}\n : { maxPointOccurrences: admission.maxPointOccurrences }),\n })\n}\n\nfunction objectPropertySelection(series: TimeseriesHistorySeriesInput): {\n readonly objectTypeId: string\n readonly primaryId: string\n readonly propertyId: string\n} {\n return {\n objectTypeId: series.objectTypeId,\n primaryId: series.objectId,\n propertyId: series.propertyId,\n }\n}\n\nfunction visibleLatestResult<T extends TimeseriesPoint | null>(\n result: T,\n objectReader: AuthorizedObjectReader\n): T {\n objectReader.assertVisibleOutputWithinLimit(result)\n return result\n}\n\nfunction snapshotProviderResult(\n result: TimeseriesHistoryBatchResult,\n maxPointsPerSeries: number | undefined\n): TimeseriesHistoryBatchResult {\n try {\n if (typeof result !== \"object\" || result === null || Array.isArray(result)) {\n throw invalidTimeseriesProviderResult()\n }\n const series = snapshotTelemetrySeries(result)\n const authoredPoints = result.points\n if (!Array.isArray(authoredPoints)) throw invalidTimeseriesProviderResult()\n const pointCount = authoredPoints.length\n if (\n !Number.isSafeInteger(pointCount) ||\n (maxPointsPerSeries !== undefined && pointCount > maxPointsPerSeries)\n ) {\n throw invalidTimeseriesProviderResult()\n }\n const points: TimeseriesPoint[] = []\n for (let index = 0; index < pointCount; index += 1) {\n points.push(snapshotProviderPoint(authoredPoints[index]!))\n }\n return { ...series, points }\n } catch (error) {\n if (isInvalidTimeseriesProviderResult(error)) throw error\n throw invalidTimeseriesProviderResult(error)\n }\n}\n\nfunction snapshotProviderPoint(point: TimeseriesPoint): TimeseriesPoint {\n try {\n const snapshot = structuredClone(point)\n if (!snapshot || typeof snapshot !== \"object\") throw invalidTimeseriesProviderResult()\n return snapshot\n } catch (error) {\n if (isInvalidTimeseriesProviderResult(error)) throw error\n throw invalidTimeseriesProviderResult(error)\n }\n}\n\nfunction invalidTimeseriesProviderResult(cause?: unknown): Error {\n return createSixbError(\n \"internal.unexpected\",\n \"[Sixb] Timeseries storage returned data outside the requested series.\",\n cause === undefined ? {} : { cause }\n )\n}\n\nfunction isInvalidTimeseriesProviderResult(\n error: unknown\n): error is Error & { readonly code: \"internal.unexpected\" } {\n return (\n error instanceof Error &&\n \"code\" in error &&\n error.code === \"internal.unexpected\" &&\n error.message === \"[Sixb] Timeseries storage returned data outside the requested series.\"\n )\n}\n\nfunction telemetryIdentifier(value: unknown, field: string): string {\n if (typeof value !== \"string\" || !value.trim()) {\n throw new Error(`[Sixb] Telemetry history ${field} must be a non-empty string.`)\n }\n return value\n}\n\nfunction seriesKey(series: TimeseriesHistorySeriesInput): string {\n return JSON.stringify([series.objectTypeId, series.objectId, series.propertyId])\n}\n",
|
|
20
|
+
"/**\n * Context resolution factories.\n *\n * Resolve ontology identifiers into concrete type data so leaf functions\n * receive all structural information pre-resolved.\n */\n\nimport type { ObjectLink } from \"../../ontology\"\nimport { OntologyNotFoundError } from \"../../ontology/errors\"\nimport type { ObjectTypeWithPropertyTokens } from \"../../ontology/tokens\"\nimport type { SixbRuntimeContext } from \"../../runtime/types\"\nimport type { ResolvedLinkContext, ResolvedObjectContext } from \"./types\"\n\n/** Look up a link definition on an object type, throwing if not found. */\nexport function requireLinkDefinition(\n objectType: ObjectTypeWithPropertyTokens,\n linkId: string\n): ObjectLink {\n const def = objectType.links.find((l) => l.id === linkId)\n if (!def) throw new OntologyNotFoundError(`Unknown link '${objectType.id}.${linkId}'`)\n return def\n}\n\n/**\n * Resolve an object type id to a full ResolvedObjectContext.\n *\n * Uses ontology.resolveObjectType() and getPrimaryPropertyId() — these\n * are structural resolution calls that belong in factories, not leaf functions.\n */\nexport function resolveObjectContext(\n runtime: SixbRuntimeContext,\n objectTypeId: string\n): ResolvedObjectContext {\n const objectType = runtime.ontology.resolveObjectType(objectTypeId)\n const primaryPropertyId = runtime.ontology.getPrimaryPropertyId(objectTypeId)\n return { ...runtime, objectType, primaryPropertyId }\n}\n\n/**\n * Resolve a link id to a full ResolvedLinkContext.\n *\n * Uses requireLinkDefinition to look up the link definition on the\n * already-resolved object type.\n */\nexport function resolveLinkContext(\n objCtx: ResolvedObjectContext,\n linkId: string\n): ResolvedLinkContext {\n const linkDefinition = requireLinkDefinition(objCtx.objectType, linkId)\n return { ...objCtx, linkDefinition }\n}\n",
|
|
21
|
+
"/**\n * Telemetry channel factory for ObjectByIdHandle.\n *\n * Creates a per-property channel that writes through the low-level `writeTelemetryBatch` leaf and\n * reads the same series back through `getTelemetryHistoryBatch`, both keyed by the property token.\n */\nimport type { TelemetryPointWrite } from \"../../materialization/model\"\nimport type { ValueType } from \"../../ontology\"\nimport type { ObjectTypeWithPropertyTokens } from \"../../ontology/tokens\"\nimport {\n assertPropertyTokenBelongsToObjectType,\n assertTelemetryProperty,\n} from \"../../ontology/validation\"\nimport { RuntimeError } from \"../../runtime/errors\"\nimport type {\n TelemetryChannel,\n TelemetryHistoryInput,\n TelemetryPropertyToken,\n} from \"../../runtime/types\"\nimport type { ResolvedObjectContext } from \"../context\"\nimport { getTelemetryHistoryBatch, writeTelemetryBatch } from \"../telemetry\"\n\nexport function createTelemetryChannel<\n TObjectType extends ObjectTypeWithPropertyTokens,\n TValueTypes extends readonly ValueType[],\n>(ctx: ResolvedObjectContext, primaryId: string) {\n return <TToken extends TelemetryPropertyToken<TObjectType>>(\n property: TToken\n ): TelemetryChannel<TToken, TValueTypes> => {\n const { objectType } = ctx\n assertPropertyTokenBelongsToObjectType(objectType, property)\n assertTelemetryProperty(property.property)\n\n const series = { objectTypeId: objectType.id, objectId: primaryId, propertyId: property.id }\n\n const channel = {\n append: async (input: { value: unknown; unit?: string; at: Date }) => {\n // Value and unit validation, plus schema normalization, happen inside the Materializer.\n await writeTelemetryBatch(ctx, [\n {\n series: {\n object: { objectTypeId: objectType.id, primaryId },\n propertyId: property.id,\n },\n value: input.value as TelemetryPointWrite[\"value\"],\n ...(input.unit !== undefined ? { unit: input.unit } : {}),\n at: input.at.toISOString(),\n },\n ])\n },\n\n history: async (input: TelemetryHistoryInput = {}) => {\n const timeseries = ctx.storage.timeseries\n const objectReader = ctx.objectReader\n if (!timeseries) {\n throw new RuntimeError(\"[Sixb] Reading telemetry requires storage.timeseries support.\")\n }\n\n const from = input.from\n const to = input.to\n const limit = input.limit\n const order = input.order\n\n const [result] = await getTelemetryHistoryBatch(\n {\n series: [series],\n ...(from !== undefined ? { from } : {}),\n ...(to !== undefined ? { to } : {}),\n ...(limit !== undefined ? { limitPerSeries: limit } : {}),\n ...(order !== undefined ? { order } : {}),\n },\n {\n storage: timeseries,\n objectReader,\n }\n )\n\n return (result?.points ?? []).map((point) => ({\n value: point.value,\n at: point.at,\n ...(point.unit !== undefined ? { unit: point.unit } : {}),\n }))\n },\n }\n\n // Cast needed: generic token inference boundary — TToken is narrower than what `channel` sees\n return channel as unknown as TelemetryChannel<TToken, TValueTypes>\n }\n}\n",
|
|
22
|
+
"/**\n * ObjectByIdHandle binds operations to a specific object id within an ObjectSet.\n * Created via `sixb.objects(MyType).byId(\"id-1\")`, it provides link/unlink and\n * per-property telemetry appenders with compile-time unit and value type safety.\n */\nimport type { ActionDefinition } from \"../../actions\"\nimport type { ObjectLink, ObjectRef, ValueType } from \"../../ontology\"\nimport { OntologyValidationError } from \"../../ontology/errors\"\nimport type { LinkToken, ObjectTypeWithPropertyTokens } from \"../../ontology/tokens\"\nimport { assertLinkTokenBelongsToObjectType } from \"../../ontology/validation\"\nimport type { ObjectByIdHandle, TwinObject } from \"../../runtime/types\"\nimport {\n requestActionAndWait as requestActionAndWaitLeaf,\n requestAction as requestActionLeaf,\n} from \"../action\"\nimport type { ExecutionObjectContext, ResolvedLinkContext } from \"../context\"\nimport { removeLink as removeLinkLeaf, upsertLink as upsertLinkLeaf } from \"../link\"\nimport { deleteObject, restoreObject } from \"../object\"\nimport { createTelemetryChannel } from \"./telemetry-channel\"\n\ntype ObjectRefInput = ObjectRef\ntype AnyLinkToken = LinkToken<string, string, string | readonly string[], ObjectLink>\n\nexport function createObjectByIdHandle<\n TObjectType extends ObjectTypeWithPropertyTokens,\n TValueTypes extends readonly ValueType[],\n>(ctx: ExecutionObjectContext, primaryId: string): ObjectByIdHandle<TObjectType, TValueTypes> {\n const objectHandle = {\n get: async () => {\n const row = await ctx.objectReader.getByPrimaryId({\n objectTypeId: ctx.objectType.id,\n primaryId,\n })\n return row ? (row as unknown as TwinObject<TObjectType, TValueTypes>) : null\n },\n\n listLinks: async (linkToken?: AnyLinkToken) => {\n if (linkToken) {\n assertLinkTokenBelongsToObjectType(ctx.objectType, linkToken)\n }\n return ctx.objectReader.listLinks({\n objectTypeId: ctx.objectType.id,\n objectId: primaryId,\n linkId: linkToken?.id,\n })\n },\n\n link: async (\n linkToken: AnyLinkToken,\n target: ObjectRefInput,\n options?: { properties?: Record<string, unknown> }\n ) => {\n assertLinkTokenBelongsToObjectType(ctx.objectType, linkToken)\n\n const linkCtx: ResolvedLinkContext = { ...ctx, linkDefinition: linkToken.link }\n await upsertLinkLeaf(linkCtx, {\n sourceId: primaryId,\n linkId: linkToken.id,\n targetTypeId: target.objectTypeId,\n targetId: target.primaryId,\n properties: options?.properties,\n })\n },\n\n unlink: async (linkToken: AnyLinkToken, target: ObjectRefInput) => {\n assertLinkTokenBelongsToObjectType(ctx.objectType, linkToken)\n\n const linkCtx: ResolvedLinkContext = { ...ctx, linkDefinition: linkToken.link }\n await removeLinkLeaf(linkCtx, {\n sourceId: primaryId,\n linkId: linkToken.id,\n targetTypeId: target.objectTypeId,\n targetId: target.primaryId,\n })\n },\n\n delete: async () => {\n await deleteObject(ctx, primaryId)\n },\n\n restore: async () => {\n await restoreObject(ctx, primaryId)\n },\n\n requestAction: async (input: {\n action?: ActionDefinition\n actionId?: string\n params?: Record<string, unknown>\n runId?: string\n }) => {\n const actionId = input.action?.id ?? input.actionId\n if (!actionId) {\n throw new OntologyValidationError(\n \"[Sixb] requestAction requires either 'action' or 'actionId'\"\n )\n }\n return requestActionLeaf(ctx, {\n primaryId,\n actionId,\n params: input.params,\n options: { runId: input.runId },\n })\n },\n\n requestActionAndWait: async (input: {\n action?: ActionDefinition\n actionId?: string\n params?: Record<string, unknown>\n timeoutMs?: number\n signal?: AbortSignal\n }) => {\n const actionId = input.action?.id ?? input.actionId\n if (!actionId) {\n throw new OntologyValidationError(\n \"[Sixb] requestActionAndWait requires either 'action' or 'actionId'\"\n )\n }\n return requestActionAndWaitLeaf(ctx, {\n primaryId,\n actionId,\n params: input.params,\n options: {\n timeoutMs: input.timeoutMs,\n signal: input.signal,\n },\n })\n },\n\n telemetry: createTelemetryChannel<TObjectType, TValueTypes>(ctx, primaryId),\n }\n\n return objectHandle as unknown as ObjectByIdHandle<TObjectType, TValueTypes>\n}\n",
|
|
23
|
+
"/**\n * Server-side ObjectQueryExecutor backed by the shared query executor and storage.\n * Validation, planning, fallback, and execution all run in-process here; the\n * HTTP executor in `@sixb/client` is the remote counterpart.\n */\n\nimport type { AuthorizedObjectReader } from \"../../execution/authorized-object-reader\"\nimport type { OntologyRegistry } from \"../../ontology\"\nimport { ObjectQueryPlanningError } from \"../query\"\nimport { explainObjectQuery } from \"../query/explain\"\nimport type { ObjectQuery } from \"../query/ir\"\nimport { validateObjectQuery } from \"../query/validate\"\nimport type { ObjectQueryExecutor, ObjectQueryExecutorFacetRequest } from \"./query-executor\"\n\nexport function createRuntimeQueryExecutor(params: {\n ontology: OntologyRegistry\n objectReader: AuthorizedObjectReader\n}): ObjectQueryExecutor {\n const { ontology, objectReader } = params\n\n return {\n async list(query: ObjectQuery, options?: { includeTotal?: boolean }) {\n try {\n return await objectReader.executeQuery({ query, includeTotal: options?.includeTotal })\n } catch (error) {\n if (error instanceof ObjectQueryPlanningError) {\n throw addSdkPlanningHints(error)\n }\n throw error\n }\n },\n\n async count(query: ObjectQuery) {\n const result = await objectReader.count({ query })\n return result.count\n },\n\n async exists(query: ObjectQuery) {\n const result = await objectReader.exists({ query })\n return result.exists\n },\n\n async facets(query: ObjectQuery, facets: readonly ObjectQueryExecutorFacetRequest[]) {\n const result = await objectReader.facet({ query, facets })\n return result.facets.map((facet) => ({\n propertyId: facet.propertyId,\n buckets: [...facet.buckets],\n }))\n },\n\n validate(query: ObjectQuery) {\n return validateObjectQuery(query, { ontology, normalize: false })\n },\n\n explain(query: ObjectQuery) {\n return explainObjectQuery(query, { ontology, normalize: false })\n },\n }\n}\n\nfunction addSdkPlanningHints(error: ObjectQueryPlanningError): ObjectQueryPlanningError {\n if (!error.issues.some((issue) => issue.code === \"fallback_requires_bound\")) return error\n\n return new ObjectQueryPlanningError(\n error.issues.map((issue) =>\n issue.code === \"fallback_requires_bound\"\n ? {\n ...issue,\n message:\n \"Object query fallback requires an explicit result bound. Add .limit(n) or .page({ pageSize: n }) before .list().\",\n }\n : issue\n )\n )\n}\n",
|
|
24
|
+
"/**\n * ObjectSet provides a type-safe collection API for objects of a given type.\n * Created via `sixb.objects(MyType)`, it exposes upsert, query, and telemetry batch operations\n * while preserving compile-time property types inferred from the ontology definition.\n */\n\nimport type { ActionDefinition } from \"../../actions\"\nimport type { AuthorizationContext } from \"../../authorization\"\nimport { shareSixbErrorReporter } from \"../../error-reporting/capability\"\nimport type { ExecutionContext } from \"../../execution\"\nimport { assertAuthorizedObjectReaderBinding } from \"../../execution/authorized-object-reader\"\nimport type { ValueType } from \"../../ontology\"\nimport { OntologyValidationError } from \"../../ontology/errors\"\nimport type { ObjectTypeWithPropertyTokens } from \"../../ontology/tokens\"\nimport { shareOntologyMutationRuntime } from \"../../runtime/ontology-mutations\"\nimport type {\n ObjectSet,\n ObjectSetListInput,\n SixbRuntimeContext,\n TwinObject,\n} from \"../../runtime/types\"\nimport {\n requestActionAndWait as requestActionAndWaitLeaf,\n requestAction as requestActionLeaf,\n} from \"../action\"\nimport type { ExecutionObjectContext, ResolvedLinkContext } from \"../context\"\nimport { requireLinkDefinition } from \"../context\"\nimport { removeLink as removeLinkLeaf, upsertLink as upsertLinkLeaf } from \"../link\"\nimport { upsertObject as upsertObjectLeaf } from \"../object\"\nimport { appendTelemetryBatch as appendTelemetryBatchLeaf } from \"../telemetry\"\nimport { createObjectByIdHandle } from \"./object-handle\"\nimport { createObjectQueryBuilder } from \"./query-builder\"\nimport { createRuntimeQueryExecutor } from \"./runtime-query-executor\"\n\nexport function createObjectSet<\n TObjectType extends ObjectTypeWithPropertyTokens,\n TRegisteredObjectTypes extends ObjectTypeWithPropertyTokens,\n TValueTypes extends readonly ValueType[],\n>(\n params: SixbRuntimeContext & {\n readonly execution: ExecutionContext\n readonly objectType: TObjectType\n readonly authorization?: AuthorizationContext\n }\n): ObjectSet<TObjectType, TValueTypes, TRegisteredObjectTypes> {\n assertAuthorizedObjectReaderBinding({\n reader: params.objectReader,\n scope: { execution: params.execution, authorization: params.runtimeAuthorization },\n })\n const { objectType } = params\n const primaryProp = objectType.properties.find((p) => p.primary)\n if (!primaryProp) {\n throw new OntologyValidationError(`Object type '${objectType.id}' has no primary property`)\n }\n const primaryPropertyId = primaryProp.id\n\n const {\n projectId,\n broker,\n ontology,\n actionRegistry,\n events,\n storage,\n queues,\n objectReader,\n runtimeAuthorization,\n authorization,\n execution,\n } = params\n const queryExecutor = createRuntimeQueryExecutor({\n ontology,\n objectReader,\n })\n\n const resolvedCtx: ExecutionObjectContext = {\n projectId,\n broker,\n ontology,\n actionRegistry,\n events,\n storage,\n queues,\n objectReader,\n runtimeAuthorization,\n authorization,\n execution,\n objectType,\n primaryPropertyId,\n }\n shareOntologyMutationRuntime(params, resolvedCtx)\n shareSixbErrorReporter(params, resolvedCtx)\n\n const objectSet = {\n get: async (id: string) => {\n const row = await objectReader.getByPrimaryId({\n objectTypeId: objectType.id,\n primaryId: id,\n })\n return row ? (row as unknown as TwinObject<TObjectType, TValueTypes>) : null\n },\n\n upsert: async (input: { properties: Record<string, unknown> }) => {\n const row = await upsertObjectLeaf(resolvedCtx, input.properties)\n return row as unknown as TwinObject<TObjectType, TValueTypes>\n },\n\n query: () =>\n createObjectQueryBuilder<TObjectType, TRegisteredObjectTypes, TValueTypes>({\n query: { kind: \"start\", objectTypeId: objectType.id },\n executor: queryExecutor,\n }),\n\n byId: (id: string) => createObjectByIdHandle<TObjectType, TValueTypes>(resolvedCtx, id),\n\n list: async (input?: ObjectSetListInput) => {\n const result = await objectReader.list({\n objectTypeId: objectType.id,\n primaryIdPrefix: input?.idPrefix,\n primaryIdSuffix: input?.idSuffix,\n updatedAfter: input?.updatedAfter,\n updatedBefore: input?.updatedBefore,\n createdAfter: input?.createdAfter,\n createdBefore: input?.createdBefore,\n limit: input?.limit,\n offset: input?.offset,\n orderBy: input?.orderBy,\n order: input?.order,\n })\n\n return {\n objects: result.objects.map(\n (row) => row as unknown as TwinObject<TObjectType, TValueTypes>\n ),\n hasMore: result.hasMore,\n total: result.total ?? result.objects.length,\n }\n },\n\n appendTelemetryBatch: async (\n items: readonly {\n id: string\n properties: Record<string, unknown | { value: unknown; unit: string }>\n at?: Date\n }[]\n ) => {\n await appendTelemetryBatchLeaf(resolvedCtx, items)\n },\n\n requestAction: async (input: {\n id: string\n action?: ActionDefinition\n actionId?: string\n params?: Record<string, unknown>\n runId?: string\n }) => {\n const actionId = input.action?.id ?? input.actionId\n if (!actionId) {\n throw new OntologyValidationError(\n \"[Sixb] requestAction requires either 'action' or 'actionId'\"\n )\n }\n return requestActionLeaf(resolvedCtx, {\n primaryId: input.id,\n actionId,\n params: input.params,\n options: { runId: input.runId },\n })\n },\n\n requestActionAndWait: async (input: {\n id: string\n action?: ActionDefinition\n actionId?: string\n params?: Record<string, unknown>\n timeoutMs?: number\n signal?: AbortSignal\n }) => {\n const actionId = input.action?.id ?? input.actionId\n if (!actionId) {\n throw new OntologyValidationError(\n \"[Sixb] requestActionAndWait requires either 'action' or 'actionId'\"\n )\n }\n return requestActionAndWaitLeaf(resolvedCtx, {\n primaryId: input.id,\n actionId,\n params: input.params,\n options: {\n timeoutMs: input.timeoutMs,\n signal: input.signal,\n },\n })\n },\n\n upsertLink: async (input: {\n sourceId: string\n linkId: string\n targetTypeId: string\n targetId: string\n properties?: Record<string, unknown>\n }) => {\n const linkDefinition = requireLinkDefinition(objectType, input.linkId)\n const linkCtx: ResolvedLinkContext = { ...resolvedCtx, linkDefinition }\n\n await upsertLinkLeaf(linkCtx, {\n sourceId: input.sourceId,\n linkId: input.linkId,\n targetTypeId: input.targetTypeId,\n targetId: input.targetId,\n properties: input.properties,\n })\n },\n\n removeLink: async (input: {\n sourceId: string\n linkId: string\n targetTypeId: string\n targetId: string\n }) => {\n const linkDefinition = requireLinkDefinition(objectType, input.linkId)\n const linkCtx: ResolvedLinkContext = { ...resolvedCtx, linkDefinition }\n\n await removeLinkLeaf(linkCtx, {\n sourceId: input.sourceId,\n linkId: input.linkId,\n targetTypeId: input.targetTypeId,\n targetId: input.targetId,\n })\n },\n }\n\n return objectSet as unknown as ObjectSet<TObjectType, TValueTypes, TRegisteredObjectTypes>\n}\n",
|
|
25
|
+
"/**\n * Service layer for action operations.\n *\n * Resolves objectTypeId to a typed context and delegates to the leaf function.\n */\n\nimport type { RequestActionResult } from \"../../actions/request\"\nimport type { ExecutionContext } from \"../../execution\"\nimport type { SixbRuntimeContext } from \"../../runtime/types\"\nimport type { ActionRunRecord } from \"../../storage\"\nimport {\n type RequestActionAndWaitOptions,\n type RequestActionOptions,\n requestActionAndWait as requestActionAndWaitLeaf,\n requestAction as requestActionLeaf,\n} from \"../action\"\nimport { resolveObjectContext } from \"../context\"\n\nexport async function requestAction(\n runtime: SixbRuntimeContext,\n execution: ExecutionContext,\n objectTypeId: string,\n primaryId: string,\n actionId: string,\n params?: Record<string, unknown>,\n options?: RequestActionOptions\n): Promise<RequestActionResult> {\n const ctx = { ...resolveObjectContext(runtime, objectTypeId), execution }\n return requestActionLeaf(ctx, { primaryId, actionId, params, options })\n}\n\nexport async function requestActionAndWait(\n runtime: SixbRuntimeContext,\n execution: ExecutionContext,\n objectTypeId: string,\n primaryId: string,\n actionId: string,\n params?: Record<string, unknown>,\n options?: RequestActionAndWaitOptions\n): Promise<ActionRunRecord> {\n const ctx = { ...resolveObjectContext(runtime, objectTypeId), execution }\n return requestActionAndWaitLeaf(ctx, { primaryId, actionId, params, options })\n}\n",
|
|
26
|
+
"/**\n * Service layer for link operations.\n *\n * Resolves objectTypeId to a typed context and delegates to leaf functions.\n */\nimport type { BatchItemResult, SixbRuntimeContext } from \"../../runtime/types\"\nimport type { ResolvedLinkBatchItem } from \"../context\"\nimport { requireLinkDefinition, resolveLinkContext, resolveObjectContext } from \"../context\"\nimport {\n removeLink as removeLinkLeaf,\n upsertLinkBatch as upsertLinkBatchLeaf,\n upsertLink as upsertLinkLeaf,\n} from \"../link\"\n\nexport async function upsertLink(\n runtime: SixbRuntimeContext,\n objectTypeId: string,\n sourceId: string,\n linkId: string,\n target: { targetTypeId: string; targetId: string; properties?: Record<string, unknown> }\n): Promise<void> {\n const ctx = resolveObjectContext(runtime, objectTypeId)\n const linkCtx = resolveLinkContext(ctx, linkId)\n await upsertLinkLeaf(linkCtx, {\n sourceId,\n linkId,\n targetTypeId: target.targetTypeId,\n targetId: target.targetId,\n properties: target.properties,\n })\n}\n\nexport async function upsertLinkBatch(\n runtime: SixbRuntimeContext,\n items: readonly {\n objectTypeId: string\n sourceId: string\n linkId: string\n target: { targetTypeId: string; targetId: string; properties?: Record<string, unknown> }\n }[]\n): Promise<readonly BatchItemResult<void>[]> {\n const resolvedItems: ResolvedLinkBatchItem[] = items.map((item) => {\n const objectType = runtime.ontology.resolveObjectType(item.objectTypeId)\n const linkDefinition = requireLinkDefinition(objectType, item.linkId)\n return {\n objectType,\n linkDefinition,\n sourceId: item.sourceId,\n linkId: item.linkId,\n targetTypeId: item.target.targetTypeId,\n targetId: item.target.targetId,\n properties: item.target.properties,\n }\n })\n\n return upsertLinkBatchLeaf(runtime, resolvedItems)\n}\n\nexport async function removeLink(\n runtime: SixbRuntimeContext,\n objectTypeId: string,\n sourceId: string,\n linkId: string,\n target: { targetTypeId: string; targetId: string }\n): Promise<void> {\n const ctx = resolveObjectContext(runtime, objectTypeId)\n const linkCtx = resolveLinkContext(ctx, linkId)\n await removeLinkLeaf(linkCtx, {\n sourceId,\n linkId,\n targetTypeId: target.targetTypeId,\n targetId: target.targetId,\n })\n}\n",
|
|
27
|
+
"/**\n * Cross-type object listing for dashboards and search.\n *\n * Type hierarchies are expanded before the request reaches the canonical object\n * reader, which owns authorization and provider-scope enforcement.\n */\n\nimport { resolveRuntimeAuthorizationForProject } from \"../../execution/authorization\"\nimport { getAuthorizedOntologyView } from \"../../execution/authorized-object-reader\"\nimport type { ListResult, SixbRuntimeContext } from \"../../runtime/types\"\nimport type { ObjectRow } from \"../../storage\"\n\nexport interface ListObjectsParams {\n objectTypeIds?: readonly string[]\n idPrefix?: string\n idSuffix?: string\n updatedAfter?: Date\n updatedBefore?: Date\n createdAfter?: Date\n createdBefore?: Date\n limit?: number\n offset?: number\n orderBy?: \"createdAt\" | \"updatedAt\" | \"primaryId\"\n order?: \"asc\" | \"desc\"\n}\n\nexport async function listObjects(\n runtime: SixbRuntimeContext,\n params: ListObjectsParams\n): Promise<ListResult<ObjectRow>> {\n const objectTypeIds = resolveTypeFilter(runtime, params.objectTypeIds)\n\n if (objectTypeIds !== undefined && objectTypeIds.length === 0) {\n return { objects: [], hasMore: false, total: 0 }\n }\n\n const result = await runtime.objectReader.list({\n objectTypeId: objectTypeIds?.length === 1 ? objectTypeIds[0] : objectTypeIds,\n primaryIdPrefix: params.idPrefix,\n primaryIdSuffix: params.idSuffix,\n updatedAfter: params.updatedAfter,\n updatedBefore: params.updatedBefore,\n createdAfter: params.createdAfter,\n createdBefore: params.createdBefore,\n limit: params.limit,\n offset: params.offset,\n orderBy: params.orderBy,\n order: params.order,\n })\n\n return {\n objects: [...result.objects],\n hasMore: result.hasMore,\n total: result.total,\n }\n}\n\nfunction resolveTypeFilter(\n runtime: SixbRuntimeContext,\n requested: readonly string[] | undefined\n): readonly string[] | undefined {\n const ontology =\n resolveRuntimeAuthorizationForProject(runtime).type === \"delegated\"\n ? getAuthorizedOntologyView(runtime.objectReader)\n : runtime.ontology\n if (requested) {\n for (const objectTypeId of requested) {\n ontology.resolveObjectType(objectTypeId)\n }\n }\n\n return requested\n ? [...new Set(requested.flatMap((id) => [id, ...ontology.listSubTypes(id)]))]\n : undefined\n}\n",
|
|
28
|
+
"/**\n * Service layer for object upsert operations.\n *\n * Resolves objectTypeId to a typed context and delegates to leaf functions.\n */\nimport type { BatchItemResult, SixbRuntimeContext } from \"../../runtime/types\"\nimport type { ObjectRow } from \"../../storage\"\nimport { resolveObjectContext } from \"../context\"\nimport {\n upsertObjectBatch as upsertObjectBatchLeaf,\n upsertObject as upsertObjectLeaf,\n} from \"../object\"\n\nexport async function upsertObject(\n runtime: SixbRuntimeContext,\n objectTypeId: string,\n properties: Record<string, unknown>\n): Promise<ObjectRow> {\n return upsertObjectLeaf(resolveObjectContext(runtime, objectTypeId), properties)\n}\n\nexport async function upsertObjectBatch(\n runtime: SixbRuntimeContext,\n objectTypeId: string,\n items: readonly { properties: Record<string, unknown> }[]\n): Promise<readonly BatchItemResult<ObjectRow>[]> {\n return upsertObjectBatchLeaf(resolveObjectContext(runtime, objectTypeId), items)\n}\n",
|
|
29
|
+
"/**\n * Service layer for telemetry operations.\n *\n * Resolves objectTypeId to a typed context and delegates to the leaf function.\n */\nimport type { SixbRuntimeContext } from \"../../runtime/types\"\nimport { resolveObjectContext } from \"../context\"\nimport { appendTelemetryBatch as appendTelemetryBatchLeaf } from \"../telemetry\"\n\nexport async function appendTelemetry(\n runtime: SixbRuntimeContext,\n objectTypeId: string,\n items: readonly { id: string; properties: Record<string, unknown>; at?: Date }[]\n): Promise<void> {\n const ctx = resolveObjectContext(runtime, objectTypeId)\n await appendTelemetryBatchLeaf(ctx, items)\n}\n"
|
|
30
|
+
],
|
|
31
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,eAAsB,cAAa,CACjC,KACA,QAM8B;AAAA,EAC9B,OAAO,cAAqB,KAAK,IAAI,WAAW;AAAA,IAC9C,UAAU,OAAO;AAAA,IACjB,SAAS;AAAA,MACP,MAAM;AAAA,MACN,cAAc,IAAI,WAAW;AAAA,MAC7B,WAAW,OAAO;AAAA,IACpB;AAAA,IACA,QAAQ,OAAO;AAAA,IACf,OAAO,OAAO,SAAS;AAAA,IACvB,QAAQ,OAAO,SAAS;AAAA,EAC1B,CAAC;AAAA;AAGH,eAAsB,qBAAoB,CACxC,KACA,QAM0B;AAAA,EAC1B,OAAO,qBAA4B,KAAK,IAAI,WAAW;AAAA,IACrD,UAAU,OAAO;AAAA,IACjB,SAAS;AAAA,MACP,MAAM;AAAA,MACN,cAAc,IAAI,WAAW;AAAA,MAC7B,WAAW,OAAO;AAAA,IACpB;AAAA,IACA,QAAQ,OAAO;AAAA,IACf,OAAO,OAAO,SAAS;AAAA,IACvB,WAAW,OAAO,SAAS;AAAA,IAC3B,QAAQ,OAAO,SAAS;AAAA,IACxB,aAAa,OAAO,SAAS;AAAA,EAC/B,CAAC;AAAA;;ACzDI,MAAM,oBAAoB,MAAM;AAAA,EAC5B,OAAO;AAClB;;;ACGA;AAkDA,eAAsB,uBAAuB,CAC3C,KACA,YAC2B;AAAA,EAC3B,MAAM,YAAY,2BAA2B,GAAG;AAAA,EAChD,MAAM,SAAS,MAAM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AO,OAAO;AAAA,IAC3B,SAAS,OAAO;AAAA,IAChB,OAAO,OAAO;AAAA,EAChB;AAAA;AAGF,SAAS,iBAAiB,CACxB,SACA,WAC+B;AAAA,EAC/B,MAAM,WACJ,sCAAsC,OAAO,EAAE,SAAS,cACpD,0BAA0B,QAAQ,YAAY,IAC9C,QAAQ;AAAA,EACd,IAAI,WAAW;AAAA,IACb,WAAW,gBAAgB,WAAW;AAAA,MACpC,SAAS,kBAAkB,YAAY;AAAA,IACzC;AAAA,EACF;AAAA,EAEA,OAAO,YACH,CAAC,GAAG,IAAI,IAAI,UAAU,QAAQ,CAAC,OAAO,CAAC,IAAI,GAAG,SAAS,aAAa,EAAE,CAAC,CAAC,CAAC,CAAC,IAC1E;AAAA;;AC5DN,eAAsB,aAAY,CAChC,SACA,cACA,YACoB;AAAA,EACpB,OAAO,aAAiB,qBAAqB,SAAS,YAAY,GAAG,UAAU;AAAA;AAGjF,eAAsB,kBAAiB,CACrC,SACA,cACA,OACgD;AAAA,EAChD,OAAO,kBAAsB,qBAAqB,SAAS,YAAY,GAAG,KAAK;AAAA;;ACjBjF,eAAsB,eAAe,CACnC,SACA,cACA,OACe;AAAA,EACf,MAAM,MAAM,qBAAqB,SAAS,YAAY;AAAA,EACtD,MAAM,qBAAyB,KAAK,KAAK;AAAA;",
|
|
32
|
+
"debugId": "33637F3A5FA7C13764756E2164756E21",
|
|
33
|
+
"names": []
|
|
34
|
+
}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
createPrimitiveExecutionRecord
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import {
|
|
6
|
-
sha256Canonical
|
|
7
|
-
} from "./chunk-72q2y8hn.js";
|
|
4
|
+
} from "./chunk-k522z7v6.js";
|
|
8
5
|
import {
|
|
9
6
|
PROJECTION_RUN_FAILURE_CODES,
|
|
10
7
|
ProjectionRunError,
|
|
11
8
|
assertProjectionRunDurableExecution,
|
|
12
9
|
assertProjectionRunIdentityMatches
|
|
13
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-rv2hkwwa.js";
|
|
11
|
+
import {
|
|
12
|
+
sha256Canonical
|
|
13
|
+
} from "./chunk-8tsf6dmc.js";
|
|
14
14
|
import {
|
|
15
15
|
findPrimitiveRunExecution
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-j1sbhm7p.js";
|
|
17
17
|
import {
|
|
18
18
|
reportRunFailure
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-jq43kdvk.js";
|
|
20
20
|
import {
|
|
21
21
|
ProjectionValidationError
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-p1x242ad.js";
|
|
23
23
|
import {
|
|
24
24
|
createSixbError,
|
|
25
25
|
toSixbFailure
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-2xns679x.js";
|
|
27
27
|
// src/projections/capability.ts
|
|
28
28
|
var projectionRegistryKey = Symbol("sixb.projectionRegistry");
|
|
29
29
|
function registerProjectionRegistry(owner, registry) {
|
|
@@ -243,6 +243,9 @@ async function assertExistingRun(storage, run, identity) {
|
|
|
243
243
|
});
|
|
244
244
|
}
|
|
245
245
|
async function resolveProducerExecution(storage, projectId, producer) {
|
|
246
|
+
if (producer?.kind === "ingest") {
|
|
247
|
+
return producer.id ? storage.executions.getById({ projectId, id: producer.id }) : null;
|
|
248
|
+
}
|
|
246
249
|
if (!producer?.runId)
|
|
247
250
|
return null;
|
|
248
251
|
if (producer.kind === "sync") {
|
|
@@ -407,4 +410,4 @@ function toEnqueueFailure(error, run, at) {
|
|
|
407
410
|
}
|
|
408
411
|
export { registerProjectionRegistry, getProjectionRegistry, getProjectionDispatchDescriptors, shareProjectionRegistry, createProjectionRunId, PROJECTION_TELEMETRY_BATCH_SIZE, ProjectionRunDispatcher };
|
|
409
412
|
|
|
410
|
-
//# debugId=
|
|
413
|
+
//# debugId=C0C0C7AA378374DA64756E2164756E21
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/projections/capability.ts", "../src/projections/run-dispatch.ts", "../src/projections/run-id.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import type { ProjectionRegistry } from \"./registry\"\nimport type { ProjectionDispatchDescriptor } from \"./types\"\n\nconst projectionRegistryKey: unique symbol = Symbol(\"sixb.projectionRegistry\")\n\ninterface ProjectionRegistryOwner {\n readonly [projectionRegistryKey]?: ProjectionRegistry\n}\n\nexport function registerProjectionRegistry(owner: object, registry: ProjectionRegistry): void {\n const registered = (owner as ProjectionRegistryOwner)[projectionRegistryKey]\n if (registered && registered !== registry) {\n throw new Error(\"[Sixb] Projection registry is already registered for this owner.\")\n }\n Object.defineProperty(owner, projectionRegistryKey, {\n configurable: false,\n enumerable: false,\n value: registry,\n writable: false,\n })\n}\n\nexport function getProjectionRegistry(owner: object): ProjectionRegistry {\n const registry = (owner as ProjectionRegistryOwner)[projectionRegistryKey]\n if (registry) return registry\n throw new Error(\"[Sixb] Projection registry is not registered for this runtime.\")\n}\n\nexport function getProjectionDispatchDescriptors(\n owner: object\n): readonly ProjectionDispatchDescriptor[] {\n return getProjectionRegistry(owner).getDispatchDescriptors()\n}\n\nexport function shareProjectionRegistry(source: object, target: object): void {\n registerProjectionRegistry(target, getProjectionRegistry(source))\n}\n",
|
|
6
|
+
"import { randomUUID } from \"node:crypto\"\nimport { reportRunFailure } from \"../error-reporting/capability\"\nimport { createSixbError, toSixbFailure } from \"../errors/internal\"\nimport type { SixbFailure } from \"../errors/types\"\nimport type { RunDispatcher } from \"../execution/dispatch\"\nimport { createPrimitiveExecutionRecord } from \"../execution/durable\"\nimport type { DatasetProducer, LakeStorage } from \"../lake-storage\"\nimport type { Queues } from \"../queues\"\nimport type { SixbDefinitions } from \"../runtime/definitions\"\nimport type { ExecutionRecord, ProjectionRunRecord, Storage } from \"../storage\"\nimport { ProjectionRunError } from \"../storage\"\nimport { findPrimitiveRunExecution } from \"../storage/executions/run-link\"\nimport {\n assertProjectionRunDurableExecution,\n assertProjectionRunIdentityMatches,\n} from \"../storage/projection-runs/provider\"\nimport { getProjectionRegistry } from \"./capability\"\nimport { ProjectionValidationError } from \"./errors\"\nimport { createProjectionRunId } from \"./run-id\"\nimport {\n PROJECTION_RUN_FAILURE_CODES,\n type ProjectionDefinition,\n type ProjectionRunFailureCode,\n} from \"./types\"\n\n/** Target maximum mapped points per telemetry commit; a single-property projection reads 500 rows. */\nexport const PROJECTION_TELEMETRY_BATCH_SIZE = 500\n\nexport interface ProjectionRunDispatchInput {\n readonly projectionId: string\n readonly datasetVersion: {\n readonly datasetId: string\n readonly versionId: string\n readonly createdAt: string\n }\n readonly metadata?: Readonly<Record<string, string>>\n}\n\nexport interface ProjectionRunDispatchResult {\n readonly projectionId: string\n readonly runId: string\n readonly queuedAt: string\n readonly jobId?: string\n readonly created: boolean\n}\n\nexport type ProjectionRunDispatchPort = RunDispatcher<\n ProjectionRunDispatchInput,\n ProjectionRunDispatchResult\n>\n\nexport interface ProjectionRunDispatcherDependencies {\n readonly id: string\n readonly definitions: Pick<SixbDefinitions, \"projections\">\n readonly lakeStorage: Pick<LakeStorage, \"getVersion\">\n readonly storage: Storage\n readonly queues: Pick<Queues, \"projections\">\n}\n\ntype PersistedProjectionRun =\n | { readonly publish: false; readonly run: ProjectionRunRecord }\n | {\n readonly publish: true\n readonly run: ProjectionRunRecord\n readonly queuedAt: Date\n readonly created: boolean\n }\n\n/** Core-owned durable dispatch boundary for immutable dataset-version materialization. */\nexport class ProjectionRunDispatcher implements ProjectionRunDispatchPort {\n constructor(private readonly dependencies: ProjectionRunDispatcherDependencies) {}\n\n async dispatch(input: ProjectionRunDispatchInput): Promise<ProjectionRunDispatchResult> {\n assertDispatchInput(input)\n const registry = getProjectionRegistry(this.dependencies)\n const descriptor = registry.resolveDispatch(input.projectionId)\n if (descriptor.datasetId !== input.datasetVersion.datasetId) {\n throw new ProjectionValidationError(\n `[Sixb] Projection '${input.projectionId}' consumes dataset '${descriptor.datasetId}', not '${input.datasetVersion.datasetId}'.`\n )\n }\n const projection = this.dependencies.definitions.projections.getById(input.projectionId)\n if (!projection) {\n throw new ProjectionValidationError(`[Sixb] Unknown projection '${input.projectionId}'.`)\n }\n const version = await this.dependencies.lakeStorage.getVersion(\n input.datasetVersion.datasetId,\n input.datasetVersion.versionId\n )\n if (!version || version.createdAt.toISOString() !== input.datasetVersion.createdAt) {\n throw new ProjectionValidationError(\n `[Sixb] Dataset '${input.datasetVersion.datasetId}' version '${input.datasetVersion.versionId}' does not match its immutable metadata.`\n )\n }\n if (version.mode === \"schema\") {\n throw new ProjectionValidationError(\n `[Sixb] Projection '${input.projectionId}' cannot materialize a schema-only dataset version.`\n )\n }\n\n const { datasetId: _datasetId, ...semanticIdentity } = descriptor\n const identity = {\n ...semanticIdentity,\n datasetVersion: structuredClone(input.datasetVersion),\n }\n const runId = createProjectionRunId(this.dependencies.id, identity)\n const projectionRuns = requireProjectionRunStorage(this.dependencies.storage)\n const existing = await projectionRuns.getById({ projectId: this.dependencies.id, id: runId })\n const persisted = existing\n ? await reuseProjectionRun(this.dependencies, existing, identity)\n : await persistProjectionRun({\n dependencies: this.dependencies,\n runId,\n identity,\n projection,\n producerExecution: await resolveProducerExecution(\n this.dependencies.storage,\n this.dependencies.id,\n version.producer\n ),\n })\n\n if (!persisted.publish) return existingResult(persisted.run)\n return publishProjectionRun(this.dependencies, input.metadata, persisted)\n }\n}\n\nasync function persistProjectionRun(input: {\n readonly dependencies: ProjectionRunDispatcherDependencies\n readonly runId: string\n readonly identity: ProjectionRunRecord[\"identity\"]\n readonly projection: ProjectionDefinition\n readonly producerExecution: ExecutionRecord | null\n}): Promise<PersistedProjectionRun> {\n const execution = createPrimitiveExecutionRecord({\n id: `exec_${randomUUID()}`,\n primitive: { kind: \"projection\", id: input.identity.projectionId, runId: input.runId },\n origin: {\n type: \"automatic\",\n projectId: input.dependencies.id,\n source: {\n type: \"datasetVersion\",\n datasetId: input.identity.datasetVersion.datasetId,\n versionId: input.identity.datasetVersion.versionId,\n },\n correlationId: input.producerExecution?.correlationId ?? input.runId,\n ...(input.producerExecution?.requestedBy === undefined\n ? {}\n : { requestedBy: input.producerExecution.requestedBy }),\n },\n })\n const queuedAt = new Date()\n\n try {\n return await input.dependencies.storage.transaction(\n async (tx): Promise<PersistedProjectionRun> => {\n const projectionRuns = requireProjectionRunStorage(tx)\n const raced = await projectionRuns.getById({\n projectId: input.dependencies.id,\n id: input.runId,\n })\n if (raced) {\n await assertExistingRun(tx, raced, input.identity)\n return { publish: false, run: raced }\n }\n await tx.executions.create(execution)\n const run = await queueProjectionRun(projectionRuns, {\n id: input.runId,\n projectId: input.dependencies.id,\n executionId: execution.id,\n identity: input.identity,\n projection: input.projection,\n queuedAt,\n })\n return { publish: true, run, queuedAt, created: true }\n },\n { isolation: \"serializable\" }\n )\n } catch (error) {\n if (!(error instanceof ProjectionRunError)) throw error\n const raced = await requireProjectionRunStorage(input.dependencies.storage).getById({\n projectId: input.dependencies.id,\n id: input.runId,\n })\n if (!raced) throw error\n await assertExistingRun(input.dependencies.storage, raced, input.identity)\n return { publish: false, run: raced }\n }\n}\n\nasync function reuseProjectionRun(\n dependencies: ProjectionRunDispatcherDependencies,\n existing: ProjectionRunRecord,\n identity: ProjectionRunRecord[\"identity\"]\n): Promise<PersistedProjectionRun> {\n await assertExistingRun(dependencies.storage, existing, identity)\n if (\n existing.status !== \"failed\" ||\n existing.error?.code !== \"queue.enqueue_failed\" ||\n !existing.error.retryable\n ) {\n return { publish: false, run: existing }\n }\n const queuedAt = new Date()\n const projectionRuns = requireProjectionRunStorage(dependencies.storage)\n try {\n const run = await requeueProjectionRun(projectionRuns, existing, queuedAt)\n return { publish: true, run, queuedAt, created: false }\n } catch (error) {\n if (!(error instanceof ProjectionRunError)) throw error\n const raced = await projectionRuns.getById({ projectId: existing.projectId, id: existing.id })\n if (\n !raced ||\n (raced.status === \"failed\" &&\n raced.error?.code === \"queue.enqueue_failed\" &&\n raced.error.retryable)\n ) {\n throw error\n }\n await assertExistingRun(dependencies.storage, raced, identity)\n return { publish: false, run: raced }\n }\n}\n\nasync function publishProjectionRun(\n dependencies: ProjectionRunDispatcherDependencies,\n metadata: Readonly<Record<string, string>> | undefined,\n persisted: Extract<PersistedProjectionRun, { readonly publish: true }>\n): Promise<ProjectionRunDispatchResult> {\n try {\n const [job] = await dependencies.queues.projections.enqueue({\n projectId: dependencies.id,\n jobs: [\n {\n id: persisted.run.id,\n type: \"projection.run.requested\",\n payload: { runId: persisted.run.id },\n ...(metadata === undefined ? {} : { metadata }),\n },\n ],\n })\n return {\n projectionId: persisted.run.identity.projectionId,\n runId: persisted.run.id,\n queuedAt: persisted.queuedAt.toISOString(),\n ...(job?.id ? { jobId: job.id } : {}),\n created: persisted.created,\n }\n } catch (error) {\n const failedAt = new Date()\n const failure = toEnqueueFailure(error, persisted.run, failedAt)\n const failed = await requireProjectionRunStorage(dependencies.storage).failEnqueue({\n projectId: dependencies.id,\n id: persisted.run.id,\n finishedAt: failedAt,\n error: failure,\n })\n reportRunFailure(dependencies, error, {\n projectId: dependencies.id,\n runKind: \"projection\",\n run: {\n runId: failed.id,\n projectionId: failed.identity.projectionId,\n projectionKind: failed.identity.projectionKind,\n },\n failure,\n })\n throw error\n }\n}\n\nasync function assertExistingRun(\n storage: Storage,\n run: ProjectionRunRecord,\n identity: ProjectionRunRecord[\"identity\"]\n): Promise<void> {\n assertProjectionRunIdentityMatches(run, identity)\n await assertProjectionRunDurableExecution({\n executions: storage.executions,\n projectId: run.projectId,\n executionId: run.executionId,\n runId: run.id,\n projectionId: run.identity.projectionId,\n datasetId: run.identity.datasetVersion.datasetId,\n datasetVersionId: run.identity.datasetVersion.versionId,\n })\n}\n\nasync function resolveProducerExecution(\n storage: Storage,\n projectId: string,\n producer: DatasetProducer | undefined\n): Promise<ExecutionRecord | null> {\n if (producer?.kind === \"ingest\") {\n return producer.id ? storage.executions.getById({ projectId, id: producer.id }) : null\n }\n if (!producer?.runId) return null\n if (producer.kind === \"sync\") {\n const run = await storage.syncRuns?.getById({ projectId, id: producer.runId })\n if (!run) return null\n assertProducerId(producer, run.syncId)\n return requireProducerExecution({\n executions: storage.executions,\n projectId,\n executionId: run.executionId,\n primitive: { kind: \"sync\", id: run.syncId, runId: run.id },\n })\n }\n\n const run = await storage.pipelineRuns?.getById({ projectId, id: producer.runId })\n if (!run) return null\n assertProducerId(producer, run.pipelineId)\n return requireProducerExecution({\n executions: storage.executions,\n projectId,\n executionId: run.executionId,\n primitive: { kind: \"pipeline\", id: run.pipelineId, runId: run.id },\n })\n}\n\nasync function requireProducerExecution(input: {\n readonly executions: Storage[\"executions\"]\n readonly projectId: string\n readonly executionId: string\n readonly primitive:\n | { readonly kind: \"sync\"; readonly id: string; readonly runId: string }\n | { readonly kind: \"pipeline\"; readonly id: string; readonly runId: string }\n}): Promise<ExecutionRecord> {\n const execution = await findPrimitiveRunExecution({\n executions: input.executions,\n projectId: input.projectId,\n executionId: input.executionId,\n primitive: input.primitive,\n sourceTypes: [\"execution\", \"schedule\", \"event\"],\n })\n if (execution) return execution\n throw new ProjectionValidationError(\n `[Sixb] Dataset producer run '${input.primitive.runId}' references an invalid execution.`\n )\n}\n\nfunction assertProducerId(producer: DatasetProducer, runOwnerId: string): void {\n if (producer.id === undefined || producer.id === runOwnerId) return\n throw new ProjectionValidationError(\n `[Sixb] Dataset producer '${producer.kind}:${producer.id}' does not match run '${producer.runId}'.`\n )\n}\n\nfunction requireProjectionRunStorage(storage: Storage): NonNullable<Storage[\"projectionRuns\"]> {\n if (storage.projectionRuns) return storage.projectionRuns\n throw new ProjectionValidationError(\"[Sixb] Projection run storage is not configured.\")\n}\n\nfunction queueProjectionRun(\n storage: NonNullable<Storage[\"projectionRuns\"]>,\n input: {\n readonly id: string\n readonly projectId: string\n readonly executionId: string\n readonly identity: ProjectionRunRecord[\"identity\"]\n readonly projection: ProjectionDefinition\n readonly queuedAt: Date\n }\n): Promise<ProjectionRunRecord> {\n const common = {\n id: input.id,\n projectId: input.projectId,\n executionId: input.executionId,\n queuedAt: input.queuedAt,\n }\n switch (input.projection._tag) {\n case \"ObjectProjectionDefinition\":\n if (input.identity.projectionKind !== \"object\") {\n throw invalidProjectionDefinition(input.id)\n }\n return storage.queue({\n ...common,\n identity: input.identity,\n target: { objectTypeId: input.projection.objectTypeId },\n })\n case \"LinkProjectionDefinition\":\n if (input.identity.projectionKind !== \"link\") {\n throw invalidProjectionDefinition(input.id)\n }\n return storage.queue({\n ...common,\n identity: input.identity,\n target: {\n sourceObjectTypeId: input.projection.sourceObjectTypeId,\n targetObjectTypeId: input.projection.targetObjectTypeId,\n },\n })\n case \"TelemetryProjectionDefinition\":\n if (input.identity.projectionKind !== \"telemetry\") {\n throw invalidProjectionDefinition(input.id)\n }\n return storage.queue({\n ...common,\n identity: input.identity,\n target: { objectTypeId: input.projection.objectTypeId },\n fixedBatchSize: telemetryProjectionBatchRowCount(input.projection),\n })\n }\n}\n\nfunction telemetryProjectionBatchRowCount(\n projection: Extract<ProjectionDefinition, { readonly _tag: \"TelemetryProjectionDefinition\" }>\n): number {\n const mappedPropertyCount = Object.keys(projection.properties).length\n if (mappedPropertyCount === 0) throw invalidProjectionDefinition(projection.id)\n return Math.max(1, Math.floor(PROJECTION_TELEMETRY_BATCH_SIZE / mappedPropertyCount))\n}\n\nfunction requeueProjectionRun(\n storage: NonNullable<Storage[\"projectionRuns\"]>,\n run: ProjectionRunRecord,\n queuedAt: Date\n): Promise<ProjectionRunRecord> {\n const common = {\n id: run.id,\n projectId: run.projectId,\n executionId: run.executionId,\n queuedAt,\n }\n switch (run.identity.projectionKind) {\n case \"object\": {\n if (!(\"objectTypeId\" in run.target)) throw invalidProjectionDefinition(run.id)\n return storage.queue({ ...common, identity: run.identity, target: run.target })\n }\n case \"link\": {\n if (!(\"sourceObjectTypeId\" in run.target)) throw invalidProjectionDefinition(run.id)\n return storage.queue({ ...common, identity: run.identity, target: run.target })\n }\n case \"telemetry\": {\n if (!(\"objectTypeId\" in run.target) || !run.telemetryCheckpoint) {\n throw invalidProjectionDefinition(run.id)\n }\n return storage.queue({\n ...common,\n identity: run.identity,\n target: run.target,\n fixedBatchSize: run.telemetryCheckpoint.fixedBatchSize,\n })\n }\n }\n}\n\nfunction invalidProjectionDefinition(runId: string): ProjectionValidationError {\n return new ProjectionValidationError(\n `[Sixb] Projection run '${runId}' has inconsistent definition metadata.`\n )\n}\n\nfunction existingResult(run: ProjectionRunRecord): ProjectionRunDispatchResult {\n return {\n projectionId: run.identity.projectionId,\n runId: run.id,\n queuedAt: run.queuedAt.toISOString(),\n created: false,\n }\n}\n\nfunction assertDispatchInput(input: ProjectionRunDispatchInput): void {\n for (const [field, value] of [\n [\"projectionId\", input.projectionId],\n [\"datasetId\", input.datasetVersion.datasetId],\n [\"versionId\", input.datasetVersion.versionId],\n ] as const) {\n if (!value.trim())\n throw new ProjectionValidationError(`[Sixb] Projection ${field} is required.`)\n }\n const timestamp = Date.parse(input.datasetVersion.createdAt)\n if (\n !Number.isFinite(timestamp) ||\n new Date(timestamp).toISOString() !== input.datasetVersion.createdAt\n ) {\n throw new ProjectionValidationError(\"[Sixb] Projection dataset version timestamp is invalid.\")\n }\n}\n\nfunction toEnqueueFailure(\n error: unknown,\n run: ProjectionRunRecord,\n at: Date\n): SixbFailure<ProjectionRunFailureCode> {\n const enqueueError = createSixbError(\n \"queue.enqueue_failed\",\n `[Sixb] Could not enqueue Projection run '${run.id}'.`,\n {\n cause: error,\n details: {\n projectionId: run.identity.projectionId,\n projectionKind: run.identity.projectionKind,\n runId: run.id,\n phase: \"enqueue\",\n },\n }\n )\n return toSixbFailure(enqueueError, { allowedCodes: PROJECTION_RUN_FAILURE_CODES, at })\n}\n",
|
|
7
|
+
"import { sha256Canonical } from \"../materialization/identity\"\nimport type { ProjectionMaterializationIdentity } from \"../materialization/model\"\n\nexport function createProjectionRunId(\n projectId: string,\n identity: ProjectionMaterializationIdentity\n): string {\n return sha256Canonical({\n projectId,\n projectionId: identity.projectionId,\n projectionKind: identity.projectionKind,\n protocol: identity.protocol,\n datasetId: identity.datasetVersion.datasetId,\n versionId: identity.datasetVersion.versionId,\n createdAt: identity.datasetVersion.createdAt,\n ontologyRevision: identity.ontologyRevision,\n projectionRevision: identity.projectionRevision,\n ownershipHash: identity.ownershipHash,\n })\n}\n"
|
|
8
|
+
],
|
|
9
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAM,wBAAuC,OAAO,yBAAyB;AAMtE,SAAS,0BAA0B,CAAC,OAAe,UAAoC;AAAA,EAC5F,MAAM,aAAc,MAAkC;AAAA,EACtD,IAAI,cAAc,eAAe,UAAU;AAAA,IACzC,MAAM,IAAI,MAAM,kEAAkE;AAAA,EACpF;AAAA,EACA,OAAO,eAAe,OAAO,uBAAuB;AAAA,IAClD,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,UAAU;AAAA,EACZ,CAAC;AAAA;AAGI,SAAS,qBAAqB,CAAC,OAAmC;AAAA,EACvE,MAAM,WAAY,MAAkC;AAAA,EACpD,IAAI;AAAA,IAAU,OAAO;AAAA,EACrB,MAAM,IAAI,MAAM,gEAAgE;AAAA;AAG3E,SAAS,gCAAgC,CAC9C,OACyC;AAAA,EACzC,OAAO,sBAAsB,KAAK,EAAE,uBAAuB;AAAA;AAGtD,SAAS,uBAAuB,CAAC,QAAgB,QAAsB;AAAA,EAC5E,2BAA2B,QAAQ,sBAAsB,MAAM,CAAC;AAAA;;ACnClE;;;ACGO,SAAS,qBAAqB,CACnC,WACA,UACQ;AAAA,EACR,OAAO,gBAAgB;AAAA,IACrB;AAAA,IACA,cAAc,SAAS;AAAA,IACvB,gBAAgB,SAAS;AAAA,IACzB,UAAU,SAAS;AAAA,IACnB,WAAW,SAAS,eAAe;AAAA,IACnC,WAAW,SAAS,eAAe;AAAA,IACnC,WAAW,SAAS,eAAe;AAAA,IACnC,kBAAkB,S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Ae,SAAS;AAAA,EAC9C,GAAY;AAAA,IACV,IAAI,CAAC,MAAM,KAAK;AAAA,MACd,MAAM,IAAI,0BAA0B,qBAAqB,oBAAoB;AAAA,EACjF;AAAA,EACA,MAAM,YAAY,KAAK,MAAM,MAAM,eAAe,SAAS;AAAA,EAC3D,IACE,CAAC,OAAO,SAAS,SAAS,KAC1B,IAAI,KAAK,SAAS,EAAE,YAAY,MAAM,MAAM,eAAe,WAC3D;AAAA,IACA,MAAM,IAAI,0BAA0B,yDAAyD;AAAA,EAC/F;AAAA;AAGF,SAAS,gBAAgB,CACvB,OACA,KACA,IACuC;AAAA,EACvC,MAAM,eAAe,gBACnB,wBACA,4CAA4C,IAAI,QAChD;AAAA,IACE,OAAO;AAAA,IACP,SAAS;AAAA,MACP,cAAc,IAAI,SAAS;AAAA,MAC3B,gBAAgB,IAAI,SAAS;AAAA,MAC7B,OAAO,IAAI;AAAA,MACX,OAAO;AAAA,IACT;AAAA,EACF,CACF;AAAA,EACA,OAAO,cAAc,cAAc,EAAE,cAAc,8BAA8B,GAAG,CAAC;AAAA;",
|
|
10
|
+
"debugId": "C0C0C7AA378374DA64756E2164756E21",
|
|
11
|
+
"names": []
|
|
12
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
aiLimitSubjectKey
|
|
4
|
+
} from "./chunk-jecn6t54.js";
|
|
5
|
+
import {
|
|
6
|
+
createSixbError
|
|
7
|
+
} from "./chunk-2xns679x.js";
|
|
8
|
+
|
|
9
|
+
// src/storage/ai-limits/enforcement.ts
|
|
10
|
+
function aiLimitSubjectsFromAttribution(requestedBy, requesterGroupIds) {
|
|
11
|
+
const subjects = [
|
|
12
|
+
{ type: "project" },
|
|
13
|
+
...requesterGroupIds.map((id) => ({ type: "group", id }))
|
|
14
|
+
];
|
|
15
|
+
if (requestedBy)
|
|
16
|
+
subjects.push(requestedBy);
|
|
17
|
+
const byKey = new Map(subjects.map((subject) => [aiLimitSubjectKey(subject), subject]));
|
|
18
|
+
return [...byKey.values()].sort((left, right) => aiLimitSubjectKey(left).localeCompare(aiLimitSubjectKey(right)));
|
|
19
|
+
}
|
|
20
|
+
function applicableAiLimitPolicyStatuses(statuses, subjects) {
|
|
21
|
+
const keys = new Set(subjects.map(aiLimitSubjectKey));
|
|
22
|
+
return statuses.filter((status) => keys.has(aiLimitSubjectKey(status.policy.subject)));
|
|
23
|
+
}
|
|
24
|
+
function applicableAiLimitPolicies(policies, subjects) {
|
|
25
|
+
const keys = new Set(subjects.map(aiLimitSubjectKey));
|
|
26
|
+
return policies.filter((policy) => keys.has(aiLimitSubjectKey(policy.subject)));
|
|
27
|
+
}
|
|
28
|
+
function aiUsageLimitExceededError(resetAt) {
|
|
29
|
+
return createSixbError("ai.usage_limit_exceeded", "[Sixb] An applicable AI usage limit has no capacity for this model call.", { details: aiLimitFailureDetails({ resetAt }) });
|
|
30
|
+
}
|
|
31
|
+
function aiUsageLimitUnavailableError(reasons) {
|
|
32
|
+
return createSixbError("ai.usage_limit_unavailable", "[Sixb] An applicable AI usage limit could not be evaluated safely.", { details: aiLimitFailureDetails({ reasons }) });
|
|
33
|
+
}
|
|
34
|
+
function aiLimitFailureDetails(input) {
|
|
35
|
+
return {
|
|
36
|
+
...input.resetAt === undefined ? {} : { resetAt: input.resetAt.toISOString() },
|
|
37
|
+
...input.reasons === undefined ? {} : { reasons: [...input.reasons] }
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export { aiLimitSubjectsFromAttribution, applicableAiLimitPolicyStatuses, applicableAiLimitPolicies, aiUsageLimitExceededError, aiUsageLimitUnavailableError };
|
|
42
|
+
|
|
43
|
+
//# debugId=264BFFFD79C6CA2964756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/storage/ai-limits/enforcement.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { createSixbError, type SixbCodedError } from \"../../errors/internal\"\nimport type { AuthorizablePrincipal } from \"../../execution/types\"\nimport type { ReadonlyJsonValue } from \"../../json\"\nimport { aiLimitSubjectKey } from \"./provider\"\nimport type { AiLimitPolicy, AiLimitPolicyStatus, AiLimitSubject } from \"./types\"\n\n/** @internal Resolve the immutable attribution dimensions enforced for one model call. */\nexport function aiLimitSubjectsFromAttribution(\n requestedBy: AuthorizablePrincipal | undefined,\n requesterGroupIds: readonly string[]\n): readonly AiLimitSubject[] {\n const subjects: AiLimitSubject[] = [\n { type: \"project\" },\n ...requesterGroupIds.map((id): AiLimitSubject => ({ type: \"group\", id })),\n ]\n if (requestedBy) subjects.push(requestedBy)\n\n const byKey = new Map(subjects.map((subject) => [aiLimitSubjectKey(subject), subject]))\n return [...byKey.values()].sort((left, right) =>\n aiLimitSubjectKey(left).localeCompare(aiLimitSubjectKey(right))\n )\n}\n\n/** @internal Select every policy that applies to the call's immutable attribution snapshot. */\nexport function applicableAiLimitPolicyStatuses(\n statuses: readonly AiLimitPolicyStatus[],\n subjects: readonly AiLimitSubject[]\n): readonly AiLimitPolicyStatus[] {\n const keys = new Set(subjects.map(aiLimitSubjectKey))\n return statuses.filter((status) => keys.has(aiLimitSubjectKey(status.policy.subject)))\n}\n\n/** @internal Cheap policy-only counterpart used before the authoritative atomic reservation. */\nexport function applicableAiLimitPolicies(\n policies: readonly AiLimitPolicy[],\n subjects: readonly AiLimitSubject[]\n): readonly AiLimitPolicy[] {\n const keys = new Set(subjects.map(aiLimitSubjectKey))\n return policies.filter((policy) => keys.has(aiLimitSubjectKey(policy.subject)))\n}\n\n/** @internal Stable failure safe for callers that may only hold run authority. */\nexport function aiUsageLimitExceededError(resetAt: Date): SixbCodedError {\n return createSixbError(\n \"ai.usage_limit_exceeded\",\n \"[Sixb] An applicable AI usage limit has no capacity for this model call.\",\n { details: aiLimitFailureDetails({ resetAt }) }\n )\n}\n\n/** @internal Fail closed when an applicable policy cannot be measured or reserved safely. */\nexport function aiUsageLimitUnavailableError(reasons: readonly string[]): SixbCodedError {\n return createSixbError(\n \"ai.usage_limit_unavailable\",\n \"[Sixb] An applicable AI usage limit could not be evaluated safely.\",\n { details: aiLimitFailureDetails({ reasons }) }\n )\n}\n\nfunction aiLimitFailureDetails(input: {\n readonly resetAt?: Date\n readonly reasons?: readonly string[]\n}): ReadonlyJsonValue {\n return {\n ...(input.resetAt === undefined ? {} : { resetAt: input.resetAt.toISOString() }),\n ...(input.reasons === undefined ? {} : { reasons: [...input.reasons] }),\n }\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;;;;;;;;AAOO,SAAS,8BAA8B,CAC5C,aACA,mBAC2B;AAAA,EAC3B,MAAM,WAA6B;AAAA,IACjC,EAAE,MAAM,UAAU;AAAA,IAClB,GAAG,kBAAkB,IAAI,CAAC,QAAwB,EAAE,MAAM,SAAS,GAAG,EAAE;AAAA,EAC1E;AAAA,EACA,IAAI;AAAA,IAAa,SAAS,KAAK,WAAW;AAAA,EAE1C,MAAM,QAAQ,IAAI,IAAI,SAAS,IAAI,CAAC,YAAY,CAAC,kBAAkB,OAAO,GAAG,OAAO,CAAC,CAAC;AAAA,EACtF,OAAO,CAAC,GAAG,MAAM,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,UACrC,kBAAkB,IAAI,EAAE,cAAc,kBAAkB,KAAK,CAAC,CAChE;AAAA;AAIK,SAAS,+BAA+B,CAC7C,UACA,UACgC;AAAA,EAChC,MAAM,OAAO,IAAI,IAAI,SAAS,IAAI,iBAAiB,CAAC;AAAA,EACpD,OAAO,SAAS,OAAO,CAAC,WAAW,KAAK,IAAI,kBAAkB,OAAO,OAAO,OAAO,CAAC,CAAC;AAAA;AAIhF,SAAS,yBAAyB,CACvC,UACA,UAC0B;AAAA,EAC1B,MAAM,OAAO,IAAI,IAAI,SAAS,IAAI,iBAAiB,CAAC;AAAA,EACpD,OAAO,SAAS,OAAO,CAAC,WAAW,KAAK,IAAI,kBAAkB,OAAO,OAAO,CAAC,CAAC;AAAA;AAIzE,SAAS,yBAAyB,CAAC,SAA+B;AAAA,EACvE,OAAO,gBACL,2BACA,4EACA,EAAE,SAAS,sBAAsB,EAAE,QAAQ,CAAC,EAAE,CAChD;AAAA;AAIK,SAAS,4BAA4B,CAAC,SAA4C;AAAA,EACvF,OAAO,gBACL,8BACA,sEACA,EAAE,SAAS,sBAAsB,EAAE,QAAQ,CAAC,EAAE,CAChD;AAAA;AAGF,SAAS,qBAAqB,CAAC,OAGT;AAAA,EACpB,OAAO;AAAA,OACD,MAAM,YAAY,YAAY,CAAC,IAAI,EAAE,SAAS,MAAM,QAAQ,YAAY,EAAE;AAAA,OAC1E,MAAM,YAAY,YAAY,CAAC,IAAI,EAAE,SAAS,CAAC,GAAG,MAAM,OAAO,EAAE;AAAA,EACvE;AAAA;",
|
|
8
|
+
"debugId": "264BFFFD79C6CA2964756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
var AGENT_RUN_FAILURE_CODES = [
|
|
4
4
|
"internal.unexpected",
|
|
5
5
|
"runtime.cancelled",
|
|
6
|
-
"agent.execution_failed"
|
|
6
|
+
"agent.execution_failed",
|
|
7
|
+
"ai.usage_limit_exceeded",
|
|
8
|
+
"ai.usage_limit_unavailable"
|
|
7
9
|
];
|
|
8
10
|
var AGENT_RUN_FINISH_REASONS = [
|
|
9
11
|
"stop",
|
|
@@ -32,4 +34,4 @@ var AGENT_RUN_DIAGNOSTIC_CODES = [
|
|
|
32
34
|
|
|
33
35
|
export { AGENT_RUN_FAILURE_CODES, AGENT_RUN_FINISH_REASONS, coerceAgentRunFinishReason, AGENT_RUN_DIAGNOSTIC_CODES };
|
|
34
36
|
|
|
35
|
-
//# debugId=
|
|
37
|
+
//# debugId=4012BA3E8FE1A2E864756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/storage/agents/types.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import type { AgentMessage, AgentMessagePart, AgentMessageRole } from \"../../agents/message\"\nimport type { AgentReasoningLevel } from \"../../agents/types\"\nimport type { Principal } from \"../../auth\"\nimport type { FileRef } from \"../../blob-storage\"\nimport type { SixbErrorCode, SixbFailure } from \"../../errors/types\"\nimport type { JsonValue } from \"../../json\"\nimport type { LanguageModelRef } from \"../../models\"\n\n// ── agent_threads — one conversation with an agent ──────────────────────────────────────────────\n\nexport type AgentThreadStatus = \"active\" | \"archived\"\n\nexport interface AgentThreadRecord {\n readonly id: string\n readonly projectId: string\n /** Who owns/opened the thread. Reuses the canonical auth principal (gains `agent` later for free). */\n readonly ownerPrincipal: Principal\n readonly title?: string\n readonly status: AgentThreadStatus\n /** Single-flight anchor: the id of the one run currently allowed to write, or `null` when idle. */\n readonly activeRunId: string | null\n readonly lastMessageAt?: Date\n readonly messageCount: number\n readonly createdAt: Date\n readonly updatedAt: Date\n}\n\nexport interface CreateAgentThreadInput {\n readonly id: string\n readonly projectId: string\n readonly ownerPrincipal: Principal\n readonly title?: string\n readonly status?: AgentThreadStatus\n readonly createdAt?: Date\n readonly updatedAt?: Date\n}\n\nexport interface ListAgentThreadsInput {\n readonly projectId: string\n readonly statuses?: readonly AgentThreadStatus[]\n readonly ownerPrincipal?: Principal\n readonly limit?: number\n readonly offset?: number\n readonly order?: \"asc\" | \"desc\"\n}\n\nexport interface ListAgentThreadsResult {\n readonly threads: readonly AgentThreadRecord[]\n readonly hasMore: boolean\n readonly total: number\n}\n\n// ── agent_runs — one loop execution (the worker job; attribution + fencing) ───────────────────\n\n/** Lifecycle shared by every durable agent execution, conversational or workflow-owned. */\nexport type AgentExecutionStatus = \"queued\" | \"running\" | \"succeeded\" | \"failed\" | \"cancelled\"\n\nexport type AgentRunStatus = AgentExecutionStatus\nexport type AgentRunKind = \"conversation\" | \"subagent\"\n\n/** Error codes an agent execution can persist and expose through its public contract. */\nexport const AGENT_RUN_FAILURE_CODES = [\n \"internal.unexpected\",\n \"runtime.cancelled\",\n \"agent.execution_failed\",\n \"ai.usage_limit_exceeded\",\n \"ai.usage_limit_unavailable\",\n] as const satisfies readonly [SixbErrorCode, ...SixbErrorCode[]]\n\nexport type AgentRunFailureCode = (typeof AGENT_RUN_FAILURE_CODES)[number]\n\n/**\n * Why a run ended — Sixb's provider-independent vocabulary. It includes model-loop reasons plus\n * platform-level endings such as `timeout`, so reads remain typed and exhaustive. `other` and\n * `unknown` preserve terminal state when a provider adds a new reason.\n */\nexport const AGENT_RUN_FINISH_REASONS = [\n \"stop\",\n \"length\",\n \"content-filter\",\n \"tool-calls\",\n \"timeout\",\n \"error\",\n \"other\",\n \"unknown\",\n] as const\n\nexport type AgentRunFinishReason = (typeof AGENT_RUN_FINISH_REASONS)[number]\n\n/**\n * Coerce an external finish-reason string — a DB column or an SDK value — to {@link\n * AgentRunFinishReason}. An unrecognised value becomes `\"unknown\"` rather than being dropped.\n */\nexport function coerceAgentRunFinishReason(\n value: string | null | undefined\n): AgentRunFinishReason | undefined {\n if (value === null || value === undefined) {\n return undefined\n }\n return (AGENT_RUN_FINISH_REASONS as readonly string[]).includes(value)\n ? (value as AgentRunFinishReason)\n : \"unknown\"\n}\n\n/** Stable, user-facing diagnostics emitted by the platform while executing a run. */\nexport const AGENT_RUN_DIAGNOSTIC_CODES = [\n \"output_file_limit_exceeded\",\n \"output_file_too_large\",\n \"output_budget_exhausted\",\n \"output_collection_failed\",\n \"output_file_changed\",\n \"output_storage_failed\",\n] as const\n\n/**\n * Closed on purpose, and the wire is closed with it.\n *\n * Sixb writes these codes and the generated client is what reads them, so an open union would only\n * be honest if the HTTP schema were open too — and that costs the OpenAPI enum, the client's\n * autocompletion, and Atlas's exhaustive `switch`. Sixb owns both ends, so a new code is a minor\n * version bump: cheap here, and a broken `switch` is better than a 500 from `z.enum`.\n */\nexport type AgentRunDiagnosticCode = (typeof AGENT_RUN_DIAGNOSTIC_CODES)[number]\nexport type AgentRunDiagnosticSeverity = \"warning\" | \"error\"\n\nexport interface AgentRunDiagnostic {\n readonly code: AgentRunDiagnosticCode\n readonly severity: AgentRunDiagnosticSeverity\n readonly scope: \"output\"\n /** Relative path inside the run's published output directory, when one file is involved. */\n readonly path?: string\n /** Sanitized, stable copy suitable for display to an end user. */\n readonly message: string\n}\n\n/**\n * Authorization state for the current queue delivery.\n *\n * `queueLeaseExpiresAt` is a persisted projection of `ClaimedQueueJob.leaseExpiresAt`, not an\n * independently managed run lease. It may only be extended from a successful queue lease renewal.\n */\nexport interface AgentRunExecution {\n readonly token: string\n readonly queueLeaseExpiresAt: Date\n}\n\ninterface AgentRunRecordBase {\n readonly id: string\n readonly projectId: string\n readonly executionId: string\n /** Durable group memberships snapshotted when the run was admitted. */\n readonly requesterGroupIds: readonly string[]\n readonly status: AgentRunStatus\n readonly modelId?: string\n /** Why the run ended (our own SDK-independent enum). */\n readonly finishReason?: AgentRunFinishReason\n /** Platform diagnostics are transcript annotations, never agent-authored message content. */\n readonly diagnostics?: readonly AgentRunDiagnostic[]\n /** Portable failure snapshot when the run did not succeed. */\n readonly error?: SixbFailure<AgentRunFailureCode>\n /** Execution attempts: `0` while queued, `1` on first start, incremented on redelivery. */\n readonly attempt: number\n readonly execution?: AgentRunExecution\n readonly createdAt: Date\n readonly startedAt?: Date\n readonly completedAt?: Date\n}\n\nexport interface ConversationAgentRunRecord extends AgentRunRecordBase {\n readonly kind: \"conversation\"\n readonly threadId: string\n readonly triggerMessageId: string\n /** Immutable model selection captured at admission. Absent only on runs predating this field. */\n readonly spec?: ConversationAgentRunSpec\n}\n\n/** Immutable, serialisable model selection for one conversational turn. */\nexport interface ConversationAgentRunSpec {\n readonly model: LanguageModelRef\n readonly reasoning?: AgentReasoningLevel\n}\n\n/** Immutable, serialisable child configuration captured before dispatch. */\nexport interface SubagentRunSpec {\n readonly model: LanguageModelRef\n readonly reasoning?: AgentReasoningLevel\n /** Focused task supplied by the parent Agent. */\n readonly task: string\n /** Project tools available when the child was admitted. Runtime tools are injected separately. */\n readonly toolNames: readonly string[]\n readonly maxSteps: number\n}\n\n/** Durable child output returned to its parent by `wait_agent`. */\nexport interface SubagentRunResult {\n readonly text?: string\n readonly files?: readonly FileRef[]\n}\n\nexport interface SubagentRunRecord extends AgentRunRecordBase {\n readonly kind: \"subagent\"\n readonly parentRunId: string\n /** Stable parent-selected key that makes repeated tool execution idempotent. */\n readonly spawnKey: string\n readonly spec: SubagentRunSpec\n readonly result?: SubagentRunResult\n}\n\nexport type AgentRunRecord = ConversationAgentRunRecord | SubagentRunRecord\n\nexport interface CreateAgentRunInput {\n readonly id: string\n readonly projectId: string\n readonly executionId: string\n readonly threadId: string\n readonly triggerMessageId: string\n readonly spec: ConversationAgentRunSpec\n readonly requesterGroupIds: readonly string[]\n readonly createdAt?: Date\n}\n\nexport interface CreateSubagentRunInput {\n readonly id: string\n readonly projectId: string\n readonly executionId: string\n readonly parentRunId: string\n /** Current parent delivery token. New children are admitted only while that delivery owns it. */\n readonly parentExecutionToken: string\n readonly spawnKey: string\n readonly spec: SubagentRunSpec\n /** Internal safety bound enforced atomically across worker processes. */\n readonly maxActiveChildren: number\n readonly createdAt?: Date\n}\n\nexport interface StartAgentRunInput {\n readonly id: string\n readonly projectId: string\n readonly modelId?: string\n readonly execution: AgentRunExecution\n readonly startedAt?: Date\n}\n\nexport interface FinishQueuedAgentRunInput {\n readonly id: string\n readonly projectId: string\n readonly status: \"failed\" | \"cancelled\"\n readonly error?: SixbFailure<AgentRunFailureCode>\n readonly completedAt?: Date\n}\n\nexport interface ReclaimAgentRunInput {\n readonly id: string\n readonly projectId: string\n readonly execution: AgentRunExecution\n}\n\nexport interface ConfirmAgentRunExecutionOwnershipInput {\n readonly id: string\n readonly projectId: string\n readonly executionToken: string\n /** Exact expiration returned by the queue claim or its latest successful renewal. */\n readonly queueLeaseExpiresAt: Date\n}\n\nexport type FinishAgentRunInput =\n | {\n readonly id: string\n readonly projectId: string\n readonly executionToken: string\n readonly status: \"succeeded\"\n readonly modelId?: string\n readonly finishReason?: AgentRunFinishReason\n readonly diagnostics?: readonly AgentRunDiagnostic[]\n readonly result?: SubagentRunResult\n readonly completedAt?: Date\n }\n | {\n readonly id: string\n readonly projectId: string\n readonly executionToken: string\n readonly status: \"failed\" | \"cancelled\"\n readonly modelId?: string\n readonly finishReason?: AgentRunFinishReason\n readonly diagnostics?: readonly AgentRunDiagnostic[]\n readonly error?: SixbFailure<AgentRunFailureCode>\n readonly completedAt?: Date\n }\n\nexport interface ListAgentRunsInput {\n readonly projectId: string\n readonly kinds?: readonly AgentRunKind[]\n readonly threadId?: string\n readonly parentRunId?: string\n readonly statuses?: readonly AgentRunStatus[]\n /** Effective start time; runs that never started use `createdAt`. */\n readonly startedAfter?: Date\n /** Effective start time; runs that never started use `createdAt`. */\n readonly startedBefore?: Date\n readonly limit?: number\n readonly offset?: number\n readonly order?: \"asc\" | \"desc\"\n}\n\nexport interface ListAgentRunsResult {\n readonly runs: readonly AgentRunRecord[]\n readonly hasMore: boolean\n readonly total: number\n}\n\n// ── agent_messages — one message (assistant messages inserted only once finalized) ─────────────\n\nexport type { AgentMessageRole }\n\nexport interface AgentMessageRecord {\n readonly id: string\n readonly projectId: string\n readonly threadId: string\n /** The run that produced this message; `null` for user-authored messages. */\n readonly runId: string | null\n readonly role: AgentMessageRole\n /** Principal that authored this persisted message: caller for user messages, agent identity later for assistant messages. */\n readonly authorPrincipal?: Principal\n /** Monotonic per thread, assigned by the store. */\n readonly seq: number\n /** Structured message content — text / reasoning / step boundaries / tool calls. */\n readonly parts: readonly AgentMessagePart[]\n /** Message-level metadata (mirrors `UIMessage.metadata`). */\n readonly metadata?: JsonValue\n /** Versions the `parts` shape so it can be migrated; stamped from `AGENT_MESSAGE_CONTENT_VERSION`. */\n readonly contentVersion: number\n readonly createdAt: Date\n readonly completedAt?: Date\n}\n\n/** Append a message: a {@link AgentMessage} (role + parts + metadata) plus its storage identity. */\nexport interface AppendAgentMessageInput extends AgentMessage {\n readonly id: string\n readonly projectId: string\n readonly threadId: string\n readonly runId: string | null\n readonly authorPrincipal?: Principal\n readonly createdAt?: Date\n readonly completedAt?: Date\n}\n\nexport interface DeleteAgentMessagesByRunInput {\n readonly projectId: string\n readonly threadId: string\n readonly runId: string\n}\n\nexport interface ListAgentMessagesInput {\n readonly projectId: string\n readonly threadId: string\n /** Return only messages whose per-thread sequence is greater than this retained boundary. */\n readonly afterSeq?: number\n readonly roles?: readonly AgentMessageRole[]\n readonly limit?: number\n readonly offset?: number\n readonly order?: \"asc\" | \"desc\"\n}\n\nexport interface ListAgentMessagesResult {\n readonly messages: readonly AgentMessageRecord[]\n readonly hasMore: boolean\n readonly total: number\n}\n\n// ── agent_context_checkpoints — append-only model-context boundaries ──────────────────────────\n\nexport type AgentContextCheckpointReason = \"threshold\" | \"overflow\"\n\n/**\n * A durable summary boundary used only when projecting a thread into model context.\n *\n * Checkpoints never replace or mutate transcript messages. Normal thread reads remain authoritative\n * and complete; the worker reads the latest checkpoint and only the retained message tail.\n */\nexport interface AgentContextCheckpointRecord {\n readonly id: string\n readonly projectId: string\n readonly threadId: string\n readonly createdByRunId: string\n readonly previousCheckpointId?: string\n readonly reason: AgentContextCheckpointReason\n readonly summary: string\n readonly summaryFormatVersion: 1\n readonly summarizedThroughSeq: number\n readonly observedHeadSeq: number\n readonly estimatedInputTokensBefore: number\n readonly estimatedInputTokensAfter: number\n readonly summaryModelId: string\n readonly createdAt: Date\n}\n\nexport interface CreateAgentContextCheckpointInput {\n readonly id: string\n readonly projectId: string\n readonly threadId: string\n readonly createdByRunId: string\n /** Compare-and-swap anchor. `null` means the thread must not have a prior checkpoint. */\n readonly expectedPreviousCheckpointId: string | null\n /** Compare-and-swap anchor for the complete transcript observed by the summarizer. */\n readonly expectedHeadSeq: number\n /** Current delivery token for `createdByRunId`; stale redeliveries must not write. */\n readonly executionToken: string\n readonly reason: AgentContextCheckpointReason\n readonly summary: string\n readonly summaryFormatVersion: 1\n readonly summarizedThroughSeq: number\n readonly observedHeadSeq: number\n readonly estimatedInputTokensBefore: number\n readonly estimatedInputTokensAfter: number\n readonly summaryModelId: string\n readonly createdAt?: Date\n}\n\n// ── Store ───────────────────────────────────────────────────────────────────────────────────────\n\nexport interface AgentThreadStore {\n create(input: CreateAgentThreadInput): Promise<AgentThreadRecord>\n getById(params: { projectId: string; id: string }): Promise<AgentThreadRecord | null>\n list(input: ListAgentThreadsInput): Promise<ListAgentThreadsResult>\n}\n\nexport interface AgentRunStore {\n /** Persist a queued run and atomically claim the thread's single-flight slot. */\n create(input: CreateAgentRunInput): Promise<ConversationAgentRunRecord>\n /** Persist or replay one idempotent child run while atomically enforcing parent fan-out. */\n createSubagent(input: CreateSubagentRunInput): Promise<SubagentRunRecord>\n /** Transition a queued run to running and install the first delivery's execution token. */\n start(input: StartAgentRunInput): Promise<AgentRunRecord>\n /** Finish a queued run before execution and release the thread's single-flight slot. */\n finishQueued(input: FinishQueuedAgentRunInput): Promise<AgentRunRecord>\n /** Rotate the execution token for a redelivered running job (`attempt++`). */\n reclaim(input: ReclaimAgentRunInput): Promise<AgentRunRecord>\n /**\n * Project the queue's latest confirmed ownership expiration onto the current execution.\n * Implementations must fence by token and must never move the expiration backwards.\n */\n confirmExecutionOwnership(input: ConfirmAgentRunExecutionOwnershipInput): Promise<AgentRunRecord>\n /** Finalize a run and release the thread's `activeRunId`. */\n finish(input: FinishAgentRunInput): Promise<AgentRunRecord>\n getById(params: { projectId: string; id: string }): Promise<AgentRunRecord | null>\n getByIds(params: {\n projectId: string\n ids: readonly string[]\n }): Promise<readonly AgentRunRecord[]>\n list(input: ListAgentRunsInput): Promise<ListAgentRunsResult>\n}\n\nexport interface AgentMessageStore {\n /** Insert a message (its `parts` are the canonical content) and bump thread stats. */\n append(input: AppendAgentMessageInput): Promise<AgentMessageRecord>\n /** Delete every message produced by one run and repair the thread's message stats. */\n deleteByRunId(input: DeleteAgentMessagesByRunInput): Promise<number>\n getById(params: { projectId: string; id: string }): Promise<AgentMessageRecord | null>\n list(input: ListAgentMessagesInput): Promise<ListAgentMessagesResult>\n}\n\nexport interface AgentContextCheckpointStore {\n /**\n * Append one checkpoint after atomically validating run ownership and both transcript anchors.\n * Repeating the same payload for the same creating run is idempotent.\n */\n create(input: CreateAgentContextCheckpointInput): Promise<AgentContextCheckpointRecord>\n /** Return checkpoints created by the requested runs, in first-occurrence input order. */\n getByRunIds(input: {\n readonly projectId: string\n readonly runIds: readonly string[]\n }): Promise<readonly AgentContextCheckpointRecord[]>\n getLatest(input: {\n readonly projectId: string\n readonly threadId: string\n }): Promise<AgentContextCheckpointRecord | null>\n}\n\nexport interface AgentStorage {\n readonly threads: AgentThreadStore\n readonly runs: AgentRunStore\n readonly messages: AgentMessageStore\n readonly checkpoints: AgentContextCheckpointStore\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;AA6DO,IAAM,0BAA0B;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AASO,IAAM,2BAA2B;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAQO,SAAS,0BAA0B,CACxC,OACkC;AAAA,EAClC,IAAI,UAAU,QAAQ,UAAU,WAAW;AAAA,IACzC;AAAA,EACF;AAAA,EACA,OAAQ,yBAA+C,SAAS,KAAK,IAChE,QACD;AAAA;AAIC,IAAM,6BAA6B;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;",
|
|
8
|
+
"debugId": "4012BA3E8FE1A2E864756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|