@sixb/core 0.1.1 → 0.1.3
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/README.md +31 -20
- package/dist/actions/commit-edits.d.ts +0 -2
- package/dist/actions/commit-edits.d.ts.map +1 -1
- package/dist/actions/execution.d.ts +21 -0
- package/dist/actions/execution.d.ts.map +1 -0
- package/dist/actions/index.d.ts +1 -1
- package/dist/actions/index.d.ts.map +1 -1
- package/dist/actions/index.js +38 -24
- package/dist/actions/index.js.map +1 -1
- package/dist/actions/registry.d.ts +16 -7
- package/dist/actions/registry.d.ts.map +1 -1
- package/dist/actions/request.d.ts +3 -2
- package/dist/actions/request.d.ts.map +1 -1
- package/dist/actions/run-dispatch.d.ts +21 -0
- package/dist/actions/run-dispatch.d.ts.map +1 -0
- package/dist/actions/types/context.d.ts +2 -2
- package/dist/actions/types/context.d.ts.map +1 -1
- package/dist/actions/validation.d.ts +1 -1
- package/dist/actions/validation.d.ts.map +1 -1
- package/dist/actions/worker.js +7 -7
- package/dist/actions/worker.js.map +1 -1
- package/dist/agents/adapters.d.ts +21 -1
- package/dist/agents/adapters.d.ts.map +1 -1
- package/dist/agents/authority.d.ts +31 -0
- package/dist/agents/authority.d.ts.map +1 -0
- package/dist/agents/context.js +2 -2
- package/dist/agents/dispatch.d.ts.map +1 -1
- package/dist/agents/errors.d.ts +2 -2
- package/dist/agents/errors.d.ts.map +1 -1
- package/dist/agents/execution.d.ts +48 -0
- package/dist/agents/execution.d.ts.map +1 -0
- package/dist/agents/index.d.ts +12 -9
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +77 -18
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/prompt.d.ts +8 -2
- package/dist/agents/prompt.d.ts.map +1 -1
- package/dist/agents/request.d.ts +6 -2
- package/dist/agents/request.d.ts.map +1 -1
- package/dist/agents/streams.d.ts +29 -3
- package/dist/agents/streams.d.ts.map +1 -1
- package/dist/agents/streams.js +22 -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 +39 -3
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/agents/validation.d.ts +3 -3
- package/dist/agents/validation.d.ts.map +1 -1
- package/dist/auth/attribution.d.ts +17 -0
- package/dist/auth/attribution.d.ts.map +1 -0
- package/dist/auth/index.d.ts +1 -0
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +11 -5
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/runtime.d.ts +4 -4
- package/dist/auth/runtime.d.ts.map +1 -1
- package/dist/authorization/decision.d.ts +24 -11
- package/dist/authorization/decision.d.ts.map +1 -1
- package/dist/authorization/grant-kinds.d.ts +2 -1
- 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 +8 -4
- package/dist/authorization/index.js.map +1 -1
- package/dist/blob-storage/browser.js +2 -2
- package/dist/blob-storage/execution.d.ts +16 -0
- package/dist/blob-storage/execution.d.ts.map +1 -0
- package/dist/blob-storage/index.js +3 -3
- package/dist/bootstrap/discovery.d.ts +90 -24
- package/dist/bootstrap/discovery.d.ts.map +1 -1
- package/dist/bootstrap/index.d.ts +2 -1
- package/dist/bootstrap/index.d.ts.map +1 -1
- package/dist/bootstrap/index.js +63 -60
- package/dist/bootstrap/index.js.map +1 -1
- package/dist/broker/in-memory.d.ts.map +1 -1
- package/dist/broker/index.js +2 -2
- package/dist/broker/types.d.ts +5 -0
- package/dist/broker/types.d.ts.map +1 -1
- package/dist/chunk-0172wgm9.js +333 -0
- package/dist/chunk-0172wgm9.js.map +11 -0
- package/dist/chunk-177ed2mp.js +3118 -0
- package/dist/chunk-177ed2mp.js.map +46 -0
- package/dist/chunk-1ywq4hzk.js +607 -0
- package/dist/chunk-1ywq4hzk.js.map +14 -0
- package/dist/chunk-261ag4t4.js +252 -0
- package/dist/chunk-261ag4t4.js.map +12 -0
- package/dist/{chunk-y2ygpd0m.js → chunk-3j7573mj.js} +2 -2
- package/dist/{chunk-y2ygpd0m.js.map → chunk-3j7573mj.js.map} +2 -2
- package/dist/{chunk-p7vj8xgb.js → chunk-3rsf30p4.js} +81 -58
- package/dist/chunk-3rsf30p4.js.map +35 -0
- package/dist/chunk-4aw0jwk0.js +118 -0
- package/dist/chunk-4aw0jwk0.js.map +10 -0
- package/dist/{chunk-md9jbrm9.js → chunk-4gz41why.js} +1 -1
- package/dist/chunk-4p9rh7jj.js +164 -0
- package/dist/chunk-4p9rh7jj.js.map +12 -0
- package/dist/chunk-4z3n1dzt.js +1206 -0
- package/dist/chunk-4z3n1dzt.js.map +23 -0
- package/dist/chunk-5gd7tpv6.js +28 -0
- package/dist/chunk-5gd7tpv6.js.map +11 -0
- package/dist/{chunk-867jxh7c.js → chunk-5sz8ta9r.js} +6 -295
- package/dist/chunk-5sz8ta9r.js.map +16 -0
- package/dist/chunk-62c7t4jc.js +27 -0
- package/dist/chunk-62c7t4jc.js.map +11 -0
- package/dist/chunk-63te770v.js.map +1 -1
- package/dist/{chunk-xz5g49bp.js → chunk-6gjqgd3d.js} +3 -1
- package/dist/chunk-6gjqgd3d.js.map +11 -0
- package/dist/{chunk-6rzdtvn5.js → chunk-8b55ygje.js} +1 -1
- package/dist/chunk-8m5ejdpn.js +33 -0
- package/dist/chunk-8m5ejdpn.js.map +10 -0
- package/dist/chunk-96swp2wd.js +47 -0
- package/dist/chunk-96swp2wd.js.map +10 -0
- package/dist/chunk-979ww6b3.js +298 -0
- package/dist/chunk-979ww6b3.js.map +12 -0
- package/dist/{chunk-ya6brh8a.js → chunk-9t8f5xfx.js} +10 -5
- package/dist/chunk-9t8f5xfx.js.map +11 -0
- package/dist/{chunk-r82k4z7z.js → chunk-a31h57d5.js} +2 -2
- package/dist/{chunk-t72dvahb.js → chunk-bhxaq2nn.js} +61 -44
- package/dist/chunk-bhxaq2nn.js.map +12 -0
- package/dist/chunk-bv41fmjn.js +3294 -0
- package/dist/chunk-bv41fmjn.js.map +35 -0
- package/dist/chunk-c6cfqydk.js +128 -0
- package/dist/chunk-c6cfqydk.js.map +13 -0
- package/dist/chunk-c8bw2b6c.js +317 -0
- package/dist/chunk-c8bw2b6c.js.map +11 -0
- package/dist/{chunk-qzyemcj7.js → chunk-ckxfnx7f.js} +2 -2
- package/dist/chunk-cy0n5dms.js +27 -0
- package/dist/chunk-cy0n5dms.js.map +11 -0
- package/dist/{chunk-xt6qx9sh.js → chunk-d2adj15j.js} +91 -9
- package/dist/chunk-d2adj15j.js.map +37 -0
- package/dist/{chunk-avppcgt6.js → chunk-d6y2wsfg.js} +241 -144
- package/dist/chunk-d6y2wsfg.js.map +15 -0
- package/dist/chunk-dsrkgtnh.js +50 -0
- package/dist/chunk-dsrkgtnh.js.map +10 -0
- package/dist/{chunk-50kv63vj.js → chunk-dysw7nsm.js} +118 -26
- package/dist/chunk-dysw7nsm.js.map +14 -0
- package/dist/{chunk-rjqm6ksg.js → chunk-ettb0cy4.js} +725 -266
- package/dist/chunk-ettb0cy4.js.map +45 -0
- package/dist/chunk-ezake7g1.js +32 -0
- package/dist/chunk-ezake7g1.js.map +11 -0
- package/dist/{chunk-b1bqvhpe.js → chunk-f1cyvnrk.js} +14 -34
- package/dist/chunk-f1cyvnrk.js.map +13 -0
- package/dist/{chunk-yn947ck3.js → chunk-f2rt4vkh.js} +48 -29
- package/dist/chunk-f2rt4vkh.js.map +14 -0
- package/dist/{chunk-hb9xcx9c.js → chunk-fmx1sz2h.js} +117 -56
- package/dist/chunk-fmx1sz2h.js.map +15 -0
- package/dist/{chunk-f6kyyeef.js → chunk-ghteq96b.js} +8 -8
- package/dist/{chunk-f6kyyeef.js.map → chunk-ghteq96b.js.map} +4 -4
- package/dist/chunk-h9kxd41f.js +271 -0
- package/dist/chunk-h9kxd41f.js.map +11 -0
- package/dist/chunk-htq0qh7z.js +59 -0
- package/dist/chunk-htq0qh7z.js.map +11 -0
- package/dist/chunk-km4rkj4t.js +402 -0
- package/dist/chunk-km4rkj4t.js.map +14 -0
- package/dist/chunk-kqxgf6kv.js +898 -0
- package/dist/chunk-kqxgf6kv.js.map +15 -0
- package/dist/chunk-n5x5y80a.js +137 -0
- package/dist/chunk-n5x5y80a.js.map +10 -0
- package/dist/chunk-nf4r78r4.js +44 -0
- package/dist/chunk-nf4r78r4.js.map +10 -0
- package/dist/chunk-pxtrxm3p.js +55 -0
- package/dist/chunk-pxtrxm3p.js.map +11 -0
- package/dist/chunk-qer6am8w.js +133 -0
- package/dist/chunk-qer6am8w.js.map +11 -0
- package/dist/{chunk-sb0shdvv.js → chunk-rdeagz6b.js} +3 -3
- package/dist/{chunk-sb0shdvv.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-53s4asfm.js → chunk-rnshztfq.js} +2 -2
- package/dist/chunk-t0jjkep3.js +35 -0
- package/dist/chunk-t0jjkep3.js.map +10 -0
- package/dist/{chunk-be9vm29v.js → chunk-t8t39h7v.js} +1 -1
- package/dist/{chunk-be9vm29v.js.map → chunk-t8t39h7v.js.map} +3 -3
- package/dist/chunk-t9xghkva.js +28 -0
- package/dist/chunk-t9xghkva.js.map +10 -0
- package/dist/{chunk-nbywkytr.js → chunk-ttba8x6z.js} +13 -33
- package/dist/chunk-ttba8x6z.js.map +15 -0
- package/dist/{chunk-8kv2sez0.js → chunk-vybf6pkp.js} +1 -1
- package/dist/chunk-wb4051cx.js +404 -0
- package/dist/chunk-wb4051cx.js.map +12 -0
- package/dist/{chunk-4tvj3ate.js → chunk-wtmzkcht.js} +4 -3
- package/dist/chunk-wtmzkcht.js.map +11 -0
- package/dist/{chunk-xqbtf4wn.js → chunk-xc7hq65b.js} +5 -3
- package/dist/{chunk-xqbtf4wn.js.map → chunk-xc7hq65b.js.map} +3 -3
- package/dist/{chunk-v5c085yp.js → chunk-xhy826cz.js} +3 -2
- package/dist/chunk-xhy826cz.js.map +10 -0
- package/dist/chunk-xkthy56g.js +33 -0
- package/dist/chunk-xkthy56g.js.map +11 -0
- package/dist/{chunk-raq0x6bd.js → chunk-xmggaxg4.js} +2199 -380
- package/dist/chunk-xmggaxg4.js.map +54 -0
- package/dist/{chunk-6zrpewy4.js → chunk-z3zp0bj1.js} +1 -1
- package/dist/chunk-z8j83gzd.js +90 -0
- package/dist/chunk-z8j83gzd.js.map +10 -0
- package/dist/chunk-zcnhxkvd.js +7 -0
- package/dist/chunk-zcnhxkvd.js.map +10 -0
- package/dist/chunk-zpw39qhj.js +194 -0
- package/dist/chunk-zpw39qhj.js.map +10 -0
- package/dist/chunk-zqqz8052.js +3 -0
- package/dist/{storage/projection-runs/lifecycle.js.map → chunk-zqqz8052.js.map} +1 -1
- package/dist/{chunk-hz8m927w.js → chunk-zqysyfjt.js} +1 -1
- package/dist/connectors/builders.d.ts +2 -1
- package/dist/connectors/builders.d.ts.map +1 -1
- package/dist/connectors/connections/authorizations.d.ts +64 -0
- package/dist/connectors/connections/authorizations.d.ts.map +1 -0
- package/dist/connectors/connections/capability.d.ts +7 -0
- package/dist/connectors/connections/capability.d.ts.map +1 -0
- package/dist/connectors/connections/command-context.d.ts +23 -0
- package/dist/connectors/connections/command-context.d.ts.map +1 -0
- package/dist/connectors/connections/contracts.d.ts +127 -0
- package/dist/connectors/connections/contracts.d.ts.map +1 -0
- package/dist/connectors/connections/credential-codec.d.ts +15 -0
- package/dist/connectors/connections/credential-codec.d.ts.map +1 -0
- package/dist/connectors/connections/credential-mutations.d.ts +63 -0
- package/dist/connectors/connections/credential-mutations.d.ts.map +1 -0
- package/dist/connectors/connections/execution.d.ts +20 -0
- package/dist/connectors/connections/execution.d.ts.map +1 -0
- package/dist/connectors/connections/internal.d.ts +5 -0
- package/dist/connectors/connections/internal.d.ts.map +1 -0
- package/dist/connectors/connections/internal.js +16 -0
- package/dist/connectors/connections/internal.js.map +9 -0
- package/dist/connectors/connections/provider-operation.d.ts +7 -0
- package/dist/connectors/connections/provider-operation.d.ts.map +1 -0
- package/dist/connectors/connections/request.d.ts +84 -0
- package/dist/connectors/connections/request.d.ts.map +1 -0
- package/dist/connectors/connections/runs.d.ts +51 -0
- package/dist/connectors/connections/runs.d.ts.map +1 -0
- package/dist/connectors/connections/service.d.ts +52 -0
- package/dist/connectors/connections/service.d.ts.map +1 -0
- package/dist/connectors/connections/storage-boundary.d.ts +3 -0
- package/dist/connectors/connections/storage-boundary.d.ts.map +1 -0
- package/dist/connectors/connections/tokens.d.ts +32 -0
- package/dist/connectors/connections/tokens.d.ts.map +1 -0
- package/dist/connectors/connections/validation.d.ts +27 -0
- package/dist/connectors/connections/validation.d.ts.map +1 -0
- package/dist/connectors/connections/views.d.ts +7 -0
- package/dist/connectors/connections/views.d.ts.map +1 -0
- package/dist/connectors/credentials.d.ts +25 -0
- package/dist/connectors/credentials.d.ts.map +1 -0
- package/dist/connectors/errors.d.ts +35 -3
- package/dist/connectors/errors.d.ts.map +1 -1
- package/dist/connectors/execution.d.ts +19 -0
- package/dist/connectors/execution.d.ts.map +1 -0
- package/dist/connectors/index.d.ts +5 -3
- package/dist/connectors/index.d.ts.map +1 -1
- package/dist/connectors/service.d.ts +23 -0
- package/dist/connectors/service.d.ts.map +1 -0
- package/dist/connectors/types.d.ts +94 -2
- package/dist/connectors/types.d.ts.map +1 -1
- package/dist/datasets/execution.d.ts +8 -0
- package/dist/datasets/execution.d.ts.map +1 -0
- package/dist/error-reporting/capability.d.ts +4 -49
- package/dist/error-reporting/capability.d.ts.map +1 -1
- package/dist/error-reporting/internal.d.ts +2 -2
- package/dist/error-reporting/internal.d.ts.map +1 -1
- package/dist/error-reporting/internal.js +10 -4
- package/dist/error-reporting/internal.js.map +1 -1
- package/dist/error-reporting/reporter.d.ts +4 -1
- package/dist/error-reporting/reporter.d.ts.map +1 -1
- package/dist/error-reporting/reports.d.ts +64 -0
- package/dist/error-reporting/reports.d.ts.map +1 -0
- package/dist/error-reporting/types.d.ts +88 -34
- package/dist/error-reporting/types.d.ts.map +1 -1
- package/dist/errors/catalog.d.ts +141 -0
- package/dist/errors/catalog.d.ts.map +1 -0
- package/dist/errors/internal.d.ts +68 -0
- package/dist/errors/internal.d.ts.map +1 -0
- package/dist/errors/internal.js +29 -0
- package/dist/errors/internal.js.map +9 -0
- package/dist/errors/types.d.ts +20 -0
- package/dist/errors/types.d.ts.map +1 -0
- package/dist/events/definitions.d.ts +0 -1
- package/dist/events/definitions.d.ts.map +1 -1
- package/dist/events/execution.d.ts +13 -0
- package/dist/events/execution.d.ts.map +1 -0
- package/dist/events/index.d.ts +3 -2
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +10 -8
- package/dist/events/index.js.map +1 -1
- package/dist/events/outbox-dispatcher.d.ts +4 -2
- package/dist/events/outbox-dispatcher.d.ts.map +1 -1
- package/dist/events/{runtime.d.ts → service.d.ts} +13 -14
- package/dist/events/service.d.ts.map +1 -0
- package/dist/events/types/pipelines.d.ts +4 -1
- package/dist/events/types/pipelines.d.ts.map +1 -1
- package/dist/events/types/syncs.d.ts +3 -0
- package/dist/events/types/syncs.d.ts.map +1 -1
- package/dist/events/types/workflows.d.ts +4 -2
- package/dist/events/types/workflows.d.ts.map +1 -1
- package/dist/execution/agent.d.ts +42 -0
- package/dist/execution/agent.d.ts.map +1 -0
- package/dist/execution/agent.js +73 -0
- package/dist/execution/agent.js.map +9 -0
- package/dist/execution/authorization.d.ts +60 -0
- package/dist/execution/authorization.d.ts.map +1 -0
- package/dist/execution/dispatch.d.ts +8 -0
- package/dist/execution/dispatch.d.ts.map +1 -0
- package/dist/execution/durable.d.ts +37 -0
- package/dist/execution/durable.d.ts.map +1 -0
- package/dist/execution/index.d.ts +2 -0
- package/dist/execution/index.d.ts.map +1 -0
- package/dist/execution/primitive.d.ts +21 -0
- package/dist/execution/primitive.d.ts.map +1 -0
- package/dist/execution/primitive.js +91 -0
- package/dist/execution/primitive.js.map +10 -0
- package/dist/execution/request.d.ts +38 -0
- package/dist/execution/request.d.ts.map +1 -0
- package/dist/execution/request.js +100 -0
- package/dist/execution/request.js.map +10 -0
- package/dist/execution/scopes.d.ts +30 -0
- package/dist/execution/scopes.d.ts.map +1 -0
- package/dist/execution/types.d.ts +111 -0
- package/dist/execution/types.d.ts.map +1 -0
- package/dist/index.d.ts +31 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +133 -105
- package/dist/index.js.map +1 -1
- package/dist/json.d.ts +0 -1
- package/dist/json.d.ts.map +1 -1
- package/dist/lake-storage/index.js +5 -5
- package/dist/logging/execution.d.ts +9 -0
- package/dist/logging/execution.d.ts.map +1 -0
- package/dist/logging/index.d.ts +1 -1
- package/dist/logging/index.d.ts.map +1 -1
- package/dist/logging/index.js +8 -8
- package/dist/logging/index.js.map +1 -1
- package/dist/logging/{runtime.d.ts → service.d.ts} +7 -7
- package/dist/logging/{runtime.d.ts.map → service.d.ts.map} +1 -1
- package/dist/logging/types.js +2 -2
- package/dist/materialization/events.d.ts +1 -0
- package/dist/materialization/events.d.ts.map +1 -1
- package/dist/materialization/index.d.ts +1 -1
- package/dist/materialization/index.d.ts.map +1 -1
- package/dist/materialization/index.js +2 -2
- package/dist/materialization/model.d.ts +30 -17
- 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/commit.d.ts +2 -1
- package/dist/materializer/edits/commit.d.ts.map +1 -1
- package/dist/materializer/edits/load-state.d.ts +1 -1
- package/dist/materializer/edits/load-state.d.ts.map +1 -1
- package/dist/materializer/edits/operations.d.ts +1 -13
- package/dist/materializer/edits/operations.d.ts.map +1 -1
- package/dist/materializer/edits/plan.d.ts +2 -1
- package/dist/materializer/edits/plan.d.ts.map +1 -1
- package/dist/materializer/edits/working-state.d.ts +38 -8
- package/dist/materializer/edits/working-state.d.ts.map +1 -1
- package/dist/materializer/effective/build-events.d.ts +1 -0
- package/dist/materializer/effective/build-events.d.ts.map +1 -1
- package/dist/materializer/effective/diff.d.ts +7 -0
- package/dist/materializer/effective/diff.d.ts.map +1 -1
- package/dist/materializer/effective/load-state.d.ts +0 -2
- package/dist/materializer/effective/load-state.d.ts.map +1 -1
- package/dist/materializer/effective/resolve.d.ts +19 -2
- package/dist/materializer/effective/resolve.d.ts.map +1 -1
- package/dist/materializer/execution/commit-lifecycle.d.ts +2 -2
- package/dist/materializer/execution/commit-lifecycle.d.ts.map +1 -1
- package/dist/materializer/execution/plan-stream.d.ts.map +1 -1
- package/dist/materializer/execution/scope.d.ts +26 -0
- package/dist/materializer/execution/scope.d.ts.map +1 -0
- package/dist/materializer/execution/work-executor.d.ts.map +1 -1
- package/dist/materializer/execution/work-records.d.ts +6 -5
- package/dist/materializer/execution/work-records.d.ts.map +1 -1
- package/dist/materializer/index.d.ts +2 -2
- package/dist/materializer/index.d.ts.map +1 -1
- package/dist/materializer/index.js +33 -18
- package/dist/materializer/index.js.map +1 -1
- package/dist/materializer/materializer.d.ts +37 -5
- package/dist/materializer/materializer.d.ts.map +1 -1
- package/dist/materializer/projections/finish-run.d.ts +2 -1
- package/dist/materializer/projections/finish-run.d.ts.map +1 -1
- package/dist/materializer/projections/replace.d.ts +2 -1
- package/dist/materializer/projections/replace.d.ts.map +1 -1
- package/dist/materializer/projections/replacement-plan.d.ts +1 -0
- package/dist/materializer/projections/replacement-plan.d.ts.map +1 -1
- package/dist/materializer/shared/batching.d.ts.map +1 -1
- package/dist/materializer/shared/normalize.d.ts.map +1 -1
- package/dist/materializer/telemetry/append.d.ts +2 -1
- package/dist/materializer/telemetry/append.d.ts.map +1 -1
- package/dist/materializer/telemetry/plan.d.ts +7 -1
- package/dist/materializer/telemetry/plan.d.ts.map +1 -1
- package/dist/objects/action/request.d.ts +3 -3
- package/dist/objects/action/request.d.ts.map +1 -1
- package/dist/objects/context/index.d.ts +1 -1
- package/dist/objects/context/index.d.ts.map +1 -1
- package/dist/objects/context/types.d.ts +5 -0
- package/dist/objects/context/types.d.ts.map +1 -1
- package/dist/objects/execution.d.ts +100 -0
- package/dist/objects/execution.d.ts.map +1 -0
- package/dist/objects/index.js +40 -24
- package/dist/objects/index.js.map +1 -1
- package/dist/objects/materializer-adapter.d.ts +1 -1
- package/dist/objects/materializer-adapter.d.ts.map +1 -1
- package/dist/objects/query/executor.d.ts +3 -8
- package/dist/objects/query/executor.d.ts.map +1 -1
- package/dist/objects/query/index.d.ts +2 -2
- package/dist/objects/query/index.d.ts.map +1 -1
- package/dist/objects/query/index.js +9 -13
- package/dist/objects/query/index.js.map +1 -1
- package/dist/objects/query/planner.d.ts +0 -3
- package/dist/objects/query/planner.d.ts.map +1 -1
- package/dist/objects/sdk/object-handle.d.ts +2 -2
- package/dist/objects/sdk/object-handle.d.ts.map +1 -1
- package/dist/objects/sdk/object-set.d.ts +2 -0
- package/dist/objects/sdk/object-set.d.ts.map +1 -1
- package/dist/objects/sdk/runtime-query-executor.d.ts +2 -0
- 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/action-service.d.ts +3 -2
- package/dist/objects/service/action-service.d.ts.map +1 -1
- package/dist/objects/service/list-service.d.ts +1 -1
- package/dist/objects/telemetry/history.d.ts +2 -0
- package/dist/objects/telemetry/history.d.ts.map +1 -1
- package/dist/objects/telemetry/write-batch.d.ts.map +1 -1
- package/dist/ontology/index.d.ts +1 -1
- package/dist/ontology/index.d.ts.map +1 -1
- package/dist/ontology/index.js +5 -5
- package/dist/ontology/internal.js +4 -4
- package/dist/ontology/registry.d.ts +15 -2
- package/dist/ontology/registry.d.ts.map +1 -1
- package/dist/pipelines/execution.d.ts +19 -0
- package/dist/pipelines/execution.d.ts.map +1 -0
- package/dist/pipelines/index.d.ts +1 -0
- package/dist/pipelines/index.d.ts.map +1 -1
- package/dist/pipelines/index.js +68 -0
- package/dist/pipelines/index.js.map +9 -0
- package/dist/pipelines/request.d.ts +6 -9
- package/dist/pipelines/request.d.ts.map +1 -1
- package/dist/pipelines/run-dispatch.d.ts +47 -0
- package/dist/pipelines/run-dispatch.d.ts.map +1 -0
- package/dist/projections/builders.d.ts +19 -8
- package/dist/projections/builders.d.ts.map +1 -1
- package/dist/projections/capability.d.ts +7 -0
- package/dist/projections/capability.d.ts.map +1 -0
- package/dist/projections/execution.d.ts +19 -0
- package/dist/projections/execution.d.ts.map +1 -0
- package/dist/projections/index.d.ts +5 -2
- package/dist/projections/index.d.ts.map +1 -1
- package/dist/projections/internal.d.ts +8 -11
- package/dist/projections/internal.d.ts.map +1 -1
- package/dist/projections/internal.js +48 -6
- package/dist/projections/internal.js.map +1 -1
- package/dist/projections/ownership.d.ts +2 -2
- package/dist/projections/ownership.d.ts.map +1 -1
- package/dist/projections/registry.d.ts +21 -11
- package/dist/projections/registry.d.ts.map +1 -1
- package/dist/projections/revision.d.ts +2 -2
- package/dist/projections/revision.d.ts.map +1 -1
- package/dist/projections/run-dispatch.d.ts +37 -0
- package/dist/projections/run-dispatch.d.ts.map +1 -0
- package/dist/projections/run-id.d.ts +3 -0
- package/dist/projections/run-id.d.ts.map +1 -0
- package/dist/projections/timestamp.d.ts +3 -0
- package/dist/projections/timestamp.d.ts.map +1 -0
- package/dist/projections/types.d.ts +12 -0
- package/dist/projections/types.d.ts.map +1 -1
- package/dist/projections/validation.d.ts +2 -2
- package/dist/projections/validation.d.ts.map +1 -1
- package/dist/queues/in-memory.d.ts +11 -10
- package/dist/queues/in-memory.d.ts.map +1 -1
- package/dist/queues/index.d.ts +1 -1
- package/dist/queues/index.d.ts.map +1 -1
- package/dist/queues/index.js +1 -1
- package/dist/queues/types.d.ts +59 -42
- package/dist/queues/types.d.ts.map +1 -1
- package/dist/rules/execution.d.ts +14 -0
- package/dist/rules/execution.d.ts.map +1 -0
- package/dist/rules/index.d.ts +1 -1
- package/dist/rules/index.d.ts.map +1 -1
- package/dist/rules/validation.d.ts +1 -2
- package/dist/rules/validation.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/ai-usage.d.ts +8 -0
- package/dist/runtime/ai-usage.d.ts.map +1 -0
- package/dist/runtime/create.d.ts +7 -5
- package/dist/runtime/create.d.ts.map +1 -1
- package/dist/runtime/definitions.d.ts +35 -0
- package/dist/runtime/definitions.d.ts.map +1 -0
- package/dist/runtime/host.d.ts +123 -0
- package/dist/runtime/host.d.ts.map +1 -0
- package/dist/runtime/index.d.ts +6 -5
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/internal.d.ts +4 -0
- package/dist/runtime/internal.d.ts.map +1 -1
- package/dist/runtime/internal.js +6 -2
- package/dist/runtime/internal.js.map +1 -1
- package/dist/runtime/ontology-mutations.d.ts +4 -2
- package/dist/runtime/ontology-mutations.d.ts.map +1 -1
- package/dist/runtime/resolve-definitions.d.ts +42 -0
- package/dist/runtime/resolve-definitions.d.ts.map +1 -0
- package/dist/runtime/sixb.d.ts +43 -219
- package/dist/runtime/sixb.d.ts.map +1 -1
- package/dist/runtime/types.d.ts +16 -216
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/scheduler/index.d.ts +1 -1
- package/dist/scheduler/index.d.ts.map +1 -1
- package/dist/scheduler/index.js +3 -6
- package/dist/scheduler/index.js.map +1 -1
- package/dist/scheduler/runtime.d.ts +7 -2
- package/dist/scheduler/runtime.d.ts.map +1 -1
- package/dist/schedules/execution.d.ts +6 -0
- package/dist/schedules/execution.d.ts.map +1 -0
- package/dist/schedules/index.js +9 -7
- package/dist/schedules/index.js.map +1 -1
- package/dist/schedules/types.d.ts +1 -3
- package/dist/schedules/types.d.ts.map +1 -1
- package/dist/security/every.d.ts +4 -1
- package/dist/security/every.d.ts.map +1 -1
- package/dist/security/grants.d.ts +4 -1
- package/dist/security/grants.d.ts.map +1 -1
- package/dist/security/index.d.ts +3 -1
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/registry.d.ts +42 -0
- package/dist/security/registry.d.ts.map +1 -0
- package/dist/security/types.d.ts +7 -12
- package/dist/security/types.d.ts.map +1 -1
- package/dist/security/validation.d.ts +2 -0
- package/dist/security/validation.d.ts.map +1 -1
- package/dist/storage/action-runs/failure.d.ts +7 -0
- package/dist/storage/action-runs/failure.d.ts.map +1 -0
- package/dist/storage/action-runs/failure.js +14 -0
- package/dist/storage/action-runs/failure.js.map +9 -0
- package/dist/storage/action-runs/idempotency.d.ts.map +1 -1
- package/dist/storage/action-runs/in-memory.d.ts +3 -1
- package/dist/storage/action-runs/in-memory.d.ts.map +1 -1
- package/dist/storage/action-runs/index.d.ts +2 -1
- package/dist/storage/action-runs/index.d.ts.map +1 -1
- package/dist/storage/action-runs/provider.d.ts +10 -0
- package/dist/storage/action-runs/provider.d.ts.map +1 -0
- package/dist/storage/action-runs/provider.js +13 -0
- package/dist/storage/action-runs/provider.js.map +9 -0
- package/dist/storage/action-runs/types.d.ts +37 -18
- package/dist/storage/action-runs/types.d.ts.map +1 -1
- 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 +22 -5
- package/dist/storage/agents/in-memory.d.ts.map +1 -1
- package/dist/storage/agents/index.d.ts +2 -2
- package/dist/storage/agents/index.d.ts.map +1 -1
- package/dist/storage/agents/provider.d.ts +41 -0
- package/dist/storage/agents/provider.d.ts.map +1 -0
- package/dist/storage/agents/provider.js +28 -0
- package/dist/storage/agents/provider.js.map +9 -0
- package/dist/storage/agents/types.d.ts +83 -26
- 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/errors.d.ts +8 -0
- package/dist/storage/ai-usage/errors.d.ts.map +1 -0
- package/dist/storage/ai-usage/in-memory.d.ts +28 -0
- package/dist/storage/ai-usage/in-memory.d.ts.map +1 -0
- package/dist/storage/ai-usage/index.d.ts +8 -0
- package/dist/storage/ai-usage/index.d.ts.map +1 -0
- package/dist/storage/ai-usage/record.d.ts +6 -0
- package/dist/storage/ai-usage/record.d.ts.map +1 -0
- package/dist/storage/ai-usage/types.d.ts +89 -0
- package/dist/storage/ai-usage/types.d.ts.map +1 -0
- package/dist/storage/ai-usage/usage.d.ts +11 -0
- package/dist/storage/ai-usage/usage.d.ts.map +1 -0
- package/dist/storage/auth/types.d.ts +1 -0
- package/dist/storage/auth/types.d.ts.map +1 -1
- package/dist/storage/connector-connections/errors.d.ts +12 -0
- package/dist/storage/connector-connections/errors.d.ts.map +1 -0
- package/dist/storage/connector-connections/in-memory.d.ts +81 -0
- package/dist/storage/connector-connections/in-memory.d.ts.map +1 -0
- package/dist/storage/connector-connections/index.d.ts +7 -0
- package/dist/storage/connector-connections/index.d.ts.map +1 -0
- package/dist/storage/connector-connections/provider/authorizations.d.ts +20 -0
- package/dist/storage/connector-connections/provider/authorizations.d.ts.map +1 -0
- package/dist/storage/connector-connections/provider/connections.d.ts +17 -0
- package/dist/storage/connector-connections/provider/connections.d.ts.map +1 -0
- package/dist/storage/connector-connections/provider/runs.d.ts +14 -0
- package/dist/storage/connector-connections/provider/runs.d.ts.map +1 -0
- package/dist/storage/connector-connections/provider/shared.d.ts +74 -0
- package/dist/storage/connector-connections/provider/shared.d.ts.map +1 -0
- package/dist/storage/connector-connections/provider.d.ts +49 -0
- package/dist/storage/connector-connections/provider.d.ts.map +1 -0
- package/dist/storage/connector-connections/provider.js +1025 -0
- package/dist/storage/connector-connections/provider.js.map +14 -0
- package/dist/storage/connector-connections/types.d.ts +402 -0
- package/dist/storage/connector-connections/types.d.ts.map +1 -0
- package/dist/storage/executions/errors.d.ts +8 -0
- package/dist/storage/executions/errors.d.ts.map +1 -0
- package/dist/storage/executions/in-memory.d.ts +21 -0
- package/dist/storage/executions/in-memory.d.ts.map +1 -0
- package/dist/storage/executions/index.d.ts +5 -0
- package/dist/storage/executions/index.d.ts.map +1 -0
- package/dist/storage/executions/provider.d.ts +29 -0
- package/dist/storage/executions/provider.d.ts.map +1 -0
- package/dist/storage/executions/provider.js +208 -0
- package/dist/storage/executions/provider.js.map +10 -0
- package/dist/storage/executions/run-link.d.ts +24 -0
- package/dist/storage/executions/run-link.d.ts.map +1 -0
- package/dist/storage/executions/types.d.ts +62 -0
- package/dist/storage/executions/types.d.ts.map +1 -0
- package/dist/storage/executions/validation.d.ts +13 -0
- package/dist/storage/executions/validation.d.ts.map +1 -0
- package/dist/storage/in-memory/index.d.ts +25 -5
- package/dist/storage/in-memory/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +30 -17
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +99 -29
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/ontology/commits.d.ts +1 -0
- package/dist/storage/ontology/commits.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/index.d.ts +1 -0
- package/dist/storage/ontology/in-memory/index.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/materializations-state.d.ts +3 -2
- package/dist/storage/ontology/in-memory/materializations-state.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/materializations-work.d.ts +2 -2
- package/dist/storage/ontology/in-memory/materializations-work.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/materializations.d.ts +3 -1
- package/dist/storage/ontology/in-memory/materializations.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/shared-state.d.ts +7 -2
- package/dist/storage/ontology/in-memory/shared-state.d.ts.map +1 -1
- package/dist/storage/ontology/index.d.ts +3 -2
- package/dist/storage/ontology/index.d.ts.map +1 -1
- package/dist/storage/ontology/materializations.d.ts +53 -5
- package/dist/storage/ontology/materializations.d.ts.map +1 -1
- package/dist/storage/ontology/outbox.d.ts +8 -2
- package/dist/storage/ontology/outbox.d.ts.map +1 -1
- package/dist/storage/ontology/provider-work.d.ts.map +1 -1
- package/dist/storage/ontology/provider.d.ts +5 -22
- package/dist/storage/ontology/provider.d.ts.map +1 -1
- package/dist/storage/ontology/provider.js +6 -7
- package/dist/storage/ontology/provider.js.map +1 -1
- package/dist/storage/operation-scope.d.ts.map +1 -1
- package/dist/storage/operation-scope.js +1 -1
- package/dist/storage/pipeline-runs/idempotency.d.ts +3 -0
- package/dist/storage/pipeline-runs/idempotency.d.ts.map +1 -0
- package/dist/storage/pipeline-runs/in-memory.d.ts +5 -1
- package/dist/storage/pipeline-runs/in-memory.d.ts.map +1 -1
- package/dist/storage/pipeline-runs/index.d.ts +3 -1
- package/dist/storage/pipeline-runs/index.d.ts.map +1 -1
- package/dist/storage/pipeline-runs/provider.d.ts +10 -0
- package/dist/storage/pipeline-runs/provider.d.ts.map +1 -0
- package/dist/storage/pipeline-runs/provider.js +11 -0
- package/dist/storage/pipeline-runs/provider.js.map +9 -0
- package/dist/storage/pipeline-runs/types.d.ts +30 -14
- package/dist/storage/pipeline-runs/types.d.ts.map +1 -1
- package/dist/storage/projection-runs/in-memory.d.ts +8 -3
- package/dist/storage/projection-runs/in-memory.d.ts.map +1 -1
- package/dist/storage/projection-runs/index.d.ts +2 -2
- package/dist/storage/projection-runs/index.d.ts.map +1 -1
- package/dist/storage/projection-runs/lifecycle.d.ts +14 -8
- package/dist/storage/projection-runs/lifecycle.d.ts.map +1 -1
- package/dist/storage/projection-runs/provider.d.ts +13 -0
- package/dist/storage/projection-runs/provider.d.ts.map +1 -0
- package/dist/storage/projection-runs/{lifecycle.js → provider.js} +15 -4
- package/dist/storage/projection-runs/provider.js.map +9 -0
- package/dist/storage/projection-runs/types.d.ts +28 -11
- package/dist/storage/projection-runs/types.d.ts.map +1 -1
- package/dist/storage/run-listing.d.ts +8 -9
- package/dist/storage/run-listing.d.ts.map +1 -1
- package/dist/storage/sync-runs/idempotency.d.ts +3 -0
- package/dist/storage/sync-runs/idempotency.d.ts.map +1 -0
- package/dist/storage/sync-runs/in-memory.d.ts +5 -1
- package/dist/storage/sync-runs/in-memory.d.ts.map +1 -1
- package/dist/storage/sync-runs/index.d.ts +3 -1
- package/dist/storage/sync-runs/index.d.ts.map +1 -1
- package/dist/storage/sync-runs/provider.d.ts +10 -0
- package/dist/storage/sync-runs/provider.d.ts.map +1 -0
- package/dist/storage/sync-runs/provider.js +11 -0
- package/dist/storage/sync-runs/provider.js.map +9 -0
- package/dist/storage/sync-runs/types.d.ts +28 -11
- package/dist/storage/sync-runs/types.d.ts.map +1 -1
- package/dist/storage/types.d.ts +22 -15
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/storage/webhook-runs/errors.d.ts +3 -0
- package/dist/storage/webhook-runs/errors.d.ts.map +1 -1
- package/dist/storage/webhook-runs/in-memory.d.ts +13 -1
- package/dist/storage/webhook-runs/in-memory.d.ts.map +1 -1
- package/dist/storage/webhook-runs/index.d.ts +3 -2
- package/dist/storage/webhook-runs/index.d.ts.map +1 -1
- package/dist/storage/webhook-runs/provider.d.ts +10 -0
- package/dist/storage/webhook-runs/provider.d.ts.map +1 -0
- package/dist/storage/webhook-runs/provider.js +11 -0
- package/dist/storage/webhook-runs/provider.js.map +9 -0
- package/dist/storage/webhook-runs/types.d.ts +37 -11
- package/dist/storage/webhook-runs/types.d.ts.map +1 -1
- package/dist/storage/workflow-runs/in-memory.d.ts +6 -2
- package/dist/storage/workflow-runs/in-memory.d.ts.map +1 -1
- package/dist/storage/workflow-runs/index.d.ts +2 -1
- package/dist/storage/workflow-runs/index.d.ts.map +1 -1
- package/dist/storage/workflow-runs/provider.d.ts +19 -0
- package/dist/storage/workflow-runs/provider.d.ts.map +1 -0
- package/dist/storage/workflow-runs/provider.js +20 -0
- package/dist/storage/workflow-runs/provider.js.map +9 -0
- package/dist/storage/workflow-runs/types.d.ts +28 -30
- package/dist/storage/workflow-runs/types.d.ts.map +1 -1
- package/dist/syncs/execution.d.ts +18 -0
- package/dist/syncs/execution.d.ts.map +1 -0
- package/dist/syncs/index.d.ts +3 -1
- package/dist/syncs/index.d.ts.map +1 -1
- package/dist/syncs/index.js +67 -0
- package/dist/syncs/index.js.map +9 -0
- package/dist/syncs/request.d.ts +6 -16
- package/dist/syncs/request.d.ts.map +1 -1
- package/dist/syncs/run-dispatch.d.ts +47 -0
- package/dist/syncs/run-dispatch.d.ts.map +1 -0
- package/dist/syncs/sources.d.ts +8 -0
- package/dist/syncs/sources.d.ts.map +1 -0
- package/dist/syncs/types.d.ts +16 -9
- package/dist/syncs/types.d.ts.map +1 -1
- package/dist/testing/action-execution.d.ts +12 -0
- package/dist/testing/action-execution.d.ts.map +1 -0
- package/dist/testing/agent-execution.d.ts +14 -0
- package/dist/testing/agent-execution.d.ts.map +1 -0
- package/dist/testing/agent-storage-contract.d.ts +12 -4
- 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 +13 -0
- package/dist/testing/ai-usage-storage-contract.d.ts.map +1 -0
- package/dist/testing/auth-storage-contract.d.ts.map +1 -1
- package/dist/testing/broker-contract.d.ts.map +1 -1
- package/dist/testing/connector-connection-storage-contract.d.ts +16 -0
- package/dist/testing/connector-connection-storage-contract.d.ts.map +1 -0
- package/dist/testing/execution-storage-contract.d.ts +15 -0
- package/dist/testing/execution-storage-contract.d.ts.map +1 -0
- package/dist/testing/execution.d.ts +23 -0
- package/dist/testing/execution.d.ts.map +1 -0
- package/dist/testing/index.d.ts +13 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +4754 -1592
- package/dist/testing/index.js.map +26 -13
- package/dist/testing/materializer-fixture.d.ts +2 -2
- package/dist/testing/materializer-fixture.d.ts.map +1 -1
- package/dist/testing/materializer-storage-contract.d.ts.map +1 -1
- package/dist/testing/ontology-contract-fixture.d.ts +1 -0
- package/dist/testing/ontology-contract-fixture.d.ts.map +1 -1
- package/dist/testing/ontology-storage-contract.d.ts.map +1 -1
- package/dist/testing/pipeline-execution.d.ts +16 -0
- package/dist/testing/pipeline-execution.d.ts.map +1 -0
- package/dist/testing/projection-execution.d.ts +20 -0
- package/dist/testing/projection-execution.d.ts.map +1 -0
- package/dist/testing/projection-run-storage-contract.d.ts +9 -4
- package/dist/testing/projection-run-storage-contract.d.ts.map +1 -1
- package/dist/testing/queues-contract.d.ts.map +1 -1
- package/dist/testing/sync-execution.d.ts +16 -0
- package/dist/testing/sync-execution.d.ts.map +1 -0
- package/dist/testing/webhook-execution.d.ts +12 -0
- package/dist/testing/webhook-execution.d.ts.map +1 -0
- package/dist/testing/webhook-run-storage-contract.d.ts +11 -0
- package/dist/testing/webhook-run-storage-contract.d.ts.map +1 -0
- package/dist/testing/workflow-execution.d.ts +23 -0
- package/dist/testing/workflow-execution.d.ts.map +1 -0
- package/dist/webhooks/index.d.ts +2 -1
- package/dist/webhooks/index.d.ts.map +1 -1
- package/dist/webhooks/internal.d.ts +2 -0
- package/dist/webhooks/internal.d.ts.map +1 -0
- package/dist/webhooks/internal.js +152 -0
- package/dist/webhooks/internal.js.map +10 -0
- package/dist/webhooks/registry.d.ts +18 -4
- package/dist/webhooks/registry.d.ts.map +1 -1
- package/dist/webhooks/run-admission.d.ts +25 -0
- package/dist/webhooks/run-admission.d.ts.map +1 -0
- package/dist/webhooks/types.d.ts +8 -5
- package/dist/webhooks/types.d.ts.map +1 -1
- package/dist/workers/index.js +29 -20
- package/dist/workers/index.js.map +4 -4
- package/dist/workers/queue-delivery.d.ts +7 -7
- package/dist/workers/queue-delivery.d.ts.map +1 -1
- package/dist/workers/queue-worker.d.ts +32 -11
- package/dist/workers/queue-worker.d.ts.map +1 -1
- package/dist/workflows/execution.d.ts +52 -0
- package/dist/workflows/execution.d.ts.map +1 -0
- package/dist/workflows/failure.d.ts +28 -0
- package/dist/workflows/failure.d.ts.map +1 -0
- package/dist/workflows/index.d.ts +4 -2
- package/dist/workflows/index.d.ts.map +1 -1
- package/dist/workflows/index.js +67 -36
- package/dist/workflows/index.js.map +1 -1
- package/dist/workflows/request.d.ts +2 -1
- package/dist/workflows/request.d.ts.map +1 -1
- package/dist/workflows/run-dispatch.d.ts +59 -0
- package/dist/workflows/run-dispatch.d.ts.map +1 -0
- package/dist/workflows/types.d.ts +38 -8
- package/dist/workflows/types.d.ts.map +1 -1
- package/package.json +113 -5
- package/src/actions/commit-edits.ts +0 -3
- package/src/actions/execution.ts +83 -0
- package/src/actions/index.ts +1 -1
- package/src/actions/registry.ts +22 -10
- package/src/actions/request.ts +55 -177
- package/src/actions/run-dispatch.ts +276 -0
- package/src/actions/types/context.ts +2 -4
- package/src/actions/validation.ts +2 -2
- package/src/agents/adapters.ts +71 -26
- package/src/agents/authority.ts +189 -0
- package/src/agents/dispatch.ts +1 -6
- package/src/agents/errors.ts +4 -2
- package/src/agents/execution.ts +266 -0
- package/src/agents/index.ts +33 -4
- package/src/agents/prompt.ts +47 -7
- package/src/agents/request.ts +158 -13
- package/src/agents/streams.ts +150 -3
- 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 +49 -5
- package/src/agents/validation.ts +3 -3
- package/src/auth/attribution.ts +48 -0
- package/src/auth/index.ts +1 -0
- package/src/auth/runtime.ts +5 -5
- package/src/authorization/decision.ts +75 -14
- package/src/authorization/grant-kinds.ts +9 -0
- package/src/authorization/index.ts +2 -0
- package/src/blob-storage/execution.ts +78 -0
- package/src/bootstrap/discovery.ts +88 -268
- package/src/bootstrap/index.ts +2 -13
- package/src/broker/in-memory.ts +8 -1
- package/src/broker/types.ts +5 -0
- package/src/connectors/builders.ts +37 -2
- package/src/connectors/connections/authorizations.ts +646 -0
- package/src/connectors/connections/capability.ts +59 -0
- package/src/connectors/connections/command-context.ts +98 -0
- package/src/connectors/connections/contracts.ts +208 -0
- package/src/connectors/connections/credential-codec.ts +48 -0
- package/src/connectors/connections/credential-mutations.ts +574 -0
- package/src/connectors/connections/execution.ts +138 -0
- package/src/connectors/connections/internal.ts +17 -0
- package/src/connectors/connections/provider-operation.ts +41 -0
- package/src/connectors/connections/request.ts +447 -0
- package/src/connectors/connections/runs.ts +702 -0
- package/src/connectors/connections/service.ts +644 -0
- package/src/connectors/connections/storage-boundary.ts +13 -0
- package/src/connectors/connections/tokens.ts +292 -0
- package/src/connectors/connections/validation.ts +316 -0
- package/src/connectors/connections/views.ts +37 -0
- package/src/connectors/credentials.ts +149 -0
- package/src/connectors/errors.ts +111 -3
- package/src/connectors/execution.ts +157 -0
- package/src/connectors/index.ts +26 -2
- package/src/connectors/service.ts +142 -0
- package/src/connectors/types.ts +156 -7
- package/src/datasets/execution.ts +24 -0
- package/src/error-reporting/capability.ts +33 -106
- package/src/error-reporting/internal.ts +3 -1
- package/src/error-reporting/reporter.ts +19 -3
- package/src/error-reporting/reports.ts +172 -0
- package/src/error-reporting/types.ts +97 -43
- package/src/errors/catalog.ts +149 -0
- package/src/errors/internal.ts +322 -0
- package/src/errors/types.ts +21 -0
- package/src/events/definitions.ts +0 -4
- package/src/events/execution.ts +45 -0
- package/src/events/index.ts +15 -14
- package/src/events/outbox-dispatcher.ts +53 -18
- package/src/events/{runtime.ts → service.ts} +19 -23
- package/src/events/types/pipelines.ts +4 -1
- package/src/events/types/syncs.ts +3 -0
- package/src/events/types/workflows.ts +4 -2
- package/src/execution/agent.ts +130 -0
- package/src/execution/authorization.ts +409 -0
- package/src/execution/dispatch.ts +7 -0
- package/src/execution/durable.ts +193 -0
- package/src/execution/index.ts +12 -0
- package/src/execution/primitive.ts +50 -0
- package/src/execution/request.ts +109 -0
- package/src/execution/scopes.ts +198 -0
- package/src/execution/types.ts +113 -0
- package/src/http/api-routes.ts +3 -3
- package/src/index.ts +122 -9
- package/src/json.ts +0 -4
- package/src/logging/execution.ts +28 -0
- package/src/logging/index.ts +4 -4
- package/src/logging/{runtime.ts → service.ts} +7 -7
- package/src/materialization/events.ts +1 -0
- package/src/materialization/index.ts +2 -0
- package/src/materialization/model.ts +34 -18
- package/src/materializer/README.md +9 -13
- package/src/materializer/edits/apply.ts +55 -2
- package/src/materializer/edits/commit.ts +85 -28
- package/src/materializer/edits/load-state.ts +79 -16
- package/src/materializer/edits/operations.ts +80 -37
- package/src/materializer/edits/plan.ts +95 -22
- package/src/materializer/edits/working-state.ts +93 -55
- package/src/materializer/effective/build-events.ts +2 -0
- package/src/materializer/effective/diff.ts +22 -0
- package/src/materializer/effective/load-state.ts +0 -31
- package/src/materializer/effective/resolve.ts +140 -9
- package/src/materializer/execution/commit-lifecycle.ts +9 -1
- package/src/materializer/execution/plan-stream.ts +33 -9
- package/src/materializer/execution/scope.ts +95 -0
- package/src/materializer/execution/work-executor.ts +6 -2
- package/src/materializer/execution/work-records.ts +42 -7
- package/src/materializer/index.ts +9 -1
- package/src/materializer/materializer.ts +67 -5
- package/src/materializer/projections/entry-validator.ts +23 -1
- package/src/materializer/projections/finish-run.ts +29 -11
- package/src/materializer/projections/replace.ts +55 -22
- package/src/materializer/projections/replacement-plan.ts +39 -7
- package/src/materializer/shared/batching.ts +4 -1
- package/src/materializer/shared/normalize.ts +16 -19
- package/src/materializer/telemetry/append.ts +57 -26
- package/src/materializer/telemetry/plan.ts +15 -6
- package/src/objects/action/request.ts +5 -5
- package/src/objects/context/index.ts +1 -0
- package/src/objects/context/types.ts +6 -0
- package/src/objects/execution.ts +346 -0
- package/src/objects/materializer-adapter.ts +1 -23
- package/src/objects/query/executor.ts +15 -29
- package/src/objects/query/index.ts +1 -2
- package/src/objects/query/planner.ts +0 -6
- package/src/objects/sdk/object-handle.ts +2 -2
- package/src/objects/sdk/object-set.ts +17 -7
- package/src/objects/sdk/runtime-query-executor.ts +9 -2
- package/src/objects/sdk/telemetry-channel.ts +5 -1
- package/src/objects/service/action-service.ts +5 -2
- package/src/objects/service/list-service.ts +1 -1
- package/src/objects/telemetry/history.ts +8 -3
- package/src/objects/telemetry/write-batch.ts +0 -2
- package/src/ontology/index.ts +6 -1
- package/src/ontology/registry.ts +16 -2
- package/src/pipelines/execution.ts +105 -0
- package/src/pipelines/index.ts +7 -0
- package/src/pipelines/request.ts +32 -26
- package/src/pipelines/run-dispatch.ts +308 -0
- package/src/projections/builders.ts +100 -44
- package/src/projections/capability.ts +37 -0
- package/src/projections/execution.ts +85 -0
- package/src/projections/index.ts +8 -1
- package/src/projections/internal.ts +21 -61
- package/src/projections/ownership.ts +2 -2
- package/src/projections/registry.ts +33 -11
- package/src/projections/revision.ts +11 -5
- package/src/projections/run-dispatch.ts +497 -0
- package/src/projections/run-id.ts +20 -0
- package/src/projections/timestamp.ts +66 -0
- package/src/projections/types.ts +19 -0
- package/src/projections/validation.ts +27 -3
- package/src/queues/in-memory.ts +37 -11
- package/src/queues/index.ts +10 -2
- package/src/queues/types.ts +78 -45
- package/src/rules/execution.ts +49 -0
- package/src/rules/index.ts +0 -1
- package/src/rules/validation.ts +2 -6
- package/src/runtime/ai-cost.ts +15 -0
- package/src/runtime/ai-usage.ts +17 -0
- package/src/runtime/create.ts +28 -68
- package/src/runtime/definitions.ts +44 -0
- package/src/runtime/host.ts +377 -0
- package/src/runtime/index.ts +5 -13
- package/src/runtime/internal.ts +12 -0
- package/src/runtime/ontology-mutations.ts +5 -3
- package/src/runtime/resolve-definitions.ts +238 -0
- package/src/runtime/sixb.ts +95 -822
- package/src/runtime/types.ts +17 -290
- package/src/scheduler/index.ts +1 -1
- package/src/scheduler/runtime.ts +37 -6
- package/src/schedules/execution.ts +14 -0
- package/src/schedules/types.ts +0 -8
- package/src/security/every.ts +4 -0
- package/src/security/grants.ts +13 -1
- package/src/security/index.ts +3 -1
- package/src/security/registry.ts +107 -0
- package/src/security/types.ts +8 -12
- package/src/security/validation.ts +7 -0
- package/src/storage/action-runs/failure.ts +64 -0
- package/src/storage/action-runs/idempotency.ts +3 -1
- package/src/storage/action-runs/in-memory.ts +39 -9
- package/src/storage/action-runs/index.ts +3 -0
- package/src/storage/action-runs/provider.ts +25 -0
- package/src/storage/action-runs/types.ts +61 -27
- package/src/storage/agents/errors.ts +1 -0
- package/src/storage/agents/in-memory.ts +219 -14
- package/src/storage/agents/index.ts +7 -1
- package/src/storage/agents/provider.ts +252 -0
- package/src/storage/agents/types.ts +96 -22
- 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/errors.ts +13 -0
- package/src/storage/ai-usage/in-memory.ts +162 -0
- package/src/storage/ai-usage/index.ts +21 -0
- package/src/storage/ai-usage/record.ts +74 -0
- package/src/storage/ai-usage/types.ts +102 -0
- package/src/storage/ai-usage/usage.ts +104 -0
- package/src/storage/auth/types.ts +1 -0
- package/src/storage/connector-connections/errors.ts +24 -0
- package/src/storage/connector-connections/in-memory.ts +1377 -0
- package/src/storage/connector-connections/index.ts +66 -0
- package/src/storage/connector-connections/provider/authorizations.ts +446 -0
- package/src/storage/connector-connections/provider/connections.ts +291 -0
- package/src/storage/connector-connections/provider/runs.ts +369 -0
- package/src/storage/connector-connections/provider/shared.ts +342 -0
- package/src/storage/connector-connections/provider.ts +219 -0
- package/src/storage/connector-connections/types.ts +546 -0
- package/src/storage/executions/errors.ts +21 -0
- package/src/storage/executions/in-memory.ts +75 -0
- package/src/storage/executions/index.ts +16 -0
- package/src/storage/executions/provider.ts +292 -0
- package/src/storage/executions/run-link.ts +70 -0
- package/src/storage/executions/types.ts +49 -0
- package/src/storage/executions/validation.ts +370 -0
- package/src/storage/in-memory/index.ts +100 -16
- package/src/storage/index.ts +191 -15
- package/src/storage/ontology/commits.ts +1 -0
- package/src/storage/ontology/in-memory/index.ts +2 -0
- package/src/storage/ontology/in-memory/materializations-finalization.ts +2 -1
- package/src/storage/ontology/in-memory/materializations-state.ts +10 -0
- package/src/storage/ontology/in-memory/materializations-work.ts +2 -1
- package/src/storage/ontology/in-memory/materializations.ts +132 -9
- package/src/storage/ontology/in-memory/outbox.ts +1 -1
- package/src/storage/ontology/in-memory/shared-state.ts +12 -1
- package/src/storage/ontology/index.ts +6 -0
- package/src/storage/ontology/materializations.ts +53 -4
- package/src/storage/ontology/outbox.ts +13 -2
- package/src/storage/ontology/provider-header-validation.ts +1 -0
- package/src/storage/ontology/provider-work.ts +33 -14
- package/src/storage/ontology/provider.ts +72 -52
- package/src/storage/operation-scope.ts +2 -0
- package/src/storage/pipeline-runs/idempotency.ts +14 -0
- package/src/storage/pipeline-runs/in-memory.ts +88 -8
- package/src/storage/pipeline-runs/index.ts +5 -1
- package/src/storage/pipeline-runs/provider.ts +25 -0
- package/src/storage/pipeline-runs/types.ts +37 -14
- package/src/storage/projection-runs/in-memory.ts +93 -24
- package/src/storage/projection-runs/index.ts +4 -0
- package/src/storage/projection-runs/lifecycle.ts +165 -36
- package/src/storage/projection-runs/provider.ts +34 -0
- package/src/storage/projection-runs/types.ts +34 -11
- package/src/storage/run-listing.ts +22 -13
- package/src/storage/sync-runs/idempotency.ts +18 -0
- package/src/storage/sync-runs/in-memory.ts +90 -7
- package/src/storage/sync-runs/index.ts +4 -1
- package/src/storage/sync-runs/provider.ts +25 -0
- package/src/storage/sync-runs/types.ts +35 -11
- package/src/storage/types.ts +46 -17
- package/src/storage/webhook-runs/errors.ts +14 -0
- package/src/storage/webhook-runs/in-memory.ts +84 -9
- package/src/storage/webhook-runs/index.ts +5 -1
- package/src/storage/webhook-runs/provider.ts +30 -0
- package/src/storage/webhook-runs/types.ts +52 -11
- package/src/storage/workflow-runs/in-memory.ts +89 -55
- package/src/storage/workflow-runs/index.ts +2 -0
- package/src/storage/workflow-runs/provider.ts +70 -0
- package/src/storage/workflow-runs/types.ts +36 -25
- package/src/syncs/builders.ts +2 -2
- package/src/syncs/execution.ts +78 -0
- package/src/syncs/index.ts +13 -0
- package/src/syncs/request.ts +32 -43
- package/src/syncs/run-dispatch.ts +312 -0
- package/src/syncs/sources.ts +20 -0
- package/src/syncs/types.ts +32 -8
- package/src/testing/action-execution.ts +61 -0
- package/src/testing/agent-execution.ts +81 -0
- package/src/testing/agent-storage-contract.ts +498 -64
- package/src/testing/ai-cost-storage-contract.ts +320 -0
- package/src/testing/ai-usage-storage-contract.ts +528 -0
- package/src/testing/auth-storage-contract.ts +17 -1
- package/src/testing/broker-contract.ts +16 -1
- package/src/testing/connector-connection-storage-contract.ts +1052 -0
- package/src/testing/execution-storage-contract.ts +435 -0
- package/src/testing/execution.ts +48 -0
- package/src/testing/index.ts +57 -0
- package/src/testing/materializer-fixture.ts +11 -3
- package/src/testing/materializer-storage-contract.ts +333 -13
- package/src/testing/ontology-contract-fixture.ts +35 -2
- package/src/testing/ontology-storage-contract.ts +75 -14
- package/src/testing/pipeline-execution.ts +64 -0
- package/src/testing/projection-execution.ts +98 -0
- package/src/testing/projection-run-storage-contract.ts +215 -29
- package/src/testing/queues-contract.ts +40 -51
- package/src/testing/sync-execution.ts +61 -0
- package/src/testing/webhook-execution.ts +47 -0
- package/src/testing/webhook-run-storage-contract.ts +240 -0
- package/src/testing/workflow-execution.ts +77 -0
- package/src/webhooks/index.ts +2 -1
- package/src/webhooks/internal.ts +5 -0
- package/src/webhooks/registry.ts +60 -36
- package/src/webhooks/run-admission.ts +172 -0
- package/src/webhooks/types.ts +8 -5
- package/src/workers/queue-delivery.ts +25 -22
- package/src/workers/queue-worker.ts +76 -33
- package/src/workflows/execution.ts +313 -0
- package/src/workflows/failure.ts +63 -0
- package/src/workflows/index.ts +10 -1
- package/src/workflows/request.ts +39 -118
- package/src/workflows/run-dispatch.ts +359 -0
- package/src/workflows/types.ts +39 -8
- package/dist/actions/runtime.d.ts +0 -11
- package/dist/actions/runtime.d.ts.map +0 -1
- package/dist/agents/runtime.d.ts +0 -41
- package/dist/agents/runtime.d.ts.map +0 -1
- package/dist/chunk-4hwxq5e6.js +0 -49
- package/dist/chunk-4hwxq5e6.js.map +0 -10
- package/dist/chunk-4tvj3ate.js.map +0 -11
- package/dist/chunk-50kv63vj.js.map +0 -12
- package/dist/chunk-86459jn0.js +0 -1091
- package/dist/chunk-86459jn0.js.map +0 -22
- package/dist/chunk-867jxh7c.js.map +0 -19
- package/dist/chunk-9k3hgv8h.js +0 -352
- package/dist/chunk-9k3hgv8h.js.map +0 -13
- package/dist/chunk-avppcgt6.js.map +0 -14
- package/dist/chunk-b1bqvhpe.js.map +0 -13
- package/dist/chunk-b5dp7gaf.js +0 -1092
- package/dist/chunk-b5dp7gaf.js.map +0 -26
- package/dist/chunk-bh8bwma3.js +0 -37
- package/dist/chunk-bh8bwma3.js.map +0 -10
- package/dist/chunk-btcsywk4.js +0 -985
- package/dist/chunk-btcsywk4.js.map +0 -15
- package/dist/chunk-exrfbt2d.js +0 -354
- package/dist/chunk-exrfbt2d.js.map +0 -17
- package/dist/chunk-hb9xcx9c.js.map +0 -14
- package/dist/chunk-k25jm1x5.js +0 -102
- package/dist/chunk-k25jm1x5.js.map +0 -10
- package/dist/chunk-k6j72mtt.js +0 -9
- package/dist/chunk-k6j72mtt.js.map +0 -10
- package/dist/chunk-m9w0artv.js +0 -554
- package/dist/chunk-m9w0artv.js.map +0 -13
- package/dist/chunk-nbywkytr.js.map +0 -16
- package/dist/chunk-p7vj8xgb.js.map +0 -34
- package/dist/chunk-raq0x6bd.js.map +0 -48
- package/dist/chunk-rgzed50y.js +0 -1445
- package/dist/chunk-rgzed50y.js.map +0 -22
- package/dist/chunk-rjqm6ksg.js.map +0 -44
- package/dist/chunk-t72dvahb.js.map +0 -12
- package/dist/chunk-v5c085yp.js.map +0 -10
- package/dist/chunk-xt6qx9sh.js.map +0 -36
- package/dist/chunk-xz5g49bp.js.map +0 -11
- package/dist/chunk-ya6brh8a.js.map +0 -11
- package/dist/chunk-yn947ck3.js.map +0 -14
- package/dist/connectors/runtime.d.ts +0 -13
- package/dist/connectors/runtime.d.ts.map +0 -1
- package/dist/events/runtime.d.ts.map +0 -1
- package/dist/objects/contexts.d.ts +0 -45
- package/dist/objects/contexts.d.ts.map +0 -1
- package/dist/objects/helpers.d.ts +0 -7
- package/dist/objects/helpers.d.ts.map +0 -1
- package/dist/runtime/scoped.d.ts +0 -158
- package/dist/runtime/scoped.d.ts.map +0 -1
- package/dist/security/runtime.d.ts +0 -16
- package/dist/security/runtime.d.ts.map +0 -1
- package/dist/storage/webhook-deliveries/in-memory.d.ts +0 -18
- package/dist/storage/webhook-deliveries/in-memory.d.ts.map +0 -1
- package/dist/storage/webhook-deliveries/index.d.ts +0 -3
- package/dist/storage/webhook-deliveries/index.d.ts.map +0 -1
- package/dist/storage/webhook-deliveries/types.d.ts +0 -43
- package/dist/storage/webhook-deliveries/types.d.ts.map +0 -1
- package/dist/workflows/runtime.d.ts +0 -33
- package/dist/workflows/runtime.d.ts.map +0 -1
- package/src/actions/runtime.ts +0 -31
- package/src/agents/runtime.ts +0 -124
- package/src/connectors/runtime.ts +0 -100
- package/src/objects/contexts.ts +0 -64
- package/src/objects/helpers.ts +0 -18
- package/src/runtime/scoped.ts +0 -436
- package/src/security/runtime.ts +0 -101
- package/src/storage/webhook-deliveries/in-memory.ts +0 -108
- package/src/storage/webhook-deliveries/index.ts +0 -9
- package/src/storage/webhook-deliveries/types.ts +0 -41
- package/src/workflows/runtime.ts +0 -68
- /package/dist/{chunk-md9jbrm9.js.map → chunk-4gz41why.js.map} +0 -0
- /package/dist/{chunk-6rzdtvn5.js.map → chunk-8b55ygje.js.map} +0 -0
- /package/dist/{chunk-r82k4z7z.js.map → chunk-a31h57d5.js.map} +0 -0
- /package/dist/{chunk-qzyemcj7.js.map → chunk-ckxfnx7f.js.map} +0 -0
- /package/dist/{chunk-53s4asfm.js.map → chunk-rnshztfq.js.map} +0 -0
- /package/dist/{chunk-8kv2sez0.js.map → chunk-vybf6pkp.js.map} +0 -0
- /package/dist/{chunk-6zrpewy4.js.map → chunk-z3zp0bj1.js.map} +0 -0
- /package/dist/{chunk-hz8m927w.js.map → chunk-zqysyfjt.js.map} +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/storage/ai-usage/errors.ts", "../src/storage/ai-usage/usage.ts", "../src/storage/ai-usage/record.ts", "../src/storage/ai-usage/in-memory.ts", "../src/storage/ai-cost/analytics.ts", "../src/storage/ai-cost/validation.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"export type AiUsageStorageErrorCode = \"duplicate_id\" | \"missing_execution\"\n\n/** Storage failure specific to the AI model-call usage ledger. */\nexport class AiUsageStorageError extends Error {\n readonly name = \"AiUsageStorageError\"\n\n constructor(\n readonly code: AiUsageStorageErrorCode,\n message: string\n ) {\n super(message)\n }\n}\n",
|
|
6
|
+
"import type { AiModelCallUsage, AiModelCallUsageInput } from \"./types\"\n\nconst USAGE_FIELDS = [\n \"inputTokens\",\n \"outputTokens\",\n \"uncachedInputTokens\",\n \"cacheReadInputTokens\",\n \"cacheWriteInputTokens\",\n \"textOutputTokens\",\n \"reasoningOutputTokens\",\n] as const\n\ntype AiUsageField = (typeof USAGE_FIELDS)[number]\n\n/** Validate provider-neutral counts and derive total/reporting fields without inventing zeroes. */\nexport function normalizeAiModelCallUsage(input: AiModelCallUsageInput): AiModelCallUsage {\n for (const field of USAGE_FIELDS) {\n assertUsageCount(input[field], field)\n }\n\n const totalTokens =\n input.inputTokens === undefined || input.outputTokens === undefined\n ? undefined\n : addUsageCounts(input.inputTokens, input.outputTokens, \"totalTokens\")\n const reportingStatus =\n input.inputTokens !== undefined && input.outputTokens !== undefined\n ? \"complete\"\n : USAGE_FIELDS.some((field) => input[field] !== undefined)\n ? \"partial\"\n : \"unavailable\"\n\n return {\n ...(input.inputTokens === undefined ? {} : { inputTokens: input.inputTokens }),\n ...(input.outputTokens === undefined ? {} : { outputTokens: input.outputTokens }),\n ...(totalTokens === undefined ? {} : { totalTokens }),\n ...(input.uncachedInputTokens === undefined\n ? {}\n : { uncachedInputTokens: input.uncachedInputTokens }),\n ...(input.cacheReadInputTokens === undefined\n ? {}\n : { cacheReadInputTokens: input.cacheReadInputTokens }),\n ...(input.cacheWriteInputTokens === undefined\n ? {}\n : { cacheWriteInputTokens: input.cacheWriteInputTokens }),\n ...(input.textOutputTokens === undefined ? {} : { textOutputTokens: input.textOutputTokens }),\n ...(input.reasoningOutputTokens === undefined\n ? {}\n : { reasoningOutputTokens: input.reasoningOutputTokens }),\n reportingStatus,\n }\n}\n\n/**\n * Aggregate model-call usage without treating a missing count as zero.\n *\n * A field is present only when every call reported it. This prevents a partial provider response\n * from becoming an apparently complete execution total. Zero remains a reported value.\n */\nexport function aggregateAiModelCallUsage(\n usages: Iterable<AiModelCallUsageInput>\n): AiModelCallUsage {\n const normalized = Array.from(usages, normalizeAiModelCallUsage)\n const fields = Object.fromEntries(\n USAGE_FIELDS.map((field) => [field, sumUsageField(normalized, field)])\n ) as Record<AiUsageField, number | undefined>\n const aggregate = normalizeAiModelCallUsage(fields)\n\n if (\n aggregate.reportingStatus === \"unavailable\" &&\n normalized.some((usage) => usage.reportingStatus !== \"unavailable\")\n ) {\n return { ...aggregate, reportingStatus: \"partial\" }\n }\n return aggregate\n}\n\nfunction sumUsageField(\n usages: readonly AiModelCallUsage[],\n field: AiUsageField\n): number | undefined {\n if (usages.length === 0) return undefined\n\n let total = 0\n for (const usage of usages) {\n const value = usage[field]\n if (value === undefined) return undefined\n total = addUsageCounts(total, value, `aggregate ${field}`)\n }\n return total\n}\n\nfunction assertUsageCount(value: number | undefined, field: AiUsageField): void {\n if (value !== undefined && (!Number.isSafeInteger(value) || value < 0)) {\n throw new TypeError(`[Sixb] AI model-call usage ${field} must be a non-negative safe integer.`)\n }\n}\n\nfunction addUsageCounts(left: number, right: number, field: string): number {\n const result = left + right\n if (!Number.isSafeInteger(result)) {\n throw new TypeError(`[Sixb] AI model-call usage ${field} exceeds the safe integer range.`)\n }\n return result\n}\n",
|
|
7
|
+
"import { normalizeRequesterGroupIds } from \"../../auth/attribution\"\nimport { assertJsonValue, isPlainRecord } from \"../../json\"\nimport type { AiModelCallUsageRecord, RecordAiModelCallInput } from \"./types\"\nimport { normalizeAiModelCallUsage } from \"./usage\"\n\n/** Validate and defensively snapshot one provider-neutral model-call ledger input. */\nexport function normalizeAiModelCallRecord(input: RecordAiModelCallInput): AiModelCallUsageRecord {\n assertNonBlank(input.id, \"id\")\n assertNonBlank(input.projectId, \"projectId\")\n assertAiUsageExecutionId(input.executionId)\n assertPositiveSafeInteger(input.attempt, \"attempt\")\n assertNonBlank(input.callId, \"callId\")\n assertNonBlank(input.providerId, \"providerId\")\n assertNonBlank(input.requestedModelId, \"requestedModelId\")\n if (input.responseModelId !== undefined) {\n assertNonBlank(input.responseModelId, \"responseModelId\")\n }\n assertNonBlank(input.responseId, \"responseId\")\n\n const occurredAt = cloneValidDate(input.occurredAt, \"occurredAt\")\n const recordedAt = cloneValidDate(input.recordedAt ?? new Date(), \"recordedAt\")\n const requesterGroupIds = normalizeRequesterGroupIds(input.requesterGroupIds)\n const rawUsage = cloneRawUsage(input.rawUsage)\n\n return {\n id: input.id,\n projectId: input.projectId,\n executionId: input.executionId,\n attempt: input.attempt,\n callId: input.callId,\n requesterGroupIds,\n providerId: input.providerId,\n requestedModelId: input.requestedModelId,\n ...(input.responseModelId === undefined ? {} : { responseModelId: input.responseModelId }),\n responseId: input.responseId,\n usage: normalizeAiModelCallUsage(input.usage),\n ...(rawUsage === undefined ? {} : { rawUsage }),\n occurredAt,\n recordedAt,\n }\n}\n\n/** Validate a durable execution reference at storage and query boundaries. */\nexport function assertAiUsageExecutionId(executionId: string): void {\n assertNonBlank(executionId, \"executionId\")\n}\n\nfunction cloneRawUsage(rawUsage: RecordAiModelCallInput[\"rawUsage\"]) {\n if (rawUsage === undefined) return undefined\n if (!isPlainRecord(rawUsage)) {\n throw new TypeError(\"[Sixb] AI usage rawUsage must be a JSON object.\")\n }\n assertJsonValue(rawUsage, \"AI usage rawUsage\")\n return structuredClone(rawUsage)\n}\n\nfunction assertNonBlank(value: string, field: string): void {\n if (typeof value !== \"string\" || value.trim().length === 0) {\n throw new TypeError(`[Sixb] AI usage ${field} must be nonblank.`)\n }\n}\n\nfunction assertPositiveSafeInteger(value: number, field: string): void {\n if (!Number.isSafeInteger(value) || value <= 0) {\n throw new TypeError(`[Sixb] AI usage ${field} must be a positive safe integer.`)\n }\n}\n\nfunction cloneValidDate(value: Date, field: string): Date {\n if (!(value instanceof Date) || !Number.isFinite(value.getTime())) {\n throw new TypeError(`[Sixb] AI usage ${field} must be a valid Date.`)\n }\n return new Date(value)\n}\n",
|
|
8
|
+
"import type { ExecutionStorage } from \"../executions\"\nimport { AiUsageStorageError } from \"./errors\"\nimport { assertAiUsageExecutionId, normalizeAiModelCallRecord } from \"./record\"\nimport type {\n AiModelCallUsageRecord,\n AiUsageExecutionSummary,\n AiUsageStorage,\n RecordAiModelCallInput,\n RecordAiModelCallResult,\n SummarizeAiUsageExecutionInput,\n SummarizeAiUsageExecutionsInput,\n} from \"./types\"\nimport { aggregateAiModelCallUsage } from \"./usage\"\n\nexport interface InMemoryAiUsageGroupRow {\n readonly projectId: string\n readonly usageRecordId: string\n readonly groupId: string\n readonly occurredAt: Date\n}\n\nexport interface InMemoryAiUsageStorageSnapshot {\n readonly records: Map<string, AiModelCallUsageRecord>\n readonly recordKeysByIdempotencyKey: Map<string, string>\n readonly groupRows: Map<string, InMemoryAiUsageGroupRow>\n}\n\n/** In-memory model-call ledger used by development runtimes and storage contract tests. */\nexport class InMemoryAiUsageStorage implements AiUsageStorage {\n private readonly records = new Map<string, AiModelCallUsageRecord>()\n private readonly recordKeysByIdempotencyKey = new Map<string, string>()\n private readonly groupRows = new Map<string, InMemoryAiUsageGroupRow>()\n\n constructor(private readonly executions: Pick<ExecutionStorage, \"getById\">) {}\n\n async recordModelCall(input: RecordAiModelCallInput): Promise<RecordAiModelCallResult> {\n const record = normalizeAiModelCallRecord(input)\n await this.assertExecutionExists(record.projectId, record.executionId)\n const idempotencyKey = modelCallIdempotencyKey(record)\n const existingRecordKey = this.recordKeysByIdempotencyKey.get(idempotencyKey)\n if (existingRecordKey !== undefined) {\n const existing = this.records.get(existingRecordKey)\n if (!existing) {\n throw new Error(\"[Sixb] In-memory AI usage idempotency index is inconsistent.\")\n }\n return { record: structuredClone(existing), created: false }\n }\n\n const recordKey = modelCallRecordKey(record.projectId, record.id)\n if (this.records.has(recordKey)) {\n throw new AiUsageStorageError(\n \"duplicate_id\",\n `[Sixb] AI usage record '${record.id}' already exists for project '${record.projectId}'.`\n )\n }\n\n this.records.set(recordKey, structuredClone(record))\n this.recordKeysByIdempotencyKey.set(idempotencyKey, recordKey)\n for (const groupId of record.requesterGroupIds) {\n const row: InMemoryAiUsageGroupRow = {\n projectId: record.projectId,\n usageRecordId: record.id,\n groupId,\n occurredAt: record.occurredAt,\n }\n this.groupRows.set(groupRowKey(row), row)\n }\n\n return { record: structuredClone(record), created: true }\n }\n\n async summarizeExecution(\n input: SummarizeAiUsageExecutionInput\n ): Promise<AiUsageExecutionSummary> {\n const [summary] = await this.summarizeExecutions({\n projectId: input.projectId,\n executionIds: [input.executionId],\n })\n return summary!\n }\n\n async summarizeExecutions(\n input: SummarizeAiUsageExecutionsInput\n ): Promise<readonly AiUsageExecutionSummary[]> {\n if (typeof input.projectId !== \"string\" || input.projectId.trim().length === 0) {\n throw new TypeError(\"[Sixb] AI usage projectId must be nonblank.\")\n }\n\n const usageByExecutionId = new Map<string, AiModelCallUsageRecord[\"usage\"][]>()\n for (const executionId of input.executionIds) {\n assertAiUsageExecutionId(executionId)\n usageByExecutionId.set(executionId, [])\n }\n if (usageByExecutionId.size === 0) return []\n\n for (const record of this.records.values()) {\n if (record.projectId !== input.projectId) continue\n usageByExecutionId.get(record.executionId)?.push(record.usage)\n }\n\n return input.executionIds.map((executionId) => {\n const usages = usageByExecutionId.get(executionId) ?? []\n return {\n modelCallCount: usages.length,\n usage: aggregateAiModelCallUsage(usages),\n }\n })\n }\n\n snapshot(): InMemoryAiUsageStorageSnapshot {\n return structuredClone({\n records: this.records,\n recordKeysByIdempotencyKey: this.recordKeysByIdempotencyKey,\n groupRows: this.groupRows,\n })\n }\n\n restore(snapshot: InMemoryAiUsageStorageSnapshot): void {\n replaceMap(this.records, snapshot.records)\n replaceMap(this.recordKeysByIdempotencyKey, snapshot.recordKeysByIdempotencyKey)\n replaceMap(this.groupRows, snapshot.groupRows)\n }\n\n private async assertExecutionExists(projectId: string, executionId: string): Promise<void> {\n const execution = await this.executions.getById({ projectId, id: executionId })\n if (execution) return\n throw new AiUsageStorageError(\n \"missing_execution\",\n `[Sixb] AI usage execution '${executionId}' does not exist in project '${projectId}'.`\n )\n }\n}\n\nfunction modelCallRecordKey(projectId: string, id: string): string {\n return JSON.stringify([projectId, id])\n}\n\nfunction modelCallIdempotencyKey(\n record: Pick<\n AiModelCallUsageRecord,\n \"projectId\" | \"executionId\" | \"attempt\" | \"callId\" | \"responseId\"\n >\n): string {\n return JSON.stringify([\n record.projectId,\n record.executionId,\n record.attempt,\n record.callId,\n record.responseId,\n ])\n}\n\nfunction groupRowKey(row: InMemoryAiUsageGroupRow): string {\n return JSON.stringify([row.projectId, row.usageRecordId, row.groupId])\n}\n\nfunction replaceMap<TKey, TValue>(target: Map<TKey, TValue>, source: Map<TKey, TValue>): void {\n target.clear()\n for (const [key, value] of structuredClone(source)) {\n target.set(key, value)\n }\n}\n",
|
|
9
|
+
"import {\n type AiModelCallUsage,\n type AiModelCallUsageRecord,\n aggregateAiModelCallUsage,\n normalizeAiModelCallUsage,\n} from \"../ai-usage\"\nimport type {\n AiAccountingAgentBreakdown,\n AiAccountingAggregate,\n AiAccountingAttribution,\n AiAccountingBucket,\n AiAccountingModelBreakdown,\n AiAccountingOverview,\n AiAccountingTimeBucket,\n AiAccountingWorkflowBreakdown,\n AiCostSummary,\n AiModelCallAccountingItem,\n AiModelCallCostRecord,\n AiMoney,\n ListAiModelCallAccountingInput,\n ListAiModelCallAccountingResult,\n QueryAiAccountingOverviewInput,\n} from \"./types\"\n\nconst DEFAULT_MODEL_CALL_PAGE_SIZE = 50\nconst MAX_MODEL_CALL_PAGE_SIZE = 200\nconst MAX_CHART_BUCKETS = 10_000\n\n/** One joined immutable model-call row used by in-memory analytics and bounded SQL pages. */\nexport interface AiAccountingRecordSetItem {\n readonly usage: AiModelCallUsageRecord\n readonly attribution?: AiAccountingAttribution\n readonly cost?: AiModelCallCostRecord\n}\n\nexport interface NormalizedAiAccountingQuery {\n readonly projectId: string\n readonly from: Date\n readonly to: Date\n readonly providerId?: string\n readonly modelId?: string\n}\n\nexport interface NormalizedAiModelCallAccountingQuery extends NormalizedAiAccountingQuery {\n readonly executionId?: string\n readonly valuationStatus?: ListAiModelCallAccountingInput[\"valuationStatus\"]\n readonly limit: number\n readonly offset: number\n}\n\ninterface AiAccountingUsageMeterFragment {\n readonly presentCallCount: string\n readonly total: string | null\n}\n\n/** One SQL-aggregated currency fragment; providers merge fragments without loading model calls. */\nexport interface AiAccountingAggregateFragment {\n readonly dimension: \"totals\" | \"series\" | \"model\" | \"agent\" | \"workflow\"\n readonly start?: Date\n readonly providerId?: string\n readonly modelId?: string\n readonly agentId?: string\n readonly workflowId?: string\n readonly modelCallCount: string\n readonly usage: {\n readonly reportedCallCount: string\n readonly inputTokens: AiAccountingUsageMeterFragment\n readonly outputTokens: AiAccountingUsageMeterFragment\n readonly uncachedInputTokens: AiAccountingUsageMeterFragment\n readonly cacheReadInputTokens: AiAccountingUsageMeterFragment\n readonly cacheWriteInputTokens: AiAccountingUsageMeterFragment\n readonly textOutputTokens: AiAccountingUsageMeterFragment\n readonly reasoningOutputTokens: AiAccountingUsageMeterFragment\n }\n readonly costs: {\n readonly amount?: AiMoney\n readonly ratedCallCount: string\n readonly unpriceableCallCount: string\n readonly unvaluedCallCount: string\n }\n}\n\nexport function normalizeAiAccountingQuery(\n input: Omit<QueryAiAccountingOverviewInput, \"bucket\"> | ListAiModelCallAccountingInput\n): NormalizedAiAccountingQuery {\n assertNonBlank(input.projectId, \"accounting projectId\")\n assertDate(input.from, \"accounting from\")\n assertDate(input.to, \"accounting to\")\n if (input.from.getTime() >= input.to.getTime()) {\n throw new TypeError(\"[Sixb] AI accounting from must be before to.\")\n }\n if (input.providerId !== undefined) assertNonBlank(input.providerId, \"accounting providerId\")\n if (input.modelId !== undefined) assertNonBlank(input.modelId, \"accounting modelId\")\n return {\n projectId: input.projectId,\n from: new Date(input.from),\n to: new Date(input.to),\n ...(input.providerId === undefined ? {} : { providerId: input.providerId }),\n ...(input.modelId === undefined ? {} : { modelId: input.modelId }),\n }\n}\n\nexport function normalizeAiModelCallAccountingQuery(\n input: ListAiModelCallAccountingInput\n): NormalizedAiModelCallAccountingQuery {\n const query = normalizeAiAccountingQuery(input)\n if (input.executionId !== undefined) {\n assertNonBlank(input.executionId, \"accounting executionId\")\n }\n const { limit, offset } = normalizePage(input.limit, input.offset)\n return {\n ...query,\n ...(input.executionId === undefined ? {} : { executionId: input.executionId }),\n ...(input.valuationStatus === undefined ? {} : { valuationStatus: input.valuationStatus }),\n limit,\n offset,\n }\n}\n\nexport function aiAccountingItemMatchesQuery(\n item: AiAccountingRecordSetItem,\n query: NormalizedAiAccountingQuery\n): boolean {\n const occurredAt = item.usage.occurredAt.getTime()\n return (\n item.usage.projectId === query.projectId &&\n occurredAt >= query.from.getTime() &&\n occurredAt < query.to.getTime() &&\n (query.providerId === undefined || item.usage.providerId === query.providerId) &&\n (query.modelId === undefined || item.usage.requestedModelId === query.modelId)\n )\n}\n\nexport function buildAiAccountingOverview(\n input: QueryAiAccountingOverviewInput,\n source: Iterable<AiAccountingRecordSetItem>\n): AiAccountingOverview {\n const query = normalizeAiAccountingQuery(input)\n assertAiAccountingBucket(input.bucket)\n const items = Array.from(source).filter((item) => aiAccountingItemMatchesQuery(item, query))\n const periods = accountingPeriods(query.from, query.to, input.bucket)\n const periodItems = new Map<number, AiAccountingRecordSetItem[]>(\n periods.map((period) => [period.start.getTime(), []])\n )\n const modelItems = new Map<string, AiAccountingRecordSetItem[]>()\n const agentItems = new Map<string, AiAccountingRecordSetItem[]>()\n const workflowItems = new Map<string, AiAccountingRecordSetItem[]>()\n\n for (const item of items) {\n const periodStart = aiAccountingBucketStart(item.usage.occurredAt, input.bucket).getTime()\n periodItems.get(periodStart)?.push(item)\n appendGrouped(\n modelItems,\n JSON.stringify([item.usage.providerId, item.usage.requestedModelId]),\n item\n )\n if (item.attribution) appendGrouped(agentItems, item.attribution.agentId, item)\n if (item.attribution?.kind === \"workflowAgent\") {\n appendGrouped(workflowItems, item.attribution.workflowId, item)\n }\n }\n\n const series: AiAccountingTimeBucket[] = periods.map((period) => ({\n ...period,\n ...aggregateAccountingItems(periodItems.get(period.start.getTime()) ?? []),\n }))\n const models: AiAccountingModelBreakdown[] = [...modelItems]\n .map(([key, grouped]) => {\n const [providerId, modelId] = JSON.parse(key) as [string, string]\n return { providerId, modelId, ...aggregateAccountingItems(grouped) }\n })\n .sort(compareModelBreakdowns)\n const agents: AiAccountingAgentBreakdown[] = [...agentItems]\n .map(([agentId, grouped]) => ({ agentId, ...aggregateAccountingItems(grouped) }))\n .sort(compareAgentBreakdowns)\n const workflows: AiAccountingWorkflowBreakdown[] = [...workflowItems]\n .map(([workflowId, grouped]) => ({ workflowId, ...aggregateAccountingItems(grouped) }))\n .sort(compareWorkflowBreakdowns)\n\n return structuredClone({\n range: { from: query.from, to: query.to },\n bucket: input.bucket,\n totals: aggregateAccountingItems(items),\n series,\n models,\n agents,\n workflows,\n })\n}\n\nexport function buildAiAccountingOverviewFromFragments(\n input: QueryAiAccountingOverviewInput,\n fragments: Iterable<AiAccountingAggregateFragment>\n): AiAccountingOverview {\n const query = normalizeAiAccountingQuery(input)\n const periods = accountingPeriods(query.from, query.to, input.bucket)\n const totals = aggregateFragmentAccumulator()\n const series = new Map<number, AggregateFragmentAccumulator>(\n periods.map((period) => [period.start.getTime(), aggregateFragmentAccumulator()])\n )\n const models = new Map<string, AggregateFragmentAccumulator>()\n const agents = new Map<string, AggregateFragmentAccumulator>()\n const workflows = new Map<string, AggregateFragmentAccumulator>()\n\n for (const fragment of fragments) {\n let target: AggregateFragmentAccumulator\n switch (fragment.dimension) {\n case \"totals\":\n target = totals\n break\n case \"series\": {\n const start = requiredFragmentDate(fragment.start, \"series start\")\n const existing = series.get(start.getTime())\n if (!existing) {\n throw new TypeError(\"[Sixb] AI accounting SQL series returned an unexpected bucket.\")\n }\n target = existing\n break\n }\n case \"model\":\n target = getFragmentAccumulator(\n models,\n JSON.stringify([\n requiredFragmentString(fragment.providerId, \"providerId\"),\n requiredFragmentString(fragment.modelId, \"modelId\"),\n ])\n )\n break\n case \"agent\":\n target = getFragmentAccumulator(agents, requiredFragmentString(fragment.agentId, \"agentId\"))\n break\n case \"workflow\":\n target = getFragmentAccumulator(\n workflows,\n requiredFragmentString(fragment.workflowId, \"workflowId\")\n )\n break\n }\n appendAggregateFragment(target, fragment)\n }\n\n return structuredClone({\n range: { from: query.from, to: query.to },\n bucket: input.bucket,\n totals: finishAggregateFragment(totals),\n series: periods.map((period) => ({\n ...period,\n ...finishAggregateFragment(series.get(period.start.getTime())!),\n })),\n models: [...models]\n .map(([key, value]) => {\n const [providerId, modelId] = JSON.parse(key) as [string, string]\n return { providerId, modelId, ...finishAggregateFragment(value) }\n })\n .sort(compareModelBreakdowns),\n agents: [...agents]\n .map(([agentId, value]) => ({ agentId, ...finishAggregateFragment(value) }))\n .sort(compareAgentBreakdowns),\n workflows: [...workflows]\n .map(([workflowId, value]) => ({ workflowId, ...finishAggregateFragment(value) }))\n .sort(compareWorkflowBreakdowns),\n })\n}\n\nexport function buildAiModelCallAccountingList(\n input: ListAiModelCallAccountingInput,\n source: Iterable<AiAccountingRecordSetItem>\n): ListAiModelCallAccountingResult {\n const query = normalizeAiModelCallAccountingQuery(input)\n const { limit, offset } = query\n const items = Array.from(source)\n .filter((item) => aiAccountingItemMatchesQuery(item, query))\n .map(toAccountingItem)\n .filter(\n (item) =>\n (input.executionId === undefined || item.usage.executionId === input.executionId) &&\n (input.valuationStatus === undefined || item.valuationStatus === input.valuationStatus)\n )\n .sort(compareAccountingItems)\n const page = items.slice(offset, offset + limit)\n return structuredClone({\n items: page,\n hasMore: offset + page.length < items.length,\n total: items.length,\n })\n}\n\nexport function toAccountingItem(item: AiAccountingRecordSetItem): AiModelCallAccountingItem {\n return {\n usage: item.usage,\n ...(item.attribution === undefined ? {} : { attribution: item.attribution }),\n ...(item.cost === undefined ? {} : { cost: item.cost }),\n valuationStatus: item.cost?.status ?? \"unvalued\",\n }\n}\n\nexport function aiAccountingBucketStart(at: Date, bucket: AiAccountingBucket): Date {\n assertDate(at, \"accounting bucket timestamp\")\n assertAiAccountingBucket(bucket)\n const start = new Date(at)\n start.setUTCMinutes(0, 0, 0)\n if (bucket === \"hour\") return start\n start.setUTCHours(0)\n if (bucket === \"day\") return start\n const mondayOffset = (start.getUTCDay() + 6) % 7\n start.setUTCDate(start.getUTCDate() - mondayOffset)\n return start\n}\n\nfunction aggregateAccountingItems(\n items: readonly AiAccountingRecordSetItem[]\n): AiAccountingAggregate {\n return {\n modelCallCount: items.length,\n usage: aggregateAiModelCallUsage(items.map((item) => item.usage.usage)),\n costs: aggregateCosts(items),\n }\n}\n\nfunction aggregateCosts(items: readonly AiAccountingRecordSetItem[]): AiCostSummary {\n const amounts = new Map<string, bigint>()\n let ratedCallCount = 0\n let unpriceableCallCount = 0\n let unvaluedCallCount = 0\n for (const item of items) {\n if (item.cost?.status === \"rated\") {\n ratedCallCount += 1\n addAmount(amounts, item.cost.money.currency, item.cost.money.amountNanos)\n } else if (item.cost?.status === \"unpriceable\") {\n unpriceableCallCount += 1\n } else {\n unvaluedCallCount += 1\n }\n }\n return {\n amounts: [...amounts]\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([currency, amountNanos]) => ({ currency, amountNanos: amountNanos.toString() })),\n ratedCallCount,\n unpriceableCallCount,\n unvaluedCallCount,\n }\n}\n\nconst AGGREGATE_USAGE_FIELDS = [\n \"inputTokens\",\n \"outputTokens\",\n \"uncachedInputTokens\",\n \"cacheReadInputTokens\",\n \"cacheWriteInputTokens\",\n \"textOutputTokens\",\n \"reasoningOutputTokens\",\n] as const\n\ntype AggregateUsageField = (typeof AGGREGATE_USAGE_FIELDS)[number]\n\ninterface AggregateFragmentAccumulator {\n modelCallCount: bigint\n reportedUsageCallCount: bigint\n usage: Record<AggregateUsageField, { presentCallCount: bigint; total: bigint }>\n amounts: Map<string, bigint>\n ratedCallCount: bigint\n unpriceableCallCount: bigint\n unvaluedCallCount: bigint\n}\n\nfunction aggregateFragmentAccumulator(): AggregateFragmentAccumulator {\n return {\n modelCallCount: 0n,\n reportedUsageCallCount: 0n,\n usage: Object.fromEntries(\n AGGREGATE_USAGE_FIELDS.map((field) => [field, { presentCallCount: 0n, total: 0n }])\n ) as AggregateFragmentAccumulator[\"usage\"],\n amounts: new Map(),\n ratedCallCount: 0n,\n unpriceableCallCount: 0n,\n unvaluedCallCount: 0n,\n }\n}\n\nfunction getFragmentAccumulator(\n values: Map<string, AggregateFragmentAccumulator>,\n key: string\n): AggregateFragmentAccumulator {\n const existing = values.get(key)\n if (existing) return existing\n const created = aggregateFragmentAccumulator()\n values.set(key, created)\n return created\n}\n\nfunction appendAggregateFragment(\n target: AggregateFragmentAccumulator,\n fragment: AiAccountingAggregateFragment\n): void {\n target.modelCallCount += naturalBigInt(fragment.modelCallCount, \"modelCallCount\")\n target.reportedUsageCallCount += naturalBigInt(\n fragment.usage.reportedCallCount,\n \"reported usage call count\"\n )\n for (const field of AGGREGATE_USAGE_FIELDS) {\n const source = fragment.usage[field]\n const presentCallCount = naturalBigInt(source.presentCallCount, `${field} call count`)\n target.usage[field].presentCallCount += presentCallCount\n if (source.total !== null) {\n target.usage[field].total += naturalBigInt(source.total, `${field} total`)\n } else if (presentCallCount !== 0n) {\n throw new TypeError(`[Sixb] AI accounting SQL ${field} total is missing.`)\n }\n }\n target.ratedCallCount += naturalBigInt(fragment.costs.ratedCallCount, \"rated call count\")\n target.unpriceableCallCount += naturalBigInt(\n fragment.costs.unpriceableCallCount,\n \"unpriceable call count\"\n )\n target.unvaluedCallCount += naturalBigInt(fragment.costs.unvaluedCallCount, \"unvalued call count\")\n if (fragment.costs.amount) {\n addAmount(target.amounts, fragment.costs.amount.currency, fragment.costs.amount.amountNanos)\n }\n}\n\nfunction finishAggregateFragment(value: AggregateFragmentAccumulator): AiAccountingAggregate {\n const classifiedCallCount =\n value.ratedCallCount + value.unpriceableCallCount + value.unvaluedCallCount\n if (\n classifiedCallCount !== value.modelCallCount ||\n value.reportedUsageCallCount > value.modelCallCount ||\n AGGREGATE_USAGE_FIELDS.some(\n (field) => value.usage[field].presentCallCount > value.modelCallCount\n )\n ) {\n throw new TypeError(\"[Sixb] AI accounting SQL aggregate counts are inconsistent.\")\n }\n const modelCallCount = safeAggregateNumber(value.modelCallCount, \"model-call count\")\n const usageInput: Partial<Record<AggregateUsageField, number>> = {}\n if (value.modelCallCount > 0n) {\n for (const field of AGGREGATE_USAGE_FIELDS) {\n const aggregate = value.usage[field]\n if (aggregate.presentCallCount === value.modelCallCount) {\n usageInput[field] = safeAggregateNumber(aggregate.total, field)\n }\n }\n }\n let usage: AiModelCallUsage = normalizeAiModelCallUsage(usageInput)\n if (usage.reportingStatus === \"unavailable\" && value.reportedUsageCallCount > 0n) {\n usage = { ...usage, reportingStatus: \"partial\" }\n }\n return {\n modelCallCount,\n usage,\n costs: {\n amounts: [...value.amounts]\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([currency, amountNanos]) => ({ currency, amountNanos: amountNanos.toString() })),\n ratedCallCount: safeAggregateNumber(value.ratedCallCount, \"rated call count\"),\n unpriceableCallCount: safeAggregateNumber(\n value.unpriceableCallCount,\n \"unpriceable call count\"\n ),\n unvaluedCallCount: safeAggregateNumber(value.unvaluedCallCount, \"unvalued call count\"),\n },\n }\n}\n\nfunction naturalBigInt(value: string, field: string): bigint {\n if (!/^(0|[1-9]\\d*)$/.test(value)) {\n throw new TypeError(`[Sixb] AI accounting SQL ${field} must be a natural integer.`)\n }\n return BigInt(value)\n}\n\nfunction safeAggregateNumber(value: bigint, field: string): number {\n if (value > BigInt(Number.MAX_SAFE_INTEGER)) {\n throw new TypeError(`[Sixb] AI accounting ${field} exceeds the safe integer range.`)\n }\n return Number(value)\n}\n\nfunction requiredFragmentString(value: string | undefined, field: string): string {\n if (value === undefined || value.length === 0) {\n throw new TypeError(`[Sixb] AI accounting SQL ${field} is missing.`)\n }\n return value\n}\n\nfunction requiredFragmentDate(value: Date | undefined, field: string): Date {\n if (value === undefined) throw new TypeError(`[Sixb] AI accounting SQL ${field} is missing.`)\n assertDate(value, field)\n return value\n}\n\nfunction accountingPeriods(\n from: Date,\n to: Date,\n bucket: AiAccountingBucket\n): Array<{ start: Date; end: Date }> {\n const result: Array<{ start: Date; end: Date }> = []\n let cursor = aiAccountingBucketStart(from, bucket)\n while (cursor.getTime() < to.getTime()) {\n if (result.length >= MAX_CHART_BUCKETS) {\n throw new RangeError(`[Sixb] AI accounting query exceeds ${MAX_CHART_BUCKETS} chart buckets.`)\n }\n const next = nextBucket(cursor, bucket)\n result.push({ start: new Date(cursor), end: next })\n cursor = next\n }\n return result\n}\n\nfunction nextBucket(start: Date, bucket: AiAccountingBucket): Date {\n const next = new Date(start)\n if (bucket === \"hour\") next.setUTCHours(next.getUTCHours() + 1)\n else if (bucket === \"day\") next.setUTCDate(next.getUTCDate() + 1)\n else next.setUTCDate(next.getUTCDate() + 7)\n return next\n}\n\nfunction appendGrouped(\n groups: Map<string, AiAccountingRecordSetItem[]>,\n key: string,\n item: AiAccountingRecordSetItem\n): void {\n const existing = groups.get(key)\n if (existing) existing.push(item)\n else groups.set(key, [item])\n}\n\nfunction addAmount(amounts: Map<string, bigint>, currency: string, amountNanos: string): void {\n amounts.set(currency, (amounts.get(currency) ?? 0n) + BigInt(amountNanos))\n}\n\nfunction normalizePage(\n requestedLimit: number | undefined,\n requestedOffset: number | undefined\n): { limit: number; offset: number } {\n const limit = requestedLimit ?? DEFAULT_MODEL_CALL_PAGE_SIZE\n const offset = requestedOffset ?? 0\n if (!Number.isSafeInteger(limit) || limit < 1 || limit > MAX_MODEL_CALL_PAGE_SIZE) {\n throw new TypeError(\n `[Sixb] AI accounting list limit must be an integer between 1 and ${MAX_MODEL_CALL_PAGE_SIZE}.`\n )\n }\n if (!Number.isSafeInteger(offset) || offset < 0) {\n throw new TypeError(\"[Sixb] AI accounting list offset must be a non-negative integer.\")\n }\n return { limit, offset }\n}\n\nfunction compareAccountingItems(\n left: AiModelCallAccountingItem,\n right: AiModelCallAccountingItem\n): number {\n return (\n right.usage.occurredAt.getTime() - left.usage.occurredAt.getTime() ||\n left.usage.id.localeCompare(right.usage.id)\n )\n}\n\nfunction compareAgentBreakdowns(\n left: AiAccountingAgentBreakdown,\n right: AiAccountingAgentBreakdown\n): number {\n return right.modelCallCount - left.modelCallCount || left.agentId.localeCompare(right.agentId)\n}\n\nfunction compareWorkflowBreakdowns(\n left: AiAccountingWorkflowBreakdown,\n right: AiAccountingWorkflowBreakdown\n): number {\n return (\n right.modelCallCount - left.modelCallCount || left.workflowId.localeCompare(right.workflowId)\n )\n}\n\nfunction compareModelBreakdowns(\n left: AiAccountingModelBreakdown,\n right: AiAccountingModelBreakdown\n): number {\n return (\n right.modelCallCount - left.modelCallCount ||\n left.providerId.localeCompare(right.providerId) ||\n left.modelId.localeCompare(right.modelId)\n )\n}\n\nfunction assertAiAccountingBucket(bucket: AiAccountingBucket): void {\n if (bucket !== \"hour\" && bucket !== \"day\" && bucket !== \"week\") {\n throw new TypeError(\"[Sixb] AI accounting bucket must be hour, day, or week.\")\n }\n}\n\nfunction assertDate(value: Date, label: string): void {\n if (!(value instanceof Date) || !Number.isFinite(value.getTime())) {\n throw new TypeError(`[Sixb] AI ${label} must be a valid Date.`)\n }\n}\n\nfunction assertNonBlank(value: string, label: string): void {\n if (typeof value !== \"string\" || value.trim().length === 0) {\n throw new TypeError(`[Sixb] AI ${label} must be nonblank.`)\n }\n}\n",
|
|
10
|
+
"import type { AiModelCallUsage, AiModelCallUsageRecord } from \"../ai-usage\"\nimport { normalizeAiModelCallUsage } from \"../ai-usage\"\nimport type {\n AiBillableMeter,\n AiBillingIdentity,\n AiCostComponent,\n AiModelCallCostRecord,\n AiPriceSource,\n AiPricingContext,\n AiRatedModelCallCostRecord,\n AiUnpriceableModelCallCostRecord,\n AiUnpriceableReason,\n} from \"./types\"\n\nconst SIGNED_INT64_MAX = 9_223_372_036_854_775_807n\nconst TOKENS_PER_MILLION = 1_000_000n\nconst HALF_MILLION = TOKENS_PER_MILLION / 2n\nconst MAX_NUMERIC_TEXT_LENGTH = 128\nconst METER_ORDER: Readonly<Record<AiBillableMeter, number>> = {\n \"tokens.input.total\": 0,\n \"tokens.input.uncached\": 1,\n \"tokens.input.cacheRead\": 2,\n \"tokens.input.cacheWrite\": 3,\n \"tokens.output.total\": 4,\n \"tokens.output.text\": 5,\n \"tokens.output.reasoning\": 6,\n}\nconst METERS = new Set(Object.keys(METER_ORDER))\nconst UNPRICEABLE_REASONS = new Set<AiUnpriceableReason>([\n \"missingBillingIdentity\",\n \"missingCatalogEntry\",\n \"missingUsageMeter\",\n \"unsupportedPricingDimension\",\n \"invalidUsageForFormula\",\n])\nconst CONTEXT_STRING_FIELDS = [\n \"serviceTier\",\n \"region\",\n \"inferenceGeo\",\n \"routedProviderId\",\n \"deploymentId\",\n \"inferenceProfileId\",\n \"mode\",\n] as const\n\nexport function normalizeAiPricingContext(input: AiPricingContext): AiPricingContext {\n if (typeof input !== \"object\" || input === null || Array.isArray(input)) {\n throw new TypeError(\"[Sixb] AI pricing context must be an object.\")\n }\n const result: Record<string, string | boolean | number> = {}\n for (const field of CONTEXT_STRING_FIELDS) {\n const value = input[field]\n if (value !== undefined) {\n assertNonBlank(value, `pricingContext.${field}`)\n result[field] = value\n }\n }\n if (input.batch !== undefined) {\n if (typeof input.batch !== \"boolean\") {\n throw new TypeError(\"[Sixb] AI pricingContext.batch must be boolean.\")\n }\n result.batch = input.batch\n }\n if (input.cacheWriteTtlSeconds !== undefined) {\n if (!Number.isSafeInteger(input.cacheWriteTtlSeconds) || input.cacheWriteTtlSeconds <= 0) {\n throw new TypeError(\n \"[Sixb] AI pricingContext.cacheWriteTtlSeconds must be a positive safe integer.\"\n )\n }\n result.cacheWriteTtlSeconds = input.cacheWriteTtlSeconds\n }\n return result\n}\n\nexport function normalizeAiModelCallCostRecord(\n input: AiModelCallCostRecord\n): AiModelCallCostRecord {\n assertNonBlank(input.projectId, \"cost record projectId\")\n assertNonBlank(input.usageRecordId, \"cost record usageRecordId\")\n const base = {\n projectId: input.projectId,\n usageRecordId: input.usageRecordId,\n pricingContext: normalizeAiPricingContext(input.pricingContext),\n priceSource: normalizePriceSource(input.priceSource),\n ratedAt: cloneDate(input.ratedAt, \"cost record ratedAt\"),\n }\n\n if (input.status === \"rated\") return normalizeRatedCost(input, base)\n if (input.status === \"unpriceable\") return normalizeUnpriceableCost(input, base)\n throw new TypeError(\"[Sixb] AI cost status is invalid.\")\n}\n\n/** Verify that a normalized valuation's billed quantities describe its usage record. */\nexport function aiModelCallCostMatchesUsage(\n record: AiModelCallCostRecord,\n usageRecord: AiModelCallUsageRecord\n): boolean {\n if (record.projectId !== usageRecord.projectId || record.usageRecordId !== usageRecord.id) {\n return false\n }\n if (record.status === \"unpriceable\") return true\n\n const usage = normalizeAiModelCallUsage(usageRecord.usage)\n const components = new Map(record.components.map((component) => [component.meter, component]))\n return (\n inputComponentsMatchUsage(components, usage) && outputComponentsMatchUsage(components, usage)\n )\n}\n\nfunction inputComponentsMatchUsage(\n components: ReadonlyMap<AiBillableMeter, AiCostComponent>,\n usage: AiModelCallUsage\n): boolean {\n if (usage.inputTokens === undefined) return false\n const total = components.get(\"tokens.input.total\")\n const partitions = [\n [\"tokens.input.uncached\", usage.uncachedInputTokens],\n [\"tokens.input.cacheRead\", usage.cacheReadInputTokens],\n [\"tokens.input.cacheWrite\", usage.cacheWriteInputTokens],\n ] as const\n const presentPartitions = partitions.filter(([meter]) => components.has(meter))\n\n if (total) {\n return presentPartitions.length === 0 && BigInt(total.quantity) === BigInt(usage.inputTokens)\n }\n if (presentPartitions.length === 0) return false\n\n let quantity = 0n\n for (const [meter, expected] of presentPartitions) {\n if (expected === undefined) return false\n const component = components.get(meter)!\n if (BigInt(component.quantity) !== BigInt(expected)) return false\n quantity += BigInt(component.quantity)\n }\n return quantity === BigInt(usage.inputTokens)\n}\n\nfunction outputComponentsMatchUsage(\n components: ReadonlyMap<AiBillableMeter, AiCostComponent>,\n usage: AiModelCallUsage\n): boolean {\n if (usage.outputTokens === undefined) return false\n const total = components.get(\"tokens.output.total\")\n const partitions = [\n [\"tokens.output.text\", usage.textOutputTokens],\n [\"tokens.output.reasoning\", usage.reasoningOutputTokens],\n ] as const\n const presentPartitions = partitions.filter(([meter]) => components.has(meter))\n\n if (total) {\n return presentPartitions.length === 0 && BigInt(total.quantity) === BigInt(usage.outputTokens)\n }\n if (presentPartitions.length === 0) return false\n\n let quantity = 0n\n for (const [meter, expected] of presentPartitions) {\n if (expected === undefined) return false\n const component = components.get(meter)!\n if (BigInt(component.quantity) !== BigInt(expected)) return false\n quantity += BigInt(component.quantity)\n }\n return quantity === BigInt(usage.outputTokens)\n}\n\nfunction normalizeRatedCost(\n input: AiRatedModelCallCostRecord,\n base: Pick<\n AiRatedModelCallCostRecord,\n \"projectId\" | \"usageRecordId\" | \"pricingContext\" | \"priceSource\" | \"ratedAt\"\n >\n): AiRatedModelCallCostRecord {\n const billingIdentity = normalizeBillingIdentity(input.billingIdentity)\n const components = input.components.map(normalizeCostComponent).sort(compareComponents)\n if (components.length === 0) throw new TypeError(\"[Sixb] AI rated cost requires components.\")\n if (new Set(components.map((component) => component.meter)).size !== components.length) {\n throw new TypeError(\"[Sixb] AI rated cost cannot contain duplicate meters.\")\n }\n const amountNanos = parseNonnegativeInt64(input.money.amountNanos, \"money amountNanos\").toString()\n if (amountNanos !== sumComponents(components)) {\n throw new TypeError(\"[Sixb] AI cost total does not equal its component charges.\")\n }\n return {\n ...base,\n status: \"rated\",\n billingIdentity,\n money: { currency: normalizeCurrency(input.money.currency), amountNanos },\n components,\n }\n}\n\nfunction normalizeUnpriceableCost(\n input: AiUnpriceableModelCallCostRecord,\n base: Pick<\n AiUnpriceableModelCallCostRecord,\n \"projectId\" | \"usageRecordId\" | \"pricingContext\" | \"priceSource\" | \"ratedAt\"\n >\n): AiUnpriceableModelCallCostRecord {\n if (!UNPRICEABLE_REASONS.has(input.reason)) {\n throw new TypeError(`[Sixb] AI unpriceable reason '${String(input.reason)}' is invalid.`)\n }\n const billingIdentity = input.billingIdentity\n ? normalizeBillingIdentity(input.billingIdentity)\n : undefined\n if (input.reason === \"missingBillingIdentity\" && billingIdentity !== undefined) {\n throw new TypeError(\"[Sixb] AI missingBillingIdentity cannot contain a billing identity.\")\n }\n if (input.reason !== \"missingBillingIdentity\" && billingIdentity === undefined) {\n throw new TypeError(`[Sixb] AI ${input.reason} requires a billing identity.`)\n }\n const missingMeters = normalizeMissingMeters(input.missingMeters)\n if (input.reason === \"missingUsageMeter\" && !missingMeters) {\n throw new TypeError(\"[Sixb] AI missingUsageMeter requires missingMeters.\")\n }\n return {\n ...base,\n status: \"unpriceable\",\n ...(billingIdentity ? { billingIdentity } : {}),\n reason: input.reason,\n ...(missingMeters ? { missingMeters } : {}),\n }\n}\n\nfunction normalizeCostComponent(input: AiCostComponent): AiCostComponent {\n if (!METERS.has(input.meter)) {\n throw new TypeError(`[Sixb] AI cost meter '${String(input.meter)}' is invalid.`)\n }\n const expected = calculateComponent(input.meter, input.quantity, input.rateAmountNanosPerMillion)\n if (expected.chargeAmountNanos !== input.chargeAmountNanos) {\n throw new TypeError(`[Sixb] AI cost component '${input.meter}' charge is invalid.`)\n }\n return expected\n}\n\nfunction calculateComponent(\n meter: AiBillableMeter,\n quantity: number | string,\n rateAmountNanosPerMillion: string\n): AiCostComponent {\n const normalizedQuantity = parseQuantity(quantity, `${meter} quantity`)\n const rate = parseNonnegativeInt64(rateAmountNanosPerMillion, `${meter} rate`)\n const charge = (normalizedQuantity * rate + HALF_MILLION) / TOKENS_PER_MILLION\n assertSignedInt64(charge, `${meter} charge`)\n return {\n meter,\n quantity: normalizedQuantity.toString(),\n rateAmountNanosPerMillion: rate.toString(),\n chargeAmountNanos: charge.toString(),\n }\n}\n\nfunction normalizePriceSource(input: AiPriceSource): AiPriceSource {\n assertNonBlank(input.sourceId, \"price sourceId\")\n assertNonBlank(input.sourceEntryId, \"price sourceEntryId\")\n assertNonBlank(input.sourceVersion, \"price sourceVersion\")\n assertNonBlank(input.sourceUrl, \"price sourceUrl\")\n return { ...input, observedAt: cloneDate(input.observedAt, \"price source observedAt\") }\n}\n\nfunction normalizeBillingIdentity(input: AiBillingIdentity): AiBillingIdentity {\n assertNonBlank(input.providerId, \"billingIdentity.providerId\")\n assertNonBlank(input.modelId, \"billingIdentity.modelId\")\n return { providerId: input.providerId, modelId: input.modelId }\n}\n\nfunction normalizeMissingMeters(\n input: readonly AiBillableMeter[] | undefined\n): readonly AiBillableMeter[] | undefined {\n if (!input?.length) return undefined\n const result = [...new Set(input)]\n for (const meter of result) {\n if (!METERS.has(meter)) throw new TypeError(`[Sixb] AI missing meter '${meter}' is invalid.`)\n }\n return result.sort((left, right) => METER_ORDER[left] - METER_ORDER[right])\n}\n\nfunction sumComponents(components: readonly AiCostComponent[]): string {\n let total = 0n\n for (const component of components) {\n total += parseNonnegativeInt64(component.chargeAmountNanos, \"component charge\")\n assertSignedInt64(total, \"cost total\")\n }\n return total.toString()\n}\n\nfunction parseQuantity(value: number | string, field: string): bigint {\n if (typeof value === \"number\") {\n if (!Number.isSafeInteger(value) || value < 0) {\n throw new TypeError(`[Sixb] AI ${field} must be a non-negative safe integer.`)\n }\n return BigInt(value)\n }\n return parseNonnegativeInt64(value, field)\n}\n\nfunction parseNonnegativeInt64(value: string, field: string): bigint {\n if (\n typeof value !== \"string\" ||\n value.length === 0 ||\n value.length > MAX_NUMERIC_TEXT_LENGTH ||\n !/^\\d+$/.test(value)\n ) {\n throw new TypeError(`[Sixb] AI ${field} must be a non-negative integer string.`)\n }\n const parsed = BigInt(value)\n assertSignedInt64(parsed, field)\n return parsed\n}\n\nfunction compareComponents(left: AiCostComponent, right: AiCostComponent): number {\n return METER_ORDER[left.meter] - METER_ORDER[right.meter]\n}\n\nfunction normalizeCurrency(value: string): string {\n if (!/^[A-Z]{3}$/.test(value)) {\n throw new TypeError(\"[Sixb] AI currency must be a three-letter uppercase code.\")\n }\n return value\n}\n\nfunction assertSignedInt64(value: bigint, field: string): void {\n if (value < 0n || value > SIGNED_INT64_MAX) {\n throw new TypeError(`[Sixb] AI ${field} exceeds the signed 64-bit range.`)\n }\n}\n\nfunction assertNonBlank(value: string, field: string): void {\n if (typeof value !== \"string\" || value.trim().length === 0) {\n throw new TypeError(`[Sixb] AI ${field} must be nonblank.`)\n }\n}\n\nfunction cloneDate(value: Date, field: string): Date {\n if (!(value instanceof Date) || !Number.isFinite(value.getTime())) {\n throw new TypeError(`[Sixb] AI ${field} must be a valid Date.`)\n }\n return new Date(value)\n}\n"
|
|
11
|
+
],
|
|
12
|
+
"mappings": ";;;;;;;;;;AAGO,MAAM,4BAA4B,MAAM;AAAA,EAIlC;AAAA,EAHF,OAAO;AAAA,EAEhB,WAAW,CACA,MACT,SACA;AAAA,IACA,MAAM,OAAO;AAAA,IAHJ;AAAA;AAKb;;;ACVA,IAAM,eAAe;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAKO,SAAS,yBAAyB,CAAC,OAAgD;AAAA,EACxF,WAAW,SAAS,cAAc;AAAA,IAChC,iBAAiB,MAAM,QAAQ,KAAK;AAAA,EACtC;AAAA,EAEA,MAAM,cACJ,MAAM,gBAAgB,aAAa,MAAM,iBAAiB,YACtD,YACA,eAAe,MAAM,aAAa,MAAM,cAAc,aAAa;AAAA,EACzE,MAAM,kBACJ,MAAM,gBAAgB,aAAa,MAAM,iBAAiB,YACtD,aACA,aAAa,KAAK,CAAC,UAAU,MAAM,WAAW,SAAS,IACrD,YACA;AAAA,EAER,OAAO;AAAA,OACD,MAAM,gBAAgB,YAAY,CAAC,IAAI,EAAE,aAAa,MAAM,YAAY;AAAA,OACxE,MAAM,iBAAiB,YAAY,CAAC,IAAI,EAAE,cAAc,MAAM,aAAa;AAAA,OAC3E,gBAAgB,YAAY,CAAC,IAAI,EAAE,YAAY;AAAA,OAC/C,MAAM,wBAAwB,YAC9B,CAAC,IACD,EAAE,qBAAqB,MAAM,oBAAoB;AAAA,OACjD,MAAM,yBAAyB,YAC/B,CAAC,IACD,EAAE,sBAAsB,MAAM,qBAAqB;AAAA,OACnD,MAAM,0BAA0B,YAChC,CAAC,IACD,EAAE,uBAAuB,MAAM,sBAAsB;AAAA,OACrD,MAAM,qBAAqB,YAAY,CAAC,IAAI,EAAE,kBAAk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} from "./chunk-4z3n1dzt.js";
|
|
9
|
+
|
|
10
|
+
// src/agents/authority.ts
|
|
11
|
+
function agentServiceAccountId(agentId) {
|
|
12
|
+
return `svc_agent_${agentId}`;
|
|
13
|
+
}
|
|
14
|
+
async function ensureAgentExecutionIdentity(input) {
|
|
15
|
+
const auth = requireAuthStorage(input.auth);
|
|
16
|
+
const id = agentServiceAccountId(input.agent.id);
|
|
17
|
+
const name = input.agent.name;
|
|
18
|
+
const description = `Managed service account for agent '${input.agent.id}'.`;
|
|
19
|
+
const now = new Date;
|
|
20
|
+
const loaded = await loadOrCreateAgentServiceAccount(auth, {
|
|
21
|
+
id,
|
|
22
|
+
projectId: input.projectId,
|
|
23
|
+
name,
|
|
24
|
+
description,
|
|
25
|
+
updatedAt: now
|
|
26
|
+
});
|
|
27
|
+
assertActiveAgentServiceAccount(input.agent.id, loaded);
|
|
28
|
+
const serviceAccount = await updateAgentServiceAccountMetadata(auth, {
|
|
29
|
+
existing: loaded,
|
|
30
|
+
name,
|
|
31
|
+
description,
|
|
32
|
+
updatedAt: now
|
|
33
|
+
});
|
|
34
|
+
assertActiveAgentServiceAccount(input.agent.id, serviceAccount);
|
|
35
|
+
const groupMemberships = await auth.serviceAccountGroupMemberships.reconcileForServiceAccount({
|
|
36
|
+
projectId: input.projectId,
|
|
37
|
+
serviceAccountId: id,
|
|
38
|
+
groupIds: input.agent.groupIds,
|
|
39
|
+
source: "agent",
|
|
40
|
+
updatedAt: now
|
|
41
|
+
});
|
|
42
|
+
return {
|
|
43
|
+
serviceAccount,
|
|
44
|
+
principal: { type: "serviceAccount", id },
|
|
45
|
+
groupMemberships
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
async function loadOrCreateAgentServiceAccount(auth, input) {
|
|
49
|
+
const existing = await auth.serviceAccounts.getById({
|
|
50
|
+
projectId: input.projectId,
|
|
51
|
+
id: input.id
|
|
52
|
+
});
|
|
53
|
+
if (existing)
|
|
54
|
+
return existing;
|
|
55
|
+
try {
|
|
56
|
+
return await auth.serviceAccounts.create({
|
|
57
|
+
id: input.id,
|
|
58
|
+
projectId: input.projectId,
|
|
59
|
+
name: input.name,
|
|
60
|
+
description: input.description,
|
|
61
|
+
status: "active",
|
|
62
|
+
createdByPrincipal: SYSTEM_PRINCIPAL,
|
|
63
|
+
createdAt: input.updatedAt,
|
|
64
|
+
updatedAt: input.updatedAt
|
|
65
|
+
});
|
|
66
|
+
} catch (error) {
|
|
67
|
+
if (!(error instanceof AuthStorageError) || error.code !== "duplicate_service_account") {
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
const concurrent = await auth.serviceAccounts.getById({
|
|
71
|
+
projectId: input.projectId,
|
|
72
|
+
id: input.id
|
|
73
|
+
});
|
|
74
|
+
if (!concurrent)
|
|
75
|
+
throw error;
|
|
76
|
+
return concurrent;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function assertActiveAgentServiceAccount(agentId, serviceAccount) {
|
|
80
|
+
if (serviceAccount.status === "suspended") {
|
|
81
|
+
throw new Error(`[Sixb] Agent '${agentId}' service account '${serviceAccount.id}' is suspended.`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
async function resolveAgentExecutionAuthorization(input) {
|
|
85
|
+
const auth = requireAuthStorage(input.auth);
|
|
86
|
+
const expectedId = agentServiceAccountId(input.agentId);
|
|
87
|
+
const principal = input.authorizationRef.type === "principal" ? input.authorizationRef.principal : null;
|
|
88
|
+
if (principal?.type !== "serviceAccount" || principal.id !== expectedId) {
|
|
89
|
+
throw new Error(`[Sixb] Agent '${input.agentId}' execution authority must reference service account '${expectedId}'.`);
|
|
90
|
+
}
|
|
91
|
+
const serviceAccount = await auth.serviceAccounts.getById({
|
|
92
|
+
projectId: input.projectId,
|
|
93
|
+
id: principal.id
|
|
94
|
+
});
|
|
95
|
+
if (!serviceAccount || serviceAccount.status !== "active") {
|
|
96
|
+
throw new Error(`[Sixb] Agent service account '${principal.id}' is not active.`);
|
|
97
|
+
}
|
|
98
|
+
const groupMemberships = await auth.serviceAccountGroupMemberships.listForServiceAccount({
|
|
99
|
+
projectId: input.projectId,
|
|
100
|
+
serviceAccountId: principal.id
|
|
101
|
+
});
|
|
102
|
+
const identity = {
|
|
103
|
+
serviceAccount,
|
|
104
|
+
principal: { type: "serviceAccount", id: principal.id },
|
|
105
|
+
groupMemberships
|
|
106
|
+
};
|
|
107
|
+
return {
|
|
108
|
+
identity,
|
|
109
|
+
context: resolveAuthorizationContext({
|
|
110
|
+
principal: identity.principal,
|
|
111
|
+
groupIds: groupMemberships.map((membership) => membership.groupId),
|
|
112
|
+
roles: input.security.listResolvedRoles()
|
|
113
|
+
})
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function requireAuthStorage(auth) {
|
|
117
|
+
if (!auth) {
|
|
118
|
+
throw new Error("[Sixb] Agent executions require auth storage.");
|
|
119
|
+
}
|
|
120
|
+
return auth;
|
|
121
|
+
}
|
|
122
|
+
async function updateAgentServiceAccountMetadata(auth, input) {
|
|
123
|
+
if (input.existing.name === input.name && input.existing.description === input.description) {
|
|
124
|
+
return input.existing;
|
|
125
|
+
}
|
|
126
|
+
return auth.serviceAccounts.update({
|
|
127
|
+
projectId: input.existing.projectId,
|
|
128
|
+
id: input.existing.id,
|
|
129
|
+
name: input.name,
|
|
130
|
+
description: input.description,
|
|
131
|
+
updatedAt: input.updatedAt
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export { agentServiceAccountId, ensureAgentExecutionIdentity, resolveAgentExecutionAuthorization };
|
|
136
|
+
|
|
137
|
+
//# debugId=BAD526CB9A059A9B64756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/agents/authority.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { SYSTEM_PRINCIPAL } from \"../auth\"\nimport type { AuthorizationContext } from \"../authorization\"\nimport { resolveAuthorizationContext } from \"../authorization\"\nimport type { AuthorizablePrincipal, AuthorizationRef } from \"../execution\"\nimport type { SecurityDefinitionCatalog } from \"../security\"\nimport type {\n AuthStorage,\n ServiceAccountGroupMembershipRecord,\n ServiceAccountRecord,\n} from \"../storage/auth\"\nimport { AuthStorageError } from \"../storage/auth\"\nimport type { AgentDefinition } from \"./types\"\n\nexport interface AgentExecutionIdentity {\n readonly serviceAccount: ServiceAccountRecord\n readonly principal: Extract<AuthorizablePrincipal, { readonly type: \"serviceAccount\" }>\n readonly groupMemberships: readonly ServiceAccountGroupMembershipRecord[]\n}\n\nexport function agentServiceAccountId(agentId: string): string {\n return `svc_agent_${agentId}`\n}\n\n/** Ensure the definition-owned service account exists before an Agent execution is admitted. */\nexport async function ensureAgentExecutionIdentity(input: {\n readonly auth: AuthStorage | undefined\n readonly projectId: string\n readonly agent: AgentDefinition\n}): Promise<AgentExecutionIdentity> {\n const auth = requireAuthStorage(input.auth)\n const id = agentServiceAccountId(input.agent.id)\n const name = input.agent.name\n const description = `Managed service account for agent '${input.agent.id}'.`\n const now = new Date()\n const loaded = await loadOrCreateAgentServiceAccount(auth, {\n id,\n projectId: input.projectId,\n name,\n description,\n updatedAt: now,\n })\n assertActiveAgentServiceAccount(input.agent.id, loaded)\n const serviceAccount = await updateAgentServiceAccountMetadata(auth, {\n existing: loaded,\n name,\n description,\n updatedAt: now,\n })\n assertActiveAgentServiceAccount(input.agent.id, serviceAccount)\n\n const groupMemberships = await auth.serviceAccountGroupMemberships.reconcileForServiceAccount({\n projectId: input.projectId,\n serviceAccountId: id,\n groupIds: input.agent.groupIds,\n source: \"agent\",\n updatedAt: now,\n })\n\n return {\n serviceAccount,\n principal: { type: \"serviceAccount\", id },\n groupMemberships,\n }\n}\n\n/** Load the managed identity, recovering only the expected concurrent-create race. */\nasync function loadOrCreateAgentServiceAccount(\n auth: AuthStorage,\n input: {\n readonly id: string\n readonly projectId: string\n readonly name: string\n readonly description: string\n readonly updatedAt: Date\n }\n): Promise<ServiceAccountRecord> {\n const existing = await auth.serviceAccounts.getById({\n projectId: input.projectId,\n id: input.id,\n })\n if (existing) return existing\n\n try {\n return await auth.serviceAccounts.create({\n id: input.id,\n projectId: input.projectId,\n name: input.name,\n description: input.description,\n status: \"active\",\n createdByPrincipal: SYSTEM_PRINCIPAL,\n createdAt: input.updatedAt,\n updatedAt: input.updatedAt,\n })\n } catch (error) {\n if (!(error instanceof AuthStorageError) || error.code !== \"duplicate_service_account\") {\n throw error\n }\n const concurrent = await auth.serviceAccounts.getById({\n projectId: input.projectId,\n id: input.id,\n })\n if (!concurrent) throw error\n return concurrent\n }\n}\n\nfunction assertActiveAgentServiceAccount(\n agentId: string,\n serviceAccount: ServiceAccountRecord\n): void {\n if (serviceAccount.status === \"suspended\") {\n throw new Error(\n `[Sixb] Agent '${agentId}' service account '${serviceAccount.id}' is suspended.`\n )\n }\n}\n\n/** Resolve current grants for the service account referenced by a durable Agent execution. */\nexport async function resolveAgentExecutionAuthorization(input: {\n readonly auth: AuthStorage | undefined\n readonly projectId: string\n readonly agentId: string\n readonly authorizationRef: AuthorizationRef\n readonly security: SecurityDefinitionCatalog\n}): Promise<{ readonly identity: AgentExecutionIdentity; readonly context: AuthorizationContext }> {\n const auth = requireAuthStorage(input.auth)\n const expectedId = agentServiceAccountId(input.agentId)\n const principal =\n input.authorizationRef.type === \"principal\" ? input.authorizationRef.principal : null\n if (principal?.type !== \"serviceAccount\" || principal.id !== expectedId) {\n throw new Error(\n `[Sixb] Agent '${input.agentId}' execution authority must reference service account '${expectedId}'.`\n )\n }\n\n const serviceAccount = await auth.serviceAccounts.getById({\n projectId: input.projectId,\n id: principal.id,\n })\n if (!serviceAccount || serviceAccount.status !== \"active\") {\n throw new Error(`[Sixb] Agent service account '${principal.id}' is not active.`)\n }\n\n const groupMemberships = await auth.serviceAccountGroupMemberships.listForServiceAccount({\n projectId: input.projectId,\n serviceAccountId: principal.id,\n })\n const identity: AgentExecutionIdentity = {\n serviceAccount,\n principal: { type: \"serviceAccount\", id: principal.id },\n groupMemberships,\n }\n return {\n identity,\n context: resolveAuthorizationContext({\n principal: identity.principal,\n groupIds: groupMemberships.map((membership) => membership.groupId),\n roles: input.security.listResolvedRoles(),\n }),\n }\n}\n\nfunction requireAuthStorage(auth: AuthStorage | undefined): AuthStorage {\n if (!auth) {\n throw new Error(\"[Sixb] Agent executions require auth storage.\")\n }\n return auth\n}\n\nasync function updateAgentServiceAccountMetadata(\n auth: AuthStorage,\n input: {\n readonly existing: ServiceAccountRecord\n readonly name: string\n readonly description: string\n readonly updatedAt: Date\n }\n): Promise<ServiceAccountRecord> {\n if (input.existing.name === input.name && input.existing.description === input.description) {\n return input.existing\n }\n return auth.serviceAccounts.update({\n projectId: input.existing.projectId,\n id: input.existing.id,\n name: input.name,\n description: input.description,\n updatedAt: input.updatedAt,\n })\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;;;;;;;;;AAmBO,SAAS,qBAAqB,CAAC,SAAyB;AAAA,EAC7D,OAAO,aAAa;AAAA;AAItB,eAAsB,4BAA4B,CAAC,OAIf;AAAA,EAClC,MAAM,OAAO,mBAAmB,MAAM,IAAI;AAAA,EAC1C,MAAM,KAAK,sBAAsB,MAAM,MAAM,EAAE;AAAA,EAC/C,MAAM,OAAO,MAAM,MAAM;AAAA,EACzB,MAAM,cAAc,sCAAsC,MAAM,MAAM;AAAA,EACtE,MAAM,MAAM,IAAI;AAAA,EAChB,MAAM,SAAS,MAAM,gCAAgC,MAAM;AAAA,IACzD;AAAA,IACA,WAAW,MAAM;AAAA,IACjB;AAAA,IACA;AAAA,IACA,WAAW;AAAA,EACb,CAAC;AAAA,EACD,gCAAgC,MAAM,MAAM,IAAI,MAAM;AAAA,EACtD,MAAM,iBAAiB,MAAM,kCAAkC,MAAM;AAAA,IACnE,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,WAAW;AAAA,EACb,CAAC;AAAA,EACD,gCAAgC,MAAM,MAAM,IAAI,cAAc;AAAA,EAE9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;AAAA,EACf;AAAA,EACA,OAAO,KAAK,gBAAgB,OAAO;AAAA,IACjC,WAAW,MAAM,SAAS;AAAA,IAC1B,IAAI,MAAM,SAAS;AAAA,IACnB,MAAM,MAAM;AAAA,IACZ,aAAa,MAAM;AAAA,IACnB,WAAW,MAAM;AAAA,EACnB,CAAC;AAAA;",
|
|
8
|
+
"debugId": "BAD526CB9A059A9B64756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/connectors/connections/capability.ts
|
|
3
|
+
var connectorConnectionsRuntimeKey = Symbol("sixb.connectorConnectionsRuntime");
|
|
4
|
+
var connectorConnectionCallbackKey = Symbol("sixb.connectorConnectionCallback");
|
|
5
|
+
function registerConnectorConnectionsRuntime(owner, runtime) {
|
|
6
|
+
const registered = owner[connectorConnectionsRuntimeKey];
|
|
7
|
+
if (registered && registered !== runtime) {
|
|
8
|
+
throw new Error("[Sixb] Connector connections runtime is already registered for this owner.");
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(owner, connectorConnectionsRuntimeKey, {
|
|
11
|
+
configurable: false,
|
|
12
|
+
enumerable: false,
|
|
13
|
+
value: runtime,
|
|
14
|
+
writable: false
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function getConnectorConnectionsRuntime(owner) {
|
|
18
|
+
const runtime = owner[connectorConnectionsRuntimeKey];
|
|
19
|
+
if (runtime)
|
|
20
|
+
return runtime;
|
|
21
|
+
throw new Error("[Sixb] Connector connections runtime is not registered for this execution.");
|
|
22
|
+
}
|
|
23
|
+
function registerConnectorConnectionCallbackProcess(owner, process) {
|
|
24
|
+
const registered = owner[connectorConnectionCallbackKey];
|
|
25
|
+
if (registered && registered !== process) {
|
|
26
|
+
throw new Error("[Sixb] Connector callback process is already registered for this host.");
|
|
27
|
+
}
|
|
28
|
+
Object.defineProperty(owner, connectorConnectionCallbackKey, {
|
|
29
|
+
configurable: false,
|
|
30
|
+
enumerable: false,
|
|
31
|
+
value: process,
|
|
32
|
+
writable: false
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function getConnectorConnectionCallbackProcess(owner) {
|
|
36
|
+
const process = owner[connectorConnectionCallbackKey];
|
|
37
|
+
if (process)
|
|
38
|
+
return process;
|
|
39
|
+
throw new Error("[Sixb] Connector callback process is not registered for this host.");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { registerConnectorConnectionsRuntime, getConnectorConnectionsRuntime, registerConnectorConnectionCallbackProcess, getConnectorConnectionCallbackProcess };
|
|
43
|
+
|
|
44
|
+
//# debugId=9A427A50CC4570A164756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/connectors/connections/capability.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import type { ConnectorConnectionCallbackProcess } from \"./contracts\"\nimport type { ConnectorConnectionsRuntime } from \"./execution\"\n\nconst connectorConnectionsRuntimeKey: unique symbol = Symbol(\"sixb.connectorConnectionsRuntime\")\nconst connectorConnectionCallbackKey: unique symbol = Symbol(\"sixb.connectorConnectionCallback\")\n\ninterface ConnectorConnectionsRuntimeOwner {\n readonly [connectorConnectionsRuntimeKey]?: ConnectorConnectionsRuntime\n}\n\ninterface ConnectorConnectionCallbackOwner {\n readonly [connectorConnectionCallbackKey]?: ConnectorConnectionCallbackProcess\n}\n\nexport function registerConnectorConnectionsRuntime(\n owner: object,\n runtime: ConnectorConnectionsRuntime\n): void {\n const registered = (owner as ConnectorConnectionsRuntimeOwner)[connectorConnectionsRuntimeKey]\n if (registered && registered !== runtime) {\n throw new Error(\"[Sixb] Connector connections runtime is already registered for this owner.\")\n }\n Object.defineProperty(owner, connectorConnectionsRuntimeKey, {\n configurable: false,\n enumerable: false,\n value: runtime,\n writable: false,\n })\n}\n\nexport function getConnectorConnectionsRuntime(owner: object): ConnectorConnectionsRuntime {\n const runtime = (owner as ConnectorConnectionsRuntimeOwner)[connectorConnectionsRuntimeKey]\n if (runtime) return runtime\n throw new Error(\"[Sixb] Connector connections runtime is not registered for this execution.\")\n}\n\nexport function registerConnectorConnectionCallbackProcess(\n owner: object,\n process: ConnectorConnectionCallbackProcess\n): void {\n const registered = (owner as ConnectorConnectionCallbackOwner)[connectorConnectionCallbackKey]\n if (registered && registered !== process) {\n throw new Error(\"[Sixb] Connector callback process is already registered for this host.\")\n }\n Object.defineProperty(owner, connectorConnectionCallbackKey, {\n configurable: false,\n enumerable: false,\n value: process,\n writable: false,\n })\n}\n\nexport function getConnectorConnectionCallbackProcess(\n owner: object\n): ConnectorConnectionCallbackProcess {\n const process = (owner as ConnectorConnectionCallbackOwner)[connectorConnectionCallbackKey]\n if (process) return process\n throw new Error(\"[Sixb] Connector callback process is not registered for this host.\")\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;AAGA,IAAM,iCAAgD,OAAO,kCAAkC;AAC/F,IAAM,iCAAgD,OAAO,kCAAkC;AAUxF,SAAS,mCAAmC,CACjD,OACA,SACM;AAAA,EACN,MAAM,aAAc,MAA2C;AAAA,EAC/D,IAAI,cAAc,eAAe,SAAS;AAAA,IACxC,MAAM,IAAI,MAAM,4EAA4E;AAAA,EAC9F;AAAA,EACA,OAAO,eAAe,OAAO,gCAAgC;AAAA,IAC3D,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,UAAU;AAAA,EACZ,CAAC;AAAA;AAGI,SAAS,8BAA8B,CAAC,OAA4C;AAAA,EACzF,MAAM,UAAW,MAA2C;AAAA,EAC5D,IAAI;AAAA,IAAS,OAAO;AAAA,EACpB,MAAM,IAAI,MAAM,4EAA4E;AAAA;AAGvF,SAAS,0CAA0C,CACxD,OACA,SACM;AAAA,EACN,MAAM,aAAc,MAA2C;AAAA,EAC/D,IAAI,cAAc,eAAe,SAAS;AAAA,IACxC,MAAM,IAAI,MAAM,wEAAwE;AAAA,EAC1F;AAAA,EACA,OAAO,eAAe,OAAO,gCAAgC;AAAA,IAC3D,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,UAAU;AAAA,EACZ,CAAC;AAAA;AAGI,SAAS,qCAAqC,CACnD,OACoC;AAAA,EACpC,MAAM,UAAW,MAA2C;AAAA,EAC5D,IAAI;AAAA,IAAS,OAAO;AAAA,EACpB,MAAM,IAAI,MAAM,oEAAoE;AAAA;",
|
|
8
|
+
"debugId": "9A427A50CC4570A164756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
agentServiceAccountId
|
|
4
|
+
} from "./chunk-n5x5y80a.js";
|
|
5
|
+
import {
|
|
6
|
+
findAgentRunExecution,
|
|
7
|
+
findPrimitiveRunExecution
|
|
8
|
+
} from "./chunk-t9xghkva.js";
|
|
9
|
+
|
|
10
|
+
// src/storage/workflow-runs/errors.ts
|
|
11
|
+
class WorkflowRunError extends Error {
|
|
12
|
+
name = "WorkflowRunError";
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// src/storage/workflow-runs/provider.ts
|
|
16
|
+
async function assertWorkflowRunExecution(input) {
|
|
17
|
+
const execution = await findPrimitiveRunExecution({
|
|
18
|
+
executions: input.executions,
|
|
19
|
+
projectId: input.projectId,
|
|
20
|
+
executionId: input.executionId,
|
|
21
|
+
primitive: { kind: "workflow", id: input.workflowId, runId: input.runId },
|
|
22
|
+
sourceTypes: ["execution", "schedule", "event"]
|
|
23
|
+
});
|
|
24
|
+
if (!execution) {
|
|
25
|
+
invalidExecution(input.executionId, input.runId);
|
|
26
|
+
}
|
|
27
|
+
if (execution.source.type === "schedule" || execution.source.type === "event") {
|
|
28
|
+
if (execution.requestedBy !== undefined) {
|
|
29
|
+
invalidExecution(input.executionId, input.runId);
|
|
30
|
+
}
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (execution.source.type !== "execution") {
|
|
34
|
+
invalidExecution(input.executionId, input.runId);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
async function assertWorkflowAgentNodeRunExecution(input) {
|
|
38
|
+
const execution = await findAgentRunExecution({
|
|
39
|
+
executions: input.executions,
|
|
40
|
+
projectId: input.projectId,
|
|
41
|
+
executionId: input.executionId,
|
|
42
|
+
runId: input.nodeRunId,
|
|
43
|
+
serviceAccountId: agentServiceAccountId(input.agentId)
|
|
44
|
+
});
|
|
45
|
+
if (!execution || execution.source.type !== "execution" || execution.source.executionId !== input.workflowExecutionId) {
|
|
46
|
+
throw new WorkflowRunError(`[Sixb] Execution '${input.executionId}' does not authorize Workflow Agent-node run '${input.nodeRunId}'.`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function invalidExecution(executionId, runId) {
|
|
50
|
+
throw new WorkflowRunError(`[Sixb] Execution '${executionId}' does not authorize workflow run '${runId}'.`);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { WorkflowRunError, assertWorkflowRunExecution, assertWorkflowAgentNodeRunExecution };
|
|
54
|
+
|
|
55
|
+
//# debugId=2817C9DE019D4AC264756E2164756E21
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/storage/workflow-runs/errors.ts", "../src/storage/workflow-runs/provider.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Base error for workflow-run storage operations.\n */\nexport class WorkflowRunError extends Error {\n readonly name = \"WorkflowRunError\"\n}\n",
|
|
6
|
+
"import { agentServiceAccountId } from \"../../agents/authority\"\nimport type { ExecutionStorage } from \"../executions\"\nimport { findAgentRunExecution, findPrimitiveRunExecution } from \"../executions/run-link\"\nimport { WorkflowRunError } from \"./errors\"\n\n/** Validate the semantic link between a durable workflow run and its immutable execution. */\nexport async function assertWorkflowRunExecution(input: {\n readonly executions: ExecutionStorage\n readonly projectId: string\n readonly executionId: string\n readonly runId: string\n readonly workflowId: string\n}): Promise<void> {\n const execution = await findPrimitiveRunExecution({\n executions: input.executions,\n projectId: input.projectId,\n executionId: input.executionId,\n primitive: { kind: \"workflow\", id: input.workflowId, runId: input.runId },\n sourceTypes: [\"execution\", \"schedule\", \"event\"],\n })\n if (!execution) {\n invalidExecution(input.executionId, input.runId)\n }\n\n if (execution.source.type === \"schedule\" || execution.source.type === \"event\") {\n if (execution.requestedBy !== undefined) {\n invalidExecution(input.executionId, input.runId)\n }\n return\n }\n\n // ExecutionStorage already validates the immutable parent reference, correlation id, and\n // requested-by propagation. This boundary only owns the workflow-specific source restriction.\n if (execution.source.type !== \"execution\") {\n invalidExecution(input.executionId, input.runId)\n }\n}\n\n/** Validate the semantic link between a Workflow Agent-node run and its child execution. */\nexport async function assertWorkflowAgentNodeRunExecution(input: {\n readonly executions: ExecutionStorage\n readonly projectId: string\n readonly executionId: string\n readonly nodeRunId: string\n readonly agentId: string\n readonly workflowExecutionId: string\n}): Promise<void> {\n const execution = await findAgentRunExecution({\n executions: input.executions,\n projectId: input.projectId,\n executionId: input.executionId,\n runId: input.nodeRunId,\n serviceAccountId: agentServiceAccountId(input.agentId),\n })\n if (\n !execution ||\n execution.source.type !== \"execution\" ||\n execution.source.executionId !== input.workflowExecutionId\n ) {\n throw new WorkflowRunError(\n `[Sixb] Execution '${input.executionId}' does not authorize Workflow Agent-node run '${input.nodeRunId}'.`\n )\n }\n}\n\nfunction invalidExecution(executionId: string, runId: string): never {\n throw new WorkflowRunError(\n `[Sixb] Execution '${executionId}' does not authorize workflow run '${runId}'.`\n )\n}\n"
|
|
7
|
+
],
|
|
8
|
+
"mappings": ";;;;;;;;;;AAGO,MAAM,yBAAyB,MAAM;AAAA,EACjC,OAAO;AAClB;;;ACCA,eAAsB,0BAA0B,CAAC,OAM/B;AAAA,EAChB,MAAM,YAAY,MAAM,0BAA0B;AAAA,IAChD,YAAY,MAAM;AAAA,IAClB,WAAW,MAAM;AAAA,IAC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
|
6
|
+
findAgentRunExecution
|
|
7
|
+
} from "./chunk-t9xghkva.js";
|
|
8
|
+
|
|
9
|
+
// src/storage/agents/errors.ts
|
|
10
|
+
class AgentStorageError extends Error {
|
|
11
|
+
code;
|
|
12
|
+
name = "AgentStorageError";
|
|
13
|
+
constructor(code, message) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.code = code;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// src/storage/agents/provider.ts
|
|
20
|
+
async function assertAgentRunExecution(input) {
|
|
21
|
+
const execution = await findAgentRunExecution({
|
|
22
|
+
executions: input.executions,
|
|
23
|
+
projectId: input.projectId,
|
|
24
|
+
executionId: input.executionId,
|
|
25
|
+
runId: input.runId,
|
|
26
|
+
serviceAccountId: agentServiceAccountId(input.agentId)
|
|
27
|
+
});
|
|
28
|
+
if (!execution) {
|
|
29
|
+
throw new AgentStorageError("invalid_input", `[Sixb] Execution '${input.executionId}' does not authorize Agent run '${input.runId}'.`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function assertCreateAgentContextCheckpointInput(input, prefix = "Sixb") {
|
|
33
|
+
for (const [name, value] of [
|
|
34
|
+
["id", input.id],
|
|
35
|
+
["projectId", input.projectId],
|
|
36
|
+
["threadId", input.threadId],
|
|
37
|
+
["createdByRunId", input.createdByRunId],
|
|
38
|
+
["executionToken", input.executionToken],
|
|
39
|
+
["summary", input.summary],
|
|
40
|
+
["summaryModelId", input.summaryModelId]
|
|
41
|
+
]) {
|
|
42
|
+
if (value.trim().length === 0) {
|
|
43
|
+
throw new AgentStorageError("invalid_input", `[${prefix}] Agent context checkpoint '${name}' must not be empty.`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (input.summaryFormatVersion !== 1) {
|
|
47
|
+
throw new AgentStorageError("invalid_input", `[${prefix}] Agent context checkpoint summary format version must be 1.`);
|
|
48
|
+
}
|
|
49
|
+
if (input.reason !== "threshold" && input.reason !== "overflow") {
|
|
50
|
+
throw new AgentStorageError("invalid_input", `[${prefix}] Agent context checkpoint reason must be 'threshold' or 'overflow'.`);
|
|
51
|
+
}
|
|
52
|
+
if (input.expectedPreviousCheckpointId !== null && input.expectedPreviousCheckpointId.trim().length === 0) {
|
|
53
|
+
throw new AgentStorageError("invalid_input", `[${prefix}] Agent context checkpoint expected previous id must not be empty.`);
|
|
54
|
+
}
|
|
55
|
+
if (input.createdAt && !Number.isFinite(input.createdAt.getTime())) {
|
|
56
|
+
throw new AgentStorageError("invalid_input", `[${prefix}] Agent context checkpoint createdAt must be a valid date.`);
|
|
57
|
+
}
|
|
58
|
+
for (const [name, value, minimum] of [
|
|
59
|
+
["expectedHeadSeq", input.expectedHeadSeq, 1],
|
|
60
|
+
["summarizedThroughSeq", input.summarizedThroughSeq, 1],
|
|
61
|
+
["observedHeadSeq", input.observedHeadSeq, 1],
|
|
62
|
+
["estimatedInputTokensBefore", input.estimatedInputTokensBefore, 0],
|
|
63
|
+
["estimatedInputTokensAfter", input.estimatedInputTokensAfter, 0]
|
|
64
|
+
]) {
|
|
65
|
+
if (!Number.isSafeInteger(value) || value < minimum) {
|
|
66
|
+
throw new AgentStorageError("invalid_input", `[${prefix}] Agent context checkpoint '${name}' must be a safe integer greater than or equal to ${minimum}.`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (input.observedHeadSeq !== input.expectedHeadSeq) {
|
|
70
|
+
throw new AgentStorageError("invalid_input", `[${prefix}] Agent context checkpoint observed head must equal its expected message head.`);
|
|
71
|
+
}
|
|
72
|
+
if (input.summarizedThroughSeq >= input.observedHeadSeq) {
|
|
73
|
+
throw new AgentStorageError("invalid_input", `[${prefix}] Agent context checkpoint must retain the triggering head message.`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function assertAgentContextCheckpointAuthority(input) {
|
|
77
|
+
const { create, run, thread } = input;
|
|
78
|
+
const prefix = input.prefix ?? "Sixb";
|
|
79
|
+
if (!run) {
|
|
80
|
+
throw new AgentStorageError("run_not_found", `[${prefix}] Agent run '${create.createdByRunId}' not found for project '${create.projectId}'.`);
|
|
81
|
+
}
|
|
82
|
+
if (!thread) {
|
|
83
|
+
throw new AgentStorageError("thread_not_found", `[${prefix}] Agent thread '${create.threadId}' not found for project '${create.projectId}'.`);
|
|
84
|
+
}
|
|
85
|
+
if (run.threadId !== create.threadId) {
|
|
86
|
+
throw new AgentStorageError("invalid_input", `[${prefix}] Agent run '${run.id}' does not belong to thread '${create.threadId}'.`);
|
|
87
|
+
}
|
|
88
|
+
if (run.status !== "running") {
|
|
89
|
+
throw new AgentStorageError("invalid_state", `[${prefix}] Agent run '${run.id}' is not running (status '${run.status}').`);
|
|
90
|
+
}
|
|
91
|
+
if (!run.execution || run.execution.token !== create.executionToken) {
|
|
92
|
+
throw new AgentStorageError("execution_lost", `[${prefix}] Execution token is no longer current on agent run '${run.id}'.`);
|
|
93
|
+
}
|
|
94
|
+
if (thread.activeRunId !== run.id) {
|
|
95
|
+
throw new AgentStorageError("invalid_state", `[${prefix}] Agent run '${run.id}' no longer owns thread '${thread.id}'.`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function assertAgentContextCheckpointAnchors(input) {
|
|
99
|
+
const { create, latest, headSeq, firstRetained } = input;
|
|
100
|
+
const prefix = input.prefix ?? "Sixb";
|
|
101
|
+
if (headSeq !== create.expectedHeadSeq) {
|
|
102
|
+
throw new AgentStorageError("invalid_state", `[${prefix}] Agent thread '${create.threadId}' message head changed from ${create.expectedHeadSeq} to ${headSeq}.`);
|
|
103
|
+
}
|
|
104
|
+
const latestId = latest?.id ?? null;
|
|
105
|
+
if (latestId !== create.expectedPreviousCheckpointId) {
|
|
106
|
+
throw new AgentStorageError("invalid_state", `[${prefix}] Agent thread '${create.threadId}' checkpoint head changed.`);
|
|
107
|
+
}
|
|
108
|
+
if (latest && create.summarizedThroughSeq <= latest.summarizedThroughSeq) {
|
|
109
|
+
throw new AgentStorageError("invalid_input", `[${prefix}] Agent context checkpoint boundary must advance beyond sequence ${latest.summarizedThroughSeq}.`);
|
|
110
|
+
}
|
|
111
|
+
if (!firstRetained || firstRetained.seq !== create.summarizedThroughSeq + 1) {
|
|
112
|
+
throw new AgentStorageError("invalid_state", `[${prefix}] Agent context checkpoint boundary does not align with stored thread messages.`);
|
|
113
|
+
}
|
|
114
|
+
if (firstRetained.role !== "user") {
|
|
115
|
+
throw new AgentStorageError("invalid_input", `[${prefix}] Agent context checkpoint must retain a complete turn beginning with a user message.`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function assertAgentContextCheckpointReplayState(input) {
|
|
119
|
+
const prefix = input.prefix ?? "Sixb";
|
|
120
|
+
if (input.headSeq !== input.create.expectedHeadSeq) {
|
|
121
|
+
throw new AgentStorageError("invalid_state", `[${prefix}] Agent thread '${input.create.threadId}' message head changed from ${input.create.expectedHeadSeq} to ${input.headSeq}.`);
|
|
122
|
+
}
|
|
123
|
+
if (input.latest?.id !== input.existing.id) {
|
|
124
|
+
throw new AgentStorageError("invalid_state", `[${prefix}] Agent thread '${input.create.threadId}' checkpoint head changed after '${input.existing.id}'.`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function agentContextCheckpointMatchesCreateInput(record, input) {
|
|
128
|
+
return record.id === input.id && record.projectId === input.projectId && record.threadId === input.threadId && record.createdByRunId === input.createdByRunId && (record.previousCheckpointId ?? null) === input.expectedPreviousCheckpointId && record.reason === input.reason && record.summary === input.summary && record.summaryFormatVersion === input.summaryFormatVersion && record.summarizedThroughSeq === input.summarizedThroughSeq && record.observedHeadSeq === input.observedHeadSeq && record.estimatedInputTokensBefore === input.estimatedInputTokensBefore && record.estimatedInputTokensAfter === input.estimatedInputTokensAfter && record.summaryModelId === input.summaryModelId;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export { AgentStorageError, assertAgentRunExecution, assertCreateAgentContextCheckpointInput, assertAgentContextCheckpointAuthority, assertAgentContextCheckpointAnchors, assertAgentContextCheckpointReplayState, agentContextCheckpointMatchesCreateInput };
|
|
132
|
+
|
|
133
|
+
//# debugId=C4E16AF3EE9252A464756E2164756E21
|