@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
package/src/agents/model-loop.ts
CHANGED
|
@@ -9,12 +9,13 @@ import {
|
|
|
9
9
|
import { ModelProviderError, ModelStreamError, StructuredOutputError } from "../models/errors"
|
|
10
10
|
import type {
|
|
11
11
|
LanguageModelStreamEvent,
|
|
12
|
-
ModelCallEndEvent,
|
|
13
12
|
ModelFinishReason,
|
|
14
13
|
ModelStep,
|
|
15
14
|
ModelUiChunk,
|
|
16
15
|
ModelUsage,
|
|
17
16
|
} from "../models/events"
|
|
17
|
+
import { ModelUsageRecordingError } from "../models/execution/errors"
|
|
18
|
+
import { LanguageModelCallMeter } from "../models/language-call"
|
|
18
19
|
import type {
|
|
19
20
|
LanguageModel,
|
|
20
21
|
ModelReasoning,
|
|
@@ -30,16 +31,10 @@ import type {
|
|
|
30
31
|
ModelToolResultPart,
|
|
31
32
|
ProviderData,
|
|
32
33
|
} from "../models/messages"
|
|
33
|
-
import {
|
|
34
|
-
estimateModelCall,
|
|
35
|
-
type ModelCallCost,
|
|
36
|
-
type ModelReportedCost,
|
|
37
|
-
rateModelCall,
|
|
38
|
-
} from "../models/pricing"
|
|
34
|
+
import type { ModelCallCost, ModelReportedCost } from "../models/pricing"
|
|
39
35
|
import type { ModelOutput, ModelTool } from "../models/tools"
|
|
40
36
|
|
|
41
37
|
const MAX_PROVIDER_DATA_BYTES = 256 * 1024
|
|
42
|
-
|
|
43
38
|
interface ModelLoopOptions {
|
|
44
39
|
readonly model: LanguageModel
|
|
45
40
|
readonly messages: readonly ModelMessage[]
|
|
@@ -47,17 +42,15 @@ interface ModelLoopOptions {
|
|
|
47
42
|
readonly reasoning?: ModelReasoning
|
|
48
43
|
readonly maxOutputTokens?: number
|
|
49
44
|
readonly caching?: "auto" | "off"
|
|
50
|
-
|
|
45
|
+
/** At most this many provider calls. Without it, the loop runs until the model answers. */
|
|
46
|
+
readonly maxSteps?: number
|
|
51
47
|
/** Direct generation cannot execute or synthesize local tool results. */
|
|
52
48
|
readonly rejectLocalToolCalls?: boolean
|
|
53
49
|
readonly signal: AbortSignal
|
|
54
|
-
/** Reserve the final provider call for a tool-free synthesis response. */
|
|
55
|
-
readonly finalStepInstruction?: string
|
|
56
50
|
readonly prepareStep?: (
|
|
57
51
|
input: PrepareModelStepInput
|
|
58
52
|
) => PrepareModelStepResult | undefined | Promise<PrepareModelStepResult | undefined>
|
|
59
53
|
readonly onEvent?: (event: ModelUiChunk) => void | Promise<void>
|
|
60
|
-
readonly onModelCallEnd?: (event: ModelCallEndEvent) => void | Promise<void>
|
|
61
54
|
readonly onStepEnd?: (step: ModelStep) => void | Promise<void>
|
|
62
55
|
/**
|
|
63
56
|
* Asked after each step that ran local tools, once `onStepEnd` settled: `true` ends the loop
|
|
@@ -164,8 +157,9 @@ export async function runModelLoop(
|
|
|
164
157
|
const steps: ModelStep[] = []
|
|
165
158
|
const generateCallId = input.generateCallId ?? (() => `model_call_${randomUUID()}`)
|
|
166
159
|
const callIds = new Set<string>()
|
|
160
|
+
const maxSteps = input.maxSteps ?? Number.POSITIVE_INFINITY
|
|
167
161
|
|
|
168
|
-
for (let stepIndex = 0; stepIndex <
|
|
162
|
+
for (let stepIndex = 0; stepIndex < maxSteps; stepIndex += 1) {
|
|
169
163
|
if (input.signal.aborted) {
|
|
170
164
|
return { status: "aborted", steps, partialContent: [] }
|
|
171
165
|
}
|
|
@@ -187,14 +181,6 @@ export async function runModelLoop(
|
|
|
187
181
|
if (input.signal.aborted) {
|
|
188
182
|
return { status: "aborted", steps, partialContent: [] }
|
|
189
183
|
}
|
|
190
|
-
let requestTools: readonly ModelToolSpecification[] = toolSpecifications
|
|
191
|
-
if (input.finalStepInstruction !== undefined && stepIndex === input.maxSteps - 1) {
|
|
192
|
-
requestMessages = [
|
|
193
|
-
...requestMessages,
|
|
194
|
-
{ role: "user", content: [{ type: "text", text: input.finalStepInstruction }] },
|
|
195
|
-
]
|
|
196
|
-
requestTools = []
|
|
197
|
-
}
|
|
198
184
|
|
|
199
185
|
const callId = generateCallId()
|
|
200
186
|
if (!callId || callIds.has(callId)) {
|
|
@@ -209,7 +195,7 @@ export async function runModelLoop(
|
|
|
209
195
|
const stream = await input.model.stream({
|
|
210
196
|
callId,
|
|
211
197
|
messages: requestMessages,
|
|
212
|
-
tools:
|
|
198
|
+
tools: toolSpecifications,
|
|
213
199
|
...(input.reasoning === undefined ? {} : { reasoning: input.reasoning }),
|
|
214
200
|
...(input.maxOutputTokens === undefined ? {} : { maxOutputTokens: input.maxOutputTokens }),
|
|
215
201
|
...(input.caching === undefined ? {} : { caching: input.caching }),
|
|
@@ -225,6 +211,7 @@ export async function runModelLoop(
|
|
|
225
211
|
schema: input.output.schema,
|
|
226
212
|
},
|
|
227
213
|
}),
|
|
214
|
+
// A call the provider leaves silent fails where it is recorded (see reportModelCalls).
|
|
228
215
|
signal: input.signal,
|
|
229
216
|
})
|
|
230
217
|
accepted = true
|
|
@@ -232,6 +219,8 @@ export async function runModelLoop(
|
|
|
232
219
|
await accumulator.accept(event)
|
|
233
220
|
}
|
|
234
221
|
} catch (error) {
|
|
222
|
+
// A call that could not be recorded fails the run, even one that was being cancelled.
|
|
223
|
+
if (error instanceof ModelUsageRecordingError) throw error
|
|
235
224
|
const aborted = input.signal.aborted || isAbortError(error)
|
|
236
225
|
if (accumulator.isFinished()) {
|
|
237
226
|
if (!aborted) terminalStreamError = { error }
|
|
@@ -245,29 +234,9 @@ export async function runModelLoop(
|
|
|
245
234
|
}
|
|
246
235
|
}
|
|
247
236
|
} finally {
|
|
248
|
-
//
|
|
249
|
-
//
|
|
250
|
-
if (accepted) {
|
|
251
|
-
const facts = accumulator.accounting()
|
|
252
|
-
const estimate = accumulator.isFinished() ? estimateModelCall(input.model, facts) : cost
|
|
253
|
-
cost = facts.reportedCost
|
|
254
|
-
? rateModelCall({ usage: facts.usage, reported: facts.reportedCost })
|
|
255
|
-
: estimate
|
|
256
|
-
await input.onModelCallEnd?.({
|
|
257
|
-
callId,
|
|
258
|
-
modelKind: "language",
|
|
259
|
-
providerId: input.model.providerId,
|
|
260
|
-
modelId: input.model.modelId,
|
|
261
|
-
responseId: facts.responseId ?? `${callId}:response`,
|
|
262
|
-
providerIds: facts.providerIds,
|
|
263
|
-
responseModelId: facts.responseModelId,
|
|
264
|
-
usage: facts.usage,
|
|
265
|
-
cost,
|
|
266
|
-
...(facts.reportedCost === undefined ? {} : { estimate }),
|
|
267
|
-
...(input.reasoning === undefined ? {} : { requestedReasoning: input.reasoning }),
|
|
268
|
-
...(facts.route === undefined ? {} : { route: facts.route }),
|
|
269
|
-
})
|
|
270
|
-
}
|
|
237
|
+
// The step's cost, as the model records the call: the model is what records it (see
|
|
238
|
+
// AiModelCallRecorder.wrapModel), never the loop that reads it.
|
|
239
|
+
if (accepted) cost = accumulator.meter.end({ model: input.model, callId }).cost
|
|
271
240
|
}
|
|
272
241
|
|
|
273
242
|
if (input.signal.aborted && !accumulator.isFinished()) {
|
|
@@ -304,7 +273,7 @@ export async function runModelLoop(
|
|
|
304
273
|
steps.push(step)
|
|
305
274
|
await input.onStepEnd?.(step)
|
|
306
275
|
messages = [...requestMessages, { role: "assistant", content: response.content }]
|
|
307
|
-
if (stepIndex + 1 ===
|
|
276
|
+
if (stepIndex + 1 === maxSteps) {
|
|
308
277
|
throw new ModelStreamError(
|
|
309
278
|
"[SixbModels] Model reached the step limit while a provider continuation was pending."
|
|
310
279
|
)
|
|
@@ -317,7 +286,7 @@ export async function runModelLoop(
|
|
|
317
286
|
await input.onStepEnd?.(step)
|
|
318
287
|
|
|
319
288
|
// An answer cut short by the output limit ends the loop as it is.
|
|
320
|
-
const canContinue = response.finishReason !== "length" && stepIndex + 1 <
|
|
289
|
+
const canContinue = response.finishReason !== "length" && stepIndex + 1 < maxSteps
|
|
321
290
|
let followUp: readonly ModelMessage[] | undefined
|
|
322
291
|
try {
|
|
323
292
|
followUp = canContinue ? await input.beforeComplete?.(step, stepIndex) : undefined
|
|
@@ -396,7 +365,7 @@ export async function runModelLoop(
|
|
|
396
365
|
{ role: "tool", content: toolResults },
|
|
397
366
|
]
|
|
398
367
|
|
|
399
|
-
if (stepIndex + 1 ===
|
|
368
|
+
if (stepIndex + 1 === maxSteps) {
|
|
400
369
|
if (input.output) {
|
|
401
370
|
throw new StructuredOutputError(
|
|
402
371
|
"[SixbModels] Model reached the step limit without structured output.",
|
|
@@ -418,7 +387,7 @@ function assertLoopInput(input: RunModelLoopInput<unknown>): void {
|
|
|
418
387
|
) {
|
|
419
388
|
throw new TypeError("[SixbModels] maxOutputTokens must be a positive safe integer.")
|
|
420
389
|
}
|
|
421
|
-
if (!Number.isInteger(input.maxSteps) || input.maxSteps <= 0) {
|
|
390
|
+
if (input.maxSteps !== undefined && (!Number.isInteger(input.maxSteps) || input.maxSteps <= 0)) {
|
|
422
391
|
throw new TypeError("[SixbModels] maxSteps must be a positive integer.")
|
|
423
392
|
}
|
|
424
393
|
if (!input.model.providerId.trim() || !input.model.modelId.trim()) {
|
|
@@ -682,13 +651,9 @@ class StreamAccumulator {
|
|
|
682
651
|
private finished = false
|
|
683
652
|
private finishReason: ModelFinishReason | undefined
|
|
684
653
|
private rawFinishReason: string | undefined
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
private providerIds: import("../models/events").ModelProviderIds | undefined
|
|
688
|
-
private responseModelId: string | undefined
|
|
654
|
+
/** Who served the call, what it used and what the provider charged. */
|
|
655
|
+
readonly meter = new LanguageModelCallMeter()
|
|
689
656
|
private projectionError: Error | undefined
|
|
690
|
-
private reportedCost: ModelReportedCost | undefined
|
|
691
|
-
private route: import("../models/events").ModelRoute | undefined
|
|
692
657
|
|
|
693
658
|
constructor(private readonly onEvent: RunModelLoopInput["onEvent"]) {}
|
|
694
659
|
|
|
@@ -707,9 +672,7 @@ class StreamAccumulator {
|
|
|
707
672
|
return
|
|
708
673
|
case "response-metadata":
|
|
709
674
|
this.requireStarted(event.type)
|
|
710
|
-
this.
|
|
711
|
-
if (event.providerIds) this.providerIds = { ...this.providerIds, ...event.providerIds }
|
|
712
|
-
this.responseModelId = event.modelId ?? this.responseModelId
|
|
675
|
+
this.meter.accept(event)
|
|
713
676
|
return
|
|
714
677
|
case "text-start":
|
|
715
678
|
await this.startText(event)
|
|
@@ -766,9 +729,7 @@ class StreamAccumulator {
|
|
|
766
729
|
this.finished = true
|
|
767
730
|
this.finishReason = event.finishReason
|
|
768
731
|
this.rawFinishReason = event.rawFinishReason
|
|
769
|
-
this.
|
|
770
|
-
this.reportedCost = event.reportedCost
|
|
771
|
-
this.route = event.route
|
|
732
|
+
this.meter.accept(event)
|
|
772
733
|
return
|
|
773
734
|
case "error":
|
|
774
735
|
throw event.error instanceof Error
|
|
@@ -798,22 +759,11 @@ class StreamAccumulator {
|
|
|
798
759
|
toolCalls: parsed.toolCalls,
|
|
799
760
|
finishReason: this.finishReason,
|
|
800
761
|
...(this.rawFinishReason === undefined ? {} : { rawFinishReason: this.rawFinishReason }),
|
|
801
|
-
...this.
|
|
762
|
+
...this.meter.facts(),
|
|
802
763
|
...(this.projectionError === undefined ? {} : { projectionError: this.projectionError }),
|
|
803
764
|
}
|
|
804
765
|
}
|
|
805
766
|
|
|
806
|
-
accounting() {
|
|
807
|
-
return {
|
|
808
|
-
usage: this.usage,
|
|
809
|
-
...(this.responseId === undefined ? {} : { responseId: this.responseId }),
|
|
810
|
-
...(this.providerIds === undefined ? {} : { providerIds: this.providerIds }),
|
|
811
|
-
...(this.responseModelId === undefined ? {} : { responseModelId: this.responseModelId }),
|
|
812
|
-
...(this.reportedCost === undefined ? {} : { reportedCost: this.reportedCost }),
|
|
813
|
-
...(this.route === undefined ? {} : { route: this.route }),
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
|
|
817
767
|
/**
|
|
818
768
|
* The output limit explains spans a provider left open: streamed text and reasoning are kept as
|
|
819
769
|
* written, and an unfinished tool call is dropped, never executed.
|
|
@@ -50,7 +50,10 @@ const TIER_QUESTIONS = {
|
|
|
50
50
|
|
|
51
51
|
export interface TurnModelChoice {
|
|
52
52
|
readonly model: LanguageModelEntry
|
|
53
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* The decision model's answer; absent when it failed, or had no words to judge, and the turn
|
|
55
|
+
* aimed for `standard`.
|
|
56
|
+
*/
|
|
54
57
|
readonly tierProbabilities?: LanguageModelTierProbabilities
|
|
55
58
|
}
|
|
56
59
|
|
|
@@ -84,7 +87,9 @@ export function createTurnModelRouter(
|
|
|
84
87
|
|
|
85
88
|
return {
|
|
86
89
|
async choose(text, previous) {
|
|
87
|
-
|
|
90
|
+
// Files sent alone leave nothing to judge: the turn aims for standard, and the cache rule
|
|
91
|
+
// keeps a warm thread on its model.
|
|
92
|
+
const tierProbabilities = text.trim() ? await askTier(decision, text) : undefined
|
|
88
93
|
const tier = tierProbabilities ? tierFor(tierProbabilities) : "standard"
|
|
89
94
|
|
|
90
95
|
return {
|
package/src/agents/request.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto"
|
|
2
2
|
import type { Principal } from "../auth"
|
|
3
|
-
import { SYSTEM_PRINCIPAL } from "../auth"
|
|
3
|
+
import { principalsEqual, SYSTEM_PRINCIPAL } from "../auth"
|
|
4
4
|
import { assertAuthorized } from "../authorization"
|
|
5
5
|
import type { FileRef } from "../blob-storage"
|
|
6
6
|
import { isValidFileRef } from "../blob-storage/validation"
|
|
@@ -62,7 +62,10 @@ import { assertConversationThread } from "./thread-access"
|
|
|
62
62
|
import { AGENT_REASONING_LEVELS, type AgentReasoning } from "./types"
|
|
63
63
|
|
|
64
64
|
export interface RequestAgentRunInput {
|
|
65
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* The user's message that triggers the turn. Omitted to {@link continue}, or when
|
|
67
|
+
* {@link attachments} are the whole message.
|
|
68
|
+
*/
|
|
66
69
|
readonly text?: string
|
|
67
70
|
/**
|
|
68
71
|
* Continue an answer the turn limit cut short, in an existing thread. Sixb writes the
|
|
@@ -93,6 +96,11 @@ export interface RequestAgentRunInput {
|
|
|
93
96
|
readonly approvalMode?: AgentApprovalMode
|
|
94
97
|
/** Title to stamp on the thread when one is created. */
|
|
95
98
|
readonly title?: string
|
|
99
|
+
/**
|
|
100
|
+
* Where a thread this creates runs: on its owner's computer, which claims its turns, or, when
|
|
101
|
+
* omitted, in the cloud. An existing thread keeps its own.
|
|
102
|
+
*/
|
|
103
|
+
readonly runsOn?: "computer"
|
|
96
104
|
/** Explicit id for the trigger (user) message. Defaults to a generated id. */
|
|
97
105
|
readonly messageId?: string
|
|
98
106
|
/** Caller principal for privileged integrations; scoped runtimes use their authorization principal. */
|
|
@@ -147,7 +155,7 @@ export async function requestAgentRun(
|
|
|
147
155
|
|
|
148
156
|
// Any other turn's spec is checked now, before anything is written. A routed turn holds its
|
|
149
157
|
// router until its model is picked, last.
|
|
150
|
-
const routed = routedTurn(models.router, selection, input
|
|
158
|
+
const routed = routedTurn(models.router, selection, input)
|
|
151
159
|
const requested =
|
|
152
160
|
routed ?? (await resolveConversationRunSpec({ models: models.language, selection, settings }))
|
|
153
161
|
assertAttachments(input.attachments)
|
|
@@ -172,7 +180,11 @@ export async function requestAgentRun(
|
|
|
172
180
|
const existingThread = input.threadId
|
|
173
181
|
? await agents.threads.getById({ projectId, id: input.threadId })
|
|
174
182
|
: null
|
|
175
|
-
if (existingThread) assertThreadAcceptsRun(existingThread)
|
|
183
|
+
if (existingThread) assertThreadAcceptsRun(existingThread, principal)
|
|
184
|
+
if (input.runsOn !== undefined && input.runsOn !== "computer") {
|
|
185
|
+
throw new AgentRequestError("invalid_message", `[Sixb] 'runsOn' must be "computer" or omitted.`)
|
|
186
|
+
}
|
|
187
|
+
const runsOn = existingThread ? existingThread.runsOn : input.runsOn
|
|
176
188
|
// The message's mode, else the sender's in the thread.
|
|
177
189
|
const approvalMode =
|
|
178
190
|
input.approvalMode ??
|
|
@@ -192,7 +204,11 @@ export async function requestAgentRun(
|
|
|
192
204
|
language: models.language,
|
|
193
205
|
})
|
|
194
206
|
: requested
|
|
195
|
-
const spec: ConversationAgentRunSpec = Object.freeze({
|
|
207
|
+
const spec: ConversationAgentRunSpec = Object.freeze({
|
|
208
|
+
...selected,
|
|
209
|
+
approvalMode,
|
|
210
|
+
...(runsOn === undefined ? {} : { runsOn }),
|
|
211
|
+
})
|
|
196
212
|
|
|
197
213
|
const createdThread = existingThread === null
|
|
198
214
|
const thread =
|
|
@@ -202,6 +218,7 @@ export async function requestAgentRun(
|
|
|
202
218
|
threadId: input.threadId,
|
|
203
219
|
title: input.title,
|
|
204
220
|
principal,
|
|
221
|
+
runsOn,
|
|
205
222
|
}))
|
|
206
223
|
|
|
207
224
|
const triggerMessageId = input.messageId ?? createAgentMessageId()
|
|
@@ -337,9 +354,11 @@ export async function retryAgentRun(
|
|
|
337
354
|
executionId: durableExecution.id,
|
|
338
355
|
threadId: failedRun.threadId,
|
|
339
356
|
triggerMessageId: failedRun.triggerMessageId,
|
|
340
|
-
spec:
|
|
357
|
+
spec: inPlace(
|
|
358
|
+
thread,
|
|
341
359
|
failedRun.spec ??
|
|
342
|
-
|
|
360
|
+
(await resolveConversationRunSpec({ models, selection: {}, settings: {} }))
|
|
361
|
+
),
|
|
343
362
|
})
|
|
344
363
|
})
|
|
345
364
|
await publishRunActivity(runtime, run)
|
|
@@ -396,7 +415,10 @@ export async function resumeAgentTurn(
|
|
|
396
415
|
const runId = createAgentRunId()
|
|
397
416
|
const durableExecution = await prepareResumedExecution(runtime, execution, runId)
|
|
398
417
|
await assertAiLimitPreflight(runtime, durableExecution)
|
|
399
|
-
const spec =
|
|
418
|
+
const spec = inPlace(
|
|
419
|
+
thread,
|
|
420
|
+
await resumedConversationRunSpec(models, pausedRun.spec, input.approvalMode)
|
|
421
|
+
)
|
|
400
422
|
const principal =
|
|
401
423
|
authority.type === "principal"
|
|
402
424
|
? authority.context.principal
|
|
@@ -498,6 +520,18 @@ async function prepareResumedExecution(
|
|
|
498
520
|
return createInheritedAgentExecutionRecord({ id: `exec_${randomUUID()}`, parent, runId })
|
|
499
521
|
}
|
|
500
522
|
|
|
523
|
+
/**
|
|
524
|
+
* A turn's spec where its thread runs: a turn that runs again or goes on after approvals runs
|
|
525
|
+
* where its first did, whatever spec it starts from.
|
|
526
|
+
*/
|
|
527
|
+
function inPlace(
|
|
528
|
+
thread: AgentThreadRecord,
|
|
529
|
+
spec: ConversationAgentRunSpec
|
|
530
|
+
): ConversationAgentRunSpec {
|
|
531
|
+
const { runsOn: _runsOn, ...rest } = spec
|
|
532
|
+
return Object.freeze(thread.runsOn === undefined ? rest : { ...rest, runsOn: thread.runsOn })
|
|
533
|
+
}
|
|
534
|
+
|
|
501
535
|
/** The paused turn's spec, with defaults for a model that has since left the catalog. */
|
|
502
536
|
async function resumedConversationRunSpec(
|
|
503
537
|
models: LanguageModelCatalog | undefined,
|
|
@@ -572,17 +606,18 @@ interface RoutedTurn {
|
|
|
572
606
|
|
|
573
607
|
/**
|
|
574
608
|
* Naming a model or a reasoning opts a turn out of routing: it runs that model, or the default, as
|
|
575
|
-
* chosen. A continuation
|
|
609
|
+
* chosen. A continuation keeps the cut-short turn's model. A message of files alone is routed with
|
|
610
|
+
* no words, which the router does not ask about.
|
|
576
611
|
*/
|
|
577
612
|
function routedTurn(
|
|
578
613
|
router: TurnModelRouter | undefined,
|
|
579
614
|
selection: Pick<RequestAgentRunInput, "model" | "reasoning">,
|
|
580
|
-
|
|
615
|
+
input: Pick<RequestAgentRunInput, "text" | "continue">
|
|
581
616
|
): RoutedTurn | undefined {
|
|
582
|
-
if (!router ||
|
|
617
|
+
if (!router || input.continue === true) return undefined
|
|
583
618
|
if (selection.model !== undefined || selection.reasoning !== undefined) return undefined
|
|
584
619
|
|
|
585
|
-
return { router, text }
|
|
620
|
+
return { router, text: input.text ?? "" }
|
|
586
621
|
}
|
|
587
622
|
|
|
588
623
|
/** The spec of a turn Sixb picks the model for, compared to the thread's previous turn. */
|
|
@@ -623,7 +658,10 @@ async function latestConversationRun(
|
|
|
623
658
|
return runs[0]?.kind === "conversation" ? runs[0] : undefined
|
|
624
659
|
}
|
|
625
660
|
|
|
626
|
-
/**
|
|
661
|
+
/**
|
|
662
|
+
* The words of the user, or the continuation Sixb words for them. Files alone are a message too:
|
|
663
|
+
* their parts follow, and the model reads each one's description.
|
|
664
|
+
*/
|
|
627
665
|
function triggerParts(input: RequestAgentRunInput): readonly AgentMessagePart[] {
|
|
628
666
|
if (input.continue === true) {
|
|
629
667
|
if (input.text !== undefined || input.attachments?.length || input.context?.length) {
|
|
@@ -634,13 +672,15 @@ function triggerParts(input: RequestAgentRunInput): readonly AgentMessagePart[]
|
|
|
634
672
|
}
|
|
635
673
|
return [{ type: "continuation" }]
|
|
636
674
|
}
|
|
637
|
-
if (typeof input.text
|
|
638
|
-
|
|
639
|
-
"invalid_message",
|
|
640
|
-
"[Sixb] An Agent message needs text, or `continue: true` to continue the previous answer."
|
|
641
|
-
)
|
|
675
|
+
if (typeof input.text === "string" && input.text.trim().length > 0) {
|
|
676
|
+
return [{ type: "text", text: input.text }]
|
|
642
677
|
}
|
|
643
|
-
|
|
678
|
+
if (input.attachments?.length) return []
|
|
679
|
+
|
|
680
|
+
throw new AgentRequestError(
|
|
681
|
+
"invalid_message",
|
|
682
|
+
"[Sixb] An Agent message needs text or attachments, or `continue: true` to continue the previous answer."
|
|
683
|
+
)
|
|
644
684
|
}
|
|
645
685
|
|
|
646
686
|
function assertAttachments(attachments: readonly FileRef[] | undefined): void {
|
|
@@ -654,9 +694,16 @@ function assertAttachments(attachments: readonly FileRef[] | undefined): void {
|
|
|
654
694
|
}
|
|
655
695
|
}
|
|
656
696
|
|
|
657
|
-
function assertThreadAcceptsRun(thread: AgentThreadRecord): void {
|
|
697
|
+
function assertThreadAcceptsRun(thread: AgentThreadRecord, principal: Principal): void {
|
|
658
698
|
assertConversationThread(thread)
|
|
659
699
|
assertSandboxExecutionAvailable(thread)
|
|
700
|
+
// Its owner's computer runs its turns as its owner: nobody else may send it one.
|
|
701
|
+
if (thread.runsOn === "computer" && !principalsEqual(principal, thread.ownerPrincipal)) {
|
|
702
|
+
throw new AgentRequestError(
|
|
703
|
+
"not_thread_owner",
|
|
704
|
+
`[Sixb] Agent thread '${thread.id}' runs on its owner's computer, as them: only its owner can message it. Shared with you, it is yours to read and follow.`
|
|
705
|
+
)
|
|
706
|
+
}
|
|
660
707
|
// Fast single-flight check for a clear error. `runs.create` is the atomic authority.
|
|
661
708
|
if (thread.activeRunId !== null) {
|
|
662
709
|
throw new AgentRequestError(
|
|
@@ -890,6 +937,7 @@ function createThread(
|
|
|
890
937
|
readonly threadId?: string
|
|
891
938
|
readonly title?: string
|
|
892
939
|
readonly principal: Principal
|
|
940
|
+
readonly runsOn?: "computer"
|
|
893
941
|
}
|
|
894
942
|
): Promise<AgentThreadRecord> {
|
|
895
943
|
return agents.threads.create({
|
|
@@ -897,6 +945,7 @@ function createThread(
|
|
|
897
945
|
projectId: params.projectId,
|
|
898
946
|
ownerPrincipal: params.principal,
|
|
899
947
|
...(params.title === undefined ? {} : { title: params.title }),
|
|
948
|
+
...(params.runsOn === undefined ? {} : { runsOn: params.runsOn }),
|
|
900
949
|
})
|
|
901
950
|
}
|
|
902
951
|
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { captureSixbFailure, createSixbError } from "../errors/internal"
|
|
2
|
+
import { bindDurableAgentExecution } from "../execution/agent"
|
|
3
|
+
import {
|
|
4
|
+
AGENT_RUN_FAILURE_CODES,
|
|
5
|
+
type AgentRunRecord,
|
|
6
|
+
AgentStorageError,
|
|
7
|
+
type SubagentRunRecord,
|
|
8
|
+
} from "../storage/agents"
|
|
9
|
+
import { resumeDecidedAgentTurn } from "./approval-continuation"
|
|
10
|
+
import { isAwaitingApprovalRun } from "./approvals"
|
|
11
|
+
import { requestAgentRunCancel } from "./cancel"
|
|
12
|
+
import { resolveAgentRunExecutionScope } from "./run-scope"
|
|
13
|
+
import type { AgentRunSessionHost } from "./run-session"
|
|
14
|
+
|
|
15
|
+
// What follows a turn's end, wherever its runner was: the worker's session does it, and so does
|
|
16
|
+
// the API's for a runner that reaches it over HTTP. Best effort: a failure is logged, and a repair
|
|
17
|
+
// pass catches up.
|
|
18
|
+
|
|
19
|
+
/** A turn ended: its children still at work stop, and one paused on decided calls goes on. */
|
|
20
|
+
export async function afterAgentRunFinished(
|
|
21
|
+
host: AgentRunSessionHost,
|
|
22
|
+
run: AgentRunRecord
|
|
23
|
+
): Promise<void> {
|
|
24
|
+
if (run.kind !== "conversation") return
|
|
25
|
+
const ended =
|
|
26
|
+
run.finishReason === "interrupted"
|
|
27
|
+
? "was interrupted"
|
|
28
|
+
: run.status === "succeeded"
|
|
29
|
+
? "has finished"
|
|
30
|
+
: `was ${run.status}`
|
|
31
|
+
await stopActiveChildren(host, run.id, `The parent Agent run ${ended}.`)
|
|
32
|
+
if (!isAwaitingApprovalRun(run)) return
|
|
33
|
+
try {
|
|
34
|
+
// As its requester, with the grants they have now: what a decision would have done.
|
|
35
|
+
const scope = await resolveAgentRunExecutionScope(
|
|
36
|
+
{ id: host.projectId, storage: host.storage, definitions: { security: host.security } },
|
|
37
|
+
{ runId: run.id, executionId: run.executionId, authority: { type: "inherited" } }
|
|
38
|
+
)
|
|
39
|
+
await resumeDecidedAgentTurn(bindDurableAgentExecution(host.sdk, scope), run.id)
|
|
40
|
+
} catch (error) {
|
|
41
|
+
console.error(`[Sixb] Could not resume Agent run '${run.id}'; retrying later.`, error)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function stopActiveChildren(
|
|
46
|
+
host: AgentRunSessionHost,
|
|
47
|
+
parentRunId: string,
|
|
48
|
+
message: string
|
|
49
|
+
): Promise<void> {
|
|
50
|
+
let children: readonly AgentRunRecord[]
|
|
51
|
+
try {
|
|
52
|
+
children = (
|
|
53
|
+
await host.storage.agents.runs.list({
|
|
54
|
+
projectId: host.projectId,
|
|
55
|
+
kinds: ["subagent"],
|
|
56
|
+
parentRunId,
|
|
57
|
+
statuses: ["queued", "running"],
|
|
58
|
+
order: "asc",
|
|
59
|
+
limit: 100,
|
|
60
|
+
})
|
|
61
|
+
).runs
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.error(
|
|
64
|
+
`[Sixb] Could not list the active children of Agent run '${parentRunId}'; the repair pass retries.`,
|
|
65
|
+
error
|
|
66
|
+
)
|
|
67
|
+
return
|
|
68
|
+
}
|
|
69
|
+
await Promise.all(
|
|
70
|
+
children.map(async (child) => {
|
|
71
|
+
if (child.kind !== "subagent") return
|
|
72
|
+
try {
|
|
73
|
+
await stopAgentRunChild(host, child, message)
|
|
74
|
+
} catch (error) {
|
|
75
|
+
console.error(
|
|
76
|
+
`[Sixb] Could not stop subagent run '${child.id}'; the repair pass retries.`,
|
|
77
|
+
error
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Stop a child whose parent ended: a queued one ends cancelled here, with why; a running one is
|
|
86
|
+
* told to stop, which its runner obeys. One whose lease lapsed has no runner left to obey: the
|
|
87
|
+
* repair pass ends it (see endLapsedAgentRuns).
|
|
88
|
+
*/
|
|
89
|
+
export async function stopAgentRunChild(
|
|
90
|
+
host: AgentRunSessionHost,
|
|
91
|
+
run: SubagentRunRecord,
|
|
92
|
+
message: string
|
|
93
|
+
): Promise<void> {
|
|
94
|
+
const cancelHost = {
|
|
95
|
+
projectId: host.projectId,
|
|
96
|
+
broker: host.broker,
|
|
97
|
+
storage: host.storage.agents,
|
|
98
|
+
}
|
|
99
|
+
if (run.status === "running") {
|
|
100
|
+
await requestAgentRunCancel(cancelHost, run.id)
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
if (run.status !== "queued") return
|
|
104
|
+
|
|
105
|
+
const completedAt = new Date()
|
|
106
|
+
const details = { parentRunId: run.parentRunId, runId: run.id }
|
|
107
|
+
const error = captureSixbFailure(createSixbError("runtime.cancelled", message, { details }), {
|
|
108
|
+
allowedCodes: AGENT_RUN_FAILURE_CODES,
|
|
109
|
+
defaultCode: "runtime.cancelled",
|
|
110
|
+
details,
|
|
111
|
+
at: completedAt,
|
|
112
|
+
})
|
|
113
|
+
try {
|
|
114
|
+
const cancelled = await host.storage.agents.runs.finishQueued({
|
|
115
|
+
projectId: host.projectId,
|
|
116
|
+
id: run.id,
|
|
117
|
+
status: "cancelled",
|
|
118
|
+
error,
|
|
119
|
+
completedAt,
|
|
120
|
+
})
|
|
121
|
+
await host.events.publishRunFinished(cancelled)
|
|
122
|
+
} catch (failure) {
|
|
123
|
+
if (!(failure instanceof AgentStorageError) || failure.code !== "invalid_state") throw failure
|
|
124
|
+
// It started meanwhile: tell its runner instead.
|
|
125
|
+
const current = await host.storage.agents.runs.getById({
|
|
126
|
+
projectId: host.projectId,
|
|
127
|
+
id: run.id,
|
|
128
|
+
})
|
|
129
|
+
if (current?.kind === "subagent" && current.status === "running") {
|
|
130
|
+
await requestAgentRunCancel(cancelHost, run.id)
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|