@sixb/core 0.1.24 → 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 +6 -3
- package/dist/artifacts/frames/index.js.map +3 -3
- package/dist/artifacts/frames/probe.d.ts.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/frames/probe.ts +14 -1
- 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
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
type AgentRunFailureCode,
|
|
13
13
|
type AgentRunRecord,
|
|
14
14
|
type ConversationAgentRunRecord,
|
|
15
|
-
type SubagentRunRecord,
|
|
16
15
|
} from "../../storage/agents/types"
|
|
17
16
|
|
|
18
17
|
export const AGENT_RUN_STREAM_SCHEMA_VERSION = 1 as const
|
|
@@ -290,296 +289,6 @@ export async function subscribeAgentRunCancel(
|
|
|
290
289
|
)
|
|
291
290
|
}
|
|
292
291
|
|
|
293
|
-
// ── Inbox streams (mail between a turn and its sub-agents) ──────────────────────────────────────
|
|
294
|
-
//
|
|
295
|
-
// A sub-agent's thread has an inbox its runs read at each step boundary: its parent steering it,
|
|
296
|
-
// and the parent's reply to its question. Every run of the child reads the same one. A turn has
|
|
297
|
-
// one too, where its children ask it. Its durable record is the sender's tool call and the
|
|
298
|
-
// reader's thread, which keeps each `mail` part where it was read, or the tool result. An answer
|
|
299
|
-
// the parent could only give in a later turn starts the run that continues the child, never through
|
|
300
|
-
// these streams. A thread's inbox outlives the turn only so that a child paused on a held call,
|
|
301
|
-
// which a later turn continues once the user decides, can still be given what it did not read: it
|
|
302
|
-
// keeps mail as long as an approval waits, and a day more.
|
|
303
|
-
//
|
|
304
|
-
// A turn's inbox also hears when each of its children finishes, so one subscription per turn wakes
|
|
305
|
-
// its waits for questions and for children alike.
|
|
306
|
-
|
|
307
|
-
export type AgentThreadInboxStreamId = `agents.threads.${string}.inbox`
|
|
308
|
-
export type AgentRunInboxStreamId = `agents.runs.${string}.inbox`
|
|
309
|
-
|
|
310
|
-
export function agentThreadInboxStreamId(threadId: string): AgentThreadInboxStreamId {
|
|
311
|
-
return `agents.threads.${threadId}.inbox`
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
export function agentRunInboxStreamId(runId: string): AgentRunInboxStreamId {
|
|
315
|
-
return `agents.runs.${runId}.inbox`
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
const AGENT_MAIL_RECORD = "agent.mail"
|
|
319
|
-
|
|
320
|
-
const AGENT_INBOX_RETENTION = {
|
|
321
|
-
// An approval waits at most 7 days (`AGENT_APPROVAL_TTL_MS`).
|
|
322
|
-
maxAgeMs: 8 * 24 * 60 * 60 * 1000,
|
|
323
|
-
maxRecords: 1_000,
|
|
324
|
-
} as const
|
|
325
|
-
|
|
326
|
-
/** Whose inbox: a sub-agent's thread, or a turn its children ask. */
|
|
327
|
-
export type AgentInbox = { readonly threadId: string } | { readonly runId: string }
|
|
328
|
-
|
|
329
|
-
function inboxStreamDefinition(inbox: AgentInbox): BrokerStreamDefinition {
|
|
330
|
-
return { id: inboxStreamId(inbox), retention: AGENT_INBOX_RETENTION }
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
function inboxStreamId(inbox: AgentInbox): AgentThreadInboxStreamId | AgentRunInboxStreamId {
|
|
334
|
-
return "threadId" in inbox
|
|
335
|
-
? agentThreadInboxStreamId(inbox.threadId)
|
|
336
|
-
: agentRunInboxStreamId(inbox.runId)
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
/**
|
|
340
|
-
* The kinds of mail this version writes and understands:
|
|
341
|
-
*
|
|
342
|
-
* - `message`: the parent steers its child;
|
|
343
|
-
* - `question`: the child asks its parent, and waits;
|
|
344
|
-
* - `answer`: the parent's reply to a question, `inReplyTo`;
|
|
345
|
-
* - `deferred`: the parent's turn ended without one, so the child pauses on its question.
|
|
346
|
-
*/
|
|
347
|
-
export const AGENT_MAIL_KINDS = ["message", "question", "answer", "deferred"] as const
|
|
348
|
-
export type AgentMailKind = (typeof AGENT_MAIL_KINDS)[number]
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* One message between a turn and its sub-agent: to the child's thread, or, a question, from the
|
|
352
|
-
* child's thread to the turn.
|
|
353
|
-
*/
|
|
354
|
-
export type AgentMail = {
|
|
355
|
-
/** Unique per message: a sender writing it again, or the broker redelivering it, is the same. */
|
|
356
|
-
readonly id: string
|
|
357
|
-
readonly fromRunId: string
|
|
358
|
-
readonly kind: AgentMailKind
|
|
359
|
-
/** The question an `answer` or `deferred` replies to. */
|
|
360
|
-
readonly inReplyTo?: string
|
|
361
|
-
/** What the reader's model reads, whatever the kind: a reader that does not know it reads this. */
|
|
362
|
-
readonly text: string
|
|
363
|
-
readonly sentAt: string
|
|
364
|
-
} & (
|
|
365
|
-
| { readonly toThreadId: string }
|
|
366
|
-
| {
|
|
367
|
-
readonly toRunId: string
|
|
368
|
-
/** The sub-agent's thread that asks. */
|
|
369
|
-
readonly fromThreadId: string
|
|
370
|
-
}
|
|
371
|
-
)
|
|
372
|
-
|
|
373
|
-
/**
|
|
374
|
-
* Mail as a reader finds it. Its kind may be one a newer sender writes: the reader delivers its
|
|
375
|
-
* text as a message rather than skipping it, so no reader's cursor passes mail it never delivered.
|
|
376
|
-
*/
|
|
377
|
-
export type ReceivedAgentMail = Omit<AgentMail, "kind"> & { readonly kind: string }
|
|
378
|
-
|
|
379
|
-
export function isKnownAgentMailKind(kind: string): kind is AgentMailKind {
|
|
380
|
-
return (AGENT_MAIL_KINDS as readonly string[]).includes(kind)
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
function isReceivedAgentMail(value: unknown): value is ReceivedAgentMail {
|
|
384
|
-
return (
|
|
385
|
-
isPlainRecord(value) &&
|
|
386
|
-
typeof value.id === "string" &&
|
|
387
|
-
typeof value.fromRunId === "string" &&
|
|
388
|
-
(typeof value.toThreadId === "string" ||
|
|
389
|
-
(typeof value.toRunId === "string" && typeof value.fromThreadId === "string")) &&
|
|
390
|
-
typeof value.kind === "string" &&
|
|
391
|
-
value.kind.length > 0 &&
|
|
392
|
-
(value.inReplyTo === undefined || typeof value.inReplyTo === "string") &&
|
|
393
|
-
typeof value.text === "string" &&
|
|
394
|
-
typeof value.sentAt === "string"
|
|
395
|
-
)
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
/** Whether mail is addressed to this inbox. */
|
|
399
|
-
function isFor(mail: ReceivedAgentMail, inbox: AgentInbox): boolean {
|
|
400
|
-
return "threadId" in inbox
|
|
401
|
-
? "toThreadId" in mail && mail.toThreadId === inbox.threadId
|
|
402
|
-
: "toRunId" in mail && mail.toRunId === inbox.runId
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
function recipientOf(mail: AgentMail): AgentInbox {
|
|
406
|
-
return "toThreadId" in mail ? { threadId: mail.toThreadId } : { runId: mail.toRunId }
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
/** Write a message to its recipient's inbox. Idempotent by its id where the broker dedupes. */
|
|
410
|
-
export async function publishAgentMail(
|
|
411
|
-
broker: Broker,
|
|
412
|
-
params: { readonly projectId: string; readonly mail: AgentMail }
|
|
413
|
-
): Promise<void> {
|
|
414
|
-
const { projectId, mail } = params
|
|
415
|
-
const inbox = recipientOf(mail)
|
|
416
|
-
await broker.ensureStream({ projectId, stream: inboxStreamDefinition(inbox) })
|
|
417
|
-
await broker.append({
|
|
418
|
-
projectId,
|
|
419
|
-
streamId: inboxStreamId(inbox),
|
|
420
|
-
records: [
|
|
421
|
-
{
|
|
422
|
-
name: AGENT_MAIL_RECORD,
|
|
423
|
-
key: "threadId" in inbox ? inbox.threadId : inbox.runId,
|
|
424
|
-
// The mail is composed only of validated JSON primitives.
|
|
425
|
-
payload: mail as unknown as JsonValue,
|
|
426
|
-
idempotencyKey: mail.id,
|
|
427
|
-
},
|
|
428
|
-
],
|
|
429
|
-
})
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
/**
|
|
433
|
-
* Call `onMail` with each page of mail to an inbox as it arrives, from its start. It is a wake: a
|
|
434
|
-
* broker may deliver a record again, so the reader keeps each mail once by its id. Returns the
|
|
435
|
-
* unsubscribe handle.
|
|
436
|
-
*/
|
|
437
|
-
export function subscribeAgentMail(
|
|
438
|
-
broker: Broker,
|
|
439
|
-
params: { readonly projectId: string; readonly inbox: AgentInbox },
|
|
440
|
-
onMail: (mail: readonly ReceivedAgentMail[]) => void
|
|
441
|
-
): Promise<() => void> {
|
|
442
|
-
return subscribeAgentInbox(broker, params, { mail: onMail })
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
/**
|
|
446
|
-
* Hear an inbox from its start: its mail, and, for a turn's with `childFinished`, the ids of its
|
|
447
|
-
* children as each finishes. Both are wakes: a broker may deliver a record again, and a finish says
|
|
448
|
-
* only that the child's run is worth reading. Returns the unsubscribe handle.
|
|
449
|
-
*/
|
|
450
|
-
export async function subscribeAgentInbox(
|
|
451
|
-
broker: Broker,
|
|
452
|
-
params: { readonly projectId: string; readonly inbox: AgentInbox },
|
|
453
|
-
on: {
|
|
454
|
-
readonly mail: (mail: readonly ReceivedAgentMail[]) => void
|
|
455
|
-
readonly childFinished?: (runIds: readonly string[]) => void
|
|
456
|
-
}
|
|
457
|
-
): Promise<() => void> {
|
|
458
|
-
const { inbox } = params
|
|
459
|
-
await broker.ensureStream({
|
|
460
|
-
projectId: params.projectId,
|
|
461
|
-
stream: inboxStreamDefinition(inbox),
|
|
462
|
-
})
|
|
463
|
-
return broker.subscribe(
|
|
464
|
-
{
|
|
465
|
-
projectId: params.projectId,
|
|
466
|
-
streamId: inboxStreamId(inbox),
|
|
467
|
-
from: "earliest",
|
|
468
|
-
names: on.childFinished
|
|
469
|
-
? [AGENT_MAIL_RECORD, AGENT_CHILD_FINISHED_RECORD]
|
|
470
|
-
: [AGENT_MAIL_RECORD],
|
|
471
|
-
},
|
|
472
|
-
(records) => {
|
|
473
|
-
const mail: ReceivedAgentMail[] = []
|
|
474
|
-
const finished: string[] = []
|
|
475
|
-
for (const { name, payload } of records) {
|
|
476
|
-
if (name === AGENT_MAIL_RECORD) {
|
|
477
|
-
if (isReceivedAgentMail(payload) && isFor(payload, inbox)) mail.push(payload)
|
|
478
|
-
} else if (
|
|
479
|
-
"runId" in inbox &&
|
|
480
|
-
isAgentChildFinished(payload) &&
|
|
481
|
-
payload.parentRunId === inbox.runId
|
|
482
|
-
) {
|
|
483
|
-
finished.push(payload.runId)
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
if (mail.length > 0) on.mail(mail)
|
|
488
|
-
if (finished.length > 0) on.childFinished?.(finished)
|
|
489
|
-
}
|
|
490
|
-
)
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
const AGENT_CHILD_FINISHED_RECORD = "agent.child.finished"
|
|
494
|
-
|
|
495
|
-
/** A child stopped being at work: it ended, or paused on a held call or on its question. */
|
|
496
|
-
interface AgentChildFinished {
|
|
497
|
-
readonly runId: string
|
|
498
|
-
readonly parentRunId: string
|
|
499
|
-
readonly status: "succeeded" | "failed" | "cancelled"
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
function isAgentChildFinished(value: unknown): value is AgentChildFinished {
|
|
503
|
-
return (
|
|
504
|
-
isPlainRecord(value) &&
|
|
505
|
-
typeof value.runId === "string" &&
|
|
506
|
-
typeof value.parentRunId === "string" &&
|
|
507
|
-
isTerminalAgentRunStatus(value.status)
|
|
508
|
-
)
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
/**
|
|
512
|
-
* Tell the turn a child works under, on the turn's inbox, that the child finished. Its run stream
|
|
513
|
-
* says so too, but that stream belongs to the transcript sink, which a worker may replace, and
|
|
514
|
-
* hearing it would take one subscription per child, each carrying every chunk the child streams.
|
|
515
|
-
* This record is the platform's, and one subscription per turn hears every child.
|
|
516
|
-
*/
|
|
517
|
-
export async function publishAgentChildFinished(
|
|
518
|
-
broker: Broker,
|
|
519
|
-
run: SubagentRunRecord
|
|
520
|
-
): Promise<void> {
|
|
521
|
-
if (run.status === "queued" || run.status === "running") return
|
|
522
|
-
|
|
523
|
-
const finished: AgentChildFinished = {
|
|
524
|
-
runId: run.id,
|
|
525
|
-
parentRunId: run.parentRunId,
|
|
526
|
-
status: run.status,
|
|
527
|
-
}
|
|
528
|
-
const inbox = { runId: run.parentRunId }
|
|
529
|
-
await broker.ensureStream({ projectId: run.projectId, stream: inboxStreamDefinition(inbox) })
|
|
530
|
-
await broker.append({
|
|
531
|
-
projectId: run.projectId,
|
|
532
|
-
streamId: inboxStreamId(inbox),
|
|
533
|
-
records: [
|
|
534
|
-
{
|
|
535
|
-
name: AGENT_CHILD_FINISHED_RECORD,
|
|
536
|
-
key: run.parentRunId,
|
|
537
|
-
// The record is composed only of validated JSON primitives.
|
|
538
|
-
payload: finished as unknown as JsonValue,
|
|
539
|
-
idempotencyKey: `${run.id}:${run.attempt}:finished:${run.status}`,
|
|
540
|
-
},
|
|
541
|
-
],
|
|
542
|
-
})
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
/**
|
|
546
|
-
* Read an inbox's mail after `afterCursor`, or from the start, every page of it. Carry the returned
|
|
547
|
-
* cursor to the next read. A record that is not mail at all (no envelope, no text) cannot be
|
|
548
|
-
* delivered: it is reported and passed, never silently.
|
|
549
|
-
*/
|
|
550
|
-
export async function readAgentMail(
|
|
551
|
-
broker: Broker,
|
|
552
|
-
params: { readonly projectId: string; readonly inbox: AgentInbox; readonly afterCursor?: string }
|
|
553
|
-
): Promise<{ readonly mail: readonly ReceivedAgentMail[]; readonly cursor?: string }> {
|
|
554
|
-
const mail: ReceivedAgentMail[] = []
|
|
555
|
-
const streamId = inboxStreamId(params.inbox)
|
|
556
|
-
let cursor = params.afterCursor
|
|
557
|
-
|
|
558
|
-
for (;;) {
|
|
559
|
-
const page = await broker.read({
|
|
560
|
-
projectId: params.projectId,
|
|
561
|
-
streamId,
|
|
562
|
-
names: [AGENT_MAIL_RECORD],
|
|
563
|
-
...(cursor === undefined ? {} : { afterCursor: cursor }),
|
|
564
|
-
})
|
|
565
|
-
for (const record of page.records) {
|
|
566
|
-
if (!isReceivedAgentMail(record.payload)) {
|
|
567
|
-
console.error(
|
|
568
|
-
`[Sixb] Agent inbox '${streamId}' record '${record.cursor}' is not mail; it is skipped.`
|
|
569
|
-
)
|
|
570
|
-
continue
|
|
571
|
-
}
|
|
572
|
-
if (isFor(record.payload, params.inbox)) mail.push(record.payload)
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
const previous = cursor
|
|
576
|
-
cursor = page.cursor ?? cursor
|
|
577
|
-
if (!page.hasMore || cursor === previous) break
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
return { mail, ...(cursor === undefined ? {} : { cursor }) }
|
|
581
|
-
}
|
|
582
|
-
|
|
583
292
|
/** Exact portable failure exposed by a terminal Agent run stream event. */
|
|
584
293
|
export type AgentRunFailure = SixbFailure<AgentRunFailureCode>
|
|
585
294
|
|
|
@@ -797,5 +506,4 @@ export async function publishAgentRunFinished(broker: Broker, run: AgentRunRecor
|
|
|
797
506
|
],
|
|
798
507
|
})
|
|
799
508
|
if (run.kind === "conversation") await publishAgentRunActivity(broker, run)
|
|
800
|
-
else await publishAgentChildFinished(broker, run)
|
|
801
509
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AgentStorage, SubagentRunRecord } from "../storage/agents"
|
|
1
|
+
import type { AgentStorage, SubagentRunFile, SubagentRunRecord } from "../storage/agents"
|
|
2
2
|
|
|
3
3
|
const PAGE = 100
|
|
4
4
|
|
|
@@ -39,3 +39,21 @@ export async function listSubagentThreadRuns(
|
|
|
39
39
|
a.id.localeCompare(b.id)
|
|
40
40
|
)
|
|
41
41
|
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The files a child finds in its sandbox: those its parent handed over, and for a continuation
|
|
45
|
+
* what the paused run left in `out/`, given back there. An output wins over a handed file at its
|
|
46
|
+
* path, as the paused run's copy was the latest.
|
|
47
|
+
*/
|
|
48
|
+
export function subagentSandboxFiles(
|
|
49
|
+
run: SubagentRunRecord,
|
|
50
|
+
paused: SubagentRunRecord | undefined
|
|
51
|
+
): readonly SubagentRunFile[] {
|
|
52
|
+
const outputs = (paused?.result?.files ?? []).map((file) => ({
|
|
53
|
+
...file,
|
|
54
|
+
path: `out/${file.path}`,
|
|
55
|
+
}))
|
|
56
|
+
const restored = new Set(outputs.map((file) => file.path))
|
|
57
|
+
|
|
58
|
+
return [...(run.spec.files ?? []).filter((file) => !restored.has(file.path)), ...outputs]
|
|
59
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { createHash } from "node:crypto"
|
|
2
|
+
import { posix } from "node:path"
|
|
3
|
+
import { ARTIFACT_LIMITS } from "../artifacts/limits"
|
|
4
|
+
import { sniffFileMediaType } from "../blob-storage/media-type"
|
|
5
|
+
import type { BlobBody, FileRef } from "../blob-storage/types"
|
|
6
|
+
import { AgentToolPublicError } from "./errors"
|
|
7
|
+
import type { AgentRunFileStore } from "./run-session"
|
|
8
|
+
import type { AgentToolFilePutInput } from "./types"
|
|
9
|
+
|
|
10
|
+
// The files a tool stores for its run: checked and stored where the tool runs, then copied into the
|
|
11
|
+
// run's sandbox by its runner, at the path the tool was told. A tool that runs on the server and
|
|
12
|
+
// one in the runner's process store the same way.
|
|
13
|
+
|
|
14
|
+
/** Where a run's sandbox keeps its files, relative to its working directory. */
|
|
15
|
+
export const SANDBOX_CONTEXT_DIRECTORY = ".sixb/agent"
|
|
16
|
+
/** The most a file a tool stores, or one `view_file` reads, may hold: an artifact's file limit. */
|
|
17
|
+
export const AGENT_FILE_MAX_BYTES = ARTIFACT_LIMITS.maxFileBytes
|
|
18
|
+
const MAX_FILE_NAME_BYTES = 255
|
|
19
|
+
const MAX_MEDIA_TYPE_LENGTH = 255
|
|
20
|
+
const MEDIA_TYPE_PATTERN = /^[!#$&^_.+A-Za-z0-9-]+\/[!#$&^_.+A-Za-z0-9-]+$/
|
|
21
|
+
const CONTROL_CHARACTER_PATTERN = /[\u0000-\u001f\u007f]/
|
|
22
|
+
|
|
23
|
+
/** A file a tool stored, and where its runner copies it in the run's sandbox. */
|
|
24
|
+
export interface AgentToolCallFile {
|
|
25
|
+
readonly fileRef: FileRef
|
|
26
|
+
/** Relative to the sandbox's context directory, wherever the runner keeps it. */
|
|
27
|
+
readonly path: string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** A file a tool just stored, with its bytes, which its runner copies; the blob holds the same. */
|
|
31
|
+
export interface StoredAgentToolFile extends AgentToolCallFile {
|
|
32
|
+
readonly bytes: Uint8Array
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Check one file a tool puts and store it: a single safe name, a media type its bytes match, at most
|
|
37
|
+
* `fileMaxBytes`. Its `path` in the sandbox's context directory is where the runner copies it: one
|
|
38
|
+
* directory per tool call, and the content's digest in its name.
|
|
39
|
+
*/
|
|
40
|
+
export async function storeAgentToolFile(input: {
|
|
41
|
+
readonly toolName: string
|
|
42
|
+
readonly toolCallId: string
|
|
43
|
+
readonly file: AgentToolFilePutInput
|
|
44
|
+
readonly store: Pick<AgentRunFileStore, "put">
|
|
45
|
+
readonly signal: AbortSignal
|
|
46
|
+
/** Called with each file's size as it is read, before it is stored; throws to refuse it. */
|
|
47
|
+
readonly onBytes?: (sizeBytes: number) => void
|
|
48
|
+
/** Test seam; production allows {@link AGENT_FILE_MAX_BYTES}. */
|
|
49
|
+
readonly fileMaxBytes?: number
|
|
50
|
+
}): Promise<StoredAgentToolFile> {
|
|
51
|
+
const { toolName, signal } = input
|
|
52
|
+
signal.throwIfAborted()
|
|
53
|
+
const fileName = validateFileName(input.file.fileName, toolName)
|
|
54
|
+
const declaredMediaType = normalizeMediaType(
|
|
55
|
+
input.file.mediaType ?? blobMediaType(input.file.body),
|
|
56
|
+
toolName
|
|
57
|
+
)
|
|
58
|
+
const bytes = await readFileBody({
|
|
59
|
+
body: input.file.body,
|
|
60
|
+
fileMaxBytes: input.fileMaxBytes ?? AGENT_FILE_MAX_BYTES,
|
|
61
|
+
signal,
|
|
62
|
+
toolName,
|
|
63
|
+
onBytes: input.onBytes ?? (() => {}),
|
|
64
|
+
})
|
|
65
|
+
const mediaType = validatedMediaType(bytes, declaredMediaType, toolName)
|
|
66
|
+
signal.throwIfAborted()
|
|
67
|
+
const fileRef = await input.store.put({
|
|
68
|
+
body: bytes,
|
|
69
|
+
expectedSizeBytes: bytes.byteLength,
|
|
70
|
+
signal,
|
|
71
|
+
fileName,
|
|
72
|
+
mediaType,
|
|
73
|
+
})
|
|
74
|
+
signal.throwIfAborted()
|
|
75
|
+
return { fileRef, path: toolFilePath(input.toolCallId, fileRef, fileName), bytes }
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async function readFileBody(input: {
|
|
79
|
+
readonly body: BlobBody
|
|
80
|
+
readonly fileMaxBytes: number
|
|
81
|
+
readonly signal: AbortSignal
|
|
82
|
+
readonly toolName: string
|
|
83
|
+
readonly onBytes: (sizeBytes: number) => void
|
|
84
|
+
}): Promise<Uint8Array> {
|
|
85
|
+
const { body, signal } = input
|
|
86
|
+
const knownSize = knownBodySize(body)
|
|
87
|
+
if (knownSize !== undefined) {
|
|
88
|
+
assertWithinFileLimit(knownSize, input.fileMaxBytes, input.toolName)
|
|
89
|
+
input.onBytes(knownSize)
|
|
90
|
+
}
|
|
91
|
+
signal.throwIfAborted()
|
|
92
|
+
|
|
93
|
+
if (body instanceof Uint8Array) return new Uint8Array(body)
|
|
94
|
+
if (body instanceof ArrayBuffer) return new Uint8Array(body.slice(0))
|
|
95
|
+
if (body instanceof Blob) {
|
|
96
|
+
const bytes = new Uint8Array(await body.arrayBuffer())
|
|
97
|
+
signal.throwIfAborted()
|
|
98
|
+
return bytes
|
|
99
|
+
}
|
|
100
|
+
if (!(body instanceof ReadableStream)) {
|
|
101
|
+
throw toolFileError(input.toolName, "file body must be binary data or a byte stream")
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const reader = body.getReader()
|
|
105
|
+
const chunks: Uint8Array[] = []
|
|
106
|
+
let totalBytes = 0
|
|
107
|
+
const cancelOnAbort = () => {
|
|
108
|
+
void reader.cancel(signal.reason)
|
|
109
|
+
}
|
|
110
|
+
signal.addEventListener("abort", cancelOnAbort, { once: true })
|
|
111
|
+
try {
|
|
112
|
+
while (true) {
|
|
113
|
+
const { done, value } = await reader.read()
|
|
114
|
+
signal.throwIfAborted()
|
|
115
|
+
if (done) break
|
|
116
|
+
const chunk = new Uint8Array(value)
|
|
117
|
+
totalBytes += chunk.byteLength
|
|
118
|
+
if (totalBytes > input.fileMaxBytes) {
|
|
119
|
+
await reader.cancel("agent tool file exceeded its file limit").catch(() => {})
|
|
120
|
+
assertWithinFileLimit(totalBytes, input.fileMaxBytes, input.toolName)
|
|
121
|
+
}
|
|
122
|
+
input.onBytes(chunk.byteLength)
|
|
123
|
+
chunks.push(chunk)
|
|
124
|
+
}
|
|
125
|
+
} finally {
|
|
126
|
+
signal.removeEventListener("abort", cancelOnAbort)
|
|
127
|
+
reader.releaseLock()
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const bytes = new Uint8Array(totalBytes)
|
|
131
|
+
let offset = 0
|
|
132
|
+
for (const chunk of chunks) {
|
|
133
|
+
bytes.set(chunk, offset)
|
|
134
|
+
offset += chunk.byteLength
|
|
135
|
+
}
|
|
136
|
+
return bytes
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function knownBodySize(body: BlobBody): number | undefined {
|
|
140
|
+
if (body instanceof Uint8Array) return body.byteLength
|
|
141
|
+
if (body instanceof ArrayBuffer) return body.byteLength
|
|
142
|
+
if (body instanceof Blob) return body.size
|
|
143
|
+
return undefined
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function assertWithinFileLimit(sizeBytes: number, limit: number, toolName: string): void {
|
|
147
|
+
if (sizeBytes <= limit) return
|
|
148
|
+
throw toolFileError(
|
|
149
|
+
toolName,
|
|
150
|
+
`file is ${sizeBytes} bytes and exceeds the ${limit}-byte file limit`
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function validateFileName(value: string, toolName: string): string {
|
|
155
|
+
if (
|
|
156
|
+
typeof value !== "string" ||
|
|
157
|
+
value.trim().length === 0 ||
|
|
158
|
+
value === "." ||
|
|
159
|
+
value === ".." ||
|
|
160
|
+
value.includes("/") ||
|
|
161
|
+
value.includes("\\") ||
|
|
162
|
+
CONTROL_CHARACTER_PATTERN.test(value)
|
|
163
|
+
) {
|
|
164
|
+
throw toolFileError(toolName, "fileName must be a single safe file name")
|
|
165
|
+
}
|
|
166
|
+
const sizeBytes = new TextEncoder().encode(value).byteLength
|
|
167
|
+
if (sizeBytes > MAX_FILE_NAME_BYTES) {
|
|
168
|
+
throw toolFileError(toolName, `fileName exceeds the ${MAX_FILE_NAME_BYTES}-byte limit`)
|
|
169
|
+
}
|
|
170
|
+
return value
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function blobMediaType(body: BlobBody): string | undefined {
|
|
174
|
+
return body instanceof Blob ? body.type : undefined
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function normalizeMediaType(value: string | undefined, toolName: string): string | undefined {
|
|
178
|
+
if (value === undefined || value === "") return undefined
|
|
179
|
+
const normalized = value.trim().toLowerCase()
|
|
180
|
+
if (
|
|
181
|
+
normalized.length === 0 ||
|
|
182
|
+
normalized.length > MAX_MEDIA_TYPE_LENGTH ||
|
|
183
|
+
!MEDIA_TYPE_PATTERN.test(normalized)
|
|
184
|
+
) {
|
|
185
|
+
throw toolFileError(toolName, "mediaType must be a valid type/subtype value")
|
|
186
|
+
}
|
|
187
|
+
return normalized === "image/jpg" ? "image/jpeg" : normalized
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function validatedMediaType(
|
|
191
|
+
bytes: Uint8Array,
|
|
192
|
+
declared: string | undefined,
|
|
193
|
+
toolName: string
|
|
194
|
+
): string {
|
|
195
|
+
const detected = sniffFileMediaType(bytes)
|
|
196
|
+
if (detected && declared && declared !== "application/octet-stream" && detected !== declared) {
|
|
197
|
+
throw toolFileError(
|
|
198
|
+
toolName,
|
|
199
|
+
`file bytes are ${detected}, not the declared media type ${declared}`
|
|
200
|
+
)
|
|
201
|
+
}
|
|
202
|
+
if (declared && SIGNATURE_REQUIRED_MEDIA_TYPES.has(declared) && detected !== declared) {
|
|
203
|
+
throw toolFileError(toolName, `file bytes do not match the declared media type ${declared}`)
|
|
204
|
+
}
|
|
205
|
+
return detected ?? declared ?? "application/octet-stream"
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const SIGNATURE_REQUIRED_MEDIA_TYPES = new Set([
|
|
209
|
+
"application/pdf",
|
|
210
|
+
"image/gif",
|
|
211
|
+
"image/jpeg",
|
|
212
|
+
"image/png",
|
|
213
|
+
"image/webp",
|
|
214
|
+
])
|
|
215
|
+
|
|
216
|
+
/** Where a tool's file goes in the context directory, as the agent names it. */
|
|
217
|
+
function toolFilePath(toolCallId: string, fileRef: FileRef, fileName: string): string {
|
|
218
|
+
const callKey = createHash("sha256").update(toolCallId).digest("hex").slice(0, 16)
|
|
219
|
+
const digestKey = fileRef.digest.slice("sha256:".length, "sha256:".length + 12)
|
|
220
|
+
return posix.join("tool-files", callKey, `${digestKey}-${fileName}`)
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function toolFileError(toolName: string, message: string): AgentToolPublicError {
|
|
224
|
+
return new AgentToolPublicError(`[SixbAgent] Agent tool '${toolName}' ${message}.`)
|
|
225
|
+
}
|