@sixb/core 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/index.js +37 -33
- package/dist/actions/index.js.map +1 -1
- package/dist/actions/types/definitions.d.ts +8 -2
- package/dist/actions/types/definitions.d.ts.map +1 -1
- package/dist/actions/worker.js +3 -3
- package/dist/agents/adapters.d.ts +33 -76
- package/dist/agents/adapters.d.ts.map +1 -1
- package/dist/agents/authority.d.ts +22 -6
- package/dist/agents/authority.d.ts.map +1 -1
- package/dist/agents/builders.d.ts +3 -11
- package/dist/agents/builders.d.ts.map +1 -1
- package/dist/agents/context.js +2 -2
- package/dist/agents/dispatch.d.ts +9 -1
- package/dist/agents/dispatch.d.ts.map +1 -1
- package/dist/agents/errors.d.ts +2 -2
- package/dist/agents/errors.d.ts.map +1 -1
- package/dist/agents/execution.d.ts +9 -10
- package/dist/agents/execution.d.ts.map +1 -1
- package/dist/agents/ids.d.ts +4 -0
- package/dist/agents/ids.d.ts.map +1 -1
- package/dist/agents/index.d.ts +13 -9
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +80 -68
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/message.d.ts +17 -10
- package/dist/agents/message.d.ts.map +1 -1
- package/dist/agents/model-loop.d.ts +56 -0
- package/dist/agents/model-loop.d.ts.map +1 -0
- package/dist/agents/reference.d.ts +4 -0
- package/dist/agents/reference.d.ts.map +1 -0
- package/dist/agents/request.d.ts +10 -8
- package/dist/agents/request.d.ts.map +1 -1
- package/dist/agents/retired-config.d.ts +4 -0
- package/dist/agents/retired-config.d.ts.map +1 -0
- package/dist/agents/streams.d.ts +13 -8
- package/dist/agents/streams.d.ts.map +1 -1
- package/dist/agents/streams.js +7 -5
- package/dist/agents/streams.js.map +1 -1
- package/dist/agents/tool-catalog.d.ts +9 -0
- package/dist/agents/tool-catalog.d.ts.map +1 -0
- package/dist/agents/tool-definition.d.ts +1 -0
- package/dist/agents/tool-definition.d.ts.map +1 -1
- package/dist/agents/types.d.ts +31 -68
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/agents/validation.d.ts +4 -10
- package/dist/agents/validation.d.ts.map +1 -1
- package/dist/ai-usage/execution.d.ts +53 -0
- package/dist/ai-usage/execution.d.ts.map +1 -0
- package/dist/ai-usage/index.d.ts +3 -0
- package/dist/ai-usage/index.d.ts.map +1 -0
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +7 -7
- package/dist/auth/runtime.d.ts.map +1 -1
- package/dist/auth/strategy.d.ts +1 -1
- package/dist/auth/strategy.d.ts.map +1 -1
- package/dist/auth/types.d.ts +13 -0
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/authorization/decision.d.ts +5 -2
- package/dist/authorization/decision.d.ts.map +1 -1
- package/dist/authorization/grant-kinds.d.ts +24 -8
- package/dist/authorization/grant-kinds.d.ts.map +1 -1
- package/dist/authorization/index.d.ts +1 -1
- package/dist/authorization/index.d.ts.map +1 -1
- package/dist/authorization/index.js +8 -6
- package/dist/authorization/index.js.map +1 -1
- package/dist/authorization/resolve.d.ts +3 -3
- package/dist/authorization/resolve.d.ts.map +1 -1
- package/dist/authorization/types.d.ts +7 -5
- package/dist/authorization/types.d.ts.map +1 -1
- package/dist/blob-storage/browser.js +2 -2
- package/dist/blob-storage/index.js +3 -3
- package/dist/bootstrap/discovery.d.ts +1 -7
- package/dist/bootstrap/discovery.d.ts.map +1 -1
- package/dist/bootstrap/index.js +52 -48
- package/dist/bootstrap/index.js.map +1 -1
- package/dist/broker/index.js +2 -2
- package/dist/{chunk-zqysyfjt.js → chunk-08m3b6w8.js} +1 -1
- package/dist/{chunk-xdf9yswn.js → chunk-08twe8m6.js} +93 -8
- package/dist/chunk-08twe8m6.js.map +12 -0
- package/dist/{chunk-xkthy56g.js → chunk-1kamz6j0.js} +1 -1
- package/dist/{chunk-h6h91mfy.js → chunk-2b5qtban.js} +12 -12
- package/dist/{chunk-h6h91mfy.js.map → chunk-2b5qtban.js.map} +3 -3
- package/dist/{chunk-0172wgm9.js → chunk-2xns679x.js} +10 -2
- package/dist/{chunk-0172wgm9.js.map → chunk-2xns679x.js.map} +3 -3
- package/dist/{chunk-f83ka50g.js → chunk-37wk412q.js} +86 -28
- package/dist/{chunk-f83ka50g.js.map → chunk-37wk412q.js.map} +8 -8
- package/dist/{chunk-6d5xdj1q.js → chunk-3fqt22c4.js} +4 -4
- package/dist/{chunk-t9xghkva.js → chunk-3kv70xwp.js} +3 -2
- package/dist/{chunk-t9xghkva.js.map → chunk-3kv70xwp.js.map} +3 -3
- package/dist/{chunk-z3zp0bj1.js → chunk-407j3msh.js} +1 -1
- package/dist/{chunk-rhrbz7d4.js → chunk-4a849fr1.js} +1 -1
- package/dist/{chunk-62c7t4jc.js → chunk-4nxeacx7.js} +1 -1
- package/dist/{chunk-cy0n5dms.js → chunk-5jcdmjam.js} +1 -1
- package/dist/{chunk-819wnjz8.js → chunk-64sr682n.js} +7 -7
- package/dist/{chunk-v0egge8b.js → chunk-6ed5bwnd.js} +666 -81
- package/dist/chunk-6ed5bwnd.js.map +57 -0
- package/dist/{chunk-x2yw73hy.js → chunk-7ds9620f.js} +1 -1
- package/dist/{chunk-dm72y8wt.js → chunk-7y0f6rf1.js} +29 -16
- package/dist/chunk-7y0f6rf1.js.map +10 -0
- package/dist/{chunk-72q2y8hn.js → chunk-8tsf6dmc.js} +2 -2
- package/dist/{chunk-72q2y8hn.js.map → chunk-8tsf6dmc.js.map} +3 -3
- package/dist/{chunk-tbv03sx2.js → chunk-9aehf39w.js} +7 -7
- package/dist/{chunk-ezake7g1.js → chunk-agsvg9ar.js} +1 -1
- package/dist/{chunk-rdeagz6b.js → chunk-atmkaf60.js} +1 -1
- package/dist/{chunk-rdeagz6b.js.map → chunk-atmkaf60.js.map} +2 -2
- package/dist/chunk-c15dr03f.js +43 -0
- package/dist/chunk-c15dr03f.js.map +10 -0
- package/dist/{chunk-78c6xvyr.js → chunk-d2ndstdf.js} +8 -6
- package/dist/{chunk-78c6xvyr.js.map → chunk-d2ndstdf.js.map} +2 -2
- package/dist/{chunk-rnshztfq.js → chunk-d63tybny.js} +2 -2
- package/dist/{chunk-t0jjkep3.js → chunk-d8qkxt2v.js} +4 -2
- package/dist/chunk-d8qkxt2v.js.map +10 -0
- package/dist/{chunk-vybf6pkp.js → chunk-dbc80ad7.js} +1 -1
- package/dist/{chunk-4gz41why.js → chunk-dqn23610.js} +1 -1
- package/dist/{chunk-z3ga9q5m.js → chunk-e4rvtvpw.js} +13 -11
- package/dist/{chunk-z3ga9q5m.js.map → chunk-e4rvtvpw.js.map} +2 -2
- package/dist/{chunk-h9kxd41f.js → chunk-gbrpsx4m.js} +19 -6
- package/dist/chunk-gbrpsx4m.js.map +11 -0
- package/dist/{chunk-84h6qhmp.js → chunk-h0knpbz5.js} +468 -1236
- package/dist/chunk-h0knpbz5.js.map +38 -0
- package/dist/{chunk-zp2v2rv6.js → chunk-ha58tjtt.js} +6 -6
- package/dist/{chunk-f6erf2vv.js → chunk-hdz94br2.js} +2 -2
- package/dist/chunk-jecn6t54.js +307 -0
- package/dist/chunk-jecn6t54.js.map +12 -0
- package/dist/{chunk-dsrkgtnh.js → chunk-jq43kdvk.js} +1 -1
- package/dist/{chunk-wtmzkcht.js → chunk-k34z5rvh.js} +1 -1
- package/dist/{chunk-htq0qh7z.js → chunk-ka3a2ft3.js} +2 -2
- package/dist/{chunk-4h947jd8.js → chunk-kt81c11h.js} +2 -2
- package/dist/chunk-n2arzn6e.js +1745 -0
- package/dist/chunk-n2arzn6e.js.map +20 -0
- package/dist/{chunk-f2rt4vkh.js → chunk-n2w475r0.js} +3 -3
- package/dist/{chunk-t8t39h7v.js → chunk-n6jxh8sw.js} +10 -2
- package/dist/chunk-n6jxh8sw.js.map +10 -0
- package/dist/{chunk-drjqm1aa.js → chunk-p03r0h5s.js} +310 -28
- package/dist/chunk-p03r0h5s.js.map +16 -0
- package/dist/chunk-p2vqaxkc.js +528 -0
- package/dist/chunk-p2vqaxkc.js.map +15 -0
- package/dist/{chunk-gadsm794.js → chunk-qjycjdj6.js} +84 -11
- package/dist/chunk-qjycjdj6.js.map +12 -0
- package/dist/chunk-qjzp9xyb.js +286 -0
- package/dist/chunk-qjzp9xyb.js.map +12 -0
- package/dist/{chunk-am6eczah.js → chunk-qv38twt8.js} +50 -69
- package/dist/{chunk-am6eczah.js.map → chunk-qv38twt8.js.map} +8 -8
- package/dist/{chunk-bhxaq2nn.js → chunk-qw9gvjv5.js} +1 -1
- package/dist/{chunk-r0rry8dn.js → chunk-rp1mvzb4.js} +6 -6
- package/dist/{chunk-tkdscva6.js → chunk-rre42skh.js} +187 -18
- package/dist/chunk-rre42skh.js.map +39 -0
- package/dist/{chunk-ghteq96b.js → chunk-s5y30bc9.js} +2 -2
- package/dist/{chunk-a31h57d5.js → chunk-tn7xcs2n.js} +2 -2
- package/dist/{chunk-6gjqgd3d.js → chunk-tpnd31c1.js} +2 -1
- package/dist/chunk-tpnd31c1.js.map +11 -0
- package/dist/chunk-trxxmgnf.js +68 -0
- package/dist/chunk-trxxmgnf.js.map +11 -0
- package/dist/{chunk-ea73pzk7.js → chunk-vjjv9mrb.js} +2 -2
- package/dist/{chunk-8b55ygje.js → chunk-w3e09qqk.js} +1 -1
- package/dist/{chunk-ckxfnx7f.js → chunk-wjgm6jjt.js} +2 -2
- package/dist/{chunk-3j7573mj.js → chunk-x0qhkqje.js} +2 -2
- package/dist/{chunk-dysw7nsm.js → chunk-xdpwpkha.js} +2 -2
- package/dist/{chunk-1q02e95s.js → chunk-y35ma3mj.js} +11 -16
- package/dist/{chunk-1q02e95s.js.map → chunk-y35ma3mj.js.map} +3 -4
- package/dist/{chunk-qewtks41.js → chunk-z2sery1b.js} +64 -1
- package/dist/{chunk-qewtks41.js.map → chunk-z2sery1b.js.map} +3 -3
- package/dist/error-reporting/internal.js +4 -4
- package/dist/error-reporting/types.d.ts +7 -2
- package/dist/error-reporting/types.d.ts.map +1 -1
- package/dist/errors/catalog.d.ts +8 -0
- package/dist/errors/catalog.d.ts.map +1 -1
- package/dist/errors/internal.js +2 -2
- package/dist/events/index.js +4 -4
- package/dist/execution/agent.d.ts +18 -9
- package/dist/execution/agent.d.ts.map +1 -1
- package/dist/execution/agent.js +52 -43
- package/dist/execution/agent.js.map +1 -1
- package/dist/execution/authorization.d.ts +14 -4
- package/dist/execution/authorization.d.ts.map +1 -1
- package/dist/execution/primitive.js +45 -43
- package/dist/execution/primitive.js.map +2 -2
- package/dist/execution/request.d.ts +3 -1
- package/dist/execution/request.d.ts.map +1 -1
- package/dist/execution/request.js +46 -44
- package/dist/execution/request.js.map +3 -3
- package/dist/execution/types.d.ts +1 -1
- package/dist/execution/types.d.ts.map +1 -1
- package/dist/http/api-routes.d.ts.map +1 -1
- package/dist/http/index.js +1 -1
- package/dist/index.d.ts +9 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +82 -77
- package/dist/index.js.map +1 -1
- package/dist/json.d.ts +2 -0
- package/dist/json.d.ts.map +1 -1
- package/dist/lake-storage/index.js +5 -5
- package/dist/logging/index.js +3 -3
- package/dist/logging/types.js +2 -2
- package/dist/materialization/index.js +2 -2
- package/dist/materializer/index.js +33 -29
- package/dist/materializer/index.js.map +1 -1
- package/dist/models/catalog.d.ts +40 -0
- package/dist/models/catalog.d.ts.map +1 -0
- package/dist/models/definitions.d.ts +25 -0
- package/dist/models/definitions.d.ts.map +1 -0
- package/dist/models/errors.d.ts +52 -0
- package/dist/models/errors.d.ts.map +1 -0
- package/dist/models/events.d.ts +192 -0
- package/dist/models/events.d.ts.map +1 -0
- package/dist/models/index.d.ts +17 -39
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +50 -0
- package/dist/models/index.js.map +9 -0
- package/dist/models/language-model.d.ts +90 -0
- package/dist/models/language-model.d.ts.map +1 -0
- package/dist/models/messages.d.ts +74 -0
- package/dist/models/messages.d.ts.map +1 -0
- package/dist/models/pricing.d.ts +69 -0
- package/dist/models/pricing.d.ts.map +1 -0
- package/dist/models/rate-card.d.ts +24 -0
- package/dist/models/rate-card.d.ts.map +1 -0
- package/dist/models/tools.d.ts +24 -0
- package/dist/models/tools.d.ts.map +1 -0
- package/dist/objects/index.js +38 -34
- package/dist/objects/index.js.map +1 -1
- package/dist/objects/query/index.js +32 -28
- package/dist/objects/query/index.js.map +1 -1
- package/dist/ontology/index.js +5 -5
- package/dist/ontology/internal.js +4 -4
- package/dist/pipelines/index.js +37 -35
- package/dist/pipelines/index.js.map +1 -1
- package/dist/projections/internal.js +35 -31
- package/dist/projections/internal.js.map +1 -1
- package/dist/queues/in-memory.d.ts +3 -2
- package/dist/queues/in-memory.d.ts.map +1 -1
- package/dist/queues/index.d.ts +3 -1
- package/dist/queues/index.d.ts.map +1 -1
- package/dist/queues/index.js +1 -1
- package/dist/queues/types.d.ts +15 -3
- package/dist/queues/types.d.ts.map +1 -1
- package/dist/runtime/create.d.ts +4 -4
- package/dist/runtime/create.d.ts.map +1 -1
- package/dist/runtime/definitions.d.ts +2 -2
- package/dist/runtime/definitions.d.ts.map +1 -1
- package/dist/runtime/host.d.ts +3 -2
- package/dist/runtime/host.d.ts.map +1 -1
- package/dist/runtime/resolve-definitions.d.ts +2 -2
- package/dist/runtime/resolve-definitions.d.ts.map +1 -1
- package/dist/runtime/sixb.d.ts +4 -2
- package/dist/runtime/sixb.d.ts.map +1 -1
- package/dist/security/every.d.ts +1 -4
- package/dist/security/every.d.ts.map +1 -1
- package/dist/security/grants.d.ts +6 -5
- package/dist/security/grants.d.ts.map +1 -1
- package/dist/security/index.d.ts +1 -1
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/registry.d.ts +1 -1
- package/dist/security/registry.d.ts.map +1 -1
- package/dist/security/types.d.ts +13 -5
- package/dist/security/types.d.ts.map +1 -1
- package/dist/security/validation.d.ts +4 -2
- package/dist/security/validation.d.ts.map +1 -1
- package/dist/storage/action-runs/failure.js +3 -3
- package/dist/storage/action-runs/provider.js +2 -2
- package/dist/storage/agents/errors.d.ts +1 -1
- package/dist/storage/agents/errors.d.ts.map +1 -1
- package/dist/storage/agents/in-memory.d.ts +3 -2
- package/dist/storage/agents/in-memory.d.ts.map +1 -1
- package/dist/storage/agents/index.d.ts +1 -1
- package/dist/storage/agents/index.d.ts.map +1 -1
- package/dist/storage/agents/provider.d.ts +11 -4
- package/dist/storage/agents/provider.d.ts.map +1 -1
- package/dist/storage/agents/provider.js +18 -15
- package/dist/storage/agents/provider.js.map +1 -1
- package/dist/storage/agents/types.d.ts +65 -17
- package/dist/storage/agents/types.d.ts.map +1 -1
- package/dist/storage/ai-cost/analytics.d.ts +2 -1
- package/dist/storage/ai-cost/analytics.d.ts.map +1 -1
- package/dist/storage/ai-cost/codec.d.ts +3 -2
- package/dist/storage/ai-cost/codec.d.ts.map +1 -1
- package/dist/storage/ai-cost/groups.d.ts +51 -0
- package/dist/storage/ai-cost/groups.d.ts.map +1 -0
- package/dist/storage/ai-cost/in-memory.d.ts +11 -1
- package/dist/storage/ai-cost/in-memory.d.ts.map +1 -1
- package/dist/storage/ai-cost/index.d.ts +1 -1
- package/dist/storage/ai-cost/index.d.ts.map +1 -1
- package/dist/storage/ai-cost/provider.d.ts +2 -0
- package/dist/storage/ai-cost/provider.d.ts.map +1 -1
- package/dist/storage/ai-cost/provider.js +29 -13
- package/dist/storage/ai-cost/provider.js.map +3 -3
- package/dist/storage/ai-cost/types.d.ts +64 -15
- package/dist/storage/ai-cost/types.d.ts.map +1 -1
- package/dist/storage/ai-cost/validation.d.ts +2 -1
- package/dist/storage/ai-cost/validation.d.ts.map +1 -1
- package/dist/storage/ai-limits/enforcement.d.ts +14 -0
- package/dist/storage/ai-limits/enforcement.d.ts.map +1 -0
- package/dist/storage/ai-limits/enforcement.js +21 -0
- package/dist/storage/ai-limits/enforcement.js.map +9 -0
- package/dist/storage/ai-limits/errors.d.ts +8 -0
- package/dist/storage/ai-limits/errors.d.ts.map +1 -0
- package/dist/storage/ai-limits/in-memory.d.ts +78 -0
- package/dist/storage/ai-limits/in-memory.d.ts.map +1 -0
- package/dist/storage/ai-limits/index.d.ts +7 -0
- package/dist/storage/ai-limits/index.d.ts.map +1 -0
- package/dist/storage/ai-limits/period.d.ts +4 -0
- package/dist/storage/ai-limits/period.d.ts.map +1 -0
- package/dist/storage/ai-limits/provider.d.ts +85 -0
- package/dist/storage/ai-limits/provider.d.ts.map +1 -0
- package/dist/storage/ai-limits/provider.js +62 -0
- package/dist/storage/ai-limits/provider.js.map +9 -0
- package/dist/storage/ai-limits/types.d.ts +175 -0
- package/dist/storage/ai-limits/types.d.ts.map +1 -0
- package/dist/storage/ai-usage/in-memory.d.ts +4 -0
- package/dist/storage/ai-usage/in-memory.d.ts.map +1 -1
- package/dist/storage/ai-usage/record.d.ts.map +1 -1
- package/dist/storage/ai-usage/types.d.ts +6 -2
- package/dist/storage/ai-usage/types.d.ts.map +1 -1
- package/dist/storage/auth/errors.d.ts +1 -1
- package/dist/storage/auth/errors.d.ts.map +1 -1
- package/dist/storage/auth/in-memory/auth-storage.d.ts +4 -1
- package/dist/storage/auth/in-memory/auth-storage.d.ts.map +1 -1
- package/dist/storage/auth/in-memory/device-authorizations.d.ts +29 -0
- package/dist/storage/auth/in-memory/device-authorizations.d.ts.map +1 -0
- package/dist/storage/auth/in-memory/shared.d.ts +3 -1
- package/dist/storage/auth/in-memory/shared.d.ts.map +1 -1
- package/dist/storage/auth/index.d.ts +2 -1
- package/dist/storage/auth/index.d.ts.map +1 -1
- package/dist/storage/auth/types.d.ts +66 -0
- package/dist/storage/auth/types.d.ts.map +1 -1
- package/dist/storage/connector-connections/provider.js +2 -2
- package/dist/storage/executions/provider.js +1 -1
- package/dist/storage/executions/run-link.d.ts +7 -2
- package/dist/storage/executions/run-link.d.ts.map +1 -1
- package/dist/storage/executions/validation.d.ts.map +1 -1
- package/dist/storage/in-memory/index.d.ts +4 -0
- package/dist/storage/in-memory/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +8 -5
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +51 -38
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/ontology/in-memory/materializations.d.ts +4 -3
- package/dist/storage/ontology/in-memory/materializations.d.ts.map +1 -1
- package/dist/storage/ontology/index.d.ts +1 -1
- package/dist/storage/ontology/index.d.ts.map +1 -1
- package/dist/storage/ontology/materializations.d.ts +7 -3
- package/dist/storage/ontology/materializations.d.ts.map +1 -1
- package/dist/storage/ontology/provider.d.ts +2 -2
- package/dist/storage/ontology/provider.d.ts.map +1 -1
- package/dist/storage/ontology/provider.js +3 -3
- package/dist/storage/pipeline-runs/provider.js +2 -2
- package/dist/storage/projection-runs/provider.js +4 -4
- package/dist/storage/sync-runs/provider.js +2 -2
- package/dist/storage/types.d.ts +5 -1
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/storage/webhook-runs/provider.js +2 -2
- package/dist/storage/workflow-runs/provider.d.ts +1 -1
- package/dist/storage/workflow-runs/provider.js +10 -11
- package/dist/storage/workflow-runs/provider.js.map +1 -1
- package/dist/storage/workflow-runs/types.d.ts +5 -4
- package/dist/storage/workflow-runs/types.d.ts.map +1 -1
- package/dist/syncs/index.js +37 -35
- package/dist/syncs/index.js.map +1 -1
- package/dist/testing/agent-execution.d.ts +3 -1
- package/dist/testing/agent-execution.d.ts.map +1 -1
- package/dist/testing/agent-storage-contract.d.ts.map +1 -1
- package/dist/testing/ai-cost-storage-contract.d.ts.map +1 -1
- package/dist/testing/ai-limit-storage-contract.d.ts +18 -0
- package/dist/testing/ai-limit-storage-contract.d.ts.map +1 -0
- package/dist/testing/ai-model-call-groups-contract.d.ts +6 -0
- package/dist/testing/ai-model-call-groups-contract.d.ts.map +1 -0
- package/dist/testing/ai-usage-storage-contract.d.ts.map +1 -1
- package/dist/testing/auth-storage-contract.d.ts.map +1 -1
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +3758 -1945
- package/dist/testing/index.js.map +15 -13
- package/dist/testing/materializer-storage-contract.d.ts.map +1 -1
- package/dist/testing/queues-contract.d.ts.map +1 -1
- package/dist/webhooks/internal.js +32 -28
- package/dist/webhooks/internal.js.map +2 -2
- package/dist/workers/index.js +2 -2
- package/dist/workflows/agent-step-identity.d.ts +3 -0
- package/dist/workflows/agent-step-identity.d.ts.map +1 -0
- package/dist/workflows/builders.d.ts +2 -3
- package/dist/workflows/builders.d.ts.map +1 -1
- package/dist/workflows/execution.d.ts +1 -1
- package/dist/workflows/execution.d.ts.map +1 -1
- package/dist/workflows/failure.d.ts +1 -1
- package/dist/workflows/failure.d.ts.map +1 -1
- package/dist/workflows/index.d.ts +3 -2
- package/dist/workflows/index.d.ts.map +1 -1
- package/dist/workflows/index.js +53 -45
- package/dist/workflows/index.js.map +1 -1
- package/dist/workflows/types.d.ts +26 -11
- package/dist/workflows/types.d.ts.map +1 -1
- package/dist/workflows/validation.d.ts +7 -1
- package/dist/workflows/validation.d.ts.map +1 -1
- package/package.json +19 -4
- package/src/actions/types/definitions.ts +24 -2
- package/src/agents/adapters.ts +109 -115
- package/src/agents/authority.ts +214 -32
- package/src/agents/builders.ts +3 -50
- package/src/agents/context-compaction.ts +4 -0
- package/src/agents/dispatch.ts +59 -2
- package/src/agents/errors.ts +5 -2
- package/src/agents/execution.ts +53 -52
- package/src/agents/ids.ts +16 -1
- package/src/agents/index.ts +23 -11
- package/src/agents/message.ts +18 -9
- package/src/agents/model-loop.ts +1023 -0
- package/src/agents/reference.ts +7 -0
- package/src/agents/request.ts +141 -74
- package/src/agents/retired-config.ts +20 -0
- package/src/agents/streams.ts +45 -19
- package/src/agents/tool-catalog.ts +21 -0
- package/src/agents/tool-definition.ts +23 -0
- package/src/agents/types.ts +39 -81
- package/src/agents/validation.ts +34 -180
- package/src/ai-usage/execution.ts +196 -0
- package/src/ai-usage/index.ts +15 -0
- package/src/auth/index.ts +1 -0
- package/src/auth/runtime.ts +8 -0
- package/src/auth/strategy.ts +1 -0
- package/src/auth/types.ts +14 -0
- package/src/authorization/decision.ts +27 -10
- package/src/authorization/grant-kinds.ts +62 -15
- package/src/authorization/index.ts +1 -0
- package/src/authorization/resolve.ts +12 -5
- package/src/authorization/types.ts +7 -5
- package/src/bootstrap/discovery.ts +0 -3
- package/src/error-reporting/types.ts +4 -2
- package/src/errors/catalog.ts +8 -0
- package/src/execution/agent.ts +129 -22
- package/src/execution/authorization.ts +48 -18
- package/src/execution/request.ts +4 -1
- package/src/execution/types.ts +1 -1
- package/src/http/api-routes.ts +63 -0
- package/src/index.ts +36 -7
- package/src/json.ts +9 -0
- package/src/models/catalog.ts +137 -0
- package/src/models/definitions.ts +202 -0
- package/src/models/errors.ts +83 -0
- package/src/models/events.ts +198 -0
- package/src/models/index.ts +89 -71
- package/src/models/language-model.ts +143 -0
- package/src/models/messages.ts +78 -0
- package/src/models/pricing.ts +390 -0
- package/src/models/rate-card.ts +101 -0
- package/src/models/tools.ts +29 -0
- package/src/queues/in-memory.ts +5 -0
- package/src/queues/index.ts +11 -0
- package/src/queues/types.ts +20 -3
- package/src/runtime/create.ts +7 -5
- package/src/runtime/definitions.ts +2 -2
- package/src/runtime/host.ts +3 -2
- package/src/runtime/resolve-definitions.ts +13 -36
- package/src/runtime/sixb.ts +6 -8
- package/src/security/every.ts +0 -4
- package/src/security/grants.ts +55 -11
- package/src/security/index.ts +2 -0
- package/src/security/registry.ts +6 -5
- package/src/security/types.ts +15 -4
- package/src/security/validation.ts +30 -9
- package/src/storage/agents/errors.ts +1 -0
- package/src/storage/agents/in-memory.ts +121 -11
- package/src/storage/agents/index.ts +7 -0
- package/src/storage/agents/provider.ts +150 -6
- package/src/storage/agents/types.ts +73 -16
- package/src/storage/ai-cost/analytics.ts +63 -6
- package/src/storage/ai-cost/codec.ts +37 -12
- package/src/storage/ai-cost/groups.ts +248 -0
- package/src/storage/ai-cost/in-memory.ts +42 -0
- package/src/storage/ai-cost/index.ts +6 -0
- package/src/storage/ai-cost/provider.ts +7 -0
- package/src/storage/ai-cost/types.ts +76 -14
- package/src/storage/ai-cost/validation.ts +147 -17
- package/src/storage/ai-limits/enforcement.ts +68 -0
- package/src/storage/ai-limits/errors.ts +23 -0
- package/src/storage/ai-limits/in-memory.ts +671 -0
- package/src/storage/ai-limits/index.ts +31 -0
- package/src/storage/ai-limits/period.ts +11 -0
- package/src/storage/ai-limits/provider.ts +430 -0
- package/src/storage/ai-limits/types.ts +195 -0
- package/src/storage/ai-usage/in-memory.ts +13 -0
- package/src/storage/ai-usage/record.ts +17 -0
- package/src/storage/ai-usage/types.ts +6 -2
- package/src/storage/auth/errors.ts +6 -0
- package/src/storage/auth/in-memory/auth-storage.ts +69 -0
- package/src/storage/auth/in-memory/device-authorizations.ts +145 -0
- package/src/storage/auth/in-memory/shared.ts +7 -0
- package/src/storage/auth/index.ts +7 -0
- package/src/storage/auth/types.ts +73 -0
- package/src/storage/executions/run-link.ts +16 -6
- package/src/storage/executions/validation.ts +36 -6
- package/src/storage/in-memory/index.ts +48 -4
- package/src/storage/index.ts +52 -1
- package/src/storage/ontology/in-memory/materializations.ts +34 -22
- package/src/storage/ontology/index.ts +1 -0
- package/src/storage/ontology/materializations.ts +8 -3
- package/src/storage/ontology/provider.ts +2 -2
- package/src/storage/types.ts +37 -0
- package/src/storage/workflow-runs/in-memory.ts +3 -3
- package/src/storage/workflow-runs/provider.ts +2 -2
- package/src/storage/workflow-runs/types.ts +6 -3
- package/src/testing/agent-execution.ts +40 -28
- package/src/testing/agent-storage-contract.ts +249 -28
- package/src/testing/ai-cost-storage-contract.ts +96 -8
- package/src/testing/ai-limit-storage-contract.ts +1134 -0
- package/src/testing/ai-model-call-groups-contract.ts +353 -0
- package/src/testing/ai-usage-storage-contract.ts +31 -0
- package/src/testing/auth-storage-contract.ts +85 -0
- package/src/testing/execution-storage-contract.ts +2 -2
- package/src/testing/index.ts +10 -0
- package/src/testing/materializer-storage-contract.ts +170 -2
- package/src/testing/queues-contract.ts +36 -1
- package/src/workflows/agent-step-identity.ts +4 -0
- package/src/workflows/builders.ts +95 -9
- package/src/workflows/execution.ts +2 -2
- package/src/workflows/failure.ts +2 -2
- package/src/workflows/index.ts +3 -0
- package/src/workflows/types.ts +23 -11
- package/src/workflows/validation.ts +100 -7
- package/dist/chunk-6gjqgd3d.js.map +0 -11
- package/dist/chunk-84h6qhmp.js.map +0 -46
- package/dist/chunk-a09jx26t.js +0 -55
- package/dist/chunk-a09jx26t.js.map +0 -11
- package/dist/chunk-dm72y8wt.js.map +0 -10
- package/dist/chunk-drjqm1aa.js.map +0 -15
- package/dist/chunk-gadsm794.js.map +0 -11
- package/dist/chunk-h9kxd41f.js.map +0 -11
- package/dist/chunk-nzw7sm3b.js +0 -137
- package/dist/chunk-nzw7sm3b.js.map +0 -10
- package/dist/chunk-t0jjkep3.js.map +0 -10
- package/dist/chunk-t8t39h7v.js.map +0 -10
- package/dist/chunk-tkdscva6.js.map +0 -37
- package/dist/chunk-v0egge8b.js.map +0 -56
- package/dist/chunk-xdf9yswn.js.map +0 -11
- /package/dist/{chunk-zqysyfjt.js.map → chunk-08m3b6w8.js.map} +0 -0
- /package/dist/{chunk-xkthy56g.js.map → chunk-1kamz6j0.js.map} +0 -0
- /package/dist/{chunk-6d5xdj1q.js.map → chunk-3fqt22c4.js.map} +0 -0
- /package/dist/{chunk-z3zp0bj1.js.map → chunk-407j3msh.js.map} +0 -0
- /package/dist/{chunk-rhrbz7d4.js.map → chunk-4a849fr1.js.map} +0 -0
- /package/dist/{chunk-62c7t4jc.js.map → chunk-4nxeacx7.js.map} +0 -0
- /package/dist/{chunk-cy0n5dms.js.map → chunk-5jcdmjam.js.map} +0 -0
- /package/dist/{chunk-819wnjz8.js.map → chunk-64sr682n.js.map} +0 -0
- /package/dist/{chunk-x2yw73hy.js.map → chunk-7ds9620f.js.map} +0 -0
- /package/dist/{chunk-tbv03sx2.js.map → chunk-9aehf39w.js.map} +0 -0
- /package/dist/{chunk-ezake7g1.js.map → chunk-agsvg9ar.js.map} +0 -0
- /package/dist/{chunk-rnshztfq.js.map → chunk-d63tybny.js.map} +0 -0
- /package/dist/{chunk-vybf6pkp.js.map → chunk-dbc80ad7.js.map} +0 -0
- /package/dist/{chunk-4gz41why.js.map → chunk-dqn23610.js.map} +0 -0
- /package/dist/{chunk-zp2v2rv6.js.map → chunk-ha58tjtt.js.map} +0 -0
- /package/dist/{chunk-f6erf2vv.js.map → chunk-hdz94br2.js.map} +0 -0
- /package/dist/{chunk-dsrkgtnh.js.map → chunk-jq43kdvk.js.map} +0 -0
- /package/dist/{chunk-wtmzkcht.js.map → chunk-k34z5rvh.js.map} +0 -0
- /package/dist/{chunk-htq0qh7z.js.map → chunk-ka3a2ft3.js.map} +0 -0
- /package/dist/{chunk-4h947jd8.js.map → chunk-kt81c11h.js.map} +0 -0
- /package/dist/{chunk-f2rt4vkh.js.map → chunk-n2w475r0.js.map} +0 -0
- /package/dist/{chunk-bhxaq2nn.js.map → chunk-qw9gvjv5.js.map} +0 -0
- /package/dist/{chunk-r0rry8dn.js.map → chunk-rp1mvzb4.js.map} +0 -0
- /package/dist/{chunk-ghteq96b.js.map → chunk-s5y30bc9.js.map} +0 -0
- /package/dist/{chunk-a31h57d5.js.map → chunk-tn7xcs2n.js.map} +0 -0
- /package/dist/{chunk-ea73pzk7.js.map → chunk-vjjv9mrb.js.map} +0 -0
- /package/dist/{chunk-8b55ygje.js.map → chunk-w3e09qqk.js.map} +0 -0
- /package/dist/{chunk-ckxfnx7f.js.map → chunk-wjgm6jjt.js.map} +0 -0
- /package/dist/{chunk-3j7573mj.js.map → chunk-x0qhkqje.js.map} +0 -0
- /package/dist/{chunk-dysw7nsm.js.map → chunk-xdpwpkha.js.map} +0 -0
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
import {
|
|
3
|
+
isModelReasoning,
|
|
4
|
+
normalizeModelProviderIds
|
|
5
|
+
} from "./chunk-trxxmgnf.js";
|
|
2
6
|
import {
|
|
3
7
|
normalizeRequesterGroupIds
|
|
4
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-4a849fr1.js";
|
|
5
9
|
import {
|
|
10
|
+
assertJsonObject,
|
|
6
11
|
assertJsonValue,
|
|
7
12
|
isPlainRecord
|
|
8
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-n6jxh8sw.js";
|
|
9
14
|
|
|
10
15
|
// src/storage/ai-usage/errors.ts
|
|
11
16
|
class AiUsageStorageError extends Error {
|
|
@@ -95,6 +100,7 @@ function normalizeAiModelCallRecord(input) {
|
|
|
95
100
|
const occurredAt = cloneValidDate(input.occurredAt, "occurredAt");
|
|
96
101
|
const recordedAt = cloneValidDate(input.recordedAt ?? new Date, "recordedAt");
|
|
97
102
|
const requesterGroupIds = normalizeRequesterGroupIds(input.requesterGroupIds);
|
|
103
|
+
const requestedReasoning = cloneRequestedReasoning(input.requestedReasoning);
|
|
98
104
|
const rawUsage = cloneRawUsage(input.rawUsage);
|
|
99
105
|
return {
|
|
100
106
|
id: input.id,
|
|
@@ -104,7 +110,9 @@ function normalizeAiModelCallRecord(input) {
|
|
|
104
110
|
callId: input.callId,
|
|
105
111
|
requesterGroupIds,
|
|
106
112
|
providerId: input.providerId,
|
|
113
|
+
...input.providerIds === undefined ? {} : { providerIds: normalizeModelProviderIds(input.providerIds) },
|
|
107
114
|
requestedModelId: input.requestedModelId,
|
|
115
|
+
...requestedReasoning === undefined ? {} : { requestedReasoning },
|
|
108
116
|
...input.responseModelId === undefined ? {} : { responseModelId: input.responseModelId },
|
|
109
117
|
responseId: input.responseId,
|
|
110
118
|
usage: normalizeAiModelCallUsage(input.usage),
|
|
@@ -113,6 +121,14 @@ function normalizeAiModelCallRecord(input) {
|
|
|
113
121
|
recordedAt
|
|
114
122
|
};
|
|
115
123
|
}
|
|
124
|
+
function cloneRequestedReasoning(reasoning) {
|
|
125
|
+
if (reasoning === undefined)
|
|
126
|
+
return;
|
|
127
|
+
if (!isModelReasoning(reasoning)) {
|
|
128
|
+
throw new TypeError("[Sixb] AI usage requestedReasoning is invalid.");
|
|
129
|
+
}
|
|
130
|
+
return typeof reasoning === "string" ? reasoning : { budgetTokens: reasoning.budgetTokens };
|
|
131
|
+
}
|
|
116
132
|
function assertAiUsageExecutionId(executionId) {
|
|
117
133
|
assertNonBlank(executionId, "executionId");
|
|
118
134
|
}
|
|
@@ -238,6 +254,13 @@ class InMemoryAiUsageStorage {
|
|
|
238
254
|
replaceMap(this.recordKeysByIdempotencyKey, snapshot.recordKeysByIdempotencyKey);
|
|
239
255
|
replaceMap(this.groupRows, snapshot.groupRows);
|
|
240
256
|
}
|
|
257
|
+
getRecord(projectId, id) {
|
|
258
|
+
const record = this.records.get(modelCallRecordKey(projectId, id));
|
|
259
|
+
return record ? structuredClone(record) : null;
|
|
260
|
+
}
|
|
261
|
+
listRecords(projectId) {
|
|
262
|
+
return [...this.records.values()].filter((record) => record.projectId === projectId).map((record) => structuredClone(record));
|
|
263
|
+
}
|
|
241
264
|
async assertExecutionExists(projectId, executionId) {
|
|
242
265
|
const execution = await this.executions.getById({ projectId, id: executionId });
|
|
243
266
|
if (execution)
|
|
@@ -320,8 +343,15 @@ function buildAiAccountingOverview(input, source) {
|
|
|
320
343
|
const periodStart = aiAccountingBucketStart(item.usage.occurredAt, input.bucket).getTime();
|
|
321
344
|
periodItems.get(periodStart)?.push(item);
|
|
322
345
|
appendGrouped(modelItems, JSON.stringify([item.usage.providerId, item.usage.requestedModelId]), item);
|
|
323
|
-
if (item.attribution)
|
|
324
|
-
appendGrouped(agentItems,
|
|
346
|
+
if (item.attribution?.kind === "agent") {
|
|
347
|
+
appendGrouped(agentItems, JSON.stringify(["agent"]), item);
|
|
348
|
+
} else if (item.attribution?.kind === "workflowAgent") {
|
|
349
|
+
appendGrouped(agentItems, JSON.stringify([
|
|
350
|
+
"workflowAgent",
|
|
351
|
+
item.attribution.workflowId,
|
|
352
|
+
item.attribution.agentStepId
|
|
353
|
+
]), item);
|
|
354
|
+
}
|
|
325
355
|
if (item.attribution?.kind === "workflowAgent") {
|
|
326
356
|
appendGrouped(workflowItems, item.attribution.workflowId, item);
|
|
327
357
|
}
|
|
@@ -334,7 +364,15 @@ function buildAiAccountingOverview(input, source) {
|
|
|
334
364
|
const [providerId, modelId] = JSON.parse(key);
|
|
335
365
|
return { providerId, modelId, ...aggregateAccountingItems(grouped) };
|
|
336
366
|
}).sort(compareModelBreakdowns);
|
|
337
|
-
const agents = [...agentItems].map(([
|
|
367
|
+
const agents = [...agentItems].map(([key, grouped]) => {
|
|
368
|
+
const [kind, workflowId, agentStepId] = JSON.parse(key);
|
|
369
|
+
return kind === "agent" ? { kind, ...aggregateAccountingItems(grouped) } : {
|
|
370
|
+
kind,
|
|
371
|
+
workflowId: requiredFragmentString(workflowId, "workflowId"),
|
|
372
|
+
agentStepId: requiredFragmentString(agentStepId, "agentStepId"),
|
|
373
|
+
...aggregateAccountingItems(grouped)
|
|
374
|
+
};
|
|
375
|
+
}).sort(compareAgentBreakdowns);
|
|
338
376
|
const workflows = [...workflowItems].map(([workflowId, grouped]) => ({ workflowId, ...aggregateAccountingItems(grouped) })).sort(compareWorkflowBreakdowns);
|
|
339
377
|
return structuredClone({
|
|
340
378
|
range: { from: query.from, to: query.to },
|
|
@@ -376,7 +414,11 @@ function buildAiAccountingOverviewFromFragments(input, fragments) {
|
|
|
376
414
|
]));
|
|
377
415
|
break;
|
|
378
416
|
case "agent":
|
|
379
|
-
target = getFragmentAccumulator(agents,
|
|
417
|
+
target = getFragmentAccumulator(agents, JSON.stringify([
|
|
418
|
+
requiredFragmentString(fragment.agentKind, "agentKind"),
|
|
419
|
+
fragment.workflowId,
|
|
420
|
+
fragment.agentStepId
|
|
421
|
+
]));
|
|
380
422
|
break;
|
|
381
423
|
case "workflow":
|
|
382
424
|
target = getFragmentAccumulator(workflows, requiredFragmentString(fragment.workflowId, "workflowId"));
|
|
@@ -396,7 +438,15 @@ function buildAiAccountingOverviewFromFragments(input, fragments) {
|
|
|
396
438
|
const [providerId, modelId] = JSON.parse(key);
|
|
397
439
|
return { providerId, modelId, ...finishAggregateFragment(value) };
|
|
398
440
|
}).sort(compareModelBreakdowns),
|
|
399
|
-
agents: [...agents].map(([
|
|
441
|
+
agents: [...agents].map(([key, value]) => {
|
|
442
|
+
const [kind, workflowId, agentStepId] = JSON.parse(key);
|
|
443
|
+
return kind === "agent" ? { kind, ...finishAggregateFragment(value) } : {
|
|
444
|
+
kind,
|
|
445
|
+
workflowId: requiredFragmentString(workflowId, "workflowId"),
|
|
446
|
+
agentStepId: requiredFragmentString(agentStepId, "agentStepId"),
|
|
447
|
+
...finishAggregateFragment(value)
|
|
448
|
+
};
|
|
449
|
+
}).sort(compareAgentBreakdowns),
|
|
400
450
|
workflows: [...workflows].map(([workflowId, value]) => ({ workflowId, ...finishAggregateFragment(value) })).sort(compareWorkflowBreakdowns)
|
|
401
451
|
});
|
|
402
452
|
}
|
|
@@ -612,7 +662,10 @@ function compareAccountingItems(left, right) {
|
|
|
612
662
|
return right.usage.occurredAt.getTime() - left.usage.occurredAt.getTime() || left.usage.id.localeCompare(right.usage.id);
|
|
613
663
|
}
|
|
614
664
|
function compareAgentBreakdowns(left, right) {
|
|
615
|
-
return right.modelCallCount - left.modelCallCount || left.
|
|
665
|
+
return right.modelCallCount - left.modelCallCount || agentBreakdownKey(left).localeCompare(agentBreakdownKey(right));
|
|
666
|
+
}
|
|
667
|
+
function agentBreakdownKey(value) {
|
|
668
|
+
return value.kind === "agent" ? "agent" : JSON.stringify(["workflowAgent", value.workflowId, value.agentStepId]);
|
|
616
669
|
}
|
|
617
670
|
function compareWorkflowBreakdowns(left, right) {
|
|
618
671
|
return right.modelCallCount - left.modelCallCount || left.workflowId.localeCompare(right.workflowId);
|
|
@@ -636,6 +689,141 @@ function assertNonBlank2(value, label) {
|
|
|
636
689
|
}
|
|
637
690
|
}
|
|
638
691
|
|
|
692
|
+
// src/storage/ai-cost/groups.ts
|
|
693
|
+
function aiModelCallGroupFragmentFromRow(row) {
|
|
694
|
+
let attribution;
|
|
695
|
+
if (row.root_agent_run_id && row.root_thread_id) {
|
|
696
|
+
attribution = {
|
|
697
|
+
kind: "agent",
|
|
698
|
+
agentRunId: row.root_agent_run_id,
|
|
699
|
+
threadId: row.root_thread_id
|
|
700
|
+
};
|
|
701
|
+
} else if (row.workflow_agent_step_id && row.workflow_node_run_id && row.workflow_id && row.workflow_run_id) {
|
|
702
|
+
attribution = {
|
|
703
|
+
kind: "workflowAgent",
|
|
704
|
+
agentStepId: row.workflow_agent_step_id,
|
|
705
|
+
nodeRunId: row.workflow_node_run_id,
|
|
706
|
+
workflowId: row.workflow_id,
|
|
707
|
+
workflowRunId: row.workflow_run_id
|
|
708
|
+
};
|
|
709
|
+
}
|
|
710
|
+
const executionAttribution = row.direct_kind === "subagent" && row.direct_run_id && row.parent_run_id ? { kind: "subagent", subagentRunId: row.direct_run_id, parentRunId: row.parent_run_id } : attribution;
|
|
711
|
+
return {
|
|
712
|
+
root: { executionId: row.root_execution_id, attribution },
|
|
713
|
+
execution: { executionId: row.execution_id, attribution: executionAttribution },
|
|
714
|
+
model: { providerId: row.provider_id, modelId: row.requested_model_id },
|
|
715
|
+
firstCallAt: new Date(row.first_call_at),
|
|
716
|
+
lastCallAt: new Date(row.last_call_at),
|
|
717
|
+
callCount: row.call_count,
|
|
718
|
+
tokenCount: row.token_count,
|
|
719
|
+
totalTokens: row.total_tokens,
|
|
720
|
+
valuationStatus: row.valuation_status,
|
|
721
|
+
...row.amount_currency === null ? {} : {
|
|
722
|
+
money: {
|
|
723
|
+
currency: row.amount_currency,
|
|
724
|
+
amountNanos: (BigInt(row.amount_high ?? "0") * 1000000000000n + BigInt(row.amount_middle ?? "0") * 1000000n + BigInt(row.amount_low ?? "0")).toString()
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
};
|
|
728
|
+
}
|
|
729
|
+
function buildAiModelCallGroupsFromFragments(fragments) {
|
|
730
|
+
const roots = new Map;
|
|
731
|
+
for (const fragment of fragments)
|
|
732
|
+
append(roots, fragment.root.executionId, fragment);
|
|
733
|
+
return [...roots.values()].map((rootFragments) => {
|
|
734
|
+
const first = rootFragments[0];
|
|
735
|
+
const executions = new Map;
|
|
736
|
+
for (const fragment of rootFragments)
|
|
737
|
+
append(executions, fragment.execution.executionId, fragment);
|
|
738
|
+
return {
|
|
739
|
+
...first.root,
|
|
740
|
+
...summarize(rootFragments),
|
|
741
|
+
...timeRange(rootFragments),
|
|
742
|
+
executions: [...executions.values()].map((items) => ({
|
|
743
|
+
...items[0].execution,
|
|
744
|
+
...summarize(items),
|
|
745
|
+
...timeRange(items),
|
|
746
|
+
models: [
|
|
747
|
+
...new Map(items.map(({ model }) => [JSON.stringify(model), model])).values()
|
|
748
|
+
].sort((a, b) => compareText(a.providerId, b.providerId) || compareText(a.modelId, b.modelId))
|
|
749
|
+
})).sort((a, b) => a.firstCallAt.getTime() - b.firstCallAt.getTime() || compareText(a.executionId, b.executionId))
|
|
750
|
+
};
|
|
751
|
+
}).sort((a, b) => b.lastCallAt.getTime() - a.lastCallAt.getTime() || compareText(a.executionId, b.executionId));
|
|
752
|
+
}
|
|
753
|
+
function buildAiModelCallGroups(input, source) {
|
|
754
|
+
const query = normalizeAiModelCallAccountingQuery(input);
|
|
755
|
+
const fragments = source.filter((item) => aiAccountingItemMatchesQuery(item, query) && (query.valuationStatus === undefined || (item.cost?.status ?? "unvalued") === query.valuationStatus)).map((item) => ({
|
|
756
|
+
root: item.root,
|
|
757
|
+
execution: { executionId: item.usage.executionId, attribution: item.attribution },
|
|
758
|
+
model: { providerId: item.usage.providerId, modelId: item.usage.requestedModelId },
|
|
759
|
+
firstCallAt: item.usage.occurredAt,
|
|
760
|
+
lastCallAt: item.usage.occurredAt,
|
|
761
|
+
callCount: "1",
|
|
762
|
+
tokenCount: item.usage.usage.totalTokens === undefined ? "0" : "1",
|
|
763
|
+
totalTokens: item.usage.usage.totalTokens?.toString() ?? null,
|
|
764
|
+
valuationStatus: item.cost?.status ?? "unvalued",
|
|
765
|
+
...item.cost && item.cost.status !== "unpriceable" ? { money: item.cost.money } : {}
|
|
766
|
+
}));
|
|
767
|
+
const groups = buildAiModelCallGroupsFromFragments(fragments);
|
|
768
|
+
const items = groups.slice(query.offset, query.offset + query.limit);
|
|
769
|
+
return structuredClone({
|
|
770
|
+
items,
|
|
771
|
+
total: groups.length,
|
|
772
|
+
hasMore: query.offset + items.length < groups.length
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
function summarize(items) {
|
|
776
|
+
let calls = 0n;
|
|
777
|
+
let tokenCount = 0n;
|
|
778
|
+
let tokens = 0n;
|
|
779
|
+
const counts = { rated: 0n, unpriceable: 0n, unvalued: 0n };
|
|
780
|
+
const money = new Map;
|
|
781
|
+
for (const item of items) {
|
|
782
|
+
const count = BigInt(item.callCount);
|
|
783
|
+
calls += count;
|
|
784
|
+
tokenCount += BigInt(item.tokenCount);
|
|
785
|
+
tokens += BigInt(item.totalTokens ?? "0");
|
|
786
|
+
counts[item.valuationStatus] += count;
|
|
787
|
+
if (item.money)
|
|
788
|
+
money.set(item.money.currency, (money.get(item.money.currency) ?? 0n) + BigInt(item.money.amountNanos));
|
|
789
|
+
}
|
|
790
|
+
const costs = {
|
|
791
|
+
amounts: [...money].sort(([a], [b]) => a.localeCompare(b)).map(([currency, amount]) => ({ currency, amountNanos: amount.toString() })),
|
|
792
|
+
ratedCallCount: safeCount(counts.rated),
|
|
793
|
+
unpriceableCallCount: safeCount(counts.unpriceable),
|
|
794
|
+
unvaluedCallCount: safeCount(counts.unvalued)
|
|
795
|
+
};
|
|
796
|
+
return {
|
|
797
|
+
modelCallCount: safeCount(calls),
|
|
798
|
+
...calls === tokenCount ? { totalTokens: safeCount(tokens) } : {},
|
|
799
|
+
costs
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
function timeRange(items) {
|
|
803
|
+
let first = items[0].firstCallAt.getTime();
|
|
804
|
+
let last = items[0].lastCallAt.getTime();
|
|
805
|
+
for (const item of items) {
|
|
806
|
+
first = Math.min(first, item.firstCallAt.getTime());
|
|
807
|
+
last = Math.max(last, item.lastCallAt.getTime());
|
|
808
|
+
}
|
|
809
|
+
return { firstCallAt: new Date(first), lastCallAt: new Date(last) };
|
|
810
|
+
}
|
|
811
|
+
function compareText(a, b) {
|
|
812
|
+
return a === b ? 0 : a < b ? -1 : 1;
|
|
813
|
+
}
|
|
814
|
+
function safeCount(value) {
|
|
815
|
+
if (value < 0n || value > BigInt(Number.MAX_SAFE_INTEGER))
|
|
816
|
+
throw new RangeError("[Sixb] AI accounting group count exceeds the safe integer range.");
|
|
817
|
+
return Number(value);
|
|
818
|
+
}
|
|
819
|
+
function append(map, key, item) {
|
|
820
|
+
const items = map.get(key);
|
|
821
|
+
if (items)
|
|
822
|
+
items.push(item);
|
|
823
|
+
else
|
|
824
|
+
map.set(key, [item]);
|
|
825
|
+
}
|
|
826
|
+
|
|
639
827
|
// src/storage/ai-cost/validation.ts
|
|
640
828
|
var SIGNED_INT64_MAX = 9223372036854775807n;
|
|
641
829
|
var TOKENS_PER_MILLION = 1000000n;
|
|
@@ -646,14 +834,16 @@ var METER_ORDER = {
|
|
|
646
834
|
"tokens.input.uncached": 1,
|
|
647
835
|
"tokens.input.cacheRead": 2,
|
|
648
836
|
"tokens.input.cacheWrite": 3,
|
|
649
|
-
"tokens.
|
|
650
|
-
"tokens.
|
|
651
|
-
"tokens.output.
|
|
837
|
+
"tokens.input.cacheWrite5m": 4,
|
|
838
|
+
"tokens.input.cacheWrite1h": 5,
|
|
839
|
+
"tokens.output.total": 6,
|
|
840
|
+
"tokens.output.text": 7,
|
|
841
|
+
"tokens.output.reasoning": 8
|
|
652
842
|
};
|
|
653
843
|
var METERS = new Set(Object.keys(METER_ORDER));
|
|
654
844
|
var UNPRICEABLE_REASONS = new Set([
|
|
655
845
|
"missingBillingIdentity",
|
|
656
|
-
"
|
|
846
|
+
"missingRateCard",
|
|
657
847
|
"missingUsageMeter",
|
|
658
848
|
"unsupportedPricingDimension",
|
|
659
849
|
"invalidUsageForFormula"
|
|
@@ -663,6 +853,7 @@ var CONTEXT_STRING_FIELDS = [
|
|
|
663
853
|
"region",
|
|
664
854
|
"inferenceGeo",
|
|
665
855
|
"routedProviderId",
|
|
856
|
+
"routedModelId",
|
|
666
857
|
"deploymentId",
|
|
667
858
|
"inferenceProfileId",
|
|
668
859
|
"mode"
|
|
@@ -697,24 +888,41 @@ function normalizeAiModelCallCostRecord(input) {
|
|
|
697
888
|
assertNonBlank3(input.projectId, "cost record projectId");
|
|
698
889
|
assertNonBlank3(input.usageRecordId, "cost record usageRecordId");
|
|
699
890
|
const base = {
|
|
891
|
+
...input.estimate === undefined ? {} : { estimate: normalizeAiCostEstimate(input.estimate) },
|
|
700
892
|
projectId: input.projectId,
|
|
701
893
|
usageRecordId: input.usageRecordId,
|
|
702
894
|
pricingContext: normalizeAiPricingContext(input.pricingContext),
|
|
703
|
-
priceSource: normalizePriceSource(input.priceSource),
|
|
704
895
|
ratedAt: cloneDate(input.ratedAt, "cost record ratedAt")
|
|
705
896
|
};
|
|
706
|
-
if (input.status === "rated")
|
|
707
|
-
return normalizeRatedCost(input,
|
|
708
|
-
|
|
709
|
-
|
|
897
|
+
if (input.status === "rated") {
|
|
898
|
+
return normalizeRatedCost(input, {
|
|
899
|
+
...base,
|
|
900
|
+
priceSource: normalizePriceSource(input.priceSource)
|
|
901
|
+
});
|
|
902
|
+
}
|
|
903
|
+
if (input.status === "unpriceable") {
|
|
904
|
+
return normalizeUnpriceableCost(input, {
|
|
905
|
+
...base,
|
|
906
|
+
...input.priceSource === undefined ? {} : { priceSource: normalizePriceSource(input.priceSource) }
|
|
907
|
+
});
|
|
908
|
+
}
|
|
710
909
|
throw new TypeError("[Sixb] AI cost status is invalid.");
|
|
711
910
|
}
|
|
712
911
|
function aiModelCallCostMatchesUsage(record, usageRecord) {
|
|
713
912
|
if (record.projectId !== usageRecord.projectId || record.usageRecordId !== usageRecord.id) {
|
|
714
913
|
return false;
|
|
715
914
|
}
|
|
915
|
+
if (record.estimate?.status === "rated") {
|
|
916
|
+
const usage2 = normalizeAiModelCallUsage(usageRecord.usage);
|
|
917
|
+
const components2 = new Map(record.estimate.components.map((component) => [component.meter, component]));
|
|
918
|
+
if (!inputComponentsMatchUsage(components2, usage2) || !outputComponentsMatchUsage(components2, usage2))
|
|
919
|
+
return false;
|
|
920
|
+
}
|
|
716
921
|
if (record.status === "unpriceable")
|
|
717
922
|
return true;
|
|
923
|
+
if (record.components.length === 0 && isExternalValuationSource(record.priceSource.sourceId)) {
|
|
924
|
+
return true;
|
|
925
|
+
}
|
|
718
926
|
const usage = normalizeAiModelCallUsage(usageRecord.usage);
|
|
719
927
|
const components = new Map(record.components.map((component) => [component.meter, component]));
|
|
720
928
|
return inputComponentsMatchUsage(components, usage) && outputComponentsMatchUsage(components, usage);
|
|
@@ -723,19 +931,25 @@ function inputComponentsMatchUsage(components, usage) {
|
|
|
723
931
|
if (usage.inputTokens === undefined)
|
|
724
932
|
return false;
|
|
725
933
|
const total = components.get("tokens.input.total");
|
|
726
|
-
const
|
|
934
|
+
const directPartitions = [
|
|
727
935
|
["tokens.input.uncached", usage.uncachedInputTokens],
|
|
728
936
|
["tokens.input.cacheRead", usage.cacheReadInputTokens],
|
|
729
937
|
["tokens.input.cacheWrite", usage.cacheWriteInputTokens]
|
|
730
938
|
];
|
|
731
|
-
const
|
|
939
|
+
const presentDirect = directPartitions.filter(([meter]) => components.has(meter));
|
|
940
|
+
const specificWrites = [
|
|
941
|
+
components.get("tokens.input.cacheWrite5m"),
|
|
942
|
+
components.get("tokens.input.cacheWrite1h")
|
|
943
|
+
].filter((component) => component !== undefined);
|
|
732
944
|
if (total) {
|
|
733
|
-
return
|
|
945
|
+
return presentDirect.length === 0 && specificWrites.length === 0 && BigInt(total.quantity) === BigInt(usage.inputTokens);
|
|
734
946
|
}
|
|
735
|
-
if (
|
|
947
|
+
if (presentDirect.length === 0 && specificWrites.length === 0)
|
|
948
|
+
return false;
|
|
949
|
+
if (components.has("tokens.input.cacheWrite") && specificWrites.length > 0)
|
|
736
950
|
return false;
|
|
737
951
|
let quantity = 0n;
|
|
738
|
-
for (const [meter, expected] of
|
|
952
|
+
for (const [meter, expected] of presentDirect) {
|
|
739
953
|
if (expected === undefined)
|
|
740
954
|
return false;
|
|
741
955
|
const component = components.get(meter);
|
|
@@ -743,6 +957,14 @@ function inputComponentsMatchUsage(components, usage) {
|
|
|
743
957
|
return false;
|
|
744
958
|
quantity += BigInt(component.quantity);
|
|
745
959
|
}
|
|
960
|
+
if (specificWrites.length > 0) {
|
|
961
|
+
if (usage.cacheWriteInputTokens === undefined)
|
|
962
|
+
return false;
|
|
963
|
+
const specificWriteQuantity = specificWrites.reduce((sum, component) => sum + BigInt(component.quantity), 0n);
|
|
964
|
+
if (specificWriteQuantity !== BigInt(usage.cacheWriteInputTokens))
|
|
965
|
+
return false;
|
|
966
|
+
quantity += specificWriteQuantity;
|
|
967
|
+
}
|
|
746
968
|
return quantity === BigInt(usage.inputTokens);
|
|
747
969
|
}
|
|
748
970
|
function outputComponentsMatchUsage(components, usage) {
|
|
@@ -773,13 +995,14 @@ function outputComponentsMatchUsage(components, usage) {
|
|
|
773
995
|
function normalizeRatedCost(input, base) {
|
|
774
996
|
const billingIdentity = normalizeBillingIdentity(input.billingIdentity);
|
|
775
997
|
const components = input.components.map(normalizeCostComponent).sort(compareComponents);
|
|
776
|
-
if (components.length === 0)
|
|
998
|
+
if (components.length === 0 && !isExternalValuationSource(base.priceSource.sourceId)) {
|
|
777
999
|
throw new TypeError("[Sixb] AI rated cost requires components.");
|
|
1000
|
+
}
|
|
778
1001
|
if (new Set(components.map((component) => component.meter)).size !== components.length) {
|
|
779
1002
|
throw new TypeError("[Sixb] AI rated cost cannot contain duplicate meters.");
|
|
780
1003
|
}
|
|
781
1004
|
const amountNanos = parseNonnegativeInt64(input.money.amountNanos, "money amountNanos").toString();
|
|
782
|
-
if (amountNanos !== sumComponents(components)) {
|
|
1005
|
+
if (components.length > 0 && amountNanos !== sumComponents(components)) {
|
|
783
1006
|
throw new TypeError("[Sixb] AI cost total does not equal its component charges.");
|
|
784
1007
|
}
|
|
785
1008
|
return {
|
|
@@ -790,6 +1013,58 @@ function normalizeRatedCost(input, base) {
|
|
|
790
1013
|
components
|
|
791
1014
|
};
|
|
792
1015
|
}
|
|
1016
|
+
function normalizeAiCostEstimate(value) {
|
|
1017
|
+
assertJsonObject(value, "AI cost estimate");
|
|
1018
|
+
if (value.status === "rated") {
|
|
1019
|
+
assertJsonObject(value.money, "estimate money");
|
|
1020
|
+
const { currency, amountNanos } = value.money;
|
|
1021
|
+
if (typeof currency !== "string" || typeof amountNanos !== "string" || !Array.isArray(value.components))
|
|
1022
|
+
throw new TypeError("[Sixb] Invalid cost estimate money or components.");
|
|
1023
|
+
const components = value.components.map((component) => {
|
|
1024
|
+
assertJsonObject(component, "estimate component");
|
|
1025
|
+
const meter = [...METERS].find((meter2) => meter2 === component.meter);
|
|
1026
|
+
if (!meter || typeof component.quantity !== "string" || typeof component.rateAmountNanosPerMillion !== "string" || typeof component.chargeAmountNanos !== "string")
|
|
1027
|
+
throw new TypeError("[Sixb] Invalid cost estimate component.");
|
|
1028
|
+
return normalizeCostComponent({
|
|
1029
|
+
meter,
|
|
1030
|
+
quantity: component.quantity,
|
|
1031
|
+
rateAmountNanosPerMillion: component.rateAmountNanosPerMillion,
|
|
1032
|
+
chargeAmountNanos: component.chargeAmountNanos
|
|
1033
|
+
});
|
|
1034
|
+
}).sort(compareComponents);
|
|
1035
|
+
if (!components.length || new Set(components.map((c) => c.meter)).size !== components.length || parseNonnegativeInt64(amountNanos, "estimate amountNanos").toString() !== sumComponents(components))
|
|
1036
|
+
throw new TypeError("[Sixb] Estimate must contain unique meters whose charges equal its total.");
|
|
1037
|
+
return {
|
|
1038
|
+
status: "rated",
|
|
1039
|
+
money: { currency: normalizeCurrency(currency), amountNanos },
|
|
1040
|
+
components
|
|
1041
|
+
};
|
|
1042
|
+
}
|
|
1043
|
+
const reason = [...UNPRICEABLE_REASONS].find((reason2) => reason2 === value.reason);
|
|
1044
|
+
if (value.status !== "unpriceable" || !reason)
|
|
1045
|
+
throw new TypeError("[Sixb] Invalid cost estimate status or reason.");
|
|
1046
|
+
let missingMeters;
|
|
1047
|
+
if (value.missingMeters !== undefined) {
|
|
1048
|
+
if (!Array.isArray(value.missingMeters))
|
|
1049
|
+
throw new TypeError("[Sixb] Invalid estimate missing meters.");
|
|
1050
|
+
missingMeters = normalizeMissingMeters(value.missingMeters.map((input) => {
|
|
1051
|
+
const meter = [...METERS].find((meter2) => meter2 === input);
|
|
1052
|
+
if (!meter)
|
|
1053
|
+
throw new TypeError("[Sixb] Invalid estimate missing meter.");
|
|
1054
|
+
return meter;
|
|
1055
|
+
}));
|
|
1056
|
+
}
|
|
1057
|
+
if (reason === "missingUsageMeter" && !missingMeters)
|
|
1058
|
+
throw new TypeError("[Sixb] Missing usage estimate requires missingMeters.");
|
|
1059
|
+
return {
|
|
1060
|
+
status: "unpriceable",
|
|
1061
|
+
reason,
|
|
1062
|
+
...missingMeters === undefined ? {} : { missingMeters }
|
|
1063
|
+
};
|
|
1064
|
+
}
|
|
1065
|
+
function isExternalValuationSource(sourceId) {
|
|
1066
|
+
return sourceId === "provider-reported";
|
|
1067
|
+
}
|
|
793
1068
|
function normalizeUnpriceableCost(input, base) {
|
|
794
1069
|
if (!UNPRICEABLE_REASONS.has(input.reason)) {
|
|
795
1070
|
throw new TypeError(`[Sixb] AI unpriceable reason '${String(input.reason)}' is invalid.`);
|
|
@@ -839,8 +1114,15 @@ function normalizePriceSource(input) {
|
|
|
839
1114
|
assertNonBlank3(input.sourceId, "price sourceId");
|
|
840
1115
|
assertNonBlank3(input.sourceEntryId, "price sourceEntryId");
|
|
841
1116
|
assertNonBlank3(input.sourceVersion, "price sourceVersion");
|
|
842
|
-
|
|
843
|
-
|
|
1117
|
+
if (input.sourceUrl !== undefined)
|
|
1118
|
+
assertNonBlank3(input.sourceUrl, "price sourceUrl");
|
|
1119
|
+
return {
|
|
1120
|
+
sourceId: input.sourceId,
|
|
1121
|
+
sourceEntryId: input.sourceEntryId,
|
|
1122
|
+
sourceVersion: input.sourceVersion,
|
|
1123
|
+
...input.sourceUrl === undefined ? {} : { sourceUrl: input.sourceUrl },
|
|
1124
|
+
observedAt: cloneDate(input.observedAt, "price source observedAt")
|
|
1125
|
+
};
|
|
844
1126
|
}
|
|
845
1127
|
function normalizeBillingIdentity(input) {
|
|
846
1128
|
assertNonBlank3(input.providerId, "billingIdentity.providerId");
|
|
@@ -908,6 +1190,6 @@ function cloneDate(value, field) {
|
|
|
908
1190
|
return new Date(value);
|
|
909
1191
|
}
|
|
910
1192
|
|
|
911
|
-
export { AiUsageStorageError, normalizeAiModelCallUsage, aggregateAiModelCallUsage, normalizeAiModelCallRecord, assertAiUsageExecutionId, InMemoryAiUsageStorage, normalizeAiAccountingQuery, normalizeAiModelCallAccountingQuery, buildAiAccountingOverview, buildAiAccountingOverviewFromFragments, buildAiModelCallAccountingList, toAccountingItem, normalizeAiPricingContext, normalizeAiModelCallCostRecord, aiModelCallCostMatchesUsage };
|
|
1193
|
+
export { AiUsageStorageError, normalizeAiModelCallUsage, aggregateAiModelCallUsage, normalizeAiModelCallRecord, assertAiUsageExecutionId, InMemoryAiUsageStorage, normalizeAiAccountingQuery, normalizeAiModelCallAccountingQuery, buildAiAccountingOverview, buildAiAccountingOverviewFromFragments, buildAiModelCallAccountingList, toAccountingItem, aiModelCallGroupFragmentFromRow, buildAiModelCallGroupsFromFragments, buildAiModelCallGroups, normalizeAiPricingContext, normalizeAiModelCallCostRecord, aiModelCallCostMatchesUsage, normalizeAiCostEstimate };
|
|
912
1194
|
|
|
913
|
-
//# debugId=
|
|
1195
|
+
//# debugId=EFFF98F246C92D1864756E2164756E21
|