@sixb/core 0.1.6 → 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/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.js +7 -7
- 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-1g8negke.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-dy311asx.js → chunk-2b5qtban.js} +12 -12
- package/dist/{chunk-dy311asx.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-md8k0r54.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-t624af60.js → chunk-6ed5bwnd.js} +646 -67
- package/dist/{chunk-t624af60.js.map → chunk-6ed5bwnd.js.map} +10 -9
- 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-nkbfrt0c.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-0hc5j867.js → chunk-d2ndstdf.js} +8 -6
- package/dist/{chunk-0hc5j867.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-5sxb1168.js → chunk-e4rvtvpw.js} +13 -11
- package/dist/{chunk-5sxb1168.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-nva1xkjz.js → chunk-h0knpbz5.js} +468 -1236
- package/dist/chunk-h0knpbz5.js.map +38 -0
- package/dist/{chunk-tg5mee00.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-znagycq7.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-n4spznws.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-5gynx4xn.js → chunk-qv38twt8.js} +50 -69
- package/dist/{chunk-5gynx4xn.js.map → chunk-qv38twt8.js.map} +8 -8
- package/dist/{chunk-bhxaq2nn.js → chunk-qw9gvjv5.js} +1 -1
- package/dist/{chunk-8gv5z0zm.js → chunk-rp1mvzb4.js} +6 -6
- package/dist/{chunk-1e8m6yn3.js → chunk-rre42skh.js} +182 -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-e42bc6m3.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-a44d5zgd.js → chunk-y35ma3mj.js} +11 -16
- package/dist/{chunk-a44d5zgd.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 +7 -4
- 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/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 +3637 -1962
- package/dist/testing/index.js.map +14 -12
- 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/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/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 +51 -1
- 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/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-1e8m6yn3.js.map +0 -37
- package/dist/chunk-1g8negke.js.map +0 -11
- package/dist/chunk-6gjqgd3d.js.map +0 -11
- package/dist/chunk-dm72y8wt.js.map +0 -10
- package/dist/chunk-drjqm1aa.js.map +0 -15
- package/dist/chunk-fe5ev6mr.js +0 -55
- package/dist/chunk-fe5ev6mr.js.map +0 -11
- package/dist/chunk-h9kxd41f.js.map +0 -11
- package/dist/chunk-hceck7dq.js +0 -137
- package/dist/chunk-hceck7dq.js.map +0 -10
- package/dist/chunk-n4spznws.js.map +0 -11
- package/dist/chunk-nva1xkjz.js.map +0 -46
- package/dist/chunk-t0jjkep3.js.map +0 -10
- package/dist/chunk-t8t39h7v.js.map +0 -10
- /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-md8k0r54.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-72q2y8hn.js.map → chunk-8tsf6dmc.js.map} +0 -0
- /package/dist/{chunk-nkbfrt0c.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-tg5mee00.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-znagycq7.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-8gv5z0zm.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-e42bc6m3.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
|
@@ -6,30 +6,30 @@ import {
|
|
|
6
6
|
createPrimitiveExecutionRecord,
|
|
7
7
|
ensureExecutionRecord,
|
|
8
8
|
executionRecordInputFromRuntime
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-hdz94br2.js";
|
|
10
10
|
import {
|
|
11
11
|
SYNC_RUN_FAILURE_CODES
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-6ed5bwnd.js";
|
|
13
13
|
import {
|
|
14
14
|
SyncRunError
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-4nxeacx7.js";
|
|
16
16
|
import {
|
|
17
17
|
ConnectorConnectionStorageError
|
|
18
18
|
} from "./chunk-5gd7tpv6.js";
|
|
19
19
|
import {
|
|
20
20
|
reportRunFailure
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-jq43kdvk.js";
|
|
22
22
|
import {
|
|
23
23
|
AuthorizationError,
|
|
24
24
|
assertAuthorized,
|
|
25
25
|
assertProviderAccess,
|
|
26
26
|
resolveExecutionScopeAuthorization
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-37wk412q.js";
|
|
28
28
|
import {
|
|
29
29
|
createSixbError,
|
|
30
30
|
isSixbError,
|
|
31
31
|
toSixbFailure
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-2xns679x.js";
|
|
33
33
|
|
|
34
34
|
// src/connectors/errors.ts
|
|
35
35
|
class ConnectorError extends Error {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
ExecutionStorageError
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-gbrpsx4m.js";
|
|
5
5
|
import {
|
|
6
6
|
createTrustedPrimitiveRuntimeAuthorization,
|
|
7
7
|
getAuthorizationRef
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-37wk412q.js";
|
|
9
9
|
|
|
10
10
|
// src/execution/durable.ts
|
|
11
11
|
import { isDeepStrictEqual } from "util";
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/storage/ai-limits/errors.ts
|
|
3
|
+
class AiLimitStorageError extends Error {
|
|
4
|
+
code;
|
|
5
|
+
name = "AiLimitStorageError";
|
|
6
|
+
constructor(code, message) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.code = code;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// src/storage/ai-limits/period.ts
|
|
13
|
+
function aiLimitCalendarMonth(at) {
|
|
14
|
+
if (!(at instanceof Date) || !Number.isFinite(at.getTime())) {
|
|
15
|
+
throw new TypeError("[Sixb] AI limit period date must be a valid Date.");
|
|
16
|
+
}
|
|
17
|
+
const start = new Date(Date.UTC(at.getUTCFullYear(), at.getUTCMonth(), 1));
|
|
18
|
+
const end = new Date(Date.UTC(at.getUTCFullYear(), at.getUTCMonth() + 1, 1));
|
|
19
|
+
return { kind: "calendarMonth", start, end, resetAt: new Date(end) };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// src/storage/ai-limits/provider.ts
|
|
23
|
+
var SIGNED_INT64_MAX = 9223372036854775807n;
|
|
24
|
+
|
|
25
|
+
class AiLimitOperationLock {
|
|
26
|
+
tail = Promise.resolve();
|
|
27
|
+
settle() {
|
|
28
|
+
return this.tail;
|
|
29
|
+
}
|
|
30
|
+
async run(operation) {
|
|
31
|
+
const previous = this.tail;
|
|
32
|
+
let release;
|
|
33
|
+
this.tail = new Promise((resolve) => {
|
|
34
|
+
release = resolve;
|
|
35
|
+
});
|
|
36
|
+
await previous;
|
|
37
|
+
try {
|
|
38
|
+
return await operation();
|
|
39
|
+
} finally {
|
|
40
|
+
release();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function normalizeAiLimitSubject(subject) {
|
|
45
|
+
if (!subject || typeof subject !== "object") {
|
|
46
|
+
throw new TypeError("[Sixb] AI limit subject must be an object.");
|
|
47
|
+
}
|
|
48
|
+
if (subject.type === "project")
|
|
49
|
+
return { type: "project" };
|
|
50
|
+
if (subject.type === "group" || subject.type === "user" || subject.type === "serviceAccount") {
|
|
51
|
+
assertNonBlank(subject.id, "subject id");
|
|
52
|
+
return { type: subject.type, id: subject.id };
|
|
53
|
+
}
|
|
54
|
+
throw new TypeError("[Sixb] AI limit subject type is unsupported.");
|
|
55
|
+
}
|
|
56
|
+
function normalizeAiLimitSubjects(subjects) {
|
|
57
|
+
if (!Array.isArray(subjects)) {
|
|
58
|
+
throw new TypeError("[Sixb] AI limit subjects must be an array.");
|
|
59
|
+
}
|
|
60
|
+
const normalized = [
|
|
61
|
+
normalizeAiLimitSubject({ type: "project" }),
|
|
62
|
+
...subjects.map(normalizeAiLimitSubject)
|
|
63
|
+
];
|
|
64
|
+
const byKey = new Map(normalized.map((subject) => [aiLimitSubjectKey(subject), subject]));
|
|
65
|
+
return [...byKey.values()].sort((left, right) => aiLimitSubjectKey(left).localeCompare(aiLimitSubjectKey(right)));
|
|
66
|
+
}
|
|
67
|
+
function aiLimitSubjectKey(subject) {
|
|
68
|
+
return subject.type === "project" ? "project:" : `${subject.type}:${subject.id}`;
|
|
69
|
+
}
|
|
70
|
+
function aiLimitSubjectParts(subject) {
|
|
71
|
+
return { type: subject.type, id: subject.type === "project" ? "" : subject.id };
|
|
72
|
+
}
|
|
73
|
+
function aiLimitSubjectFromParts(type, id) {
|
|
74
|
+
return normalizeAiLimitSubject(type === "project" ? { type } : { type, id });
|
|
75
|
+
}
|
|
76
|
+
function normalizeAiLimitQuantity(quantity) {
|
|
77
|
+
const normalized = normalizeAiLimitAmount(quantity);
|
|
78
|
+
return aiLimitQuantityFromAmount(normalized);
|
|
79
|
+
}
|
|
80
|
+
function normalizeAiLimitQuantities(quantities, label) {
|
|
81
|
+
if (!Array.isArray(quantities) || quantities.length === 0) {
|
|
82
|
+
throw new TypeError(`[Sixb] AI limit ${label} must contain at least one quantity.`);
|
|
83
|
+
}
|
|
84
|
+
const byKey = new Map;
|
|
85
|
+
for (const quantity of quantities) {
|
|
86
|
+
const normalized = normalizeAiLimitQuantity(quantity);
|
|
87
|
+
const key = aiLimitAmountKey(normalizeAiLimitAmount(normalized));
|
|
88
|
+
if (byKey.has(key)) {
|
|
89
|
+
throw new TypeError(`[Sixb] AI limit ${label} contains duplicate meter '${key}'.`);
|
|
90
|
+
}
|
|
91
|
+
byKey.set(key, normalized);
|
|
92
|
+
}
|
|
93
|
+
return [...byKey.values()].sort((left, right) => aiLimitAmountKey(normalizeAiLimitAmount(left)).localeCompare(aiLimitAmountKey(normalizeAiLimitAmount(right))));
|
|
94
|
+
}
|
|
95
|
+
function normalizeAiLimitAmount(quantity) {
|
|
96
|
+
if (!quantity || typeof quantity !== "object") {
|
|
97
|
+
throw new TypeError("[Sixb] AI limit quantity must be an object.");
|
|
98
|
+
}
|
|
99
|
+
if (quantity.meter === "tokens.total") {
|
|
100
|
+
if (!Number.isSafeInteger(quantity.amount) || quantity.amount < 0) {
|
|
101
|
+
throw new TypeError("[Sixb] AI limit token amount must be a non-negative safe integer.");
|
|
102
|
+
}
|
|
103
|
+
return { meter: quantity.meter, currency: "", amount: BigInt(quantity.amount) };
|
|
104
|
+
}
|
|
105
|
+
if (quantity.meter === "cost.catalogEstimated") {
|
|
106
|
+
const money = normalizeAiMoney(quantity.amount);
|
|
107
|
+
return { meter: quantity.meter, currency: money.currency, amount: BigInt(money.amountNanos) };
|
|
108
|
+
}
|
|
109
|
+
throw new TypeError("[Sixb] AI limit meter is unsupported.");
|
|
110
|
+
}
|
|
111
|
+
function aiLimitQuantityFromAmount(amount) {
|
|
112
|
+
if (amount.amount < 0n) {
|
|
113
|
+
throw new TypeError("[Sixb] AI limit amount cannot be negative.");
|
|
114
|
+
}
|
|
115
|
+
if (amount.meter === "tokens.total") {
|
|
116
|
+
const tokens = Number(amount.amount);
|
|
117
|
+
if (!Number.isSafeInteger(tokens)) {
|
|
118
|
+
throw new RangeError("[Sixb] AI limit token amount exceeds JavaScript's safe integer range.");
|
|
119
|
+
}
|
|
120
|
+
return { meter: amount.meter, amount: tokens };
|
|
121
|
+
}
|
|
122
|
+
if (amount.currency !== "USD") {
|
|
123
|
+
throw new TypeError("[Sixb] AI limit catalog-estimated cost currency must be 'USD'.");
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
meter: amount.meter,
|
|
127
|
+
amount: { currency: "USD", amountNanos: amount.amount.toString() }
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function aiLimitAmountKey(amount) {
|
|
131
|
+
return `${amount.meter}:${amount.currency}`;
|
|
132
|
+
}
|
|
133
|
+
function normalizeCreateAiLimitPolicy(input) {
|
|
134
|
+
assertNonBlank(input.id, "policy id");
|
|
135
|
+
assertNonBlank(input.projectId, "projectId");
|
|
136
|
+
const createdAt = cloneValidDate(input.createdAt ?? new Date, "createdAt");
|
|
137
|
+
return {
|
|
138
|
+
id: input.id,
|
|
139
|
+
projectId: input.projectId,
|
|
140
|
+
subject: normalizeAiLimitSubject(input.subject),
|
|
141
|
+
limit: normalizeAiLimitQuantity(input.limit),
|
|
142
|
+
period: "calendarMonth",
|
|
143
|
+
enabled: input.enabled ?? true,
|
|
144
|
+
createdAt,
|
|
145
|
+
updatedAt: new Date(createdAt)
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function normalizeUpdateAiLimitPolicy(input) {
|
|
149
|
+
assertNonBlank(input.projectId, "projectId");
|
|
150
|
+
assertNonBlank(input.id, "policy id");
|
|
151
|
+
if (input.limit === undefined && input.enabled === undefined) {
|
|
152
|
+
throw new TypeError("[Sixb] AI limit policy update must change limit or enabled.");
|
|
153
|
+
}
|
|
154
|
+
if (input.enabled !== undefined && typeof input.enabled !== "boolean") {
|
|
155
|
+
throw new TypeError("[Sixb] AI limit enabled must be a boolean.");
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
projectId: input.projectId,
|
|
159
|
+
id: input.id,
|
|
160
|
+
...input.limit === undefined ? {} : { limit: normalizeAiLimitQuantity(input.limit) },
|
|
161
|
+
...input.enabled === undefined ? {} : { enabled: input.enabled },
|
|
162
|
+
updatedAt: cloneValidDate(input.updatedAt ?? new Date, "updatedAt")
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
function normalizeReserveAiModelCall(input) {
|
|
166
|
+
const identity = normalizeAiModelCallReservationIdentity(input);
|
|
167
|
+
const reservedAt = cloneValidDate(input.reservedAt ?? new Date, "reservedAt");
|
|
168
|
+
return {
|
|
169
|
+
identity,
|
|
170
|
+
subjects: normalizeAiLimitSubjects(input.subjects),
|
|
171
|
+
estimates: normalizeAiLimitQuantities(input.estimates, "estimates"),
|
|
172
|
+
period: aiLimitCalendarMonth(reservedAt),
|
|
173
|
+
reservedAt
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function normalizeAiModelCallReservationIdentity(input) {
|
|
177
|
+
assertNonBlank(input.projectId, "projectId");
|
|
178
|
+
assertNonBlank(input.executionId, "executionId");
|
|
179
|
+
if (!Number.isSafeInteger(input.attempt) || input.attempt <= 0) {
|
|
180
|
+
throw new TypeError("[Sixb] AI limit reservation attempt must be a positive safe integer.");
|
|
181
|
+
}
|
|
182
|
+
assertNonBlank(input.callId, "callId");
|
|
183
|
+
return {
|
|
184
|
+
projectId: input.projectId,
|
|
185
|
+
executionId: input.executionId,
|
|
186
|
+
attempt: input.attempt,
|
|
187
|
+
callId: input.callId
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
function aiModelCallReservationKey(identity) {
|
|
191
|
+
return JSON.stringify([
|
|
192
|
+
identity.projectId,
|
|
193
|
+
identity.executionId,
|
|
194
|
+
identity.attempt,
|
|
195
|
+
identity.callId
|
|
196
|
+
]);
|
|
197
|
+
}
|
|
198
|
+
function aiLimitPolicyDimensionKey(policy) {
|
|
199
|
+
const amount = normalizeAiLimitAmount(policy.limit);
|
|
200
|
+
return JSON.stringify([
|
|
201
|
+
policy.projectId,
|
|
202
|
+
aiLimitSubjectKey(policy.subject),
|
|
203
|
+
amount.meter,
|
|
204
|
+
amount.currency
|
|
205
|
+
]);
|
|
206
|
+
}
|
|
207
|
+
function aiLimitReservationRequestMatches(reservation, request) {
|
|
208
|
+
return reservation.requestKey === aiLimitReservationRequestKey(request);
|
|
209
|
+
}
|
|
210
|
+
function aiLimitReservationRequestKey(request) {
|
|
211
|
+
return JSON.stringify([
|
|
212
|
+
request.period.start.toISOString(),
|
|
213
|
+
request.subjects.map(aiLimitSubjectKey),
|
|
214
|
+
request.estimates.map((quantity) => {
|
|
215
|
+
const amount = normalizeAiLimitAmount(quantity);
|
|
216
|
+
return [amount.meter, amount.currency, amount.amount.toString()];
|
|
217
|
+
})
|
|
218
|
+
]);
|
|
219
|
+
}
|
|
220
|
+
function aiLimitReservationBuckets(policies, subjects, estimates) {
|
|
221
|
+
const subjectKeys = new Set(subjects.map(aiLimitSubjectKey));
|
|
222
|
+
const estimatesByDimension = new Map(estimates.map((estimate) => {
|
|
223
|
+
const amount = normalizeAiLimitAmount(estimate);
|
|
224
|
+
return [aiLimitAmountKey(amount), estimate];
|
|
225
|
+
}));
|
|
226
|
+
return policies.filter((policy) => subjectKeys.has(aiLimitSubjectKey(policy.subject))).flatMap((policy) => {
|
|
227
|
+
const estimate = estimatesByDimension.get(aiLimitAmountKey(normalizeAiLimitAmount(policy.limit)));
|
|
228
|
+
return estimate ? [{ subject: policy.subject, estimate }] : [];
|
|
229
|
+
}).sort((left, right) => {
|
|
230
|
+
const subject = aiLimitSubjectKey(left.subject).localeCompare(aiLimitSubjectKey(right.subject));
|
|
231
|
+
if (subject !== 0)
|
|
232
|
+
return subject;
|
|
233
|
+
return aiLimitAmountKey(normalizeAiLimitAmount(left.estimate)).localeCompare(aiLimitAmountKey(normalizeAiLimitAmount(right.estimate)));
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
function aiLimitAccountingEntryAppliesToSubject(entry, subject) {
|
|
237
|
+
if (subject.type === "project")
|
|
238
|
+
return true;
|
|
239
|
+
if (subject.type === "group")
|
|
240
|
+
return entry.requesterGroupIds.includes(subject.id);
|
|
241
|
+
return entry.requester?.type === subject.type && entry.requester.id === subject.id;
|
|
242
|
+
}
|
|
243
|
+
function aiLimitSubjectsFromAccountingEntry(entry) {
|
|
244
|
+
return normalizeAiLimitSubjects([
|
|
245
|
+
...entry.requesterGroupIds.map((id) => ({ type: "group", id })),
|
|
246
|
+
...entry.requester ? [entry.requester] : []
|
|
247
|
+
]);
|
|
248
|
+
}
|
|
249
|
+
function resolveAiLimitActual(entries, dimension) {
|
|
250
|
+
let amount = 0n;
|
|
251
|
+
let accountingStatus = "complete";
|
|
252
|
+
for (const entry of entries) {
|
|
253
|
+
if (dimension.meter === "tokens.total") {
|
|
254
|
+
if (entry.totalTokens === undefined) {
|
|
255
|
+
accountingStatus = "unavailable";
|
|
256
|
+
} else {
|
|
257
|
+
amount += BigInt(entry.totalTokens);
|
|
258
|
+
}
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
if (entry.valuation?.status !== "rated" || entry.valuation.money.currency !== dimension.currency) {
|
|
262
|
+
accountingStatus = "unavailable";
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
amount += BigInt(entry.valuation.money.amountNanos);
|
|
266
|
+
}
|
|
267
|
+
return { amount, accountingStatus };
|
|
268
|
+
}
|
|
269
|
+
function assertAiLimitAccountingMatchesReservation(reservation, entry) {
|
|
270
|
+
if (entry.projectId !== reservation.projectId || entry.executionId !== reservation.executionId || entry.attempt !== reservation.attempt || entry.callId !== reservation.callId) {
|
|
271
|
+
throw new AiLimitStorageError("usage_mismatch", `[Sixb] AI usage record '${entry.usageRecordId}' does not belong to reservation '${reservation.callId}'.`);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
function cloneAiLimitPolicy(policy) {
|
|
275
|
+
return structuredClone(policy);
|
|
276
|
+
}
|
|
277
|
+
function normalizeAiMoney(money) {
|
|
278
|
+
if (!money || typeof money !== "object") {
|
|
279
|
+
throw new TypeError("[Sixb] AI limit cost amount must be AiMoney.");
|
|
280
|
+
}
|
|
281
|
+
assertNonBlank(money.currency, "cost currency");
|
|
282
|
+
if (money.currency !== "USD") {
|
|
283
|
+
throw new TypeError("[Sixb] AI limit catalog-estimated cost currency must be 'USD'.");
|
|
284
|
+
}
|
|
285
|
+
if (!/^(0|[1-9][0-9]*)$/.test(money.amountNanos)) {
|
|
286
|
+
throw new TypeError("[Sixb] AI limit cost amountNanos must be a canonical non-negative integer string.");
|
|
287
|
+
}
|
|
288
|
+
if (BigInt(money.amountNanos) > SIGNED_INT64_MAX) {
|
|
289
|
+
throw new RangeError("[Sixb] AI limit cost amountNanos exceeds the supported range.");
|
|
290
|
+
}
|
|
291
|
+
return { currency: "USD", amountNanos: money.amountNanos };
|
|
292
|
+
}
|
|
293
|
+
function assertNonBlank(value, label) {
|
|
294
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
295
|
+
throw new TypeError(`[Sixb] AI limit ${label} must be nonblank.`);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
function cloneValidDate(value, label) {
|
|
299
|
+
if (!(value instanceof Date) || !Number.isFinite(value.getTime())) {
|
|
300
|
+
throw new TypeError(`[Sixb] AI limit ${label} must be a valid Date.`);
|
|
301
|
+
}
|
|
302
|
+
return new Date(value);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
export { AiLimitStorageError, aiLimitCalendarMonth, AiLimitOperationLock, normalizeAiLimitSubject, normalizeAiLimitSubjects, aiLimitSubjectKey, aiLimitSubjectParts, aiLimitSubjectFromParts, normalizeAiLimitQuantity, normalizeAiLimitQuantities, normalizeAiLimitAmount, aiLimitQuantityFromAmount, aiLimitAmountKey, normalizeCreateAiLimitPolicy, normalizeUpdateAiLimitPolicy, normalizeReserveAiModelCall, normalizeAiModelCallReservationIdentity, aiModelCallReservationKey, aiLimitPolicyDimensionKey, aiLimitReservationRequestMatches, aiLimitReservationRequestKey, aiLimitReservationBuckets, aiLimitAccountingEntryAppliesToSubject, aiLimitSubjectsFromAccountingEntry, resolveAiLimitActual, assertAiLimitAccountingMatchesReservation, cloneAiLimitPolicy, assertNonBlank, cloneValidDate };
|
|
306
|
+
|
|
307
|
+
//# debugId=8F027D87CF44DB7364756E2164756E21
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/storage/ai-limits/errors.ts", "../src/storage/ai-limits/period.ts", "../src/storage/ai-limits/provider.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"export type AiLimitStorageErrorCode =\n | \"duplicate_policy\"\n | \"missing_policy\"\n | \"missing_execution\"\n | \"missing_reservation\"\n | \"missing_usage_record\"\n | \"usage_mismatch\"\n | \"unavailable_actuals\"\n | \"reservation_conflict\"\n | \"reconciliation_conflict\"\n | \"invalid_reservation_state\"\n\n/** Stable storage failure for AI limit policies and reservations. */\nexport class AiLimitStorageError extends Error {\n readonly name = \"AiLimitStorageError\"\n\n constructor(\n readonly code: AiLimitStorageErrorCode,\n message: string\n ) {\n super(message)\n }\n}\n",
|
|
6
|
+
"import type { AiLimitPeriod } from \"./types\"\n\n/** Return the UTC calendar month containing `at`, with an inclusive start and exclusive end. */\nexport function aiLimitCalendarMonth(at: Date): AiLimitPeriod {\n if (!(at instanceof Date) || !Number.isFinite(at.getTime())) {\n throw new TypeError(\"[Sixb] AI limit period date must be a valid Date.\")\n }\n const start = new Date(Date.UTC(at.getUTCFullYear(), at.getUTCMonth(), 1))\n const end = new Date(Date.UTC(at.getUTCFullYear(), at.getUTCMonth() + 1, 1))\n return { kind: \"calendarMonth\", start, end, resetAt: new Date(end) }\n}\n",
|
|
7
|
+
"import type { AiMoney } from \"../ai-cost\"\nimport { AiLimitStorageError } from \"./errors\"\nimport { aiLimitCalendarMonth } from \"./period\"\nimport type {\n AiLimitPeriod,\n AiLimitPolicy,\n AiLimitQuantity,\n AiLimitReservationBucket,\n AiLimitSubject,\n AiModelCallReservation,\n AiModelCallReservationIdentity,\n CreateAiLimitPolicyInput,\n ReserveAiModelCallInput,\n UpdateAiLimitPolicyInput,\n} from \"./types\"\n\nconst SIGNED_INT64_MAX = 9_223_372_036_854_775_807n\n\n/** @internal Serialize compound limit operations, including within an existing transaction. */\nexport class AiLimitOperationLock {\n private tail: Promise<void> = Promise.resolve()\n\n /** Wait for already queued operations before the owning transaction commits or rolls back. */\n settle(): Promise<void> {\n return this.tail\n }\n\n async run<T>(operation: () => Promise<T> | T): Promise<T> {\n const previous = this.tail\n let release!: () => void\n this.tail = new Promise<void>((resolve) => {\n release = resolve\n })\n await previous\n try {\n return await operation()\n } finally {\n release()\n }\n }\n}\n\n/** @internal Canonical integer quantity used by storage providers. */\nexport interface NormalizedAiLimitAmount {\n readonly meter: AiLimitQuantity[\"meter\"]\n readonly currency: string\n readonly amount: bigint\n}\n\n/** @internal Minimal immutable accounting facts consumed by limit providers. */\nexport interface AiLimitAccountingEntry {\n readonly projectId: string\n readonly usageRecordId: string\n readonly executionId: string\n readonly attempt: number\n readonly callId: string\n readonly occurredAt: Date\n readonly totalTokens?: number\n readonly requesterGroupIds: readonly string[]\n readonly requester?:\n | { readonly type: \"user\"; readonly id: string }\n | { readonly type: \"serviceAccount\"; readonly id: string }\n readonly valuation?:\n | { readonly status: \"rated\"; readonly money: AiMoney }\n | { readonly status: \"unavailable\" }\n}\n\nexport interface ResolvedAiLimitActual {\n readonly amount: bigint\n readonly accountingStatus: \"complete\" | \"unavailable\"\n}\n\nexport function normalizeAiLimitSubject(subject: AiLimitSubject): AiLimitSubject {\n if (!subject || typeof subject !== \"object\") {\n throw new TypeError(\"[Sixb] AI limit subject must be an object.\")\n }\n if (subject.type === \"project\") return { type: \"project\" }\n if (subject.type === \"group\" || subject.type === \"user\" || subject.type === \"serviceAccount\") {\n assertNonBlank(subject.id, \"subject id\")\n return { type: subject.type, id: subject.id }\n }\n throw new TypeError(\"[Sixb] AI limit subject type is unsupported.\")\n}\n\nexport function normalizeAiLimitSubjects(\n subjects: readonly AiLimitSubject[]\n): readonly AiLimitSubject[] {\n if (!Array.isArray(subjects)) {\n throw new TypeError(\"[Sixb] AI limit subjects must be an array.\")\n }\n const normalized = [\n normalizeAiLimitSubject({ type: \"project\" }),\n ...subjects.map(normalizeAiLimitSubject),\n ]\n const byKey = new Map(normalized.map((subject) => [aiLimitSubjectKey(subject), subject]))\n return [...byKey.values()].sort((left, right) =>\n aiLimitSubjectKey(left).localeCompare(aiLimitSubjectKey(right))\n )\n}\n\nexport function aiLimitSubjectKey(subject: AiLimitSubject): string {\n return subject.type === \"project\" ? \"project:\" : `${subject.type}:${subject.id}`\n}\n\nexport function aiLimitSubjectParts(subject: AiLimitSubject): {\n readonly type: AiLimitSubject[\"type\"]\n readonly id: string\n} {\n return { type: subject.type, id: subject.type === \"project\" ? \"\" : subject.id }\n}\n\nexport function aiLimitSubjectFromParts(type: AiLimitSubject[\"type\"], id: string): AiLimitSubject {\n return normalizeAiLimitSubject(type === \"project\" ? { type } : { type, id })\n}\n\nexport function normalizeAiLimitQuantity(quantity: AiLimitQuantity): AiLimitQuantity {\n const normalized = normalizeAiLimitAmount(quantity)\n return aiLimitQuantityFromAmount(normalized)\n}\n\nexport function normalizeAiLimitQuantities(\n quantities: readonly AiLimitQuantity[],\n label: string\n): readonly AiLimitQuantity[] {\n if (!Array.isArray(quantities) || quantities.length === 0) {\n throw new TypeError(`[Sixb] AI limit ${label} must contain at least one quantity.`)\n }\n const byKey = new Map<string, AiLimitQuantity>()\n for (const quantity of quantities) {\n const normalized = normalizeAiLimitQuantity(quantity)\n const key = aiLimitAmountKey(normalizeAiLimitAmount(normalized))\n if (byKey.has(key)) {\n throw new TypeError(`[Sixb] AI limit ${label} contains duplicate meter '${key}'.`)\n }\n byKey.set(key, normalized)\n }\n return [...byKey.values()].sort((left, right) =>\n aiLimitAmountKey(normalizeAiLimitAmount(left)).localeCompare(\n aiLimitAmountKey(normalizeAiLimitAmount(right))\n )\n )\n}\n\nexport function normalizeAiLimitAmount(quantity: AiLimitQuantity): NormalizedAiLimitAmount {\n if (!quantity || typeof quantity !== \"object\") {\n throw new TypeError(\"[Sixb] AI limit quantity must be an object.\")\n }\n if (quantity.meter === \"tokens.total\") {\n if (!Number.isSafeInteger(quantity.amount) || quantity.amount < 0) {\n throw new TypeError(\"[Sixb] AI limit token amount must be a non-negative safe integer.\")\n }\n return { meter: quantity.meter, currency: \"\", amount: BigInt(quantity.amount) }\n }\n if (quantity.meter === \"cost.catalogEstimated\") {\n const money = normalizeAiMoney(quantity.amount)\n return { meter: quantity.meter, currency: money.currency, amount: BigInt(money.amountNanos) }\n }\n throw new TypeError(\"[Sixb] AI limit meter is unsupported.\")\n}\n\nexport function aiLimitQuantityFromAmount(amount: NormalizedAiLimitAmount): AiLimitQuantity {\n if (amount.amount < 0n) {\n throw new TypeError(\"[Sixb] AI limit amount cannot be negative.\")\n }\n if (amount.meter === \"tokens.total\") {\n const tokens = Number(amount.amount)\n if (!Number.isSafeInteger(tokens)) {\n throw new RangeError(\"[Sixb] AI limit token amount exceeds JavaScript's safe integer range.\")\n }\n return { meter: amount.meter, amount: tokens }\n }\n if (amount.currency !== \"USD\") {\n throw new TypeError(\"[Sixb] AI limit catalog-estimated cost currency must be 'USD'.\")\n }\n return {\n meter: amount.meter,\n amount: { currency: \"USD\", amountNanos: amount.amount.toString() },\n }\n}\n\nexport function aiLimitAmountKey(\n amount: Pick<NormalizedAiLimitAmount, \"meter\" | \"currency\">\n): string {\n return `${amount.meter}:${amount.currency}`\n}\n\nexport function normalizeCreateAiLimitPolicy(input: CreateAiLimitPolicyInput): AiLimitPolicy {\n assertNonBlank(input.id, \"policy id\")\n assertNonBlank(input.projectId, \"projectId\")\n const createdAt = cloneValidDate(input.createdAt ?? new Date(), \"createdAt\")\n return {\n id: input.id,\n projectId: input.projectId,\n subject: normalizeAiLimitSubject(input.subject),\n limit: normalizeAiLimitQuantity(input.limit),\n period: \"calendarMonth\",\n enabled: input.enabled ?? true,\n createdAt,\n updatedAt: new Date(createdAt),\n }\n}\n\nexport function normalizeUpdateAiLimitPolicy(input: UpdateAiLimitPolicyInput): {\n readonly projectId: string\n readonly id: string\n readonly limit?: AiLimitQuantity\n readonly enabled?: boolean\n readonly updatedAt: Date\n} {\n assertNonBlank(input.projectId, \"projectId\")\n assertNonBlank(input.id, \"policy id\")\n if (input.limit === undefined && input.enabled === undefined) {\n throw new TypeError(\"[Sixb] AI limit policy update must change limit or enabled.\")\n }\n if (input.enabled !== undefined && typeof input.enabled !== \"boolean\") {\n throw new TypeError(\"[Sixb] AI limit enabled must be a boolean.\")\n }\n return {\n projectId: input.projectId,\n id: input.id,\n ...(input.limit === undefined ? {} : { limit: normalizeAiLimitQuantity(input.limit) }),\n ...(input.enabled === undefined ? {} : { enabled: input.enabled }),\n updatedAt: cloneValidDate(input.updatedAt ?? new Date(), \"updatedAt\"),\n }\n}\n\nexport function normalizeReserveAiModelCall(input: ReserveAiModelCallInput): {\n readonly identity: AiModelCallReservationIdentity\n readonly subjects: readonly AiLimitSubject[]\n readonly estimates: readonly AiLimitQuantity[]\n readonly period: AiLimitPeriod\n readonly reservedAt: Date\n} {\n const identity = normalizeAiModelCallReservationIdentity(input)\n const reservedAt = cloneValidDate(input.reservedAt ?? new Date(), \"reservedAt\")\n return {\n identity,\n subjects: normalizeAiLimitSubjects(input.subjects),\n estimates: normalizeAiLimitQuantities(input.estimates, \"estimates\"),\n period: aiLimitCalendarMonth(reservedAt),\n reservedAt,\n }\n}\n\nexport function normalizeAiModelCallReservationIdentity(\n input: AiModelCallReservationIdentity\n): AiModelCallReservationIdentity {\n assertNonBlank(input.projectId, \"projectId\")\n assertNonBlank(input.executionId, \"executionId\")\n if (!Number.isSafeInteger(input.attempt) || input.attempt <= 0) {\n throw new TypeError(\"[Sixb] AI limit reservation attempt must be a positive safe integer.\")\n }\n assertNonBlank(input.callId, \"callId\")\n return {\n projectId: input.projectId,\n executionId: input.executionId,\n attempt: input.attempt,\n callId: input.callId,\n }\n}\n\nexport function aiModelCallReservationKey(identity: AiModelCallReservationIdentity): string {\n return JSON.stringify([\n identity.projectId,\n identity.executionId,\n identity.attempt,\n identity.callId,\n ])\n}\n\nexport function aiLimitPolicyDimensionKey(\n policy: Pick<AiLimitPolicy, \"projectId\" | \"subject\" | \"limit\">\n): string {\n const amount = normalizeAiLimitAmount(policy.limit)\n return JSON.stringify([\n policy.projectId,\n aiLimitSubjectKey(policy.subject),\n amount.meter,\n amount.currency,\n ])\n}\n\nexport function aiLimitReservationRequestMatches(\n reservation: AiModelCallReservation,\n request: ReturnType<typeof normalizeReserveAiModelCall>\n): boolean {\n return reservation.requestKey === aiLimitReservationRequestKey(request)\n}\n\nexport function aiLimitReservationRequestKey(\n request: ReturnType<typeof normalizeReserveAiModelCall>\n): string {\n return JSON.stringify([\n request.period.start.toISOString(),\n request.subjects.map(aiLimitSubjectKey),\n request.estimates.map((quantity) => {\n const amount = normalizeAiLimitAmount(quantity)\n return [amount.meter, amount.currency, amount.amount.toString()]\n }),\n ])\n}\n\nexport function aiLimitReservationBuckets(\n policies: readonly AiLimitPolicy[],\n subjects: readonly AiLimitSubject[],\n estimates: readonly AiLimitQuantity[]\n): readonly AiLimitReservationBucket[] {\n const subjectKeys = new Set(subjects.map(aiLimitSubjectKey))\n const estimatesByDimension = new Map(\n estimates.map((estimate) => {\n const amount = normalizeAiLimitAmount(estimate)\n return [aiLimitAmountKey(amount), estimate] as const\n })\n )\n return policies\n .filter((policy) => subjectKeys.has(aiLimitSubjectKey(policy.subject)))\n .flatMap((policy) => {\n const estimate = estimatesByDimension.get(\n aiLimitAmountKey(normalizeAiLimitAmount(policy.limit))\n )\n return estimate ? [{ subject: policy.subject, estimate }] : []\n })\n .sort((left, right) => {\n const subject = aiLimitSubjectKey(left.subject).localeCompare(\n aiLimitSubjectKey(right.subject)\n )\n if (subject !== 0) return subject\n return aiLimitAmountKey(normalizeAiLimitAmount(left.estimate)).localeCompare(\n aiLimitAmountKey(normalizeAiLimitAmount(right.estimate))\n )\n })\n}\n\nexport function aiLimitAccountingEntryAppliesToSubject(\n entry: AiLimitAccountingEntry,\n subject: AiLimitSubject\n): boolean {\n if (subject.type === \"project\") return true\n if (subject.type === \"group\") return entry.requesterGroupIds.includes(subject.id)\n return entry.requester?.type === subject.type && entry.requester.id === subject.id\n}\n\nexport function aiLimitSubjectsFromAccountingEntry(\n entry: AiLimitAccountingEntry\n): readonly AiLimitSubject[] {\n return normalizeAiLimitSubjects([\n ...entry.requesterGroupIds.map((id) => ({ type: \"group\" as const, id })),\n ...(entry.requester ? [entry.requester] : []),\n ])\n}\n\nexport function resolveAiLimitActual(\n entries: readonly AiLimitAccountingEntry[],\n dimension: Pick<NormalizedAiLimitAmount, \"meter\" | \"currency\">\n): ResolvedAiLimitActual {\n let amount = 0n\n let accountingStatus: ResolvedAiLimitActual[\"accountingStatus\"] = \"complete\"\n for (const entry of entries) {\n if (dimension.meter === \"tokens.total\") {\n if (entry.totalTokens === undefined) {\n accountingStatus = \"unavailable\"\n } else {\n amount += BigInt(entry.totalTokens)\n }\n continue\n }\n if (\n entry.valuation?.status !== \"rated\" ||\n entry.valuation.money.currency !== dimension.currency\n ) {\n accountingStatus = \"unavailable\"\n continue\n }\n amount += BigInt(entry.valuation.money.amountNanos)\n }\n return { amount, accountingStatus }\n}\n\nexport function assertAiLimitAccountingMatchesReservation(\n reservation: AiModelCallReservation,\n entry: AiLimitAccountingEntry\n): void {\n if (\n entry.projectId !== reservation.projectId ||\n entry.executionId !== reservation.executionId ||\n entry.attempt !== reservation.attempt ||\n entry.callId !== reservation.callId\n ) {\n throw new AiLimitStorageError(\n \"usage_mismatch\",\n `[Sixb] AI usage record '${entry.usageRecordId}' does not belong to reservation '${reservation.callId}'.`\n )\n }\n}\n\nexport function cloneAiLimitPolicy(policy: AiLimitPolicy): AiLimitPolicy {\n return structuredClone(policy)\n}\n\nfunction normalizeAiMoney(money: AiMoney): AiMoney & { readonly currency: \"USD\" } {\n if (!money || typeof money !== \"object\") {\n throw new TypeError(\"[Sixb] AI limit cost amount must be AiMoney.\")\n }\n assertNonBlank(money.currency, \"cost currency\")\n if (money.currency !== \"USD\") {\n throw new TypeError(\"[Sixb] AI limit catalog-estimated cost currency must be 'USD'.\")\n }\n if (!/^(0|[1-9][0-9]*)$/.test(money.amountNanos)) {\n throw new TypeError(\n \"[Sixb] AI limit cost amountNanos must be a canonical non-negative integer string.\"\n )\n }\n if (BigInt(money.amountNanos) > SIGNED_INT64_MAX) {\n throw new RangeError(\"[Sixb] AI limit cost amountNanos exceeds the supported range.\")\n }\n return { currency: \"USD\", amountNanos: money.amountNanos }\n}\n\nexport function assertNonBlank(value: string, label: string): void {\n if (typeof value !== \"string\" || value.trim().length === 0) {\n throw new TypeError(`[Sixb] AI limit ${label} must be nonblank.`)\n }\n}\n\nexport function cloneValidDate(value: Date, label: string): Date {\n if (!(value instanceof Date) || !Number.isFinite(value.getTime())) {\n throw new TypeError(`[Sixb] AI limit ${label} must be a valid Date.`)\n }\n return new Date(value)\n}\n"
|
|
8
|
+
],
|
|
9
|
+
"mappings": ";;AAaO,MAAM,4BAA4B,MAAM;AAAA,EAIlC;AAAA,EAHF,OAAO;AAAA,EAEhB,WAAW,CACA,MACT,SACA;AAAA,IACA,MAAM,OAAO;AAAA,IAHJ;AAAA;AAKb;;;ACnBO,SAAS,oBAAoB,CAAC,IAAyB;AAAA,EAC5D,IAAI,EAAE,cAAc,SAAS,CAAC,OAAO,SAAS,GAAG,QAAQ,CAAC,GAAG;AAAA,IAC3D,MAAM,IAAI,UAAU,mDAAmD;AAAA,EACzE;AAAA,EACA,MAAM,QAAQ,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6
|
isPlainRecord
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-n6jxh8sw.js";
|
|
8
8
|
|
|
9
9
|
// src/storage/action-runs/types.ts
|
|
10
10
|
var ACTION_RUN_PHASES = [
|
|
@@ -5,13 +5,13 @@ import {
|
|
|
5
5
|
} from "./chunk-5sz8ta9r.js";
|
|
6
6
|
import {
|
|
7
7
|
isDatasetDefinition
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-tn7xcs2n.js";
|
|
9
9
|
import {
|
|
10
10
|
ConnectorError,
|
|
11
11
|
SyncValidationError,
|
|
12
12
|
createConnectorCodedError,
|
|
13
13
|
getConnectorExecutionSourceResolver
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-ha58tjtt.js";
|
|
15
15
|
import {
|
|
16
16
|
isConnectorDefinition,
|
|
17
17
|
isOAuthConnectorAdapter
|