@sixb/core 0.1.25 → 0.1.26
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 +35 -35
- package/dist/agents/attachment-keys.d.ts +25 -0
- package/dist/agents/attachment-keys.d.ts.map +1 -0
- package/dist/agents/cancel.d.ts +12 -0
- package/dist/agents/cancel.d.ts.map +1 -1
- package/dist/agents/children.d.ts.map +1 -1
- package/dist/agents/dispatch.d.ts +1 -9
- package/dist/agents/dispatch.d.ts.map +1 -1
- package/dist/agents/execution.d.ts +5 -0
- package/dist/agents/execution.d.ts.map +1 -1
- package/dist/agents/index.d.ts +31 -6
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +154 -66
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/model-loop.d.ts +3 -5
- package/dist/agents/model-loop.d.ts.map +1 -1
- package/dist/agents/model-routing.d.ts +4 -1
- package/dist/agents/model-routing.d.ts.map +1 -1
- package/dist/agents/request.d.ts +9 -1
- package/dist/agents/request.d.ts.map +1 -1
- package/dist/agents/run-after-finish.d.ts +11 -0
- package/dist/agents/run-after-finish.d.ts.map +1 -0
- package/dist/agents/run-artifacts.d.ts +56 -0
- package/dist/agents/run-artifacts.d.ts.map +1 -0
- package/dist/agents/run-events.d.ts +49 -0
- package/dist/agents/run-events.d.ts.map +1 -0
- package/dist/agents/run-fence.d.ts +38 -0
- package/dist/agents/run-fence.d.ts.map +1 -0
- package/dist/agents/run-liveness.d.ts +36 -0
- package/dist/agents/run-liveness.d.ts.map +1 -0
- package/dist/agents/run-plan.d.ts +110 -0
- package/dist/agents/run-plan.d.ts.map +1 -0
- package/dist/agents/run-session-children.d.ts +89 -0
- package/dist/agents/run-session-children.d.ts.map +1 -0
- package/dist/agents/run-session-http.d.ts +37 -0
- package/dist/agents/run-session-http.d.ts.map +1 -0
- package/dist/agents/run-session-serve.d.ts +24 -0
- package/dist/agents/run-session-serve.d.ts.map +1 -0
- package/dist/agents/run-session-wire.d.ts +31 -0
- package/dist/agents/run-session-wire.d.ts.map +1 -0
- package/dist/agents/run-session.d.ts +239 -0
- package/dist/agents/run-session.d.ts.map +1 -0
- package/dist/agents/run-token.d.ts +40 -0
- package/dist/agents/run-token.d.ts.map +1 -0
- package/dist/agents/run-tools.d.ts +68 -0
- package/dist/agents/run-tools.d.ts.map +1 -0
- package/dist/agents/run-turn.d.ts +59 -0
- package/dist/agents/run-turn.d.ts.map +1 -0
- package/dist/agents/streams/index.js +1 -1
- package/dist/agents/streams/internal.d.ts +1 -1
- package/dist/agents/streams/internal.d.ts.map +1 -1
- package/dist/agents/streams/internal.js +2 -4
- package/dist/agents/streams/internal.js.map +1 -1
- package/dist/agents/streams/protocol.d.ts +1 -96
- package/dist/agents/streams/protocol.d.ts.map +1 -1
- package/dist/agents/subagent-runs.d.ts +7 -1
- package/dist/agents/subagent-runs.d.ts.map +1 -1
- package/dist/agents/tool-files.d.ts +34 -0
- package/dist/agents/tool-files.d.ts.map +1 -0
- package/dist/agents/workflow-node-session.d.ts +99 -0
- package/dist/agents/workflow-node-session.d.ts.map +1 -0
- package/dist/artifacts/frames/index.js +1 -1
- package/dist/artifacts/frames/index.js.map +1 -1
- package/dist/artifacts/index.js.map +1 -1
- package/dist/artifacts/publish/index.d.ts +1 -1
- package/dist/artifacts/publish/index.d.ts.map +1 -1
- package/dist/artifacts/publish/index.js +19 -19
- package/dist/auth/index.js +8 -8
- package/dist/authorization/index.js +4 -4
- package/dist/bootstrap/index.js +45 -43
- package/dist/bootstrap/index.js.map +2 -2
- package/dist/{chunk-2fn60nvs.js → chunk-06sg8s4z.js} +2 -2
- package/dist/{chunk-2fn60nvs.js.map → chunk-06sg8s4z.js.map} +1 -1
- package/dist/chunk-07kkp2e1.js.map +1 -1
- package/dist/{chunk-9ntbsnke.js → chunk-0bc3w0zq.js} +7 -7
- package/dist/{chunk-9ntbsnke.js.map → chunk-0bc3w0zq.js.map} +2 -2
- package/dist/{chunk-d2m879s4.js → chunk-0kk2wt0h.js} +27 -27
- package/dist/chunk-0kk2wt0h.js.map +12 -0
- package/dist/chunk-16a9dmfy.js.map +1 -1
- package/dist/chunk-18sk89cg.js.map +2 -2
- package/dist/{chunk-3qms4nax.js → chunk-1vg43g9q.js} +20 -20
- package/dist/{chunk-3qms4nax.js.map → chunk-1vg43g9q.js.map} +4 -4
- package/dist/{chunk-hqsp2sx4.js → chunk-1xvqgg88.js} +31 -33
- package/dist/{chunk-hqsp2sx4.js.map → chunk-1xvqgg88.js.map} +6 -6
- package/dist/chunk-2adz0h75.js.map +1 -1
- package/dist/{chunk-fm62y49k.js → chunk-2pk5hjj9.js} +5 -3
- package/dist/{chunk-fm62y49k.js.map → chunk-2pk5hjj9.js.map} +5 -5
- package/dist/{chunk-vrf90dkv.js → chunk-2vjnyz1s.js} +1 -1
- package/dist/{chunk-vrf90dkv.js.map → chunk-2vjnyz1s.js.map} +1 -1
- package/dist/{chunk-4f3ydv7t.js → chunk-315qye3g.js} +1 -1
- package/dist/{chunk-4f3ydv7t.js.map → chunk-315qye3g.js.map} +1 -1
- package/dist/{chunk-rap5w0x0.js → chunk-31khg3g0.js} +1 -1
- package/dist/{chunk-rap5w0x0.js.map → chunk-31khg3g0.js.map} +1 -1
- package/dist/chunk-45ngkxkp.js.map +1 -1
- package/dist/chunk-48jezz3j.js.map +1 -1
- package/dist/{chunk-vr3j63jq.js → chunk-4jq2bg8t.js} +78 -78
- package/dist/{chunk-vr3j63jq.js.map → chunk-4jq2bg8t.js.map} +4 -4
- package/dist/chunk-4ymrcdbm.js.map +1 -1
- package/dist/chunk-58geavnf.js.map +1 -1
- package/dist/{chunk-6y0mkhex.js → chunk-59kf345w.js} +2 -2
- package/dist/{chunk-6y0mkhex.js.map → chunk-59kf345w.js.map} +1 -1
- package/dist/{chunk-3p93tb91.js → chunk-6qn7nmd3.js} +102 -102
- package/dist/{chunk-3p93tb91.js.map → chunk-6qn7nmd3.js.map} +4 -4
- package/dist/chunk-73j0v4qv.js +355 -0
- package/dist/chunk-73j0v4qv.js.map +13 -0
- package/dist/{chunk-2gjj5dx3.js → chunk-78ymxrn0.js} +1 -1
- package/dist/{chunk-6bkbyer5.js → chunk-7ex2p3zp.js} +3 -3
- package/dist/{chunk-6bkbyer5.js.map → chunk-7ex2p3zp.js.map} +1 -1
- package/dist/{chunk-5tfev0fv.js → chunk-7hf6tkgs.js} +167 -167
- package/dist/{chunk-5tfev0fv.js.map → chunk-7hf6tkgs.js.map} +4 -4
- package/dist/{chunk-8z4726jz.js → chunk-7wn5z7mq.js} +10 -10
- package/dist/{chunk-8z4726jz.js.map → chunk-7wn5z7mq.js.map} +2 -2
- package/dist/{chunk-6n69k945.js → chunk-8mb7mt8n.js} +2 -2
- package/dist/chunk-8ncg20rd.js.map +1 -1
- package/dist/{chunk-68wghpdf.js → chunk-8v5a54qz.js} +50 -11
- package/dist/{chunk-68wghpdf.js.map → chunk-8v5a54qz.js.map} +3 -3
- package/dist/{chunk-gqm0b7vd.js → chunk-8v6xzwgr.js} +92 -76
- package/dist/{chunk-gqm0b7vd.js.map → chunk-8v6xzwgr.js.map} +6 -6
- package/dist/{chunk-m36fw8ft.js → chunk-8wsjr52f.js} +1 -1
- package/dist/{chunk-vd1rk42q.js → chunk-8xnz9vvp.js} +4 -4
- package/dist/{chunk-vd1rk42q.js.map → chunk-8xnz9vvp.js.map} +1 -1
- package/dist/chunk-9mab3dvg.js.map +1 -1
- package/dist/chunk-9tc8dxmn.js.map +1 -1
- package/dist/chunk-9x8dybsb.js.map +2 -2
- package/dist/chunk-a3faa34j.js.map +1 -1
- package/dist/{chunk-62a63pr6.js → chunk-axb4ss9a.js} +7 -7
- package/dist/{chunk-62a63pr6.js.map → chunk-axb4ss9a.js.map} +2 -2
- package/dist/{chunk-z3ryd53f.js → chunk-b6ghvap7.js} +35 -11
- package/dist/{chunk-z3ryd53f.js.map → chunk-b6ghvap7.js.map} +3 -3
- package/dist/{chunk-sqfvnvqj.js → chunk-c14ap3s9.js} +2 -2
- package/dist/{chunk-sqfvnvqj.js.map → chunk-c14ap3s9.js.map} +1 -1
- package/dist/{chunk-661ezhks.js → chunk-cbcgs9f7.js} +87 -8
- package/dist/chunk-cbcgs9f7.js.map +11 -0
- package/dist/chunk-cwdzcv37.js.map +1 -1
- package/dist/{chunk-bab05bhg.js → chunk-dgtd0836.js} +1 -1
- package/dist/{chunk-1j6j0rht.js → chunk-e24fvw8g.js} +1 -1
- package/dist/{chunk-1j6j0rht.js.map → chunk-e24fvw8g.js.map} +1 -1
- package/dist/chunk-e5wf5vz0.js.map +1 -1
- package/dist/chunk-eptrvnby.js.map +1 -1
- package/dist/chunk-ey1nk510.js.map +1 -1
- package/dist/{chunk-j936th07.js → chunk-fakrpfy3.js} +58 -58
- package/dist/{chunk-j936th07.js.map → chunk-fakrpfy3.js.map} +5 -5
- package/dist/chunk-fb3feg1e.js.map +1 -1
- package/dist/chunk-ff5xkv0p.js.map +1 -1
- package/dist/chunk-fntqb7qy.js.map +1 -1
- package/dist/{chunk-7ny9mjgm.js → chunk-ft3w5ahs.js} +1 -1
- package/dist/chunk-g663fahq.js.map +1 -1
- package/dist/{chunk-cdk3egjj.js → chunk-h1na2cxc.js} +1 -1
- package/dist/{chunk-cdk3egjj.js.map → chunk-h1na2cxc.js.map} +1 -1
- package/dist/chunk-hn2r7z41.js.map +1 -1
- package/dist/{chunk-24bqx0dx.js → chunk-hn76sanm.js} +1 -1
- package/dist/{chunk-24bqx0dx.js.map → chunk-hn76sanm.js.map} +1 -1
- package/dist/chunk-jmfet9r4.js.map +1 -1
- package/dist/{chunk-bnr4a734.js → chunk-jn3ysaf2.js} +24 -22
- package/dist/{chunk-bnr4a734.js.map → chunk-jn3ysaf2.js.map} +5 -5
- package/dist/{chunk-4y26vs3v.js → chunk-jspskey0.js} +16 -3
- package/dist/chunk-jspskey0.js.map +10 -0
- package/dist/{chunk-r6szek0x.js → chunk-jt3r6thp.js} +2 -135
- package/dist/chunk-jt3r6thp.js.map +10 -0
- package/dist/chunk-kfee1h52.js.map +1 -1
- package/dist/{chunk-qx00vjrj.js → chunk-kwfhd1g0.js} +23 -23
- package/dist/{chunk-qx00vjrj.js.map → chunk-kwfhd1g0.js.map} +4 -4
- package/dist/chunk-m427qgq0.js.map +1 -1
- package/dist/chunk-mbsbxarb.js.map +1 -1
- package/dist/{chunk-et017krg.js → chunk-mdxmt0n3.js} +8657 -8704
- package/dist/{chunk-et017krg.js.map → chunk-mdxmt0n3.js.map} +37 -37
- package/dist/chunk-mmagke4x.js.map +1 -1
- package/dist/{chunk-2x19q6k6.js → chunk-mqx25wwh.js} +319 -154
- package/dist/chunk-mqx25wwh.js.map +18 -0
- package/dist/chunk-mzx71snp.js.map +1 -1
- package/dist/chunk-n8q5j6y5.js.map +1 -1
- package/dist/chunk-npcr0228.js.map +1 -1
- package/dist/{chunk-m2nevja0.js → chunk-phm3c7b9.js} +1 -1
- package/dist/{chunk-m2nevja0.js.map → chunk-phm3c7b9.js.map} +1 -1
- package/dist/chunk-qf954wje.js.map +1 -1
- package/dist/{chunk-65pyhyas.js → chunk-qgvbxfqv.js} +6 -8
- package/dist/{chunk-65pyhyas.js.map → chunk-qgvbxfqv.js.map} +2 -2
- package/dist/{chunk-hk38wahh.js → chunk-qst145py.js} +4 -4
- package/dist/{chunk-hk38wahh.js.map → chunk-qst145py.js.map} +1 -1
- package/dist/{chunk-c844dkwd.js → chunk-qtzftvxa.js} +4 -5
- package/dist/{chunk-c844dkwd.js.map → chunk-qtzftvxa.js.map} +2 -2
- package/dist/chunk-ratkv4zc.js +3 -0
- package/dist/chunk-ratkv4zc.js.map +9 -0
- package/dist/{chunk-nzapm6p0.js → chunk-s3we74h8.js} +1 -2
- package/dist/chunk-s3we74h8.js.map +12 -0
- package/dist/{chunk-0xmt5p5y.js → chunk-t3brw0wd.js} +1 -2
- package/dist/{chunk-0xmt5p5y.js.map → chunk-t3brw0wd.js.map} +2 -2
- package/dist/chunk-t5608tkq.js.map +1 -1
- package/dist/chunk-tdxfsg1c.js.map +1 -1
- package/dist/{chunk-1t6k1avb.js → chunk-tnhqtfea.js} +1 -1
- package/dist/chunk-vhbw5sqm.js.map +1 -1
- package/dist/{chunk-rp9wwk7b.js → chunk-vx4e4zv4.js} +30 -30
- package/dist/{chunk-rp9wwk7b.js.map → chunk-vx4e4zv4.js.map} +4 -4
- package/dist/chunk-waqk73p1.js.map +1 -1
- package/dist/chunk-x0v3jd47.js.map +1 -1
- package/dist/{chunk-yecwnwpq.js → chunk-xm8qgbqm.js} +58 -29
- package/dist/{chunk-yecwnwpq.js.map → chunk-xm8qgbqm.js.map} +7 -7
- package/dist/{chunk-97wr6p2g.js → chunk-y7j6x4h0.js} +8 -8
- package/dist/{chunk-97wr6p2g.js.map → chunk-y7j6x4h0.js.map} +4 -4
- package/dist/{chunk-xe0732g0.js → chunk-yavhtnac.js} +12 -8
- package/dist/{chunk-xe0732g0.js.map → chunk-yavhtnac.js.map} +4 -4
- package/dist/chunk-yd00vzqr.js +3394 -0
- package/dist/chunk-yd00vzqr.js.map +37 -0
- package/dist/{chunk-n9w3n38q.js → chunk-ye5c8016.js} +54 -8
- package/dist/chunk-ye5c8016.js.map +23 -0
- package/dist/chunk-yw9pyg66.js.map +1 -1
- package/dist/{chunk-nydf3dbe.js → chunk-z9mg7wya.js} +37 -20
- package/dist/chunk-z9mg7wya.js.map +13 -0
- package/dist/chunk-zbc929zg.js.map +1 -1
- package/dist/chunk-zhh1jd89.js +290 -0
- package/dist/chunk-zhh1jd89.js.map +10 -0
- package/dist/connectors/connections/authorizations.d.ts +2 -2
- package/dist/connectors/connections/authorizations.d.ts.map +1 -1
- package/dist/connectors/connections/service.d.ts.map +1 -1
- package/dist/connectors/connections/tokens.d.ts +2 -2
- package/dist/connectors/connections/tokens.d.ts.map +1 -1
- package/dist/connectors/connections/validation.d.ts +5 -0
- package/dist/connectors/connections/validation.d.ts.map +1 -1
- package/dist/connectors/types.d.ts +9 -2
- package/dist/connectors/types.d.ts.map +1 -1
- package/dist/datasets/write.js +3 -3
- package/dist/deploy/internal.js +2 -5
- package/dist/deploy/internal.js.map +3 -3
- package/dist/deploy/types.d.ts +0 -2
- package/dist/deploy/types.d.ts.map +1 -1
- package/dist/execution/agent.d.ts +2 -2
- package/dist/execution/agent.d.ts.map +1 -1
- package/dist/execution/agent.js +38 -38
- package/dist/execution/agent.js.map +1 -1
- package/dist/execution/primitive.js +35 -35
- package/dist/execution/request.js +37 -37
- package/dist/execution/request.js.map +2 -2
- package/dist/http/api-routes.d.ts +12 -11
- package/dist/http/api-routes.d.ts.map +1 -1
- package/dist/http/index.js +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +53 -51
- package/dist/index.js.map +1 -1
- package/dist/lake-storage/index.js +3 -3
- package/dist/logging/internal.js +1 -1
- package/dist/materializer/index.js +17 -17
- package/dist/models/execution/errors.d.ts +5 -0
- package/dist/models/execution/errors.d.ts.map +1 -1
- package/dist/models/execution/index.d.ts +2 -1
- package/dist/models/execution/index.d.ts.map +1 -1
- package/dist/models/execution/index.js +55 -50
- package/dist/models/execution/index.js.map +1 -1
- package/dist/models/execution/model-call-recorder.d.ts +7 -2
- package/dist/models/execution/model-call-recorder.d.ts.map +1 -1
- package/dist/models/execution.d.ts.map +1 -1
- package/dist/models/language-call.d.ts +51 -0
- package/dist/models/language-call.d.ts.map +1 -0
- package/dist/objects/index.js +35 -35
- package/dist/objects/query/index.js +17 -17
- package/dist/ontology/docs-markdown.d.ts.map +1 -1
- package/dist/ontology/index.d.ts +1 -1
- package/dist/ontology/index.d.ts.map +1 -1
- package/dist/ontology/index.js +4 -4
- package/dist/ontology/internal.js +8 -275
- package/dist/ontology/internal.js.map +3 -4
- package/dist/ontology/user-ref.d.ts +21 -3
- package/dist/ontology/user-ref.d.ts.map +1 -1
- package/dist/pipelines/index.js +19 -19
- package/dist/projections/builders.d.ts +13 -2
- package/dist/projections/builders.d.ts.map +1 -1
- package/dist/projections/index.d.ts +1 -1
- package/dist/projections/index.d.ts.map +1 -1
- package/dist/projections/internal.js +17 -17
- package/dist/projections/types.d.ts +7 -0
- package/dist/projections/types.d.ts.map +1 -1
- package/dist/projections/validation.d.ts +2 -0
- package/dist/projections/validation.d.ts.map +1 -1
- package/dist/query.js +2 -2
- package/dist/queues/in-memory.d.ts +0 -1
- package/dist/queues/in-memory.d.ts.map +1 -1
- package/dist/queues/index.d.ts +1 -1
- package/dist/queues/index.d.ts.map +1 -1
- package/dist/queues/index.js +1 -1
- package/dist/queues/types.d.ts +0 -8
- package/dist/queues/types.d.ts.map +1 -1
- package/dist/runtime/internal.js +23 -23
- package/dist/runtime/internal.js.map +1 -1
- package/dist/sandboxes/configuration.d.ts +4 -6
- package/dist/sandboxes/configuration.d.ts.map +1 -1
- package/dist/sandboxes/environment.d.ts.map +1 -1
- package/dist/sandboxes/exec.d.ts +5 -3
- package/dist/sandboxes/exec.d.ts.map +1 -1
- package/dist/sandboxes/guest-credentials.d.ts +61 -0
- package/dist/sandboxes/guest-credentials.d.ts.map +1 -0
- package/dist/sandboxes/index.d.ts +2 -0
- package/dist/sandboxes/index.d.ts.map +1 -1
- package/dist/sandboxes/index.js +23 -9
- package/dist/sandboxes/index.js.map +1 -1
- package/dist/sandboxes/sandbox.d.ts +18 -4
- package/dist/sandboxes/sandbox.d.ts.map +1 -1
- package/dist/security/internal.js +1 -1
- package/dist/security/internal.js.map +1 -1
- package/dist/shares/internal.js +17 -17
- package/dist/shares/internal.js.map +1 -1
- package/dist/storage/agents/in-memory.d.ts +3 -1
- 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 +6 -0
- package/dist/storage/agents/provider.d.ts.map +1 -1
- package/dist/storage/agents/provider.js +8 -2
- package/dist/storage/agents/provider.js.map +1 -1
- package/dist/storage/agents/types.d.ts +63 -7
- package/dist/storage/agents/types.d.ts.map +1 -1
- package/dist/storage/ai-cost/provider.js +2 -2
- package/dist/storage/connector-connections/provider.js.map +1 -1
- package/dist/storage/file-upload-sessions/provider.js +9 -9
- package/dist/storage/index.d.ts +1 -1
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +15 -15
- package/dist/storage/ontology/provider.js +1 -1
- package/dist/storage/share-grants/provider.js +3 -3
- package/dist/storage/types.d.ts +1 -1
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/storage/workflow-runs/provider.js +9 -9
- package/dist/syncs/index.js +20 -20
- package/dist/testing/agent-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 +677 -352
- package/dist/testing/index.js.map +9 -7
- package/dist/testing/queues-contract.d.ts.map +1 -1
- package/dist/testing/sandbox-credentials-contract.d.ts +27 -0
- package/dist/testing/sandbox-credentials-contract.d.ts.map +1 -0
- package/dist/testing/sandboxes-contract.d.ts.map +1 -1
- package/dist/testing/users.d.ts +20 -0
- package/dist/testing/users.d.ts.map +1 -0
- package/dist/users/execution.d.ts +6 -2
- package/dist/users/execution.d.ts.map +1 -1
- package/dist/users/index.d.ts +1 -1
- package/dist/users/index.d.ts.map +1 -1
- package/dist/webhooks/internal.js +17 -17
- package/dist/webhooks/internal.js.map +1 -1
- package/dist/workers/index.js.map +1 -1
- package/dist/workflows/index.js +41 -39
- package/dist/workflows/index.js.map +1 -1
- package/package.json +1 -1
- package/src/agents/README.md +136 -0
- package/src/agents/attachment-keys.ts +83 -0
- package/src/agents/cancel.ts +16 -1
- package/src/agents/children.ts +5 -3
- package/src/agents/dispatch.ts +6 -58
- package/src/agents/execution.ts +18 -0
- package/src/agents/index.ts +127 -21
- package/src/agents/model-loop.ts +23 -73
- package/src/agents/model-routing.ts +7 -2
- package/src/agents/request.ts +69 -20
- package/src/agents/run-after-finish.ts +133 -0
- package/src/agents/run-artifacts.ts +257 -0
- package/src/agents/run-events.ts +302 -0
- package/src/agents/run-fence.ts +71 -0
- package/src/agents/run-liveness.ts +122 -0
- package/src/agents/run-plan.ts +316 -0
- package/src/agents/run-session-children.ts +303 -0
- package/src/agents/run-session-http.ts +397 -0
- package/src/agents/run-session-serve.ts +479 -0
- package/src/agents/run-session-wire.ts +189 -0
- package/src/agents/run-session.ts +802 -0
- package/src/agents/run-token.ts +124 -0
- package/src/agents/run-tools.ts +180 -0
- package/src/agents/run-turn.ts +265 -0
- package/src/agents/streams/internal.ts +0 -1
- package/src/agents/streams/protocol.ts +0 -292
- package/src/agents/subagent-runs.ts +19 -1
- package/src/agents/tool-files.ts +225 -0
- package/src/agents/workflow-node-session.ts +387 -0
- package/src/artifacts/publish/index.ts +1 -0
- package/src/connectors/connections/authorizations.ts +3 -2
- package/src/connectors/connections/service.ts +5 -1
- package/src/connectors/connections/tokens.ts +41 -5
- package/src/connectors/connections/validation.ts +21 -0
- package/src/connectors/types.ts +12 -2
- package/src/deploy/types.ts +0 -2
- package/src/deploy/validation.ts +1 -4
- package/src/execution/agent.ts +2 -2
- package/src/execution/authorized-object-reader.ts +28 -1
- package/src/http/api-routes.ts +114 -27
- package/src/index.ts +3 -1
- package/src/models/execution/README.md +15 -1
- package/src/models/execution/errors.ts +14 -0
- package/src/models/execution/index.ts +2 -1
- package/src/models/execution/model-call-recorder.ts +12 -10
- package/src/models/execution.ts +9 -11
- package/src/models/language-call.ts +247 -0
- package/src/ontology/docs-markdown.ts +14 -0
- package/src/ontology/index.ts +1 -1
- package/src/ontology/user-ref.ts +40 -6
- package/src/projections/builders.ts +48 -4
- package/src/projections/index.ts +1 -0
- package/src/projections/registry.ts +1 -0
- package/src/projections/revision.ts +10 -0
- package/src/projections/types.ts +8 -0
- package/src/projections/validation.ts +52 -6
- package/src/queues/in-memory.ts +0 -5
- package/src/queues/index.ts +0 -2
- package/src/queues/types.ts +0 -13
- package/src/runtime/host.ts +1 -1
- package/src/sandboxes/README.md +17 -6
- package/src/sandboxes/configuration.ts +7 -9
- package/src/sandboxes/environment.ts +1 -0
- package/src/sandboxes/exec.ts +17 -9
- package/src/sandboxes/guest-credentials.ts +262 -0
- package/src/sandboxes/index.ts +14 -0
- package/src/sandboxes/sandbox.ts +19 -4
- package/src/storage/agents/in-memory.ts +53 -0
- package/src/storage/agents/index.ts +2 -0
- package/src/storage/agents/provider.ts +56 -11
- package/src/storage/agents/types.ts +59 -7
- package/src/storage/index.ts +2 -0
- package/src/storage/types.ts +1 -0
- package/src/testing/agent-storage-contract.ts +175 -2
- package/src/testing/ai-model-call-groups-contract.ts +0 -1
- package/src/testing/index.ts +5 -0
- package/src/testing/queues-contract.ts +0 -16
- package/src/testing/sandbox-credentials-contract.ts +284 -0
- package/src/testing/sandboxes-contract.ts +21 -0
- package/src/testing/users.ts +39 -0
- package/src/users/execution.ts +33 -7
- package/src/users/index.ts +7 -1
- package/dist/agents/api-gateway.d.ts +0 -26
- package/dist/agents/api-gateway.d.ts.map +0 -1
- package/dist/chunk-2x19q6k6.js.map +0 -17
- package/dist/chunk-4y26vs3v.js.map +0 -10
- package/dist/chunk-661ezhks.js.map +0 -11
- package/dist/chunk-d2m879s4.js.map +0 -12
- package/dist/chunk-n9w3n38q.js.map +0 -23
- package/dist/chunk-nydf3dbe.js.map +0 -13
- package/dist/chunk-nzapm6p0.js.map +0 -12
- package/dist/chunk-r6szek0x.js.map +0 -10
- package/dist/chunk-vabga7fk.js +0 -176
- package/dist/chunk-vabga7fk.js.map +0 -12
- package/dist/chunk-vpgwq5nf.js +0 -810
- package/dist/chunk-vpgwq5nf.js.map +0 -21
- package/src/agents/api-gateway.ts +0 -68
- /package/dist/{chunk-2gjj5dx3.js.map → chunk-78ymxrn0.js.map} +0 -0
- /package/dist/{chunk-6n69k945.js.map → chunk-8mb7mt8n.js.map} +0 -0
- /package/dist/{chunk-m36fw8ft.js.map → chunk-8wsjr52f.js.map} +0 -0
- /package/dist/{chunk-bab05bhg.js.map → chunk-dgtd0836.js.map} +0 -0
- /package/dist/{chunk-7ny9mjgm.js.map → chunk-ft3w5ahs.js.map} +0 -0
- /package/dist/{chunk-1t6k1avb.js.map → chunk-tnhqtfea.js.map} +0 -0
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"/**\n * Base error for pipeline-run storage operations.\n */\nexport class PipelineRunError extends Error {\n readonly name = \"PipelineRunError\"\n}\n",
|
|
6
6
|
"import type { ExecutionStorage } from \"../executions\"\nimport { findPrimitiveRunExecution } from \"../executions/run-link\"\nimport { PipelineRunError } from \"./errors\"\n\n/** Validate the semantic link between a durable Pipeline run and its immutable execution. */\nexport async function assertPipelineRunExecution(input: {\n readonly executions: ExecutionStorage\n readonly projectId: string\n readonly executionId: string\n readonly runId: string\n readonly pipelineId: string\n}): Promise<void> {\n const execution = await findPrimitiveRunExecution({\n executions: input.executions,\n projectId: input.projectId,\n executionId: input.executionId,\n primitive: { kind: \"pipeline\", id: input.pipelineId, runId: input.runId },\n sourceTypes: [\"execution\", \"schedule\", \"event\"],\n })\n if (!execution) {\n throw new PipelineRunError(\n `[Sixb] Execution '${input.executionId}' does not authorize Pipeline run '${input.runId}'.`\n )\n }\n}\n"
|
|
7
7
|
],
|
|
8
|
-
"mappings": ";;;;;;AAGO,MAAM,0BAAyB,MAAM;AAAA,EACjC,OAAO;AAClB;;;
|
|
8
|
+
"mappings": ";;;;;;AAGO,MAAM,0BAAyB,MAAM;AAAA,EACjC,OAAO;AAClB;;;ACAO,eAAe,2BAA0B,CAAC,OAM/B;AAAA,EAChB,MAAM,YAAY,MAAM,0BAA0B;AAAA,IAChD,YAAY,MAAM;AAAA,IAClB,WAAW,MAAM;AAAA,IACjB,aAAa,MAAM;AAAA,IACnB,WAAW,EAAE,MAAM,YAAY,IAAI,MAAM,YAAY,OAAO,MAAM,MAAM;AAAA,IACxE,aAAa,CAAC,aAAa,YAAY,OAAO;AAAA,EAChD,CAAC;AAAA,EACD,IAAI,CAAC,WAAW;AAAA,IACd,MAAM,IAAI,kBACR,qBAAqB,MAAM,iDAAiD,MAAM,SACpF;AAAA,EACF;AAAA;",
|
|
9
9
|
"debugId": "541A905468003F0364756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
|
@@ -3,6 +3,10 @@ import {
|
|
|
3
3
|
createSixbError2,
|
|
4
4
|
isSixbError2
|
|
5
5
|
} from "./chunk-zbc929zg.js";
|
|
6
|
+
import {
|
|
7
|
+
normalizeAiModelCallCostRecord2,
|
|
8
|
+
aiModelCallCostMatchesUsage2
|
|
9
|
+
} from "./chunk-t3brw0wd.js";
|
|
6
10
|
import {
|
|
7
11
|
AiLimitStorageError2,
|
|
8
12
|
aiLimitMeterApplies2
|
|
@@ -14,109 +18,78 @@ import {
|
|
|
14
18
|
aiUsageLimitUnavailableError2
|
|
15
19
|
} from "./chunk-dp0cdtj2.js";
|
|
16
20
|
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} from "./chunk-
|
|
21
|
+
estimateModelCall,
|
|
22
|
+
rateModelCall2
|
|
23
|
+
} from "./chunk-tdxfsg1c.js";
|
|
20
24
|
import {
|
|
21
25
|
AiCostStorageError2
|
|
22
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-8v5a54qz.js";
|
|
23
27
|
import {
|
|
24
28
|
AiUsageStorageError2,
|
|
25
29
|
normalizeAiModelCallRecord2
|
|
26
30
|
} from "./chunk-pgrf64hp.js";
|
|
31
|
+
import {
|
|
32
|
+
ModelStreamError2
|
|
33
|
+
} from "./chunk-kyjcwqz6.js";
|
|
27
34
|
import {
|
|
28
35
|
assertJsonObject2
|
|
29
36
|
} from "./chunk-wy0qdqfm.js";
|
|
30
37
|
|
|
31
|
-
// src/models/execution/model-call-
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
// src/models/execution/model-call-admission.ts
|
|
39
|
+
var AI_MODEL_CALL_OUTPUT_TOKEN_ALLOWANCE = 4096;
|
|
40
|
+
function estimateAiModelCallInputTokens(input) {
|
|
41
|
+
if (containsNonTextInput(input.prompt)) {
|
|
42
|
+
return { status: "unavailable", reason: "nonTextInput" };
|
|
43
|
+
}
|
|
44
|
+
let serialized;
|
|
45
|
+
try {
|
|
46
|
+
serialized = JSON.stringify(input);
|
|
47
|
+
} catch {
|
|
48
|
+
return { status: "unavailable", reason: "unserializableInput" };
|
|
49
|
+
}
|
|
50
|
+
if (serialized === undefined) {
|
|
51
|
+
return { status: "unavailable", reason: "unserializableInput" };
|
|
52
|
+
}
|
|
53
|
+
const bytes = new TextEncoder().encode(serialized).byteLength;
|
|
34
54
|
return {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const policies = await input.storage.aiLimits.listPolicies({
|
|
39
|
-
projectId: input.projectId
|
|
40
|
-
});
|
|
41
|
-
applicable = applicableAiLimitPolicies2(policies, subjects).filter((policy) => aiLimitMeterApplies2(policy.limit.meter, admission.modelKind));
|
|
42
|
-
} catch (error) {
|
|
43
|
-
throw limitStorageUnavailable(error);
|
|
44
|
-
}
|
|
45
|
-
if (applicable.length === 0)
|
|
46
|
-
return { reservation: "none" };
|
|
47
|
-
const estimates = reservationEstimates(admission, applicable.some((policy) => policy.limit.meter === "cost.catalogEstimated"));
|
|
48
|
-
if (estimates.length === 0) {
|
|
49
|
-
throw aiUsageLimitUnavailableError2(["missingEstimate"]);
|
|
50
|
-
}
|
|
51
|
-
let result;
|
|
52
|
-
try {
|
|
53
|
-
result = await input.storage.aiLimits.reserveModelCall({
|
|
54
|
-
...reservationIdentity(admission),
|
|
55
|
-
subjects,
|
|
56
|
-
estimates,
|
|
57
|
-
...admission.modelKind === undefined ? {} : { modelKind: admission.modelKind }
|
|
58
|
-
});
|
|
59
|
-
} catch (error) {
|
|
60
|
-
throw limitStorageUnavailable(error);
|
|
61
|
-
}
|
|
62
|
-
switch (result.status) {
|
|
63
|
-
case "reserved":
|
|
64
|
-
return { reservation: "active" };
|
|
65
|
-
case "notRequired":
|
|
66
|
-
return { reservation: "none" };
|
|
67
|
-
case "denied":
|
|
68
|
-
throw aiUsageLimitExceededError2(result.resetAt);
|
|
69
|
-
case "unavailable":
|
|
70
|
-
throw aiUsageLimitUnavailableError2(result.reasons);
|
|
71
|
-
case "terminal":
|
|
72
|
-
throw aiUsageLimitUnavailableError2(["terminalReservationReplay"]);
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
markModelCallUnknown: async (identity) => {
|
|
76
|
-
try {
|
|
77
|
-
await input.storage.aiLimits.markReservationUnknown(identity);
|
|
78
|
-
} catch (error) {
|
|
79
|
-
throw limitStorageUnavailable(error);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
55
|
+
status: "estimated",
|
|
56
|
+
tokens: Math.ceil(bytes / 4),
|
|
57
|
+
method: "utf8BytesDividedByFour"
|
|
82
58
|
};
|
|
83
59
|
}
|
|
84
|
-
function
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if (needsCost) {
|
|
90
|
-
try {
|
|
91
|
-
let money = input.reservationCost;
|
|
92
|
-
if (money == null && input.inputTokens.status === "estimated") {
|
|
93
|
-
money = input.costEstimator?.estimateReservation?.({
|
|
94
|
-
inputTokens: input.inputTokens.tokens,
|
|
95
|
-
outputTokens: input.outputTokenAllowance
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
if (money) {
|
|
99
|
-
estimates.push({ meter: "cost.catalogEstimated", amount: money });
|
|
100
|
-
}
|
|
101
|
-
} catch {
|
|
102
|
-
return estimates;
|
|
103
|
-
}
|
|
60
|
+
function aiModelCallOutputTokenAllowance(maxOutputTokens) {
|
|
61
|
+
if (maxOutputTokens === undefined)
|
|
62
|
+
return AI_MODEL_CALL_OUTPUT_TOKEN_ALLOWANCE;
|
|
63
|
+
if (!Number.isSafeInteger(maxOutputTokens) || maxOutputTokens <= 0) {
|
|
64
|
+
throw new TypeError("[SixbModels] AI model-call maxOutputTokens must be a positive safe integer.");
|
|
104
65
|
}
|
|
105
|
-
return
|
|
66
|
+
return maxOutputTokens;
|
|
106
67
|
}
|
|
107
|
-
function
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
68
|
+
function estimatedAiModelCallTotalTokens(inputTokens, outputTokenAllowance) {
|
|
69
|
+
if (inputTokens.status !== "estimated")
|
|
70
|
+
return;
|
|
71
|
+
const total = inputTokens.tokens + outputTokenAllowance;
|
|
72
|
+
if (!Number.isSafeInteger(total)) {
|
|
73
|
+
throw new TypeError("[SixbModels] AI model-call token estimate exceeds the safe range.");
|
|
74
|
+
}
|
|
75
|
+
return total;
|
|
114
76
|
}
|
|
115
|
-
function
|
|
116
|
-
if (
|
|
117
|
-
return
|
|
77
|
+
function containsNonTextInput(value, seen = new WeakSet) {
|
|
78
|
+
if (value === null || typeof value !== "object")
|
|
79
|
+
return false;
|
|
80
|
+
if (value instanceof URL || value instanceof ArrayBuffer || ArrayBuffer.isView(value) || typeof Blob !== "undefined" && value instanceof Blob) {
|
|
81
|
+
return true;
|
|
118
82
|
}
|
|
119
|
-
|
|
83
|
+
if (seen.has(value))
|
|
84
|
+
return false;
|
|
85
|
+
seen.add(value);
|
|
86
|
+
if (!Array.isArray(value)) {
|
|
87
|
+
const type = Reflect.get(value, "type");
|
|
88
|
+
if (type === "image" || type === "file" || type === "reasoning-file" || type === "custom" || type === "provider-state") {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return Object.values(value).some((entry) => containsNonTextInput(entry, seen));
|
|
120
93
|
}
|
|
121
94
|
|
|
122
95
|
// src/models/execution/errors.ts
|
|
@@ -132,6 +105,167 @@ class ModelUsageRecordingError2 extends Error {
|
|
|
132
105
|
this.recoveryScheduled = recoveryScheduled;
|
|
133
106
|
}
|
|
134
107
|
}
|
|
108
|
+
function isModelCallAccountingFailure2(error) {
|
|
109
|
+
return error instanceof ModelUsageRecordingError2 || isSixbError2(error) && (error.code === "ai.usage_limit_exceeded" || error.code === "ai.usage_limit_unavailable");
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// src/models/language-call.ts
|
|
113
|
+
class LanguageModelCallMeter {
|
|
114
|
+
usage = {};
|
|
115
|
+
responseId;
|
|
116
|
+
providerIds;
|
|
117
|
+
responseModelId;
|
|
118
|
+
reportedCost;
|
|
119
|
+
route;
|
|
120
|
+
settled = false;
|
|
121
|
+
get finished() {
|
|
122
|
+
return this.settled;
|
|
123
|
+
}
|
|
124
|
+
accept(event) {
|
|
125
|
+
if (event.type === "response-metadata") {
|
|
126
|
+
this.responseId = event.id ?? this.responseId;
|
|
127
|
+
if (event.providerIds)
|
|
128
|
+
this.providerIds = { ...this.providerIds, ...event.providerIds };
|
|
129
|
+
this.responseModelId = event.modelId ?? this.responseModelId;
|
|
130
|
+
} else if (event.type === "finish") {
|
|
131
|
+
this.settled = true;
|
|
132
|
+
this.usage = event.usage;
|
|
133
|
+
this.reportedCost = event.reportedCost;
|
|
134
|
+
this.route = event.route;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
facts() {
|
|
138
|
+
return {
|
|
139
|
+
usage: this.usage,
|
|
140
|
+
...this.responseId === undefined ? {} : { responseId: this.responseId },
|
|
141
|
+
...this.providerIds === undefined ? {} : { providerIds: this.providerIds },
|
|
142
|
+
...this.responseModelId === undefined ? {} : { responseModelId: this.responseModelId },
|
|
143
|
+
...this.reportedCost === undefined ? {} : { reportedCost: this.reportedCost },
|
|
144
|
+
...this.route === undefined ? {} : { route: this.route }
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
end(call) {
|
|
148
|
+
const facts = this.facts();
|
|
149
|
+
const estimate = this.settled ? estimateModelCall(call.model, facts) : { status: "unpriceable", reason: "missing-usage" };
|
|
150
|
+
const cost = facts.reportedCost ? rateModelCall2({ usage: facts.usage, reported: facts.reportedCost }) : estimate;
|
|
151
|
+
return {
|
|
152
|
+
callId: call.callId,
|
|
153
|
+
modelKind: "language",
|
|
154
|
+
providerId: call.model.providerId,
|
|
155
|
+
modelId: call.model.modelId,
|
|
156
|
+
responseId: facts.responseId ?? `${call.callId}:response`,
|
|
157
|
+
providerIds: facts.providerIds,
|
|
158
|
+
responseModelId: facts.responseModelId,
|
|
159
|
+
usage: facts.usage,
|
|
160
|
+
cost,
|
|
161
|
+
...facts.reportedCost === undefined ? {} : { estimate },
|
|
162
|
+
...call.requestedReasoning === undefined ? {} : { requestedReasoning: call.requestedReasoning },
|
|
163
|
+
...facts.route === undefined ? {} : { route: facts.route }
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
var MODEL_CALL_IDLE_MS = 10 * 60000;
|
|
168
|
+
function reportModelCalls2(model, onEnd) {
|
|
169
|
+
const { providerId, modelId, definition, costEstimator, rateCard } = model;
|
|
170
|
+
const { defaultReasoning, maxOutputTokens } = model;
|
|
171
|
+
return {
|
|
172
|
+
providerId,
|
|
173
|
+
modelId,
|
|
174
|
+
definition,
|
|
175
|
+
...costEstimator === undefined ? {} : { costEstimator },
|
|
176
|
+
...rateCard === undefined ? {} : { rateCard },
|
|
177
|
+
...defaultReasoning === undefined ? {} : { defaultReasoning },
|
|
178
|
+
...maxOutputTokens === undefined ? {} : { maxOutputTokens },
|
|
179
|
+
...model.validateResponseFormat === undefined ? {} : { validateResponseFormat: model.validateResponseFormat.bind(model) },
|
|
180
|
+
stream: async (request) => {
|
|
181
|
+
const stop = new AbortController;
|
|
182
|
+
const opening = model.stream({
|
|
183
|
+
...request,
|
|
184
|
+
signal: AbortSignal.any([request.signal, stop.signal])
|
|
185
|
+
});
|
|
186
|
+
const opened = await withinIdle(opening, stop, (late) => closeEvents(late.events));
|
|
187
|
+
return { ...opened, events: reportedEvents(model, request, opened, stop, onEnd) };
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
function reportedEvents(model, request, stream, stop, onEnd) {
|
|
192
|
+
const meter = new LanguageModelCallMeter;
|
|
193
|
+
let reported;
|
|
194
|
+
const report = () => {
|
|
195
|
+
reported ??= (async () => onEnd(meter.end({
|
|
196
|
+
model,
|
|
197
|
+
callId: request.callId,
|
|
198
|
+
...request.reasoning === undefined ? {} : { requestedReasoning: request.reasoning }
|
|
199
|
+
})))();
|
|
200
|
+
return reported;
|
|
201
|
+
};
|
|
202
|
+
let source;
|
|
203
|
+
let done = false;
|
|
204
|
+
const events = {
|
|
205
|
+
async next() {
|
|
206
|
+
if (done)
|
|
207
|
+
return { done: true, value: undefined };
|
|
208
|
+
source ??= stream.events[Symbol.asyncIterator]();
|
|
209
|
+
let result;
|
|
210
|
+
try {
|
|
211
|
+
result = await withinIdle(source.next(), stop);
|
|
212
|
+
} catch (error) {
|
|
213
|
+
done = true;
|
|
214
|
+
if (stop.signal.aborted)
|
|
215
|
+
closeEvents(source);
|
|
216
|
+
await report();
|
|
217
|
+
throw error;
|
|
218
|
+
}
|
|
219
|
+
if (result.done) {
|
|
220
|
+
done = true;
|
|
221
|
+
await report();
|
|
222
|
+
return result;
|
|
223
|
+
}
|
|
224
|
+
meter.accept(result.value);
|
|
225
|
+
if (result.value.type === "finish")
|
|
226
|
+
await report();
|
|
227
|
+
return result;
|
|
228
|
+
},
|
|
229
|
+
async return(value) {
|
|
230
|
+
done = true;
|
|
231
|
+
if (!reported)
|
|
232
|
+
stop.abort(new DOMException("The reader let the model call go.", "AbortError"));
|
|
233
|
+
if (source)
|
|
234
|
+
closeEvents(source);
|
|
235
|
+
else
|
|
236
|
+
closeEvents(stream.events);
|
|
237
|
+
try {
|
|
238
|
+
await report();
|
|
239
|
+
} catch (error) {
|
|
240
|
+
console.error(`[SixbModels] Model call '${request.callId}' ended early, and recording it failed.`, error);
|
|
241
|
+
throw error;
|
|
242
|
+
}
|
|
243
|
+
return { done: true, value };
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
return { [Symbol.asyncIterator]: () => events };
|
|
247
|
+
}
|
|
248
|
+
async function withinIdle(pending, stop, onLate) {
|
|
249
|
+
let timer;
|
|
250
|
+
const silence = new Promise((_, reject) => {
|
|
251
|
+
timer = setTimeout(() => {
|
|
252
|
+
const error = new ModelStreamError2(`[SixbModels] The model sent nothing for ${MODEL_CALL_IDLE_MS / 60000} minutes.`);
|
|
253
|
+
stop.abort(error);
|
|
254
|
+
reject(error);
|
|
255
|
+
}, MODEL_CALL_IDLE_MS);
|
|
256
|
+
});
|
|
257
|
+
try {
|
|
258
|
+
return await Promise.race([pending, silence]);
|
|
259
|
+
} finally {
|
|
260
|
+
clearTimeout(timer);
|
|
261
|
+
if (stop.signal.aborted)
|
|
262
|
+
pending.then(onLate, () => {});
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
function closeEvents(events) {
|
|
266
|
+
const iterator = Symbol.asyncIterator in events ? events[Symbol.asyncIterator]() : events;
|
|
267
|
+
Promise.resolve().then(() => iterator.return?.()).catch(() => {});
|
|
268
|
+
}
|
|
135
269
|
|
|
136
270
|
// src/models/execution/model-call-accounting.ts
|
|
137
271
|
import { createHash } from "crypto";
|
|
@@ -264,6 +398,100 @@ function requireAccountingCapabilities(storage) {
|
|
|
264
398
|
return { aiUsage: storage.aiUsage, aiCosts: storage.aiCosts, aiLimits: storage.aiLimits };
|
|
265
399
|
}
|
|
266
400
|
|
|
401
|
+
// src/models/execution/model-call-limits.ts
|
|
402
|
+
function createAiModelCallLimitController2(input) {
|
|
403
|
+
const subjects = aiLimitSubjectsFromAttribution2(input.requestedBy, input.requesterGroupIds);
|
|
404
|
+
return {
|
|
405
|
+
beforeModelCall: async (admission) => {
|
|
406
|
+
let applicable;
|
|
407
|
+
try {
|
|
408
|
+
const policies = await input.storage.aiLimits.listPolicies({
|
|
409
|
+
projectId: input.projectId
|
|
410
|
+
});
|
|
411
|
+
applicable = applicableAiLimitPolicies2(policies, subjects).filter((policy) => aiLimitMeterApplies2(policy.limit.meter, admission.modelKind));
|
|
412
|
+
} catch (error) {
|
|
413
|
+
throw limitStorageUnavailable(error);
|
|
414
|
+
}
|
|
415
|
+
if (applicable.length === 0)
|
|
416
|
+
return { reservation: "none" };
|
|
417
|
+
const estimates = reservationEstimates(admission, applicable.some((policy) => policy.limit.meter === "cost.catalogEstimated"));
|
|
418
|
+
if (estimates.length === 0) {
|
|
419
|
+
throw aiUsageLimitUnavailableError2(["missingEstimate"]);
|
|
420
|
+
}
|
|
421
|
+
let result;
|
|
422
|
+
try {
|
|
423
|
+
result = await input.storage.aiLimits.reserveModelCall({
|
|
424
|
+
...reservationIdentity(admission),
|
|
425
|
+
subjects,
|
|
426
|
+
estimates,
|
|
427
|
+
...admission.modelKind === undefined ? {} : { modelKind: admission.modelKind }
|
|
428
|
+
});
|
|
429
|
+
} catch (error) {
|
|
430
|
+
throw limitStorageUnavailable(error);
|
|
431
|
+
}
|
|
432
|
+
switch (result.status) {
|
|
433
|
+
case "reserved":
|
|
434
|
+
return { reservation: "active" };
|
|
435
|
+
case "notRequired":
|
|
436
|
+
return { reservation: "none" };
|
|
437
|
+
case "denied":
|
|
438
|
+
throw aiUsageLimitExceededError2(result.resetAt);
|
|
439
|
+
case "unavailable":
|
|
440
|
+
throw aiUsageLimitUnavailableError2(result.reasons);
|
|
441
|
+
case "terminal":
|
|
442
|
+
throw aiUsageLimitUnavailableError2(["terminalReservationReplay"]);
|
|
443
|
+
}
|
|
444
|
+
},
|
|
445
|
+
markModelCallUnknown: async (identity) => {
|
|
446
|
+
try {
|
|
447
|
+
await input.storage.aiLimits.markReservationUnknown(identity);
|
|
448
|
+
} catch (error) {
|
|
449
|
+
throw limitStorageUnavailable(error);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
function reservationEstimates(input, needsCost) {
|
|
455
|
+
const estimates = [];
|
|
456
|
+
if (input.inputTokens.status === "estimated" && input.estimatedTotalTokens !== undefined) {
|
|
457
|
+
estimates.push({ meter: "tokens.total", amount: input.estimatedTotalTokens });
|
|
458
|
+
}
|
|
459
|
+
if (needsCost) {
|
|
460
|
+
try {
|
|
461
|
+
let money = input.reservationCost;
|
|
462
|
+
if (money == null && input.inputTokens.status === "estimated") {
|
|
463
|
+
money = input.costEstimator?.estimateReservation?.({
|
|
464
|
+
inputTokens: input.inputTokens.tokens,
|
|
465
|
+
outputTokens: input.outputTokenAllowance
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
if (money) {
|
|
469
|
+
estimates.push({ meter: "cost.catalogEstimated", amount: money });
|
|
470
|
+
}
|
|
471
|
+
} catch {
|
|
472
|
+
return estimates;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
return estimates;
|
|
476
|
+
}
|
|
477
|
+
function reservationIdentity(input) {
|
|
478
|
+
return {
|
|
479
|
+
projectId: input.projectId,
|
|
480
|
+
executionId: input.executionId,
|
|
481
|
+
attempt: input.attempt,
|
|
482
|
+
callId: input.callId
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
function limitStorageUnavailable(error) {
|
|
486
|
+
if (isSixbError2(error) && (error.code === "ai.usage_limit_exceeded" || error.code === "ai.usage_limit_unavailable")) {
|
|
487
|
+
return error;
|
|
488
|
+
}
|
|
489
|
+
return aiUsageLimitUnavailableError2(["limitStorageUnavailable"]);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
// src/models/execution/model-call-recorder.ts
|
|
493
|
+
import { randomUUID } from "crypto";
|
|
494
|
+
|
|
267
495
|
// src/models/execution/usage.ts
|
|
268
496
|
function aiModelCallUsageFromModel(usage) {
|
|
269
497
|
return {
|
|
@@ -354,66 +582,6 @@ function parseDate(value, jobId, field) {
|
|
|
354
582
|
return date;
|
|
355
583
|
}
|
|
356
584
|
|
|
357
|
-
// src/models/execution/model-call-recorder.ts
|
|
358
|
-
import { randomUUID } from "crypto";
|
|
359
|
-
|
|
360
|
-
// src/models/execution/model-call-admission.ts
|
|
361
|
-
var AI_MODEL_CALL_OUTPUT_TOKEN_ALLOWANCE = 4096;
|
|
362
|
-
function estimateAiModelCallInputTokens(input) {
|
|
363
|
-
if (containsNonTextInput(input.prompt)) {
|
|
364
|
-
return { status: "unavailable", reason: "nonTextInput" };
|
|
365
|
-
}
|
|
366
|
-
let serialized;
|
|
367
|
-
try {
|
|
368
|
-
serialized = JSON.stringify(input);
|
|
369
|
-
} catch {
|
|
370
|
-
return { status: "unavailable", reason: "unserializableInput" };
|
|
371
|
-
}
|
|
372
|
-
if (serialized === undefined) {
|
|
373
|
-
return { status: "unavailable", reason: "unserializableInput" };
|
|
374
|
-
}
|
|
375
|
-
const bytes = new TextEncoder().encode(serialized).byteLength;
|
|
376
|
-
return {
|
|
377
|
-
status: "estimated",
|
|
378
|
-
tokens: Math.ceil(bytes / 4),
|
|
379
|
-
method: "utf8BytesDividedByFour"
|
|
380
|
-
};
|
|
381
|
-
}
|
|
382
|
-
function aiModelCallOutputTokenAllowance(maxOutputTokens) {
|
|
383
|
-
if (maxOutputTokens === undefined)
|
|
384
|
-
return AI_MODEL_CALL_OUTPUT_TOKEN_ALLOWANCE;
|
|
385
|
-
if (!Number.isSafeInteger(maxOutputTokens) || maxOutputTokens <= 0) {
|
|
386
|
-
throw new TypeError("[SixbModels] AI model-call maxOutputTokens must be a positive safe integer.");
|
|
387
|
-
}
|
|
388
|
-
return maxOutputTokens;
|
|
389
|
-
}
|
|
390
|
-
function estimatedAiModelCallTotalTokens(inputTokens, outputTokenAllowance) {
|
|
391
|
-
if (inputTokens.status !== "estimated")
|
|
392
|
-
return;
|
|
393
|
-
const total = inputTokens.tokens + outputTokenAllowance;
|
|
394
|
-
if (!Number.isSafeInteger(total)) {
|
|
395
|
-
throw new TypeError("[SixbModels] AI model-call token estimate exceeds the safe range.");
|
|
396
|
-
}
|
|
397
|
-
return total;
|
|
398
|
-
}
|
|
399
|
-
function containsNonTextInput(value, seen = new WeakSet) {
|
|
400
|
-
if (value === null || typeof value !== "object")
|
|
401
|
-
return false;
|
|
402
|
-
if (value instanceof URL || value instanceof ArrayBuffer || ArrayBuffer.isView(value) || typeof Blob !== "undefined" && value instanceof Blob) {
|
|
403
|
-
return true;
|
|
404
|
-
}
|
|
405
|
-
if (seen.has(value))
|
|
406
|
-
return false;
|
|
407
|
-
seen.add(value);
|
|
408
|
-
if (!Array.isArray(value)) {
|
|
409
|
-
const type = Reflect.get(value, "type");
|
|
410
|
-
if (type === "image" || type === "file" || type === "reasoning-file" || type === "custom" || type === "provider-state") {
|
|
411
|
-
return true;
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
return Object.values(value).some((entry) => containsNonTextInput(entry, seen));
|
|
415
|
-
}
|
|
416
|
-
|
|
417
585
|
// src/models/execution/model-call-recorder.ts
|
|
418
586
|
var STORAGE_RETRY_DELAYS_MS = [50, 200, 600];
|
|
419
587
|
|
|
@@ -445,12 +613,9 @@ class AiModelCallRecorder2 {
|
|
|
445
613
|
return this.input.attempt;
|
|
446
614
|
}
|
|
447
615
|
wrapModel(model) {
|
|
616
|
+
const recorded = reportModelCalls2(model, this.onModelCallEnd);
|
|
448
617
|
return {
|
|
449
|
-
|
|
450
|
-
modelId: model.modelId,
|
|
451
|
-
definition: model.definition,
|
|
452
|
-
costEstimator: model.costEstimator,
|
|
453
|
-
...model.validateResponseFormat === undefined ? {} : { validateResponseFormat: model.validateResponseFormat.bind(model) },
|
|
618
|
+
...recorded,
|
|
454
619
|
stream: async (request) => {
|
|
455
620
|
this.assertHealthy();
|
|
456
621
|
const inputTokens = estimateAiModelCallInputTokens({
|
|
@@ -469,7 +634,7 @@ class AiModelCallRecorder2 {
|
|
|
469
634
|
estimatedTotalTokens: estimatedAiModelCallTotalTokens(inputTokens, outputTokenAllowance)
|
|
470
635
|
});
|
|
471
636
|
try {
|
|
472
|
-
return await
|
|
637
|
+
return await recorded.stream(request);
|
|
473
638
|
} catch (error) {
|
|
474
639
|
await this.markCallUnknown(request.callId);
|
|
475
640
|
throw error;
|
|
@@ -612,6 +777,6 @@ async function enqueueAiModelCallRecovery2(queue, input) {
|
|
|
612
777
|
}
|
|
613
778
|
}
|
|
614
779
|
|
|
615
|
-
export { AI_MODEL_CALL_OUTPUT_TOKEN_ALLOWANCE, aiModelCallOutputTokenAllowance, requireAccountingCapabilities, createAiModelCallLimitController2,
|
|
780
|
+
export { AI_MODEL_CALL_OUTPUT_TOKEN_ALLOWANCE, aiModelCallOutputTokenAllowance, ModelUsageRecordingError2, isModelCallAccountingFailure2, LanguageModelCallMeter, reportModelCalls2, requireAccountingCapabilities, createAiModelCallLimitController2, recordRecoveredAiModelCall2, isPermanentAiUsageRecoveryError2, AiModelCallRecorder2, enqueueAiModelCallRecovery2 };
|
|
616
781
|
|
|
617
|
-
//# debugId=
|
|
782
|
+
//# debugId=E9009B4AC2DD257B64756E2164756E21
|