@sixb/core 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/index.js +19 -17
- package/dist/actions/index.js.map +1 -1
- package/dist/actions/worker.js +4 -4
- package/dist/actions/worker.js.map +1 -1
- package/dist/agents/adapters.d.ts +11 -1
- package/dist/agents/adapters.d.ts.map +1 -1
- package/dist/agents/context-compaction.d.ts +40 -0
- package/dist/agents/context-compaction.d.ts.map +1 -0
- package/dist/agents/context.js +1 -1
- package/dist/agents/errors.d.ts +1 -1
- package/dist/agents/errors.d.ts.map +1 -1
- package/dist/agents/execution.d.ts +3 -0
- package/dist/agents/execution.d.ts.map +1 -1
- package/dist/agents/ids.d.ts +2 -0
- package/dist/agents/ids.d.ts.map +1 -1
- package/dist/agents/index.d.ts +10 -6
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +51 -35
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/request.d.ts.map +1 -1
- package/dist/agents/streams.d.ts +17 -1
- package/dist/agents/streams.d.ts.map +1 -1
- package/dist/agents/streams.js +5 -3
- package/dist/agents/streams.js.map +1 -1
- package/dist/agents/thread-context-projection.d.ts +19 -0
- package/dist/agents/thread-context-projection.d.ts.map +1 -0
- package/dist/agents/tool-definition.d.ts.map +1 -1
- package/dist/agents/tool-result.d.ts +6 -0
- package/dist/agents/tool-result.d.ts.map +1 -0
- package/dist/agents/types.d.ts +46 -1
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/agents/validation.d.ts +2 -2
- package/dist/agents/validation.d.ts.map +1 -1
- package/dist/auth/index.js +11 -5
- package/dist/auth/index.js.map +1 -1
- package/dist/authorization/index.js +6 -2
- package/dist/authorization/index.js.map +1 -1
- package/dist/bootstrap/index.js +33 -31
- package/dist/bootstrap/index.js.map +1 -1
- package/dist/{chunk-ys1nse2v.js → chunk-1wk20wn3.js} +438 -246
- package/dist/{chunk-ys1nse2v.js.map → chunk-1wk20wn3.js.map} +11 -11
- package/dist/{chunk-sa4340y1.js → chunk-1yz3x65y.js} +7 -7
- package/dist/{chunk-gqdd7508.js → chunk-4rh2m6zg.js} +1 -1
- package/dist/{chunk-fmx1sz2h.js → chunk-72q2y8hn.js} +3 -3
- package/dist/{chunk-fmx1sz2h.js.map → chunk-72q2y8hn.js.map} +4 -4
- package/dist/{chunk-nnyp53zt.js → chunk-7gw7mepb.js} +259 -9
- package/dist/chunk-7gw7mepb.js.map +14 -0
- package/dist/{chunk-nten49ta.js → chunk-819wnjz8.js} +11 -5
- package/dist/chunk-819wnjz8.js.map +12 -0
- package/dist/chunk-96swp2wd.js +47 -0
- package/dist/chunk-96swp2wd.js.map +10 -0
- package/dist/{chunk-4x43bkbp.js → chunk-a09jx26t.js} +1 -1
- package/dist/{chunk-st4xgxey.js → chunk-afjpa2hs.js} +205 -48
- package/dist/chunk-afjpa2hs.js.map +45 -0
- package/dist/{chunk-0mbx247x.js → chunk-c43qr6s0.js} +427 -99
- package/dist/chunk-c43qr6s0.js.map +46 -0
- package/dist/{chunk-zg9yryhz.js → chunk-cbkm2vam.js} +3 -3
- package/dist/{chunk-57zpb99z.js → chunk-dm72y8wt.js} +26 -3
- package/dist/chunk-dm72y8wt.js.map +10 -0
- package/dist/chunk-drjqm1aa.js +913 -0
- package/dist/chunk-drjqm1aa.js.map +15 -0
- package/dist/chunk-dysw7nsm.js.map +1 -1
- package/dist/{chunk-8ryen3p3.js → chunk-f6erf2vv.js} +1 -1
- package/dist/{chunk-34bqh420.js → chunk-f83ka50g.js} +188 -44
- package/dist/chunk-f83ka50g.js.map +23 -0
- package/dist/{chunk-bct7hmfc.js → chunk-g13869yf.js} +3 -3
- package/dist/{chunk-0k4avqr2.js → chunk-hbeh8j9w.js} +2 -2
- package/dist/{chunk-qvybnnpe.js → chunk-nzw7sm3b.js} +2 -2
- package/dist/{chunk-k9pts48t.js → chunk-pn8n8sba.js} +16 -15
- package/dist/{chunk-k9pts48t.js.map → chunk-pn8n8sba.js.map} +3 -3
- package/dist/{chunk-63te770v.js → chunk-qewtks41.js} +8 -8
- package/dist/{chunk-63te770v.js.map → chunk-qewtks41.js.map} +2 -2
- package/dist/{chunk-85j5ybfj.js → chunk-rdeagz6b.js} +2 -2
- package/dist/{chunk-85j5ybfj.js.map → chunk-rdeagz6b.js.map} +3 -3
- package/dist/chunk-rhrbz7d4.js +36 -0
- package/dist/chunk-rhrbz7d4.js.map +10 -0
- package/dist/{chunk-bh6k3nc6.js → chunk-rs1wbvy6.js} +1 -1
- package/dist/{chunk-88ppkr54.js → chunk-rte5sm3z.js} +26 -2
- package/dist/chunk-rte5sm3z.js.map +12 -0
- package/dist/{chunk-n8herkry.js → chunk-s31d0qmq.js} +57 -20
- package/dist/{chunk-n8herkry.js.map → chunk-s31d0qmq.js.map} +8 -7
- package/dist/{chunk-7pc8b818.js → chunk-sxwk41qa.js} +1 -1
- package/dist/{chunk-663csy96.js → chunk-t0jjkep3.js} +2 -1
- package/dist/chunk-t0jjkep3.js.map +10 -0
- package/dist/{chunk-c6qd89g5.js → chunk-tek1qwgm.js} +6 -6
- package/dist/{chunk-c6qd89g5.js.map → chunk-tek1qwgm.js.map} +1 -1
- package/dist/{chunk-jaj13078.js → chunk-tkdscva6.js} +3 -33
- package/dist/{chunk-jaj13078.js.map → chunk-tkdscva6.js.map} +3 -4
- package/dist/{chunk-5egfka8j.js → chunk-tycbzedm.js} +2 -2
- package/dist/{chunk-g9t3kdtx.js → chunk-x2yw73hy.js} +1 -1
- package/dist/{chunk-57r1cpxx.js → chunk-xc7hq65b.js} +3 -2
- package/dist/{chunk-57r1cpxx.js.map → chunk-xc7hq65b.js.map} +3 -3
- package/dist/chunk-xdf9yswn.js +133 -0
- package/dist/chunk-xdf9yswn.js.map +11 -0
- package/dist/execution/agent.js +29 -27
- package/dist/execution/agent.js.map +1 -1
- package/dist/execution/primitive.js +29 -27
- package/dist/execution/primitive.js.map +2 -2
- package/dist/execution/request.js +30 -28
- package/dist/execution/request.js.map +2 -2
- package/dist/http/index.js +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +60 -58
- package/dist/index.js.map +1 -1
- package/dist/lake-storage/types.d.ts +2 -1
- package/dist/lake-storage/types.d.ts.map +1 -1
- package/dist/materialization/model.d.ts +4 -0
- package/dist/materialization/model.d.ts.map +1 -1
- package/dist/materializer/edits/apply.d.ts +6 -1
- package/dist/materializer/edits/apply.d.ts.map +1 -1
- package/dist/materializer/edits/working-state.d.ts +2 -0
- package/dist/materializer/edits/working-state.d.ts.map +1 -1
- package/dist/materializer/effective/resolve.d.ts +3 -1
- package/dist/materializer/effective/resolve.d.ts.map +1 -1
- package/dist/materializer/execution/work-records.d.ts.map +1 -1
- package/dist/materializer/index.js +19 -17
- package/dist/materializer/index.js.map +1 -1
- package/dist/materializer/projections/replacement-plan.d.ts.map +1 -1
- package/dist/materializer/shared/normalize.d.ts.map +1 -1
- package/dist/models/index.d.ts +40 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/objects/execution.d.ts +6 -1
- package/dist/objects/execution.d.ts.map +1 -1
- package/dist/objects/index.js +21 -19
- package/dist/objects/index.js.map +1 -1
- package/dist/objects/link/endpoints.d.ts.map +1 -1
- package/dist/objects/query/executor.d.ts +1 -0
- package/dist/objects/query/executor.d.ts.map +1 -1
- package/dist/objects/query/explain.d.ts +1 -0
- package/dist/objects/query/explain.d.ts.map +1 -1
- package/dist/objects/query/index.d.ts +3 -1
- package/dist/objects/query/index.d.ts.map +1 -1
- package/dist/objects/query/index.js +30 -5
- package/dist/objects/query/index.js.map +1 -1
- package/dist/objects/query/ir.d.ts +14 -1
- package/dist/objects/query/ir.d.ts.map +1 -1
- package/dist/objects/query/links.d.ts +25 -0
- package/dist/objects/query/links.d.ts.map +1 -0
- package/dist/objects/query/normalize.d.ts.map +1 -1
- package/dist/objects/query/planner.d.ts.map +1 -1
- package/dist/objects/query/validate.d.ts +1 -0
- package/dist/objects/query/validate.d.ts.map +1 -1
- package/dist/pipelines/index.js +16 -15
- package/dist/pipelines/index.js.map +1 -1
- package/dist/projections/builders.d.ts +52 -10
- package/dist/projections/builders.d.ts.map +1 -1
- package/dist/projections/index.d.ts +2 -1
- package/dist/projections/index.d.ts.map +1 -1
- package/dist/projections/internal.d.ts +4 -1
- package/dist/projections/internal.d.ts.map +1 -1
- package/dist/projections/internal.js +22 -17
- package/dist/projections/internal.js.map +1 -1
- package/dist/projections/run-dispatch.d.ts +1 -0
- package/dist/projections/run-dispatch.d.ts.map +1 -1
- package/dist/projections/timestamp.d.ts +3 -0
- package/dist/projections/timestamp.d.ts.map +1 -0
- package/dist/projections/types.d.ts +21 -9
- package/dist/projections/types.d.ts.map +1 -1
- package/dist/projections/validation.d.ts +6 -5
- package/dist/projections/validation.d.ts.map +1 -1
- package/dist/query.d.ts +2 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +2 -2
- package/dist/queues/index.d.ts +1 -1
- package/dist/queues/index.d.ts.map +1 -1
- package/dist/queues/types.d.ts +7 -0
- package/dist/queues/types.d.ts.map +1 -1
- package/dist/runtime/ai-cost.d.ts +8 -0
- package/dist/runtime/ai-cost.d.ts.map +1 -0
- package/dist/runtime/create.d.ts +3 -0
- package/dist/runtime/create.d.ts.map +1 -1
- package/dist/runtime/definitions.d.ts +3 -0
- package/dist/runtime/definitions.d.ts.map +1 -1
- package/dist/runtime/host.d.ts +2 -0
- package/dist/runtime/host.d.ts.map +1 -1
- package/dist/runtime/resolve-definitions.d.ts +2 -0
- package/dist/runtime/resolve-definitions.d.ts.map +1 -1
- package/dist/storage/agents/in-memory.d.ts +22 -4
- 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 +31 -0
- package/dist/storage/agents/provider.d.ts.map +1 -1
- package/dist/storage/agents/provider.js +22 -7
- package/dist/storage/agents/provider.js.map +1 -1
- package/dist/storage/agents/types.d.ts +75 -4
- package/dist/storage/agents/types.d.ts.map +1 -1
- package/dist/storage/ai-cost/analytics.d.ts +61 -0
- package/dist/storage/ai-cost/analytics.d.ts.map +1 -0
- package/dist/storage/ai-cost/codec.d.ts +14 -0
- package/dist/storage/ai-cost/codec.d.ts.map +1 -0
- package/dist/storage/ai-cost/errors.d.ts +7 -0
- package/dist/storage/ai-cost/errors.d.ts.map +1 -0
- package/dist/storage/ai-cost/in-memory.d.ts +32 -0
- package/dist/storage/ai-cost/in-memory.d.ts.map +1 -0
- package/dist/storage/ai-cost/index.d.ts +6 -0
- package/dist/storage/ai-cost/index.d.ts.map +1 -0
- package/dist/storage/ai-cost/provider.d.ts +7 -0
- package/dist/storage/ai-cost/provider.d.ts.map +1 -0
- package/dist/storage/ai-cost/provider.js +132 -0
- package/dist/storage/ai-cost/provider.js.map +10 -0
- package/dist/storage/ai-cost/types.d.ts +154 -0
- package/dist/storage/ai-cost/types.d.ts.map +1 -0
- package/dist/storage/ai-cost/validation.d.ts +7 -0
- package/dist/storage/ai-cost/validation.d.ts.map +1 -0
- package/dist/storage/ai-usage/in-memory.d.ts +2 -1
- package/dist/storage/ai-usage/in-memory.d.ts.map +1 -1
- package/dist/storage/ai-usage/index.d.ts +1 -1
- package/dist/storage/ai-usage/index.d.ts.map +1 -1
- package/dist/storage/ai-usage/types.d.ts +6 -0
- package/dist/storage/ai-usage/types.d.ts.map +1 -1
- package/dist/storage/in-memory/index.d.ts +5 -0
- package/dist/storage/in-memory/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +6 -3
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +33 -21
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/objects/in-memory.d.ts +6 -3
- package/dist/storage/objects/in-memory.d.ts.map +1 -1
- package/dist/storage/objects/index.d.ts +3 -1
- package/dist/storage/objects/index.d.ts.map +1 -1
- package/dist/storage/objects/keys.d.ts +16 -0
- package/dist/storage/objects/keys.d.ts.map +1 -0
- package/dist/storage/objects/types.d.ts +33 -6
- package/dist/storage/objects/types.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/materializations.d.ts.map +1 -1
- package/dist/storage/ontology/materializations.d.ts +3 -0
- package/dist/storage/ontology/materializations.d.ts.map +1 -1
- package/dist/storage/ontology/provider.js +1 -1
- package/dist/storage/operation-scope.d.ts.map +1 -1
- package/dist/storage/operation-scope.js +1 -1
- package/dist/storage/types.d.ts +2 -0
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/storage/workflow-runs/provider.js +10 -5
- package/dist/storage/workflow-runs/provider.js.map +1 -1
- package/dist/syncs/index.js +16 -15
- package/dist/syncs/index.js.map +1 -1
- package/dist/testing/agent-storage-contract.d.ts +3 -2
- package/dist/testing/agent-storage-contract.d.ts.map +1 -1
- package/dist/testing/ai-cost-storage-contract.d.ts +12 -0
- package/dist/testing/ai-cost-storage-contract.d.ts.map +1 -0
- package/dist/testing/ai-usage-storage-contract.d.ts.map +1 -1
- package/dist/testing/effective-storage-contract.d.ts +1 -1
- package/dist/testing/effective-storage-contract.d.ts.map +1 -1
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +2525 -1480
- package/dist/testing/index.js.map +10 -9
- package/dist/testing/lake-storage-contract.d.ts.map +1 -1
- package/dist/testing/materializer-storage-contract.d.ts.map +1 -1
- package/dist/testing/object-query-contract.d.ts +1 -1
- package/dist/testing/object-query-contract.d.ts.map +1 -1
- package/dist/webhooks/internal.js +14 -13
- package/dist/webhooks/internal.js.map +2 -2
- package/dist/workers/index.js +12 -2
- package/dist/workers/index.js.map +3 -3
- package/dist/workers/queue-worker.d.ts +2 -0
- package/dist/workers/queue-worker.d.ts.map +1 -1
- package/dist/workflows/execution.d.ts +3 -0
- package/dist/workflows/execution.d.ts.map +1 -1
- package/dist/workflows/index.js +30 -28
- package/dist/workflows/index.js.map +1 -1
- package/package.json +7 -1
- package/src/agents/adapters.ts +64 -23
- package/src/agents/builders.ts +3 -3
- package/src/agents/context-compaction.ts +261 -0
- package/src/agents/errors.ts +2 -2
- package/src/agents/execution.ts +14 -2
- package/src/agents/ids.ts +5 -0
- package/src/agents/index.ts +32 -6
- package/src/agents/request.ts +5 -0
- package/src/agents/streams.ts +56 -0
- package/src/agents/thread-context-projection.ts +93 -0
- package/src/agents/tool-definition.ts +17 -2
- package/src/agents/tool-result.ts +61 -0
- package/src/agents/types.ts +57 -1
- package/src/agents/validation.ts +36 -6
- package/src/http/api-routes.ts +7 -7
- package/src/index.ts +27 -0
- package/src/lake-storage/types.ts +2 -1
- package/src/materialization/model.ts +4 -0
- package/src/materializer/edits/apply.ts +55 -2
- package/src/materializer/edits/operations.ts +8 -1
- package/src/materializer/edits/working-state.ts +7 -0
- package/src/materializer/effective/resolve.ts +78 -9
- package/src/materializer/execution/work-records.ts +3 -1
- package/src/materializer/projections/entry-validator.ts +23 -1
- package/src/materializer/projections/replacement-plan.ts +2 -0
- package/src/materializer/shared/normalize.ts +16 -0
- package/src/materializer/telemetry/append.ts +33 -16
- package/src/models/index.ts +71 -0
- package/src/objects/execution.ts +20 -0
- package/src/objects/link/endpoints.ts +2 -1
- package/src/objects/query/executor.ts +42 -11
- package/src/objects/query/explain.ts +11 -0
- package/src/objects/query/index.ts +6 -0
- package/src/objects/query/ir.ts +16 -0
- package/src/objects/query/links.ts +308 -0
- package/src/objects/query/normalize.ts +40 -1
- package/src/objects/query/planner.ts +5 -0
- package/src/objects/query/validate.ts +58 -2
- package/src/projections/builders.ts +320 -50
- package/src/projections/index.ts +7 -0
- package/src/projections/internal.ts +4 -1
- package/src/projections/ownership.ts +5 -5
- package/src/projections/registry.ts +16 -3
- package/src/projections/revision.ts +35 -5
- package/src/projections/run-dispatch.ts +10 -1
- package/src/projections/timestamp.ts +66 -0
- package/src/projections/types.ts +20 -9
- package/src/projections/validation.ts +85 -19
- package/src/query.ts +2 -0
- package/src/queues/index.ts +1 -0
- package/src/queues/types.ts +8 -0
- package/src/runtime/ai-cost.ts +15 -0
- package/src/runtime/create.ts +4 -0
- package/src/runtime/definitions.ts +3 -0
- package/src/runtime/host.ts +2 -0
- package/src/runtime/resolve-definitions.ts +28 -0
- package/src/storage/agents/in-memory.ts +186 -4
- package/src/storage/agents/index.ts +5 -0
- package/src/storage/agents/provider.ts +225 -0
- package/src/storage/agents/types.ts +82 -3
- package/src/storage/ai-cost/analytics.ts +602 -0
- package/src/storage/ai-cost/codec.ts +136 -0
- package/src/storage/ai-cost/errors.ts +12 -0
- package/src/storage/ai-cost/in-memory.ts +164 -0
- package/src/storage/ai-cost/index.ts +35 -0
- package/src/storage/ai-cost/provider.ts +20 -0
- package/src/storage/ai-cost/types.ts +193 -0
- package/src/storage/ai-cost/validation.ts +337 -0
- package/src/storage/ai-usage/in-memory.ts +23 -0
- package/src/storage/ai-usage/index.ts +1 -0
- package/src/storage/ai-usage/types.ts +10 -0
- package/src/storage/in-memory/index.ts +50 -0
- package/src/storage/index.ts +48 -0
- package/src/storage/objects/in-memory.ts +103 -16
- package/src/storage/objects/index.ts +9 -0
- package/src/storage/objects/keys.ts +36 -0
- package/src/storage/objects/types.ts +34 -6
- package/src/storage/ontology/in-memory/materializations.ts +1 -0
- package/src/storage/ontology/materializations.ts +3 -0
- package/src/storage/ontology/provider-header-validation.ts +2 -2
- package/src/storage/operation-scope.ts +1 -0
- package/src/storage/types.ts +2 -0
- package/src/testing/agent-storage-contract.ts +353 -2
- package/src/testing/ai-cost-storage-contract.ts +320 -0
- package/src/testing/ai-usage-storage-contract.ts +35 -0
- package/src/testing/effective-storage-contract.ts +194 -4
- package/src/testing/index.ts +5 -0
- package/src/testing/lake-storage-contract.ts +56 -0
- package/src/testing/materializer-storage-contract.ts +120 -2
- package/src/testing/object-query-contract.ts +208 -1
- package/src/workers/queue-worker.ts +14 -1
- package/src/workflows/execution.ts +31 -10
- package/dist/agents/prompt.d.ts +0 -15
- package/dist/agents/prompt.d.ts.map +0 -1
- package/dist/chunk-0mbx247x.js.map +0 -43
- package/dist/chunk-34bqh420.js.map +0 -23
- package/dist/chunk-57zpb99z.js.map +0 -10
- package/dist/chunk-663csy96.js.map +0 -10
- package/dist/chunk-6wetht33.js +0 -89
- package/dist/chunk-6wetht33.js.map +0 -10
- package/dist/chunk-88ppkr54.js.map +0 -12
- package/dist/chunk-nnyp53zt.js.map +0 -13
- package/dist/chunk-nten49ta.js.map +0 -12
- package/dist/chunk-st4xgxey.js.map +0 -45
- package/dist/chunk-vp1vc6ee.js +0 -35
- package/dist/chunk-vp1vc6ee.js.map +0 -11
- package/src/agents/prompt.ts +0 -57
- /package/dist/{chunk-sa4340y1.js.map → chunk-1yz3x65y.js.map} +0 -0
- /package/dist/{chunk-gqdd7508.js.map → chunk-4rh2m6zg.js.map} +0 -0
- /package/dist/{chunk-4x43bkbp.js.map → chunk-a09jx26t.js.map} +0 -0
- /package/dist/{chunk-zg9yryhz.js.map → chunk-cbkm2vam.js.map} +0 -0
- /package/dist/{chunk-8ryen3p3.js.map → chunk-f6erf2vv.js.map} +0 -0
- /package/dist/{chunk-bct7hmfc.js.map → chunk-g13869yf.js.map} +0 -0
- /package/dist/{chunk-0k4avqr2.js.map → chunk-hbeh8j9w.js.map} +0 -0
- /package/dist/{chunk-qvybnnpe.js.map → chunk-nzw7sm3b.js.map} +0 -0
- /package/dist/{chunk-bh6k3nc6.js.map → chunk-rs1wbvy6.js.map} +0 -0
- /package/dist/{chunk-7pc8b818.js.map → chunk-sxwk41qa.js.map} +0 -0
- /package/dist/{chunk-5egfka8j.js.map → chunk-tycbzedm.js.map} +0 -0
- /package/dist/{chunk-g9t3kdtx.js.map → chunk-x2yw73hy.js.map} +0 -0
|
@@ -241,6 +241,13 @@ function cloneObjectProjectionDefinition(
|
|
|
241
241
|
},
|
|
242
242
|
])
|
|
243
243
|
),
|
|
244
|
+
conflictResolution:
|
|
245
|
+
projection.conflictResolution?.strategy === "mostRecent"
|
|
246
|
+
? {
|
|
247
|
+
strategy: "mostRecent",
|
|
248
|
+
sourceTimestamp: projection.conflictResolution.sourceTimestamp,
|
|
249
|
+
}
|
|
250
|
+
: { strategy: "editsWin" },
|
|
244
251
|
}
|
|
245
252
|
}
|
|
246
253
|
|
|
@@ -266,12 +273,18 @@ function cloneTelemetryProjectionDefinition(
|
|
|
266
273
|
_tag: "TelemetryProjectionDefinition",
|
|
267
274
|
id: projection.id,
|
|
268
275
|
objectTypeId: projection.objectTypeId,
|
|
269
|
-
propertyId: projection.propertyId,
|
|
270
276
|
datasetId: projection.datasetId,
|
|
271
277
|
objectIdField: projection.objectIdField,
|
|
272
278
|
atField: projection.atField,
|
|
273
|
-
|
|
274
|
-
|
|
279
|
+
properties: Object.fromEntries(
|
|
280
|
+
Object.entries(projection.properties).map(([propertyId, mapping]) => [
|
|
281
|
+
propertyId,
|
|
282
|
+
{
|
|
283
|
+
valueField: mapping.valueField,
|
|
284
|
+
...(mapping.unitField !== undefined ? { unitField: mapping.unitField } : {}),
|
|
285
|
+
},
|
|
286
|
+
])
|
|
287
|
+
),
|
|
275
288
|
}
|
|
276
289
|
}
|
|
277
290
|
|
|
@@ -147,6 +147,7 @@ function normalizeProjectionDefinition(projection: ProjectionDefinition): JsonVa
|
|
|
147
147
|
},
|
|
148
148
|
])
|
|
149
149
|
),
|
|
150
|
+
conflictResolution: projection.conflictResolution ?? { strategy: "editsWin" },
|
|
150
151
|
}
|
|
151
152
|
}
|
|
152
153
|
if (projection._tag === "LinkProjectionDefinition") {
|
|
@@ -159,14 +160,38 @@ function normalizeProjectionDefinition(projection: ProjectionDefinition): JsonVa
|
|
|
159
160
|
targetField: projection.targetField,
|
|
160
161
|
}
|
|
161
162
|
}
|
|
163
|
+
const properties = Object.entries(projection.properties).sort(([left], [right]) =>
|
|
164
|
+
compareStrings(left, right)
|
|
165
|
+
)
|
|
166
|
+
if (properties.length === 1) {
|
|
167
|
+
const [propertyId, mapping] = properties[0]
|
|
168
|
+
// Preserve the pre-grouping semantic hash for one-property projections. The authoring form and
|
|
169
|
+
// lowered shape changed, but the source semantics did not; keeping the hash stable prevents a
|
|
170
|
+
// deployment from invalidating queued jobs or replaying completed dataset versions.
|
|
171
|
+
return {
|
|
172
|
+
kind: "telemetry",
|
|
173
|
+
objectTypeId: projection.objectTypeId,
|
|
174
|
+
propertyId,
|
|
175
|
+
objectIdField: projection.objectIdField,
|
|
176
|
+
atField: projection.atField,
|
|
177
|
+
valueField: mapping.valueField,
|
|
178
|
+
unitField: mapping.unitField ?? null,
|
|
179
|
+
}
|
|
180
|
+
}
|
|
162
181
|
return {
|
|
163
182
|
kind: "telemetry",
|
|
164
183
|
objectTypeId: projection.objectTypeId,
|
|
165
|
-
propertyId: projection.propertyId,
|
|
166
184
|
objectIdField: projection.objectIdField,
|
|
167
185
|
atField: projection.atField,
|
|
168
|
-
|
|
169
|
-
|
|
186
|
+
properties: Object.fromEntries(
|
|
187
|
+
properties.map(([propertyId, mapping]) => [
|
|
188
|
+
propertyId,
|
|
189
|
+
{
|
|
190
|
+
valueField: mapping.valueField,
|
|
191
|
+
unitField: mapping.unitField ?? null,
|
|
192
|
+
},
|
|
193
|
+
])
|
|
194
|
+
),
|
|
170
195
|
}
|
|
171
196
|
}
|
|
172
197
|
|
|
@@ -177,6 +202,9 @@ function projectionColumns(projection: ProjectionDefinition): Set<string> {
|
|
|
177
202
|
...Object.values(projection.links).flatMap((link) =>
|
|
178
203
|
link.sourceField === undefined ? [] : [link.sourceField]
|
|
179
204
|
),
|
|
205
|
+
...(projection.conflictResolution?.strategy === "mostRecent"
|
|
206
|
+
? [projection.conflictResolution.sourceTimestamp]
|
|
207
|
+
: []),
|
|
180
208
|
])
|
|
181
209
|
}
|
|
182
210
|
if (projection._tag === "LinkProjectionDefinition") {
|
|
@@ -185,8 +213,10 @@ function projectionColumns(projection: ProjectionDefinition): Set<string> {
|
|
|
185
213
|
return new Set([
|
|
186
214
|
projection.objectIdField,
|
|
187
215
|
projection.atField,
|
|
188
|
-
projection.
|
|
189
|
-
|
|
216
|
+
...Object.values(projection.properties).flatMap((mapping) => [
|
|
217
|
+
mapping.valueField,
|
|
218
|
+
...(mapping.unitField === undefined ? [] : [mapping.unitField]),
|
|
219
|
+
]),
|
|
190
220
|
])
|
|
191
221
|
}
|
|
192
222
|
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
type ProjectionRunFailureCode,
|
|
24
24
|
} from "./types"
|
|
25
25
|
|
|
26
|
+
/** Target maximum mapped points per telemetry commit; a single-property projection reads 500 rows. */
|
|
26
27
|
export const PROJECTION_TELEMETRY_BATCH_SIZE = 500
|
|
27
28
|
|
|
28
29
|
export interface ProjectionRunDispatchInput {
|
|
@@ -403,11 +404,19 @@ function queueProjectionRun(
|
|
|
403
404
|
...common,
|
|
404
405
|
identity: input.identity,
|
|
405
406
|
target: { objectTypeId: input.projection.objectTypeId },
|
|
406
|
-
fixedBatchSize:
|
|
407
|
+
fixedBatchSize: telemetryProjectionBatchRowCount(input.projection),
|
|
407
408
|
})
|
|
408
409
|
}
|
|
409
410
|
}
|
|
410
411
|
|
|
412
|
+
function telemetryProjectionBatchRowCount(
|
|
413
|
+
projection: Extract<ProjectionDefinition, { readonly _tag: "TelemetryProjectionDefinition" }>
|
|
414
|
+
): number {
|
|
415
|
+
const mappedPropertyCount = Object.keys(projection.properties).length
|
|
416
|
+
if (mappedPropertyCount === 0) throw invalidProjectionDefinition(projection.id)
|
|
417
|
+
return Math.max(1, Math.floor(PROJECTION_TELEMETRY_BATCH_SIZE / mappedPropertyCount))
|
|
418
|
+
}
|
|
419
|
+
|
|
411
420
|
function requeueProjectionRun(
|
|
412
421
|
storage: NonNullable<Storage["projectionRuns"]>,
|
|
413
422
|
run: ProjectionRunRecord,
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
const DATASET_TIMESTAMP =
|
|
2
|
+
/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[ T](\d{1,2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?)?([zZ]|[+-]\d{2}:?\d{2})?$/
|
|
3
|
+
|
|
4
|
+
interface TimestampComponents {
|
|
5
|
+
readonly year: number
|
|
6
|
+
readonly month: number
|
|
7
|
+
readonly day: number
|
|
8
|
+
readonly hour: number
|
|
9
|
+
readonly minute: number
|
|
10
|
+
readonly second: number
|
|
11
|
+
readonly milliseconds: number
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Parses a projection dataset timestamp, interpreting zone-less values as UTC. */
|
|
15
|
+
export function parseDatasetTimestamp(value: unknown): Date | null {
|
|
16
|
+
if (value instanceof Date) return Number.isNaN(value.getTime()) ? null : value
|
|
17
|
+
if (typeof value !== "string") return null
|
|
18
|
+
|
|
19
|
+
const match = DATASET_TIMESTAMP.exec(value.trim())
|
|
20
|
+
if (!match) return null
|
|
21
|
+
const [, year, month, day, hour, minute, second, fraction, zone] = match
|
|
22
|
+
const offsetMinutes = parseZoneOffsetMinutes(zone)
|
|
23
|
+
if (offsetMinutes === null) return null
|
|
24
|
+
|
|
25
|
+
const components: TimestampComponents = {
|
|
26
|
+
year: Number(year),
|
|
27
|
+
month: Number(month),
|
|
28
|
+
day: Number(day),
|
|
29
|
+
hour: hour === undefined ? 0 : Number(hour),
|
|
30
|
+
minute: minute === undefined ? 0 : Number(minute),
|
|
31
|
+
second: second === undefined ? 0 : Number(second),
|
|
32
|
+
milliseconds: fraction === undefined ? 0 : Math.trunc(Number(`0.${fraction}`) * 1000),
|
|
33
|
+
}
|
|
34
|
+
const wallClock = Date.UTC(
|
|
35
|
+
components.year,
|
|
36
|
+
components.month - 1,
|
|
37
|
+
components.day,
|
|
38
|
+
components.hour,
|
|
39
|
+
components.minute,
|
|
40
|
+
components.second,
|
|
41
|
+
components.milliseconds
|
|
42
|
+
)
|
|
43
|
+
if (!wallClockMatchesComponents(wallClock, components)) return null
|
|
44
|
+
return new Date(wallClock - offsetMinutes * 60_000)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function parseZoneOffsetMinutes(zone: string | undefined): number | null {
|
|
48
|
+
if (zone === undefined || zone === "Z" || zone === "z") return 0
|
|
49
|
+
const digits = zone.slice(1).replace(":", "")
|
|
50
|
+
const hours = Number(digits.slice(0, 2))
|
|
51
|
+
const minutes = Number(digits.slice(2, 4))
|
|
52
|
+
if (hours > 23 || minutes > 59) return null
|
|
53
|
+
return (zone[0] === "-" ? -1 : 1) * (hours * 60 + minutes)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function wallClockMatchesComponents(wallClock: number, components: TimestampComponents): boolean {
|
|
57
|
+
const date = new Date(wallClock)
|
|
58
|
+
return (
|
|
59
|
+
date.getUTCFullYear() === components.year &&
|
|
60
|
+
date.getUTCMonth() === components.month - 1 &&
|
|
61
|
+
date.getUTCDate() === components.day &&
|
|
62
|
+
date.getUTCHours() === components.hour &&
|
|
63
|
+
date.getUTCMinutes() === components.minute &&
|
|
64
|
+
date.getUTCSeconds() === components.second
|
|
65
|
+
)
|
|
66
|
+
}
|
package/src/projections/types.ts
CHANGED
|
@@ -39,6 +39,11 @@ export interface ForeignKeyDescriptor {
|
|
|
39
39
|
readonly targetObjectTypeId: string
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
/** Resolves competing source-projection and managed-edit values for projected properties. */
|
|
43
|
+
export type SourceEditConflictResolution =
|
|
44
|
+
| { readonly strategy: "editsWin" }
|
|
45
|
+
| { readonly strategy: "mostRecent"; readonly sourceTimestamp: string }
|
|
46
|
+
|
|
42
47
|
/**
|
|
43
48
|
* Lowered, serializable definition for projecting a dataset into object instances.
|
|
44
49
|
*
|
|
@@ -56,6 +61,8 @@ export interface ObjectProjectionDefinition {
|
|
|
56
61
|
readonly properties: Readonly<Record<string, string>>
|
|
57
62
|
/** Maps link id -> FK descriptor. Empty `{}` when no FK links are projected. */
|
|
58
63
|
readonly links: Readonly<Record<string, ForeignKeyDescriptor>>
|
|
64
|
+
/** Defaults to `editsWin` when omitted by a legacy lowered definition. */
|
|
65
|
+
readonly conflictResolution?: SourceEditConflictResolution
|
|
59
66
|
}
|
|
60
67
|
|
|
61
68
|
/**
|
|
@@ -77,28 +84,32 @@ export interface LinkProjectionDefinition {
|
|
|
77
84
|
readonly targetField: string
|
|
78
85
|
}
|
|
79
86
|
|
|
87
|
+
/** Dataset columns that produce one telemetry property value. */
|
|
88
|
+
export interface TelemetryProjectionPropertyMapping {
|
|
89
|
+
/** Dataset column holding the telemetry value. */
|
|
90
|
+
readonly valueField: string
|
|
91
|
+
/** Dataset column holding the telemetry unit, when the property requires one. */
|
|
92
|
+
readonly unitField?: string
|
|
93
|
+
}
|
|
94
|
+
|
|
80
95
|
/**
|
|
81
96
|
* Lowered, serializable definition for projecting dataset rows into telemetry history.
|
|
82
97
|
*
|
|
83
|
-
* Each row
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* value, and optional unit.
|
|
98
|
+
* Each row shares one target object id and observation timestamp, then contributes up to one
|
|
99
|
+
* telemetry point for every mapped property. A property-token projection is lowered to the same
|
|
100
|
+
* shape with one entry, so execution and ownership have one canonical contract.
|
|
87
101
|
*/
|
|
88
102
|
export interface TelemetryProjectionDefinition {
|
|
89
103
|
readonly _tag: "TelemetryProjectionDefinition"
|
|
90
104
|
readonly id: string
|
|
91
105
|
readonly objectTypeId: string
|
|
92
|
-
readonly propertyId: string
|
|
93
106
|
readonly datasetId: string
|
|
94
107
|
/** Dataset column holding the target object's primary id. */
|
|
95
108
|
readonly objectIdField: string
|
|
96
109
|
/** Dataset column holding the telemetry observation timestamp. */
|
|
97
110
|
readonly atField: string
|
|
98
|
-
/**
|
|
99
|
-
readonly
|
|
100
|
-
/** Dataset column holding the telemetry unit, when the property requires one. */
|
|
101
|
-
readonly unitField?: string
|
|
111
|
+
/** Maps telemetry property id -> value and optional unit dataset columns. */
|
|
112
|
+
readonly properties: Readonly<Record<string, TelemetryProjectionPropertyMapping>>
|
|
102
113
|
}
|
|
103
114
|
|
|
104
115
|
/** Union of all projection definition types. */
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
import type { DatasetDefinition } from "../datasets"
|
|
9
9
|
import type { OntologyDefinitionCatalog } from "../ontology"
|
|
10
|
-
import type { ObjectType, Property } from "../ontology/types"
|
|
10
|
+
import type { ObjectType, Property, ValueType } from "../ontology/types"
|
|
11
|
+
import { resolveSemanticType } from "../ontology/validation"
|
|
11
12
|
import { ProjectionValidationError } from "./errors"
|
|
12
13
|
import {
|
|
13
14
|
computeProjectionOwnership,
|
|
@@ -196,37 +197,29 @@ export function validateLinkProjectionTarget(linkToken: {
|
|
|
196
197
|
|
|
197
198
|
/**
|
|
198
199
|
* Validates a telemetry projection's field mapping against its dataset columns
|
|
199
|
-
* and object type:
|
|
200
|
+
* and object type: every mapped property exists and is telemetry-enabled, and
|
|
200
201
|
* every mapped field (objectId/at/value/unit) resolves to a real dataset column.
|
|
201
202
|
*
|
|
202
203
|
* Owned here so startup validation and the projection worker's pre-execution
|
|
203
204
|
* check share one implementation and cannot drift; the worker layers
|
|
204
205
|
* dataset-version column type compatibility on top of these rules. Returns the
|
|
205
|
-
* resolved telemetry
|
|
206
|
+
* resolved telemetry properties for callers that need their schemas.
|
|
206
207
|
*/
|
|
207
208
|
export function validateTelemetryProjectionFieldMapping(
|
|
208
209
|
projection: TelemetryProjectionDefinition,
|
|
209
210
|
objectType: { readonly id: string; readonly properties: readonly Property[] },
|
|
210
211
|
datasetColumnNames: ReadonlySet<string>,
|
|
212
|
+
valueTypesById: ReadonlyMap<string, ValueType>,
|
|
211
213
|
prefix: string
|
|
212
|
-
): Property {
|
|
213
|
-
const
|
|
214
|
-
if (
|
|
215
|
-
throw new ProjectionValidationError(
|
|
216
|
-
`${prefix}: unknown property "${projection.propertyId}" on type "${projection.objectTypeId}"`
|
|
217
|
-
)
|
|
218
|
-
}
|
|
219
|
-
if (property.mode !== "telemetry") {
|
|
220
|
-
throw new ProjectionValidationError(
|
|
221
|
-
`${prefix}: property "${projection.propertyId}" on type "${projection.objectTypeId}" must be telemetry-enabled`
|
|
222
|
-
)
|
|
214
|
+
): ReadonlyMap<string, Property> {
|
|
215
|
+
const mappedProperties = Object.entries(projection.properties)
|
|
216
|
+
if (mappedProperties.length === 0) {
|
|
217
|
+
throw new ProjectionValidationError(`${prefix}: must map at least one telemetry property`)
|
|
223
218
|
}
|
|
224
219
|
|
|
225
220
|
const mappedFields = [
|
|
226
221
|
["objectId", projection.objectIdField],
|
|
227
222
|
["at", projection.atField],
|
|
228
|
-
["value", projection.valueField],
|
|
229
|
-
...(projection.unitField !== undefined ? ([["unit", projection.unitField]] as const) : []),
|
|
230
223
|
] as const
|
|
231
224
|
for (const [fieldRole, columnName] of mappedFields) {
|
|
232
225
|
if (!datasetColumnNames.has(columnName)) {
|
|
@@ -237,7 +230,49 @@ export function validateTelemetryProjectionFieldMapping(
|
|
|
237
230
|
}
|
|
238
231
|
}
|
|
239
232
|
|
|
240
|
-
|
|
233
|
+
const propertiesById = new Map(objectType.properties.map((property) => [property.id, property]))
|
|
234
|
+
const resolvedProperties = new Map<string, Property>()
|
|
235
|
+
for (const [propertyId, mapping] of mappedProperties) {
|
|
236
|
+
const property = propertiesById.get(propertyId)
|
|
237
|
+
if (!property) {
|
|
238
|
+
throw new ProjectionValidationError(
|
|
239
|
+
`${prefix}: unknown property "${propertyId}" on type "${projection.objectTypeId}"`
|
|
240
|
+
)
|
|
241
|
+
}
|
|
242
|
+
if (property.mode !== "telemetry") {
|
|
243
|
+
throw new ProjectionValidationError(
|
|
244
|
+
`${prefix}: property "${propertyId}" on type "${projection.objectTypeId}" must be telemetry-enabled`
|
|
245
|
+
)
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
for (const [fieldRole, columnName] of [
|
|
249
|
+
["value", mapping.valueField],
|
|
250
|
+
...(mapping.unitField !== undefined ? ([["unit", mapping.unitField]] as const) : []),
|
|
251
|
+
] as const) {
|
|
252
|
+
if (!datasetColumnNames.has(columnName)) {
|
|
253
|
+
throw new ProjectionValidationError(
|
|
254
|
+
`${prefix}: property "${propertyId}" ${fieldRole} field "${columnName}" references ` +
|
|
255
|
+
`unknown dataset column on dataset "${projection.datasetId}"`
|
|
256
|
+
)
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
const semanticType = resolveSemanticType(property, valueTypesById)
|
|
261
|
+
if (semanticType !== undefined && mapping.unitField === undefined) {
|
|
262
|
+
throw new ProjectionValidationError(
|
|
263
|
+
`${prefix}: property "${propertyId}" requires a unit field because it uses semantic type "${semanticType}"`
|
|
264
|
+
)
|
|
265
|
+
}
|
|
266
|
+
if (semanticType === undefined && mapping.unitField !== undefined) {
|
|
267
|
+
throw new ProjectionValidationError(
|
|
268
|
+
`${prefix}: property "${propertyId}" cannot map a unit field because it has no semantic type`
|
|
269
|
+
)
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
resolvedProperties.set(propertyId, property)
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
return resolvedProperties
|
|
241
276
|
}
|
|
242
277
|
|
|
243
278
|
/**
|
|
@@ -262,8 +297,9 @@ export function validateTelemetryProjectionFieldMapping(
|
|
|
262
297
|
* For telemetry projections:
|
|
263
298
|
* 1. `datasetId` exists in the dataset registry.
|
|
264
299
|
* 2. `objectTypeId` exists in the type registry.
|
|
265
|
-
* 3.
|
|
300
|
+
* 3. Every mapped property exists on the object type and is telemetry-enabled.
|
|
266
301
|
* 4. Point mapping fields exist in the referenced dataset.
|
|
302
|
+
* 5. Unit mappings match each property's semantic type requirements.
|
|
267
303
|
*/
|
|
268
304
|
export interface ValidatedProjectionRecord<TDefinition extends ProjectionDefinition>
|
|
269
305
|
extends ProjectionOwnershipRecord<TDefinition> {
|
|
@@ -315,6 +351,30 @@ export function validateProjectionsAtStartup(
|
|
|
315
351
|
}
|
|
316
352
|
|
|
317
353
|
const datasetColumnNames = new Set(dataset.schema.columns.map((column) => column.name))
|
|
354
|
+
const conflictResolution = projection.conflictResolution ?? { strategy: "editsWin" }
|
|
355
|
+
if (conflictResolution.strategy === "mostRecent") {
|
|
356
|
+
const sourceTimestamp = dataset.schema.columns.find(
|
|
357
|
+
(column) => column.name === conflictResolution.sourceTimestamp
|
|
358
|
+
)
|
|
359
|
+
if (!sourceTimestamp) {
|
|
360
|
+
throw new ProjectionValidationError(
|
|
361
|
+
`${prefix}: source timestamp "${conflictResolution.sourceTimestamp}" references unknown ` +
|
|
362
|
+
`dataset column on dataset "${projection.datasetId}"`
|
|
363
|
+
)
|
|
364
|
+
}
|
|
365
|
+
if (sourceTimestamp.type !== "timestamp") {
|
|
366
|
+
throw new ProjectionValidationError(
|
|
367
|
+
`${prefix}: source timestamp "${conflictResolution.sourceTimestamp}" must reference a ` +
|
|
368
|
+
`timestamp dataset column`
|
|
369
|
+
)
|
|
370
|
+
}
|
|
371
|
+
if (sourceTimestamp.nullable === true) {
|
|
372
|
+
throw new ProjectionValidationError(
|
|
373
|
+
`${prefix}: source timestamp "${conflictResolution.sourceTimestamp}" must reference a ` +
|
|
374
|
+
`non-null timestamp dataset column`
|
|
375
|
+
)
|
|
376
|
+
}
|
|
377
|
+
}
|
|
318
378
|
const propertyIds = new Set(objectType.properties.map((p) => p.id))
|
|
319
379
|
for (const [propId, columnName] of Object.entries(projection.properties)) {
|
|
320
380
|
if (!propertyIds.has(propId)) {
|
|
@@ -488,7 +548,13 @@ export function validateProjectionsAtStartup(
|
|
|
488
548
|
}
|
|
489
549
|
|
|
490
550
|
const datasetColumnNames = new Set(dataset.schema.columns.map((column) => column.name))
|
|
491
|
-
validateTelemetryProjectionFieldMapping(
|
|
551
|
+
validateTelemetryProjectionFieldMapping(
|
|
552
|
+
projection,
|
|
553
|
+
objectType,
|
|
554
|
+
datasetColumnNames,
|
|
555
|
+
ontology.getValueTypesById(),
|
|
556
|
+
prefix
|
|
557
|
+
)
|
|
492
558
|
validatedTelemetryProjections.push({
|
|
493
559
|
definition: projection,
|
|
494
560
|
dataset,
|
package/src/query.ts
CHANGED
|
@@ -28,6 +28,7 @@ export type {
|
|
|
28
28
|
ObjectQueryPredicateIn,
|
|
29
29
|
ObjectQueryPredicateNot,
|
|
30
30
|
ObjectQueryProject,
|
|
31
|
+
ObjectQueryRefs,
|
|
31
32
|
ObjectQueryResultShape,
|
|
32
33
|
ObjectQuerySet,
|
|
33
34
|
ObjectQuerySetOperation,
|
|
@@ -50,6 +51,7 @@ export type {
|
|
|
50
51
|
ObjectQueryExecutorListResult,
|
|
51
52
|
ObjectQueryExecutorRow,
|
|
52
53
|
} from "./objects/sdk/query-executor"
|
|
54
|
+
export type { ObjectRef } from "./ontology/refs"
|
|
53
55
|
export type {
|
|
54
56
|
LinkToken,
|
|
55
57
|
ObjectTypeWithPropertyTokens,
|
package/src/queues/index.ts
CHANGED
package/src/queues/types.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { ProjectionRunFailureCode } from "../projections/types"
|
|
|
4
4
|
import type { ProviderScope } from "../provider-scope"
|
|
5
5
|
import type { ActionRunFailureCode } from "../storage/action-runs/types"
|
|
6
6
|
import type { AgentRunFailureCode } from "../storage/agents/types"
|
|
7
|
+
import type { AiPricingContext } from "../storage/ai-cost/types"
|
|
7
8
|
import type { RecordAiModelCallInput } from "../storage/ai-usage"
|
|
8
9
|
import type { PipelineRunFailureCode } from "../storage/pipeline-runs/types"
|
|
9
10
|
import type { SyncRunFailureCode } from "../storage/sync-runs/types"
|
|
@@ -209,11 +210,18 @@ export type AgentAiUsageRecordPayload = Omit<
|
|
|
209
210
|
readonly occurredAt: string
|
|
210
211
|
}
|
|
211
212
|
|
|
213
|
+
export interface AgentAiUsageAccountingPayload {
|
|
214
|
+
readonly pricingContext: AiPricingContext
|
|
215
|
+
readonly ratedAt: string
|
|
216
|
+
}
|
|
217
|
+
|
|
212
218
|
export interface AgentAiUsageRecordRequestedQueueJob
|
|
213
219
|
extends QueueJob<
|
|
214
220
|
"agent.ai-usage.record.requested",
|
|
215
221
|
{
|
|
216
222
|
readonly record: AgentAiUsageRecordPayload
|
|
223
|
+
/** Absent on Phase 1 jobs; recovery then uses an empty pricing context. */
|
|
224
|
+
readonly accounting?: AgentAiUsageAccountingPayload
|
|
217
225
|
}
|
|
218
226
|
> {}
|
|
219
227
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AiCostStorage, AiCostSummary } from "../storage/ai-cost"
|
|
2
|
+
|
|
3
|
+
/** Resolve preferred cost summaries in input order without inventing unavailable accounting. */
|
|
4
|
+
export async function resolveExecutionCosts(input: {
|
|
5
|
+
readonly storage: AiCostStorage | undefined
|
|
6
|
+
readonly projectId: string
|
|
7
|
+
readonly executionIds: readonly string[]
|
|
8
|
+
}): Promise<readonly (AiCostSummary | undefined)[]> {
|
|
9
|
+
if (input.executionIds.length === 0) return []
|
|
10
|
+
if (!input.storage) return input.executionIds.map(() => undefined)
|
|
11
|
+
return input.storage.summarizeExecutions({
|
|
12
|
+
projectId: input.projectId,
|
|
13
|
+
executionIds: input.executionIds,
|
|
14
|
+
})
|
|
15
|
+
}
|
package/src/runtime/create.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type { SixbErrorHandler } from "../error-reporting/types"
|
|
|
11
11
|
import type { LakeStorage } from "../lake-storage"
|
|
12
12
|
import type { LoggerProvider, ObservabilityOptions } from "../logging"
|
|
13
13
|
import type { OntologyMaintenanceOptions } from "../maintenance"
|
|
14
|
+
import type { ModelCatalogInput } from "../models"
|
|
14
15
|
import type { PipelineDefinition } from "../pipelines/types"
|
|
15
16
|
import type { ProjectionDefinition } from "../projections/types"
|
|
16
17
|
import type { Queues } from "../queues"
|
|
@@ -45,6 +46,8 @@ export interface CreateSixbOptions {
|
|
|
45
46
|
actions?: readonly ActionDefinition[]
|
|
46
47
|
/** Agent definitions to register in addition to auto-discovered `agents/` exports. */
|
|
47
48
|
agents?: readonly AgentDefinition[]
|
|
49
|
+
/** Models this project allows Sixb to use. The first of each kind is the default. */
|
|
50
|
+
models?: ModelCatalogInput
|
|
48
51
|
datasets?: readonly DatasetDefinition[]
|
|
49
52
|
/** Connector definitions to register in addition to auto-discovered `connectors/` exports. */
|
|
50
53
|
connectors?: readonly ConnectorDefinition[]
|
|
@@ -118,6 +121,7 @@ export async function createSixb(
|
|
|
118
121
|
roles: [...(options.roles ?? []), ...definitions.roles],
|
|
119
122
|
membershipPolicies: [...(options.membershipPolicies ?? []), ...definitions.membershipPolicies],
|
|
120
123
|
agents: [...(options.agents ?? []), ...definitions.agents],
|
|
124
|
+
models: options.models,
|
|
121
125
|
auth: options.auth,
|
|
122
126
|
})
|
|
123
127
|
}
|
|
@@ -2,6 +2,7 @@ import type { ActionDefinitionCatalog } from "../actions"
|
|
|
2
2
|
import type { AgentDefinition } from "../agents"
|
|
3
3
|
import type { ConnectorDefinition } from "../connectors"
|
|
4
4
|
import type { DatasetDefinition } from "../datasets"
|
|
5
|
+
import type { ModelCatalog } from "../models"
|
|
5
6
|
import type { OntologyDefinitionCatalog } from "../ontology"
|
|
6
7
|
import type { PipelineDefinition } from "../pipelines"
|
|
7
8
|
import type { ProjectionDefinitionCatalog } from "../projections"
|
|
@@ -24,6 +25,8 @@ export interface SixbDefinitions {
|
|
|
24
25
|
readonly agents: DefinitionCatalog<AgentDefinition>
|
|
25
26
|
readonly connectors: DefinitionCatalog<ConnectorDefinition>
|
|
26
27
|
readonly datasets: DefinitionCatalog<DatasetDefinition>
|
|
28
|
+
/** Absent until a project configures `models` in createSixb(). */
|
|
29
|
+
readonly models?: ModelCatalog
|
|
27
30
|
readonly pipelines: DefinitionCatalog<PipelineDefinition>
|
|
28
31
|
readonly projections: ProjectionDefinitionCatalog
|
|
29
32
|
readonly rules: DefinitionCatalog<RuleDefinition>
|
package/src/runtime/host.ts
CHANGED
|
@@ -48,6 +48,7 @@ import {
|
|
|
48
48
|
type SixbReadiness,
|
|
49
49
|
} from "../maintenance"
|
|
50
50
|
import { createOntologyMaterializer, type OntologyMaterializerContract } from "../materializer"
|
|
51
|
+
import type { ModelCatalogInput } from "../models"
|
|
51
52
|
import type { PipelineDefinition } from "../pipelines/types"
|
|
52
53
|
import { registerProjectionRegistry } from "../projections/internal"
|
|
53
54
|
import type { ProjectionDefinition } from "../projections/types"
|
|
@@ -108,6 +109,7 @@ export interface SixbHostOptions<TOntologySources extends readonly OntologySourc
|
|
|
108
109
|
rules?: readonly RuleDefinition[]
|
|
109
110
|
workflows?: readonly WorkflowDefinition[]
|
|
110
111
|
agents?: readonly AgentDefinition[]
|
|
112
|
+
models?: ModelCatalogInput
|
|
111
113
|
groups?: readonly GroupDefinition[]
|
|
112
114
|
roles?: readonly RoleDefinition[]
|
|
113
115
|
membershipPolicies?: readonly MembershipPolicyDefinition[]
|
|
@@ -5,6 +5,7 @@ import { validateAgentGroupReferences, validateAgentToolsAtStartup } from "../ag
|
|
|
5
5
|
import type { ConnectorDefinition } from "../connectors"
|
|
6
6
|
import type { DatasetDefinition } from "../datasets/types"
|
|
7
7
|
import { assertDatasetDefinition } from "../datasets/validation"
|
|
8
|
+
import { createModelCatalog, type ModelCatalog, type ModelCatalogInput, modelRef } from "../models"
|
|
8
9
|
import { OntologyRegistry } from "../ontology"
|
|
9
10
|
import type { PipelineDefinition } from "../pipelines/types"
|
|
10
11
|
import { ProjectionRegistry } from "../projections"
|
|
@@ -40,6 +41,7 @@ interface DefinitionOptions {
|
|
|
40
41
|
readonly rules?: readonly RuleDefinition[]
|
|
41
42
|
readonly workflows?: readonly WorkflowDefinition[]
|
|
42
43
|
readonly agents?: readonly AgentDefinition[]
|
|
44
|
+
readonly models?: ModelCatalogInput
|
|
43
45
|
readonly groups?: readonly GroupDefinition[]
|
|
44
46
|
readonly roles?: readonly RoleDefinition[]
|
|
45
47
|
readonly membershipPolicies?: readonly MembershipPolicyDefinition[]
|
|
@@ -60,6 +62,8 @@ export function resolveDefinitions(options: DefinitionOptions): ResolvedDefiniti
|
|
|
60
62
|
|
|
61
63
|
const agents = options.agents ?? []
|
|
62
64
|
validateAgentToolsAtStartup(agents)
|
|
65
|
+
const models = options.models === undefined ? undefined : createModelCatalog(options.models)
|
|
66
|
+
validateAgentModelReferences(agents, models)
|
|
63
67
|
const agentsById = indexUniqueDefinitions("agent", agents)
|
|
64
68
|
const connectorsById = indexUniqueDefinitions("connector", options.connectors ?? [])
|
|
65
69
|
|
|
@@ -158,6 +162,7 @@ export function resolveDefinitions(options: DefinitionOptions): ResolvedDefiniti
|
|
|
158
162
|
agents: createDefinitionCatalog(agentsById),
|
|
159
163
|
connectors: createDefinitionCatalog(connectorsById),
|
|
160
164
|
datasets: createDefinitionCatalog(datasetsById),
|
|
165
|
+
...(models === undefined ? {} : { models }),
|
|
161
166
|
pipelines: createDefinitionCatalog(pipelinesById),
|
|
162
167
|
projections: projectionRegistry,
|
|
163
168
|
rules: createDefinitionCatalog(rulesById),
|
|
@@ -236,3 +241,26 @@ function validateScheduleReferences(
|
|
|
236
241
|
}
|
|
237
242
|
}
|
|
238
243
|
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Keep every agent on a model the project actually allows.
|
|
247
|
+
*
|
|
248
|
+
* Only enforced once a project configures `models`; without a catalog an agent's model is its own
|
|
249
|
+
* declaration, which is the pre-catalog behavior.
|
|
250
|
+
*/
|
|
251
|
+
function validateAgentModelReferences(
|
|
252
|
+
agents: readonly AgentDefinition[],
|
|
253
|
+
models: ModelCatalog | undefined
|
|
254
|
+
): void {
|
|
255
|
+
if (models === undefined) {
|
|
256
|
+
return
|
|
257
|
+
}
|
|
258
|
+
for (const agent of agents) {
|
|
259
|
+
const ref = modelRef(agent.model)
|
|
260
|
+
if (models.language.getById(ref) === null) {
|
|
261
|
+
throw new RuntimeError(
|
|
262
|
+
`[Sixb] Agent '${agent.id}' uses unknown language model '${ref}'. Add it to 'models.language' in createSixb().`
|
|
263
|
+
)
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|