@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,1537 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
countObjects,
|
|
4
|
+
executeObjectQuery,
|
|
5
|
+
executeObjectQueryLinks,
|
|
6
|
+
existsObjects,
|
|
7
|
+
facetObjects,
|
|
8
|
+
preflightObjectQueryLinks,
|
|
9
|
+
validateObjectFacetRequests,
|
|
10
|
+
validateObjectQuery,
|
|
11
|
+
validateObjectQueryWithAdmission
|
|
12
|
+
} from "./chunk-q0k9nc5a.js";
|
|
13
|
+
import {
|
|
14
|
+
ObjectQueryValidationError
|
|
15
|
+
} from "./chunk-rte5sm3z.js";
|
|
16
|
+
import {
|
|
17
|
+
createPrimitiveExecutionRecord,
|
|
18
|
+
ensureExecutionRecord,
|
|
19
|
+
executionRecordInputFromRuntime
|
|
20
|
+
} from "./chunk-k522z7v6.js";
|
|
21
|
+
import {
|
|
22
|
+
actionRunParamsEqual,
|
|
23
|
+
actionSubjectsEqual,
|
|
24
|
+
isTerminalActionRun
|
|
25
|
+
} from "./chunk-sbzzr4kx.js";
|
|
26
|
+
import {
|
|
27
|
+
ACTION_RUN_FAILURE_CODES,
|
|
28
|
+
parseActionRunFailure
|
|
29
|
+
} from "./chunk-ka3a2ft3.js";
|
|
30
|
+
import {
|
|
31
|
+
ActionRunError
|
|
32
|
+
} from "./chunk-w1tvjszy.js";
|
|
33
|
+
import {
|
|
34
|
+
findPrimitiveParentRequestExecution
|
|
35
|
+
} from "./chunk-j1sbhm7p.js";
|
|
36
|
+
import {
|
|
37
|
+
reportRunFailure
|
|
38
|
+
} from "./chunk-jq43kdvk.js";
|
|
39
|
+
import {
|
|
40
|
+
isObjectActionDefinition,
|
|
41
|
+
normalizeActionParams,
|
|
42
|
+
resolveObjectActionSubject,
|
|
43
|
+
validateActionSubject
|
|
44
|
+
} from "./chunk-4sm0aznx.js";
|
|
45
|
+
import {
|
|
46
|
+
createLinkTokenMap,
|
|
47
|
+
createPropertyTokenMap
|
|
48
|
+
} from "./chunk-19jp6g9d.js";
|
|
49
|
+
import {
|
|
50
|
+
AuthorizationError,
|
|
51
|
+
MAX_OBJECT_READ_FACETS,
|
|
52
|
+
assertAuthorized,
|
|
53
|
+
assertObjectReadOutputWithinLimit,
|
|
54
|
+
canViewActionRun,
|
|
55
|
+
captureExecutionScope,
|
|
56
|
+
getAuthorizationRef,
|
|
57
|
+
isAllowed,
|
|
58
|
+
resolveExecutionScopeAuthorization,
|
|
59
|
+
resolveRuntimeAuthorizationForProject
|
|
60
|
+
} from "./chunk-p1x242ad.js";
|
|
61
|
+
import {
|
|
62
|
+
OntologyNotFoundError,
|
|
63
|
+
OntologyValidationError,
|
|
64
|
+
formatUnknownObjectTypeMessage
|
|
65
|
+
} from "./chunk-dktq02ne.js";
|
|
66
|
+
import {
|
|
67
|
+
createSixbError,
|
|
68
|
+
toSixbFailure
|
|
69
|
+
} from "./chunk-2xns679x.js";
|
|
70
|
+
|
|
71
|
+
// src/objects/action/errors.ts
|
|
72
|
+
class ActionValidationError extends Error {
|
|
73
|
+
name = "ActionValidationError";
|
|
74
|
+
actionId;
|
|
75
|
+
subject;
|
|
76
|
+
primaryId;
|
|
77
|
+
constructor(message, params) {
|
|
78
|
+
super(message);
|
|
79
|
+
this.actionId = params.actionId;
|
|
80
|
+
this.subject = params.subject;
|
|
81
|
+
this.primaryId = params.subject.kind === "object" ? params.subject.primaryId : undefined;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
class ActionRunFailedError extends Error {
|
|
86
|
+
name = "ActionRunFailedError";
|
|
87
|
+
runId;
|
|
88
|
+
actionId;
|
|
89
|
+
subject;
|
|
90
|
+
objectTypeId;
|
|
91
|
+
primaryId;
|
|
92
|
+
error;
|
|
93
|
+
finishedAt;
|
|
94
|
+
constructor(payload) {
|
|
95
|
+
super(payload.error.message);
|
|
96
|
+
this.runId = payload.runId;
|
|
97
|
+
this.actionId = payload.actionId;
|
|
98
|
+
this.subject = payload.subject;
|
|
99
|
+
this.objectTypeId = payload.subject.kind === "object" ? payload.subject.objectTypeId : undefined;
|
|
100
|
+
this.primaryId = payload.subject.kind === "object" ? payload.subject.primaryId : undefined;
|
|
101
|
+
this.error = payload.error;
|
|
102
|
+
this.finishedAt = payload.finishedAt;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
class ActionRunTimeoutError extends Error {
|
|
107
|
+
name = "ActionRunTimeoutError";
|
|
108
|
+
runId;
|
|
109
|
+
timeoutMs;
|
|
110
|
+
constructor(params) {
|
|
111
|
+
super(`Action run '${params.runId}' did not finish within ${params.timeoutMs}ms.`);
|
|
112
|
+
this.runId = params.runId;
|
|
113
|
+
this.timeoutMs = params.timeoutMs;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// src/objects/authorized-ontology-view.ts
|
|
118
|
+
function createAuthorizedOntologyView(input) {
|
|
119
|
+
const allObjectTypes = input.ontology.listObjectTypes();
|
|
120
|
+
const registeredObjectTypeIds = new Set(allObjectTypes.map((objectType) => objectType.id));
|
|
121
|
+
const requestedObjectTypeIds = selectedObjectTypeIds(input.selection, allObjectTypes);
|
|
122
|
+
const visibleObjectTypeIds = new Set([...requestedObjectTypeIds].filter((objectTypeId) => registeredObjectTypeIds.has(objectTypeId)));
|
|
123
|
+
const selectedSchema = input.selection.kind === "selected" ? collectSelectedSchema(input.selection.scope) : undefined;
|
|
124
|
+
const projectedObjectTypes = [];
|
|
125
|
+
for (const objectType of allObjectTypes) {
|
|
126
|
+
if (!visibleObjectTypeIds.has(objectType.id))
|
|
127
|
+
continue;
|
|
128
|
+
const propertyIds = selectedSchema?.propertyIdsByObjectType.get(objectType.id) ?? new Set(objectType.properties.map((property) => property.id));
|
|
129
|
+
const links = selectedSchema ? selectedSchema.linksBySourceType.get(objectType.id) ?? new Map : input.selection.kind === "all" ? allDeclaredLinks(objectType) : allVisibleLinks(input.ontology, objectType, visibleObjectTypeIds);
|
|
130
|
+
projectedObjectTypes.push(projectObjectType({
|
|
131
|
+
objectType,
|
|
132
|
+
propertyIds,
|
|
133
|
+
links,
|
|
134
|
+
visibleObjectTypeIds,
|
|
135
|
+
ontology: input.ontology,
|
|
136
|
+
targetMode: input.selection.kind === "all" ? "original" : input.selection.kind === "types" ? "principal" : "exact",
|
|
137
|
+
exposeContracts: input.selection.kind !== "selected"
|
|
138
|
+
}));
|
|
139
|
+
}
|
|
140
|
+
const objectTypes = projectedObjectTypes;
|
|
141
|
+
const objectTypesById = new Map(objectTypes.map((objectType) => [objectType.id, objectType]));
|
|
142
|
+
const valueTypesById = input.selection.kind === "selected" ? collectVisibleValueTypes(input.ontology.getValueTypesById(), objectTypes) : snapshotAllValueTypes(input.ontology.getValueTypesById());
|
|
143
|
+
const release = (value, budgetValue = value) => {
|
|
144
|
+
input.assertOutputWithinLimit?.(budgetValue);
|
|
145
|
+
return value;
|
|
146
|
+
};
|
|
147
|
+
const cloneObjectType = (objectType) => structuredClone(objectType);
|
|
148
|
+
const cloneValueTypes = () => new Map([...valueTypesById].map(([valueTypeId, valueType]) => [
|
|
149
|
+
valueTypeId,
|
|
150
|
+
structuredClone(valueType)
|
|
151
|
+
]));
|
|
152
|
+
return Object.freeze({
|
|
153
|
+
listObjectTypes: () => release(objectTypes.map(cloneObjectType)),
|
|
154
|
+
getObjectTypeById: (objectTypeId) => {
|
|
155
|
+
const objectType = objectTypesById.get(objectTypeId);
|
|
156
|
+
return release(objectType ? cloneObjectType(objectType) : null);
|
|
157
|
+
},
|
|
158
|
+
resolveObjectType: (objectTypeId) => {
|
|
159
|
+
const objectType = objectTypesById.get(objectTypeId);
|
|
160
|
+
return objectType ? release(cloneObjectType(objectType)) : unknownObjectType(objectTypeId);
|
|
161
|
+
},
|
|
162
|
+
getValueTypesById: () => {
|
|
163
|
+
const valueTypes = cloneValueTypes();
|
|
164
|
+
return release(valueTypes, [...valueTypes.entries()]);
|
|
165
|
+
},
|
|
166
|
+
getPrimaryPropertyId: (objectTypeId) => {
|
|
167
|
+
const objectType = objectTypesById.get(objectTypeId);
|
|
168
|
+
if (!objectType)
|
|
169
|
+
return unknownObjectType(objectTypeId);
|
|
170
|
+
const primary = objectType.properties.find((property) => property.primary);
|
|
171
|
+
if (!primary) {
|
|
172
|
+
throw new OntologyValidationError(`[Sixb] Object type '${objectTypeId}' does not expose its primary property in this execution scope.`);
|
|
173
|
+
}
|
|
174
|
+
return release(primary.id);
|
|
175
|
+
},
|
|
176
|
+
listSubTypes: (objectTypeId) => {
|
|
177
|
+
const subTypes = visibleObjectTypeIds.has(objectTypeId) ? input.ontology.listSubTypes(objectTypeId).filter((subTypeId) => visibleObjectTypeIds.has(subTypeId)) : [];
|
|
178
|
+
return release(subTypes);
|
|
179
|
+
},
|
|
180
|
+
isValidLinkTarget: (expected, actual) => {
|
|
181
|
+
if (input.selection.kind === "all") {
|
|
182
|
+
return release(input.ontology.isValidLinkTarget(expected, actual));
|
|
183
|
+
}
|
|
184
|
+
if (!visibleObjectTypeIds.has(actual))
|
|
185
|
+
return release(false);
|
|
186
|
+
const expectedTypes = Array.isArray(expected) ? expected : [expected];
|
|
187
|
+
if (input.selection.kind === "selected") {
|
|
188
|
+
return release(expectedTypes.some((expectedType) => expectedType === "*" || expectedType === actual));
|
|
189
|
+
}
|
|
190
|
+
return release(expectedTypes.some((expectedType) => expectedType === "*" || visibleObjectTypeIds.has(expectedType) && input.ontology.isValidLinkTarget(expectedType, actual)));
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
function selectedObjectTypeIds(selection, allObjectTypes) {
|
|
195
|
+
switch (selection.kind) {
|
|
196
|
+
case "all":
|
|
197
|
+
return new Set(allObjectTypes.map((objectType) => objectType.id));
|
|
198
|
+
case "types":
|
|
199
|
+
return new Set(selection.objectTypeIds);
|
|
200
|
+
case "selected":
|
|
201
|
+
return new Set(selection.scope.objects.map((object) => object.objectTypeId));
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
function collectSelectedSchema(scope) {
|
|
205
|
+
const propertyIdsByObjectType = new Map;
|
|
206
|
+
for (const object of scope.objects) {
|
|
207
|
+
const properties = propertyIdsByObjectType.get(object.objectTypeId) ?? new Set;
|
|
208
|
+
for (const propertyId of object.propertyIds)
|
|
209
|
+
properties.add(propertyId);
|
|
210
|
+
propertyIdsByObjectType.set(object.objectTypeId, properties);
|
|
211
|
+
}
|
|
212
|
+
const linksBySourceType = new Map;
|
|
213
|
+
for (const step of scope.steps) {
|
|
214
|
+
const links = linksBySourceType.get(step.sourceObjectTypeId) ?? new Map;
|
|
215
|
+
const selected = links.get(step.linkId) ?? {
|
|
216
|
+
targetObjectTypeIds: new Set,
|
|
217
|
+
propertyIds: new Set
|
|
218
|
+
};
|
|
219
|
+
selected.targetObjectTypeIds.add(step.targetObjectTypeId);
|
|
220
|
+
for (const propertyId of step.propertyIds)
|
|
221
|
+
selected.propertyIds.add(propertyId);
|
|
222
|
+
links.set(step.linkId, selected);
|
|
223
|
+
linksBySourceType.set(step.sourceObjectTypeId, links);
|
|
224
|
+
}
|
|
225
|
+
return { propertyIdsByObjectType, linksBySourceType };
|
|
226
|
+
}
|
|
227
|
+
function allDeclaredLinks(objectType) {
|
|
228
|
+
return new Map(objectType.links.map((link) => [
|
|
229
|
+
link.id,
|
|
230
|
+
{
|
|
231
|
+
targetObjectTypeIds: new Set(typeof link.targetObjectTypeId === "string" ? [link.targetObjectTypeId] : link.targetObjectTypeId),
|
|
232
|
+
propertyIds: new Set(link.properties?.map((property) => property.id) ?? [])
|
|
233
|
+
}
|
|
234
|
+
]));
|
|
235
|
+
}
|
|
236
|
+
function allVisibleLinks(ontology, objectType, visibleObjectTypeIds) {
|
|
237
|
+
const links = new Map;
|
|
238
|
+
for (const link of objectType.links) {
|
|
239
|
+
const targetObjectTypeIds = new Set([...visibleObjectTypeIds].filter((targetObjectTypeId) => ontology.isValidLinkTarget(link.targetObjectTypeId, targetObjectTypeId)));
|
|
240
|
+
if (targetObjectTypeIds.size === 0)
|
|
241
|
+
continue;
|
|
242
|
+
links.set(link.id, {
|
|
243
|
+
targetObjectTypeIds,
|
|
244
|
+
propertyIds: new Set(link.properties?.map((property) => property.id) ?? [])
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
return links;
|
|
248
|
+
}
|
|
249
|
+
function projectObjectType(input) {
|
|
250
|
+
const properties = input.objectType.properties.filter((property) => input.propertyIds.has(property.id)).map(snapshotProperty);
|
|
251
|
+
const visiblePropertyIds = new Set(properties.map((property) => property.id));
|
|
252
|
+
const links = input.objectType.links.flatMap((link) => {
|
|
253
|
+
const selected = input.links.get(link.id);
|
|
254
|
+
if (!selected)
|
|
255
|
+
return [];
|
|
256
|
+
if (input.targetMode === "original") {
|
|
257
|
+
return [snapshotLink(link, snapshotLinkTarget(link.targetObjectTypeId), selected.propertyIds)];
|
|
258
|
+
}
|
|
259
|
+
const targetObjectTypeIds = new Set([...selected.targetObjectTypeIds].filter((targetObjectTypeId) => input.visibleObjectTypeIds.has(targetObjectTypeId) && input.ontology.isValidLinkTarget(link.targetObjectTypeId, targetObjectTypeId)));
|
|
260
|
+
if (targetObjectTypeIds.size === 0)
|
|
261
|
+
return [];
|
|
262
|
+
const target = input.targetMode === "principal" ? principalLinkTargets(link, targetObjectTypeIds, input.visibleObjectTypeIds) : exactLinkTargets(targetObjectTypeIds);
|
|
263
|
+
return [snapshotLink(link, target, selected.propertyIds, { omitEmptyProperties: true })];
|
|
264
|
+
});
|
|
265
|
+
const projected = {
|
|
266
|
+
id: input.objectType.id,
|
|
267
|
+
name: input.objectType.name,
|
|
268
|
+
description: input.objectType.description,
|
|
269
|
+
quantityKind: input.objectType.quantityKind,
|
|
270
|
+
seeAlso: input.objectType.seeAlso ? [...input.objectType.seeAlso] : undefined,
|
|
271
|
+
extends: input.objectType.extends && input.visibleObjectTypeIds.has(input.objectType.extends) ? input.objectType.extends : undefined,
|
|
272
|
+
parents: projectOptionalIds(input.objectType.parents, input.visibleObjectTypeIds, input.targetMode === "original"),
|
|
273
|
+
implements: input.exposeContracts && input.objectType.implements ? [...input.objectType.implements] : undefined,
|
|
274
|
+
properties,
|
|
275
|
+
links,
|
|
276
|
+
search: projectSearch(input.objectType.search, visiblePropertyIds, {
|
|
277
|
+
preserveEmpty: input.targetMode !== "exact"
|
|
278
|
+
})
|
|
279
|
+
};
|
|
280
|
+
const withTokens = {
|
|
281
|
+
...projected,
|
|
282
|
+
p: createPropertyTokenMap(projected),
|
|
283
|
+
l: createLinkTokenMap(projected)
|
|
284
|
+
};
|
|
285
|
+
return deepFreeze(withTokens);
|
|
286
|
+
}
|
|
287
|
+
function principalLinkTargets(link, allowedTargetObjectTypeIds, visibleObjectTypeIds) {
|
|
288
|
+
if (link.targetObjectTypeId === "*")
|
|
289
|
+
return exactLinkTargets(allowedTargetObjectTypeIds);
|
|
290
|
+
const declared = Array.isArray(link.targetObjectTypeId) ? link.targetObjectTypeId : [link.targetObjectTypeId];
|
|
291
|
+
if (declared.every((objectTypeId) => visibleObjectTypeIds.has(objectTypeId))) {
|
|
292
|
+
return snapshotLinkTarget(link.targetObjectTypeId);
|
|
293
|
+
}
|
|
294
|
+
return exactLinkTargets(allowedTargetObjectTypeIds);
|
|
295
|
+
}
|
|
296
|
+
function exactLinkTargets(targetObjectTypeIds) {
|
|
297
|
+
const targets = [...targetObjectTypeIds].sort();
|
|
298
|
+
return targets.length === 1 ? targets[0] : targets;
|
|
299
|
+
}
|
|
300
|
+
function projectOptionalIds(ids, visibleObjectTypeIds, preserveOriginal) {
|
|
301
|
+
if (!ids)
|
|
302
|
+
return;
|
|
303
|
+
if (preserveOriginal)
|
|
304
|
+
return [...ids];
|
|
305
|
+
const visible = ids.filter((id) => visibleObjectTypeIds.has(id));
|
|
306
|
+
return visible.length > 0 ? visible : undefined;
|
|
307
|
+
}
|
|
308
|
+
function snapshotLink(link, targetObjectTypeId, propertyIds, options = {}) {
|
|
309
|
+
const properties = link.properties?.filter((property) => propertyIds.has(property.id)).map(snapshotProperty);
|
|
310
|
+
return {
|
|
311
|
+
id: link.id,
|
|
312
|
+
name: link.name,
|
|
313
|
+
description: link.description,
|
|
314
|
+
targetObjectTypeId,
|
|
315
|
+
cardinality: link.cardinality,
|
|
316
|
+
properties: options.omitEmptyProperties && properties?.length === 0 ? undefined : properties
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
function snapshotLinkTarget(target) {
|
|
320
|
+
return typeof target === "string" ? target : [...target];
|
|
321
|
+
}
|
|
322
|
+
function snapshotProperty(property) {
|
|
323
|
+
return {
|
|
324
|
+
id: property.id,
|
|
325
|
+
name: property.name,
|
|
326
|
+
schema: snapshotSchema(property.schema),
|
|
327
|
+
description: property.description,
|
|
328
|
+
required: property.required,
|
|
329
|
+
nullable: property.nullable,
|
|
330
|
+
primary: property.primary,
|
|
331
|
+
mode: property.mode,
|
|
332
|
+
semanticType: property.semanticType,
|
|
333
|
+
query: snapshotPropertyQuery(property.query)
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
function snapshotPropertyQuery(query) {
|
|
337
|
+
if (!query)
|
|
338
|
+
return;
|
|
339
|
+
return {
|
|
340
|
+
searchable: query.searchable,
|
|
341
|
+
filterable: query.filterable,
|
|
342
|
+
sortable: query.sortable,
|
|
343
|
+
text: query.text,
|
|
344
|
+
exact: query.exact,
|
|
345
|
+
facet: query.facet,
|
|
346
|
+
vector: query.vector,
|
|
347
|
+
weight: query.weight
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
function projectSearch(search, visiblePropertyIds, options) {
|
|
351
|
+
if (!search)
|
|
352
|
+
return;
|
|
353
|
+
const title = search.title && visiblePropertyIds.has(search.title) ? search.title : undefined;
|
|
354
|
+
const selectedDefaultText = search.defaultText?.filter((propertyId) => visiblePropertyIds.has(propertyId));
|
|
355
|
+
const selectedExact = search.exact?.filter((propertyId) => visiblePropertyIds.has(propertyId));
|
|
356
|
+
const defaultText = options.preserveEmpty || selectedDefaultText?.length ? selectedDefaultText : undefined;
|
|
357
|
+
const exact = options.preserveEmpty || selectedExact?.length ? selectedExact : undefined;
|
|
358
|
+
const vector = search.vector && visiblePropertyIds.has(search.vector.property) && search.vector.source.every((propertyId) => visiblePropertyIds.has(propertyId)) ? { property: search.vector.property, source: [...search.vector.source] } : undefined;
|
|
359
|
+
const projected = {
|
|
360
|
+
...title === undefined ? {} : { title },
|
|
361
|
+
...defaultText === undefined ? {} : { defaultText },
|
|
362
|
+
...exact === undefined ? {} : { exact },
|
|
363
|
+
...vector === undefined ? {} : { vector }
|
|
364
|
+
};
|
|
365
|
+
return Object.keys(projected).length > 0 || options.preserveEmpty ? projected : undefined;
|
|
366
|
+
}
|
|
367
|
+
function snapshotAllValueTypes(registered) {
|
|
368
|
+
return new Map([...registered.values()].map((valueType) => {
|
|
369
|
+
const snapshot = snapshotValueType(valueType);
|
|
370
|
+
return [snapshot.id, snapshot];
|
|
371
|
+
}));
|
|
372
|
+
}
|
|
373
|
+
function collectVisibleValueTypes(registered, objectTypes) {
|
|
374
|
+
const referencedIds = new Set;
|
|
375
|
+
const pendingSchemas = [];
|
|
376
|
+
const visitedSchemas = new Set;
|
|
377
|
+
for (const objectType of objectTypes) {
|
|
378
|
+
for (const property of objectType.properties)
|
|
379
|
+
pendingSchemas.push(property.schema);
|
|
380
|
+
for (const link of objectType.links) {
|
|
381
|
+
for (const property of link.properties ?? [])
|
|
382
|
+
pendingSchemas.push(property.schema);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
while (pendingSchemas.length > 0) {
|
|
386
|
+
const schema = pendingSchemas.pop();
|
|
387
|
+
if (typeof schema === "string" || visitedSchemas.has(schema))
|
|
388
|
+
continue;
|
|
389
|
+
visitedSchemas.add(schema);
|
|
390
|
+
if (schema.type === "valueTypeRef") {
|
|
391
|
+
if (!referencedIds.has(schema.valueTypeId)) {
|
|
392
|
+
referencedIds.add(schema.valueTypeId);
|
|
393
|
+
const valueType = registered.get(schema.valueTypeId);
|
|
394
|
+
if (valueType)
|
|
395
|
+
pendingSchemas.push(valueType.schema);
|
|
396
|
+
}
|
|
397
|
+
if (schema._resolved)
|
|
398
|
+
pendingSchemas.push(schema._resolved);
|
|
399
|
+
} else if (schema.type === "object") {
|
|
400
|
+
for (const field of Object.values(schema.properties))
|
|
401
|
+
pendingSchemas.push(field.schema);
|
|
402
|
+
} else if (schema.type === "array") {
|
|
403
|
+
pendingSchemas.push(schema.items);
|
|
404
|
+
} else if (schema.type === "map") {
|
|
405
|
+
pendingSchemas.push(schema.valueSchema);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
return new Map([...referencedIds].map((valueTypeId) => registered.get(valueTypeId)).filter((valueType) => valueType !== undefined).map((valueType) => {
|
|
409
|
+
const snapshot = snapshotValueType(valueType);
|
|
410
|
+
return [snapshot.id, snapshot];
|
|
411
|
+
}));
|
|
412
|
+
}
|
|
413
|
+
function snapshotValueType(valueType) {
|
|
414
|
+
return deepFreeze({
|
|
415
|
+
id: valueType.id,
|
|
416
|
+
name: valueType.name,
|
|
417
|
+
description: valueType.description,
|
|
418
|
+
schema: snapshotSchema(valueType.schema),
|
|
419
|
+
semanticType: valueType.semanticType
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
function snapshotSchema(schema) {
|
|
423
|
+
return deepFreeze(structuredClone(schema));
|
|
424
|
+
}
|
|
425
|
+
function deepFreeze(value, seen = new Set) {
|
|
426
|
+
if (typeof value !== "object" || value === null || seen.has(value))
|
|
427
|
+
return value;
|
|
428
|
+
seen.add(value);
|
|
429
|
+
for (const key of Reflect.ownKeys(value)) {
|
|
430
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
431
|
+
if (descriptor && "value" in descriptor)
|
|
432
|
+
deepFreeze(descriptor.value, seen);
|
|
433
|
+
}
|
|
434
|
+
return Object.freeze(value);
|
|
435
|
+
}
|
|
436
|
+
function unknownObjectType(objectTypeId) {
|
|
437
|
+
throw new OntologyNotFoundError(formatUnknownObjectTypeMessage(objectTypeId));
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// src/objects/query/selected-read-admission.ts
|
|
441
|
+
var selectedStateBrand = Symbol("sixb.selected-object-query-admission-state");
|
|
442
|
+
function createSelectedObjectQueryAdmission(scope) {
|
|
443
|
+
const selectionByKey = new Map;
|
|
444
|
+
const selectionsByType = new Map;
|
|
445
|
+
const propertiesBySelection = new Map;
|
|
446
|
+
for (const selection of scope.objects) {
|
|
447
|
+
const key = selectionKey(selection.nodeId, selection.objectTypeId);
|
|
448
|
+
selectionByKey.set(key, selection);
|
|
449
|
+
propertiesBySelection.set(key, new Set(selection.propertyIds));
|
|
450
|
+
const byType = selectionsByType.get(selection.objectTypeId) ?? [];
|
|
451
|
+
byType.push(selection);
|
|
452
|
+
selectionsByType.set(selection.objectTypeId, byType);
|
|
453
|
+
}
|
|
454
|
+
const outgoing = indexSteps(scope.steps, "outgoing", selectionByKey);
|
|
455
|
+
const incoming = indexSteps(scope.steps, "incoming", selectionByKey);
|
|
456
|
+
const emptyState = selectedState([]);
|
|
457
|
+
const admission = {
|
|
458
|
+
empty: () => emptyState,
|
|
459
|
+
source: (input) => {
|
|
460
|
+
const selections = input.result.objectTypeIds.flatMap((objectTypeId2) => selectionsByType.get(objectTypeId2) ?? []);
|
|
461
|
+
const state = selectedState(selections);
|
|
462
|
+
if (input.kind === "refs") {
|
|
463
|
+
const missingType = [...new Set(input.refs?.map((ref) => ref.objectTypeId) ?? [])].sort().find((objectTypeId2) => !selectionsByType.has(objectTypeId2));
|
|
464
|
+
if (missingType) {
|
|
465
|
+
return denied(state, new AuthorizationError(`view:object:${missingType}`, `[Sixb] Delegated query cannot reference object type '${missingType}' at '${input.path}': the selected object scope does not contain that type.`));
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
if (state.selections.length > 0)
|
|
469
|
+
return { state };
|
|
470
|
+
const objectTypeId = input.objectTypeId ?? input.result.objectTypeIds[0] ?? "unknown";
|
|
471
|
+
return denied(state, new AuthorizationError(`view:object:${objectTypeId}`, `[Sixb] Delegated query cannot start from object type '${objectTypeId}' at '${input.path}': the selected object scope does not contain that type.`));
|
|
472
|
+
},
|
|
473
|
+
property: (input) => propertyDenial(asSelectedState(input.state), input.propertyId, input.objectTypeId, input.use, input.path, propertiesBySelection),
|
|
474
|
+
edge: (input) => {
|
|
475
|
+
const state = asSelectedState(input.state);
|
|
476
|
+
const next = followEdge(state, input.linkId, input.direction, input.sourceObjectTypeId, outgoing, incoming, input.result.objectTypeIds);
|
|
477
|
+
if (next.selections.length > 0 || state.selections.length === 0)
|
|
478
|
+
return { state: next };
|
|
479
|
+
return denied(next, edgeDenial(state, input.linkId, input.direction, input.sourceObjectTypeId, input.use, input.path));
|
|
480
|
+
},
|
|
481
|
+
set: ({ op, states }) => {
|
|
482
|
+
if (op === "subtract")
|
|
483
|
+
return asSelectedState(states[0] ?? emptyState);
|
|
484
|
+
return selectedState(states.flatMap((state) => asSelectedState(state).selections));
|
|
485
|
+
},
|
|
486
|
+
assertPropertySelected: (input) => {
|
|
487
|
+
const denial = propertyDenial(asSelectedState(input.state), input.propertyId, input.objectTypeId, input.use, input.path, propertiesBySelection);
|
|
488
|
+
if (denial)
|
|
489
|
+
throw denial;
|
|
490
|
+
},
|
|
491
|
+
assertIncidentEdgeSelected: (input) => {
|
|
492
|
+
if (input.linkId === undefined)
|
|
493
|
+
return;
|
|
494
|
+
const state = asSelectedState(input.state);
|
|
495
|
+
const directions = input.direction === "both" ? ["outgoing", "incoming"] : [input.direction];
|
|
496
|
+
const next = selectedState(directions.flatMap((direction) => followEdge(state, input.linkId, direction, undefined, outgoing, incoming).selections));
|
|
497
|
+
if (next.selections.length > 0 || state.selections.length === 0)
|
|
498
|
+
return;
|
|
499
|
+
throw edgeDenial(state, input.linkId, input.direction, undefined, "queryLinks", input.path);
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
return Object.freeze(admission);
|
|
503
|
+
}
|
|
504
|
+
function indexSteps(steps, direction, selectionByKey) {
|
|
505
|
+
const index = new Map;
|
|
506
|
+
for (const step of steps) {
|
|
507
|
+
const fromKey = direction === "outgoing" ? selectionKey(step.parentNodeId, step.sourceObjectTypeId) : selectionKey(step.nodeId, step.targetObjectTypeId);
|
|
508
|
+
const toKey = direction === "outgoing" ? selectionKey(step.nodeId, step.targetObjectTypeId) : selectionKey(step.parentNodeId, step.sourceObjectTypeId);
|
|
509
|
+
const target = selectionByKey.get(toKey);
|
|
510
|
+
if (!selectionByKey.has(fromKey) || !target) {
|
|
511
|
+
throw new Error("[Sixb] Compiled selected object scope contains an invalid query path step.");
|
|
512
|
+
}
|
|
513
|
+
const key = edgeKey(direction === "outgoing" ? step.parentNodeId : step.nodeId, direction === "outgoing" ? step.sourceObjectTypeId : step.targetObjectTypeId, step.linkId);
|
|
514
|
+
const targets = index.get(key) ?? [];
|
|
515
|
+
targets.push(target);
|
|
516
|
+
index.set(key, targets);
|
|
517
|
+
}
|
|
518
|
+
return index;
|
|
519
|
+
}
|
|
520
|
+
function followEdge(state, linkId, direction, sourceObjectTypeId, outgoing, incoming, resultObjectTypeIds) {
|
|
521
|
+
const index = direction === "outgoing" ? outgoing : incoming;
|
|
522
|
+
const resultTypes = resultObjectTypeIds ? new Set(resultObjectTypeIds) : undefined;
|
|
523
|
+
const selections = state.selections.flatMap((selection) => {
|
|
524
|
+
const candidates = index.get(edgeKey(selection.nodeId, selection.objectTypeId, linkId)) ?? [];
|
|
525
|
+
return candidates.filter((candidate) => (resultTypes === undefined || resultTypes.has(candidate.objectTypeId)) && (direction === "outgoing" || sourceObjectTypeId === undefined || candidate.objectTypeId === sourceObjectTypeId));
|
|
526
|
+
});
|
|
527
|
+
return selectedState(selections);
|
|
528
|
+
}
|
|
529
|
+
function propertyDenial(state, propertyId, objectTypeId, use, path, propertiesBySelection) {
|
|
530
|
+
const candidates = objectTypeId ? state.selections.filter((selection) => selection.objectTypeId === objectTypeId) : state.selections;
|
|
531
|
+
if (candidates.length === 0)
|
|
532
|
+
return;
|
|
533
|
+
const missing = candidates.find((selection) => !propertiesBySelection.get(selectionKey(selection.nodeId, selection.objectTypeId))?.has(propertyId));
|
|
534
|
+
if (!missing)
|
|
535
|
+
return;
|
|
536
|
+
const objectTypeIds = [...new Set(candidates.map((selection) => selection.objectTypeId))].sort();
|
|
537
|
+
return new AuthorizationError(`view:object:${objectTypeIds.join(",")}:property:${propertyId}`, `[Sixb] Delegated query cannot use property '${propertyId}' for ${use} at '${path}': it is not selected on every matching read-scope path (missing on ${formatSelection(missing)}).`);
|
|
538
|
+
}
|
|
539
|
+
function edgeDenial(state, linkId, direction, sourceObjectTypeId, use, path) {
|
|
540
|
+
const source = sourceObjectTypeId ? `:${sourceObjectTypeId}` : "";
|
|
541
|
+
return new AuthorizationError(`view:link:${direction}${source}:${linkId}`, `[Sixb] Delegated query cannot use ${direction} link '${linkId}' for ${use} from ${formatState(state)} at '${path}': that exact read-scope path is not selected.`);
|
|
542
|
+
}
|
|
543
|
+
function formatState(state) {
|
|
544
|
+
if (state.selections.length === 0)
|
|
545
|
+
return "an empty read-scope provenance";
|
|
546
|
+
return `read-scope provenance ${state.selections.map(formatSelection).join(", ")}`;
|
|
547
|
+
}
|
|
548
|
+
function formatSelection(selection) {
|
|
549
|
+
return `'${selection.objectTypeId}'@node ${selection.nodeId}`;
|
|
550
|
+
}
|
|
551
|
+
function selectedState(selections) {
|
|
552
|
+
const unique = new Map;
|
|
553
|
+
for (const selection of selections) {
|
|
554
|
+
unique.set(selectionKey(selection.nodeId, selection.objectTypeId), selection);
|
|
555
|
+
}
|
|
556
|
+
return Object.freeze({
|
|
557
|
+
[selectedStateBrand]: true,
|
|
558
|
+
selections: Object.freeze([...unique.values()].sort((left, right) => left.nodeId - right.nodeId || left.objectTypeId.localeCompare(right.objectTypeId)))
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
function asSelectedState(state) {
|
|
562
|
+
if (state[selectedStateBrand] !== true) {
|
|
563
|
+
throw new Error("[Sixb] Object query admission state belongs to another semantic admission.");
|
|
564
|
+
}
|
|
565
|
+
return state;
|
|
566
|
+
}
|
|
567
|
+
function denied(state, denial) {
|
|
568
|
+
return { state, denial };
|
|
569
|
+
}
|
|
570
|
+
function selectionKey(nodeId, objectTypeId) {
|
|
571
|
+
return JSON.stringify([nodeId, objectTypeId]);
|
|
572
|
+
}
|
|
573
|
+
function edgeKey(nodeId, objectTypeId, linkId) {
|
|
574
|
+
return JSON.stringify([nodeId, objectTypeId, linkId]);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
// src/objects/telemetry/workload.ts
|
|
578
|
+
var MAX_DELEGATED_TELEMETRY_HISTORY_SERIES = 100;
|
|
579
|
+
var MAX_DELEGATED_TELEMETRY_HISTORY_POINTS = 1e4;
|
|
580
|
+
var DEFAULT_DELEGATED_TELEMETRY_HISTORY_LIMIT_PER_SERIES = 100;
|
|
581
|
+
|
|
582
|
+
class TelemetryHistoryWorkloadExceededError extends Error {
|
|
583
|
+
metric;
|
|
584
|
+
limit;
|
|
585
|
+
name = "TelemetryHistoryWorkloadExceededError";
|
|
586
|
+
code = "telemetry_history_workload_exceeded";
|
|
587
|
+
constructor(metric, limit) {
|
|
588
|
+
super(`[Sixb] Delegated telemetry history exceeded its ${metric} limit (${limit}).`);
|
|
589
|
+
this.metric = metric;
|
|
590
|
+
this.limit = limit;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
function admitTelemetryHistoryReadWorkload(input, delegated) {
|
|
594
|
+
const seriesCount = input.seriesCount;
|
|
595
|
+
const limitPerSeries = input.limitPerSeries;
|
|
596
|
+
if (!Number.isSafeInteger(seriesCount) || seriesCount < 0) {
|
|
597
|
+
throw new Error("[Sixb] Telemetry history series must have a non-negative safe integer length.");
|
|
598
|
+
}
|
|
599
|
+
if (limitPerSeries !== undefined && (!Number.isSafeInteger(limitPerSeries) || limitPerSeries < 0)) {
|
|
600
|
+
throw new Error("[Sixb] Telemetry history limit must be a non-negative safe integer.");
|
|
601
|
+
}
|
|
602
|
+
if (!delegated) {
|
|
603
|
+
const admission = limitPerSeries === undefined ? {} : { limitPerSeries };
|
|
604
|
+
return Object.freeze(admission);
|
|
605
|
+
}
|
|
606
|
+
if (seriesCount > MAX_DELEGATED_TELEMETRY_HISTORY_SERIES) {
|
|
607
|
+
throw new TelemetryHistoryWorkloadExceededError("series", MAX_DELEGATED_TELEMETRY_HISTORY_SERIES);
|
|
608
|
+
}
|
|
609
|
+
if (seriesCount === 0) {
|
|
610
|
+
return Object.freeze({
|
|
611
|
+
...limitPerSeries === undefined ? {} : { limitPerSeries },
|
|
612
|
+
maxPointOccurrences: MAX_DELEGATED_TELEMETRY_HISTORY_POINTS
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
const maxLimitPerSeries = Math.floor(MAX_DELEGATED_TELEMETRY_HISTORY_POINTS / seriesCount);
|
|
616
|
+
const effectiveLimitPerSeries = limitPerSeries ?? Math.min(DEFAULT_DELEGATED_TELEMETRY_HISTORY_LIMIT_PER_SERIES, maxLimitPerSeries);
|
|
617
|
+
if (effectiveLimitPerSeries > maxLimitPerSeries) {
|
|
618
|
+
throw new TelemetryHistoryWorkloadExceededError("points", MAX_DELEGATED_TELEMETRY_HISTORY_POINTS);
|
|
619
|
+
}
|
|
620
|
+
return Object.freeze({
|
|
621
|
+
limitPerSeries: effectiveLimitPerSeries,
|
|
622
|
+
maxPointOccurrences: MAX_DELEGATED_TELEMETRY_HISTORY_POINTS
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
// src/execution/authorized-object-reader.ts
|
|
627
|
+
var readerConstructionKey = Object.freeze({});
|
|
628
|
+
|
|
629
|
+
class AuthorizedObjectReaderImpl {
|
|
630
|
+
#authorization;
|
|
631
|
+
#authority;
|
|
632
|
+
#runtime;
|
|
633
|
+
#ontology;
|
|
634
|
+
#ontologyView;
|
|
635
|
+
#storage;
|
|
636
|
+
#delegatedObjectTypeIds;
|
|
637
|
+
#delegatedLinkDefinitions;
|
|
638
|
+
#delegatedQueryAdmission;
|
|
639
|
+
constructor(key, input) {
|
|
640
|
+
if (key !== readerConstructionKey) {
|
|
641
|
+
throw new Error("[Sixb] AuthorizedObjectReader can only be created by Core.");
|
|
642
|
+
}
|
|
643
|
+
this.#authorization = input.scope.authorization;
|
|
644
|
+
this.#authority = input.authority;
|
|
645
|
+
this.#ontology = input.ontology;
|
|
646
|
+
this.#storage = input.storage;
|
|
647
|
+
this.#delegatedObjectTypeIds = input.authority.type === "delegated" ? new Set(input.authority.objectRead.scope.objects.map((object) => object.objectTypeId)) : undefined;
|
|
648
|
+
this.#delegatedLinkDefinitions = input.authority.type === "delegated" ? new Set(input.authority.objectRead.scope.steps.map(delegatedLinkDefinitionKey)) : undefined;
|
|
649
|
+
this.#delegatedQueryAdmission = input.authority.type === "delegated" ? createSelectedObjectQueryAdmission(input.authority.objectRead.scope) : undefined;
|
|
650
|
+
this.#runtime = Object.freeze({
|
|
651
|
+
projectId: input.scope.execution.projectId,
|
|
652
|
+
runtimeAuthorization: input.scope.authorization,
|
|
653
|
+
...input.authority.type === "principal" ? { authorization: input.authority.context } : {}
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
static assertBound(reader, scope) {
|
|
657
|
+
const capturedScope = captureExecutionScope(scope);
|
|
658
|
+
resolveExecutionScopeAuthorization(reader.#runtime.projectId, capturedScope);
|
|
659
|
+
if (capturedScope.authorization !== reader.#authorization) {
|
|
660
|
+
throw new Error("[Sixb] AuthorizedObjectReader is not bound to this exact execution authority.");
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
static ontologyView(reader) {
|
|
664
|
+
const authority = reader.#authority;
|
|
665
|
+
reader.#ontologyView ??= createAuthorizedOntologyView({
|
|
666
|
+
ontology: reader.#ontology,
|
|
667
|
+
selection: ontologySelectionForAuthority(authority, reader.#ontology),
|
|
668
|
+
...authority.type === "delegated" ? {
|
|
669
|
+
assertOutputWithinLimit: (value) => assertObjectReadOutputWithinLimit(value, authority.objectRead.limits)
|
|
670
|
+
} : {}
|
|
671
|
+
});
|
|
672
|
+
return reader.#ontologyView;
|
|
673
|
+
}
|
|
674
|
+
get projectId() {
|
|
675
|
+
return this.#runtime.projectId;
|
|
676
|
+
}
|
|
677
|
+
async getByPrimaryId(input) {
|
|
678
|
+
const request = snapshotReadValue({
|
|
679
|
+
objectTypeId: input.objectTypeId,
|
|
680
|
+
primaryId: input.primaryId
|
|
681
|
+
});
|
|
682
|
+
this.#assertObjectTypesViewable([request.objectTypeId]);
|
|
683
|
+
return detachReadResult(await this.#storage.getByPrimaryId({
|
|
684
|
+
...request,
|
|
685
|
+
projectId: this.#runtime.projectId
|
|
686
|
+
}));
|
|
687
|
+
}
|
|
688
|
+
async getByPrimaryIdBatch(input) {
|
|
689
|
+
const request = snapshotReadValue({
|
|
690
|
+
items: input.items.map((item) => ({
|
|
691
|
+
objectTypeId: item.objectTypeId,
|
|
692
|
+
primaryId: item.primaryId
|
|
693
|
+
}))
|
|
694
|
+
});
|
|
695
|
+
this.#assertObjectTypesViewable(request.items.map((item) => item.objectTypeId));
|
|
696
|
+
return detachReadResult(await this.#storage.getByPrimaryIdBatch({
|
|
697
|
+
...request,
|
|
698
|
+
projectId: this.#runtime.projectId
|
|
699
|
+
}));
|
|
700
|
+
}
|
|
701
|
+
async canReadObjectProperty(input) {
|
|
702
|
+
const request = snapshotReadValue({
|
|
703
|
+
objectTypeId: input.objectTypeId,
|
|
704
|
+
primaryId: input.primaryId,
|
|
705
|
+
propertyId: input.propertyId
|
|
706
|
+
});
|
|
707
|
+
this.#assertObjectTypesViewable([request.objectTypeId]);
|
|
708
|
+
if (this.#authority.type !== "delegated")
|
|
709
|
+
return true;
|
|
710
|
+
const [readable] = await this.#storage.selectsObjectProperties({
|
|
711
|
+
projectId: this.#runtime.projectId,
|
|
712
|
+
items: [request]
|
|
713
|
+
});
|
|
714
|
+
return readable ?? false;
|
|
715
|
+
}
|
|
716
|
+
async canReadObjectPropertiesBatch(input) {
|
|
717
|
+
const request = snapshotReadValue({
|
|
718
|
+
items: input.items.map((item) => ({
|
|
719
|
+
objectTypeId: item.objectTypeId,
|
|
720
|
+
primaryId: item.primaryId,
|
|
721
|
+
propertyId: item.propertyId
|
|
722
|
+
}))
|
|
723
|
+
});
|
|
724
|
+
this.#assertObjectTypesViewable(request.items.map((item) => item.objectTypeId));
|
|
725
|
+
if (this.#authority.type !== "delegated")
|
|
726
|
+
return request.items.map(() => true);
|
|
727
|
+
return detachReadResult(await this.#storage.selectsObjectProperties({
|
|
728
|
+
...request,
|
|
729
|
+
projectId: this.#runtime.projectId
|
|
730
|
+
}));
|
|
731
|
+
}
|
|
732
|
+
async list(input) {
|
|
733
|
+
const request = snapshotReadValue({
|
|
734
|
+
objectTypeId: typeof input.objectTypeId === "string" ? input.objectTypeId : input.objectTypeId === undefined ? undefined : [...input.objectTypeId],
|
|
735
|
+
primaryIdPrefix: input.primaryIdPrefix,
|
|
736
|
+
primaryIdSuffix: input.primaryIdSuffix,
|
|
737
|
+
updatedAfter: input.updatedAfter,
|
|
738
|
+
updatedBefore: input.updatedBefore,
|
|
739
|
+
createdAfter: input.createdAfter,
|
|
740
|
+
createdBefore: input.createdBefore,
|
|
741
|
+
limit: input.limit,
|
|
742
|
+
offset: input.offset,
|
|
743
|
+
orderBy: input.orderBy,
|
|
744
|
+
order: input.order
|
|
745
|
+
});
|
|
746
|
+
const objectTypeId = this.#resolveListObjectTypes(request.objectTypeId);
|
|
747
|
+
if (Array.isArray(objectTypeId) && objectTypeId.length === 0) {
|
|
748
|
+
return { objects: [], hasMore: false, total: 0 };
|
|
749
|
+
}
|
|
750
|
+
return detachReadResult(await this.#storage.list({
|
|
751
|
+
...request,
|
|
752
|
+
...objectTypeId === undefined ? {} : { objectTypeId },
|
|
753
|
+
projectId: this.#runtime.projectId
|
|
754
|
+
}));
|
|
755
|
+
}
|
|
756
|
+
async listLinks(input) {
|
|
757
|
+
const request = snapshotReadValue({
|
|
758
|
+
objectTypeId: input.objectTypeId,
|
|
759
|
+
objectId: input.objectId,
|
|
760
|
+
linkId: input.linkId,
|
|
761
|
+
direction: input.direction
|
|
762
|
+
});
|
|
763
|
+
this.#assertObjectTypesViewable([request.objectTypeId]);
|
|
764
|
+
const links = detachReadResult(await this.#storage.listLinks({
|
|
765
|
+
...request,
|
|
766
|
+
projectId: this.#runtime.projectId
|
|
767
|
+
}));
|
|
768
|
+
return links.filter((link) => this.#isLinkViewable(link));
|
|
769
|
+
}
|
|
770
|
+
async listLinksBatch(input) {
|
|
771
|
+
const request = snapshotReadValue({
|
|
772
|
+
direction: input.direction,
|
|
773
|
+
items: input.items.map((item) => ({
|
|
774
|
+
objectTypeId: item.objectTypeId,
|
|
775
|
+
objectId: item.objectId,
|
|
776
|
+
linkId: item.linkId
|
|
777
|
+
}))
|
|
778
|
+
});
|
|
779
|
+
this.#assertObjectTypesViewable(request.items.map((item) => item.objectTypeId));
|
|
780
|
+
const pages = detachReadResult(await this.#storage.listLinksBatch({
|
|
781
|
+
...request,
|
|
782
|
+
projectId: this.#runtime.projectId
|
|
783
|
+
}));
|
|
784
|
+
const filtered = new Map;
|
|
785
|
+
for (const [key, links] of pages) {
|
|
786
|
+
filtered.set(key, links.filter((link) => this.#isLinkViewable(link)));
|
|
787
|
+
}
|
|
788
|
+
return filtered;
|
|
789
|
+
}
|
|
790
|
+
async executeQuery(input) {
|
|
791
|
+
const query = snapshotAuthoredQuery(input.query);
|
|
792
|
+
const includeTotal = snapshotReadValue(input.includeTotal);
|
|
793
|
+
const executionQuery = this.#admitDelegatedQuery(query)?.query ?? query;
|
|
794
|
+
return detachReadResult(await executeObjectQuery({
|
|
795
|
+
query: executionQuery,
|
|
796
|
+
...includeTotal === undefined ? {} : { includeTotal },
|
|
797
|
+
projectId: this.#runtime.projectId
|
|
798
|
+
}, this.#queryExecutorOptions()));
|
|
799
|
+
}
|
|
800
|
+
async queryLinks(input) {
|
|
801
|
+
const query = snapshotAuthoredQuery(input.query);
|
|
802
|
+
const request = snapshotReadValue({
|
|
803
|
+
direction: input.direction,
|
|
804
|
+
linkId: input.linkId,
|
|
805
|
+
includeObjects: input.includeObjects,
|
|
806
|
+
pageSize: input.pageSize,
|
|
807
|
+
pageToken: input.pageToken
|
|
808
|
+
});
|
|
809
|
+
let executionQuery = query;
|
|
810
|
+
const admission = this.#delegatedQueryAdmission;
|
|
811
|
+
if (admission) {
|
|
812
|
+
const preflight = preflightObjectQueryLinks({ query, ...request, projectId: this.#runtime.projectId }, { ontology: this.#ontology });
|
|
813
|
+
const admitted = validateObjectQueryWithAdmission(preflight.validated.query, { ontology: this.#ontology, normalize: false }, admission);
|
|
814
|
+
admission.assertIncidentEdgeSelected({
|
|
815
|
+
state: admitted.admissionState,
|
|
816
|
+
...preflight.linkId === undefined ? {} : { linkId: preflight.linkId },
|
|
817
|
+
direction: preflight.direction,
|
|
818
|
+
path: "$.linkId"
|
|
819
|
+
});
|
|
820
|
+
executionQuery = admitted.query;
|
|
821
|
+
}
|
|
822
|
+
const result = detachReadResult(await executeObjectQueryLinks({ query: executionQuery, ...request, projectId: this.#runtime.projectId }, this.#queryExecutorOptions()));
|
|
823
|
+
if (result.objects.some((row) => !this.#isObjectTypeViewable(row.objectTypeId)) || result.links.some((link) => !this.#isLinkViewable(link))) {
|
|
824
|
+
throw new Error("[Sixb] Object storage returned a link page outside its authorized scope.");
|
|
825
|
+
}
|
|
826
|
+
return result;
|
|
827
|
+
}
|
|
828
|
+
async count(input) {
|
|
829
|
+
const query = snapshotAuthoredQuery(input.query);
|
|
830
|
+
const executionQuery = this.#admitDelegatedQuery(query)?.query ?? query;
|
|
831
|
+
return detachReadResult(await countObjects({ query: executionQuery, projectId: this.#runtime.projectId }, this.#queryExecutorOptions()));
|
|
832
|
+
}
|
|
833
|
+
async exists(input) {
|
|
834
|
+
const query = snapshotAuthoredQuery(input.query);
|
|
835
|
+
const executionQuery = this.#admitDelegatedQuery(query)?.query ?? query;
|
|
836
|
+
return detachReadResult(await existsObjects({ query: executionQuery, projectId: this.#runtime.projectId }, this.#queryExecutorOptions()));
|
|
837
|
+
}
|
|
838
|
+
async facet(input) {
|
|
839
|
+
const query = snapshotAuthoredQuery(input.query);
|
|
840
|
+
const facets = snapshotFacetRequests(input.facets);
|
|
841
|
+
let executionQuery = query;
|
|
842
|
+
let executionFacets = facets;
|
|
843
|
+
const admission = this.#delegatedQueryAdmission;
|
|
844
|
+
if (admission) {
|
|
845
|
+
const validated = validateObjectQuery(query, { ontology: this.#ontology });
|
|
846
|
+
const normalizedFacets = validateObjectFacetRequests(facets, validated.result.objectTypeIds, {
|
|
847
|
+
ontology: this.#ontology
|
|
848
|
+
});
|
|
849
|
+
const admitted = validateObjectQueryWithAdmission(validated.query, { ontology: this.#ontology, normalize: false }, admission);
|
|
850
|
+
normalizedFacets.forEach((facet, index) => {
|
|
851
|
+
admission.assertPropertySelected({
|
|
852
|
+
state: admitted.admissionState,
|
|
853
|
+
propertyId: facet.propertyId,
|
|
854
|
+
use: "facet",
|
|
855
|
+
path: `$.facets[${index}].propertyId`
|
|
856
|
+
});
|
|
857
|
+
});
|
|
858
|
+
executionQuery = admitted.query;
|
|
859
|
+
executionFacets = normalizedFacets;
|
|
860
|
+
}
|
|
861
|
+
return detachReadResult(await facetObjects({
|
|
862
|
+
query: executionQuery,
|
|
863
|
+
facets: executionFacets,
|
|
864
|
+
projectId: this.#runtime.projectId
|
|
865
|
+
}, this.#queryExecutorOptions()));
|
|
866
|
+
}
|
|
867
|
+
assertVisibleOutputWithinLimit(value) {
|
|
868
|
+
if (this.#authority.type !== "delegated")
|
|
869
|
+
return;
|
|
870
|
+
assertObjectReadOutputWithinLimit(value, this.#authority.objectRead.limits);
|
|
871
|
+
}
|
|
872
|
+
admitTelemetryHistoryRead(input) {
|
|
873
|
+
return admitTelemetryHistoryReadWorkload(input, this.#authority.type === "delegated");
|
|
874
|
+
}
|
|
875
|
+
#queryExecutorOptions() {
|
|
876
|
+
if (this.#authority.type === "delegated") {
|
|
877
|
+
return { ontology: this.#ontology, storage: this.#storage };
|
|
878
|
+
}
|
|
879
|
+
return {
|
|
880
|
+
ontology: this.#ontology,
|
|
881
|
+
storage: this.#storage,
|
|
882
|
+
runtimeAuthorization: this.#runtime.runtimeAuthorization,
|
|
883
|
+
...this.#runtime.authorization === undefined ? {} : { authorization: this.#runtime.authorization }
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
#admitDelegatedQuery(query) {
|
|
887
|
+
if (!this.#delegatedQueryAdmission)
|
|
888
|
+
return;
|
|
889
|
+
return validateObjectQueryWithAdmission(query, { ontology: this.#ontology }, this.#delegatedQueryAdmission);
|
|
890
|
+
}
|
|
891
|
+
#assertObjectTypesViewable(objectTypeIds) {
|
|
892
|
+
if (this.#authority.type === "delegated") {
|
|
893
|
+
for (const objectTypeId of new Set(objectTypeIds)) {
|
|
894
|
+
if (this.#delegatedObjectTypeIds?.has(objectTypeId))
|
|
895
|
+
continue;
|
|
896
|
+
throw new AuthorizationError(`delegated:object.view:${objectTypeId}`, `[Sixb] Delegated authorization does not select object type '${objectTypeId}'.`);
|
|
897
|
+
}
|
|
898
|
+
return;
|
|
899
|
+
}
|
|
900
|
+
for (const objectTypeId of new Set(objectTypeIds)) {
|
|
901
|
+
assertAuthorized(this.#runtime, { kind: "object.view", objectTypeId });
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
#resolveListObjectTypes(requested) {
|
|
905
|
+
if (requested !== undefined) {
|
|
906
|
+
const objectTypeIds = typeof requested === "string" ? [requested] : [...new Set(requested)];
|
|
907
|
+
for (const objectTypeId of objectTypeIds) {
|
|
908
|
+
this.#ontology.resolveObjectType(objectTypeId);
|
|
909
|
+
}
|
|
910
|
+
this.#assertObjectTypesViewable(objectTypeIds);
|
|
911
|
+
return typeof requested === "string" ? requested : objectTypeIds;
|
|
912
|
+
}
|
|
913
|
+
if (this.#authority.type === "unrestricted")
|
|
914
|
+
return;
|
|
915
|
+
return this.#ontology.listObjectTypes().map((objectType) => objectType.id).filter((objectTypeId) => this.#isObjectTypeViewable(objectTypeId));
|
|
916
|
+
}
|
|
917
|
+
#isObjectTypeViewable(objectTypeId) {
|
|
918
|
+
if (this.#authority.type === "delegated") {
|
|
919
|
+
return this.#delegatedObjectTypeIds?.has(objectTypeId) ?? false;
|
|
920
|
+
}
|
|
921
|
+
return isAllowed(this.#runtime.authorization, { kind: "object.view", objectTypeId });
|
|
922
|
+
}
|
|
923
|
+
#isLinkViewable(link) {
|
|
924
|
+
if (!this.#isObjectTypeViewable(link.sourceTypeId) || !this.#isObjectTypeViewable(link.targetTypeId)) {
|
|
925
|
+
return false;
|
|
926
|
+
}
|
|
927
|
+
return this.#delegatedLinkDefinitions?.has(delegatedLinkDefinitionKey(link)) ?? this.#authority.type !== "delegated";
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
Object.freeze(AuthorizedObjectReaderImpl.prototype);
|
|
931
|
+
Object.freeze(AuthorizedObjectReaderImpl);
|
|
932
|
+
function createAuthorizedObjectReader(input) {
|
|
933
|
+
const scope = captureExecutionScope(input.scope);
|
|
934
|
+
const projectId = scope.execution.projectId;
|
|
935
|
+
const authority = resolveExecutionScopeAuthorization(projectId, scope);
|
|
936
|
+
const storage = objectStorageForAuthority(authority, input.objectStorage);
|
|
937
|
+
const reader = new AuthorizedObjectReaderImpl(readerConstructionKey, {
|
|
938
|
+
scope,
|
|
939
|
+
ontology: input.ontology,
|
|
940
|
+
storage,
|
|
941
|
+
authority
|
|
942
|
+
});
|
|
943
|
+
Object.freeze(reader);
|
|
944
|
+
return reader;
|
|
945
|
+
}
|
|
946
|
+
function assertAuthorizedObjectReaderBinding(input) {
|
|
947
|
+
AuthorizedObjectReaderImpl.assertBound(input.reader, input.scope);
|
|
948
|
+
}
|
|
949
|
+
function getAuthorizedOntologyView(reader) {
|
|
950
|
+
return AuthorizedObjectReaderImpl.ontologyView(reader);
|
|
951
|
+
}
|
|
952
|
+
function objectStorageForAuthority(authority, objectStorage) {
|
|
953
|
+
switch (authority.type) {
|
|
954
|
+
case "principal":
|
|
955
|
+
case "unrestricted":
|
|
956
|
+
return objectStorage;
|
|
957
|
+
case "delegated":
|
|
958
|
+
return objectStorage.createSelectedReadScope({
|
|
959
|
+
projectId: authority.projectId,
|
|
960
|
+
scope: authority.objectRead.scope,
|
|
961
|
+
limits: authority.objectRead.limits
|
|
962
|
+
});
|
|
963
|
+
default:
|
|
964
|
+
return assertNever(authority);
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
function assertNever(value) {
|
|
968
|
+
throw new Error(`[Sixb] Unsupported object reader authority '${String(value.type)}'.`);
|
|
969
|
+
}
|
|
970
|
+
function ontologySelectionForAuthority(authority, ontology) {
|
|
971
|
+
switch (authority.type) {
|
|
972
|
+
case "unrestricted":
|
|
973
|
+
return { kind: "all" };
|
|
974
|
+
case "principal":
|
|
975
|
+
return {
|
|
976
|
+
kind: "types",
|
|
977
|
+
objectTypeIds: ontology.listObjectTypes().filter((objectType) => isAllowed(authority.context, {
|
|
978
|
+
kind: "object.view",
|
|
979
|
+
objectTypeId: objectType.id
|
|
980
|
+
})).map((objectType) => objectType.id)
|
|
981
|
+
};
|
|
982
|
+
case "delegated":
|
|
983
|
+
return { kind: "selected", scope: authority.objectRead.scope };
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
function delegatedLinkDefinitionKey(input) {
|
|
987
|
+
return "sourceObjectTypeId" in input ? JSON.stringify([input.sourceObjectTypeId, input.linkId, input.targetObjectTypeId]) : JSON.stringify([input.sourceTypeId, input.linkId, input.targetTypeId]);
|
|
988
|
+
}
|
|
989
|
+
function detachReadResult(value) {
|
|
990
|
+
return structuredClone(value);
|
|
991
|
+
}
|
|
992
|
+
function snapshotReadValue(value) {
|
|
993
|
+
return structuredClone(value);
|
|
994
|
+
}
|
|
995
|
+
function snapshotFacetRequests(facets) {
|
|
996
|
+
if (!Array.isArray(facets)) {
|
|
997
|
+
throw new ObjectQueryValidationError([
|
|
998
|
+
{
|
|
999
|
+
path: "$.facets",
|
|
1000
|
+
code: "invalid_facets",
|
|
1001
|
+
message: "facets must be an array"
|
|
1002
|
+
}
|
|
1003
|
+
]);
|
|
1004
|
+
}
|
|
1005
|
+
const length = facets.length;
|
|
1006
|
+
if (!Number.isSafeInteger(length) || length > MAX_OBJECT_READ_FACETS) {
|
|
1007
|
+
throw new ObjectQueryValidationError([
|
|
1008
|
+
{
|
|
1009
|
+
path: "$.facets",
|
|
1010
|
+
code: "too_many_facets",
|
|
1011
|
+
message: `facets must include at most ${MAX_OBJECT_READ_FACETS} facet requests`
|
|
1012
|
+
}
|
|
1013
|
+
]);
|
|
1014
|
+
}
|
|
1015
|
+
const snapshot = [];
|
|
1016
|
+
for (let index = 0;index < length; index += 1) {
|
|
1017
|
+
const facet = facets[index];
|
|
1018
|
+
snapshot.push({ propertyId: facet.propertyId, limit: facet.limit });
|
|
1019
|
+
}
|
|
1020
|
+
return snapshot;
|
|
1021
|
+
}
|
|
1022
|
+
function snapshotAuthoredQuery(query) {
|
|
1023
|
+
try {
|
|
1024
|
+
return structuredClone(query);
|
|
1025
|
+
} catch (error) {
|
|
1026
|
+
if (error instanceof ObjectQueryValidationError)
|
|
1027
|
+
throw error;
|
|
1028
|
+
throw new ObjectQueryValidationError([
|
|
1029
|
+
{
|
|
1030
|
+
path: "$",
|
|
1031
|
+
code: "query_not_cloneable",
|
|
1032
|
+
message: "Object query must contain only structured-cloneable data"
|
|
1033
|
+
}
|
|
1034
|
+
]);
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
// src/actions/delegated-admission.ts
|
|
1039
|
+
function assertDelegatedActionTarget(input) {
|
|
1040
|
+
const { actionId, authorization, subject } = input;
|
|
1041
|
+
if (subject.kind !== "object" || !authorization.actionApply.some((target) => target.actionId === actionId && target.subject.objectTypeId === subject.objectTypeId && target.subject.primaryId === subject.primaryId)) {
|
|
1042
|
+
throw denied2(actionId, subject);
|
|
1043
|
+
}
|
|
1044
|
+
return subject;
|
|
1045
|
+
}
|
|
1046
|
+
async function admitDelegatedObjectAction(input) {
|
|
1047
|
+
const { action, authorization, execution, objectReader, runtimeAuthorization, subject } = input;
|
|
1048
|
+
assertDelegatedActionTarget({ authorization, actionId: action.id, subject });
|
|
1049
|
+
if (action.binding.kind !== "object" || action.binding.objectType.id !== subject.objectTypeId) {
|
|
1050
|
+
throw denied2(action.id, subject);
|
|
1051
|
+
}
|
|
1052
|
+
assertAuthorizedObjectReaderBinding({
|
|
1053
|
+
reader: objectReader,
|
|
1054
|
+
scope: { execution, authorization: runtimeAuthorization }
|
|
1055
|
+
});
|
|
1056
|
+
try {
|
|
1057
|
+
const visible = await objectReader.getByPrimaryId({
|
|
1058
|
+
objectTypeId: subject.objectTypeId,
|
|
1059
|
+
primaryId: subject.primaryId
|
|
1060
|
+
});
|
|
1061
|
+
if (!visible)
|
|
1062
|
+
throw denied2(action.id, subject);
|
|
1063
|
+
} catch (error) {
|
|
1064
|
+
if (error instanceof AuthorizationError)
|
|
1065
|
+
throw denied2(action.id, subject);
|
|
1066
|
+
throw error;
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
function denied2(actionId, subject) {
|
|
1070
|
+
const target = subject.kind === "object" ? `${subject.objectTypeId}:${subject.primaryId}` : "global";
|
|
1071
|
+
return new AuthorizationError(`apply:action:${actionId}:${target}`, `[Sixb] Delegated authority cannot apply Action '${actionId}' to '${target}'.`);
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
// src/actions/run-authorization.ts
|
|
1075
|
+
async function canDelegationAccessActionRun(input) {
|
|
1076
|
+
const subject = input.run.subject;
|
|
1077
|
+
if (!input.authority.delegation || subject.kind !== "object" || !input.authority.actionApply.some((target) => target.actionId === input.run.actionId && target.subject.objectTypeId === subject.objectTypeId && target.subject.primaryId === subject.primaryId)) {
|
|
1078
|
+
return false;
|
|
1079
|
+
}
|
|
1080
|
+
return actionRunBelongsToShareGrant({
|
|
1081
|
+
storage: input.storage,
|
|
1082
|
+
projectId: input.projectId,
|
|
1083
|
+
run: input.run,
|
|
1084
|
+
grantId: input.authority.delegation.grantId
|
|
1085
|
+
});
|
|
1086
|
+
}
|
|
1087
|
+
async function actionRunBelongsToShareGrant(input) {
|
|
1088
|
+
const parent = await findPrimitiveParentRequestExecution({
|
|
1089
|
+
executions: input.storage.executions,
|
|
1090
|
+
projectId: input.projectId,
|
|
1091
|
+
executionId: input.run.executionId,
|
|
1092
|
+
primitive: { kind: "action", id: input.run.actionId, runId: input.run.id }
|
|
1093
|
+
});
|
|
1094
|
+
const authorization = parent?.authorizationRef;
|
|
1095
|
+
return authorization?.type === "delegated" && authorization.delegation.kind === "share" && authorization.delegation.grantId === input.grantId;
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
// src/actions/run-dispatch.ts
|
|
1099
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
1100
|
+
|
|
1101
|
+
// src/actions/run-id.ts
|
|
1102
|
+
import { randomUUID } from "crypto";
|
|
1103
|
+
function createActionRunId(runId) {
|
|
1104
|
+
if (runId !== undefined) {
|
|
1105
|
+
if (!runId.trim()) {
|
|
1106
|
+
throw new OntologyValidationError("[Sixb] Action run id must not be empty");
|
|
1107
|
+
}
|
|
1108
|
+
return runId;
|
|
1109
|
+
}
|
|
1110
|
+
return `act_${randomUUID()}`;
|
|
1111
|
+
}
|
|
1112
|
+
function createActionRunIdempotencyKey(projectId, runId) {
|
|
1113
|
+
return `action:${projectId}:${runId}`;
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
// src/actions/run-dispatch.ts
|
|
1117
|
+
async function dispatchActionRun(input) {
|
|
1118
|
+
const request = prepareActionRun(input);
|
|
1119
|
+
const persisted = await persistActionRun(input, request);
|
|
1120
|
+
if (!persisted.publish)
|
|
1121
|
+
return existingActionRunResult(persisted.run);
|
|
1122
|
+
return publishActionRun(input, persisted);
|
|
1123
|
+
}
|
|
1124
|
+
function prepareActionRun(input) {
|
|
1125
|
+
const runId = createActionRunId(input.runId);
|
|
1126
|
+
return {
|
|
1127
|
+
runId,
|
|
1128
|
+
idempotencyKey: createActionRunIdempotencyKey(input.projectId, runId)
|
|
1129
|
+
};
|
|
1130
|
+
}
|
|
1131
|
+
async function persistActionRun(input, request) {
|
|
1132
|
+
const actionRuns = requireActionRunStorage(input.storage);
|
|
1133
|
+
const existing = await actionRuns.getById({ projectId: input.projectId, id: request.runId });
|
|
1134
|
+
if (existing) {
|
|
1135
|
+
await input.assertCanReuseExisting?.(input.storage, existing);
|
|
1136
|
+
return reuseActionRun(input, existing);
|
|
1137
|
+
}
|
|
1138
|
+
const execution = await input.createExecution(`exec_${randomUUID2()}`, request.runId);
|
|
1139
|
+
const queuedAt = new Date;
|
|
1140
|
+
try {
|
|
1141
|
+
return await input.storage.transaction(async (tx) => {
|
|
1142
|
+
const transactionalRuns = requireActionRunStorage(tx);
|
|
1143
|
+
const raced = await transactionalRuns.getById({
|
|
1144
|
+
projectId: input.projectId,
|
|
1145
|
+
id: request.runId
|
|
1146
|
+
});
|
|
1147
|
+
if (raced) {
|
|
1148
|
+
await input.assertCanReuseExisting?.(tx, raced);
|
|
1149
|
+
assertExistingRunMatchesRequest(raced, input);
|
|
1150
|
+
return { publish: false, run: raced };
|
|
1151
|
+
}
|
|
1152
|
+
await tx.executions.create(execution);
|
|
1153
|
+
const run = await transactionalRuns.queue({
|
|
1154
|
+
projectId: input.projectId,
|
|
1155
|
+
id: request.runId,
|
|
1156
|
+
executionId: execution.id,
|
|
1157
|
+
actionId: input.actionId,
|
|
1158
|
+
subject: input.subject,
|
|
1159
|
+
params: input.params,
|
|
1160
|
+
idempotencyKey: request.idempotencyKey,
|
|
1161
|
+
queuedAt
|
|
1162
|
+
});
|
|
1163
|
+
return { publish: true, run, execution, queuedAt, created: true };
|
|
1164
|
+
}, { isolation: "serializable" });
|
|
1165
|
+
} catch (error) {
|
|
1166
|
+
if (!(error instanceof ActionRunError))
|
|
1167
|
+
throw error;
|
|
1168
|
+
const raced = await actionRuns.getById({ projectId: input.projectId, id: request.runId });
|
|
1169
|
+
if (!raced)
|
|
1170
|
+
throw error;
|
|
1171
|
+
await input.assertCanReuseExisting?.(input.storage, raced);
|
|
1172
|
+
assertExistingRunMatchesRequest(raced, input);
|
|
1173
|
+
return { publish: false, run: raced };
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
async function reuseActionRun(input, existing) {
|
|
1177
|
+
assertExistingRunMatchesRequest(existing, input);
|
|
1178
|
+
if (!isRetryableEnqueueFailure(existing))
|
|
1179
|
+
return { publish: false, run: existing };
|
|
1180
|
+
const execution = await input.storage.executions.getById({
|
|
1181
|
+
projectId: input.projectId,
|
|
1182
|
+
id: existing.executionId
|
|
1183
|
+
});
|
|
1184
|
+
if (!execution) {
|
|
1185
|
+
throw new ActionRunError(`[Sixb] Execution '${existing.executionId}' for Action run '${existing.id}' was not found.`);
|
|
1186
|
+
}
|
|
1187
|
+
const queuedAt = new Date;
|
|
1188
|
+
const run = await requireActionRunStorage(input.storage).queue({
|
|
1189
|
+
projectId: input.projectId,
|
|
1190
|
+
id: existing.id,
|
|
1191
|
+
executionId: existing.executionId,
|
|
1192
|
+
actionId: existing.actionId,
|
|
1193
|
+
subject: existing.subject,
|
|
1194
|
+
params: existing.params,
|
|
1195
|
+
idempotencyKey: existing.idempotencyKey,
|
|
1196
|
+
queuedAt
|
|
1197
|
+
});
|
|
1198
|
+
return { publish: true, run, execution, queuedAt, created: false };
|
|
1199
|
+
}
|
|
1200
|
+
async function publishActionRun(input, persisted) {
|
|
1201
|
+
let job;
|
|
1202
|
+
try {
|
|
1203
|
+
const jobs = await input.queue.enqueue({
|
|
1204
|
+
projectId: input.projectId,
|
|
1205
|
+
jobs: [
|
|
1206
|
+
{
|
|
1207
|
+
id: persisted.run.id,
|
|
1208
|
+
type: "action.run.requested",
|
|
1209
|
+
payload: {
|
|
1210
|
+
runId: persisted.run.id
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
]
|
|
1214
|
+
});
|
|
1215
|
+
job = jobs[0];
|
|
1216
|
+
} catch (error) {
|
|
1217
|
+
await failActionRunPublication(input, persisted.run, error);
|
|
1218
|
+
throw error;
|
|
1219
|
+
}
|
|
1220
|
+
await input.events.emit({
|
|
1221
|
+
events: [
|
|
1222
|
+
{
|
|
1223
|
+
type: "action.requested",
|
|
1224
|
+
payload: {
|
|
1225
|
+
actionId: persisted.run.actionId,
|
|
1226
|
+
subject: persisted.run.subject,
|
|
1227
|
+
params: persisted.run.params,
|
|
1228
|
+
runId: persisted.run.id
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
],
|
|
1232
|
+
correlationId: persisted.execution.correlationId
|
|
1233
|
+
}, { source: "Sixb" });
|
|
1234
|
+
return {
|
|
1235
|
+
runId: persisted.run.id,
|
|
1236
|
+
queuedAt: persisted.queuedAt.toISOString(),
|
|
1237
|
+
...job?.id ? { jobId: job.id } : {},
|
|
1238
|
+
created: persisted.created
|
|
1239
|
+
};
|
|
1240
|
+
}
|
|
1241
|
+
async function failActionRunPublication(input, run, error) {
|
|
1242
|
+
const failedAt = new Date;
|
|
1243
|
+
const failure = toActionRunFailure(error, run, failedAt);
|
|
1244
|
+
await requireActionRunStorage(input.storage).finish({
|
|
1245
|
+
projectId: input.projectId,
|
|
1246
|
+
id: run.id,
|
|
1247
|
+
status: "failed",
|
|
1248
|
+
finishedAt: failedAt,
|
|
1249
|
+
error: failure
|
|
1250
|
+
});
|
|
1251
|
+
reportRunFailure(input.errorReporterHost, error, {
|
|
1252
|
+
projectId: input.projectId,
|
|
1253
|
+
runKind: "action",
|
|
1254
|
+
run: { runId: run.id, actionId: run.actionId },
|
|
1255
|
+
failure
|
|
1256
|
+
});
|
|
1257
|
+
}
|
|
1258
|
+
function requireActionRunStorage(storage) {
|
|
1259
|
+
if (!storage.actionRuns) {
|
|
1260
|
+
throw new ActionRunError("[Sixb] Action run storage is not configured.");
|
|
1261
|
+
}
|
|
1262
|
+
return storage.actionRuns;
|
|
1263
|
+
}
|
|
1264
|
+
function assertExistingRunMatchesRequest(existing, request) {
|
|
1265
|
+
if (existing.actionId !== request.actionId || !actionSubjectsEqual(existing.subject, request.subject) || !actionRunParamsEqual(existing.params, request.params)) {
|
|
1266
|
+
throw new ActionRunError(`[Sixb] Action run '${existing.id}' already exists with a different request payload.`);
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
function isRetryableEnqueueFailure(record) {
|
|
1270
|
+
return record.status === "failed" && record.phase === "enqueue" && record.error?.retryable === true;
|
|
1271
|
+
}
|
|
1272
|
+
function existingActionRunResult(existing) {
|
|
1273
|
+
return {
|
|
1274
|
+
runId: existing.id,
|
|
1275
|
+
queuedAt: existing.queuedAt.toISOString(),
|
|
1276
|
+
created: false
|
|
1277
|
+
};
|
|
1278
|
+
}
|
|
1279
|
+
function toActionRunFailure(error, run, at) {
|
|
1280
|
+
const enqueueError = createSixbError("queue.enqueue_failed", `[Sixb] Could not enqueue Action run '${run.id}'.`, {
|
|
1281
|
+
cause: error,
|
|
1282
|
+
details: { actionId: run.actionId, runId: run.id, phase: "enqueue" }
|
|
1283
|
+
});
|
|
1284
|
+
return parseActionRunFailure(toSixbFailure(enqueueError, {
|
|
1285
|
+
allowedCodes: ACTION_RUN_FAILURE_CODES,
|
|
1286
|
+
at
|
|
1287
|
+
}), "enqueue");
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
// src/actions/request.ts
|
|
1291
|
+
var DEFAULT_ACTION_WAIT_TIMEOUT_MS = 60000;
|
|
1292
|
+
var DEFAULT_ACTION_WAIT_POLL_MS = 1000;
|
|
1293
|
+
function clearTimer(timer) {
|
|
1294
|
+
if (timer) {
|
|
1295
|
+
clearTimeout(timer);
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
function getActionDefinition(runtime, actionId) {
|
|
1299
|
+
const action = runtime.actionRegistry.getById(actionId);
|
|
1300
|
+
if (!action) {
|
|
1301
|
+
throw new OntologyValidationError(`Unknown action '${actionId}'`);
|
|
1302
|
+
}
|
|
1303
|
+
return action;
|
|
1304
|
+
}
|
|
1305
|
+
async function requestAction(runtime, execution, input) {
|
|
1306
|
+
const projectId = runtime.projectId;
|
|
1307
|
+
const runtimeAuthorization = runtime.runtimeAuthorization;
|
|
1308
|
+
const objectReader = runtime.objectReader;
|
|
1309
|
+
const request = snapshotActionRequest(input);
|
|
1310
|
+
const authorization = resolveExecutionScopeAuthorization(projectId, {
|
|
1311
|
+
execution,
|
|
1312
|
+
authorization: runtimeAuthorization
|
|
1313
|
+
});
|
|
1314
|
+
const subject = request.subject;
|
|
1315
|
+
const delegatedSubject = authorization.type === "delegated" ? assertDelegatedActionTarget({
|
|
1316
|
+
authorization,
|
|
1317
|
+
actionId: request.actionId,
|
|
1318
|
+
subject
|
|
1319
|
+
}) : undefined;
|
|
1320
|
+
const action = getActionDefinition(runtime, request.actionId);
|
|
1321
|
+
const actionId = action.id;
|
|
1322
|
+
const rawParams = request.params;
|
|
1323
|
+
if (authorization.type === "delegated") {
|
|
1324
|
+
await admitDelegatedObjectAction({
|
|
1325
|
+
objectReader,
|
|
1326
|
+
runtimeAuthorization,
|
|
1327
|
+
execution,
|
|
1328
|
+
authorization,
|
|
1329
|
+
action,
|
|
1330
|
+
subject: delegatedSubject
|
|
1331
|
+
});
|
|
1332
|
+
} else {
|
|
1333
|
+
assertAuthorized({ projectId, runtimeAuthorization }, { kind: "action.apply", actionId });
|
|
1334
|
+
}
|
|
1335
|
+
if (authorization.type !== "delegated" && action.binding.kind === "object") {
|
|
1336
|
+
assertAuthorized({ projectId, runtimeAuthorization }, { kind: "object.view", objectTypeId: action.binding.objectType.id });
|
|
1337
|
+
}
|
|
1338
|
+
validateActionSubject(action, subject);
|
|
1339
|
+
let pathPrefix = action.id;
|
|
1340
|
+
let objectType = null;
|
|
1341
|
+
if (isObjectActionDefinition(action)) {
|
|
1342
|
+
objectType = resolveObjectActionSubject({ runtime, action, subject });
|
|
1343
|
+
pathPrefix = `${objectType.id}.${action.id}`;
|
|
1344
|
+
}
|
|
1345
|
+
const actionParams = normalizeActionParams(runtime, action.params, rawParams, pathPrefix);
|
|
1346
|
+
getAuthorizationRef(runtimeAuthorization);
|
|
1347
|
+
return dispatchActionRun({
|
|
1348
|
+
errorReporterHost: runtime,
|
|
1349
|
+
projectId,
|
|
1350
|
+
storage: runtime.storage,
|
|
1351
|
+
queue: runtime.queues.actions,
|
|
1352
|
+
events: runtime.events,
|
|
1353
|
+
actionId,
|
|
1354
|
+
subject,
|
|
1355
|
+
params: actionParams,
|
|
1356
|
+
runId: request.runId,
|
|
1357
|
+
...authorization.type === "delegated" ? {
|
|
1358
|
+
assertCanReuseExisting: async (storage, existing) => {
|
|
1359
|
+
if (!authorization.delegation || !await actionRunBelongsToShareGrant({
|
|
1360
|
+
storage,
|
|
1361
|
+
projectId,
|
|
1362
|
+
run: existing,
|
|
1363
|
+
grantId: authorization.delegation.grantId
|
|
1364
|
+
})) {
|
|
1365
|
+
throw new AuthorizationError(`apply:action:${actionId}`, "[Sixb] Delegated authority cannot reuse this Action run.");
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
} : {},
|
|
1369
|
+
createExecution: async (executionId, runId) => {
|
|
1370
|
+
const caller = await ensureExecutionRecord(runtime.storage.executions, executionRecordInputFromRuntime({
|
|
1371
|
+
execution,
|
|
1372
|
+
runtimeAuthorization
|
|
1373
|
+
}));
|
|
1374
|
+
return createPrimitiveExecutionRecord({
|
|
1375
|
+
id: executionId,
|
|
1376
|
+
primitive: { kind: "action", id: actionId, runId },
|
|
1377
|
+
origin: { type: "execution", parent: caller }
|
|
1378
|
+
});
|
|
1379
|
+
}
|
|
1380
|
+
});
|
|
1381
|
+
}
|
|
1382
|
+
function snapshotActionRequest(input) {
|
|
1383
|
+
const actionId = input.actionId;
|
|
1384
|
+
const subject = input.subject;
|
|
1385
|
+
const params = input.params;
|
|
1386
|
+
const runId = input.runId;
|
|
1387
|
+
return structuredClone({
|
|
1388
|
+
actionId,
|
|
1389
|
+
subject: subject ?? { kind: "none" },
|
|
1390
|
+
params: params ?? {},
|
|
1391
|
+
...runId === undefined ? {} : { runId }
|
|
1392
|
+
});
|
|
1393
|
+
}
|
|
1394
|
+
async function requestActionAndWait(runtime, execution, input) {
|
|
1395
|
+
const runId = createActionRunId(input.runId);
|
|
1396
|
+
await requestAction(runtime, execution, {
|
|
1397
|
+
...input,
|
|
1398
|
+
runId
|
|
1399
|
+
});
|
|
1400
|
+
await input.onRequested?.(runId);
|
|
1401
|
+
return waitForActionRun(runtime, {
|
|
1402
|
+
runId,
|
|
1403
|
+
timeoutMs: input.timeoutMs,
|
|
1404
|
+
signal: input.signal
|
|
1405
|
+
});
|
|
1406
|
+
}
|
|
1407
|
+
async function waitForActionRun(runtime, input) {
|
|
1408
|
+
const projectId = runtime.projectId;
|
|
1409
|
+
const runtimeAuthorization = runtime.runtimeAuthorization;
|
|
1410
|
+
const request = {
|
|
1411
|
+
runId: input.runId,
|
|
1412
|
+
timeoutMs: input.timeoutMs,
|
|
1413
|
+
signal: input.signal
|
|
1414
|
+
};
|
|
1415
|
+
const authorization = resolveRuntimeAuthorizationForProject({
|
|
1416
|
+
projectId,
|
|
1417
|
+
runtimeAuthorization
|
|
1418
|
+
});
|
|
1419
|
+
if (authorization.type === "denied") {
|
|
1420
|
+
throw new AuthorizationError("runtime:unbound", "[Sixb] Protected operations require registered runtime authorization for this project.");
|
|
1421
|
+
}
|
|
1422
|
+
if (authorization.type === "delegated")
|
|
1423
|
+
getAuthorizationRef(runtimeAuthorization);
|
|
1424
|
+
const actionRuns = requireActionRunStorage2(runtime);
|
|
1425
|
+
const timeoutMs = request.timeoutMs ?? DEFAULT_ACTION_WAIT_TIMEOUT_MS;
|
|
1426
|
+
const signal = request.signal;
|
|
1427
|
+
const startedAt = Date.now();
|
|
1428
|
+
if (signal?.aborted) {
|
|
1429
|
+
throw signal.reason ?? new Error("aborted");
|
|
1430
|
+
}
|
|
1431
|
+
return new Promise((resolve, reject) => {
|
|
1432
|
+
let timer;
|
|
1433
|
+
let pollTimer;
|
|
1434
|
+
let unsubscribe;
|
|
1435
|
+
let settled = false;
|
|
1436
|
+
let checking = false;
|
|
1437
|
+
const releaseSubscription = (release) => {
|
|
1438
|
+
if (!release)
|
|
1439
|
+
return;
|
|
1440
|
+
try {
|
|
1441
|
+
release();
|
|
1442
|
+
} catch (error) {
|
|
1443
|
+
console.error("[Sixb] Failed to release action run wait subscription:", error);
|
|
1444
|
+
}
|
|
1445
|
+
};
|
|
1446
|
+
const cleanup = () => {
|
|
1447
|
+
if (settled)
|
|
1448
|
+
return;
|
|
1449
|
+
settled = true;
|
|
1450
|
+
clearTimer(timer);
|
|
1451
|
+
clearTimer(pollTimer);
|
|
1452
|
+
signal?.removeEventListener("abort", onAbort);
|
|
1453
|
+
releaseSubscription(unsubscribe);
|
|
1454
|
+
};
|
|
1455
|
+
const rejectWith = (error) => {
|
|
1456
|
+
cleanup();
|
|
1457
|
+
reject(error);
|
|
1458
|
+
};
|
|
1459
|
+
const schedulePoll = () => {
|
|
1460
|
+
if (!settled && !pollTimer) {
|
|
1461
|
+
pollTimer = setTimeout(() => {
|
|
1462
|
+
pollTimer = undefined;
|
|
1463
|
+
check();
|
|
1464
|
+
}, DEFAULT_ACTION_WAIT_POLL_MS);
|
|
1465
|
+
}
|
|
1466
|
+
};
|
|
1467
|
+
const check = async () => {
|
|
1468
|
+
if (settled || checking) {
|
|
1469
|
+
return;
|
|
1470
|
+
}
|
|
1471
|
+
checking = true;
|
|
1472
|
+
try {
|
|
1473
|
+
const record = await actionRuns.getById({
|
|
1474
|
+
projectId,
|
|
1475
|
+
id: request.runId
|
|
1476
|
+
});
|
|
1477
|
+
const visible = record && (authorization.type === "unrestricted" || authorization.type === "principal" && canViewActionRun(authorization.context, record) || authorization.type === "delegated" && await canDelegationAccessActionRun({
|
|
1478
|
+
storage: runtime.storage,
|
|
1479
|
+
projectId,
|
|
1480
|
+
authority: authorization,
|
|
1481
|
+
run: record
|
|
1482
|
+
}));
|
|
1483
|
+
if (visible && isTerminalActionRun(record)) {
|
|
1484
|
+
if (authorization.type === "delegated") {
|
|
1485
|
+
assertObjectReadOutputWithinLimit(record, authorization.objectRead.limits);
|
|
1486
|
+
}
|
|
1487
|
+
cleanup();
|
|
1488
|
+
resolve(record);
|
|
1489
|
+
return;
|
|
1490
|
+
}
|
|
1491
|
+
schedulePoll();
|
|
1492
|
+
} catch (error) {
|
|
1493
|
+
rejectWith(error);
|
|
1494
|
+
} finally {
|
|
1495
|
+
checking = false;
|
|
1496
|
+
}
|
|
1497
|
+
};
|
|
1498
|
+
const onAbort = () => {
|
|
1499
|
+
rejectWith(signal?.reason ?? new Error("aborted"));
|
|
1500
|
+
};
|
|
1501
|
+
timer = setTimeout(() => {
|
|
1502
|
+
rejectWith(new ActionRunTimeoutError({ runId: request.runId, timeoutMs }));
|
|
1503
|
+
}, Math.max(0, timeoutMs - (Date.now() - startedAt)));
|
|
1504
|
+
if (signal) {
|
|
1505
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
1506
|
+
}
|
|
1507
|
+
runtime.events.subscribe({ types: ["action.completed", "action.failed"] }, (events) => {
|
|
1508
|
+
if (events.some((event) => (event.type === "action.completed" || event.type === "action.failed") && event.payload.runId === request.runId)) {
|
|
1509
|
+
check();
|
|
1510
|
+
}
|
|
1511
|
+
}).then((unsubscribeEvents) => {
|
|
1512
|
+
if (settled) {
|
|
1513
|
+
releaseSubscription(unsubscribeEvents);
|
|
1514
|
+
return;
|
|
1515
|
+
}
|
|
1516
|
+
unsubscribe = unsubscribeEvents;
|
|
1517
|
+
check();
|
|
1518
|
+
}).catch((error) => {
|
|
1519
|
+
if (settled) {
|
|
1520
|
+
console.error("[Sixb] Action run wait subscription failed after the wait settled:", error);
|
|
1521
|
+
return;
|
|
1522
|
+
}
|
|
1523
|
+
rejectWith(error);
|
|
1524
|
+
});
|
|
1525
|
+
});
|
|
1526
|
+
}
|
|
1527
|
+
function requireActionRunStorage2(runtime) {
|
|
1528
|
+
const actionRuns = runtime.storage.actionRuns;
|
|
1529
|
+
if (!actionRuns) {
|
|
1530
|
+
throw new ActionRunError("[Sixb] Action run storage is not configured.");
|
|
1531
|
+
}
|
|
1532
|
+
return actionRuns;
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
export { ActionValidationError, ActionRunFailedError, ActionRunTimeoutError, createAuthorizedObjectReader, assertAuthorizedObjectReaderBinding, getAuthorizedOntologyView, canDelegationAccessActionRun, requestAction, requestActionAndWait, waitForActionRun };
|
|
1536
|
+
|
|
1537
|
+
//# debugId=FFB8DCF8ECEF803364756E2164756E21
|